|
|
@ -1,123 +1,154 @@
|
|
|
|
var time = '1d';
|
|
|
|
Vue.prototype.getDeviceDataValue = function (device, name) {
|
|
|
|
if(window.WXInlinePlayer&&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();
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
return data['value'];
|
|
|
|
return data['value'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
function getDeviceDataDescription(device, name) {
|
|
|
|
|
|
|
|
|
|
|
|
Vue.prototype.getDeviceDataDescription = function (device, name) {
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
return data['description'];
|
|
|
|
return data['description'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getDeviceDataUnit(device, name) {
|
|
|
|
Vue.prototype.getDeviceDataUnit = function (device, name) {
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
return data['unit'];
|
|
|
|
return data['unit'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getDeviceData(device, name) {
|
|
|
|
Vue.prototype.getDeviceData = function (device, name) {
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
return data['value'] + ' ' + data['unit'];
|
|
|
|
return data['value'] + ' ' + data['unit'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getData(device, name) {
|
|
|
|
Vue.prototype.getData = function (device, name) {
|
|
|
|
return Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
return Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//devices
|
|
|
|
Vue.prototype.execApi = function (number, method, query) {
|
|
|
|
function parseModel(response) {
|
|
|
|
loading.show();
|
|
|
|
var html = new DOMParser().parseFromString(response.data, 'text/html');
|
|
|
|
axios.post(config.baseUrl + '/platform/api/v1/api/execApi', { connectionId, number, method, query })
|
|
|
|
var template = html.getElementsByTagName('template')[0].innerHTML;
|
|
|
|
.then(function (response) {
|
|
|
|
var script = html.getElementsByTagName('script')[0].innerHTML;
|
|
|
|
})
|
|
|
|
var model = eval(script);
|
|
|
|
.catch(function (error) {
|
|
|
|
model.template = template;
|
|
|
|
console.log(error);
|
|
|
|
return model;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
.finally(function () {
|
|
|
|
function urlContent(path) {
|
|
|
|
loading.hide();
|
|
|
|
if (!path.startsWith("/dfs/")) {
|
|
|
|
|
|
|
|
return baseUrl + path;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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.prototype.execScene = function (id) {
|
|
|
|
|
|
|
|
loading.show();
|
|
|
|
|
|
|
|
axios.post('/platform/api/v1/api/execScene', '"' + id + '"', { headers: { 'Content-Type': 'application/json;charset=UTF-8' } })
|
|
|
|
|
|
|
|
.then(function (response) {
|
|
|
|
|
|
|
|
console.log(response);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.finally(function () {
|
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Vue.component('iot-switch3', function (resolve, reject) {
|
|
|
|
}
|
|
|
|
axios.get(baseUrl+"/pages/iot/device/switch3.html").then(function (response) {
|
|
|
|
Vue.prototype.execOrganScene = function (id) {
|
|
|
|
resolve(parseModel(response));
|
|
|
|
loading.show();
|
|
|
|
});
|
|
|
|
axios.post('/platform/api/v1/api/execOrganScene', '"' + id + '"', { headers: { 'Content-Type': 'application/json;charset=UTF-8' } })
|
|
|
|
});
|
|
|
|
.then(function (response) {
|
|
|
|
Vue.component('iot-socket', function (resolve, reject) {
|
|
|
|
console.log(response);
|
|
|
|
axios.get(baseUrl+"/pages/iot/device/socket.html").then(function (response) {
|
|
|
|
})
|
|
|
|
resolve(parseModel(response));
|
|
|
|
.catch(function (error) {
|
|
|
|
});
|
|
|
|
console.log(error);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
Vue.component('iot-ir', function (resolve, reject) {
|
|
|
|
.finally(function () {
|
|
|
|
axios.get(baseUrl+"/pages/iot/device/ir.html").then(function (response) {
|
|
|
|
loading.hide();
|
|
|
|
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-door', function (resolve, reject) {
|
|
|
|
}
|
|
|
|
axios.get(baseUrl + "/pages/iot/device/door.html").then(function (response) {
|
|
|
|
//devices
|
|
|
|
resolve(parseModel(response));
|
|
|
|
var iotComponents = [
|
|
|
|
|
|
|
|
'gateway',
|
|
|
|
|
|
|
|
'light',
|
|
|
|
|
|
|
|
'humiture',
|
|
|
|
|
|
|
|
'smoke',
|
|
|
|
|
|
|
|
'person',
|
|
|
|
|
|
|
|
'curtain',
|
|
|
|
|
|
|
|
'switch',
|
|
|
|
|
|
|
|
'switch3',
|
|
|
|
|
|
|
|
'socket',
|
|
|
|
|
|
|
|
'ir',
|
|
|
|
|
|
|
|
'color-light',
|
|
|
|
|
|
|
|
'door',
|
|
|
|
|
|
|
|
'camera',
|
|
|
|
|
|
|
|
'serial-port',
|
|
|
|
|
|
|
|
'ir-command'
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
for (var i = 0; i < iotComponents.length; i++) {
|
|
|
|
|
|
|
|
var name = 'iot-' + iotComponents[i];
|
|
|
|
|
|
|
|
var url = "components/iot/" + iotComponents[i] + ".html";
|
|
|
|
|
|
|
|
vueComponent(name, url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var deviceInfo = [];
|
|
|
|
|
|
|
|
deviceInfo['网关'] = 'iot-gateway';
|
|
|
|
|
|
|
|
deviceInfo['光强检测器'] = 'iot-light';
|
|
|
|
|
|
|
|
deviceInfo['温湿度传感器'] = 'iot-humiture';
|
|
|
|
|
|
|
|
deviceInfo['烟雾报警器'] = 'iot-smoke';
|
|
|
|
|
|
|
|
deviceInfo['人体感应器'] = 'iot-person';
|
|
|
|
|
|
|
|
deviceInfo['窗帘电机'] = 'iot-curtain';
|
|
|
|
|
|
|
|
deviceInfo['一路开关'] = 'iot-switch';
|
|
|
|
|
|
|
|
deviceInfo['三路开关'] = 'iot-switch3';
|
|
|
|
|
|
|
|
deviceInfo['插座'] = 'iot-socket';
|
|
|
|
|
|
|
|
deviceInfo['智能插座'] = 'iot-socket';
|
|
|
|
|
|
|
|
deviceInfo['红外转发器'] = 'iot-ir';
|
|
|
|
|
|
|
|
deviceInfo['调色灯'] = 'iot-color-light';
|
|
|
|
|
|
|
|
deviceInfo['门锁'] = 'iot-door';
|
|
|
|
|
|
|
|
deviceInfo['摄像头'] = 'iot-camera';
|
|
|
|
|
|
|
|
deviceInfo['串口控制器'] = 'iot-serial-port';
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
function updateSelect(action, id, value) {
|
|
|
|
|
|
|
|
var select = $('select#' + id);
|
|
|
|
|
|
|
|
if (select.length) {
|
|
|
|
|
|
|
|
select.find("option[value!='']").remove();
|
|
|
|
|
|
|
|
select[0].dispatchEvent(new Event('change'));
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
|
|
|
var url = config.baseUrl + '/platform/IoTCenter/Ajax/' + action + '?parentId=' + value;
|
|
|
|
|
|
|
|
$.getJSON(url, function (data) {
|
|
|
|
|
|
|
|
$.each(data, function (i, v) {
|
|
|
|
|
|
|
|
select.append('<option value="' + v.value + '">' + v.text + '</option>');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Vue.component('iot-camera', function (resolve, reject) {
|
|
|
|
}
|
|
|
|
axios.get(baseUrl+"/pages/iot/device/camera.html").then(function (response) {
|
|
|
|
}
|
|
|
|
resolve(parseModel(response));
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('change', 'select#productId', function (e) {
|
|
|
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
|
|
|
updateSelect('getProductApiJson', 'apiId', value);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', 'select#nodeId', function (e) {
|
|
|
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
|
|
|
updateSelect('getDeviceJson', 'deviceId', value);
|
|
|
|
|
|
|
|
updateSelect('getCommandJson', 'commandId', value);
|
|
|
|
|
|
|
|
if ($(this).parents('form.GlobalSceneCommand').length === 0) {
|
|
|
|
|
|
|
|
updateSelect('getSceneJson', 'sceneId', value);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', 'select#deviceNodeId', function (e) {
|
|
|
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
|
|
|
updateSelect('getDeviceJson', 'deviceId', value);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Vue.component('iot-serial-port', function (resolve, reject) {
|
|
|
|
$(document).on('change', 'select#deviceId', function (e) {
|
|
|
|
axios.get(baseUrl+"/pages/iot/device/serial-port.html").then(function (response) {
|
|
|
|
var value = $(this).val();
|
|
|
|
resolve(parseModel(response));
|
|
|
|
updateSelect('getApiJson', 'apiId', value);
|
|
|
|
|
|
|
|
updateSelect('getDataJson', 'dataId', value);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', 'select#organId', function (e) {
|
|
|
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
|
|
|
updateSelect('GetOrganSceneJson', 'organSceneId', value);
|
|
|
|
|
|
|
|
updateSelect('GetOrganNodeJson', 'nodeId', value);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//$(document).on('change', 'select', function (e) {
|
|
|
|
|
|
|
|
// $(this).parents('form').find("button[type='submit']").click();
|
|
|
|
|
|
|
|
//});
|
|
|
|