diff --git a/bower.json b/bower.json index 4e10c8b..9feb366 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "strolch-wc-plc", "description": "Strolch PLC WebComponents", - "version": "0.1.0", + "version": "0.2.0", "authors": ["Robert von Burg"], "keywords": [ "strolch", diff --git a/locales.json b/locales.json index 563f130..0610b1e 100644 --- a/locales.json +++ b/locales.json @@ -30,9 +30,15 @@ "stop": "Stoppen", "reconfigure": "Neu Konfigurieren", "info": "Info", - "reconnect": "Wiederhestellen" + "reconnect": "Wiederhestellen", + "lastUpdate": "Letzte Aktualisierung", + "confirmActionWarning": "Aktionswarnung", + "confirmActionWarningMsg": "Beim Auslösen von Befehlen können Aktoren eingeschaltet werden. Wollen Sie diese Aktion wirklich ausführen?" }, "en": { + "confirmActionWarning": "Action Warning", + "confirmActionWarningMsg": "Sending commands can turn on actuators. Do you really want to execute this action?", + "lastUpdate": "Last Update", "info": "Info", "start": "Start", "stop": "Stop", diff --git a/strolch-wc-plc-behavior.html b/strolch-wc-plc-behavior.html index 750e85c..ae2f435 100644 --- a/strolch-wc-plc-behavior.html +++ b/strolch-wc-plc-behavior.html @@ -7,6 +7,10 @@ localesPath: { type: String, value: './locales.json' + }, + warningConfirmed: { + type: Boolean, + value: false } }, @@ -77,7 +81,29 @@ onRequestError: function (e) { this.fire("strolch-ajax-request-error", e.detail); - } + }, + confirmActionWarning: function (callback) { + var bound = callback.bind(this); + + if (this.warningConfirmed) { + bound(); + return; + } + + var confirmedCallback = function (confirmed) { + if (confirmed) { + this.warningConfirmed = true; + bound(); + } + }.bind(this); + + this.fire("cx-show-confirmation", { + title: this.localize('confirmActionWarning'), + text: this.localize('confirmActionWarningMsg'), + callback: confirmedCallback, + bind: this + }); + } } \ No newline at end of file diff --git a/strolch-wc-plc-connections.html b/strolch-wc-plc-connections.html index 3d26bd2..9b6835a 100644 --- a/strolch-wc-plc-connections.html +++ b/strolch-wc-plc-connections.html @@ -28,7 +28,7 @@ @@ -111,7 +111,7 @@ - [[param.id]] + [[param.name]] [[param.value]] diff --git a/strolch-wc-plc-logical-device.html b/strolch-wc-plc-logical-device.html index b75a0d5..95e3af6 100644 --- a/strolch-wc-plc-logical-device.html +++ b/strolch-wc-plc-logical-device.html @@ -33,7 +33,7 @@ - [[device.name]] + [[device.description]] @@ -42,8 +42,10 @@ - [[address.resource]] - [[address.action]] - [[address.address]] + [[address.description]] + [[address.resource]] - [[address.action]] + + [[address.address]] @@ -251,6 +253,13 @@ }, sendAddress: function (type, resource, action, value) { + this.confirmActionWarning(function () { + this._sendAddress(type, resource, action, value); + }); + }, + + _sendAddress: function (type, resource, action, value) { + console.log("Sending " + type + " for " + resource + " - " + action + ": " + value); this.$.ajaxPutAddress.body = { type: type, diff --git a/strolch-wc-plc-logical-devices.html b/strolch-wc-plc-logical-devices.html index 71f83b0..6c9822b 100644 --- a/strolch-wc-plc-logical-devices.html +++ b/strolch-wc-plc-logical-devices.html @@ -31,62 +31,21 @@ + [[localize('lastUpdate')]]: [[lastUpdate]] - - [[localize('virtualAddresses')]] - - - - - - - - - - [[address.resource]] - [[address.action]] - [[address.address]] - - - - - - [[localize('on')]] - - [[localize('off')]] - - - - - - - - - - - - - [[localize('notify')]] - - - - - - - - - - - [[group.name]] @@ -108,22 +67,6 @@ on-response="onGetDevicesResponse" on-error="onRequestError"> - - - - @@ -137,6 +80,12 @@ ], properties: { + lastUpdate: { + type: String, + value: function () { + return Strolch.toLocalDateTime(new Date()); + } + }, observerHandler: { type: Object, value: function () { @@ -147,10 +96,6 @@ type: Boolean, value: false }, - virtualAddresses: { - type: Array, - value: [] - }, devicesByGroup: { type: Array, value: [] @@ -166,39 +111,17 @@ /* Listeners */ onGetDevicesResponse: function (e) { this.devicesByGroup = e.detail.response.data; - }, - onGetVirtualAddressesResponse: function (e) { - this.virtualAddresses = e.detail.response.data; - }, - - sendAddressNotification: function (e) { - var a = e.model.address; - this.sendAddress("Notification", a.resource, a.action, a.value); - }, - sendAddress: function (type, resource, action, value) { - console.log("Sending " + type + " for " + resource + " - " + action + ": " + value); - this.$.ajaxPutAddress.body = { - type: type, - resource: resource, - action: action, - value: value - }; - this.$.ajaxPutAddress.generateRequest(); + this.lastUpdate = Strolch.toLocalDateTime(new Date()); }, _refresh: function () { this.$.ajaxGetDevices.generateRequest(); - this.$.ajaxGetVirtualAddresses.generateRequest(); if (!this.registeredForUpdates) { this.$.observerHandler.register("Resource", "PlcAddress", "strolch-wc-plc-logical-devices", true, this.handleUpdate.bind(this)); this.registeredForUpdates = true; } }, - onAjaxError: function (e) { - this._refresh(); - this.onRequestError(e); - }, /* Lifecycle */ reload: function () { @@ -210,6 +133,8 @@ for (var i = 0; i < elements.length; i++) { this.observerHandler.notifyUpdate(objectType, type, elements[i].id, elements[i]); } + + this.lastUpdate = Strolch.toLocalDateTime(new Date()); } });
[[localize('lastUpdate')]]: [[lastUpdate]]