mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 05:46:35 +00:00
Remove introduction card (#543)
* Remove introduction card * Extract ha-markdown component * Limit image width * Links in persistent notification should be blue
This commit is contained in:
parent
021ded76d1
commit
da5ae33bb3
@ -3,7 +3,6 @@
|
|||||||
<link rel='import' href='./ha-camera-card.html'>
|
<link rel='import' href='./ha-camera-card.html'>
|
||||||
<link rel='import' href='./ha-entities-card.html'>
|
<link rel='import' href='./ha-entities-card.html'>
|
||||||
<link rel='import' href='./ha-history_graph-card.html'>
|
<link rel='import' href='./ha-history_graph-card.html'>
|
||||||
<link rel='import' href='./ha-introduction-card.html'>
|
|
||||||
<link rel='import' href='./ha-media_player-card.html'>
|
<link rel='import' href='./ha-media_player-card.html'>
|
||||||
<link rel='import' href='./ha-weather-card.html'>
|
<link rel='import' href='./ha-weather-card.html'>
|
||||||
<link rel='import' href='./ha-persistent_notification-card.html'>
|
<link rel='import' href='./ha-persistent_notification-card.html'>
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
<link rel='import' href='../../bower_components/polymer/polymer-element.html'>
|
|
||||||
|
|
||||||
<link rel='import' href='../components/ha-card.html'>
|
|
||||||
|
|
||||||
<dom-module id='ha-introduction-card'>
|
|
||||||
<template>
|
|
||||||
<style>
|
|
||||||
:host {
|
|
||||||
@apply(--paper-font-body1);
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: var(--dark-primary-color);
|
|
||||||
}
|
|
||||||
ul {
|
|
||||||
margin: 8px;
|
|
||||||
padding-left: 16px;
|
|
||||||
}
|
|
||||||
li {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
padding: 0 16px 16px;
|
|
||||||
}
|
|
||||||
.install {
|
|
||||||
display: block;
|
|
||||||
line-height: 1.5em;
|
|
||||||
margin-top: 8px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<ha-card header="Welcome Home!">
|
|
||||||
<div class='content'>
|
|
||||||
<template is='dom-if' if='[[hass.demo]]'>
|
|
||||||
To install Home Assistant, run:<br />
|
|
||||||
<code class='install'>
|
|
||||||
pip3 install homeassistant<br />
|
|
||||||
hass --open-ui
|
|
||||||
</code>
|
|
||||||
</template>
|
|
||||||
Here are some resources to get you started.
|
|
||||||
<ul>
|
|
||||||
<template is='dom-if' if='[[hass.demo]]'>
|
|
||||||
<li><a href='https://home-assistant.io/getting-started/'>Home Assistant website</a></li>
|
|
||||||
<li><a href='https://home-assistant.io/getting-started/'>Installation instructions</a></li>
|
|
||||||
<li><a href='https://home-assistant.io/getting-started/troubleshooting/'>Troubleshooting your installation</a></li>
|
|
||||||
</template>
|
|
||||||
<li><a href='https://home-assistant.io/getting-started/configuration/' target='_blank'>
|
|
||||||
Configuring Home Assistant
|
|
||||||
</a></li>
|
|
||||||
<li><a href='https://home-assistant.io/components/' target='_blank'>
|
|
||||||
Available components
|
|
||||||
</a></li>
|
|
||||||
<li><a href='https://home-assistant.io/getting-started/troubleshooting-configuration/' target='_blank'>Troubleshooting your configuration</a></li>
|
|
||||||
<li><a href='https://home-assistant.io/help/' target='_blank'>
|
|
||||||
Ask the community for help
|
|
||||||
</a></li>
|
|
||||||
</ul>
|
|
||||||
<template is='dom-if' if='[[showHideInstruction]]'>
|
|
||||||
To remove this card, edit your config in
|
|
||||||
<code>configuration.yaml</code> and disable the
|
|
||||||
<code>introduction</code> component.
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</ha-card>
|
|
||||||
</template>
|
|
||||||
</dom-module>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
class HaIntroductionCard extends Polymer.Element {
|
|
||||||
static get is() { return 'ha-introduction-card'; }
|
|
||||||
static get properties() {
|
|
||||||
return {
|
|
||||||
hass: Object,
|
|
||||||
showHideInstruction: {
|
|
||||||
type: Boolean,
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
customElements.define(HaIntroductionCard.is, HaIntroductionCard);
|
|
||||||
</script>
|
|
@ -2,6 +2,7 @@
|
|||||||
<link rel='import' href='../../bower_components/paper-button/paper-button.html'>
|
<link rel='import' href='../../bower_components/paper-button/paper-button.html'>
|
||||||
|
|
||||||
<link rel='import' href='../components/ha-card.html'>
|
<link rel='import' href='../components/ha-card.html'>
|
||||||
|
<link rel='import' href='../components/ha-markdown.html'>
|
||||||
|
|
||||||
<dom-module id='ha-persistent_notification-card'>
|
<dom-module id='ha-persistent_notification-card'>
|
||||||
<template>
|
<template>
|
||||||
@ -9,12 +10,25 @@
|
|||||||
:host {
|
:host {
|
||||||
@apply(--paper-font-body1);
|
@apply(--paper-font-body1);
|
||||||
}
|
}
|
||||||
.content {
|
ha-markdown {
|
||||||
padding: 0 16px 16px;
|
display: block;
|
||||||
|
padding: 0 16px;
|
||||||
-ms-user-select: initial;
|
-ms-user-select: initial;
|
||||||
-webkit-user-select: initial;
|
-webkit-user-select: initial;
|
||||||
-moz-user-select: initial;
|
-moz-user-select: initial;
|
||||||
}
|
}
|
||||||
|
ha-markdown p:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
ha-markdown p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
ha-markdown a {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
ha-markdown img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
paper-button {
|
paper-button {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@ -22,7 +36,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<ha-card header='[[computeTitle(stateObj)]]'>
|
<ha-card header='[[computeTitle(stateObj)]]'>
|
||||||
<div id='pnContent' class='content'></div>
|
<ha-markdown content='[[stateObj.attributes.message]]'></ha-markdown>
|
||||||
<paper-button on-tap='dismissTap'>DISMISS</paper-button>
|
<paper-button on-tap='dismissTap'>DISMISS</paper-button>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
</template>
|
</template>
|
||||||
@ -35,44 +49,14 @@ class HaPersistentNotificationCard extends Polymer.Element {
|
|||||||
return {
|
return {
|
||||||
hass: Object,
|
hass: Object,
|
||||||
stateObj: Object,
|
stateObj: Object,
|
||||||
scriptLoaded: {
|
|
||||||
type: Number,
|
|
||||||
// 0 = not loaded, 1 = success, 2 = error
|
|
||||||
value: 0,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static get observers() {
|
|
||||||
return [
|
|
||||||
'computeContent(stateObj, scriptLoaded)',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
computeTitle(stateObj) {
|
computeTitle(stateObj) {
|
||||||
return (stateObj.attributes.title ||
|
return (stateObj.attributes.title ||
|
||||||
window.hassUtil.computeStateName(stateObj));
|
window.hassUtil.computeStateName(stateObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
computeContent(stateObj, scriptLoaded) {
|
|
||||||
if (scriptLoaded === 1) {
|
|
||||||
const converter = window.Markdown.getSanitizingConverter();
|
|
||||||
this.$.pnContent.innerHTML = converter.makeHtml(stateObj.attributes.message);
|
|
||||||
} else if (scriptLoaded === 2) {
|
|
||||||
this.$.pnContent.innerText = stateObj.attributes.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ready() {
|
|
||||||
super.ready();
|
|
||||||
|
|
||||||
Polymer.importHref(
|
|
||||||
'/static/pagedown-js.html',
|
|
||||||
() => { this.scriptLoaded = 1; },
|
|
||||||
() => { this.scriptLoaded = 2; },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
dismissTap(ev) {
|
dismissTap(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.hass.callApi('DELETE', 'states/' + this.stateObj.entity_id);
|
this.hass.callApi('DELETE', 'states/' + this.stateObj.entity_id);
|
||||||
|
@ -149,11 +149,6 @@
|
|||||||
return {
|
return {
|
||||||
hass: Object,
|
hass: Object,
|
||||||
|
|
||||||
showIntroduction: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: {
|
columns: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 2,
|
value: 2,
|
||||||
@ -175,14 +170,13 @@
|
|||||||
|
|
||||||
static get observers() {
|
static get observers() {
|
||||||
return [
|
return [
|
||||||
'updateCards(columns, states, showIntroduction, panelVisible, viewVisible, orderedGroups)',
|
'updateCards(columns, states, panelVisible, viewVisible, orderedGroups)',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCards(
|
updateCards(
|
||||||
columns,
|
columns,
|
||||||
states,
|
states,
|
||||||
showIntroduction,
|
|
||||||
panelVisible,
|
panelVisible,
|
||||||
viewVisible,
|
viewVisible,
|
||||||
orderedGroups
|
orderedGroups
|
||||||
@ -196,13 +190,13 @@
|
|||||||
() => {
|
() => {
|
||||||
// Things might have changed since it got scheduled.
|
// Things might have changed since it got scheduled.
|
||||||
if (this.panelVisible && this.viewVisible) {
|
if (this.panelVisible && this.viewVisible) {
|
||||||
this.cards = this.computeCards(columns, states, showIntroduction, orderedGroups);
|
this.cards = this.computeCards(columns, states, orderedGroups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
computeCards(columns, states, showIntroduction, orderedGroups) {
|
computeCards(columns, states, orderedGroups) {
|
||||||
const hass = this.hass;
|
const hass = this.hass;
|
||||||
|
|
||||||
const cards = {
|
const cards = {
|
||||||
@ -234,14 +228,6 @@
|
|||||||
return minIndex;
|
return minIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showIntroduction) {
|
|
||||||
cards.columns[getIndex(5)].push({
|
|
||||||
hass: hass,
|
|
||||||
cardType: 'introduction',
|
|
||||||
showHideInstruction: Object.keys(states).length > 0 && !window.HASS_DEMO,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function addEntitiesCard(name, entities, groupEntity) {
|
function addEntitiesCard(name, entities, groupEntity) {
|
||||||
if (entities.length === 0) return;
|
if (entities.length === 0) return;
|
||||||
|
|
||||||
|
48
src/components/ha-markdown.html
Normal file
48
src/components/ha-markdown.html
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<link rel='import' href='../../bower_components/polymer/polymer-element.html'>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
class HaMarkdown extends Polymer.Element {
|
||||||
|
static get is() { return 'ha-markdown'; }
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
content: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
scriptLoaded: {
|
||||||
|
type: Number,
|
||||||
|
// 0 = not loaded, 1 = success, 2 = error
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static get observers() {
|
||||||
|
return [
|
||||||
|
'updateContent(content, scriptLoaded)',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
updateContent(content, scriptLoaded) {
|
||||||
|
if (scriptLoaded === 1) {
|
||||||
|
const converter = window.Markdown.getSanitizingConverter();
|
||||||
|
this.innerHTML = converter.makeHtml(content);
|
||||||
|
} else if (scriptLoaded === 2) {
|
||||||
|
this.innerText = content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ready() {
|
||||||
|
super.ready();
|
||||||
|
|
||||||
|
Polymer.importHref(
|
||||||
|
'/static/pagedown-js.html',
|
||||||
|
() => { this.scriptLoaded = 1; },
|
||||||
|
() => { this.scriptLoaded = 2; },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
customElements.define(HaMarkdown.is, HaMarkdown);
|
||||||
|
</script>
|
@ -108,7 +108,6 @@
|
|||||||
>
|
>
|
||||||
<ha-cards
|
<ha-cards
|
||||||
data-view=''
|
data-view=''
|
||||||
show-introduction='[[computeShowIntroduction(currentView, introductionLoaded, viewStates)]]'
|
|
||||||
states='[[viewStates]]'
|
states='[[viewStates]]'
|
||||||
columns='[[_columns]]'
|
columns='[[_columns]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
@ -174,11 +173,6 @@
|
|||||||
value: 1,
|
value: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
introductionLoaded: {
|
|
||||||
type: Boolean,
|
|
||||||
computed: 'computeIntroductionLoaded(hass)',
|
|
||||||
},
|
|
||||||
|
|
||||||
locationName: {
|
locationName: {
|
||||||
type: String,
|
type: String,
|
||||||
value: '',
|
value: '',
|
||||||
@ -305,10 +299,6 @@
|
|||||||
return views && views.length > 0 ? 'Home Assistant' : locationName;
|
return views && views.length > 0 ? 'Home Assistant' : locationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
computeShowIntroduction(currentView, introductionLoaded, states) {
|
|
||||||
return currentView === '' && (introductionLoaded || Object.keys(states).length === 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
computeStateName(stateObj) {
|
computeStateName(stateObj) {
|
||||||
if (stateObj.entity_id === DEFAULT_VIEW_ENTITY_ID) {
|
if (stateObj.entity_id === DEFAULT_VIEW_ENTITY_ID) {
|
||||||
if (stateObj.attributes.friendly_name &&
|
if (stateObj.attributes.friendly_name &&
|
||||||
@ -324,10 +314,6 @@
|
|||||||
return window.hassUtil.computeLocationName(hass);
|
return window.hassUtil.computeLocationName(hass);
|
||||||
}
|
}
|
||||||
|
|
||||||
computeIntroductionLoaded(hass) {
|
|
||||||
return window.hassUtil.isComponentLoaded(hass, 'introduction');
|
|
||||||
}
|
|
||||||
|
|
||||||
hassChanged(hass) {
|
hassChanged(hass) {
|
||||||
if (!hass) return;
|
if (!hass) return;
|
||||||
var views = window.HAWS.extractViews(hass.states);
|
var views = window.HAWS.extractViews(hass.states);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user