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.
iot/projects/WebMVC/wwwroot/pages/nodes.html

57 lines
2.0 KiB

<template>
<layout v-bind:title="title">
<div class="row overlay-wrapper">
<div class="col-md-2 col-sm-4 col-xs-6" v-for="item in nodes">
<div class="card">
<div class="card-header">
<h3 class="card-title">
<span v-if="item.isOnline" style="color:green;">{{item.name}}</span>
<span v-else style="color:red;">{{item.name}}</span>
</h3>
<div class="card-tools"><span data-toggle="tooltip" class="badge bg-green">{{item.count}}</span></div>
</div>
<router-link :to="{path:'/pages/node.html',query:{number:item.number}}" class="card-body" style="display: block; text-align: center;">
<img :src="config.baseUrl+item.image" style="margin: 0px auto; width: 64px;">
</router-link>
</div>
</div>
</div>
</layout>
</template>
<script>
export default {
data: function () {
return {
title: '节点列表',
url: '/IoTCenter/api/v1/node/getNodes',
nodes: [],
events: ['NodeEntityInserted', 'NodeEntityUpdated', 'NodeEntityDeleted']
}
},
mounted: function () {
this.subscribe();
this.load();
},
methods: {
load() {
var url = config.baseUrl + this.url;
var vm = this;
axios.post(url).then(function (response) {
vm.nodes = response.data;
});
},
subscribe() {
var vm = this;
subscribe(this.events, function (method, data) {
vm.load();
});
},
unsubscribe() {
this.unsubscribe(this.events);
}
},
beforeDestroy: function () {
unsubscribe();
}
}
</script>