diff --git a/src/components/ha-menu-button.js b/src/components/ha-menu-button.js
index ec44307ddd..6baf3efa42 100644
--- a/src/components/ha-menu-button.js
+++ b/src/components/ha-menu-button.js
@@ -10,12 +10,10 @@ import EventsMixin from '../mixins/events-mixin.js';
class HaMenuButton extends EventsMixin(PolymerElement) {
static get template() {
return html`
-
-
+
`;
}
@@ -38,13 +36,9 @@ class HaMenuButton extends EventsMixin(PolymerElement) {
};
}
- computeMenuButtonClass(narrow, showMenu) {
- return !narrow && showMenu ? 'invisible' : '';
- }
-
toggleMenu(ev) {
ev.stopPropagation();
- this.fire('hass-open-menu');
+ this.fire(this.showMenu ? 'hass-close-menu' : 'hass-open-menu');
}
_getIcon(hassio) {
diff --git a/src/components/ha-sidebar.js b/src/components/ha-sidebar.js
index 3982af53b8..988ba92825 100644
--- a/src/components/ha-sidebar.js
+++ b/src/components/ha-sidebar.js
@@ -9,15 +9,12 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '../components/ha-icon.js';
import '../util/hass-translation.js';
-import NavigateMixin from '../mixins/navigate-mixin.js';
import LocalizeMixin from '../mixins/localize-mixin.js';
/*
* @appliesMixin LocalizeMixin
- * @appliesMixin NavigateMixin
*/
-class HaSidebar extends
- LocalizeMixin(NavigateMixin(PolymerElement)) {
+class HaSidebar extends LocalizeMixin(PolymerElement) {
static get template() {
return html`
- Home Assistant
-
+ Home Assistant
+
+
+
+ [[_initials]]
+
+
-
-
- [[localize('panel.states')]]
-
+
+
+
+ [[localize('panel.states')]]
+
+
-
-
- [[computePanelName(localize, item)]]
-
+
+
+
+ [[_computePanelName(localize, item)]]
+
+
-
+
[[localize('ui.sidebar.log_out')]]
-
-
-
- [[_computeUserName(hass.user)]]
-
-
@@ -138,14 +158,54 @@ class HaSidebar extends
`;
@@ -168,9 +228,27 @@ class HaSidebar extends
computed: 'computePanels(hass)',
},
defaultPage: String,
+ _initials: {
+ type: String,
+ computed: '_computeUserInitials(hass.user.name)',
+ },
};
}
+ _computeUserInitials(name) {
+ if (!name) return 'user';
+ return name.trim()
+ // Split by space and take first 3 words
+ .split(' ').slice(0, 3)
+ // Of each word, take first letter
+ .map(s => s.substr(0, 1))
+ .join('');
+ }
+
+ _computeBadgeClass(initials) {
+ return `profile-badge ${initials.length > 2 ? 'long' : ''}`;
+ }
+
_mqttLoaded(hass) {
return hass.config.core.components.indexOf('mqtt') !== -1;
}
@@ -179,7 +257,7 @@ class HaSidebar extends
return user && (user.name || 'Unnamed User');
}
- computePanelName(localize, panel) {
+ _computePanelName(localize, panel) {
return localize(`panel.${panel.title}`) || panel.title;
}
@@ -222,45 +300,11 @@ class HaSidebar extends
return result;
}
- menuClicked(ev) {
- // Selection made inside dom-repeat
- if (ev.model) {
- this.selectPanel(ev.model.item.url_path);
- return;
- }
-
- let target = ev.target;
- let checks = 5;
- let attr;
-
- do {
- attr = target.getAttribute('data-panel');
- target = target.parentElement;
- checks--;
- } while (checks > 0 && target !== null && !attr);
-
- if (checks > 0 && target !== null) {
- this.selectPanel(attr);
- }
+ _computeUrl(urlPath) {
+ return `/${urlPath}`;
}
- toggleMenu() {
- this.fire('hass-close-menu');
- }
-
- selectPanel(newChoice) {
- if (newChoice === 'logout') {
- this.handleLogOut();
- return;
- }
- var path = '/' + newChoice;
- if (path === document.location.pathname) {
- return;
- }
- this.navigate(path);
- }
-
- handleLogOut() {
+ _handleLogOut() {
this.fire('hass-logout');
}
}
diff --git a/src/panels/profile/ha-change-password-card.js b/src/panels/profile/ha-change-password-card.js
index f9e9ae55ce..b841e630ed 100644
--- a/src/panels/profile/ha-change-password-card.js
+++ b/src/panels/profile/ha-change-password-card.js
@@ -40,7 +40,6 @@ class HaChangePasswordCard extends PolymerElement {
[[_statusMsg]]