diff --git a/src/app/system-management/condition-monitoring/condition-monitoring.component.html b/src/app/system-management/condition-monitoring/condition-monitoring.component.html index adcfddb..9fb9b37 100644 --- a/src/app/system-management/condition-monitoring/condition-monitoring.component.html +++ b/src/app/system-management/condition-monitoring/condition-monitoring.component.html @@ -42,28 +42,23 @@ [nzType]="'sync'">重置 - - - - - - diff --git a/src/app/system-management/condition-monitoring/condition-monitoring.component.ts b/src/app/system-management/condition-monitoring/condition-monitoring.component.ts index b6a4d0f..4a8d940 100644 --- a/src/app/system-management/condition-monitoring/condition-monitoring.component.ts +++ b/src/app/system-management/condition-monitoring/condition-monitoring.component.ts @@ -135,19 +135,37 @@ export class ConditionMonitoringComponent implements OnInit { this.refreshCheckedStatus(); } - sendRequest(type): void { + selectedBoxId = [] + updateBox(type, name) { const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id)); - - let strArr = [] + this.selectedBoxId = [] requestData.forEach(element => { - strArr.push(element.id) + this.selectedBoxId.push(element.id) }); + + if (this.selectedBoxId.length == 0) { + this.modal.confirm({ + nzTitle: `确定更新所有边缘主机的${name}吗?`, + nzOnOk: () => { + console.log('OK') + this.sendRequest(type, true) + } + }); + } else { + this.sendRequest(type, false) + } + } + + + + sendRequest(type, isAllBox): void { let body if (type != 'UpdateModels') { this.loading = type; body = { - edgeDeviceIds: strArr + edgeDeviceIds: this.selectedBoxId, + allEdgeDevices: isAllBox } this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({ next: (data: any) => { @@ -175,11 +193,11 @@ export class ConditionMonitoringComponent implements OnInit { nzWidth: 288, nzComponentParams: {}, nzOnOk: async () => { - // console.log(instance.validateForm.value.type) if (instance.validateForm.valid) { body = { - edgeDeviceIds: strArr, - modelNames: instance.validateForm.value.type + 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({ @@ -215,12 +233,26 @@ export class ConditionMonitoringComponent implements OnInit { } - file() { + updateBoxfile() { const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id)); - let strArr = [] + this.selectedBoxId = [] requestData.forEach(element => { - strArr.push(element.id) + this.selectedBoxId.push(element.id) }); + if (this.selectedBoxId.length == 0) { + this.modal.confirm({ + nzTitle: `确定更新所有边缘主机的监控程序配置文件吗?`, + nzOnOk: () => { + this.file(true) + } + }); + } else { + this.file(false) + } + } + + + file(isAllBox) { const modal = this.modal.create({ nzTitle: '配置文件', nzContent: FileComponent, @@ -230,18 +262,18 @@ export class ConditionMonitoringComponent implements OnInit { nzOnOk: async () => { if (instance.validateForm.valid) { let body = { - edgeDeviceIds: strArr, + edgeDeviceIds: this.selectedBoxId, scheme: instance.validateForm.value.scheme, host: instance.validateForm.value.host, port: instance.validateForm.value.port, - maxRetries: instance.validateForm.value.maxRetries + maxRetries: instance.validateForm.value.maxRetries, + allEdgeDevices: isAllBox } await new Promise((resolve, reject) => { this.loading = 'file' this.http.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body).subscribe({ next: (data: any) => { this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!'); - // console.log(data) if (data.failedItems.length != 0) { data.failedItems.forEach(element => { this.message.create('info', element.detail);