update beta.102

TangShanKaiPing
wanggang 6 years ago
parent d824c7d0ad
commit 436f42b455

@ -20,7 +20,7 @@
<EmbeddedResource Include="wwwroot\**\*" Exclude="**\*.css" />
</ItemGroup><ItemGroup>
<None Remove="wwwroot\images\icon_tabbar.png" />
<None Remove="wwwroot\index - 复制.html" />
<None Remove="wwwroot\index2.html" />
<None Remove="wwwroot\lib\URI.js\URI.min.js" />
<None Remove="wwwroot\lib\weui\weui.min.js" />
<None Remove="wwwroot\weui.html" />

@ -1,29 +1,26 @@
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(../fonts/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'), local('MaterialIcons-Regular'), url(../fonts/MaterialIcons-Regular.woff2) format('woff2'), url(../fonts/MaterialIcons-Regular.woff) format('woff'), url(../fonts/MaterialIcons-Regular.ttf) format('truetype');
}
.c-home-menu-list col {
text-align: center;
}
.c-home-menu-list a {
display: block;
text-align: center;
color:#000;
}
.c-home-menu-list i {
font-size: 50px;
color:dodgerblue;
}
.field-validation-error, .field-validation-valid{
color:red;
display:inline-block;
height:20px;
padding-right:1px;
font-size:small;
}
.row{
text-align:center;
}
.block-strong .row .button {
margin: 5px auto 0 auto;
}
.text-align-center {
text-align: center;
}
.float-left{
float:left;
}
.float-right{
float:right;
}
.col{
text-align:center;
padding: 3px;
}

