Skip to content

Commit eb7fcd3

Browse files
sarkapalkovicovaHejdaJakub
authored andcommitted
fix(admin): services status bulk operations
Used bulk operations for forcing propagation, blocking, and unblocking services.
1 parent d358470 commit eb7fcd3

File tree

2 files changed

+418
-41
lines changed

2 files changed

+418
-41
lines changed

apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-service-status/facility-service-status.component.ts

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ export class FacilityServiceStatusComponent implements OnInit {
3636

3737
tableId = TABLE_FACILITY_SERVICES_STATUS_LIST;
3838

39-
successFPMessage: string;
40-
successAllowMessage: string;
41-
successBlockMessage: string;
42-
successDeleteMessage: string;
43-
allreadyDeletedMessage: string;
44-
4539
disableAllowButton = true;
4640
disableBlockButton = true;
4741
disableRemoveButton = true;
@@ -64,23 +58,7 @@ export class FacilityServiceStatusComponent implements OnInit {
6458
private resourcesManager: ResourcesManagerService,
6559
private dialog: MatDialog,
6660
private entityStorageService: EntityStorageService
67-
) {
68-
translate
69-
.get('FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_FORCE_PROPAGATION')
70-
.subscribe((value: string) => (this.successFPMessage = value));
71-
translate
72-
.get('FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_ALLOW')
73-
.subscribe((value: string) => (this.successAllowMessage = value));
74-
translate
75-
.get('FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_BLOCK')
76-
.subscribe((value: string) => (this.successBlockMessage = value));
77-
translate
78-
.get('FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_DELETE')
79-
.subscribe((value: string) => (this.successDeleteMessage = value));
80-
translate
81-
.get('FACILITY_DETAIL.SERVICES_STATUS.ALREADY_DELETED')
82-
.subscribe((value: string) => (this.allreadyDeletedMessage = value));
83-
}
61+
) {}
8462

8563
ngOnInit(): void {
8664
this.loading = true;
@@ -90,30 +68,44 @@ export class FacilityServiceStatusComponent implements OnInit {
9068
}
9169

9270
forcePropagation(): void {
93-
for (const ss of this.selected.selected) {
94-
this.servicesManager.forceServicePropagation(ss.service.id, ss.facility.id).subscribe(() => {
95-
this.refreshTable();
96-
this.notificator.showSuccess(this.successFPMessage);
97-
});
98-
}
71+
const serviceIds = this.selected.selected.map((status) => status.service.id);
72+
this.servicesManager.forceServicePropagationBulk(serviceIds, this.facility.id).subscribe({
73+
next: () => {
74+
this.notificator.showInstantSuccess(
75+
'FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_FORCE_PROPAGATION'
76+
);
77+
this.loading = false;
78+
},
79+
error: () => {
80+
this.loading = false;
81+
},
82+
});
9983
}
10084

10185
allow(): void {
102-
for (const ss of this.selected.selected) {
103-
this.servicesManager.unblockServiceOnFacility(ss.service.id, ss.facility.id).subscribe(() => {
104-
this.refreshTable();
105-
this.notificator.showSuccess(this.successAllowMessage);
106-
});
107-
}
86+
const serviceIds = this.selected.selected.map((status) => status.service.id);
87+
this.servicesManager.unblockServicesOnFacility(serviceIds, this.facility.id).subscribe({
88+
next: () => {
89+
this.notificator.showInstantSuccess('FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_ALLOW');
90+
this.loading = false;
91+
},
92+
error: () => {
93+
this.loading = false;
94+
},
95+
});
10896
}
10997

11098
block(): void {
111-
for (const ss of this.selected.selected) {
112-
this.servicesManager.blockServiceOnFacility(ss.service.id, ss.facility.id).subscribe(() => {
113-
this.refreshTable();
114-
this.notificator.showSuccess(this.successBlockMessage);
115-
});
116-
}
99+
const serviceIds = this.selected.selected.map((status) => status.service.id);
100+
this.servicesManager.blockServicesOnFacility(serviceIds, this.facility.id).subscribe({
101+
next: () => {
102+
this.notificator.showInstantSuccess('FACILITY_DETAIL.SERVICES_STATUS.SUCCESS_BLOCK');
103+
this.loading = false;
104+
},
105+
error: () => {
106+
this.loading = false;
107+
},
108+
});
117109
}
118110

119111
removeTaskResults(): void {

0 commit comments

Comments
 (0)