|
|
|
@ -9,12 +9,14 @@ import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/htt
|
|
|
|
|
import { EditcameraComponent } from './editcamera/editcamera.component'; |
|
|
|
|
import { catchError, tap } from 'rxjs/operators'; |
|
|
|
|
import { ConfigFormDataService } from 'src/app/service/configFormData.service'; |
|
|
|
|
import { SendFileComponent } from './send-file/send-file.component'; |
|
|
|
|
interface Camera { |
|
|
|
|
name: string; |
|
|
|
|
user: string; |
|
|
|
|
password: string; |
|
|
|
|
uri: string; |
|
|
|
|
type: number; |
|
|
|
|
order: number; |
|
|
|
|
dimensionedPoints: string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -35,6 +37,30 @@ export class HostConfigComponent implements OnInit {
|
|
|
|
|
this.hostId = this.route.snapshot.queryParams.hostId |
|
|
|
|
this.orId = this.route.snapshot.queryParams.orId |
|
|
|
|
this.getCamera() |
|
|
|
|
|
|
|
|
|
this.http.get(`/api/EdgeDevices/${this.hostId}`).subscribe( |
|
|
|
|
{ |
|
|
|
|
next: ((data: any) => { |
|
|
|
|
console.log(data) |
|
|
|
|
// let isExist = data.configFiles.find((item, index, arr) => {
|
|
|
|
|
// if (item.name == 'source.yaml') {
|
|
|
|
|
// console.log("存在", index)
|
|
|
|
|
// return item
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
if (data.configFiles) { |
|
|
|
|
this.isSourceYaml = true |
|
|
|
|
} else { |
|
|
|
|
this.isSourceYaml = false |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
error: (err) => { |
|
|
|
|
// this.message.create('error', '请先下发source.yaml配置');
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
listOfData: Camera[] = []; |
|
|
|
|
goback() { |
|
|
|
@ -42,7 +68,10 @@ export class HostConfigComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
//摄像头
|
|
|
|
|
getCamera() { |
|
|
|
|
this.http.get('/api/Cameras').subscribe((data: any) => { |
|
|
|
|
let params = { |
|
|
|
|
EdgeDeviceId: this.hostId |
|
|
|
|
} |
|
|
|
|
this.http.get('/api/Cameras',{ params: params }).subscribe((data: any) => { |
|
|
|
|
data.items.forEach(element => { |
|
|
|
|
element.dimensionedPointsObj = JSON.parse(element.dimensionedPoints) |
|
|
|
|
}); |
|
|
|
@ -67,12 +96,15 @@ export class HostConfigComponent implements OnInit {
|
|
|
|
|
password: instance.validateForm.value.password, |
|
|
|
|
uri: instance.validateForm.value.uri, |
|
|
|
|
type: instance.validateForm.value.type, |
|
|
|
|
organizationId: this.orId |
|
|
|
|
organizationId: this.orId, |
|
|
|
|
edgeDeviceId: this.hostId, |
|
|
|
|
order: instance.validateForm.value.order, |
|
|
|
|
} |
|
|
|
|
this.http.post('/api/Cameras', body).subscribe(data => { |
|
|
|
|
resolve(data) |
|
|
|
|
this.message.create('success', '创建成功!'); |
|
|
|
|
this.getCamera() |
|
|
|
|
this.isSourceYaml = false |
|
|
|
|
return true |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -104,12 +136,15 @@ export class HostConfigComponent implements OnInit {
|
|
|
|
|
password: instance.validateForm.value.password, |
|
|
|
|
uri: instance.validateForm.value.uri, |
|
|
|
|
type: instance.validateForm.value.type, |
|
|
|
|
organizationId: this.orId |
|
|
|
|
organizationId: this.orId, |
|
|
|
|
edgeDeviceId: this.hostId, |
|
|
|
|
order: instance.validateForm.value.order, |
|
|
|
|
} |
|
|
|
|
this.http.put(`/api/Cameras/${data.id}`, body).subscribe(data => { |
|
|
|
|
resolve(data) |
|
|
|
|
this.message.create('success', '创建成功!'); |
|
|
|
|
this.message.create('success', '编辑成功!'); |
|
|
|
|
this.getCamera() |
|
|
|
|
this.isSourceYaml = false |
|
|
|
|
return true |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -131,17 +166,59 @@ export class HostConfigComponent implements OnInit {
|
|
|
|
|
this.http.delete(`/api/Cameras/${item.id}`).subscribe(data => { |
|
|
|
|
this.message.create('success', '删除成功!'); |
|
|
|
|
this.getCamera() |
|
|
|
|
this.isSourceYaml = false |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
nzCancelText: '取消' |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isSourceYaml: boolean |
|
|
|
|
|
|
|
|
|
label(item) { |
|
|
|
|
|
|
|
|
|
this.http.get(`/api/EdgeDevices/${this.hostId}`).subscribe( |
|
|
|
|
{ |
|
|
|
|
next: ((data: any) => { |
|
|
|
|
console.log(data) |
|
|
|
|
// let isExist = data.configFiles.find((item, index, arr) => {
|
|
|
|
|
// if (item.name == 'source.yaml') {
|
|
|
|
|
// console.log("存在", index)
|
|
|
|
|
// return item
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
if (data.configFiles) { |
|
|
|
|
this.router.navigate(['/system/host/camera/imageLabel'], { queryParams: { id: item.id } }) |
|
|
|
|
this.isSourceYaml = true |
|
|
|
|
} else { |
|
|
|
|
this.isSourceYaml = false |
|
|
|
|
this.message.create('error', '请先下发source.yaml配置'); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
error: (err) => { |
|
|
|
|
// this.message.create('error', '请先下发source.yaml配置');
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
connect() { |
|
|
|
|
|
|
|
|
|
let isAllLabel = this.listOfData.find((item: any) => { |
|
|
|
|
if (item.type != 1 && !item.dimensionedPoints) { |
|
|
|
|
console.log('存在摄像头未标注的情况') |
|
|
|
|
return item |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (isAllLabel) { |
|
|
|
|
this.message.create('error', '存在摄像头未标注的情况'); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let ids = [] |
|
|
|
|
this.listOfData.forEach((item: any) => { |
|
|
|
|
ids.push(item.id) |
|
|
|
@ -160,9 +237,77 @@ export class HostConfigComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sourceYaml() { |
|
|
|
|
let config4 = `video_rate: 5
|
|
|
|
|
inference_buffer_second: 10 |
|
|
|
|
sources:` |
|
|
|
|
this.listOfData.forEach((item: any, index) => { |
|
|
|
|
config4 += ` |
|
|
|
|
- name: '${item.name}' |
|
|
|
|
user: '${item.user}' |
|
|
|
|
password: '${item.password}' |
|
|
|
|
uri: '${item.uri}' |
|
|
|
|
type: ${item.type} |
|
|
|
|
` |
|
|
|
|
}) |
|
|
|
|
const modal = this.modal.create({ |
|
|
|
|
nzTitle: '下发source.yaml配置', |
|
|
|
|
nzContent: SendFileComponent, |
|
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
|
nzWidth: 1000, |
|
|
|
|
nzBodyStyle: { |
|
|
|
|
'border-radius': '0px', |
|
|
|
|
'padding': '7px', |
|
|
|
|
}, |
|
|
|
|
nzComponentParams: { |
|
|
|
|
data: config4 |
|
|
|
|
}, |
|
|
|
|
nzOnOk: async () => { |
|
|
|
|
|
|
|
|
|
await new Promise(resolve => { |
|
|
|
|
console.log('表单信息', instance.validateForm) |
|
|
|
|
let body = { |
|
|
|
|
configFiles: [ |
|
|
|
|
{ name: 'source.yaml', content: instance.datacopy } |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
this.http.put(`/api/EdgeDevices/${this.hostId}`, body).subscribe({ |
|
|
|
|
next: (data) => { |
|
|
|
|
this.message.create('success', `文件保存成功`); |
|
|
|
|
resolve('成功了') |
|
|
|
|
this.isSourceYaml = true |
|
|
|
|
let params = { |
|
|
|
|
edgeDeviceId: this.hostId, |
|
|
|
|
fileName: 'source.yaml' |
|
|
|
|
} |
|
|
|
|
this.http.put('/api/EdgeDevices/Commands/PushFile', '', { params: params }).subscribe({ |
|
|
|
|
next: (data) => { |
|
|
|
|
this.message.create('success', `发送文件名成功`); |
|
|
|
|
}, |
|
|
|
|
error: err => { |
|
|
|
|
// this.message.create('error', `发送文件名失败`);
|
|
|
|
|
// reject('失败了')
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
error: (err) => { |
|
|
|
|
// this.message.create('error', `文件保存失败`);
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
|
} |
|
|
|
|
//整理配置文件数据
|
|
|
|
|
disposalData() { |
|
|
|
|
console.log(this.listOfData) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let config1 = `[property]
|
|
|
|
|
enable=1 |
|
|
|
|
#Width height used for configuration to which below configs are configured |
|
|
|
@ -179,20 +324,10 @@ display-font-size=12
|
|
|
|
|
let config3 = `test_action: true
|
|
|
|
|
logging_interval : 600 |
|
|
|
|
` |
|
|
|
|
let config4 = `#RTSP sources for file source, use file as the
|
|
|
|
|
#Shoushi Yuan RTSP sources |
|
|
|
|
video_rate: 5 |
|
|
|
|
inference_buffer_second: 10` |
|
|
|
|
let xieyouqu = [] |
|
|
|
|
this.listOfData.forEach((item: any, index) => { |
|
|
|
|
if (item.type == 2) { xieyouqu.push(item) } |
|
|
|
|
config4 += ` |
|
|
|
|
- name: '${item.name} ${index}' |
|
|
|
|
user: '${item.user}' |
|
|
|
|
password: '${item.password}' |
|
|
|
|
uri: '${item.uri}' |
|
|
|
|
type: ${item.type}
|
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
if (item.type == 0) { |
|
|
|
|
let str = '' |
|
|
|
|
item.dimensionedPointsObj.polygon.forEach(element => { |
|
|
|
@ -203,7 +338,7 @@ inference_buffer_second: 10`
|
|
|
|
|
console.log('进出口多边形', str) |
|
|
|
|
config1 += ` |
|
|
|
|
## Per stream configuration |
|
|
|
|
[roi-filtering-stream-${index}] |
|
|
|
|
[roi-filtering-stream-${item.order}] |
|
|
|
|
#shoushiyuan-out202 |
|
|
|
|
#enable or disable following feature |
|
|
|
|
enable=1 |
|
|
|
@ -219,7 +354,7 @@ class-id=-1
|
|
|
|
|
let str = arrowArr[0].startX + ',' + arrowArr[0].startY + ',' + arrowArr[0].endX + ',' + arrowArr[0].endY + ',' + arrowArr[1].startX + ',' + arrowArr[1].startY + ',' + arrowArr[1].endX + ',' + arrowArr[1].endY |
|
|
|
|
console.log('十字箭头', str) |
|
|
|
|
config1 += ` |
|
|
|
|
[line-crossing-stream-${index}] |
|
|
|
|
[line-crossing-stream-${item.order}] |
|
|
|
|
enable=1 |
|
|
|
|
#Label;direction;lc |
|
|
|
|
line-crossing-Entry=${str} |
|
|
|
@ -362,7 +497,5 @@ rule_threshold:
|
|
|
|
|
sessionStorage.setItem('config1', config1) |
|
|
|
|
sessionStorage.setItem('config2', config2) |
|
|
|
|
sessionStorage.setItem('config3', config3) |
|
|
|
|
sessionStorage.setItem('config4', config4) |
|
|
|
|
// console.log('config4', config4)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|