Former-commit-id: 69c96f8748fa5ea018e4d1c489ab5b8ee0954ed5
Former-commit-id: 062b23287564eca3bfa9f75e29a612574baef008
1.0
wanggang 5 years ago
parent fd0a549385
commit 6db1c29b76

@ -138,6 +138,13 @@
<script src="~/lib/toastr/toastr.min.js"></script>
<script src="~/lib/jqcron/jqCron.js"></script>
<script src="~/lib/jqcron/jqCron.cn.js"></script>
<script>
var config = {
baseUrl : '@Url.Content("~")',
hubUrl : "@Url.Content("~")/hub?group=page"
};
</script>
<script src="~/js/signalr.js"></script>
@RenderSection("scripts", required: false)
<script src="~/js/site.js"></script>
</body>

@ -29,64 +29,5 @@
</table>
</div>
@section scripts{
<script>
$('a.ajax.api').click(function () {
if (confirm('确认操作编号为:' + $(this).attr('data-number') + '的设备吗?')) {
$.get($(this).attr('href'), function () {
window.location.href = window.location.href;
});
};
return false;
});
</script>
<script>
var config = {
baseUrl : '@Url.Content("~")',
hubUrl : "@Url.Content("~")/hub?group=page"
}
</script>
<script>
var app = new Vue({
el: '#app',
data() {
return {
title: "产品",
url: '@Url.Content("~/Home/IndexData")',
gateway: null,
events: ['IoTDeviceEntityInserted', 'IoTDeviceEntityUpdated', 'IoTDeviceEntityDeleted']
};
},
mounted: function () {
var vm = this;
PubSub.subscribe(this.events, function (method, data) {
this.load();
});
this.load();
},
beforeDestroy: function () {
PubSub.unsubscribe(this.events);
},
methods: {
load: function () {
var vm = this;
axios.post(this.url).then(function (response) {
vm.gateway = response.data;
});
},
upload: function () {
$.get('@Url.Action("Upload","Home")', function () {
this.load();
});
},
remove: function (gateway, number) {
if (confirm('确认操作编号为:' +'number' + '的设备吗?')) {
$.get('@Url.Content("~/Gateway/X95")' +'?gateway='+gateway+'&number='+number, function () {
this.load();
});
};
}
}
});
</script>
<script src="~/js/signalr.js"></script>
<script src="~/js/home/index.js"></script>
}

@ -0,0 +1,73 @@
//tools
$('a.ajax.api').click(function () {
if (confirm('确认操作编号为:' + $(this).attr('data-number') + '的设备吗?')) {
$.get($(this).attr('href'), function () {
window.location.href = window.location.href;
});
};
return false;
});
function subscribes(events, action) {
if (!events || !action) {
return;
}
for (var i = 0; i < events.length; i++) {
PubSub.subscribe(events[i], function (m, d) { action(m, d); });
}
}
function unsubscribes(events) {
if (!events) {
return;
}
for (var i = 0; i < events.length; i++) {
PubSub.unsubscribe(events[i]);
}
}
//
var app = new Vue({
el: '#app',
data() {
return {
title: "产品",
url: config.baseUrl + '/Home/IndexData',
gateway: null,
events: ['IoTDeviceEntityInserted', 'IoTDeviceEntityUpdated', 'IoTDeviceEntityDeleted']
};
},
mounted: function () {
this.subscribe();
this.load();
},
beforeDestroy: function () {
unsubscribes(this.events);
},
methods: {
subscribe: function () {
var app = this;
subscribes(this.events, function (method, data) {
app.load();
});
},
load: function () {
var app = this;
axios.post(this.url).then(function (response) {
app.gateway = response.data;
});
},
upload: function () {
$.get(config.baseUrl + 'Home/Upload', function () {
this.load();
});
},
remove: function (gateway, number) {
if (confirm('确认操作编号为:' + 'number' + '的设备吗?')) {
var app = this;
$.get(config.baseUrl + '/Gateway/X95")' + '?gateway=' + gateway + '&number=' + number, function () {
app.load();
});
};
}
}
});

@ -22,6 +22,7 @@ connection.on('Connected', function (id) {
});
connection.on("ServerToClient", function (method, message, to, from) {
console.log(method);
PubSub.publish(method, { message: message, to: to, from: from });
});
connect();
Loading…
Cancel
Save