Update dashboard to 20210617.0 (#1930)

This commit is contained in:
Paulus Schoutsen 2021-06-17 12:35:54 -07:00 committed by Jesse Hills
parent 59c192becc
commit 066c1022d0
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 14 additions and 16 deletions

View file

@ -716,9 +716,6 @@ class LogoutHandler(BaseHandler):
self.redirect("./login")
_STATIC_FILE_HASHES = {}
def get_base_frontend_path():
if ENV_DEV not in os.environ:
import esphome_dashboard
@ -741,19 +738,23 @@ def get_static_path(*args):
return os.path.join(get_base_frontend_path(), "static", *args)
@functools.lru_cache(maxsize=None)
def get_static_file_url(name):
base = f"./static/{name}"
if ENV_DEV in os.environ:
return base
# Module imports can't deduplicate if stuff added to url
if name == "js/esphome/index.js":
return f"./static/{name}"
import esphome_dashboard
return base.replace("index.js", esphome_dashboard.entrypoint())
if name in _STATIC_FILE_HASHES:
hash_ = _STATIC_FILE_HASHES[name]
else:
path = get_static_path(name)
with open(path, "rb") as f_handle:
hash_ = hashlib.md5(f_handle.read()).hexdigest()[:8]
_STATIC_FILE_HASHES[name] = hash_
return f"./static/{name}?hash={hash_}"
return f"{base}?hash={hash_}"
def make_app(debug=get_bool_env(ENV_DEV)):
@ -820,9 +821,6 @@ def make_app(debug=get_bool_env(ENV_DEV)):
**app_settings,
)
if debug:
_STATIC_FILE_HASHES.clear()
return app

View file

@ -11,4 +11,4 @@ ifaddr==0.1.7
platformio==5.1.1
esptool==2.8
click==7.1.2
esphome-dashboard==20210615.0
esphome-dashboard==20210617.1