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

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

parent d328bbf0
...@@ -5,7 +5,7 @@ import {TranslateService} from '@ngx-translate/core'; ...@@ -5,7 +5,7 @@ import {TranslateService} from '@ngx-translate/core';
import {CheckService} from '../../service/check'; import {CheckService} from '../../service/check';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {StringUtil} from "../../service/StringUtil"; import {StringUtil} from '../../service/StringUtil';
@Component({ @Component({
selector: 'app-retention-policy-mgr', selector: 'app-retention-policy-mgr',
...@@ -57,7 +57,7 @@ export class RetentionPolicyMgrComponent implements OnInit { ...@@ -57,7 +57,7 @@ export class RetentionPolicyMgrComponent implements OnInit {
getData() { getData() {
// this.isLoading = true; // this.isLoading = true;
// this.api.influxdbTables.getPolicyByInfluxdb([{companyNo: this.companyNo}, this.next]); // this.api.influxdbPolicy.getPolicyByInfluxdb([{companyNo: this.companyNo}, this.next]);
this.data = [ this.data = [
{retentionPolicyName: 'witium_policy', duration: '1000h0m0s', shardDuration: '168h0m0s', defaultPolicy: 1, remark: ''}, {retentionPolicyName: 'witium_policy', duration: '1000h0m0s', shardDuration: '168h0m0s', defaultPolicy: 1, remark: ''},
{retentionPolicyName: 'autogen', duration: '1000h0m0s', shardDuration: '168h0m0s', defaultPolicy: 0, remark: ''}, {retentionPolicyName: 'autogen', duration: '1000h0m0s', shardDuration: '168h0m0s', defaultPolicy: 0, remark: ''},
...@@ -83,7 +83,17 @@ export class RetentionPolicyMgrComponent implements OnInit { ...@@ -83,7 +83,17 @@ export class RetentionPolicyMgrComponent implements OnInit {
} }
onSetDefalut(one) { 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) { edit(one) {
...@@ -117,9 +127,9 @@ export class RetentionPolicyMgrComponent implements OnInit { ...@@ -117,9 +127,9 @@ export class RetentionPolicyMgrComponent implements OnInit {
this.isLoading = false; this.isLoading = false;
if (this.isUpdate) { if (this.isUpdate) {
this.api.influxdbTables.updateInfluxdbPolicy([param, this.next]); this.api.influxdbPolicy.updateInfluxdbPolicy([param, this.next]);
} else { } else {
this.api.influxdbTables.addInfluxdbPolicy([param, this.next]); this.api.influxdbPolicy.addInfluxdbPolicy([param, this.next]);
} }
} }
...@@ -137,6 +147,6 @@ export class RetentionPolicyMgrComponent implements OnInit { ...@@ -137,6 +147,6 @@ export class RetentionPolicyMgrComponent implements OnInit {
} }
delete(one) { delete(one) {
this.api.influxdbTables.delInfluxdbPolicy([{influxdbDatabaseNo: one.influxdbDatabaseNo}, this.next]); this.api.influxdbPolicy.delInfluxdbPolicy([{influxdbDatabaseNo: one.influxdbDatabaseNo}, this.next]);
} }
} }
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
<th nz-th><span>{{'dataType' | translate}}</span></th> <th nz-th><span>{{'dataType' | translate}}</span></th>
<th nz-th><span>{{'inTime' | translate}}</span></th> <th nz-th><span>{{'inTime' | translate}}</span></th>
<th nz-th><span>{{'dataSaveInTime' | 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> <th nz-th><span>{{'oper' | translate}}</span></th>
</tr> </tr>
</thead> </thead>
...@@ -40,6 +42,8 @@ ...@@ -40,6 +42,8 @@
<td nz-td>{{one.dataType === 0 ? 'json' : 'bin'}}</td> <td nz-td>{{one.dataType === 0 ? 'json' : 'bin'}}</td>
<td nz-td>{{one.interval}}</td> <td nz-td>{{one.interval}}</td>
<td nz-td>{{one.dataInterval}}</td> <td nz-td>{{one.dataInterval}}</td>
<td nz-td>{{one.retentionPolicyName}}</td>
<td nz-td>{{one.duration}}</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>
...@@ -49,56 +53,7 @@ ...@@ -49,56 +53,7 @@
</tbody> </tbody>
</nz-table> </nz-table>
</nz-tab> </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="运行状态"> <nz-tab nzTitle="运行状态">
<div class="subTitle"> <div class="subTitle">
<div class="backBtnOnTabset" style="top: -2px"> <div class="backBtnOnTabset" style="top: -2px">
...@@ -197,60 +152,7 @@ ...@@ -197,60 +152,7 @@
</nz-tab> </nz-tab>
</nz-tabset> </nz-tabset>
</nz-tab> </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> </nz-tabset>
</div> </div>
<nz-modal [(nzVisible)]="isUC" [nzTitle]="isUpdate ? ('updateTopic' | translate) : ('addTopic' | translate)" [nzContent]="con1" nzWidth="500" <nz-modal [(nzVisible)]="isUC" [nzTitle]="isUpdate ? ('updateTopic' | translate) : ('addTopic' | translate)" [nzContent]="con1" nzWidth="500"
...@@ -267,6 +169,12 @@ ...@@ -267,6 +169,12 @@
<app-search-item inModal="true" [label]="'dataInterval' | translate" [(value)]="req.dataInterval"></app-search-item> <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]="'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-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>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()">
......
...@@ -54,6 +54,8 @@ export class SensorDetailComponent implements OnInit { ...@@ -54,6 +54,8 @@ export class SensorDetailComponent implements OnInit {
hisDevInfo; hisDevInfo;
selectedTopicValue; selectedTopicValue;
policyList = [];
constructor(private api: ApiService, private message: NzMessageService, private router: Router, private ck: CheckService, constructor(private api: ApiService, private message: NzMessageService, private router: Router, private ck: CheckService,
private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) { private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) {
} }
...@@ -77,6 +79,8 @@ export class SensorDetailComponent implements OnInit { ...@@ -77,6 +79,8 @@ export class SensorDetailComponent implements OnInit {
this.getCurrent(); this.getCurrent();
} }
}); });
this.getAllPolicies();
} }
next = (data) => { next = (data) => {
...@@ -159,13 +163,13 @@ export class SensorDetailComponent implements OnInit { ...@@ -159,13 +163,13 @@ export class SensorDetailComponent implements OnInit {
format(timestamp, format) { format(timestamp, format) {
const date = new Date(timestamp); const date = new Date(timestamp);
const o = { const o = {
'M+': date.getMonth() +1, 'M+': date.getMonth() + 1,
'd+': date.getDate(), 'd+': date.getDate(),
'h+': date.getHours(), 'h+': date.getHours(),
'm+': date.getMinutes(), 'm+': date.getMinutes(),
's+': date.getSeconds(), 's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() +3) /3), 'q+': Math.floor((date.getMonth() + 3) / 3),
S: date.getMilliseconds(),}; S: date.getMilliseconds()};
let formatString = format; let formatString = format;
if (/(y+)/.test(format)) { if (/(y+)/.test(format)) {
formatString = format.replace(RegExp.$1, (`${date.getFullYear()}`).substr(4 - RegExp.$1.length)); formatString = format.replace(RegExp.$1, (`${date.getFullYear()}`).substr(4 - RegExp.$1.length));
...@@ -180,6 +184,25 @@ export class SensorDetailComponent implements OnInit { ...@@ -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 { getHistoryData(): void {
// this.hisTopicName = this.wayData[0].topicName; // this.hisTopicName = this.wayData[0].topicName;
this.hisTopicName = this.selectedTopicValue; this.hisTopicName = this.selectedTopicValue;
...@@ -285,6 +308,15 @@ export class SensorDetailComponent implements OnInit { ...@@ -285,6 +308,15 @@ export class SensorDetailComponent implements OnInit {
this.getHistoryData(); 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() { close() {
} }
...@@ -315,6 +347,13 @@ export class SensorDetailComponent implements OnInit { ...@@ -315,6 +347,13 @@ export class SensorDetailComponent implements OnInit {
this.isUpdate = true; this.isUpdate = true;
this.req.frequency = 0; this.req.frequency = 0;
this.req.oldTopicName = one.topicName; 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.isUC = true;
this.try = { this.try = {
trans: {dataType: 'dataType', frequency: 'frequency', interval: 'interval', trans: {dataType: 'dataType', frequency: 'frequency', interval: 'interval',
......
...@@ -109,6 +109,10 @@ ...@@ -109,6 +109,10 @@
<!--[data]="influxdbs" inModal="true" optV="influxdbDatabaseNo"></app-search-select>--> <!--[data]="influxdbs" inModal="true" optV="influxdbDatabaseNo"></app-search-select>-->
<app-search-select [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName" <app-search-select [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" inModal="true" optV="sceneNo"></app-search-select> [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" <app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item> [(value)]="req.remark"></app-search-item>
</ng-template> </ng-template>
......
...@@ -49,6 +49,8 @@ export class SensorMgrComponent implements OnInit { ...@@ -49,6 +49,8 @@ export class SensorMgrComponent implements OnInit {
rows = 10; rows = 10;
total = 0; total = 0;
influxDBTableList = [];
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 ck: CheckService) { private modalService: NzModalService, private translate: TranslateService, private ck: CheckService) {
} }
...@@ -62,6 +64,7 @@ export class SensorMgrComponent implements OnInit { ...@@ -62,6 +64,7 @@ export class SensorMgrComponent implements OnInit {
this.getTopicModels(); this.getTopicModels();
this.getCompanys(); this.getCompanys();
this.getGateways(); this.getGateways();
this.getAllInfluxDB();
} }
next = (data) => { next = (data) => {
...@@ -131,6 +134,23 @@ export class SensorMgrComponent implements OnInit { ...@@ -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() { onSearch() {
this.page = 1; this.page = 1;
this.query.isBind = null; this.query.isBind = null;
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<th nz-th><span>{{'dataType' | translate}}</span></th> <th nz-th><span>{{'dataType' | translate}}</span></th>
<th nz-th><span>{{'dataInterval' | translate}}</span></th> <th nz-th><span>{{'dataInterval' | translate}}</span></th>
<th nz-th><span>{{'inTime' | 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> <th nz-th><span>{{'oper' | translate}}</span></th>
</tr> </tr>
</thead> </thead>
...@@ -29,6 +31,8 @@ ...@@ -29,6 +31,8 @@
<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.dataInterval}}</td>
<td nz-td>{{one.interval}}</td> <td nz-td>{{one.interval}}</td>
<td nz-td>{{one.retentionPolicyName}}</td>
<td nz-td>{{one.duration}}</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>
...@@ -53,6 +57,13 @@ ...@@ -53,6 +57,13 @@
<app-search-item inModal="true" [label]="'dataInterval' | translate" [(value)]="req.dataInterval"></app-search-item> <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]="'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-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>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
......
...@@ -24,6 +24,8 @@ export class TopicModuleDetailComponent implements OnInit { ...@@ -24,6 +24,8 @@ export class TopicModuleDetailComponent implements OnInit {
probesModels = []; probesModels = [];
try = {}; try = {};
policyList = [];
constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute, constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute,
private translate: TranslateService, private router: Router, private modalService: NzModalService, private translate: TranslateService, private router: Router, private modalService: NzModalService,
private ck: CheckService) { private ck: CheckService) {
...@@ -42,6 +44,7 @@ export class TopicModuleDetailComponent implements OnInit { ...@@ -42,6 +44,7 @@ export class TopicModuleDetailComponent implements OnInit {
} }
}); });
this.getProbsModels(); this.getProbsModels();
this.getAllPolicies();
} }
getData() { getData() {
...@@ -61,6 +64,25 @@ export class TopicModuleDetailComponent implements OnInit { ...@@ -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() { onSearch() {
this.query(); this.query();
} }
...@@ -106,6 +128,14 @@ export class TopicModuleDetailComponent implements OnInit { ...@@ -106,6 +128,14 @@ export class TopicModuleDetailComponent implements OnInit {
this.req = {...one}; this.req = {...one};
this.req.frequency = 0; this.req.frequency = 0;
this.req.oldTopicName = one.topicName; 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 = { this.try = {
trans: {topicName: 'topicName', topicType: 'topicType', trans: {topicName: 'topicName', topicType: 'topicType',
dataType: 'dataType', interval: 'inTime', dataInterval: 'dataInterval'}, dataType: 'dataType', interval: 'inTime', dataInterval: 'dataInterval'},
...@@ -120,23 +150,32 @@ export class TopicModuleDetailComponent implements OnInit { ...@@ -120,23 +150,32 @@ export class TopicModuleDetailComponent implements OnInit {
save() { save() {
this.isLoading = true; this.isLoading = true;
let req: any = {}; let param: any = {};
if (this.isUpdate) { if (this.isUpdate) {
req = this.req; param = this.req;
req.topicModelNo = this.topicModelNo; param.topicModelNo = this.topicModelNo;
if (!this.ck.formCheck(req, this.try)) { if (!this.ck.formCheck(param, this.try)) {
this.isLoading = false; this.isLoading = false;
return false; return false;
} }
this.api.topicModelInfo.updateTopicModelInfo([req, this.next]); this.api.topicModelInfo.updateTopicModelInfo([param, this.next]);
} else { } else {
req.topicModelNo = this.topicModelNo; param.topicModelNo = this.topicModelNo;
req.addTopicModelForInfoVos = [this.req]; param.addTopicModelForInfoVos = [this.req];
if (!this.ck.formCheck(req.addTopicModelForInfoVos[0], this.try)) { if (!this.ck.formCheck(param.addTopicModelForInfoVos[0], this.try)) {
this.isLoading = false; this.isLoading = false;
return 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 { ...@@ -146,10 +146,14 @@ export class ApiService {
getAll: (data) => this.trans('get', '/device/influxdbTables/getAll', data), getAll: (data) => this.trans('get', '/device/influxdbTables/getAll', data),
getByCompanyNo: (data) => this.trans('post', '/device/influxdbTables/getByCompanyNo', data), getByCompanyNo: (data) => this.trans('post', '/device/influxdbTables/getByCompanyNo', data),
updateInfluxdbTables: (data) => this.trans('post', '/device/influxdbTables/updateInfluxdbTables', 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), public influxdbPolicy = {
delInfluxdbPolicy: (data) => this.trans('post', '/device/influxdbTables/delInfluxdbPolicy', data), 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 = { public probes = {
......
...@@ -187,6 +187,7 @@ ...@@ -187,6 +187,7 @@
"duration": "存储策略时长", "duration": "存储策略时长",
"shardDuration": "shard保存时长", "shardDuration": "shard保存时长",
"retentionPolicyName": "存储策略名称", "retentionPolicyName": "存储策略名称",
"retentionPolicyNo": "存储策略名称",
"isDefault": "是否 default", "isDefault": "是否 default",
"setAsDefault": "设为 default", "setAsDefault": "设为 default",
"editInfluxDB": "编辑InfluxDB", "editInfluxDB": "编辑InfluxDB",
...@@ -195,5 +196,6 @@ ...@@ -195,5 +196,6 @@
"addPolicy": "新增存储策略", "addPolicy": "新增存储策略",
"isDefaultDB": "是否 default", "isDefaultDB": "是否 default",
"popDuration": "存储策略时长(h)", "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