Browse Source

[新增]在不勾选要更新的主机时提示是否更新所有

非煤矿业企业安全风险监测预警系统
邵佳豪 2 years ago
parent
commit
c28facb59b
  1. 23
      src/app/system-management/condition-monitoring/condition-monitoring.component.html
  2. 60
      src/app/system-management/condition-monitoring/condition-monitoring.component.ts

23
src/app/system-management/condition-monitoring/condition-monitoring.component.html

@ -42,28 +42,23 @@
[nzType]="'sync'"></i>重置</button>
</nz-form-control>
</nz-form-item>
<!-- <button nz-button nzType="primary" type="button" [disabled]="setOfCheckedId.size === 0"
[nzLoading]="loading == 'UpdateStates'" (click)="sendRequest('UpdateStates')">
更新识别程序服务状态
</button> -->
<button nz-button nzType="primary" type="button" [disabled]="setOfCheckedId.size === 0"
[nzLoading]="loading == 'UpdateApps'" (click)="sendRequest('UpdateApps')">
<button nz-button nzType="primary" type="button" [nzLoading]="loading == 'UpdateApps'"
(click)="updateBox('UpdateApps','识别程序')">
更新识别程序
</button>
<button nz-button nzType="primary" type="button" [disabled]="setOfCheckedId.size === 0"
[nzLoading]="loading == 'primary'" (click)="sendRequest('UpdateImages')">
<button nz-button nzType="primary" type="button" [nzLoading]="loading == 'primary'"
(click)="updateBox('UpdateImages','镜像')">
更新镜像
</button>
<button nz-button nzType="primary" type="button" [disabled]="setOfCheckedId.size === 0"
[nzLoading]="loading == 'primary'" (click)="sendRequest('UpdateModels')">
<button nz-button nzType="primary" type="button" [nzLoading]="loading == 'primary'"
(click)="updateBox('UpdateModels','模型')">
更新模型
</button>
<button nz-button nzType="primary" type="button" [disabled]="setOfCheckedId.size === 0"
[nzLoading]="loading == 'primary'" (click)="sendRequest('UpdateMonitors')">
<button nz-button nzType="primary" type="button" [nzLoading]="loading == 'primary'"
(click)="updateBox('UpdateMonitors','监控程序')">
更新监控程序
</button>
<button nz-button nzType="primary" type="button" [disabled]="setOfCheckedId.size === 0"
[nzLoading]="loading == 'file'" (click)="file()">
<button nz-button nzType="primary" type="button" [nzLoading]="loading == 'file'" (click)="updateBoxfile()">
更新监控程序配置文件
</button>
</form>

60
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: `<i>确定更新所有边缘主机的${name}吗?</i>`,
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: `<i>确定更新所有边缘主机的监控程序配置文件吗?</i>`,
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);

Loading…
Cancel
Save