Add option to retrieve n amount of last lines from log. (#604)

* Add option to retrieve n amount of last lines from log.

* Move line logic to backend

* Review changes

* Review changes

* Only print text

* Use query params instead of url path to specify lines
This commit is contained in:
John Arild Berentsen 2017-11-17 07:07:03 +01:00 committed by Paulus Schoutsen
parent d79ae551b2
commit b15edbd4fd

View File

@ -16,16 +16,32 @@
margin: 0 auto; margin: 0 auto;
max-width: 600px; max-width: 600px;
} }
.device-picker {
padding-left: 24px;
padding-right: 24px;
padding-bottom: 24px;
}
</style> </style>
<ha-config-section is-wide='[[isWide]]'> <ha-config-section is-wide='[[isWide]]'>
<span slot='header'>OZW Log</span> <span slot='header'>OZW Log</span>
<paper-card> <paper-card>
<div class='help-text'> <div class='device-picker'>
<pre>[[ozwLogs]]</pre> <paper-input
</div> label="Number of last log lines."
<div class="card-actions"> type=number
<paper-button raised on-tap='refreshLog'>Refresh</paper-button> min=0
</div> max=1000
step=10
value={{numLogLines}}>
</paper-input>
</div>
<div class="card-actions">
<paper-button raised on-tap='refreshLog'>Refresh</paper-button>
</div>
<div class='help-text'>
<pre>[[ozwLogs]]</pre>
</div>
</paper-card> </paper-card>
</ha-config-section> </ha-config-section>
</template> </template>
@ -50,12 +66,17 @@ class OzwLog extends Polymer.Element {
type: String, type: String,
value: 'Refresh to pull log' value: 'Refresh to pull log'
}, },
numLogLines: {
type: Number,
value: 0
},
}; };
} }
refreshLog() { refreshLog() {
this.ozwLogs = 'Loading ozw log...'; this.ozwLogs = 'Loading ozw log...';
this.hass.callApi('GET', 'zwave/ozwlog') this.hass.callApi('GET', 'zwave/ozwlog?lines=' + this.numLogLines)
.then((info) => { .then((info) => {
this.ozwLogs = info; this.ozwLogs = info;
}); });