@ -19,17 +19,17 @@
<f7-app :params="f7params">
<f7-statusbar></f7-statusbar>
<f7-view id="main-view" main class="safe-areas">
<f7-page name="page-index" @page:beforein="init">
<f7-page name="page-index" :page-content="false" @page:beforein="init">
<f7-navbar>
<f7-nav-title>{{Title}}</f7-nav-title>
</f7-navbar>
<f7-toolbar tabbar labels bottom>
<f7-link tab-link="#tab-1" icon-ios="f7:chat" icon-md="f7:chat" text="消息"></f7-link>
<f7-link tab-link="#tab-2" icon-ios="f7:data" icon-md="f7:data" text="智慧教室" tab-link-active></f7-link>
<f7-link tab-link="#tab-3" icon-ios="f7:person" icon-md="f7:person" text="我的"></f7-link>
<f7-link tab-link="#tab-message" icon-ios="f7:chat" icon-md="f7:chat" text="消息"></f7-link>
<f7-link tab-link="#tab-nodes" icon-ios="f7:data" icon-md="f7:data" text="智慧教室" tab-link-active></f7-link>
<f7-link tab-link="#tab-user" icon-ios="f7:person" icon-md="f7:person" text="我的"></f7-link>
</f7-toolbar>
<f7-tabs>
<f7-tab id="tab-1" class="page-content">
<f7-tab id="tab-message" class="page-content">
<template v-for="message in Messages">
<template v-if="message&&message.Data.length">
<div class="block-title">{{message.DisplayName||message.Name}}</div>
@ -63,21 +63,17 @@
</template>
</template>
</f7-tab>
<f7-tab id="tab-2" class="page-content" tab-active>
<f7-block>
<f7-list>
<f7-list-item v-for="node in Nodes" :title="node.Name" :badge="node.Count" :link="'/node/'+node.Number+'/name/'+node.Name"></f7-list-item>
</f7-list>
</f7-block>
<f7-tab id="tab-nodes" class="page-content" tab-active>
<f7-list>
<f7-list-item v-for="node in Nodes" :title="node.Name" :badge="node.Count" :link="'/node/'+node.Number+'/name/'+node.Name"></f7-list-item>
</f7-list>
</f7-tab>
<f7-tab id="tab-3" class="page-content">
<f7-block>
<f7-list>
<f7-list-item title="用户名" :after="UserName"></f7-list-item>
<f7-list-item title="昵称" :after="NickName"></f7-list-item>
<f7-list-item link="/login/" title="注销"></f7-list-item>
</f7-list>
</f7-block>
<f7-tab id="tab-user" class="page-content">
<f7-list>
<f7-list-item title="用户名" :after="UserName"></f7-list-item>
<f7-list-item title="昵称" :after="NickName"></f7-list-item>
<f7-list-item link="/login/" title="注销"></f7-list-item>
</f7-list>
</f7-tab>
</f7-tabs>
</f7-view>
@ -148,8 +144,229 @@
<template id="page-node">
<f7-page>
<f7-navbar>
<f7-navbar :title="Name" back-link="Back"></f7-navbar>
<f7-navbar :title="Node.Name" back-link="Back"></f7-navbar>
</f7-navbar>
<template :v-if="Node.Sences.length">
<div class="block-title">场景</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="sence in _.orderBy(Node.Sences,['DisplayOrder','Name'])" v-on:click="callSence(sence.Id)">
<a href="javascript:;" class="button button-raised button-fill">{{sence.Name}}</a>
</div>
</div>
</div>
</template>
<template v-if="getDevices('检测器','监测器').length">
<div class="block-title">监测</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('检测器','监测器')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<div class="row" v-if="device.Name==='温湿度检测器'">
<div class="col">{{getData(device,"温度")}}</div>
<div class="col">{{getData(device,"湿度")}}</div>
</div>
<div class="row" v-else-if="device.Name==='二氧化碳监测器'">
<div class="col">{{getData(device,"二氧化碳")}}</div>
</div>
<div class="row" v-else-if="device.Name==='光强检测器'">
<div class="col">{{getData(device,"光照强度")}}</div>
</div>
<div class="row" v-else-if="device.Name==='粉尘检测器'">
<div class="col">{{getData(device,"粉尘")}}</div>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('感应器').length">
<div class="block-title">警报</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('感应器')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<div class="row">
<div class="col">{{getData(device,"状态")}}</div>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('主机').length">
<div class="block-title">主机</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('主机')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<div class="row">
<div class="col">{{getData(device,"计算机名")}}</div>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('AP').length">
<div class="block-title">无线AP</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('AP')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<div class="row">
<div class="col">{{getData(device,"连接数")}}</div>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('一路可调窗帘').length">
<div class="block-title">一路可调窗帘</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('一路可调窗帘')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<div class="row">
<div class="col">{{getData(device,"状态")}}</div>
</div>
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'21on')"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'23stop')"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'22off')"></a>
</div>
</div>
</div>
<div class="row">
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('一路可调窗帘','21on')"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('一路可调窗帘','23stop')"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('一路可调窗帘','22off')"></a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('计量开关').length">
<div class="block-title">计量开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('计量开关')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<template v-if="device.Name==='计量开关'">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'21on')" v-if="getData(device,'状态')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'22off')" v-else></a>
</div>
</template>
</div>
</div>
<div class="row">
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('计量开关','21on')">全开</a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('计量开关','22off')">全关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('一路照明开关').length">
<div class="block-title">一路开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('一路照明开关')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<template v-if="device.Name==='一路照明开关'">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'21on')" v-if="getData(device,'状态')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'22off')" v-else></a>
</div>
</template>
</div>
</div>
<div class="row">
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('一路照明开关','21on')">全开</a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('一路照明开关','22off')">全关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('二路灯开关').length">
<div class="block-title">二路灯开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('二路灯开关')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<template v-else-if="device.Name==='二路灯开关'">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'21on')">全开</a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'22off')">全关</a>
</div>
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'23l1on')" v-if="getData(device,'L1状态')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'24l1off')" v-else></a>
</div>
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'25l2on')" v-if="getData(device,'L2状态')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'26l2off')" v-else></a>
</div>
</template>
</div>
</div>
<div class="row">
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('二路灯开关','21on')">全开</a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('二路灯开关','22off')">全关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('三路照明开关').length">
<div class="block-title">三路照明开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-33 tablet-20 desktop-10" v-for="device in getDevices('三路照明开关')">
<a class="button button-raised">{{device.Name||device.DisplayName}}</a>
<template v-if="device.Name==='三路照明开关'">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'21on')">全开</a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'22off')">全关</a>
</div>
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'23on')" v-if="getData(device,'状态4')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'24off')" v-else></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'25on')" v-if="getData(device,'状态5')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'26off')" v-else></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'27on')" v-if="getData(device,'状态6')==='关'"></a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'28off')" v-else></a>
</div>
</template>
</div>
</div>
<div class="row">
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10"></div>
<div class="col-33 tablet-20 desktop-10">
<div class="row">
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('三路照明开关','21on')">全开</a>
<a class="button button-raised button-fill" href="javascript: ;" v-on:click="callAll('三路照明开关','22off')">全关</a>
</div>
</div>
</div>
</div>
</template>
</f7-page>
</template>
<script src="lib/mobile.detect/mobile-detect.min.js"></script>
@ -165,215 +382,5 @@
<script src="lib/dayjs/dayjs.min.js"></script>
<script src="lib/URI.js/URI.min.js"></script>
<script src="js/app.js"></script>
<!--<script>
function getJsonExt(url) {
console.log('send:' + url);
app.dialog.progress();
$.getJSON(url, function (result) {
console.log(result);
app.dialog.close();
if (result.code === 0) {
if (result.type === 0) {
if (result.format === 1) {
console.log('format/1/base64 jpeg image');
$('#callback .page-content .block').html('<img class="shot" src="' + result.data + '">');
}
else {
console.log('format/0/json object');
$('#callback .page-content .block').html(result.data);
}
app.popup.open('#callback');
}
}
else {
app.dialog.alert(result.message, "消息", function () {
setTimeout(function () { app.dialog.close(); }, 3000);
});
}
}).fail(function () {
console.log('error');
app.dialog.close();
});;
}
</script>
<script>
var baseUrl = localStorage.getItem('iotServer');
var wsUrl = baseUrl + "/hub?group=nodes";
var ajaxUrl = baseUrl + "/Home/GetNodes";
var $$ = Dom7;
var username = localStorage.getItem("username");
var server = localStorage.getItem("server");
var iotPageIndex = 1;
function init() {
Framework7.request.json(ajaxUrl, null, function (response) {
vm.model = response;
}, null, 'json');
}
</script>
<script>
const connection = new signalR.HubConnectionBuilder()
.withUrl(wsUrl)
.build();
function connect() {
if (connection && connection.connection.connectionState === 1) {
console.log('has connected');
}
else {
console.log('start connect to server:' + Date());
connection.start().then(function () {
console.log('signalR>start');
}).catch(function (err) {
console.error(err.toString());
setTimeout(connect, 10 * 1000);
});
}
}
connection.on("UpdateNode", (message) => {
var node = JSON.parse(message);
var oldNode = _.chain(vm.model).filter(o => o.Number === node.Number).first().value();
oldNode.Name = node.Name;
console.log('update:' + node.Name);
});
connection.on("UpdateDevice", (message) => {
var device = JSON.parse(message);
var update = false;
var node = _.chain(vm.model).filter(o => o.Number === device.Node.Number).first().value();
for (var i = 0; i < node.Devices.length; i++) {
if (node.Devices[i].Number == device.Number) {
update = true;
break;
}
}
if (update) {
node.Devices.splice(i, 1, device);
}
else {
node.Devices.push(device);
}
console.log('update:' + device.DisplayName);
vm.message = device;
});
connection.on("DeleteDevice", (message) => {
var number = message;
for (var i = 0; i < vm.model.length; i++) {
var node = vm.model[i];
for (var j = 0; j < node.Devices.length; j++) {
if (node.Devices[j].Number == number) {
node.Devices.splice(j, 1);
break;
}
}
}
console.log('delete:' + number);
});
connection.onclose(function () {
setTimeout(connect, 10 * 1000);
});
</script>
<script>
var app;
var vm = new Vue({
el: '#app',
data: {
model: [],
message: null,
node: null,
device: null,
UserName: localStorage.getItem('username'),
NickName: localStorage.getItem('nickName')
},
mounted: function () {
console.log('vue>mounted');
var os = new MobileDetect(navigator.userAgent).os();
var theme = os == "AndroidOS" ? "md" : "ios";
if (document.location.search.indexOf('theme=') >= 0) {
theme = document.location.search.split('theme=')[1].split('&')[0];
}
app = new Framework7({
root: '#app',
theme: theme,
routes: [
{
path: '(.*)',
async: function (routeTo, routeFrom, resolve, reject) {
resolve({ url: routeTo.url });
}
}
],
on: {
pageInit: function (page) {
console.log('f7>page init');
}
}
});
var mainView = app.views.create('.view-main', {
stackPages: true
});
init();
connect();
},
methods: {
sendSence: function (id) {
var url = baseUrl + '/Command/Sence/?node=' + this.model.Number + '&id=' + id;
getJsonExt(url);
},
getDeviceDataValue: function (device, dataName) {
if (device != null) {
var data = _.first(_.filter(device.Data, function (o) { return o.Name === dataName }));
if (data != null) {
if (data.Value) {
var value = data.Value;
if (data.Unit) {
value += " " + data.Unit;
}
if (data.Description) {
value += " " + data.Description;
}
return value;
}
else {
console.log('值为空:' + device.Name + '/' + dataName);
}
}
else {
console.log('无法找到:' + device.Name + '/' + dataName);
}
}
else {
console.log('无法找到:' + dataName);
}
return "";
}
}
});
</script>
<script>
$(document).on('click', 'a.popup-open.node', function () {
var id = $(this).attr('data-node-id');
vm.node = _.chain(vm.model).filter(function (o) { return o.Id == id; }).first().value();
});
$(document).on('click', 'a.popup-open.device', function () {
var id = $(this).attr('data-device-id');
vm.device = _.chain(vm.node.Devices).filter(function (o) { return o.Id == id; }).first().value();
});
$$('.node-popup').on('popup:open', function (e, popup) {
console.log('node popup open');
});
$$('.node-popup').on('popup:close', function (e, popup) {
console.log('node popup close');
});
$$('.device-popup').on('popup:open', function (e, popup) {
console.log('device popup open');
});
$$('.device-popup').on('popup:close', function (e, popup) {
console.log('device popup close');
});
</script>-->
</body>
</html>

