Esempio n. 1
0
    def get(self, request, extra=None):
        """Serve the index view."""
        hass = request.app['hass']
        latest = _is_latest(self.js_option, request)

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        elif latest:
            panel_url = hass.data[DATA_PANELS][panel].webcomponent_url_latest
        else:
            panel_url = hass.data[DATA_PANELS][panel].webcomponent_url_es5

        no_auth = 'true'
        if hass.config.api.api_password and not is_trusted_ip(request):
            # do not try to auto connect on load
            no_auth = 'false'

        template = yield from hass.async_add_job(self.get_template, latest)

        resp = template.render(
            no_auth=no_auth,
            panel_url=panel_url,
            panels=hass.data[DATA_PANELS],
            dev_mode=self.repo_path is not None,
            theme_color=MANIFEST_JSON['theme_color'],
            extra_urls=hass.data[DATA_EXTRA_HTML_URL],
            latest=latest,
        )

        return web.Response(text=resp, content_type='text/html')
Esempio n. 2
0
    def get(self, request, extra=None):
        """Serve the index view."""
        hass = request.app['hass']
        latest = _is_latest(self.js_option, request)

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        elif latest:
            panel_url = hass.data[DATA_PANELS][panel].webcomponent_url_latest
        else:
            panel_url = hass.data[DATA_PANELS][panel].webcomponent_url_es5

        no_auth = 'true'
        if hass.config.api.api_password and not is_trusted_ip(request):
            # do not try to auto connect on load
            no_auth = 'false'

        template = yield from hass.async_add_job(self.get_template, latest)

        resp = template.render(
            no_auth=no_auth,
            panel_url=panel_url,
            panels=hass.data[DATA_PANELS],
            dev_mode=self.repo_path is not None,
            theme_color=MANIFEST_JSON['theme_color'],
            extra_urls=hass.data[DATA_EXTRA_HTML_URL],
            latest=latest,
        )

        return web.Response(text=resp, content_type='text/html')
Esempio n. 3
0
    def get(self, request, entity_id=None):
        """Serve the index view."""
        hass = request.app['hass']

        if entity_id is not None:
            state = hass.states.get(entity_id)

            if (not state or state.domain != 'group'
                    or not state.attributes.get(group.ATTR_VIEW)):
                return self.json_message('Entity not found', HTTP_NOT_FOUND)

        if request.app[KEY_DEVELOPMENT]:
            core_url = '/static/home-assistant-polymer/build/core.js'
            compatibility_url = \
                '/static/home-assistant-polymer/build/compatibility.js'
            ui_url = '/static/home-assistant-polymer/src/home-assistant.html'
        else:
            core_url = '/static/core-{}.js'.format(FINGERPRINTS['core.js'])
            compatibility_url = '/static/compatibility-{}.js'.format(
                FINGERPRINTS['compatibility.js'])
            ui_url = '/static/frontend-{}.html'.format(
                FINGERPRINTS['frontend.html'])

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        else:
            panel_url = hass.data[DATA_PANELS][panel]['url']

        no_auth = 'true'
        if hass.config.api.api_password:
            # require password if set
            no_auth = 'false'
            if is_trusted_ip(request):
                # bypass for trusted networks
                no_auth = 'true'

        icons_url = '/static/mdi-{}.html'.format(FINGERPRINTS['mdi.html'])
        template = yield from hass.loop.run_in_executor(
            None, self.templates.get_template, 'index.html')

        # pylint is wrong
        # pylint: disable=no-member
        # This is a jinja2 template, not a HA template so we call 'render'.
        resp = template.render(core_url=core_url,
                               ui_url=ui_url,
                               compatibility_url=compatibility_url,
                               no_auth=no_auth,
                               icons_url=icons_url,
                               icons=FINGERPRINTS['mdi.html'],
                               panel_url=panel_url,
                               panels=hass.data[DATA_PANELS])

        return web.Response(text=resp, content_type='text/html')
