diff --git a/src/app/appmarket/bulkDeployment/appdeployment.service.ts b/src/app/appmarket/bulkDeployment/appdeployment.service.ts index b858eb65c02ee55a8cf4f49a629e26ba638c274b..8ca97da1aaf043faf86a26b447f48823fb549763 100644 --- a/src/app/appmarket/bulkDeployment/appdeployment.service.ts +++ b/src/app/appmarket/bulkDeployment/appdeployment.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {ApplicationBase} from '../../model/application-base'; -import {HttpClient} from '@angular/common/http'; +import {HttpClient, HttpParams} from '@angular/common/http'; import {AppConfigService} from '../../service'; import {BulkResponse} from '../../model/bulk-response'; import {Observable} from 'rxjs'; @@ -94,4 +94,9 @@ export class AppdeploymentService { } + public removeBulkDeployment(id: number, removeAll: boolean): Observable<void> { + let params = new HttpParams() + params = params.append('removeAll', removeAll) + return this.http.delete<void>(this.getUrl() + `${id}`, {params}) + } } diff --git a/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.html b/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.html index e34eee5938d37ec4330b3cd1f1ebdc2d9659707f..6ca3b86ef56dbb270004f4df691a1a17d92c8c9a 100644 --- a/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.html +++ b/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.html @@ -1,2 +1,6 @@ -<app-bulk-list [header]="'BULK.APP.HEADER'" [bulks]="bulks" [mode]="mode"></app-bulk-list> +<app-bulk-list [header]="'BULK.APP.HEADER'" + [bulks]="bulks" + [mode]="mode" + (reloadBulks)="retrieveBulks()" +></app-bulk-list> diff --git a/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts index 9256cfa4ea2a99172b68b96471a1312b92bb206d..7eaed23ae6fccaf2f641ca72cdd51d8ee205f5dd 100644 --- a/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts +++ b/src/app/appmarket/bulkDeployment/bulk-app-list/bulk-app-list.component.ts @@ -20,6 +20,10 @@ export class BulkAppListComponent implements OnInit { } ngOnInit(): void { + this.retrieveBulks(); + } + + public retrieveBulks() { if (this.authService.getRoles().find(value => value === 'ROLE_VL_MANAGER') !== undefined) { this.deployService.getBulksAppDeploymentsOwner().subscribe(data => { data = data.sort((a, b) => new Date(b.creationDate).getTime() - new Date(a.creationDate).getTime()) diff --git a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html index c68bbe80370e26c7df8dfd879c91785745f46cb2..dad549b0d8a09af20bae1208a7176f18c99a6e0c 100644 --- a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html +++ b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html @@ -103,7 +103,7 @@ <a (click)="getAppBulkDetails(bulk?.id)"> {{"BULK.APP.DOWNLOAD_CSV" | translate}}</a> </li> <li *ngIf="mode === bulkTypeApp"> - <a (click)="modal.show()">{{ 'BULK.LIST.REMOVE' | translate }}</a> + <a (click)="modal.show(); setBulkToDelete(bulk)">{{ 'BULK.LIST.REMOVE' | translate }}</a> </li> </ul> </span> @@ -130,9 +130,12 @@ <p-checkbox [(ngModel)]="removeAll" binary="true"></p-checkbox> </div> </div> + <div *ngIf="errorMessage !== ''" style="margin-top: 2rem; display: flex; justify-content: start; color: indianred"> + <p>{{ 'BULK.REMOVE.ERROR' | translate}} {{errorMessage}}</p> + </div> </div> <div class="nmaas-modal-footer"> <button type="button" class="btn btn-secondary" (click)="modal.hide()">{{'APP_CHANGE_STATE_MODAL.CANCEL_BUTTON' | translate}}</button> - <button type="button" class="btn btn-primary" [disabled]="false">{{'BULK.REMOVE.REMOVE' | translate}}</button> + <button type="button" class="btn btn-primary" (click)="removeBulkDeployment()" [disabled]="false">{{'BULK.REMOVE.REMOVE' | translate}}</button> </div> </nmaas-modal> diff --git a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts index 8288379d544ee7f88744f62d8ee497a98c9d199c..642bcf677efea934828cac6db1d169ea51e72982 100644 --- a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts +++ b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, QueryList, ViewChild, ViewChildren} from '@angular/core'; +import {Component, EventEmitter, Input, Output, QueryList, ViewChild, ViewChildren} from '@angular/core'; import {BulkDeployment} from '../../../model/bulk-deployment'; import {BulkType} from '../../../model/bulk-response'; import {SortableHeaderDirective} from '../../../service/sort-domain.directive'; @@ -42,6 +42,12 @@ export class BulkListComponent { public searchValue = ''; public removeAll = false; + public bulkToDelete; + + public errorMessage = ''; + + @Output() + public reloadBulks = new EventEmitter<void>(); constructor(private appDeploy: AppdeploymentService, private sanitizer: DomSanitizer) { @@ -147,4 +153,25 @@ export class BulkListComponent { } return null } + + public removeBulkDeployment() { + this.appDeploy.removeBulkDeployment(this.bulkToDelete.id, this.removeAll) + .subscribe({ + next: (_) => { + this.reloadData() + this.modal.hide() + }, + error: err => { + this.errorMessage = err.error.message + } + }) + } + + public setBulkToDelete(bulk: BulkDeployment) { + this.bulkToDelete = bulk + } + + private reloadData() { + this.reloadBulks.emit() + } }