Template titles
This commit is contained in:
parent
b82da219ce
commit
fbf37fbdfd
@ -1863,8 +1863,15 @@ const AutoSettingsMixin = (SuperClass) => {
|
|||||||
return class AutoSettingsMixinClass extends SuperClass {
|
return class AutoSettingsMixinClass extends SuperClass {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
this.__currentTitle = undefined;
|
||||||
this._auto_settings_setup();
|
this._auto_settings_setup();
|
||||||
this.addEventListener("browser-mod-config-update", () => this._auto_settings_setup());
|
this.addEventListener("browser-mod-config-update", () => this._auto_settings_setup());
|
||||||
|
window.addEventListener("location-changed", () => {
|
||||||
|
this._updateTitle();
|
||||||
|
setTimeout(() => this._updateTitle(), 500);
|
||||||
|
setTimeout(() => this._updateTitle(), 1000);
|
||||||
|
setTimeout(() => this._updateTitle(), 5000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async _auto_settings_setup() {
|
async _auto_settings_setup() {
|
||||||
await this.connectionPromise;
|
await this.connectionPromise;
|
||||||
@ -1908,7 +1915,20 @@ const AutoSettingsMixin = (SuperClass) => {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
// Title template
|
// Title template
|
||||||
if (settings.titleTemplate !== undefined) ;
|
if (settings.titleTemplate !== undefined) {
|
||||||
|
(async () => {
|
||||||
|
if (this._titleTemplateSubscription) {
|
||||||
|
this._titleTemplateSubscription();
|
||||||
|
}
|
||||||
|
this._titleTemplateSubscription = undefined;
|
||||||
|
this._titleTemplateSubscription =
|
||||||
|
await this.connection.subscribeMessage(this._updateTitle.bind(this), {
|
||||||
|
type: "render_template",
|
||||||
|
template: settings.titleTemplate,
|
||||||
|
variables: {},
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
get _currentFavicon() {
|
get _currentFavicon() {
|
||||||
const link = document.head.querySelector("link[rel~='icon']");
|
const link = document.head.querySelector("link[rel~='icon']");
|
||||||
@ -1927,6 +1947,16 @@ const AutoSettingsMixin = (SuperClass) => {
|
|||||||
link.href = result;
|
link.href = result;
|
||||||
window.browser_mod.fireEvent("browser-mod-favicon-update");
|
window.browser_mod.fireEvent("browser-mod-favicon-update");
|
||||||
}
|
}
|
||||||
|
get _currentTitle() {
|
||||||
|
return this.__currentTitle;
|
||||||
|
}
|
||||||
|
_updateTitle(data = undefined) {
|
||||||
|
if (data)
|
||||||
|
this.__currentTitle = data.result;
|
||||||
|
if (this.__currentTitle)
|
||||||
|
document.title = this.__currentTitle;
|
||||||
|
window.browser_mod.fireEvent("browser-mod-favicon-update");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1967,12 +1997,13 @@ const AutoSettingsMixin = (SuperClass) => {
|
|||||||
X Framework
|
X Framework
|
||||||
x Save sidebar
|
x Save sidebar
|
||||||
x Kiosk mode
|
x Kiosk mode
|
||||||
- Default panel?
|
- Default panel
|
||||||
- Screensaver?
|
- Screensaver?
|
||||||
x Favicon templates
|
x Favicon templates
|
||||||
- Title templates
|
x Title templates
|
||||||
- Tweaks
|
- Tweaks
|
||||||
- Quickbar tweaks (ctrl+enter)?
|
- Quickbar tweaks (ctrl+enter)?
|
||||||
|
- Card-mod preload
|
||||||
- Video player?
|
- Video player?
|
||||||
- Media_seek
|
- Media_seek
|
||||||
- Screensavers
|
- Screensavers
|
||||||
|
@ -119,8 +119,9 @@ class BrowserModSettingsCard extends s {
|
|||||||
return $ `
|
return $ `
|
||||||
<ha-card header="Frontend settings" outlined>
|
<ha-card header="Frontend settings" outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<ha-alert alert-type="warning">
|
||||||
<p>
|
<p>
|
||||||
Please note: Those settings severely change the way the Home
|
Please note: The settings in this section severely change the way the Home
|
||||||
Assistant frontend works and looks. It is very easy to forget that
|
Assistant frontend works and looks. It is very easy to forget that
|
||||||
you made a setting here when you switch devices or user.
|
you made a setting here when you switch devices or user.
|
||||||
</p>
|
</p>
|
||||||
@ -130,6 +131,7 @@ class BrowserModSettingsCard extends s {
|
|||||||
caches. Failure to do so means you risk wasting a lot of peoples
|
caches. Failure to do so means you risk wasting a lot of peoples
|
||||||
time, and you will be severly and rightfully ridiculed.
|
time, and you will be severly and rightfully ridiculed.
|
||||||
</p>
|
</p>
|
||||||
|
</ha-alert>
|
||||||
<p>
|
<p>
|
||||||
Global settings are applied for all users and browsers.</br>
|
Global settings are applied for all users and browsers.</br>
|
||||||
User settings are applied to the current user and overrides any Global settings.</br>
|
User settings are applied to the current user and overrides any Global settings.</br>
|
||||||
@ -189,10 +191,32 @@ class BrowserModSettingsCard extends s {
|
|||||||
|
|
||||||
<div class="separator"></div>
|
<div class="separator"></div>
|
||||||
|
|
||||||
|
<ha-settings-row>
|
||||||
|
<span slot="heading">Title template</span>
|
||||||
|
${OVERRIDDEN("titleTemplate")}
|
||||||
|
</ha-settings-row>
|
||||||
|
<ha-code-editor
|
||||||
|
.hass=${this.hass}
|
||||||
|
.value=${current.titleTemplate}
|
||||||
|
@value-changed=${(ev) => {
|
||||||
|
const tpl = ev.detail.value || undefined;
|
||||||
|
window.browser_mod.set_setting("titleTemplate", tpl, level);
|
||||||
|
}}
|
||||||
|
></ha-code-editor>
|
||||||
|
<ha-settings-row>
|
||||||
|
<mwc-button
|
||||||
|
@click=${() => window.browser_mod.set_setting("titleTemplate", undefined, level)}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</mwc-button>
|
||||||
|
</ha-settings-row>
|
||||||
|
|
||||||
|
<div class="separator"></div>
|
||||||
|
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading">Hide Sidebar</span>
|
<span slot="heading">Hide Sidebar</span>
|
||||||
<span slot="description">Hide the sidebar and hamburger menu</span>
|
<span slot="description">Hide the sidebar and hamburger menu</span>
|
||||||
Currenty: ${DESC_BOOLEAN(current.hideSidebar)}
|
Currently: ${DESC_BOOLEAN(current.hideSidebar)}
|
||||||
${OVERRIDDEN("hideSidebar")}
|
${OVERRIDDEN("hideSidebar")}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
@ -218,7 +242,7 @@ class BrowserModSettingsCard extends s {
|
|||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading">Hide Header</span>
|
<span slot="heading">Hide Header</span>
|
||||||
<span slot="description">Hide the header on all pages</span>
|
<span slot="description">Hide the header on all pages</span>
|
||||||
Currenty: ${DESC_BOOLEAN(current.hideHeader)}
|
Currently: ${DESC_BOOLEAN(current.hideHeader)}
|
||||||
${OVERRIDDEN("hideHeader")}
|
${OVERRIDDEN("hideHeader")}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
@ -246,7 +270,7 @@ class BrowserModSettingsCard extends s {
|
|||||||
<span slot="description"
|
<span slot="description"
|
||||||
>Order and visibility of sidebar buttons</span
|
>Order and visibility of sidebar buttons</span
|
||||||
>
|
>
|
||||||
Currenty: ${DESC_SET_UNSET(current.sidebarPanelOrder)}
|
Currently: ${DESC_SET_UNSET(current.sidebarPanelOrder)}
|
||||||
${OVERRIDDEN("sidebarPanelOrder")}
|
${OVERRIDDEN("sidebarPanelOrder")}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
|
@ -27,8 +27,9 @@ class BrowserModSettingsCard extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<ha-card header="Frontend settings" outlined>
|
<ha-card header="Frontend settings" outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<ha-alert alert-type="warning">
|
||||||
<p>
|
<p>
|
||||||
Please note: Those settings severely change the way the Home
|
Please note: The settings in this section severely change the way the Home
|
||||||
Assistant frontend works and looks. It is very easy to forget that
|
Assistant frontend works and looks. It is very easy to forget that
|
||||||
you made a setting here when you switch devices or user.
|
you made a setting here when you switch devices or user.
|
||||||
</p>
|
</p>
|
||||||
@ -38,6 +39,7 @@ class BrowserModSettingsCard extends LitElement {
|
|||||||
caches. Failure to do so means you risk wasting a lot of peoples
|
caches. Failure to do so means you risk wasting a lot of peoples
|
||||||
time, and you will be severly and rightfully ridiculed.
|
time, and you will be severly and rightfully ridiculed.
|
||||||
</p>
|
</p>
|
||||||
|
</ha-alert>
|
||||||
<p>
|
<p>
|
||||||
Global settings are applied for all users and browsers.</br>
|
Global settings are applied for all users and browsers.</br>
|
||||||
User settings are applied to the current user and overrides any Global settings.</br>
|
User settings are applied to the current user and overrides any Global settings.</br>
|
||||||
@ -106,10 +108,33 @@ class BrowserModSettingsCard extends LitElement {
|
|||||||
|
|
||||||
<div class="separator"></div>
|
<div class="separator"></div>
|
||||||
|
|
||||||
|
<ha-settings-row>
|
||||||
|
<span slot="heading">Title template</span>
|
||||||
|
${OVERRIDDEN("titleTemplate")}
|
||||||
|
</ha-settings-row>
|
||||||
|
<ha-code-editor
|
||||||
|
.hass=${this.hass}
|
||||||
|
.value=${current.titleTemplate}
|
||||||
|
@value-changed=${(ev) => {
|
||||||
|
const tpl = ev.detail.value || undefined;
|
||||||
|
window.browser_mod.set_setting("titleTemplate", tpl, level);
|
||||||
|
}}
|
||||||
|
></ha-code-editor>
|
||||||
|
<ha-settings-row>
|
||||||
|
<mwc-button
|
||||||
|
@click=${() =>
|
||||||
|
window.browser_mod.set_setting("titleTemplate", undefined, level)}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</mwc-button>
|
||||||
|
</ha-settings-row>
|
||||||
|
|
||||||
|
<div class="separator"></div>
|
||||||
|
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading">Hide Sidebar</span>
|
<span slot="heading">Hide Sidebar</span>
|
||||||
<span slot="description">Hide the sidebar and hamburger menu</span>
|
<span slot="description">Hide the sidebar and hamburger menu</span>
|
||||||
Currenty: ${DESC_BOOLEAN(current.hideSidebar)}
|
Currently: ${DESC_BOOLEAN(current.hideSidebar)}
|
||||||
${OVERRIDDEN("hideSidebar")}
|
${OVERRIDDEN("hideSidebar")}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
@ -138,7 +163,7 @@ class BrowserModSettingsCard extends LitElement {
|
|||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading">Hide Header</span>
|
<span slot="heading">Hide Header</span>
|
||||||
<span slot="description">Hide the header on all pages</span>
|
<span slot="description">Hide the header on all pages</span>
|
||||||
Currenty: ${DESC_BOOLEAN(current.hideHeader)}
|
Currently: ${DESC_BOOLEAN(current.hideHeader)}
|
||||||
${OVERRIDDEN("hideHeader")}
|
${OVERRIDDEN("hideHeader")}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
@ -169,7 +194,7 @@ class BrowserModSettingsCard extends LitElement {
|
|||||||
<span slot="description"
|
<span slot="description"
|
||||||
>Order and visibility of sidebar buttons</span
|
>Order and visibility of sidebar buttons</span
|
||||||
>
|
>
|
||||||
Currenty: ${DESC_SET_UNSET(current.sidebarPanelOrder)}
|
Currently: ${DESC_SET_UNSET(current.sidebarPanelOrder)}
|
||||||
${OVERRIDDEN("sidebarPanelOrder")}
|
${OVERRIDDEN("sidebarPanelOrder")}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
|
@ -4,6 +4,7 @@ export const AutoSettingsMixin = (SuperClass) => {
|
|||||||
return class AutoSettingsMixinClass extends SuperClass {
|
return class AutoSettingsMixinClass extends SuperClass {
|
||||||
_faviconTemplateSubscription;
|
_faviconTemplateSubscription;
|
||||||
_titleTemplateSubscription;
|
_titleTemplateSubscription;
|
||||||
|
__currentTitle = undefined;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -12,6 +13,13 @@ export const AutoSettingsMixin = (SuperClass) => {
|
|||||||
this.addEventListener("browser-mod-config-update", () =>
|
this.addEventListener("browser-mod-config-update", () =>
|
||||||
this._auto_settings_setup()
|
this._auto_settings_setup()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
window.addEventListener("location-changed", () => {
|
||||||
|
this._updateTitle();
|
||||||
|
setTimeout(() => this._updateTitle(), 500);
|
||||||
|
setTimeout(() => this._updateTitle(), 1000);
|
||||||
|
setTimeout(() => this._updateTitle(), 5000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async _auto_settings_setup() {
|
async _auto_settings_setup() {
|
||||||
@ -72,6 +80,21 @@ export const AutoSettingsMixin = (SuperClass) => {
|
|||||||
|
|
||||||
// Title template
|
// Title template
|
||||||
if (settings.titleTemplate !== undefined) {
|
if (settings.titleTemplate !== undefined) {
|
||||||
|
(async () => {
|
||||||
|
if (this._titleTemplateSubscription) {
|
||||||
|
this._titleTemplateSubscription();
|
||||||
|
}
|
||||||
|
this._titleTemplateSubscription = undefined;
|
||||||
|
this._titleTemplateSubscription =
|
||||||
|
await this.connection.subscribeMessage(
|
||||||
|
this._updateTitle.bind(this),
|
||||||
|
{
|
||||||
|
type: "render_template",
|
||||||
|
template: settings.titleTemplate,
|
||||||
|
variables: {},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,5 +116,15 @@ export const AutoSettingsMixin = (SuperClass) => {
|
|||||||
link.href = result;
|
link.href = result;
|
||||||
window.browser_mod.fireEvent("browser-mod-favicon-update");
|
window.browser_mod.fireEvent("browser-mod-favicon-update");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get _currentTitle() {
|
||||||
|
return this.__currentTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateTitle(data = undefined) {
|
||||||
|
if (data) this.__currentTitle = data.result;
|
||||||
|
if (this.__currentTitle) document.title = this.__currentTitle;
|
||||||
|
window.browser_mod.fireEvent("browser-mod-favicon-update");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -53,12 +53,13 @@ import { AutoSettingsMixin } from "./auto-settings";
|
|||||||
X Framework
|
X Framework
|
||||||
x Save sidebar
|
x Save sidebar
|
||||||
x Kiosk mode
|
x Kiosk mode
|
||||||
- Default panel?
|
- Default panel
|
||||||
- Screensaver?
|
- Screensaver?
|
||||||
x Favicon templates
|
x Favicon templates
|
||||||
- Title templates
|
x Title templates
|
||||||
- Tweaks
|
- Tweaks
|
||||||
- Quickbar tweaks (ctrl+enter)?
|
- Quickbar tweaks (ctrl+enter)?
|
||||||
|
- Card-mod preload
|
||||||
- Video player?
|
- Video player?
|
||||||
- Media_seek
|
- Media_seek
|
||||||
- Screensavers
|
- Screensavers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user