[Major] Remove virtual addresses, added action warning confirmation
This commit is contained in:
parent
a90ad2dfd1
commit
3e8876b2ee
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "strolch-wc-plc",
|
"name": "strolch-wc-plc",
|
||||||
"description": "Strolch PLC WebComponents",
|
"description": "Strolch PLC WebComponents",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"authors": ["Robert von Burg"],
|
"authors": ["Robert von Burg"],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"strolch",
|
"strolch",
|
||||||
|
|
|
@ -30,9 +30,15 @@
|
||||||
"stop": "Stoppen",
|
"stop": "Stoppen",
|
||||||
"reconfigure": "Neu Konfigurieren",
|
"reconfigure": "Neu Konfigurieren",
|
||||||
"info": "Info",
|
"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": {
|
"en": {
|
||||||
|
"confirmActionWarning": "Action Warning",
|
||||||
|
"confirmActionWarningMsg": "Sending commands can turn on actuators. Do you really want to execute this action?",
|
||||||
|
"lastUpdate": "Last Update",
|
||||||
"info": "Info",
|
"info": "Info",
|
||||||
"start": "Start",
|
"start": "Start",
|
||||||
"stop": "Stop",
|
"stop": "Stop",
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
localesPath: {
|
localesPath: {
|
||||||
type: String,
|
type: String,
|
||||||
value: './locales.json'
|
value: './locales.json'
|
||||||
|
},
|
||||||
|
warningConfirmed: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -77,7 +81,29 @@
|
||||||
|
|
||||||
onRequestError: function (e) {
|
onRequestError: function (e) {
|
||||||
this.fire("strolch-ajax-request-error", e.detail);
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<style is="custom-style" include="strolch-wc-plc-style">
|
<style is="custom-style" include="strolch-wc-plc-style">
|
||||||
.label {
|
.label {
|
||||||
min-width: 250px;
|
min-width: 300px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
<template is="dom-repeat" items="[[connection.parameters]]" as="param">
|
<template is="dom-repeat" items="[[connection.parameters]]" as="param">
|
||||||
<div class="g-flex-table-row">
|
<div class="g-flex-table-row">
|
||||||
<div class="g-flex-table-cell label">[[param.id]]</div>
|
<div class="g-flex-table-cell label" title="[[param.id]]">[[param.name]]</div>
|
||||||
<div class="g-flex-table-cell">[[param.value]]</div>
|
<div class="g-flex-table-cell">[[param.value]]</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<paper-card elevation="1">
|
<paper-card elevation="1">
|
||||||
<div class="header"><h3>[[device.name]]</h3></div>
|
<div class="header"><h3>[[device.description]]</h3></div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
|
||||||
<div class="g-row">
|
<div class="g-row">
|
||||||
|
@ -42,8 +42,10 @@
|
||||||
<template is="dom-repeat" items="[[addresses]]" as="address">
|
<template is="dom-repeat" items="[[addresses]]" as="address">
|
||||||
<div class="g-flex-table-row">
|
<div class="g-flex-table-row">
|
||||||
<div class="g-flex-table-cell address-field" title="[[address.id]]">
|
<div class="g-flex-table-cell address-field" title="[[address.id]]">
|
||||||
<div class="address">[[address.resource]] - [[address.action]]</div>
|
<div class="address">[[address.description]]</div>
|
||||||
<div class="hw-address">[[address.address]]</div>
|
<div class="hw-address"> [[address.resource]] - [[address.action]]
|
||||||
|
</div>
|
||||||
|
<div class="hw-address"> [[address.address]]</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="g-flex-table-cell address-field no-grow">
|
<div class="g-flex-table-cell address-field no-grow">
|
||||||
<template is="dom-if" if="[[isBoolean(address.valueType)]]">
|
<template is="dom-if" if="[[isBoolean(address.valueType)]]">
|
||||||
|
@ -251,6 +253,13 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
sendAddress: function (type, resource, action, value) {
|
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);
|
console.log("Sending " + type + " for " + resource + " - " + action + ": " + value);
|
||||||
this.$.ajaxPutAddress.body = {
|
this.$.ajaxPutAddress.body = {
|
||||||
type: type,
|
type: type,
|
||||||
|
|
|
@ -31,62 +31,21 @@
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
<style is="custom-style" include="strolch-wc-plc-style">
|
<style is="custom-style" include="strolch-wc-plc-style">
|
||||||
|
h2 {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
<p>[[localize('lastUpdate')]]: [[lastUpdate]]</p>
|
||||||
<paper-icon-button class="g-pull-right" icon="refresh" on-tap="_refresh"></paper-icon-button>
|
<paper-icon-button class="g-pull-right" icon="refresh" on-tap="_refresh"></paper-icon-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template is="dom-if" if="[[arrayFilled(virtualAddresses)]]">
|
|
||||||
<h2>[[localize('virtualAddresses')]]</h2>
|
|
||||||
<paper-card elevation="1">
|
|
||||||
<div class="card-content">
|
|
||||||
|
|
||||||
<div class="g-row">
|
|
||||||
<div class="g-12">
|
|
||||||
|
|
||||||
<template is="dom-repeat" items="[[virtualAddresses]]" as="address">
|
|
||||||
<div class="g-flex-table-row">
|
|
||||||
<div class="g-flex-table-cell address-field">
|
|
||||||
<div class="address">[[address.resource]] - [[address.action]]</div>
|
|
||||||
<div class="hw-address">[[address.address]]</div>
|
|
||||||
</div>
|
|
||||||
<div class="g-flex-table-cell no-grow value-cell">
|
|
||||||
|
|
||||||
<template is="dom-if" if="[[isBoolean(address.type)]]">
|
|
||||||
<paper-radio-group selected="{{address.value}}" attr-for-selected="name">
|
|
||||||
<paper-radio-button name="true">[[localize('on')]]
|
|
||||||
</paper-radio-button>
|
|
||||||
<paper-radio-button name="false">[[localize('off')]]
|
|
||||||
</paper-radio-button>
|
|
||||||
</paper-radio-group>
|
|
||||||
</template>
|
|
||||||
<template is="dom-if" if="[[isNumber(address.type)]]">
|
|
||||||
<paper-input class="value-input"
|
|
||||||
value="{{address.value}}"
|
|
||||||
no-label-float></paper-input>
|
|
||||||
</template>
|
|
||||||
<template is="dom-if" if="[[isString(address.type)]]">
|
|
||||||
<paper-input class="value-input"
|
|
||||||
value="{{address.value}}"
|
|
||||||
no-label-float></paper-input>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="g-flex-table-cell no-grow">
|
|
||||||
<paper-button raised on-tap="sendAddressNotification">[[localize('notify')]]
|
|
||||||
</paper-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</paper-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template is="dom-repeat" items="[[devicesByGroup]]" as="group">
|
<template is="dom-repeat" items="[[devicesByGroup]]" as="group">
|
||||||
|
|
||||||
<h2>[[group.name]]</h2>
|
<h2>[[group.name]]</h2>
|
||||||
|
@ -108,22 +67,6 @@
|
||||||
on-response="onGetDevicesResponse"
|
on-response="onGetDevicesResponse"
|
||||||
on-error="onRequestError"></iron-ajax>
|
on-error="onRequestError"></iron-ajax>
|
||||||
|
|
||||||
<iron-ajax id="ajaxGetVirtualAddresses"
|
|
||||||
url="[[baseRestPath]]/plc/addresses/virtual"
|
|
||||||
content-type="application/json"
|
|
||||||
handle-as="json"
|
|
||||||
method="GET"
|
|
||||||
on-response="onGetVirtualAddressesResponse"
|
|
||||||
on-error="onRequestError"></iron-ajax>
|
|
||||||
|
|
||||||
<iron-ajax id="ajaxPutAddress"
|
|
||||||
url="[[baseRestPath]]/plc/addresses"
|
|
||||||
content-type="application/json"
|
|
||||||
handle-as="json"
|
|
||||||
method="PUT"
|
|
||||||
on-response="_refresh"
|
|
||||||
on-error="onAjaxError"></iron-ajax>
|
|
||||||
|
|
||||||
<strolch-wc-ws-observer id="observerHandler" ws-path="[[wsObserverPath]]"></strolch-wc-ws-observer>
|
<strolch-wc-ws-observer id="observerHandler" ws-path="[[wsObserverPath]]"></strolch-wc-ws-observer>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
@ -137,6 +80,12 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
|
lastUpdate: {
|
||||||
|
type: String,
|
||||||
|
value: function () {
|
||||||
|
return Strolch.toLocalDateTime(new Date());
|
||||||
|
}
|
||||||
|
},
|
||||||
observerHandler: {
|
observerHandler: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: function () {
|
value: function () {
|
||||||
|
@ -147,10 +96,6 @@
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false
|
value: false
|
||||||
},
|
},
|
||||||
virtualAddresses: {
|
|
||||||
type: Array,
|
|
||||||
value: []
|
|
||||||
},
|
|
||||||
devicesByGroup: {
|
devicesByGroup: {
|
||||||
type: Array,
|
type: Array,
|
||||||
value: []
|
value: []
|
||||||
|
@ -166,39 +111,17 @@
|
||||||
/* Listeners */
|
/* Listeners */
|
||||||
onGetDevicesResponse: function (e) {
|
onGetDevicesResponse: function (e) {
|
||||||
this.devicesByGroup = e.detail.response.data;
|
this.devicesByGroup = e.detail.response.data;
|
||||||
},
|
this.lastUpdate = Strolch.toLocalDateTime(new Date());
|
||||||
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();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_refresh: function () {
|
_refresh: function () {
|
||||||
this.$.ajaxGetDevices.generateRequest();
|
this.$.ajaxGetDevices.generateRequest();
|
||||||
this.$.ajaxGetVirtualAddresses.generateRequest();
|
|
||||||
|
|
||||||
if (!this.registeredForUpdates) {
|
if (!this.registeredForUpdates) {
|
||||||
this.$.observerHandler.register("Resource", "PlcAddress", "strolch-wc-plc-logical-devices", true, this.handleUpdate.bind(this));
|
this.$.observerHandler.register("Resource", "PlcAddress", "strolch-wc-plc-logical-devices", true, this.handleUpdate.bind(this));
|
||||||
this.registeredForUpdates = true;
|
this.registeredForUpdates = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onAjaxError: function (e) {
|
|
||||||
this._refresh();
|
|
||||||
this.onRequestError(e);
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Lifecycle */
|
/* Lifecycle */
|
||||||
reload: function () {
|
reload: function () {
|
||||||
|
@ -210,6 +133,8 @@
|
||||||
for (var i = 0; i < elements.length; i++) {
|
for (var i = 0; i < elements.length; i++) {
|
||||||
this.observerHandler.notifyUpdate(objectType, type, elements[i].id, elements[i]);
|
this.observerHandler.notifyUpdate(objectType, type, elements[i].id, elements[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.lastUpdate = Strolch.toLocalDateTime(new Date());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue