mirror of
https://github.com/esphome/esphome.git
synced 2024-12-03 12:14:13 +01:00
added link from dashboard to web server, if configured (#556)
* added link from dashboard to web server, if configured * linter fixes * simplified integration lookup * included loaded_integration in storage json * included loaded_integration in storage json * fixed loaded_integrations plus linter changes * fixed comment: List Co-Authored-By: Otto Winter <otto@otto-winter.com> * return empty list Co-Authored-By: Otto Winter <otto@otto-winter.com> * convert to list Co-Authored-By: Otto Winter <otto@otto-winter.com> * default to empty list on missing loaded_integrations Co-Authored-By: Otto Winter <otto@otto-winter.com> * None check no longer needed Co-Authored-By: Otto Winter <otto@otto-winter.com> * None check no longer needed Co-Authored-By: Otto Winter <otto@otto-winter.com> * removed newline
This commit is contained in:
parent
edee28acf0
commit
bd6b9ff1da
4 changed files with 19 additions and 2 deletions
|
@ -201,6 +201,7 @@ CONF_LEVEL = 'level'
|
||||||
CONF_LG = 'lg'
|
CONF_LG = 'lg'
|
||||||
CONF_LIBRARIES = 'libraries'
|
CONF_LIBRARIES = 'libraries'
|
||||||
CONF_LIGHT = 'light'
|
CONF_LIGHT = 'light'
|
||||||
|
CONF_LOADED_INTEGRATIONS = 'loaded_integrations'
|
||||||
CONF_LOCAL = 'local'
|
CONF_LOCAL = 'local'
|
||||||
CONF_LOGGER = 'logger'
|
CONF_LOGGER = 'logger'
|
||||||
CONF_LOGS = 'logs'
|
CONF_LOGS = 'logs'
|
||||||
|
|
|
@ -430,6 +430,12 @@ class DashboardEntry(object):
|
||||||
def update_new(self):
|
def update_new(self):
|
||||||
return const.__version__
|
return const.__version__
|
||||||
|
|
||||||
|
@property
|
||||||
|
def loaded_integrations(self):
|
||||||
|
if self.storage is None:
|
||||||
|
return []
|
||||||
|
return self.storage.loaded_integrations
|
||||||
|
|
||||||
|
|
||||||
class MainRequestHandler(BaseHandler):
|
class MainRequestHandler(BaseHandler):
|
||||||
@authenticated
|
@authenticated
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">
|
<span class="card-title">
|
||||||
{{ escape(entry.name) }}
|
{{ escape(entry.name) }}
|
||||||
|
{% if 'web_server' in entry.loaded_integrations %}
|
||||||
|
<a href="http://{{ escape(entry.address) }}" target="_blank"><i class="material-icons icon-grey">launch</i></a>
|
||||||
|
{% end %}
|
||||||
<i class="material-icons right dropdown-trigger" data-target="dropdown-{{ i }}">more_vert</i>
|
<i class="material-icons right dropdown-trigger" data-target="dropdown-{{ i }}">more_vert</i>
|
||||||
</span>
|
</span>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -37,7 +37,7 @@ def trash_storage_path(base_path): # type: (str) -> str
|
||||||
class StorageJSON(object):
|
class StorageJSON(object):
|
||||||
def __init__(self, storage_version, name, esphome_version,
|
def __init__(self, storage_version, name, esphome_version,
|
||||||
src_version, arduino_version, address, esp_platform, board, build_path,
|
src_version, arduino_version, address, esp_platform, board, build_path,
|
||||||
firmware_bin_path):
|
firmware_bin_path, loaded_integrations):
|
||||||
# Version of the storage JSON schema
|
# Version of the storage JSON schema
|
||||||
assert storage_version is None or isinstance(storage_version, int)
|
assert storage_version is None or isinstance(storage_version, int)
|
||||||
self.storage_version = storage_version # type: int
|
self.storage_version = storage_version # type: int
|
||||||
|
@ -61,6 +61,9 @@ class StorageJSON(object):
|
||||||
self.build_path = build_path # type: str
|
self.build_path = build_path # type: str
|
||||||
# The absolute path to the firmware binary
|
# The absolute path to the firmware binary
|
||||||
self.firmware_bin_path = firmware_bin_path # type: str
|
self.firmware_bin_path = firmware_bin_path # type: str
|
||||||
|
# A list of strings of names of loaded integrations
|
||||||
|
self.loaded_integrations = loaded_integrations # type: List[str]
|
||||||
|
self.loaded_integrations.sort()
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
return {
|
return {
|
||||||
|
@ -74,6 +77,7 @@ class StorageJSON(object):
|
||||||
'board': self.board,
|
'board': self.board,
|
||||||
'build_path': self.build_path,
|
'build_path': self.build_path,
|
||||||
'firmware_bin_path': self.firmware_bin_path,
|
'firmware_bin_path': self.firmware_bin_path,
|
||||||
|
'loaded_integrations': self.loaded_integrations,
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
|
@ -97,6 +101,7 @@ class StorageJSON(object):
|
||||||
board=esph.board,
|
board=esph.board,
|
||||||
build_path=esph.build_path,
|
build_path=esph.build_path,
|
||||||
firmware_bin_path=esph.firmware_bin,
|
firmware_bin_path=esph.firmware_bin,
|
||||||
|
loaded_integrations=list(esph.loaded_integrations),
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -113,6 +118,7 @@ class StorageJSON(object):
|
||||||
board=board,
|
board=board,
|
||||||
build_path=None,
|
build_path=None,
|
||||||
firmware_bin_path=None,
|
firmware_bin_path=None,
|
||||||
|
loaded_integrations=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -130,9 +136,10 @@ class StorageJSON(object):
|
||||||
board = storage.get('board')
|
board = storage.get('board')
|
||||||
build_path = storage.get('build_path')
|
build_path = storage.get('build_path')
|
||||||
firmware_bin_path = storage.get('firmware_bin_path')
|
firmware_bin_path = storage.get('firmware_bin_path')
|
||||||
|
loaded_integrations = storage.get('loaded_integrations', [])
|
||||||
return StorageJSON(storage_version, name, esphome_version,
|
return StorageJSON(storage_version, name, esphome_version,
|
||||||
src_version, arduino_version, address, esp_platform, board, build_path,
|
src_version, arduino_version, address, esp_platform, board, build_path,
|
||||||
firmware_bin_path)
|
firmware_bin_path, loaded_integrations)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(path): # type: (str) -> Optional[StorageJSON]
|
def load(path): # type: (str) -> Optional[StorageJSON]
|
||||||
|
|
Loading…
Reference in a new issue