Esempio n. 4
0
    def get(self, request, entity_id=None):
        """Serve the index view."""
        hass = request.app['hass']

        if entity_id is not None:
            state = hass.states.get(entity_id)

            if (not state or state.domain != 'group' or
                    not state.attributes.get(group.ATTR_VIEW)):
                return self.json_message('Entity not found', HTTP_NOT_FOUND)

        if request.app[KEY_DEVELOPMENT]:
            core_url = '/static/home-assistant-polymer/build/core.js'
            compatibility_url = \
                '/static/home-assistant-polymer/build/compatibility.js'
            ui_url = '/static/home-assistant-polymer/src/home-assistant.html'
        else:
            core_url = '/static/core-{}.js'.format(
                FINGERPRINTS['core.js'])
            compatibility_url = '/static/compatibility-{}.js'.format(
                FINGERPRINTS['compatibility.js'])
            ui_url = '/static/frontend-{}.html'.format(
                FINGERPRINTS['frontend.html'])

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        else:
            panel_url = hass.data[DATA_PANELS][panel]['url']

        no_auth = 'true'
        if hass.config.api.api_password:
            # require password if set
            no_auth = 'false'
            if is_trusted_ip(request):
                # bypass for trusted networks
                no_auth = 'true'

        icons_url = '/static/mdi-{}.html'.format(FINGERPRINTS['mdi.html'])
        template = yield from hass.loop.run_in_executor(
            None, self.templates.get_template, 'index.html')

        # pylint is wrong
        # pylint: disable=no-member
        # This is a jinja2 template, not a HA template so we call 'render'.
        resp = template.render(
            core_url=core_url, ui_url=ui_url,
            compatibility_url=compatibility_url, no_auth=no_auth,
            icons_url=icons_url, icons=FINGERPRINTS['mdi.html'],
            panel_url=panel_url, panels=hass.data[DATA_PANELS])

        return web.Response(text=resp, content_type='text/html')
Esempio n. 5
0
    def get(self, request, extra=None):
        """Serve the index view."""
        hass = request.app['hass']

        if self.use_repo:
            core_url = '/home-assistant-polymer/build/core.js'
            compatibility_url = \
                '/home-assistant-polymer/build/compatibility.js'
            ui_url = '/home-assistant-polymer/src/home-assistant.html'
            icons_fp = ''
            icons_url = '/static/mdi.html'
        else:
            import hass_frontend
            core_url = '/static/core-{}.js'.format(
                hass_frontend.FINGERPRINTS['core.js'])
            compatibility_url = '/static/compatibility-{}.js'.format(
                hass_frontend.FINGERPRINTS['compatibility.js'])
            ui_url = '/static/frontend-{}.html'.format(
                hass_frontend.FINGERPRINTS['frontend.html'])
            icons_fp = '-{}'.format(hass_frontend.FINGERPRINTS['mdi.html'])
            icons_url = '/static/mdi{}.html'.format(icons_fp)

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        else:
            panel_url = hass.data[DATA_PANELS][panel].webcomponent_url

        no_auth = 'true'
        if hass.config.api.api_password and not is_trusted_ip(request):
            # do not try to auto connect on load
            no_auth = 'false'

        template = yield from hass.async_add_job(self.templates.get_template,
                                                 'index.html')

        # pylint is wrong
        # pylint: disable=no-member
        # This is a jinja2 template, not a HA template so we call 'render'.
        resp = template.render(core_url=core_url,
                               ui_url=ui_url,
                               compatibility_url=compatibility_url,
                               no_auth=no_auth,
                               icons_url=icons_url,
                               icons=icons_fp,
                               panel_url=panel_url,
                               panels=hass.data[DATA_PANELS],
                               dev_mode=self.use_repo,
                               theme_color=MANIFEST_JSON['theme_color'],
                               extra_urls=hass.data[DATA_EXTRA_HTML_URL])

        return web.Response(text=resp, content_type='text/html')
    def get(self, request, extra=None):
        """Serve the index view."""
        hass = request.app['hass']

        if request.app[KEY_DEVELOPMENT]:
            core_url = '/static/home-assistant-polymer/build/core.js'
            compatibility_url = \
                '/static/home-assistant-polymer/build/compatibility.js'
            ui_url = '/static/home-assistant-polymer/src/home-assistant.html'
        else:
            core_url = '/static/core-{}.js'.format(FINGERPRINTS['core.js'])
            compatibility_url = '/static/compatibility-{}.js'.format(
                FINGERPRINTS['compatibility.js'])
            ui_url = '/static/frontend-{}.html'.format(
                FINGERPRINTS['frontend.html'])

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        else:
            panel_url = hass.data[DATA_PANELS][panel]['url']

        no_auth = 'true'
        if hass.config.api.api_password:
            # require password if set
            no_auth = 'false'
            if is_trusted_ip(request):
                # bypass for trusted networks
                no_auth = 'true'

        icons_url = '/static/mdi-{}.html'.format(FINGERPRINTS['mdi.html'])
        template = yield from hass.async_add_job(self.templates.get_template,
                                                 'index.html')

        # pylint is wrong
        # pylint: disable=no-member
        # This is a jinja2 template, not a HA template so we call 'render'.
        resp = template.render(core_url=core_url,
                               ui_url=ui_url,
                               compatibility_url=compatibility_url,
                               no_auth=no_auth,
                               icons_url=icons_url,
                               icons=FINGERPRINTS['mdi.html'],
                               panel_url=panel_url,
                               panels=hass.data[DATA_PANELS],
                               dev_mode=request.app[KEY_DEVELOPMENT],
                               theme_color=MANIFEST_JSON['theme_color'],
                               extra_urls=hass.data[DATA_EXTRA_HTML_URL])

        return web.Response(text=resp, content_type='text/html')
