diff --git a/src/main/webapp/app/entities/queue/queue-clear-dialog.component.html b/src/main/webapp/app/entities/queue/queue-clear-dialog.component.html new file mode 100644 index 000000000..a25135751 --- /dev/null +++ b/src/main/webapp/app/entities/queue/queue-clear-dialog.component.html @@ -0,0 +1,24 @@ +
diff --git a/src/main/webapp/app/entities/queue/queue-clear-dialog.component.ts b/src/main/webapp/app/entities/queue/queue-clear-dialog.component.ts new file mode 100644 index 000000000..2d21edfa5 --- /dev/null +++ b/src/main/webapp/app/entities/queue/queue-clear-dialog.component.ts @@ -0,0 +1,69 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { IQueue } from 'app/shared/model/queue.model'; +import { QueueService } from './queue.service'; +import { IAddress } from 'app/shared/model/address.model'; +import { IBroker } from 'app/shared/model/broker.model'; + +@Component({ + templateUrl: './queue-clear-dialog.component.html' +}) +export class QueueClearDialogComponent { + queue?: IQueue; + address?: IAddress; + + brokerType: string = ''; + brokers: IBroker[]; + + message = 'Are you sure you want to clear this queue?'; + disableDelete: boolean; + + constructor( + protected queueService: QueueService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager, + protected jhiAlertService: JhiAlertService, + protected router: Router + ) { + this.brokers = []; + this.getBrokerType(); + this.disableDelete = false; + } + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmClear(name: string): void { + if (this.address.numberOfConsumers > 0) { + this.message = 'Cannot clear queue because there is at least one active consumer'; + this.disableDelete = true; + } else { + this.queueService.clearQueue(name, this.brokerType).subscribe(() => { + this.eventManager.broadcast('queueListModification'); + this.router.navigate(['/queue']).then(() => { + window.location.reload(); + }); + // this.activeModal.close(); + this.activeModal.close(); + }); + } + } + + getBrokerType(): void { + this.queueService.getBrokers().subscribe( + data => { + if (data) { + for (let i = 0; i < data.body.length; i++) { + this.brokers.push(data.body[i]); + this.brokerType = this.brokers[0].type; + } + } + }, + error => console.log(error) + ); + } +} diff --git a/src/main/webapp/app/entities/queue/queue-delete-dialog.component.html b/src/main/webapp/app/entities/queue/queue-delete-dialog.component.html index 18ef04b49..d4c4effc8 100644 --- a/src/main/webapp/app/entities/queue/queue-delete-dialog.component.html +++ b/src/main/webapp/app/entities/queue/queue-delete-dialog.component.html @@ -1,4 +1,4 @@ -