Commit 1f638138 authored by van.chen's avatar van.chen

提交一下

parent 6cce3c71
...@@ -130,9 +130,9 @@ ...@@ -130,9 +130,9 @@
} }
}, },
"@angular/cdk": { "@angular/cdk": {
"version": "7.3.6", "version": "7.3.7",
"resolved": "http://registry.npm.taobao.org/@angular/cdk/download/@angular/cdk-7.3.6.tgz", "resolved": "http://registry.npm.taobao.org/@angular/cdk/download/@angular/cdk-7.3.7.tgz",
"integrity": "sha1-TDMMrNEd9K2t5sHNPtWHdF+ZEv0=", "integrity": "sha1-zhrVO6BL65yOlQrMVpHqAUN1N2Q=",
"requires": { "requires": {
"parse5": "^5.0.0", "parse5": "^5.0.0",
"tslib": "^1.7.1" "tslib": "^1.7.1"
......
...@@ -30,6 +30,8 @@ import {SensorDetailComponent} from '../main/sensor-detail/sensor-detail.compone ...@@ -30,6 +30,8 @@ import {SensorDetailComponent} from '../main/sensor-detail/sensor-detail.compone
import {ModuleDetailComponent} from '../main/module-detail/module-detail.component'; import {ModuleDetailComponent} from '../main/module-detail/module-detail.component';
import {TopicModuleDetailComponent} from '../main/topic-module-detail/topic-module-detail.component'; import {TopicModuleDetailComponent} from '../main/topic-module-detail/topic-module-detail.component';
import {TopicModuleWayComponent} from '../main/topic-module-way/topic-module-way.component'; import {TopicModuleWayComponent} from '../main/topic-module-way/topic-module-way.component';
import {InfluxdbComponent} from '../main/influxdb/influxdb.component';
import {SensorTopicWayComponent} from '../main/sensor-topic-way/sensor-topic-way.component';
// 通用组件 // 通用组件
import {SearchDateComponent} from '../component/search-date/search-date.component'; import {SearchDateComponent} from '../component/search-date/search-date.component';
import {SearchItemComponent} from '../component/search-item/search-item.component'; import {SearchItemComponent} from '../component/search-item/search-item.component';
...@@ -86,7 +88,9 @@ import {BackComponent} from '../component/back/back.component'; ...@@ -86,7 +88,9 @@ import {BackComponent} from '../component/back/back.component';
SensorDetailComponent, SensorDetailComponent,
ModuleDetailComponent, ModuleDetailComponent,
TopicModuleDetailComponent, TopicModuleDetailComponent,
TopicModuleWayComponent TopicModuleWayComponent,
InfluxdbComponent,
SensorTopicWayComponent
] ]
}) })
export class LayoutModule { export class LayoutModule {
......
...@@ -38,7 +38,7 @@ export class LeftmenuComponent implements OnInit, OnDestroy { ...@@ -38,7 +38,7 @@ export class LeftmenuComponent implements OnInit, OnDestroy {
name: 'systemMgr', name: 'systemMgr',
icon: 'io i-shezhi', icon: 'io i-shezhi',
type: 0, type: 0,
child: [{name: 'userCenter'}, {name: 'customCenter'}, {name: 'partMgr'}, {name: 'areaMgr'}, {name: 'logMgr'}] child: [{name: 'influxdbMgr'}, {name: 'userCenter'}, {name: 'customCenter'}, {name: 'partMgr'}, {name: 'areaMgr'}, {name: 'logMgr'}]
}, { }, {
name: 'dataCenter', name: 'dataCenter',
icon: 'io i-ico_data', icon: 'io i-ico_data',
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<nz-tabset> <nz-tabset>
<nz-tab nzTitle="传感器"> <nz-tab nzTitle="传感器">
<div class="subTitle"> <div class="subTitle">
{{'gateway' | translate}} 123456 {{'detail' | translate}} {{'gateway' | translate}} {{name}} {{'detail' | translate}}
</div> </div>
<nz-table #nzTable <nz-table #nzTable
[nzData]="data" [nzData]="deviceData"
[nzSize]="'middle'" [nzSize]="'middle'"
nzShowSizeChanger nzShowSizeChanger
[nzShowPagination]="true" [nzShowPagination]="true"
...@@ -16,34 +16,37 @@ ...@@ -16,34 +16,37 @@
<thead nz-thead> <thead nz-thead>
<tr> <tr>
<th nz-th><span>{{'sensorName' | translate}}</span></th> <th nz-th><span>{{'sensorName' | translate}}</span></th>
<th nz-th><span>{{'wayNum' | translate}}</span></th> <th nz-th><span>{{'sensorSN' | translate}}</span></th>
<th nz-th><span>{{'sensorType' | translate}}</span></th>
<th nz-th><span>{{'createTime' | translate}}</span></th> <th nz-th><span>{{'createTime' | translate}}</span></th>
<th nz-th><span>{{'oper' | translate}}</span></th> <th nz-th><span>{{'oper' | translate}}</span></th>
</tr> </tr>
</thead> </thead>
<tbody nz-tbody> <tbody nz-tbody>
<tr *ngFor="let one of nzTable.data, let i = index"> <tr *ngFor="let one of nzTable.data, let i = index">
<td nz-td class="canClick" (click)="toDetail(one)">{{i + 1}}</td> <td nz-td class="canClick" (click)="toDetail(one)">{{one.name}}</td>
<td nz-td>{{one.userName}}</td> <td nz-td>{{one.sn}}</td>
<td nz-td>{{one.realName}}</td> <td nz-td>{{one.type}}</td>
<td nz-td>{{i}}</td> <td nz-td>{{one.createTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
<td nz-td>
<span (click)="unbind(one)" class="deleteFontColor"> {{'unbind' | translate}}</span>
</td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
</nz-tab> </nz-tab>
<nz-tab nzTitle="通道"> <nz-tab nzTitle="通道">
<div class="subTitle"> <div class="subTitle">
{{'gateway' | translate}} 123456 {{'wayDetail' | translate}} {{'gateway' | translate}} {{name}} {{'wayDetail' | translate}}
</div> </div>
<nz-table #nzTable2 <nz-table #nzTable2
[nzData]="data" [nzData]="wayData"
[nzSize]="'middle'" [nzSize]="'middle'"
nzShowSizeChanger nzShowSizeChanger
[nzShowPagination]="true" [nzShowPagination]="true"
[nzLoading]="isLoading"> [nzLoading]="isLoading">
<thead nz-thead> <thead nz-thead>
<tr> <tr>
<th nz-th><span>{{'wayIndex' | translate}}</span></th>
<th nz-th><span>{{'sensorSN' | translate}}</span></th> <th nz-th><span>{{'sensorSN' | translate}}</span></th>
<th nz-th><span>{{'wayName' | translate}}</span></th> <th nz-th><span>{{'wayName' | translate}}</span></th>
<th nz-th><span>{{'wayAlias' | translate}}</span></th> <th nz-th><span>{{'wayAlias' | translate}}</span></th>
...@@ -55,26 +58,21 @@ ...@@ -55,26 +58,21 @@
<th nz-th><span>{{'alarmMaxMax' | translate}}</span></th> <th nz-th><span>{{'alarmMaxMax' | translate}}</span></th>
<th nz-th><span>{{'alarmMin' | translate}}</span></th> <th nz-th><span>{{'alarmMin' | translate}}</span></th>
<th nz-th><span>{{'alarmMinMin' | translate}}</span></th> <th nz-th><span>{{'alarmMinMin' | translate}}</span></th>
<th nz-th><span>{{'oper' | translate}}</span></th>
</tr> </tr>
</thead> </thead>
<tbody nz-tbody> <tbody nz-tbody>
<tr *ngFor="let one of nzTable2.data, let i = index"> <tr *ngFor="let one of nzTable2.data, let i = index">
<td nz-td>{{i + 1}}</td> <td nz-td>{{one.sn}}</td>
<td nz-td>{{one.userName}}</td> <td nz-td>{{one.name}}</td>
<td nz-td>{{one.realName}}</td> <td nz-td>{{one.alias}}</td>
<td nz-td>{{one.loginTime}}</td> <td nz-td>{{one.unit}}</td>
<td nz-td>{{'web'}}</td> <td nz-td>{{one.type}}</td>
<td nz-td>{{one.userName}}</td> <td nz-td>{{one.rangeMax}}</td>
<td nz-td>{{one.realName}}</td> <td nz-td>{{one.rangeMin}}</td>
<td nz-td>{{one.loginTime}}</td> <td nz-td>{{one.alarmUp}}</td>
<td nz-td>{{'web'}}</td> <td nz-td>{{one.alarmDown}}</td>
<td nz-td>{{one.userName}}</td> <td nz-td>{{one.upperAlarmLimit}}</td>
<td nz-td>{{one.realName}}</td> <td nz-td>{{one.lowerAlarmLimit}}</td>
<td nz-td>{{one.loginTime}}</td>
<td nz-td>
<span class="deleteFontColor">{{'delete' | translate}}</span>
</td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {ApiService} from '../../service/api'; import {ApiService} from '../../service/api';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {TranslateService} from '@ngx-translate/core';
@Component({ @Component({
selector: 'app-gateway-see', selector: 'app-gateway-see',
...@@ -14,33 +15,72 @@ export class GatewaySeeComponent implements OnInit { ...@@ -14,33 +15,72 @@ export class GatewaySeeComponent implements OnInit {
isLoading = false; isLoading = false;
data = []; data = [];
constructor(private api: ApiService, private message: NzMessageService, private router: Router) { } deviceNo = '';
name = '';
wayData = [];
deviceData = [];
constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) { }
ngOnInit() { ngOnInit() {
this.init(); this.init();
} }
init() { init() {
this.getData(); this.ac.queryParams.subscribe((e) => {
this.deviceNo = e.deviceNo;
this.name = e.name;
this.getDeviceData();
this.getWayData();
});
} }
next = (data) => { next = (data) => {
if (data && data.constructor === Array) { if (data && data.constructor === Array) {
this.data = data; this.deviceData = data;
} else if (data.code === 1) { } else if (data.code === 1) {
this.message.success(data && data.message ? data.message : '操作成功'); this.message.success(data && data.message ? data.message : '操作成功');
this.getDeviceData();
this.getWayData();
} else if (data.code === 0) { } else if (data.code === 0) {
this.message.error(data && data.message ? data.message : '操作失败'); this.message.error(data && data.message ? data.message : '操作失败');
} else { } else {
this.message.error(data && data.message ? data.message : '获取数据失败'); this.message.error(data && data.message ? data.message : '获取数据失败');
} }
this.isLoading = false;
} }
getData() { getDeviceData() {
this.api.role.getAll(['', this.next]); this.isLoading = true;
this.api.device.getSensorByMaxDevice([{deviceNo: this.deviceNo}, this.next]);
} }
toDetail() { getWayData() {
this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail']); this.isLoading = true;
this.api.probes.getProbesByGateway([{deviceNo: this.deviceNo}, (data) => {
if (data && data.constructor === Array) {
this.wayData = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
toDetail(one) {
this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail'], {queryParams: {deviceNo: one.deviceNo, name: one.name}});
}
unbind(one) {
this.modalService.confirm({
nzTitle : '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmUnbindThisRecord') + '</b>',
nzOnOk : () => this.unbindOne(one)
});
}
unbindOne(one) {
this.isLoading = true;
this.api.device.unBindDevice([{deviceNo: one.deviceNo}, this.next]);
} }
} }
This diff is collapsed.
...@@ -28,20 +28,26 @@ export class GatewayComponent implements OnInit { ...@@ -28,20 +28,26 @@ export class GatewayComponent implements OnInit {
isLoading = false; isLoading = false;
isAllCheck = false; isAllCheck = false;
isIndeterminate = false; isIndeterminate = false;
page = 1; listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
rows = 10;
total = 125;
listOfBind = [{text: '全部', value: 1}, {text: '已绑定', value: 2}, {text: '未绑定', value: 3}];
selectedOne: any = {}; selectedOne: any = {};
isAddConV = false; isAddConV = false;
isMultiAddConV = false; isMultiAddConV = false;
isUpdate = false;
isBindConV = false; isBindConV = false;
isDivideConV = false;
isMulti = false; isMulti = false;
canbind = false; canbind = false;
canUnbind = false; canUnbind = false;
isCheckedOne = false; isCheckedOne = false;
isUpdateConV = false; req: any = {};
isDivideConV = false; companys = [];
influxdbs = [];
filterFlag = null;
selectedGateways = [];
canBindGateways = [];
req3: any = {};
scenes = [{sceneNo: '123', sceneName: 'qq'}];
req4: any = {};
constructor(private api: ApiService, private message: NzMessageService, private router: Router, constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private modalService: NzModalService, private translate: TranslateService) { private modalService: NzModalService, private translate: TranslateService) {
...@@ -53,14 +59,22 @@ export class GatewayComponent implements OnInit { ...@@ -53,14 +59,22 @@ export class GatewayComponent implements OnInit {
init() { init() {
this.getData(); this.getData();
this.getCompanys();
} }
next = (data) => { next = (data) => {
if (data && data.rows && data.rows.constructor === Array) { if (data && data.constructor === Array) {
this.data = data.rows.filter(one => { one.isOn = Math.random() > 0.5; return one; }); const flag = !(this.filterFlag === 0 || this.filterFlag === 1);
this.total = data.total; this.canBindGateways = data.filter(one => !one.pDeviceNo);
this.data = data.filter(one => (one.pDeviceNo && this.filterFlag || flag)
&& one.name.indexOf(this.query.gatewayName) > -1 && one.sn.indexOf(this.query.gatewaySN) > -1);
} else if (data.code === 1) { } else if (data.code === 1) {
this.message.success(data && data.message ? data.message : '操作成功'); this.message.success(data && data.message ? data.message : '操作成功');
this.isAddConV = false;
this.isMultiAddConV = false;
this.isBindConV = false;
this.isDivideConV = false;
this.getData();
} else if (data.code === 0) { } else if (data.code === 0) {
this.message.error(data && data.message ? data.message : '操作失败'); this.message.error(data && data.message ? data.message : '操作失败');
} else { } else {
...@@ -71,13 +85,51 @@ export class GatewayComponent implements OnInit { ...@@ -71,13 +85,51 @@ export class GatewayComponent implements OnInit {
getData() { getData() {
this.isLoading = true; this.isLoading = true;
this.api.loginlog.getAll(this.page, this.rows, ['', this.next]); this.api.device.getAll([{model: 0}, this.next]);
}
getCompanys() {
this.isLoading = true;
this.api.company.getAll(['', (data) => {
if (data && data.constructor === Array) {
this.companys = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
companySelected(e) {
this.isLoading = true;
this.api.influxdbTables.getByCompanyNo([{companyNo: e}, (data) => {
if (data && data.constructor === Array) {
this.influxdbs = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
} }
onSearch() { onSearch() {
this.filterFlag = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData();
} }
onGetAll() { onGetAll() {
this.query = {
gatewayName: '',
gatewaySN: ''
};
this.filterFlag = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData();
}
onInput(e) {
this.selectedGateways = this.canBindGateways.filter(one => one.name.indexOf(e) > -1 || one.sn.indexOf(e) > -1);
} }
// 复选框的方法 // 复选框的方法
...@@ -129,41 +181,61 @@ export class GatewayComponent implements OnInit { ...@@ -129,41 +181,61 @@ export class GatewayComponent implements OnInit {
} }
// 筛选 // 筛选
filter(a, b) { filter(e) {
console.log(a, b); this.filterFlag = e;
this.getData();
} }
// 跳转详情 // 跳转详情
toSee(e) { toSee(e) {
this.router.navigate(['/app/deviceCenter/gatewayMgr/gatewaySee']); this.router.navigate(['/app/deviceCenter/gatewayMgr/gatewaySee'],
{queryParams: {deviceNo: e.deviceNo, name: e.name}});
} }
// 单个的方法 // 单个的方法
add() { add() {
this.isMulti = false; this.isMulti = false;
this.isUpdate = false;
this.isAddConV = true; this.isAddConV = true;
} }
bind(one) { bind(one) {
this.isMulti = false; this.isMulti = false;
this.selectedOne = one; this.selectedGateways = [];
this.req3 = {
address: '',
deviceNo: one.deviceNo,
influxdbDatabaseNo: '',
pDeviceNo: ''
};
this.isBindConV = true; this.isBindConV = true;
} }
unbind(one) { unbind(one) {
this.modalService.confirm({ this.modalService.confirm({
nzTitle : '<i> </i>', nzTitle : '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteSelectedRecord') + '</b>', nzContent: '<b>' + this.translate.instant('confirmUnbindThisRecord') + '</b>',
nzOnOk : () => this.unbindOne(one) nzOnOk : () => this.unbindOne(one)
}); });
} }
unbindOne(one) {} unbindOne(one) {
this.isLoading = true;
this.api.device.unBindDevice([{deviceNo: one.deviceNo}, this.next]);
}
update(one) { update(one) {
this.isMulti = false; this.isMulti = false;
this.selectedOne = one; this.req = {...one};
this.isUpdateConV = true; this.companySelected(one.companyNo);
this.isUpdate = true;
this.isAddConV = true;
}
divide(one) {
this.isMulti = false;
this.req4 = {...one};
this.isDivideConV = true;
} }
cancel(v) { cancel(v) {
...@@ -171,7 +243,22 @@ export class GatewayComponent implements OnInit { ...@@ -171,7 +243,22 @@ export class GatewayComponent implements OnInit {
} }
save(v) { save(v) {
this[v] = false; this.isLoading = true;
// 单个新增
if (!this.isMulti && this.isAddConV && !this.isUpdate) {
this.api.device.addGateway([this.req, this.next]);
// 单个编辑
} else if (!this.isMulti && this.isAddConV && this.isUpdate) {
this.api.device.updateGateway([this.req, this.next]);
// 单个分配
} else if (!this.isMulti && this.isDivideConV) {
this.api.device.updateCompany([this.req4, this.next]);
// 单个绑定
} else if (!this.isMulti && this.isBindConV) {
this.req3.pDeviceNo = this.req3.device.deviceNo;
this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo;
this.api.device.gatewayBindGateway([this.req3, this.next]);
}
} }
deleteConfirm(one) { deleteConfirm(one) {
...@@ -182,12 +269,15 @@ export class GatewayComponent implements OnInit { ...@@ -182,12 +269,15 @@ export class GatewayComponent implements OnInit {
}); });
} }
delete(one) {} delete(one) {
this.isLoading = true;
this.api.device.delDevice([{deviceNo: one.deviceNo}, this.next]);
}
// 批量的方法 // 批量的方法
allUpdate() { allUpdate() {
this.isMulti = true; this.isMulti = true;
this.isUpdateConV = true; this.isUpdate = true;
} }
multiAdd() { multiAdd() {
......
<div class="searchBar" @fade>
<app-search-select [(value)]="companyNo" [label]="'selectCompany' | translate" optL="companyName"
[data]="companys" optV="companyNo"></app-search-select>
<div class="btnLine">
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="onSearch()"><span>{{'search' | translate}}</span></button>
<button nz-button class="btnAll" [nzLoading]="isLoading" (click)="onGetAll()"><span>{{'allData' | translate}}</span></button>
<button nz-button class="btnAdd" [nzLoading]="isLoading" (click)="add()"><span>{{'add' | translate}}</span></button>
</div>
</div>
<div class="tableBar" @fade>
<nz-table #nzTable
[nzData]="data"
[nzLoading]="isLoading">
<thead nz-thead>
<tr>
<th nz-th><span>{{'num' | translate}}</span></th>
<th nz-th><span>{{'databaseName' | translate}}</span></th>
<th nz-th><span>{{'companyName' | translate}}</span></th>
<th nz-th><span>{{'field' | translate}}</span></th>
<th nz-th><span>{{'dbPolicy' | translate}}</span></th>
<th nz-th><span>{{'dbState' | translate}}</span></th>
<th nz-th><span>{{'description' | translate}}</span></th>
<th nz-th><span>{{'remark' | translate}}</span></th>
<th nz-th><span>{{'oper' | translate}}</span></th>
</tr>
</thead>
<tbody nz-tbody>
<tr *ngFor="let one of nzTable.data,let i = index">
<td nz-td>{{i + 1}}</td>
<td nz-td>{{one.databaseName}}</td>
<td nz-td>{{one.companyName}}</td>
<td nz-td>{{one.field}}</td>
<td nz-td>{{one.policy}}</td>
<td nz-td>{{one.state}}</td>
<td nz-td>{{one.description}}</td>
<td nz-td>{{one.remark}}</td>
<td nz-td>
<span class="editSpan" (click)="edit(one)">{{'edit' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider>
<span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span>
</td>
</tr>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="(isUpdate ? 'editUser' : 'addUser') | translate" [nzContent]="modalContent" nzWidth="500"
[nzFooter]="modalFooter" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #modalContent>
<app-search-item isMust="true" [(value)]="req.databaseName" [label]="'databaseName' | translate" inModal="true"></app-search-item>
<app-search-item isMust="true" [(value)]="req.field" [label]="'field' | translate" inModal="true"></app-search-item>
<app-search-item isMust="true" [(value)]="req.description" [label]="'description' | translate" inModal="true"></app-search-item>
<app-search-select isMust="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate" optL="companyName"
[data]="companys" inModal="true" optV="companyNo"></app-search-select>
<app-search-select isMust="true" [(value)]="req.state" [label]="'dbState' | translate" optL="a" optV="b"
[data]="[{a: '好', b: 1}, {a: '坏', b: 0}]" inModal="true"></app-search-select>
<app-search-item isMust="true" [(value)]="req.policy" [label]="'dbPolicy' | translate" inModal="true"></app-search-item>
<app-search-item [(value)]="req.remark" [label]="'remark' | translate" inModal="true"></app-search-item>
</ng-template>
<ng-template #modalFooter>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save()"><span>{{'confirm' | translate}}</span></button>
</ng-template>
</nz-modal>
import { Component, OnInit } from '@angular/core';
import {ApiService} from '../../service/api';
import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {TranslateService} from '@ngx-translate/core';
import {CheckService} from '../../service/check';
import {fadeIn} from '../../animation/fade-in';
@Component({
selector: 'app-influxdb',
templateUrl: './influxdb.component.html',
styles: [],
animations: [fadeIn]
})
export class InfluxdbComponent implements OnInit {
req: any = {};
data: any = [];
isLoading = false;
isVisible = false;
isUpdate = false;
companyNo = '';
companys = [];
constructor(private api: ApiService, private message: NzMessageService, private translate: TranslateService,
private modalService: NzModalService, private ck: CheckService) {
}
ngOnInit() {
this.init();
}
init() {
this.getData();
this.getCompanys();
}
getCompanys() {
this.isLoading = true;
this.api.company.getAll(['', (data) => {
if (data.constructor === Array) {
this.companys = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
next = (data) => {
if (data && data.constructor === Array) {
this.data = data;
} else if (data && data.code === 1) {
this.message.success(data.message ? data.message : '操作成功');
this.init();
this.isVisible = false;
} else if (data && data.code === 0) {
this.message.error(data.message ? data.message : '操作失败');
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}
getData() {
this.isLoading = true;
this.api.influxdbTables.getAll(['', this.next]);
}
onSearch() {
this.isLoading = true;
this.api.influxdbTables.getByCompanyNo([{companyNo: this.companyNo}, this.next]);
}
onGetAll() {
this.companyNo = '';
this.getData();
}
add() {
this.isUpdate = false;
this.req = {};
this.isVisible = true;
}
edit(one) {
this.isUpdate = true;
this.req = {...one};
this.isVisible = true;
}
save() {
this.isLoading = true;
if (this.isUpdate) {
this.api.influxdbTables.updateInfluxdbTables([this.req, this.next]);
} else {
this.api.influxdbTables.addInfluxdbTables([this.req, this.next]);
}
}
cancel() {
this.isVisible = false;
}
deleteConfirm(one) {
this.modalService.confirm({
nzTitle : '<i></i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete(one)
});
}
delete(one) {
this.api.influxdbTables.delInfluxdbTables([{influxdbDatabaseNo: one.influxdbDatabaseNo}, this.next]);
}
}
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<tr *ngFor="let one of nzTable.data, let i = index"> <tr *ngFor="let one of nzTable.data, let i = index">
<td nz-td>{{i + 1}}</td> <td nz-td>{{i + 1}}</td>
<td nz-td class="canClick" (click)="toDetail(one)">{{one.probesModelName}}</td> <td nz-td class="canClick" (click)="toDetail(one)">{{one.probesModelName}}</td>
<td nz-td>{{one.probesModelName}}</td> <td nz-td>{{one.counts}}</td>
<td nz-td>{{one.remark}}</td> <td nz-td>{{one.remark}}</td>
<td nz-td> <td nz-td>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span> <span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ApiService} from '../../service/api'; import {ApiService} from '../../service/api';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {TranslateService} from '@ngx-translate/core';
@Component({ @Component({
selector: 'app-sensor-detail', selector: 'app-sensor-detail',
...@@ -13,11 +14,22 @@ import {fadeIn} from '../../animation/fade-in'; ...@@ -13,11 +14,22 @@ import {fadeIn} from '../../animation/fade-in';
export class SensorDetailComponent implements OnInit { export class SensorDetailComponent implements OnInit {
isLoading = false; isLoading = false;
data = []; deviceData = [];
selectTime = 24; deviceNo = '';
req = {}; name = '';
selectTime2 = 24; req: any = {};
req2 = {}; req2: any = {};
req3 = {};
req5: any = {};
isUC = false;
isUC2 = false;
isMC = false;
isUpdate = false;
isUpdate2 = false;
probsModels = [];
topicModels = [];
wayData = [];
selectTime3 = 24;
items = [{ items = [{
name: '液位', name: '液位',
data: '1', data: '1',
...@@ -40,21 +52,32 @@ export class SensorDetailComponent implements OnInit { ...@@ -40,21 +52,32 @@ export class SensorDetailComponent implements OnInit {
min: '0', min: '0',
time: new Date().getTime() time: new Date().getTime()
}]; }];
constructor(private api: ApiService, private message: NzMessageService, private router: Router) { } constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) { }
ngOnInit() { ngOnInit() {
this.init(); this.init();
} }
init() { init() {
this.getData(); this.ac.queryParams.subscribe((e) => {
if (e.deviceNo) {
this.deviceNo = e.deviceNo;
this.name = e.name;
this.getTopicData();
this.getProbsModels();
this.getTopicModels();
this.getProbs();
}
});
} }
next = (data) => { next = (data) => {
if (data && data.constructor === Array) { if (data && data.constructor === Array) {
this.data = data;
} else if (data.code === 1) { } else if (data.code === 1) {
this.message.success(data && data.message ? data.message : '操作成功'); this.message.success(data && data.message ? data.message : '操作成功');
this.cancel();
this.getTopicData();
} else if (data.code === 0) { } else if (data.code === 0) {
this.message.error(data && data.message ? data.message : '操作失败'); this.message.error(data && data.message ? data.message : '操作失败');
} else { } else {
...@@ -62,17 +85,145 @@ export class SensorDetailComponent implements OnInit { ...@@ -62,17 +85,145 @@ export class SensorDetailComponent implements OnInit {
} }
} }
getData() { getProbsModels() {
this.api.role.getAll(['', this.next]); this.isLoading = true;
this.api.probesModel.getAll(['', (data) => {
if (data && data.constructor === Array) {
this.probsModels = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
} }
toDetail() { getTopicData() {
this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail']); this.isLoading = true;
this.api.topic.getByDeviceNo([{deviceNo: this.deviceNo}, (data) => {
if (data && data.constructor === Array) {
this.deviceData = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
} }
onSearch() {} getTopicModels() {
this.isLoading = true;
this.api.topicModel.getAll(['', (data) => {
if (data && data.constructor === Array) {
this.topicModels = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
getProbs() {
this.isLoading = true;
this.api.probes.getProbesByGateway([{deviceNo: this.deviceNo}, (data) => {
if (data && data.constructor === Array) {
this.wayData = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
onSearch2() {} toDetail(one) {
this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail/sensorTopicWay'],
{queryParams: {deviceNo: one.deviceNo, topicName: one.topicName}});
}
onSearch() {}
close() {} close() {}
changeModel() {
this.isMC = true;
this.req5 = {
deviceNo: this.deviceNo
};
}
add() {
this.isUpdate = false;
this.req = {};
this.req.deviceNo = this.deviceNo;
this.isUC = true;
}
update(one) {
this.req = {...one};
this.isUpdate = true;
this.req.oldTopicName = one.topicName;
this.isUC = true;
}
cancel() {
this.isUC = false;
this.isMC = false;
this.isUC2 = false;
}
save() {
this.isLoading = true;
if (this.isUC && this.isUpdate) {
this.api.topic.updateTopic([this.req, this.next]);
} else if (this.isUC && !this.isUpdate) {
this.api.topic.addTopic([this.req, this.next]);
} else if (this.isMC) {
this.api.device.deploySensor([this.req5, this.next]);
} else if (this.isUC2 && this.isUpdate) {
this.req2.deviceNo = this.deviceNo;
this.api.probes.updateProbes([this.req2, this.next]);
} else if (this.isUC2 && !this.isUpdate) {
this.req2.deviceNo = this.deviceNo;
this.api.probes.addProbes([this.req2, this.next]);
}
}
deleteConfirm(one) {
this.modalService.confirm({
nzTitle : '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete(one)
});
}
delete(one) {
this.isLoading = true;
this.api.topic.delTopic([{deviceNo: one.deviceNo, topicName: one.topicName}, this.next]);
}
add2() {
this.isUpdate2 = false;
this.req2 = {};
this.req2.deviceNo = this.deviceNo;
this.isUC2 = true;
}
update2(one) {
this.req2 = {...one};
this.isUpdate2 = true;
this.req2.oldTopicName = one.topicName;
this.isUC2 = true;
}
deleteConfirm2(one) {
this.modalService.confirm({
nzTitle : '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete2(one)
});
}
delete2(one) {
this.isLoading = true;
this.api.topic.delTopic([{deviceNo: one.deviceNo, topicName: one.topicName}, this.next]);
}
} }
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<span>{{'search' | translate}}</span></button> <span>{{'search' | translate}}</span></button>
<button nz-button class="btnAll" [nzLoading]="isLoading" (click)="onGetAll()"><span>{{'allData' | translate}}</span> <button nz-button class="btnAll" [nzLoading]="isLoading" (click)="onGetAll()"><span>{{'allData' | translate}}</span>
</button> </button>
<button nz-button class="btnAdd" [nzLoading]="isLoading" (click)="multiAdd()"> <!--<button nz-button class="btnAdd" [nzLoading]="isLoading" (click)="multiAdd()">-->
<span>{{'multiAdd' | translate}}</span></button> <!--<span>{{'multiAdd' | translate}}</span></button>-->
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()"> <button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()">
<span>{{'addSensor' | translate}}</span></button> <span>{{'addSensor' | translate}}</span></button>
</div> </div>
...@@ -15,17 +15,16 @@ ...@@ -15,17 +15,16 @@
<div class="tableBar" @fade> <div class="tableBar" @fade>
<nz-table #nzTable <nz-table #nzTable
[nzData]="data" [nzData]="data"
[nzShowPagination]="false"
[nzLoading]="isLoading"> [nzLoading]="isLoading">
<thead nz-thead> <thead nz-thead>
<tr> <tr>
<th <!--<th-->
nzShowCheckbox <!--nzShowCheckbox-->
[(nzChecked)]="isAllCheck" <!--[(nzChecked)]="isAllCheck"-->
[nzDisabled]="data.length===0" <!--[nzDisabled]="data.length===0"-->
[nzIndeterminate]="isIndeterminate" <!--[nzIndeterminate]="isIndeterminate"-->
(nzCheckedChange)="checkAll($event)" <!--(nzCheckedChange)="checkAll($event)"-->
></th> <!--&gt;</th>-->
<th nz-th><span>{{'sensorName' | translate}}</span></th> <th nz-th><span>{{'sensorName' | translate}}</span></th>
<th nz-th><span>{{'sensorSN' | translate}}</span></th> <th nz-th><span>{{'sensorSN' | translate}}</span></th>
<th nz-th><span>{{'frontName' | translate}}</span></th> <th nz-th><span>{{'frontName' | translate}}</span></th>
...@@ -43,50 +42,70 @@ ...@@ -43,50 +42,70 @@
</thead> </thead>
<tbody nz-tbody> <tbody nz-tbody>
<tr *ngFor="let one of nzTable.data,let i = index"> <tr *ngFor="let one of nzTable.data,let i = index">
<td nzShowCheckbox [(nzChecked)]="one.checked" (nzCheckedChange)="oneCheck()"></td> <!--<td nzShowCheckbox [(nzChecked)]="one.checked" (nzCheckedChange)="oneCheck()"></td>-->
<td nz-td class="canClick" (click)="toSee(one)">设备{{i}}</td> <td nz-td class="canClick" (click)="toSee(one)">{{one.name}}</td>
<td nz-td>{{one.realName}}</td> <td nz-td>{{one.sn}}</td>
<td nz-td>{{one.userName}}</td> <td nz-td>{{one.prefixName}}</td>
<td nz-td>{{one.nickName}}</td> <td nz-td>{{one.type}}</td>
<td nz-td> <td nz-td>
<nz-switch [nzControl]="true" (click)="toggleOn(one)" [(ngModel)]="one.isOn" <nz-switch [nzControl]="true" (click)="toggleOn(one)" [(ngModel)]="one.state"
[nzLoading]="one.isLoading"></nz-switch> [nzLoading]="one.isLoading"></nz-switch>
</td> </td>
<td nz-td>{{one.email}}</td> <td nz-td>{{one.pDeviceNo ? '是' : '否'}}</td>
<td nz-td>{{one.roleName}}</td> <td nz-td>{{one.companyName}}</td>
<td nz-td> <td nz-td>
<span class="editSpan" (click)="bind(one)">{{'bind' | translate}}</span> <span *ngIf="!one.pDeviceNo" class="editSpan" (click)="bind(one)">{{'bind' | translate}}</span>
<span *ngIf="one.pDeviceNo" class="editSpan" (click)="unbind(one)">{{'unbind' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span> <span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<span class="deleteFontColor" (click)="deleteConfirm(one.roleNo)">{{'delete' | translate}}</span> <span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
<div class="btnLine whenOneLine" style="text-align: left; margin-top: 10px;"> <!--<div class="btnLine whenOneLine" style="text-align: left; margin-top: -48px;">-->
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDelete()"> <!--<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDelete()">-->
<span>{{'delete' | translate}}</span></button> <!--<span>{{'delete' | translate}}</span></button>-->
<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!canbind" (click)="allBind()"><span>{{'bind' | translate}}</span> <!--<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!canbind" (click)="allBind()"><span>{{'bind' | translate}}</span>-->
</button> <!--</button>-->
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!canUnbind" (click)="allUnbind()"> <!--<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!canUnbind" (click)="allUnbind()">-->
<span>{{'unbind' | translate}}</span></button> <!--<span>{{'unbind' | translate}}</span></button>-->
<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDivide()"><span>{{'divide' | translate}}</span> <!--<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDivide()"><span>{{'divide' | translate}}</span>-->
</button> <!--</button>-->
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()"> <!--<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()">-->
<span>{{'update' | translate}}</span></button> <!--<span>{{'update' | translate}}</span></button>-->
</div> <!--</div>-->
<div class="pagePart whenOneLine"> <!--<div class="pagePart whenOneLine">-->
<nz-pagination [nzPageIndex]="page" [nzTotal]="total" [nzPageSize]="rows" <!--<nz-pagination [nzPageIndex]="page" [nzTotal]="total" [nzPageSize]="rows"-->
[nzShowTotal]="totalTemplate"></nz-pagination> <!--[nzShowTotal]="totalTemplate"></nz-pagination>-->
<ng-template #totalTemplate> 共 {{ total }} 项</ng-template> <!--<ng-template #totalTemplate> 共 {{ total }} 项</ng-template>-->
</div> <!--</div>-->
</div> </div>
<nz-modal [(nzVisible)]="isAddConV" [nzContent]="con1" nzWidth="500" <nz-modal [(nzVisible)]="isAddConV" [nzContent]="con1" nzWidth="500" [nzTitle]="isUpdate ? ('updateSensor' | translate) : ('addSensor' | translate)"
[nzFooter]="foot1" (nzOnCancel)="cancel('isAddConV')" nzMaskClosable="false"> [nzFooter]="foot1" (nzOnCancel)="cancel('isAddConV')" nzMaskClosable="false">
<ng-template #con1> <ng-template #con1>
新增传感器 <app-search-item inModal="true" isMust="true" [label]="'sensorName' | translate"
[(value)]="req.name"></app-search-item>
<app-search-item *ngIf="!isUpdate" isMust="true" inModal="true" [label]="'sensorSN' | translate"
[(value)]="req.sn"></app-search-item>
<app-search-item *ngIf="!isUpdate" isMust="true" inModal="true" [label]="'type' | translate" [(value)]="req.type"></app-search-item>
<app-search-item *ngIf="!isUpdate" isMust="true" inModal="true" [label]="'configJson' | translate"
[(value)]="req.configJson"></app-search-item>
<app-search-item *ngIf="isUpdate" inModal="true" [label]="'front' | translate"
[(value)]="req.prefixName"></app-search-item>
<app-search-select *ngIf="!isUpdate" isMust="true" [(value)]="req.topicModelNo" [label]="'topicModel' | translate" optL="topicModelName"
[data]="topicModels" inModal="true" optV="topicModelNo"></app-search-select>
<app-search-select isMust="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate" optL="companyName"
(valueChange)="companySelected($event)" [data]="companys" inModal="true" optV="companyNo"></app-search-select>
<app-search-select isMust="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"
[label]="'selectInfluxDB' | translate" optL="databaseName"
[data]="influxdbs" inModal="true" optV="influxdbDatabaseNo"></app-search-select>
<app-search-select [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" inModal="true" optV="sceneNo"></app-search-select>
<app-search-item inModal="true" isMust="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
</ng-template> </ng-template>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button>
...@@ -105,14 +124,29 @@ ...@@ -105,14 +124,29 @@
</ng-template> </ng-template>
</nz-modal> </nz-modal>
<nz-modal [(nzVisible)]="isBindConV" [nzContent]="con3" nzWidth="500" <nz-modal [(nzVisible)]="isBindConV" [nzContent]="con3" nzWidth="500" [nzTitle]="'bindGateway' | translate"
[nzFooter]="foot3" (nzOnCancel)="cancel('isBindConV')" nzMaskClosable="false"> [nzFooter]="foot3" (nzOnCancel)="cancel('isBindConV')" nzMaskClosable="false">
<ng-template #con3> <ng-template #con3>
绑定/批量绑定传感器 <div class="searchItem inModal">
<div class="item-label">
<span class="deleteFontColor">* </span>{{'selectGateway' | translate}}
</div>
<div class="item-input">
<input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device" (input)="onInput($event.target?.value)">
<nz-autocomplete nzBackfill #auto>
<nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.name + '-' + one.sn" [nzValue]="one">
{{one.name}} - {{one.sn}}
</nz-auto-option>
</nz-autocomplete>
</div>
</div>
<app-search-item *ngIf="!isUpdate" isMust="true" inModal="true" [label]="'belongAddress' | translate" [(value)]="req3.address"></app-search-item>
</ng-template> </ng-template>
<ng-template #foot3> <ng-template #foot3>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isBindConV')"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isBindConV')">
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isBindConV')"><span>{{'confirm' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save()">
<span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
......
...@@ -22,26 +22,32 @@ export class SensorMgrComponent implements OnInit { ...@@ -22,26 +22,32 @@ export class SensorMgrComponent implements OnInit {
data = []; data = [];
query = { query = {
gatewayName: '', sensorName: '',
gatewaySN: '' sensorSN: ''
}; };
isLoading = false; isLoading = false;
isAllCheck = false; isAllCheck = false;
isIndeterminate = false; isIndeterminate = false;
page = 1; listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
rows = 10;
total = 125;
listOfBind = [{text: '全部', value: 1}, {text: '已绑定', value: 2}, {text: '未绑定', value: 3}];
selectedOne: any = {}; selectedOne: any = {};
isAddConV = false; isAddConV = false;
isMultiAddConV = false; isMultiAddConV = false;
isBindConV = false; isBindConV = false;
isMulti = false; isMulti = false;
isDivideConV = false;
isUpdate = false;
canbind = false; canbind = false;
canUnbind = false; canUnbind = false;
isCheckedOne = false; isCheckedOne = false;
isDivideConV = false; req: any = {};
isUpdateConV = false; topicModels = [];
companys = [];
influxdbs = [];
scenes = [{sceneNo: '123', sceneName: 'qq'}];
filterFlag;
selectedGateways = [];
canBindGateways = [];
req3: any = {};
constructor(private api: ApiService, private message: NzMessageService, private router: Router, constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private modalService: NzModalService, private translate: TranslateService) { private modalService: NzModalService, private translate: TranslateService) {
...@@ -53,14 +59,23 @@ export class SensorMgrComponent implements OnInit { ...@@ -53,14 +59,23 @@ export class SensorMgrComponent implements OnInit {
init() { init() {
this.getData(); this.getData();
this.getTopicModels();
this.getCompanys();
this.getGateways();
} }
next = (data) => { next = (data) => {
if (data && data.rows && data.rows.constructor === Array) { if (data && data.constructor === Array) {
this.data = data.rows.filter(one => { one.isOn = Math.random() > 0.5; return one; }); const flag = !(this.filterFlag === 0 || this.filterFlag === 1);
this.total = data.total; this.data = data.filter(one => (one.pDeviceNo && this.filterFlag || flag)
&& one.name.indexOf(this.query.sensorName) > -1 && one.sn.indexOf(this.query.sensorSN) > -1);
} else if (data.code === 1) { } else if (data.code === 1) {
this.message.success(data && data.message ? data.message : '操作成功'); this.message.success(data && data.message ? data.message : '操作成功');
this.isAddConV = false;
this.isMultiAddConV = false;
this.isBindConV = false;
this.isDivideConV = false;
this.getData();
} else if (data.code === 0) { } else if (data.code === 0) {
this.message.error(data && data.message ? data.message : '操作失败'); this.message.error(data && data.message ? data.message : '操作失败');
} else { } else {
...@@ -71,13 +86,63 @@ export class SensorMgrComponent implements OnInit { ...@@ -71,13 +86,63 @@ export class SensorMgrComponent implements OnInit {
getData() { getData() {
this.isLoading = true; this.isLoading = true;
this.api.loginlog.getAll(this.page, this.rows, ['', this.next]); this.api.device.getAll([{model: 1}, this.next]);
}
getTopicModels() {
this.isLoading = true;
this.api.topicModel.getAll(['', (data) => {
if (data && data.constructor === Array) {
this.topicModels = data;
} else {
this.message.error(data && data .message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
getCompanys() {
this.isLoading = true;
this.api.company.getAll(['', (data) => {
if (data && data.constructor === Array) {
this.companys = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
getGateways() {
this.isLoading = true;
this.api.device.getAll([{model: 0}, (data) => {
if (data && data.constructor === Array) {
this.canBindGateways = data.filter(one => !one.pDeviceNo);
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
} }
onSearch() { onSearch() {
this.filterFlag = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData();
} }
onGetAll() { onGetAll() {
this.query = {
sensorName: '',
sensorSN: ''
};
this.filterFlag = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData();
}
onInput(e) {
this.selectedGateways = this.canBindGateways.filter(one => one.name.indexOf(e) > -1 || one.sn.indexOf(e) > -1);
} }
// 复选框的方法 // 复选框的方法
...@@ -129,13 +194,26 @@ export class SensorMgrComponent implements OnInit { ...@@ -129,13 +194,26 @@ export class SensorMgrComponent implements OnInit {
} }
// 筛选 // 筛选
filter(a, b) { filter(e) {
console.log(a, b); this.filterFlag = e;
this.getData();
}
companySelected(e) {
this.isLoading = true;
this.api.influxdbTables.getByCompanyNo([{companyNo: e}, (data) => {
if (data && data.constructor === Array) {
this.influxdbs = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
} }
// 跳转详情 // 跳转详情
toSee(e) { toSee(e) {
this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail']); this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail'], {queryParams: {deviceNo: e.deviceNo, name: e.name}});
} }
// 单个的方法 // 单个的方法
...@@ -146,48 +224,76 @@ export class SensorMgrComponent implements OnInit { ...@@ -146,48 +224,76 @@ export class SensorMgrComponent implements OnInit {
bind(one) { bind(one) {
this.isMulti = false; this.isMulti = false;
this.selectedOne = one; this.selectedGateways = [];
this.req3 = {
address: '',
deviceNo: one.deviceNo,
influxdbDatabaseNo: '',
pDeviceNo: ''
};
this.isBindConV = true; this.isBindConV = true;
} }
unbind(one) { unbind(one) {
this.modalService.confirm({ this.modalService.confirm({
nzTitle : '<i></i>', nzTitle : '<i></i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteSelectedRecord') + '</b>', nzContent: '<b>' + this.translate.instant('confirmUnbindThisRecord') + '</b>',
nzOnOk : () => this.unbindOne(one) nzOnOk : () => this.unbindOne(one)
}); });
} }
unbindOne(one) {} unbindOne(one) {
this.isLoading = true;
this.api.device.unBindDevice([{deviceNo: one.deviceNo}, this.next]);
}
update(one) { update(one) {
this.isMulti = false; this.isMulti = false;
this.selectedOne = one; this.req = {...one};
this.isUpdateConV = true; this.companySelected(one.companyNo);
this.isUpdate = true;
this.isAddConV = true;
} }
cancel(v) { cancel(v) {
this[v] = false; this[v] = false;
} }
save(v) { save() {
this[v] = false; if (!this.isMulti && this.isAddConV && !this.isUpdate) {
this.req.alarmMethodNos = [];
this.req.alarmUsers = [];
this.req.model = 1;
this.api.device.addSensorOrBlend([this.req, this.next]);
} else if (!this.isMulti && this.isAddConV && this.isUpdate) {
this.req.alarmMethodNos = [];
this.req.alarmUsers = [];
this.req.model = 1;
this.api.device.updateSensor([this.req, this.next]);
} else if (!this.isMulti && this.isBindConV) {
this.req3.pDeviceNo = this.req3.device.deviceNo;
this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo;
this.api.device.gatewayBindGateway([this.req3, this.next]);
}
} }
deleteConfirm(one) { deleteConfirm(one) {
this.modalService.confirm({ this.modalService.confirm({
nzTitle : '<i></i>', nzTitle : '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>', nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete(one) nzOnOk : () => this.delete(one)
}); });
} }
delete(one) {} delete(one) {
this.isLoading = true;
this.api.device.delDevice([{deviceNo: one.deviceNo}, this.next]);
}
// 批量的方法 // 批量的方法
allUpdate() { allUpdate() {
this.isMulti = true; this.isMulti = true;
this.isUpdateConV = true; this.isUpdate = true;
} }
multiAdd() { multiAdd() {
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
<tr *ngFor="let one of nzTable.data, let i = index"> <tr *ngFor="let one of nzTable.data, let i = index">
<td nz-td>{{i + 1}}</td> <td nz-td>{{i + 1}}</td>
<td nz-td class="canClick" (click)="toConfig(one)">{{one.topicName}}</td> <td nz-td class="canClick" (click)="toConfig(one)">{{one.topicName}}</td>
<td nz-td>{{one.topicType === 0 ? 'pub' : one.topicType === 1 ? 'sub': 'pub and sub'}}</td> <td nz-td>{{one.topicType === 0 ? '推送主题' : one.topicType === 1 ? '订阅主题': '推送订阅主题'}}</td>
<td nz-td>{{one.dataType === 0 ? 'json' : 'bin'}}</td> <td nz-td>{{one.dataType === 0 ? 'json' : 'bin'}}</td>
<td nz-td>{{one.dataInterval}}</td> <td nz-td>{{one.interval}}</td>
<td nz-td> <td nz-td>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span> <span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<ng-template #con1> <ng-template #con1>
<app-search-item isMust="true" inModal="true" [label]="'topicName' | translate" [(value)]="req.topicName"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'topicName' | translate" [(value)]="req.topicName"></app-search-item>
<app-search-select isMust="true" inModal="true" [label]="'topicType' | translate" [(value)]="req.topicType" <app-search-select isMust="true" inModal="true" [label]="'topicType' | translate" [(value)]="req.topicType"
[data]="[{a: 'pub', b: 0}, {a: 'sub', b: 1}, {a: 'pub and sub', b: 2}]" optL="a" optV="b"></app-search-select> [data]="[{a: '推送主题', b: 0}, {a: '订阅主题', b: 1}, {a: '推送订阅主题', b: 2}]" optL="a" optV="b"></app-search-select>
<app-search-select isMust="true" inModal="true" [label]="'dataType' | translate" [(value)]="req.dataType" <app-search-select isMust="true" inModal="true" [label]="'dataType' | translate" [(value)]="req.dataType"
[data]="[{a: 'json', b: 0}, {a: 'bin', b: 1}]" optL="a" optV="b"></app-search-select> [data]="[{a: 'json', b: 0}, {a: 'bin', b: 1}]" optL="a" optV="b"></app-search-select>
<app-search-select *ngIf="!isUpdate" isMust="true" inModal="true" [label]="'probesModel' | translate" [(value)]="req.probesModelNo" <app-search-select *ngIf="!isUpdate" isMust="true" inModal="true" [label]="'probesModel' | translate" [(value)]="req.probesModelNo"
......
...@@ -21,6 +21,8 @@ import {SensorDetailComponent} from './main/sensor-detail/sensor-detail.componen ...@@ -21,6 +21,8 @@ import {SensorDetailComponent} from './main/sensor-detail/sensor-detail.componen
import {ModuleDetailComponent} from './main/module-detail/module-detail.component'; import {ModuleDetailComponent} from './main/module-detail/module-detail.component';
import {TopicModuleDetailComponent} from './main/topic-module-detail/topic-module-detail.component'; import {TopicModuleDetailComponent} from './main/topic-module-detail/topic-module-detail.component';
import {TopicModuleWayComponent} from './main/topic-module-way/topic-module-way.component'; import {TopicModuleWayComponent} from './main/topic-module-way/topic-module-way.component';
import {InfluxdbComponent} from './main/influxdb/influxdb.component';
import {SensorTopicWayComponent} from './main/sensor-topic-way/sensor-topic-way.component';
const AppRoutes: Routes = [ const AppRoutes: Routes = [
{path: '', redirectTo: '/extra/login', pathMatch: 'full'}, {path: '', redirectTo: '/extra/login', pathMatch: 'full'},
...@@ -42,6 +44,7 @@ const routes: Routes = [ ...@@ -42,6 +44,7 @@ const routes: Routes = [
{path: 'deviceCenter/gatewayMgr/gatewaySee', component: GatewaySeeComponent}, {path: 'deviceCenter/gatewayMgr/gatewaySee', component: GatewaySeeComponent},
{path: 'deviceCenter/sensorMgr', component: SensorMgrComponent}, {path: 'deviceCenter/sensorMgr', component: SensorMgrComponent},
{path: 'deviceCenter/sensorMgr/sensorDetail', component: SensorDetailComponent}, {path: 'deviceCenter/sensorMgr/sensorDetail', component: SensorDetailComponent},
{path: 'deviceCenter/sensorMgr/sensorDetail/sensorTopicWay', component: SensorTopicWayComponent},
{path: 'deviceCenter/moduleMgr', component: ModuleMgrComponent}, {path: 'deviceCenter/moduleMgr', component: ModuleMgrComponent},
{path: 'deviceCenter/moduleMgr/moduleDetail', component: ModuleDetailComponent}, {path: 'deviceCenter/moduleMgr/moduleDetail', component: ModuleDetailComponent},
{path: 'deviceCenter/topicModuleMgr', component: TopicModuleMgrComponent}, {path: 'deviceCenter/topicModuleMgr', component: TopicModuleMgrComponent},
...@@ -50,6 +53,7 @@ const routes: Routes = [ ...@@ -50,6 +53,7 @@ const routes: Routes = [
{path: 'deviceCenter/setModuleMgr', component: SetModuleMgrComponent}, {path: 'deviceCenter/setModuleMgr', component: SetModuleMgrComponent},
{path: 'deviceCenter/mqttSetMgr', component: MqttSetMgrComponent}, {path: 'deviceCenter/mqttSetMgr', component: MqttSetMgrComponent},
{path: 'systemMgr/userCenter', component: UserComponent}, {path: 'systemMgr/userCenter', component: UserComponent},
{path: 'systemMgr/influxdbMgr', component: InfluxdbComponent},
{path: 'systemMgr/customCenter', component: UserComponent}, {path: 'systemMgr/customCenter', component: UserComponent},
{path: 'systemMgr/roleMgr', component: RoleComponent}, {path: 'systemMgr/roleMgr', component: RoleComponent},
{path: 'systemMgr/partMgr', component: PartMgrComponent}, {path: 'systemMgr/partMgr', component: PartMgrComponent},
......
...@@ -14,8 +14,6 @@ export class ApiService { ...@@ -14,8 +14,6 @@ export class ApiService {
tokenLoseflag = 0; tokenLoseflag = 0;
public url = environment.baseUrl; public url = environment.baseUrl;
public imgUrl = environment.imgUrl; // 前端地址
public loginlog = { public loginlog = {
getAll: (page, rows, data) => this.trans('get', '/system/loginlog/getAll?page=' + page + '&rows=' + rows, data), getAll: (page, rows, data) => this.trans('get', '/system/loginlog/getAll?page=' + page + '&rows=' + rows, data),
getByTime: (page, rows, data) => this.trans('post', '/system/loginlog/getByTime?page=' + page + '&rows=' + rows, data), getByTime: (page, rows, data) => this.trans('post', '/system/loginlog/getByTime?page=' + page + '&rows=' + rows, data),
...@@ -124,6 +122,7 @@ export class ApiService { ...@@ -124,6 +122,7 @@ export class ApiService {
delDevice: (data) => this.trans('post', '/device/device/delDevice', data), delDevice: (data) => this.trans('post', '/device/device/delDevice', data),
deploySensor: (data) => this.trans('post', '/device/device/deploySensor', data), deploySensor: (data) => this.trans('post', '/device/device/deploySensor', data),
gatewayBindGateway: (data) => this.trans('post', '/device/device/gatewayBindGateway', data), gatewayBindGateway: (data) => this.trans('post', '/device/device/gatewayBindGateway', data),
getSensorByMaxDevice: (data) => this.trans('post', '/device/device/getSensorByMaxDevice', data),
getAll: (data) => this.trans('post', '/device/device/getAll', data), getAll: (data) => this.trans('post', '/device/device/getAll', data),
getByTerm: (data) => this.trans('post', '/device/device/getByTerm', data), getByTerm: (data) => this.trans('post', '/device/device/getByTerm', data),
mountUninstallDevice: (data) => this.trans('post', '/device/device/mountUninstallDevice', data), mountUninstallDevice: (data) => this.trans('post', '/device/device/mountUninstallDevice', data),
...@@ -134,6 +133,22 @@ export class ApiService { ...@@ -134,6 +133,22 @@ export class ApiService {
updateSensor: (data) => this.trans('post', '/device/device/updateSensor', data), updateSensor: (data) => this.trans('post', '/device/device/updateSensor', data),
}; };
public influxdbTables = {
addInfluxdbTables: (data) => this.trans('post', '/device/influxdbTables/addInfluxdbTables', data),
delInfluxdbTables: (data) => this.trans('post', '/device/influxdbTables/delInfluxdbTables', data),
getAll: (data) => this.trans('get', '/device/influxdbTables/getAll', data),
getByCompanyNo: (data) => this.trans('post', '/device/influxdbTables/getByCompanyNo', data),
updateInfluxdbTables: (data) => this.trans('post', '/device/influxdbTables/updateInfluxdbTables', data),
};
public probes = {
addProbes: (data) => this.trans('post', '/device/probes/addProbes', data),
delAProbes: (data) => this.trans('post', '/device/probes/delAProbes', data),
getAll: (data) => this.trans('post', '/device/probes/getAll', data),
getProbesByGateway: (data) => this.trans('post', '/device/probes/getProbesByGateway', data),
updateProbes: (data) => this.trans('post', '/device/probes/updateProbes', data),
};
private trans(type, addr, data) { private trans(type, addr, data) {
this.sendHttpReq(type, addr, data[0], data[1], data[2], data[3]); this.sendHttpReq(type, addr, data[0], data[1], data[2], data[3]);
} }
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
"topicType": "主题类型", "topicType": "主题类型",
"dataType": "数据类型", "dataType": "数据类型",
"inTime": "间隔时间/ms", "inTime": "间隔时间/ms",
"dataSaveInTime": "数据存储间隔时间/ms", "dataSaveInTime": "数据存储间隔时间/μs",
"sensor": "传感器", "sensor": "传感器",
"wayDetail": "通道详情", "wayDetail": "通道详情",
"detail": "详情", "detail": "详情",
...@@ -126,8 +126,29 @@ ...@@ -126,8 +126,29 @@
"wayDescription": "通道描述", "wayDescription": "通道描述",
"addTopic": "新增主题", "addTopic": "新增主题",
"interval": "间隔时间/ms", "interval": "间隔时间/ms",
"dataInterval": "批量数据存储间隔时间/ms", "dataInterval": "批量数据存储间隔时间/μs",
"frequency": "发送频率", "frequency": "发送频率",
"probesModel": "通道模板", "probesModel": "通道模板",
"topicModuleWay": "主题配置模板通道" "topicModuleWay": "主题配置模板通道",
"influxdbMgr": "influxDB管理",
"databaseName": "数据库名称",
"field": "域名",
"dbState": "数据库状态",
"dbPolicy": "存储策略",
"simcard": "sim卡号",
"selectScene": "选择场景",
"configJson": "配置Json",
"updateGateway": "编辑网关",
"selectInfluxDB": "选择数据库",
"topicModel": "主题模板",
"updateSensor": "编辑传感器",
"confirmUnbindThisRecord": "确认解绑此设备吗",
"selectGateway": "选择网关",
"bindGateway": "绑定网关",
"belongAddress": "所属位置",
"sensorType": "传感器类型",
"changeModel": "更换模板",
"sensorTopicWay": "传感器主题通道",
"topic": "主题",
"updateWay": "编辑通道"
} }
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
export const environment = { export const environment = {
production: false, production: false,
baseUrl: 'http://172.16.1.53:8092', // 对外访问测试网地址 baseUrl: 'http://172.16.1.52:8094', // 对外访问测试网地址
imgUrl: 'http://172.16.1.53:8092' // 图片地址
}; };
/* /*
......
...@@ -378,6 +378,7 @@ span.addSpan { ...@@ -378,6 +378,7 @@ span.addSpan {
font-size: 18px; font-size: 18px;
text-indent: 5px; text-indent: 5px;
font-weight: 500; font-weight: 500;
position: relative;
} }
label.subTitle { label.subTitle {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment