Browse Source

[完善]安信配置文件回显

非煤矿业企业安全风险监测预警系统
邵佳豪 2 years ago
parent
commit
59cfcaab02
  1. 4
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html
  2. 75
      src/app/system-management/host-config/host-config.component.ts

4
src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html

@ -52,7 +52,7 @@
<td class="operation"> <td class="operation">
<a (click)="edit(data)" style="margin-right: 12px;">编辑</a> <a (click)="edit(data)" style="margin-right: 12px;">编辑</a>
<a (click)="config(data)" style="margin-right: 12px;">配置</a> <a (click)="config(data)" style="margin-right: 12px;">配置</a>
<nz-modal [(nzVisible)]="isVisible" [nzWidth]="350" nzTitle="请选择要配置的边缘主机" (nzOnCancel)="handleCancel()" <!-- <nz-modal [(nzVisible)]="isVisible" [nzWidth]="350" nzTitle="请选择要配置的边缘主机" (nzOnCancel)="handleCancel()"
(nzOnOk)="handleOk()"> (nzOnOk)="handleOk()">
<ng-container *nzModalContent> <ng-container *nzModalContent>
<nz-radio-group [(ngModel)]="radioValue"> <nz-radio-group [(ngModel)]="radioValue">
@ -61,7 +61,7 @@
<label nz-radio nzValue="警旗3">警旗3</label> <label nz-radio nzValue="警旗3">警旗3</label>
</nz-radio-group> </nz-radio-group>
</ng-container> </ng-container>
</nz-modal> </nz-modal> -->
<a (click)="download(data)" style="margin-right: 12px;">下载设备编号</a> <a (click)="download(data)" style="margin-right: 12px;">下载设备编号</a>
<a class="red" (click)="delete(data)">删除</a> <a class="red" (click)="delete(data)">删除</a>
</td> </td>

75
src/app/system-management/host-config/host-config.component.ts

@ -22,6 +22,7 @@ import { SendFileComponent } from './send-file/send-file.component';
import { ImageLabel2Component } from '../image-label2/image-label2.component'; import { ImageLabel2Component } from '../image-label2/image-label2.component';
import { ImageLabelComponent } from '../image-label/image-label.component'; import { ImageLabelComponent } from '../image-label/image-label.component';
import { HuangHaiConfigComponent } from './huang-hai-config/huang-hai-config.component'; import { HuangHaiConfigComponent } from './huang-hai-config/huang-hai-config.component';
interface Camera { interface Camera {
name: string; name: string;
user: string; user: string;
@ -68,28 +69,25 @@ export class HostConfigComponent implements OnInit {
this.hostType = this.route.snapshot.queryParams.type; this.hostType = this.route.snapshot.queryParams.type;
this.getCamera(); this.getCamera();
this.getHostData();
}
//获得盒子配置
getHostData() {
this.http.get(`/api/EdgeDevices/${this.hostId}`).subscribe({ this.http.get(`/api/EdgeDevices/${this.hostId}`).subscribe({
next: (data: any) => { next: (data: any) => {
console.log(data); console.log(data);
this.hostData = data; this.hostData = data;
// let isExist = data.configFiles.find((item, index, arr) => {
// if (item.name == 'source.yaml') {
// console.log("存在", index)
// return item
// }
// })
if (data.configFiles && data.configFiles.length != 0) { if (data.configFiles && data.configFiles.length != 0) {
this.isSourceYaml = true; this.isSourceYaml = true;
} else { } else {
this.isSourceYaml = false; this.isSourceYaml = false;
} }
}, },
error: (err) => { error: (err) => {},
// this.message.create('error', '请先下发source.yaml配置');
},
}); });
} }
listOfData: Camera[] = []; listOfData: Camera[] = [];
goback() { goback() {
history.go(-1); history.go(-1);
@ -1540,6 +1538,7 @@ rule_threshold:
next: (data) => { next: (data) => {
resolve(data); resolve(data);
this.message.success('文件保存成功'); this.message.success('文件保存成功');
this.getHostData();
let params = { let params = {
edgeDeviceId: this.hostId, edgeDeviceId: this.hostId,
fileName: 'data.yaml', fileName: 'data.yaml',
@ -1566,25 +1565,16 @@ rule_threshold:
} }
configJsonToAx() { configJsonToAx() {
let server;
let obs;
if (location.origin.indexOf('121') !== -1) {
server = 'http://121.36.37.70:8208';
obs = 'http://121.36.37.70:8906';
} else {
server = 'http://10.156.134.53:8208';
obs = 'https://znaq.sinochemoilmarketing.com';
}
let data = { let data = {
server: server, server: null,
obs: obs, obs: null,
userInfo: { userInfo: {
user: '', user: '',
password: '', password: '',
}, },
ip: this.hostData.hostIPAddress, ip: this.hostData.hostIPAddress,
imgScale: 1.5, imgScale: 1.5,
cpuRtsp: true, cpuRtsp: false,
caps: [], caps: [],
params: { params: {
smoke_sleep_m: 5, smoke_sleep_m: 5,
@ -1604,7 +1594,47 @@ rule_threshold:
fire_continue_s: 3, fire_continue_s: 3,
}, },
}; };
console.log(this.listOfData); console.log(this.hostData);
//如果保存过安信的配置文件
if (
this.hostData.configFiles &&
this.hostData.configFiles.find((v) => v.name === 'data.yaml')
) {
let oldFile = yaml.load(
this.hostData.configFiles.find((v) => v.name === 'data.yaml').content
);
// console.log('曾经保存过安信的配置文件', oldFile);
for (const key in oldFile) {
const element = oldFile[key];
if (key !== 'caps' && key !== 'params') {
if (data.hasOwnProperty(key)) {
data[key] = element;
}
}
if (key === 'params') {
for (const v in element) {
const item = element[v];
if (data.params.hasOwnProperty(v)) {
data.params[v] = item;
}
}
}
}
} else {
let server;
let obs;
if (location.origin.indexOf('121') !== -1) {
server = 'http://121.36.37.70:8208';
obs = 'http://121.36.37.70:8906';
} else {
server = 'http://10.156.134.53:8208';
obs = 'https://znaq.sinochemoilmarketing.com';
}
data.server = server;
data.obs = obs;
}
//填充caps数组
this.listOfData.forEach((item: any) => { this.listOfData.forEach((item: any) => {
if (item.isEnabled) { if (item.isEnabled) {
let type = null; let type = null;
@ -1639,7 +1669,6 @@ rule_threshold:
data.caps.push(obj); data.caps.push(obj);
} }
}); });
return data; return data;
} }
} }

Loading…
Cancel
Save