Esempio n. 7
0
    def get(self, request, extra=None):
        """Serve the index view."""
        hass = request.app['hass']

        if self.use_repo:
            core_url = '/home-assistant-polymer/build/core.js'
            compatibility_url = \
                '/home-assistant-polymer/build/compatibility.js'
            ui_url = '/home-assistant-polymer/src/home-assistant.html'
            icons_fp = ''
            icons_url = '/static/mdi.html'
        else:
            import hass_frontend
            core_url = '/static/core-{}.js'.format(
                hass_frontend.FINGERPRINTS['core.js'])
            compatibility_url = '/static/compatibility-{}.js'.format(
                hass_frontend.FINGERPRINTS['compatibility.js'])
            ui_url = '/static/frontend-{}.html'.format(
                hass_frontend.FINGERPRINTS['frontend.html'])
            icons_fp = '-{}'.format(hass_frontend.FINGERPRINTS['mdi.html'])
            icons_url = '/static/mdi{}.html'.format(icons_fp)

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        else:
            panel_url = hass.data[DATA_PANELS][panel].webcomponent_url

        no_auth = 'true'
        if hass.config.api.api_password and not is_trusted_ip(request):
            # do not try to auto connect on load
            no_auth = 'false'

        template = yield from hass.async_add_job(
            self.templates.get_template, 'index.html')

        # pylint is wrong
        # pylint: disable=no-member
        # This is a jinja2 template, not a HA template so we call 'render'.
        resp = template.render(
            core_url=core_url, ui_url=ui_url,
            compatibility_url=compatibility_url, no_auth=no_auth,
            icons_url=icons_url, icons=icons_fp,
            panel_url=panel_url, panels=hass.data[DATA_PANELS],
            dev_mode=self.use_repo,
            theme_color=MANIFEST_JSON['theme_color'],
            extra_urls=hass.data[DATA_EXTRA_HTML_URL])

        return web.Response(text=resp, content_type='text/html')
Esempio n. 8
0
    def get(self, request, extra=None):
        """Serve the index view."""
        hass = request.app['hass']

        if request.app[KEY_DEVELOPMENT]:
            core_url = '/static/home-assistant-polymer/build/core.js'
            compatibility_url = \
                '/static/home-assistant-polymer/build/compatibility.js'
            ui_url = '/static/home-assistant-polymer/src/home-assistant.html'
        else:
            core_url = '/static/core-{}.js'.format(
                FINGERPRINTS['core.js'])
            compatibility_url = '/static/compatibility-{}.js'.format(
                FINGERPRINTS['compatibility.js'])
            ui_url = '/static/frontend-{}.html'.format(
                FINGERPRINTS['frontend.html'])

        if request.path == '/':
            panel = 'states'
        else:
            panel = request.path.split('/')[1]

        if panel == 'states':
            panel_url = ''
        else:
            panel_url = hass.data[DATA_PANELS][panel]['url']

        no_auth = 'true'
        if hass.config.api.api_password:
            # require password if set
            no_auth = 'false'
            if is_trusted_ip(request):
                # bypass for trusted networks
                no_auth = 'true'

        icons_url = '/static/mdi-{}.html'.format(FINGERPRINTS['mdi.html'])
        template = yield from hass.async_add_job(
            self.templates.get_template, 'index.html')

        # pylint is wrong
        # pylint: disable=no-member
        # This is a jinja2 template, not a HA template so we call 'render'.
        resp = template.render(
            core_url=core_url, ui_url=ui_url,
            compatibility_url=compatibility_url, no_auth=no_auth,
            icons_url=icons_url, icons=FINGERPRINTS['mdi.html'],
            panel_url=panel_url, panels=hass.data[DATA_PANELS],
            dev_mode=request.app[KEY_DEVELOPMENT],
            theme_color=MANIFEST_JSON['theme_color'],
            extra_urls=hass.data[DATA_EXTRA_HTML_URL])

        return web.Response(text=resp, content_type='text/html')