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

60
src/app/system-management/condition-monitoring/condition-monitoring.component.ts

@ -135,19 +135,37 @@ export class ConditionMonitoringComponent implements OnInit {
this.refreshCheckedStatus(); this.refreshCheckedStatus();
} }
sendRequest(type): void {
selectedBoxId = []
updateBox(type, name) {
const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id)); const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id));
this.selectedBoxId = []
let strArr = []
requestData.forEach(element => { 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 let body
if (type != 'UpdateModels') { if (type != 'UpdateModels') {
this.loading = type; this.loading = type;
body = { body = {
edgeDeviceIds: strArr edgeDeviceIds: this.selectedBoxId,
allEdgeDevices: isAllBox
} }
this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({ this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({
next: (data: any) => { next: (data: any) => {
@ -175,11 +193,11 @@ export class ConditionMonitoringComponent implements OnInit {
nzWidth: 288, nzWidth: 288,
nzComponentParams: {}, nzComponentParams: {},
nzOnOk: async () => { nzOnOk: async () => {
// console.log(instance.validateForm.value.type)
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
body = { body = {
edgeDeviceIds: strArr, edgeDeviceIds: this.selectedBoxId,
modelNames: instance.validateForm.value.type modelNames: instance.validateForm.value.type,
allEdgeDevices: isAllBox
} }
await new Promise(resolve => { await new Promise(resolve => {
this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({ 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)); const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id));
let strArr = [] this.selectedBoxId = []
requestData.forEach(element => { 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({ const modal = this.modal.create({
nzTitle: '配置文件', nzTitle: '配置文件',
nzContent: FileComponent, nzContent: FileComponent,
@ -230,18 +262,18 @@ export class ConditionMonitoringComponent implements OnInit {
nzOnOk: async () => { nzOnOk: async () => {
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
let body = { let body = {
edgeDeviceIds: strArr, edgeDeviceIds: this.selectedBoxId,
scheme: instance.validateForm.value.scheme, scheme: instance.validateForm.value.scheme,
host: instance.validateForm.value.host, host: instance.validateForm.value.host,
port: instance.validateForm.value.port, port: instance.validateForm.value.port,
maxRetries: instance.validateForm.value.maxRetries maxRetries: instance.validateForm.value.maxRetries,
allEdgeDevices: isAllBox
} }
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
this.loading = 'file' this.loading = 'file'
this.http.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body).subscribe({ this.http.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body).subscribe({
next: (data: any) => { next: (data: any) => {
this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!'); this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!');
// console.log(data)
if (data.failedItems.length != 0) { if (data.failedItems.length != 0) {
data.failedItems.forEach(element => { data.failedItems.forEach(element => {
this.message.create('info', element.detail); this.message.create('info', element.detail);

Loading…
Cancel
Save