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.
117 lines
3.8 KiB
117 lines
3.8 KiB
var time = '1d';
|
|
if (WXInlinePlayer.isSupport()) {
|
|
WXInlinePlayer.init({
|
|
asmUrl: '/lib/WXInlinePlayer/prod.all.asm.combine.js',
|
|
wasmUrl: '/lib/WXInlinePlayer/prod.all.wasm.combine.js'
|
|
});
|
|
}
|
|
function getDeviceDataValue(device, name) {
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
if (data) {
|
|
return data['value'];
|
|
}
|
|
return null;
|
|
}
|
|
function getDeviceDataDescription(device, name) {
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
if (data) {
|
|
return data['description'];
|
|
}
|
|
return null;
|
|
}
|
|
function getDeviceDataUnit(device, name) {
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
if (data) {
|
|
return data['unit'];
|
|
}
|
|
return null;
|
|
}
|
|
function getDeviceData(device, name) {
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
if (data) {
|
|
return data['value'] + ' ' + data['unit'];
|
|
}
|
|
return null;
|
|
}
|
|
function getData(device, name) {
|
|
return Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
}
|
|
//devices
|
|
function parseModel(response) {
|
|
|
|
var html = new DOMParser().parseFromString(response.data, 'text/html');
|
|
|
|
var template = html.getElementsByTagName('template')[0].innerHTML;
|
|
|
|
var script = html.getElementsByTagName('script')[0].innerHTML;
|
|
|
|
var model = eval(script);
|
|
model.template = template;
|
|
|
|
return model;
|
|
}
|
|
Vue.component('iot-gateway', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/gateway.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-light', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/light.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-humiture', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/humiture.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-smoke', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/smoke.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-person', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/person.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-curtain', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/curtain.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-switch', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/switch.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-switch3', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/switch3.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-socket', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/socket.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-ir', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/ir.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-color-light', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/color-light.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-camera', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/camera.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
});
|
|
Vue.component('iot-serial-port', function (resolve, reject) {
|
|
axios.get("/pages/iot/device/serial-port.html").then(function (response) {
|
|
resolve(parseModel(response));
|
|
});
|
|
}); |