|
|
|
@ -9,43 +9,51 @@ import { ModelComponent } from './model/model.component';
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-condition-monitoring', |
|
|
|
|
templateUrl: './condition-monitoring.component.html', |
|
|
|
|
styleUrls: ['./condition-monitoring.component.scss'] |
|
|
|
|
styleUrls: ['./condition-monitoring.component.scss'], |
|
|
|
|
}) |
|
|
|
|
export class ConditionMonitoringComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor(private http: HttpClient, private fb: FormBuilder, private toTree: TreeService, private message: NzMessageService, private modal: NzModalService, private viewContainerRef: ViewContainerRef) { } |
|
|
|
|
constructor( |
|
|
|
|
private http: HttpClient, |
|
|
|
|
private fb: FormBuilder, |
|
|
|
|
private toTree: TreeService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private modal: NzModalService, |
|
|
|
|
private viewContainerRef: ViewContainerRef |
|
|
|
|
) {} |
|
|
|
|
validateForm!: FormGroup; |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
|
organization: [null], |
|
|
|
|
state: [null] |
|
|
|
|
state: [null], |
|
|
|
|
updatestate: [null], |
|
|
|
|
}); |
|
|
|
|
this.getAllOrganization() |
|
|
|
|
|
|
|
|
|
this.getAllOrganization(); |
|
|
|
|
} |
|
|
|
|
//获取所有组织机构
|
|
|
|
|
nodes: any = [] |
|
|
|
|
defaultOrId: string |
|
|
|
|
nodes: any = []; |
|
|
|
|
defaultOrId: string; |
|
|
|
|
defaultExpandedKeys = []; |
|
|
|
|
getAllOrganization() { |
|
|
|
|
let params = { |
|
|
|
|
ContainsChildren: true, |
|
|
|
|
pageSize: 9999 |
|
|
|
|
} |
|
|
|
|
this.http.get('/api/Organizations', { |
|
|
|
|
params: params |
|
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
console.log('组织机构列表', data) |
|
|
|
|
data.items.forEach(element => { |
|
|
|
|
element.key = element.id |
|
|
|
|
element.title = element.name |
|
|
|
|
pageSize: 9999, |
|
|
|
|
}; |
|
|
|
|
this.http |
|
|
|
|
.get('/api/Organizations', { |
|
|
|
|
params: params, |
|
|
|
|
}) |
|
|
|
|
.subscribe((data: any) => { |
|
|
|
|
console.log('组织机构列表', data); |
|
|
|
|
data.items.forEach((element) => { |
|
|
|
|
element.key = element.id; |
|
|
|
|
element.title = element.name; |
|
|
|
|
// element.selectable = false
|
|
|
|
|
}); |
|
|
|
|
this.nodes = [...this.toTree.toTree(data.items)] |
|
|
|
|
this.defaultOrId = this.nodes[0].id |
|
|
|
|
this.validateForm.value.organization = this.defaultOrId |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
}) |
|
|
|
|
this.nodes = [...this.toTree.toTree(data.items)]; |
|
|
|
|
this.defaultOrId = this.nodes[0].id; |
|
|
|
|
this.validateForm.value.organization = this.defaultOrId; |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
submitForm(): void { |
|
|
|
@ -53,7 +61,7 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
this.validateForm.controls[i].markAsDirty(); |
|
|
|
|
this.validateForm.controls[i].updateValueAndValidity(); |
|
|
|
|
} |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
} |
|
|
|
|
resetForm(e: MouseEvent): void { |
|
|
|
|
e.preventDefault(); |
|
|
|
@ -65,13 +73,13 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
this.validateForm.patchValue({ |
|
|
|
|
organization: this.nodes[0].id, |
|
|
|
|
}); |
|
|
|
|
this.PageNumber = 1 |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
this.PageNumber = 1; |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
} |
|
|
|
|
listOfData: any |
|
|
|
|
num: string |
|
|
|
|
PageNumber: number = 1 |
|
|
|
|
isLoading = false |
|
|
|
|
listOfData: any; |
|
|
|
|
num: string; |
|
|
|
|
PageNumber: number = 1; |
|
|
|
|
isLoading = false; |
|
|
|
|
//获取盒子状态
|
|
|
|
|
getConditionMonitoring() { |
|
|
|
|
let params = { |
|
|
|
@ -79,28 +87,27 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
OrganizationId: this.defaultOrId, |
|
|
|
|
PageNumber: this.PageNumber, |
|
|
|
|
PageSize: 10, |
|
|
|
|
HubConnectionState: this.validateForm.value.state |
|
|
|
|
} |
|
|
|
|
this.isLoading = true |
|
|
|
|
HubConnectionState: this.validateForm.value.state, |
|
|
|
|
AppUpdatingState: this.validateForm.value.updatestate, |
|
|
|
|
}; |
|
|
|
|
this.isLoading = true; |
|
|
|
|
this.http.get('/api/EdgeDevices/Statuses', { params: params }).subscribe( |
|
|
|
|
(data: any) => { |
|
|
|
|
console.log(data) |
|
|
|
|
this.isLoading = false |
|
|
|
|
this.listOfData = data.items |
|
|
|
|
this.num = data.totalCount |
|
|
|
|
}, err => { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
console.log(data); |
|
|
|
|
this.isLoading = false; |
|
|
|
|
this.listOfData = data.items; |
|
|
|
|
this.num = data.totalCount; |
|
|
|
|
}, |
|
|
|
|
(err) => {} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
pageChange($event) { |
|
|
|
|
this.PageNumber = $event |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
this.PageNumber = $event; |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checked = false; |
|
|
|
|
loading |
|
|
|
|
loading; |
|
|
|
|
indeterminate = false; |
|
|
|
|
listOfCurrentPageData: readonly any[] = []; |
|
|
|
|
setOfCheckedId = new Set<number>(); |
|
|
|
@ -118,9 +125,15 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshCheckedStatus(): void { |
|
|
|
|
const listOfEnabledData = this.listOfCurrentPageData.filter(({ disabled }) => !disabled); |
|
|
|
|
this.checked = listOfEnabledData.every(({ id }) => this.setOfCheckedId.has(id)); |
|
|
|
|
this.indeterminate = listOfEnabledData.some(({ id }) => this.setOfCheckedId.has(id)) && !this.checked; |
|
|
|
|
const listOfEnabledData = this.listOfCurrentPageData.filter( |
|
|
|
|
({ disabled }) => !disabled |
|
|
|
|
); |
|
|
|
|
this.checked = listOfEnabledData.every(({ id }) => |
|
|
|
|
this.setOfCheckedId.has(id) |
|
|
|
|
); |
|
|
|
|
this.indeterminate = |
|
|
|
|
listOfEnabledData.some(({ id }) => this.setOfCheckedId.has(id)) && |
|
|
|
|
!this.checked; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onItemChecked(id: number, checked: boolean): void { |
|
|
|
@ -135,60 +148,64 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectedBoxId = [] |
|
|
|
|
selectedBoxId = []; |
|
|
|
|
updateBox(type, name) { |
|
|
|
|
const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id)); |
|
|
|
|
this.selectedBoxId = [] |
|
|
|
|
requestData.forEach(element => { |
|
|
|
|
this.selectedBoxId.push(element.id) |
|
|
|
|
const requestData = this.listOfData.filter((data) => |
|
|
|
|
this.setOfCheckedId.has(data.id) |
|
|
|
|
); |
|
|
|
|
this.selectedBoxId = []; |
|
|
|
|
requestData.forEach((element) => { |
|
|
|
|
this.selectedBoxId.push(element.id); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (this.selectedBoxId.length == 0) { |
|
|
|
|
this.modal.confirm({ |
|
|
|
|
nzTitle: `<i>确定更新所有边缘主机的${name}吗?</i>`, |
|
|
|
|
nzOnOk: () => { |
|
|
|
|
console.log('OK') |
|
|
|
|
this.sendRequest(type, true) |
|
|
|
|
} |
|
|
|
|
console.log('OK'); |
|
|
|
|
this.sendRequest(type, true); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.sendRequest(type, false) |
|
|
|
|
this.sendRequest(type, false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendRequest(type, isAllBox): void { |
|
|
|
|
let body |
|
|
|
|
let body; |
|
|
|
|
if (type != 'UpdateModels') { |
|
|
|
|
this.loading = type; |
|
|
|
|
body = { |
|
|
|
|
edgeDeviceIds: this.selectedBoxId, |
|
|
|
|
allEdgeDevices: isAllBox |
|
|
|
|
} |
|
|
|
|
this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({ |
|
|
|
|
allEdgeDevices: isAllBox, |
|
|
|
|
}; |
|
|
|
|
this.http |
|
|
|
|
.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }) |
|
|
|
|
.subscribe({ |
|
|
|
|
next: (data: any) => { |
|
|
|
|
this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!'); |
|
|
|
|
let str = '更新失败列表<br>' |
|
|
|
|
this.message.create( |
|
|
|
|
'success', |
|
|
|
|
'通知边缘盒子成功,请过一段时间手动刷新尝试!' |
|
|
|
|
); |
|
|
|
|
let str = '更新失败列表<br>'; |
|
|
|
|
if (data.failedItems.length != 0) { |
|
|
|
|
data.failedItems.forEach(element => { |
|
|
|
|
str += element.detail + '<br>' |
|
|
|
|
data.failedItems.forEach((element) => { |
|
|
|
|
str += element.detail + '<br>'; |
|
|
|
|
}); |
|
|
|
|
this.message.create('info', str, { |
|
|
|
|
nzDuration: 3000 |
|
|
|
|
nzDuration: 3000, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.setOfCheckedId.clear(); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
this.loading = null; |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
}, |
|
|
|
|
error: (err) => { |
|
|
|
|
this.loading = null; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const modal = this.modal.create({ |
|
|
|
|
nzTitle: '选择更新模型类型', |
|
|
|
@ -201,66 +218,73 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
body = { |
|
|
|
|
edgeDeviceIds: this.selectedBoxId, |
|
|
|
|
modelNames: instance.validateForm.value.type, |
|
|
|
|
allEdgeDevices: isAllBox |
|
|
|
|
} |
|
|
|
|
await new Promise(resolve => { |
|
|
|
|
this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({ |
|
|
|
|
allEdgeDevices: isAllBox, |
|
|
|
|
}; |
|
|
|
|
await new Promise((resolve) => { |
|
|
|
|
this.http |
|
|
|
|
.patch('/api/EdgeDevices/Commands', body, { |
|
|
|
|
params: { command: type }, |
|
|
|
|
}) |
|
|
|
|
.subscribe({ |
|
|
|
|
next: (data: any) => { |
|
|
|
|
resolve(data) |
|
|
|
|
this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!'); |
|
|
|
|
let str = '更新失败列表<br>' |
|
|
|
|
resolve(data); |
|
|
|
|
this.message.create( |
|
|
|
|
'success', |
|
|
|
|
'通知边缘盒子成功,请过一段时间手动刷新尝试!' |
|
|
|
|
); |
|
|
|
|
let str = '更新失败列表<br>'; |
|
|
|
|
if (data.failedItems.length != 0) { |
|
|
|
|
data.failedItems.forEach(element => { |
|
|
|
|
str += element.detail + '<br>' |
|
|
|
|
data.failedItems.forEach((element) => { |
|
|
|
|
str += element.detail + '<br>'; |
|
|
|
|
}); |
|
|
|
|
this.message.create('info', str, { |
|
|
|
|
nzDuration: 3000 |
|
|
|
|
nzDuration: 3000, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.setOfCheckedId.clear(); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
this.loading = null; |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
return true |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
error: (err) => { |
|
|
|
|
resolve(err) |
|
|
|
|
resolve(err); |
|
|
|
|
this.loading = null; |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
return false; |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.message.create('warning', '请填写完整!'); |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateBoxfile() { |
|
|
|
|
const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id)); |
|
|
|
|
this.selectedBoxId = [] |
|
|
|
|
requestData.forEach(element => { |
|
|
|
|
this.selectedBoxId.push(element.id) |
|
|
|
|
const requestData = this.listOfData.filter((data) => |
|
|
|
|
this.setOfCheckedId.has(data.id) |
|
|
|
|
); |
|
|
|
|
this.selectedBoxId = []; |
|
|
|
|
requestData.forEach((element) => { |
|
|
|
|
this.selectedBoxId.push(element.id); |
|
|
|
|
}); |
|
|
|
|
if (this.selectedBoxId.length == 0) { |
|
|
|
|
this.modal.confirm({ |
|
|
|
|
nzTitle: `<i>确定更新所有边缘主机的监控程序配置文件吗?</i>`, |
|
|
|
|
nzOnOk: () => { |
|
|
|
|
this.file(true) |
|
|
|
|
} |
|
|
|
|
this.file(true); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.file(false) |
|
|
|
|
this.file(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file(isAllBox) { |
|
|
|
|
const modal = this.modal.create({ |
|
|
|
|
nzTitle: '配置文件', |
|
|
|
@ -276,42 +300,46 @@ export class ConditionMonitoringComponent implements OnInit {
|
|
|
|
|
host: instance.validateForm.value.host, |
|
|
|
|
port: instance.validateForm.value.port, |
|
|
|
|
maxRetries: instance.validateForm.value.maxRetries, |
|
|
|
|
allEdgeDevices: isAllBox |
|
|
|
|
} |
|
|
|
|
allEdgeDevices: isAllBox, |
|
|
|
|
}; |
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
|
this.loading = 'file' |
|
|
|
|
this.http.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body).subscribe({ |
|
|
|
|
this.loading = 'file'; |
|
|
|
|
this.http |
|
|
|
|
.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body) |
|
|
|
|
.subscribe({ |
|
|
|
|
next: (data: any) => { |
|
|
|
|
this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!'); |
|
|
|
|
let str = '更新失败列表<br>' |
|
|
|
|
this.message.create( |
|
|
|
|
'success', |
|
|
|
|
'通知边缘盒子成功,请过一段时间手动刷新尝试!' |
|
|
|
|
); |
|
|
|
|
let str = '更新失败列表<br>'; |
|
|
|
|
if (data.failedItems.length != 0) { |
|
|
|
|
data.failedItems.forEach(element => { |
|
|
|
|
str += element.detail + '<br>' |
|
|
|
|
data.failedItems.forEach((element) => { |
|
|
|
|
str += element.detail + '<br>'; |
|
|
|
|
}); |
|
|
|
|
this.message.create('info', str, { |
|
|
|
|
nzDuration: 3000 |
|
|
|
|
nzDuration: 3000, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.setOfCheckedId.clear(); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
this.getConditionMonitoring() |
|
|
|
|
this.getConditionMonitoring(); |
|
|
|
|
this.loading = null; |
|
|
|
|
resolve(data) |
|
|
|
|
return true |
|
|
|
|
resolve(data); |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
error: (err) => { |
|
|
|
|
reject(err) |
|
|
|
|
reject(err); |
|
|
|
|
this.loading = null; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.message.create('warning', '请填写完整!'); |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|