var time = '1d'; if (WXInlinePlayer.isSupport()) { WXInlinePlayer.init({ asmUrl: baseUrl+'/lib/WXInlinePlayer/prod.all.asm.combine.js', wasmUrl: baseUrl +'/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(baseUrl+"/pages/iot/device/gateway.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-light', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/light.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-humiture', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/humiture.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-smoke', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/smoke.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-person', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/person.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-curtain', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/curtain.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-switch', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/switch.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-switch3', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/switch3.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-socket', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/socket.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-ir', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/ir.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-color-light', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/color-light.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-camera', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/camera.html").then(function (response) { resolve(parseModel(response)); }); }); Vue.component('iot-serial-port', function (resolve, reject) { axios.get(baseUrl+"/pages/iot/device/serial-port.html").then(function (response) { resolve(parseModel(response)); }); });