142 lines
3.7 KiB
HTML
142 lines
3.7 KiB
HTML
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
|
<link rel="import" href="../../../bower_components/app-layout/app-header-layout/app-header-layout.html">
|
|
<link rel="import" href="../../../bower_components/app-layout/app-header/app-header.html">
|
|
<link rel="import" href="../../../bower_components/app-layout/app-toolbar/app-toolbar.html">
|
|
<link rel="import" href="../../../bower_components/paper-card/paper-card.html">
|
|
<link rel="import" href="../../../bower_components/paper-item/paper-item.html">
|
|
<link rel="import" href="../../../bower_components/paper-item/paper-item-body.html">
|
|
<link rel="import" href="../../../bower_components/paper-fab/paper-fab.html">
|
|
<link rel="import" href="../../../bower_components/paper-icon-button/paper-icon-button.html">
|
|
|
|
<link rel="import" href="../ha-config-section.html">
|
|
|
|
<dom-module id="ha-script-picker">
|
|
<template>
|
|
<style include="ha-style">
|
|
:host {
|
|
display: block;
|
|
}
|
|
|
|
paper-item {
|
|
cursor: pointer;
|
|
}
|
|
|
|
paper-fab {
|
|
position: fixed;
|
|
bottom: 16px;
|
|
right: 16px;
|
|
z-index: 1;
|
|
}
|
|
|
|
paper-fab[is-wide] {
|
|
bottom: 24px;
|
|
right: 24px;
|
|
}
|
|
|
|
a {
|
|
color: var(--primary-color);
|
|
}
|
|
</style>
|
|
|
|
<app-header-layout has-scrolling-region>
|
|
<app-header slot="header" fixed>
|
|
<app-toolbar>
|
|
<paper-icon-button
|
|
icon='mdi:arrow-left'
|
|
on-tap='_backTapped'
|
|
></paper-icon-button>
|
|
<div main-title>Scripts</div>
|
|
</app-toolbar>
|
|
</app-header>
|
|
|
|
<ha-config-section
|
|
is-wide='[[isWide]]'
|
|
>
|
|
<div slot='header'>Script Editor</div>
|
|
<div slot='introduction'>
|
|
The script editor allows you to create and edit scripts.
|
|
Please read <a href='https://home-assistant.io/docs/scripts/editor/' target='_blank'>the instructions</a> to make sure that you have configured Home Assistant correctly.
|
|
</div>
|
|
|
|
<paper-card heading='Pick script to edit'>
|
|
<template is='dom-if' if='[[!scripts.length]]'>
|
|
<div class='card-content'>
|
|
<p>We couldn't find any editable scripts.</p>
|
|
</div>
|
|
</template>
|
|
<template is='dom-repeat' items='[[scripts]]' as='script'>
|
|
<paper-item>
|
|
<paper-item-body two-line on-tap='scriptTapped'>
|
|
<div>[[computeName(script)]]</div>
|
|
<div secondary>[[computeDescription(script)]]</div>
|
|
</paper-item-body>
|
|
<iron-icon icon='mdi:chevron-right'></iron-icon>
|
|
</paper-item>
|
|
</template>
|
|
</paper-card>
|
|
</ha-config-section>
|
|
|
|
<paper-fab
|
|
is-wide$='[[isWide]]'
|
|
icon='mdi:plus'
|
|
title='Add Script'
|
|
on-tap='addScript'
|
|
></paper-fab>
|
|
</app-header-layout>
|
|
|
|
</template>
|
|
</dom-module>
|
|
|
|
<script>
|
|
Polymer({
|
|
is: 'ha-script-picker',
|
|
|
|
properties: {
|
|
hass: {
|
|
type: Object,
|
|
},
|
|
|
|
narrow: {
|
|
type: Boolean,
|
|
},
|
|
|
|
showMenu: {
|
|
type: Boolean,
|
|
value: false,
|
|
},
|
|
|
|
scripts: {
|
|
type: Array,
|
|
},
|
|
|
|
isWide: {
|
|
type: Boolean,
|
|
},
|
|
},
|
|
|
|
scriptTapped: function (ev) {
|
|
history.pushState(null, null, '/config/script/edit/' + this.scripts[ev.model.index].entity_id);
|
|
this.fire('location-changed');
|
|
},
|
|
|
|
addScript: function () {
|
|
history.pushState(null, null, '/config/script/new');
|
|
this.fire('location-changed');
|
|
},
|
|
|
|
computeName: function (script) {
|
|
return window.hassUtil.computeStateName(script);
|
|
},
|
|
|
|
// Still thinking of something to add here.
|
|
// eslint-disable-next-line
|
|
computeDescription: function (script) {
|
|
return '';
|
|
},
|
|
|
|
_backTapped: function () {
|
|
history.back();
|
|
},
|
|
});
|
|
</script>
|