Commit 0cf1f8af authored by yating.lin's avatar yating.lin

修改传感器管理页面、传感器主题详情页面、存储策略管理页面、主题配置模板详情页面

parent d328bbf0
......@@ -5,7 +5,7 @@ import {TranslateService} from '@ngx-translate/core';
import {CheckService} from '../../service/check';
import {fadeIn} from '../../animation/fade-in';
import {ActivatedRoute, Router} from '@angular/router';
import {StringUtil} from "../../service/StringUtil";
import {StringUtil} from '../../service/StringUtil';
@Component({
selector: 'app-retention-policy-mgr',
......@@ -57,7 +57,7 @@ export class RetentionPolicyMgrComponent implements OnInit {
getData() {
// this.isLoading = true;
// this.api.influxdbTables.getPolicyByInfluxdb([{companyNo: this.companyNo}, this.next]);
// this.api.influxdbPolicy.getPolicyByInfluxdb([{companyNo: this.companyNo}, this.next]);
this.data = [
{retentionPolicyName: 'witium_policy', duration: '1000h0m0s', shardDuration: '168h0m0s', defaultPolicy: 1, remark: ''},
{retentionPolicyName: 'autogen', duration: '1000h0m0s', shardDuration: '168h0m0s', defaultPolicy: 0, remark: ''},
......@@ -83,7 +83,17 @@ export class RetentionPolicyMgrComponent implements OnInit {
}
onSetDefalut(one) {
const param = {
retentionPolicyNo: this.req.retentionPolicyNo,
influxdbDatabaseNo: this.req.influxdbDatabaseNo,
retentionPolicyName: this.req.retentionPolicyName,
duration: this.req.duration,
defaultPolicy: this.req.defaultPolicy,
shardDuration: this.req.shardDuration,
remark: this.req.remark,
};
this.isLoading = true;
this.api.influxdbPolicy.delInfluxdbPolicy([{influxdbDatabaseNo: one.influxdbDatabaseNo}, this.next]);
}
edit(one) {
......@@ -117,9 +127,9 @@ export class RetentionPolicyMgrComponent implements OnInit {
this.isLoading = false;
if (this.isUpdate) {
this.api.influxdbTables.updateInfluxdbPolicy([param, this.next]);
this.api.influxdbPolicy.updateInfluxdbPolicy([param, this.next]);
} else {
this.api.influxdbTables.addInfluxdbPolicy([param, this.next]);
this.api.influxdbPolicy.addInfluxdbPolicy([param, this.next]);
}
}
......@@ -137,6 +147,6 @@ export class RetentionPolicyMgrComponent implements OnInit {
}
delete(one) {
this.api.influxdbTables.delInfluxdbPolicy([{influxdbDatabaseNo: one.influxdbDatabaseNo}, this.next]);
this.api.influxdbPolicy.delInfluxdbPolicy([{influxdbDatabaseNo: one.influxdbDatabaseNo}, this.next]);
}
}
......@@ -28,6 +28,8 @@
<th nz-th><span>{{'dataType' | translate}}</span></th>
<th nz-th><span>{{'inTime' | translate}}</span></th>
<th nz-th><span>{{'dataSaveInTime' | translate}}</span></th>
<th nz-th><span>{{'retentionPolicyName' | translate}}</span></th>
<th nz-th><span>{{'duration' | translate}}</span></th>
<th nz-th><span>{{'oper' | translate}}</span></th>
</tr>
</thead>
......@@ -40,6 +42,8 @@
<td nz-td>{{one.dataType === 0 ? 'json' : 'bin'}}</td>
<td nz-td>{{one.interval}}</td>
<td nz-td>{{one.dataInterval}}</td>
<td nz-td>{{one.retentionPolicyName}}</td>
<td nz-td>{{one.duration}}</td>
<td nz-td>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider>
......@@ -49,56 +53,7 @@
</tbody>
</nz-table>
</nz-tab>
<!--<nz-tab nzTitle="通道">-->
<!--<div class="subTitle">-->
<!--{{'sensor' | translate}} {{name}} {{'wayDetail' | translate}}-->
<!--</div>-->
<!--<nz-table #nzTable2-->
<!--[nzData]="wayData"-->
<!--[nzSize]="'middle'"-->
<!--nzShowSizeChanger-->
<!--[nzShowPagination]="true"-->
<!--[nzLoading]="isLoading">-->
<!--<thead nz-thead>-->
<!--<tr>-->
<!--<th nz-th><span>{{'wayName' | translate}}</span></th>-->
<!--<th nz-th><span>{{'wayAlias' | translate}}</span></th>-->
<!--<th nz-th><span>{{'topicName' | translate}}</span></th>-->
<!--<th nz-th><span>{{'per' | translate}}</span></th>-->
<!--<th nz-th><span>{{'wayType' | translate}}</span></th>-->
<!--<th nz-th><span>{{'max' | translate}}</span></th>-->
<!--<th nz-th><span>{{'min' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMax' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMaxMax' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMin' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMinMin' | translate}}</span></th>-->
<!--<th nz-th><span>{{'isAlarm' | translate}}</span></th>-->
<!--<th nz-th><span>{{'oper' | translate}}</span></th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody nz-tbody>-->
<!--<tr *ngFor="let one of nzTable2.data, let i = index">-->
<!--<td nz-td>{{one.name}}</td>-->
<!--<td nz-td>{{one.alias}}</td>-->
<!--<td nz-td>{{one.topicName}}</td>-->
<!--<td nz-td>{{one.unit}}</td>-->
<!--<td nz-td>{{one.pType}}</td>-->
<!--<td nz-td>{{one.rangeMax}}</td>-->
<!--<td nz-td>{{one.rangeMin}}</td>-->
<!--<td nz-td>{{one.alarmUp}}</td>-->
<!--<td nz-td>{{one.upperAlarmLimit}}</td>-->
<!--<td nz-td>{{one.alarmDown}}</td>-->
<!--<td nz-td>{{one.lowerAlarmLimit}}</td>-->
<!--<td nz-td>{{one.isAlarm === 1 ? '是': '否'}}</td>-->
<!--<td nz-td>-->
<!--<span class="editSpan" (click)="update2(one)">{{'update' | translate}}</span>-->
<!--<nz-divider nzType="vertical"></nz-divider>-->
<!--<span class="deleteFontColor" (click)="deleteConfirm2(one)">{{'delete' | translate}}</span>-->
<!--</td>-->
<!--</tr>-->
<!--</tbody>-->
<!--</nz-table>-->
<!--</nz-tab>-->
<nz-tab nzTitle="运行状态">
<div class="subTitle">
<div class="backBtnOnTabset" style="top: -2px">
......@@ -197,60 +152,7 @@
</nz-tab>
</nz-tabset>
</nz-tab>
<!--<nz-tab nzTitle="日志服务">-->
<!--<div style="width: calc(100% - 80px);display: inline-block;vertical-align: top;">-->
<!--<app-search-select [label]="'selectTime' | translate" [(value)]="selectTime2"-->
<!--showTime="true" optL="a" optV="b"-->
<!--[data]="[{a: '1小时', b: 1}, {a: '24小时', b: 24}, {a: '7天', b: 144}, {a: '自定义', b: 0}]"></app-search-select>-->
<!--<app-search-date *ngIf="selectTime === 0" [label]="'startTime' | translate" [(value)]="req2.startTime"-->
<!--showTime="true"></app-search-date>-->
<!--<app-search-date *ngIf="selectTime === 0" [label]="'endTime' | translate" [(value)]="req2.endTime"-->
<!--showTime="true"></app-search-date>-->
<!--</div>-->
<!--<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="onSearch2()">-->
<!--<span>{{'search' | translate}}</span></button>-->
<!--<nz-table #nzTable3-->
<!--[nzData]="deviceData"-->
<!--[nzSize]="'middle'"-->
<!--nzShowSizeChanger-->
<!--[nzShowPagination]="true"-->
<!--[nzLoading]="isLoading">-->
<!--<thead nz-thead>-->
<!--<tr>-->
<!--<th nz-th><span>{{'wayIndex' | translate}}</span></th>-->
<!--<th nz-th><span>{{'wayName' | translate}}</span></th>-->
<!--<th nz-th><span>{{'wayAlias' | translate}}</span></th>-->
<!--<th nz-th><span>{{'per' | translate}}</span></th>-->
<!--<th nz-th><span>{{'wayType' | translate}}</span></th>-->
<!--<th nz-th><span>{{'max' | translate}}</span></th>-->
<!--<th nz-th><span>{{'min' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMax' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMaxMax' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMin' | translate}}</span></th>-->
<!--<th nz-th><span>{{'alarmMinMin' | translate}}</span></th>-->
<!--<th nz-th><span>{{'isbind' | translate}}</span></th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody nz-tbody>-->
<!--<tr *ngFor="let one of nzTable3.data, let i = index">-->
<!--<td nz-td>{{i + 1}}</td>-->
<!--<td nz-td>{{one.userName}}</td>-->
<!--<td nz-td>{{one.loginTime}}</td>-->
<!--<td nz-td>{{'web'}}</td>-->
<!--<td nz-td>{{one.userName}}</td>-->
<!--<td nz-td>{{one.realName}}</td>-->
<!--<td nz-td>{{one.loginTime}}</td>-->
<!--<td nz-td>{{'web'}}</td>-->
<!--<td nz-td>{{one.userName}}</td>-->
<!--<td nz-td>{{one.realName}}</td>-->
<!--<td nz-td>{{one.loginTime}}</td>-->
<!--<td nz-td>-->
<!--<span class="deleteFontColor">{{'delete' | translate}}</span>-->
<!--</td>-->
<!--</tr>-->
<!--</tbody>-->
<!--</nz-table>-->
<!--</nz-tab>-->
</nz-tabset>
</div>
<nz-modal [(nzVisible)]="isUC" [nzTitle]="isUpdate ? ('updateTopic' | translate) : ('addTopic' | translate)" [nzContent]="con1" nzWidth="500"
......@@ -267,6 +169,12 @@
<app-search-item inModal="true" [label]="'dataInterval' | translate" [(value)]="req.dataInterval"></app-search-item>
<!--<app-search-item isMust="true" inModal="true" [label]="'frequency' | translate" [(value)]="req.frequency"></app-search-item>-->
<app-search-item isMust="true" inModal="true" [label]="'interval' | translate" [(value)]="req.interval"></app-search-item>
<app-search-select inModal="true" [label]="'retentionPolicyName' | translate" [(value)]="req.retentionPolicyNo"
[data]="policyList"
(valueChange)="onChangePolicy()"
optL="opLevel" optV="opValue"></app-search-select>
<app-search-item inModal="true" [readonly]="'true'" [label]="'duration' | translate" [(value)]="req.duration"></app-search-item>
</ng-template>
<ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()">
......
......@@ -54,6 +54,8 @@ export class SensorDetailComponent implements OnInit {
hisDevInfo;
selectedTopicValue;
policyList = [];
constructor(private api: ApiService, private message: NzMessageService, private router: Router, private ck: CheckService,
private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) {
}
......@@ -77,6 +79,8 @@ export class SensorDetailComponent implements OnInit {
this.getCurrent();
}
});
this.getAllPolicies();
}
next = (data) => {
......@@ -159,13 +163,13 @@ export class SensorDetailComponent implements OnInit {
format(timestamp, format) {
const date = new Date(timestamp);
const o = {
'M+': date.getMonth() +1,
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() +3) /3),
S: date.getMilliseconds(),};
'q+': Math.floor((date.getMonth() + 3) / 3),
S: date.getMilliseconds()};
let formatString = format;
if (/(y+)/.test(format)) {
formatString = format.replace(RegExp.$1, (`${date.getFullYear()}`).substr(4 - RegExp.$1.length));
......@@ -180,6 +184,25 @@ export class SensorDetailComponent implements OnInit {
}
getAllPolicies() {
this.isLoading = true;
this.policyList = [];
this.api.influxdbPolicy.getAllPolicyByCompany(['', (data) => {
if (data.constructor === Array) {
data.forEach(one => {
this.policyList.push({
opLevel: one.databaseName + ' : ' + one.retentionPolicyName,
opValue: one.retentionPolicyNo,
duration: one.duration
});
});
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
getHistoryData(): void {
// this.hisTopicName = this.wayData[0].topicName;
this.hisTopicName = this.selectedTopicValue;
......@@ -285,6 +308,15 @@ export class SensorDetailComponent implements OnInit {
this.getHistoryData();
}
onChangePolicy() {
if (this.policyList && this.req.retentionPolicyNo) {
const currPolicy = this.policyList.filter(item => item.opValue === this.req.retentionPolicyNo);
if (currPolicy) {
this.req.duration = currPolicy[0].duration;
}
}
}
close() {
}
......@@ -315,6 +347,13 @@ export class SensorDetailComponent implements OnInit {
this.isUpdate = true;
this.req.frequency = 0;
this.req.oldTopicName = one.topicName;
if (this.policyList && one.retentionPolicyNo) {
const currPolicy = this.policyList.filter(item => item.opValue === one.retentionPolicyNo);
if (currPolicy) {
this.req.duration = currPolicy[0].duration;
}
}
this.isUC = true;
this.try = {
trans: {dataType: 'dataType', frequency: 'frequency', interval: 'interval',
......
......@@ -109,6 +109,10 @@
<!--[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-select inModal="true" [label]="'selectInfluxDBTable' | translate" [(value)]="req.influxdbDatabaseNo"
[data]="influxDBTableList" optL="opLevel" optV="opValue"></app-search-select>
<app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
</ng-template>
......
......@@ -49,6 +49,8 @@ export class SensorMgrComponent implements OnInit {
rows = 10;
total = 0;
influxDBTableList = [];
constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private modalService: NzModalService, private translate: TranslateService, private ck: CheckService) {
}
......@@ -62,6 +64,7 @@ export class SensorMgrComponent implements OnInit {
this.getTopicModels();
this.getCompanys();
this.getGateways();
this.getAllInfluxDB();
}
next = (data) => {
......@@ -131,6 +134,23 @@ export class SensorMgrComponent implements OnInit {
}]);
}
getAllInfluxDB() {
this.isLoading = true;
this.influxDBTableList = [];
this.api.influxdbTables.getAll( ['', (data) => {
if (data && data.constructor === Array) {
data.forEach(one => {
this.influxDBTableList.push({opLevel: one.databaseName, opValue: one.influxdbDatabaseNo});
});
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
onSearch() {
this.page = 1;
this.query.isBind = null;
......
......@@ -17,6 +17,8 @@
<th nz-th><span>{{'dataType' | translate}}</span></th>
<th nz-th><span>{{'dataInterval' | translate}}</span></th>
<th nz-th><span>{{'inTime' | translate}}</span></th>
<th nz-th><span>{{'retentionPolicyName' | translate}}</span></th>
<th nz-th><span>{{'duration' | translate}}</span></th>
<th nz-th><span>{{'oper' | translate}}</span></th>
</tr>
</thead>
......@@ -29,6 +31,8 @@
<td nz-td>{{one.dataType === 0 ? 'json' : 'bin'}}</td>
<td nz-td>{{one.dataInterval}}</td>
<td nz-td>{{one.interval}}</td>
<td nz-td>{{one.retentionPolicyName}}</td>
<td nz-td>{{one.duration}}</td>
<td nz-td>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider>
......@@ -53,6 +57,13 @@
<app-search-item inModal="true" [label]="'dataInterval' | translate" [(value)]="req.dataInterval"></app-search-item>
<!--<app-search-item isMust="true" inModal="true" [label]="'frequency' | translate" [(value)]="req.frequency"></app-search-item>-->
<app-search-item isMust="true" inModal="true" [label]="'interval' | translate" [(value)]="req.interval"></app-search-item>
<app-search-select inModal="true" [label]="'retentionPolicyName' | translate" [(value)]="req.retentionPolicyNo"
[data]="policyList"
(valueChange)="onChangePolicy()"
optL="opLevel" optV="opValue"></app-search-select>
<app-search-item inModal="true" [readonly]="'true'" [label]="'duration' | translate" [(value)]="req.duration"></app-search-item>
</ng-template>
<ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
......
......@@ -24,6 +24,8 @@ export class TopicModuleDetailComponent implements OnInit {
probesModels = [];
try = {};
policyList = [];
constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute,
private translate: TranslateService, private router: Router, private modalService: NzModalService,
private ck: CheckService) {
......@@ -42,6 +44,7 @@ export class TopicModuleDetailComponent implements OnInit {
}
});
this.getProbsModels();
this.getAllPolicies();
}
getData() {
......@@ -61,6 +64,25 @@ export class TopicModuleDetailComponent implements OnInit {
}]);
}
getAllPolicies() {
this.isLoading = true;
this.policyList = [];
this.api.influxdbPolicy.getAllPolicyByCompany(['', (data) => {
if (data.constructor === Array) {
data.forEach(one => {
this.policyList.push({
opLevel: one.databaseName + ' : ' + one.retentionPolicyName,
opValue: one.retentionPolicyNo,
duration: one.duration
});
});
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
onSearch() {
this.query();
}
......@@ -106,6 +128,14 @@ export class TopicModuleDetailComponent implements OnInit {
this.req = {...one};
this.req.frequency = 0;
this.req.oldTopicName = one.topicName;
if (this.policyList && one.retentionPolicyNo) {
const currPolicy = this.policyList.filter(item => item.opValue === one.retentionPolicyNo);
if (currPolicy) {
this.req.duration = currPolicy[0].duration;
}
}
this.try = {
trans: {topicName: 'topicName', topicType: 'topicType',
dataType: 'dataType', interval: 'inTime', dataInterval: 'dataInterval'},
......@@ -120,23 +150,32 @@ export class TopicModuleDetailComponent implements OnInit {
save() {
this.isLoading = true;
let req: any = {};
let param: any = {};
if (this.isUpdate) {
req = this.req;
req.topicModelNo = this.topicModelNo;
if (!this.ck.formCheck(req, this.try)) {
param = this.req;
param.topicModelNo = this.topicModelNo;
if (!this.ck.formCheck(param, this.try)) {
this.isLoading = false;
return false;
}
this.api.topicModelInfo.updateTopicModelInfo([req, this.next]);
this.api.topicModelInfo.updateTopicModelInfo([param, this.next]);
} else {
req.topicModelNo = this.topicModelNo;
req.addTopicModelForInfoVos = [this.req];
if (!this.ck.formCheck(req.addTopicModelForInfoVos[0], this.try)) {
param.topicModelNo = this.topicModelNo;
param.addTopicModelForInfoVos = [this.req];
if (!this.ck.formCheck(param.addTopicModelForInfoVos[0], this.try)) {
this.isLoading = false;
return false;
}
this.api.topicModelInfo.addTopicModelInfo([req, this.next]);
this.api.topicModelInfo.addTopicModelInfo([param, this.next]);
}
}
onChangePolicy() {
if (this.policyList && this.req.retentionPolicyNo) {
const currPolicy = this.policyList.filter(item => item.opValue === this.req.retentionPolicyNo);
if (currPolicy) {
this.req.duration = currPolicy[0].duration;
}
}
}
......
......@@ -146,10 +146,14 @@ export class ApiService {
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),
addInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbTables/addInfluxdbPolicy', data),
updateInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbTables/addInfluxdbPolicy', data),
getPolicyByInfluxdb: (data) => this.trans('post', '/device/influxdbTables/getPolicyByInfluxdb', data),
delInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbTables/delInfluxdbPolicy', data),
};
public influxdbPolicy = {
addInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbPolicy/addInfluxdbPolicy', data),
updateInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbPolicy/updateInfluxdbPolicy', data),
getPolicyByInfluxdb: (data) => this.trans('post', '/device/influxdbPolicy/getPolicyByInfluxdb', data),
delInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbPolicy/delInfluxdbPolicy', data),
getAllPolicyByCompany: (data) => this.trans('post', '/device/influxdbPolicy/getAllPolicyByCompany', data),
};
public probes = {
......
......@@ -187,6 +187,7 @@
"duration": "存储策略时长",
"shardDuration": "shard保存时长",
"retentionPolicyName": "存储策略名称",
"retentionPolicyNo": "存储策略名称",
"isDefault": "是否 default",
"setAsDefault": "设为 default",
"editInfluxDB": "编辑InfluxDB",
......@@ -195,5 +196,6 @@
"addPolicy": "新增存储策略",
"isDefaultDB": "是否 default",
"popDuration": "存储策略时长(h)",
"popShardDuration": "shard保存时长(h)"
"popShardDuration": "shard保存时长(h)",
"selectInfluxDBTable": "选择InfluxDB数据库"
}
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