diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-10-27 11:13:49 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-10-27 11:14:52 +0200 |
commit | 1eea6c0ce8d5357204fb6248c0444e5495e1c191 (patch) | |
tree | 2050b6d9e32ca8193baeeb150d9f96752690cf28 | |
parent | bd4bf6ac9bafa8f1b80de37709eb64fb40c08c29 (diff) |
luci-base: add ui indicator when fallback theme is used
Add a ui indicator displaying error details when the configured theme
failed to load and the next available one is being used instead.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | modules/luci-base/ucode/runtime.uc | 1 | ||||
-rw-r--r-- | modules/luci-base/ucode/template/footer.ut | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/modules/luci-base/ucode/runtime.uc b/modules/luci-base/ucode/runtime.uc index a8b6812e74..d02d8dd667 100644 --- a/modules/luci-base/ucode/runtime.uc +++ b/modules/luci-base/ucode/runtime.uc @@ -137,6 +137,7 @@ export default function(env) { if (status !== true) { media = null; + self.env.media_error = status; for (let k, v in uci.get_all('luci', 'themes')) { if (substr(k, 0, 1) != '.') { diff --git a/modules/luci-base/ucode/template/footer.ut b/modules/luci-base/ucode/template/footer.ut index 22d4f136f0..d0978594f8 100644 --- a/modules/luci-base/ucode/template/footer.ut +++ b/modules/luci-base/ucode/template/footer.ut @@ -18,6 +18,25 @@ </script> {% endif %} +{% if (media_error): %} + <script type="text/javascript"> + L.require('ui').then(function(ui) { + ui.showIndicator('media_error', _('Theme fallback'), function(ev) { + ui.showModal(_('Error loading theme'), [ + E('p', [ + _('A fallback is used since the configured theme failed to load with the error below.') + ]), + E('hr'), + E('div', { 'style': 'white-space:pre-line' }, {{ sprintf('%J', trim(media_error)) }}), + E('div', { 'class': 'right' }, [ + E('button', { 'class': 'btn cbi-button', 'click': ui.hideModal }, _('Dismiss')) + ]) + ]); + }); + }); + </script> +{% endif %} + {% include(`themes/${theme}/footer`) %} <!-- Lua compatibility mode active: {{ lua_active ? 'yes' : 'no' }} --> |