You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.2 KiB
53 lines
2.2 KiB
function pages_iot_node() {
|
|
return Vue.component('pages_iot_node', function (resolve, reject) {
|
|
axios.get("/pages/iot/node.html").then(function (response) {
|
|
resolve({
|
|
template: response.data,
|
|
data() {
|
|
return {
|
|
url: '/IoTCenter/api/v1/node/getNode?number=' + this.$route.query.number
|
|
};
|
|
},
|
|
mounted: function () {
|
|
axios.post(this.url)
|
|
.then(function (response) {
|
|
store.commit('setNode', response.data);
|
|
$('title').text(response.data.name);
|
|
})
|
|
.catch(function (error) {
|
|
})
|
|
.finally(function () {
|
|
|
|
});
|
|
},
|
|
destroyed: function () {
|
|
store.commit('setNode', null);
|
|
},
|
|
methods: {
|
|
getDevices: function (name) {
|
|
return Enumerable.from(this.node.devices).where(function (o) { return o.name === name; }).toArray();
|
|
},
|
|
getDeviceDataAttr: function (number, name, attr) {
|
|
var device = Enumerable.from(this.node.devices).where(function (o) { return o.number === number; }).firstOrDefault();
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
if (data !== null) {
|
|
return data[attr];
|
|
}
|
|
return null;
|
|
},
|
|
getDataValue: function (number, name) {
|
|
return this.getDeviceDataAttr(number, name, 'value');
|
|
}
|
|
},
|
|
computed: {
|
|
node: function () {
|
|
return store.state.node;
|
|
},
|
|
scenes: function () {
|
|
return Enumerable.from(this.node.scenes).orderBy('o=>o.displayOrder').toArray();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
} |