@ -2,28 +2,28 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="theme-color" content="#2196f3">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<title>首页</title>
<link rel="stylesheet" href="lib/framework7/css/framework7.bundle.min.css">
<link rel="stylesheet" href="css/framework7-icons.css">
<link rel="stylesheet" href="css/app.css">
<title>首页</title>
</head>
<body>
<f7-view id="app">
<f7-app :params="f7params">
<f7-statusbar></f7-statusbar>
</f7-app>
<f7-view id="main-view" main class="safe-areas">
<f7-page>
<f7-navbar>
<f7-nav-title>科学技术学院</f7-nav-title>
</f7-navbar>
<div id="app">
<div class="view view-main view-init">
<div class="page page-current" data-page="index">
<div class="navbar">
<div class="navbar-inner">
<div class="left">
</div>
<div class="title sliding">科学技术学院</div>
<div class="right">
</div>
</div>
</div>
<div class="toolbar tabbar tabbar-labels toolbar-bottom">
<div class="toolbar-inner">
<a href="#tab-1" class="tab-link">
@ -117,8 +117,19 @@
</div>
</div>
</div>
</div>
<div class="page stacked" data-page="test">
<div class="navbar">
<div class="navbar-inner">
<div class="title">test</div>
<div class="right"></div>
</div>
</div>
<div class="page-content">
<div class="block-title">test</div>
</div>
</f7-view>
</div>
</div>
<div class="popup node-popup popup-tablet-fullscreen">
<div class="page">
<div class="navbar">
@ -283,226 +294,225 @@
</div>
</div>
</div>
</div>
<script src="lib/mobile.detect/mobile-detect.min.js"></script>
<script src="lib/lodash/lodash.min.js"></script>
<script src="lib/jquery/jquery.min.js"></script>
<script src="lib/framework7/js/framework7.bundle.min.js"></script>
<script src="lib/vue/vue.min.js"></script>
<script src="lib/framework7-vue/framework7-vue.bundle.min.js"></script>
<script src="lib/signalr/signalr.min.js"></script>
<script src="lib/dayjs/dayjs.min.js"></script>
<script src="lib/URI.js/URI.min.js"></script>
<script src="js/app.js"></script>
<!--<script>
function getJsonExt(url) {
console.log('send:' + url);
app.dialog.progress();
$.getJSON(url, function (result) {
console.log(result);
app.dialog.close();
if (result.code === 0) {
if (result.type === 0) {
if (result.format === 1) {
console.log('format/1/base64 jpeg image');
$('#callback .page-content .block').html('<img class="shot" src="' + result.data + '">');
}
else {
console.log('format/0/json object');
$('#callback .page-content .block').html(result.data);
}
app.popup.open('#callback');
</div>
<script src="lib/mobile.detect/mobile-detect.min.js"></script>
<script src="lib/lodash/lodash.min.js"></script>
<script src="lib/jquery/jquery.min.js"></script>
<script src="lib/framework7/js/framework7.bundle.min.js"></script>
<script src="lib/signalr/signalr.min.js"></script>
<script src="lib/vue/vue.min.js"></script>
<script src="lib/dayjs/dayjs.min.js"></script>
<script src="lib/URI.js/URI.min.js"></script>
<!--<script src="js/app.js"></script>-->
<script>
function getJsonExt(url) {
console.log('send:' + url);
app.dialog.progress();
$.getJSON(url, function (result) {
console.log(result);
app.dialog.close();
if (result.code === 0) {
if (result.type === 0) {
if (result.format === 1) {
console.log('format/1/base64 jpeg image');
$('#callback .page-content .block').html('<img class="shot" src="' + result.data + '">');
}
else {
console.log('format/0/json object');
$('#callback .page-content .block').html(result.data);
}
app.popup.open('#callback');
}
else {
app.dialog.alert(result.message, "消息", function () {
setTimeout(function () { app.dialog.close(); }, 3000);
});
}
}).fail(function () {
console.log('error');
app.dialog.close();
});;
}
</script>
<script>
var baseUrl = localStorage.getItem('iotServer');
var wsUrl = baseUrl + "/hub?group=nodes";
var ajaxUrl = baseUrl + "/Home/GetNodes";
var $$ = Dom7;
var username = localStorage.getItem("username");
var server = localStorage.getItem("server");
var iotPageIndex = 1;
function init() {
Framework7.request.json(ajaxUrl, null, function (response) {
vm.model = response;
}, null, 'json');
}
</script>
<script>
const connection = new signalR.HubConnectionBuilder()
.withUrl(wsUrl)
.build();
function connect() {
if (connection && connection.connection.connectionState === 1) {
console.log('has connected');
}
else {
console.log('start connect to server:' + Date());
connection.start().then(function () {
console.log('signalR>start');
}).catch(function (err) {
console.error(err.toString());
setTimeout(connect, 10 * 1000);
app.dialog.alert(result.message, "消息", function () {
setTimeout(function () { app.dialog.close(); }, 3000);
});
}
}).fail(function () {
console.log('error');
app.dialog.close();
});;
}
</script>
<script>
var baseUrl = localStorage.getItem('iotServer');
var wsUrl = baseUrl + "/hub?group=nodes";
var ajaxUrl = baseUrl + "/Home/GetNodes";
var $$ = Dom7;
var username = localStorage.getItem("username");
var server = localStorage.getItem("server");
var iotPageIndex = 1;
function init() {
Framework7.request.json(ajaxUrl, null, function (response) {
vm.model = response;
}, null, 'json');
}
</script>
<script>
const connection = new signalR.HubConnectionBuilder()
.withUrl(wsUrl)
.build();
function connect() {
if (connection && connection.connection.connectionState === 1) {
console.log('has connected');
}
connection.on("UpdateNode", (message) => {
var node = JSON.parse(message);
var oldNode = _.chain(vm.model).filter(o => o.Number === node.Number).first().value();
oldNode.Name = node.Name;
console.log('update:' + node.Name);
});
connection.on("UpdateDevice", (message) => {
var device = JSON.parse(message);
var update = false;
var node = _.chain(vm.model).filter(o => o.Number === device.Node.Number).first().value();
for (var i = 0; i < node.Devices.length; i++) {
if (node.Devices[i].Number == device.Number) {
update = true;
break;
}
}
if (update) {
node.Devices.splice(i, 1, device);
}
else {
node.Devices.push(device);
else {
console.log('start connect to server:' + Date());
connection.start().then(function () {
console.log('signalR>start');
}).catch(function (err) {
console.error(err.toString());
setTimeout(connect, 10 * 1000);
});
}
}
connection.on("UpdateNode", (message) => {
var node = JSON.parse(message);
var oldNode = _.chain(vm.model).filter(o => o.Number === node.Number).first().value();
oldNode.Name = node.Name;
console.log('update:' + node.Name);
});
connection.on("UpdateDevice", (message) => {
var device = JSON.parse(message);
var update = false;
var node = _.chain(vm.model).filter(o => o.Number === device.Node.Number).first().value();
for (var i = 0; i < node.Devices.length; i++) {
if (node.Devices[i].Number == device.Number) {
update = true;
break;
}
console.log('update:' + device.DisplayName);
vm.message = device;
});
connection.on("DeleteDevice", (message) => {
var number = message;
for (var i = 0; i < vm.model.length; i++) {
var node = vm.model[i];
for (var j = 0; j < node.Devices.length; j++) {
if (node.Devices[j].Number == number) {
node.Devices.splice(j, 1);
break;
}
}
if (update) {
node.Devices.splice(i, 1, device);
}
else {
node.Devices.push(device);
}
console.log('update:' + device.DisplayName);
vm.message = device;
});
connection.on("DeleteDevice", (message) => {
var number = message;
for (var i = 0; i < vm.model.length; i++) {
var node = vm.model[i];
for (var j = 0; j < node.Devices.length; j++) {
if (node.Devices[j].Number == number) {
node.Devices.splice(j, 1);
break;
}
}
console.log('delete:' + number);
});
connection.onclose(function () {
setTimeout(connect, 10 * 1000);
});
</script>
<script>
var app;
var vm = new Vue({
el: '#app',
data: {
model: [],
message: null,
node: null,
device: null,
UserName: localStorage.getItem('username'),
NickName: localStorage.getItem('nickName')
},
mounted: function () {
console.log('vue>mounted');
}
console.log('delete:' + number);
});
connection.onclose(function () {
setTimeout(connect, 10 * 1000);
});
</script>
<script>
var app;
var vm = new Vue({
el: '#app',
data: {
model: [],
message: null,
node: null,
device: null,
UserName: localStorage.getItem('username'),
NickName: localStorage.getItem('nickName')
},
mounted: function () {
console.log('vue>mounted');
var os = new MobileDetect(navigator.userAgent).os();
var theme = os == "AndroidOS" ? "md" : "ios";
var os = new MobileDetect(navigator.userAgent).os();
var theme = os == "AndroidOS" ? "md" : "ios";
if (document.location.search.indexOf('theme=') >= 0) {
theme = document.location.search.split('theme=')[1].split('&')[0];
}
app = new Framework7({
root: '#app',
theme: theme,
routes: [
{
path: '(.*)',
async: function (routeTo, routeFrom, resolve, reject) {
resolve({ url: routeTo.url });
}
if (document.location.search.indexOf('theme=') >= 0) {
theme = document.location.search.split('theme=')[1].split('&')[0];
}
app = new Framework7({
root: '#app',
theme: theme,
routes: [
{
path: '(.*)',
async: function (routeTo, routeFrom, resolve, reject) {
resolve({ url: routeTo.url });
}
],
on: {
pageInit: function (page) {
console.log('f7>page init');
}
],
on: {
pageInit: function (page) {
console.log('f7>page init');
}
}
});
var mainView = app.views.create('.view-main', {
stackPages: true
});
init();
connect();
}
});
var mainView = app.views.create('.view-main', {
stackPages: true
});
init();
connect();
},
methods: {
sendSence: function (id) {
var url = baseUrl + '/Command/Sence/?node=' + this.model.Number + '&id=' + id;
getJsonExt(url);
},
methods: {
sendSence: function (id) {
var url = baseUrl + '/Command/Sence/?node=' + this.model.Number + '&id=' + id;
getJsonExt(url);
},
getDeviceDataValue: function (device, dataName) {
if (device != null) {
getDeviceDataValue: function (device, dataName) {
if (device != null) {
var data = _.first(_.filter(device.Data, function (o) { return o.Name === dataName }));
if (data != null) {
var data = _.first(_.filter(device.Data, function (o) { return o.Name === dataName }));
if (data != null) {
if (data.Value) {
var value = data.Value;
if (data.Unit) {
value += " " + data.Unit;
}
if (data.Description) {
value += " " + data.Description;
}
return value;
if (data.Value) {
var value = data.Value;
if (data.Unit) {
value += " " + data.Unit;
}
else {
console.log('值为空:' + device.Name + '/' + dataName);
if (data.Description) {
value += " " + data.Description;
}
return value;
}
else {
console.log('无法找到' + device.Name + '/' + dataName);
console.log('值为空' + device.Name + '/' + dataName);
}
}
else {
console.log('无法找到:' + dataName);
console.log('无法找到:' + device.Name + '/' + dataName);
}
return "";
}
else {
console.log('无法找到:' + dataName);
}
return "";
}
});
</script>
<script>
$(document).on('click', 'a.popup-open.node', function () {
var id = $(this).attr('data-node-id');
vm.node = _.chain(vm.model).filter(function (o) { return o.Id == id; }).first().value();
});
$(document).on('click', 'a.popup-open.device', function () {
var id = $(this).attr('data-device-id');
vm.device = _.chain(vm.node.Devices).filter(function (o) { return o.Id == id; }).first().value();
});
$$('.node-popup').on('popup:open', function (e, popup) {
console.log('node popup open');
});
$$('.node-popup').on('popup:close', function (e, popup) {
console.log('node popup close');
});
$$('.device-popup').on('popup:open', function (e, popup) {
console.log('device popup open');
});
$$('.device-popup').on('popup:close', function (e, popup) {
console.log('device popup close');
});
</script>-->
}
});
</script>
<script>
$(document).on('click', 'a.popup-open.node', function () {
var id = $(this).attr('data-node-id');
vm.node = _.chain(vm.model).filter(function (o) { return o.Id == id; }).first().value();
});
$(document).on('click', 'a.popup-open.device', function () {
var id = $(this).attr('data-device-id');
vm.device = _.chain(vm.node.Devices).filter(function (o) { return o.Id == id; }).first().value();
});
$$('.node-popup').on('popup:open', function (e, popup) {
console.log('node popup open');
});
$$('.node-popup').on('popup:close', function (e, popup) {
console.log('node popup close');
});
$$('.device-popup').on('popup:open', function (e, popup) {
console.log('device popup open');
});
$$('.device-popup').on('popup:close', function (e, popup) {
console.log('device popup close');
});
</script>
</body>
</html>

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Information"

@ -1,4 +1,4 @@
version=1.0.0-beta.101
version=1.0.0-beta.102
server.host=127.0.0.1
server.port=8003
spring.thymeleaf.cache=false

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Information"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Information"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,3 @@
using System;
using System.Linq;
using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Jwt;
@ -7,6 +5,8 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using System;
using System.Linq;
namespace IoTCenter.Controllers
{
@ -45,13 +45,12 @@ namespace IoTCenter.Controllers
return View(model);
}
public IActionResult GetNode(Guid id)
public IActionResult GetNode(string number)
{
var model = this._nodeRepo.ReadOnlyTable()
.Include(o => o.Sences)
.Include(o => o.Devices).ThenInclude(o => o.Data)
.Include(o => o.Devices).ThenInclude(o => o.Apis).ThenInclude(o => o.Parameters)
.FirstOrDefault(o => o.Id == id);
.FirstOrDefault(o => o.Number == number);
return Json(model, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
}
}

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.101",
"version": "1.0.0-beta.102",
"Logging": {
"LogLevel": {
"Default": "Warning"

Loading…
Cancel
Save