Add available sounds to config view.

This commit is contained in:
René Köcher 2015-12-23 13:42:22 +01:00
parent 1557f53e1c
commit f5ae0d2c75
2 changed files with 35 additions and 3 deletions

View File

@ -27,6 +27,34 @@
<label for="node-input-priority"><i class="fa fa-star"></i> Priority</label>
<input type="text" id="node-input-priority" placeholder="0" style="width:50px;">
</div>
<div class="form-row">
<label for="node-input-sound"><i class="fa fa-bell"></i> Sound</label>
<select id="node-input-sound">
<option></option>
<option>pushover</option>
<option>bike</option>
<option>bugle</option>
<option>cashregister</option>
<option>classical</option>
<option>cosmic</option>
<option>falling</option>
<option>gamelan</option>
<option>incoming</option>
<option>intermission</option>
<option>magic</option>
<option>mechanical</option>
<option>pianobar</option>
<option>siren</option>
<option>spacealarm</option>
<option>tugboat</option>
<option>alien</option>
<option>climb</option>
<option>persistent</option>
<option>echo</option>
<option>updown</option>
<option>none</option>
</select>
</div>
<div class="form-row">
<label for="node-input-deviceid"><i class="fa fa-user"></i> User key</label>
<input type="text" id="node-input-deviceid">
@ -42,7 +70,8 @@
</div>
<div class="form-tips" id="node-tip">Tip: Leave title blank to set using <b>msg.topic</b>.<br/>
Leave device blank to send to all devices, or to set using <b>msg.device</b>.<br/>
Leave priority blank to set using <b>msg.priority</b>. Supports priorities 2, 1, 0, -1, and -2.</div>
Leave priority blank to set using <b>msg.priority</b>. Supports priorities 2, 1, 0, -1, and -2.<br/>
Leave sound blank to use the default, or set using <b>msg.sound</b>.</div>
</script>
<script type="text/x-red" data-help-name="pushover">
@ -60,7 +89,8 @@
name: {value:""},
device: {value:""},
title: {value:""},
priority: {value:0}
priority: {value:0},
sound: {value:""}
},
credentials: {
deviceid: {type:"text"},

View File

@ -24,6 +24,8 @@ module.exports = function(RED) {
this.title = n.title;
this.device = n.device;
this.priority = n.priority;
this.sound = n.sound;
if (this.sound === '') { this.sound = null; }
var credentials = this.credentials;
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
else { this.error("No Pushover api token set"); }
@ -45,7 +47,7 @@ module.exports = function(RED) {
var titl = this.title || msg.topic || "Node-RED";
var pri = this.priority || msg.priority || 0;
var dev = this.device || msg.device;
var sound = msg.sound || null;
var sound = this.sound || msg.sound || null;
if (isNaN(pri)) {pri=0;}
if (pri > 2) {pri = 2;}
if (pri < -2) {pri = -2;}