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 @@ -
+ -
+ + + + + + + + + + + + + + + + + +
diff --git a/src/main/webapp/app/entities/queue/queue-row.component.ts b/src/main/webapp/app/entities/queue/queue-row.component.ts index 6a48d9964..062fa4836 100644 --- a/src/main/webapp/app/entities/queue/queue-row.component.ts +++ b/src/main/webapp/app/entities/queue/queue-row.component.ts @@ -11,6 +11,9 @@ import { NavigationEnd, Router } from '@angular/router'; import * as moment from 'moment'; import { forkJoin, Observable, Observer, Subscription } from 'rxjs'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { QueueDeleteDialogComponent } from 'app/entities/queue/queue-delete-dialog.component'; +import { QueueClearDialogComponent } from 'app/entities/queue/queue-clear-dialog.component'; +import { FlowDeleteDialogComponent } from 'app/entities/flow'; enum Status { active = 'active', @@ -69,107 +72,22 @@ export class QueueRowComponent implements OnInit, OnDestroy { }); } - ngOnInit() { - // this.setFlowStatusDefaults(); - // this.getStatus(this.flow.id); - // this.endpoints = this.flow.endpoints; - // this.getEndpoints(); - // - // this.registerTriggeredAction(); - } + ngOnInit() {} - ngAfterViewInit() { - // this.connection = this.flowService.connectionStomp(); - // this.stompClient = this.flowService.client(); - // this.subscribe('alert'); - // this.subscribe('event'); - // this.receive().subscribe(data => { - // const data2 = data.split(':'); - // - // if (Array.isArray(data2) || data2.length) { - // if (data2[0] === 'event') { - // this.setFlowStatus(data2[1]); - // } else if (data2[0] === 'alert') { - // const alertId = Number(data2[1]); - // if (this.flow.id === alertId) { - // this.getFlowNumberOfAlerts(alertId); - // } - // } - // } - // }); - } + ngOnDestroy() {} - ngOnDestroy() { - // this.flowService.unsubscribe(); - // if (this.mySubscription) { - // this.mySubscription.unsubscribe(); - // } - } - // - // navigateToFlow(action: string) { - // switch (action) { - // case 'edit': - // this.isAdmin - // ? this.router.navigate(['../../flow/edit-all', this.flow.id, { mode: 'edit' }]) - // : this.router.navigate(['../flow', this.flow.id]); - // break; - // case 'clone': - // this.isAdmin - // ? this.router.navigate(['../../flow/edit-all', this.flow.id, { mode: 'clone' }]) - // : this.router.navigate(['../flow', this.flow.id]); - // break; - // case 'delete': - // if (this.isAdmin) { - // let modalRef = this.modalService.open(FlowDeleteDialogComponent as any); - // if (typeof FlowDeleteDialogComponent as Component) { - // modalRef.componentInstance.flow = this.flow; - // modalRef.result.then( - // result => { - // this.eventManager.broadcast({ name: 'flowDeleted', content: this.flow }); - // modalRef = null; - // }, - // reason => { - // this.eventManager.broadcast({ name: 'flowDeleted', content: this.flow }); - // modalRef = null; - // } - // ); - // } - // } else { - // this.router.navigate(['../flow', this.flow.id]); - // } - // - // //this.router.navigate([{ outlets: { popup: 'flow/' + this.flow.id + '/delete' } }], { replaceUrl: true, queryParamsHandling: 'merge' }) : - // //this.router.navigate(['../flow', this.flow.id]); - // break; - // default: - // break; - // } - // } - - // navigateToEndpoint(endpoint: Endpoint) { - // this.isAdmin - // ? this.router.navigate(['../../flow/edit-all', this.flow.id], { queryParams: { mode: 'edit', endpointid: endpoint.id } }) - // : this.router.navigate(['../flow', this.flow.id]); - // } - - subscribe(type) { - // const topic = '/topic/' + this.flow.id + '/' + type; - // - // this.connection.then(() => { - // this.subscriber = this.stompClient.subscribe(topic, data => { - // if (!this.listenerObserver) { - // this.listener = this.createListener(); - // } - // this.listenerObserver.next(data.body); - // }); - // }); + subscribe(type) {} + + unsubscribe() {} + + delete(address: IAddress): void { + const modalRef = this.modalService.open(QueueDeleteDialogComponent as any); + modalRef.componentInstance.address = address; } - unsubscribe() { - // if (this.subscriber !== null) { - // this.subscriber.unsubscribe(); - // } - // this.listener = this.createListener(); + clear(address: IAddress): void { + const modalRef = this.modalService.open(QueueClearDialogComponent as any); + modalRef.componentInstance.address = address; } private createListener(): Observable { diff --git a/src/main/webapp/app/entities/queue/queue-update.component.html b/src/main/webapp/app/entities/queue/queue-update.component.html index e468f147b..63b2061ac 100644 --- a/src/main/webapp/app/entities/queue/queue-update.component.html +++ b/src/main/webapp/app/entities/queue/queue-update.component.html @@ -1,40 +1,46 @@
- + + + +
- - + +
-
- - -
- -
- - -
- -
- - -
+ + + + + + + + + + + + + + + + + + + + + + +
@@ -46,6 +52,6 @@

Create or edit a Queue

 Save
- --> +
diff --git a/src/main/webapp/app/entities/queue/queue-update.component.ts b/src/main/webapp/app/entities/queue/queue-update.component.ts index f220098df..71fb25380 100644 --- a/src/main/webapp/app/entities/queue/queue-update.component.ts +++ b/src/main/webapp/app/entities/queue/queue-update.component.ts @@ -7,6 +7,8 @@ import { Observable } from 'rxjs'; import { IQueue, Queue } from 'app/shared/model/queue.model'; import { QueueService } from './queue.service'; +import { Address, IAddress } from 'app/shared/model/address.model'; +import { IBroker } from 'app/shared/model/broker.model'; @Component({ selector: 'jhi-queue-update', @@ -16,28 +18,36 @@ export class QueueUpdateComponent implements OnInit { isSaving = false; editForm = this.fb.group({ - id: [], - itemsOnPage: [], - refreshInterval: [], - selectedColumn: [], - orderColumn: [] + address: [], + name: [], + numberOfConsumers: [], + numberOfMessages: [], + size: [], + temporary: [] }); - constructor(protected queueService: QueueService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) {} + brokerType: string = ''; + brokers: IBroker[]; + + constructor(protected queueService: QueueService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) { + this.brokers = []; + } ngOnInit(): void { - this.activatedRoute.data.subscribe(({ queue }) => { - this.updateForm(queue); + this.activatedRoute.data.subscribe(({ address }) => { + this.updateForm(address); }); + this.getBrokerType(); } - updateForm(queue: IQueue): void { + updateForm(address: IAddress): void { this.editForm.patchValue({ - id: queue.id, - itemsOnPage: queue.itemsOnPage, - refreshInterval: queue.refreshInterval, - selectedColumn: queue.selectedColumn, - orderColumn: queue.orderColumn + address: address.address, + name: address.name, + numberOfConsumers: address.numberOfConsumers, + numberOfMessages: address.numberOfMessages, + size: address.size, + temporary: address.temporary }); } @@ -47,26 +57,23 @@ export class QueueUpdateComponent implements OnInit { save(): void { this.isSaving = true; - const queue = this.createFromForm(); - if (queue.id !== undefined) { - this.subscribeToSaveResponse(this.queueService.update(queue)); - } else { - this.subscribeToSaveResponse(this.queueService.create(queue)); - } + const address = this.createFromForm(); + this.subscribeToSaveResponse(this.queueService.createQueue(address.name, this.brokerType)); } - private createFromForm(): IQueue { + private createFromForm(): IAddress { return { - ...new Queue(), - id: this.editForm.get(['id'])!.value, - itemsOnPage: this.editForm.get(['itemsOnPage'])!.value, - refreshInterval: this.editForm.get(['refreshInterval'])!.value, - selectedColumn: this.editForm.get(['selectedColumn'])!.value, - orderColumn: this.editForm.get(['orderColumn'])!.value + ...new Address(), + address: this.editForm.get(['address'])!.value, + name: this.editForm.get(['name'])!.value, + numberOfConsumers: this.editForm.get(['numberOfConsumers'])!.value, + numberOfMessages: this.editForm.get(['numberOfMessages'])!.value, + size: this.editForm.get(['size'])!.value, + temporary: this.editForm.get(['temporary'])!.value }; } - protected subscribeToSaveResponse(result: Observable>): void { + protected subscribeToSaveResponse(result: Observable>): void { result.subscribe( () => this.onSaveSuccess(), () => this.onSaveError() @@ -81,4 +88,18 @@ export class QueueUpdateComponent implements OnInit { protected onSaveError(): void { this.isSaving = false; } + + 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.component.html b/src/main/webapp/app/entities/queue/queue.component.html index 0550d6ddf..3bb432608 100644 --- a/src/main/webapp/app/entities/queue/queue.component.html +++ b/src/main/webapp/app/entities/queue/queue.component.html @@ -18,10 +18,6 @@

No queues found -
- Number of Queues: {{addresses}} -
-
- - - - - - - + + + + + @@ -47,7 +41,7 @@

[infiniteScrollDisabled]="page >= links['last']" [infiniteScrollDistance]="0" [infiniteScrollUpDistance]="0">

diff --git a/src/main/webapp/app/entities/queue/queue.component.ts b/src/main/webapp/app/entities/queue/queue.component.ts index fd8c21e9f..9edba6aed 100644 --- a/src/main/webapp/app/entities/queue/queue.component.ts +++ b/src/main/webapp/app/entities/queue/queue.component.ts @@ -7,11 +7,15 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { AccountService } from 'app/core'; import { IQueue } from 'app/shared/model/queue.model'; -import { IAddresses, IAddress, Address } from 'app/shared/model/address.model'; +import { IRootAddress, IAddress, Address } from 'app/shared/model/address.model'; import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; import { QueueService } from './queue.service'; import { QueueDeleteDialogComponent } from './queue-delete-dialog.component'; +import { QueueClearDialogComponent } from './queue-clear-dialog.component'; +import { IBroker } from 'app/shared/model/broker.model'; +import { BrokerService } from 'app/entities/broker'; +import { IFlow } from 'app/shared/model/flow.model'; @Component({ selector: 'jhi-queue', @@ -21,6 +25,7 @@ export class QueueComponent implements OnInit, OnDestroy { public isAdmin: boolean; queues: IQueue[]; addresses: IAddress[]; + brokers: IBroker[]; eventSubscriber?: Subscription; currentAccount: any; itemsPerPage: number; @@ -33,9 +38,11 @@ export class QueueComponent implements OnInit, OnDestroy { dummy: any; searchText: string = ''; + brokerType: string = ''; constructor( protected queueService: QueueService, + protected brokerService: BrokerService, protected jhiAlertService: JhiAlertService, protected eventManager: JhiEventManager, protected modalService: NgbModal, @@ -43,37 +50,24 @@ export class QueueComponent implements OnInit, OnDestroy { protected accountService: AccountService ) { this.queues = []; + this.brokers = []; this.itemsPerPage = ITEMS_PER_PAGE; this.page = 0; this.links = { last: 0 }; - this.predicate = 'id'; - this.ascending = true; + this.predicate = 'name'; + this.ascending = false; } loadAll(): void { - alert('test'); - - this.queueService.getAllQueues('classic').subscribe( - (res: HttpResponse) => this.onSuccess(res.body, res.headers), - (res: HttpErrorResponse) => this.onError(res.message) - ); - - this.queueService - .query({ - page: this.page, - size: this.itemsPerPage, - sort: this.sort() - }) - .subscribe((res: HttpResponse) => this.paginateQueues(res.body, res.headers)); - - // this.addresses = this.parseXmlToAddresses("hello"); + this.brokerType = this.getBrokerType(); + // this.addresses = this.getAllQueues(this.brokerType); } reset(): void { this.page = 0; - this.queues = []; + this.addresses = []; this.loadAll(); } @@ -83,6 +77,7 @@ export class QueueComponent implements OnInit, OnDestroy { } ngOnInit(): void { + // this.loadBrokers(); this.loadAll(); this.registerChangeInQueues(); this.accountService.identity().then(account => { @@ -114,52 +109,76 @@ export class QueueComponent implements OnInit, OnDestroy { sort(): string[] { const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; - if (this.predicate !== 'id') { - result.push('id'); + if (this.predicate !== 'name') { + result.push('name'); } return result; } - protected paginateQueues(data: IQueue[] | null, headers: HttpHeaders): void { - const headersLink = headers.get('link'); - this.links = this.parseLinks.parse(headersLink ? headersLink : ''); - if (data) { - for (let i = 0; i < data.length; i++) { - this.queues.push(data[i]); - } - } + getAllQueues(brokerType: string): IAddress[] { + let addresses: Address[] = []; + + this.queueService.getAllQueues(brokerType).subscribe( + data => { + if (data) { + for (let i = 0; i < data.body.queues.queue.length; i++) { + addresses.push(data.body.queues.queue[i]); + } + } + }, + error => console.log(error) + ); + return addresses; } - protected parseXmlToAddresses(xmlInput: string): IAddress[] { - let addressList: IAddress[] = []; - addressList.push(new Address(1, 'hoi', 'hallo', 2, 3, 4)); - addressList.push(new Address(2, 'doei', 'dag', 5, 6, 7)); - - return addressList; + getBrokerType(): string { + this.queueService.getBrokers().subscribe( + data => { + if (data) { + for (let i = 0; i < data.body.length; i++) { + this.brokers.push(data.body[i]); + } + this.addresses = this.getAllQueues(this.brokers[0].type); + } + }, + error => console.log(error) + ); + return this.brokers[0].type; } - private onSuccess(data, headers) { - // if (this.gateways.length === 1) { - // this.links = this.parseLinks.parse(headers.get('link')); - // } + protected paginateQueues(data: IRootAddress | null, headers: HttpHeaders): void { + const headersLink = headers.get('link'); - this.dummy = data; + this.addresses = new Array(); - alert('BLAAAAAAAAAAAAAAAAAAAAAAAAAAAT ' + this.dummy); + if (data) { + for (let i = 0; i < data.queues.queue.length; i++) { + this.addresses.push(data.queues.queue[i]); + } + } + // this.links = this.parseLinks.parse(headersLink ? headersLink : ''); + } + + private onSuccess(data: IRootAddress, headers) { this.addresses = new Array(); - for (let i = 0; i < data.queues.length; i++) { - this.addresses.push(data.queues[i]); + for (let i = 0; i < data.queues.queue.length; i++) { + this.addresses.push(data.queues.queue[i]); } - let str = JSON.stringify(data, null, 4); - console.log('BLAAAAAAAAAAAAAAAAAAAAAAAAAAAT ' + str); - alert('BLAAAAAAAAAAAAAAAAAAAAAAAAAAAT ' + str); + this.totalItems = headers.get('X-Total-Count'); + } + + private onSuccessBroker(data: IBroker[], headers) { + for (let i = 0; i < data.length; i++) { + this.brokers.push(data[i]); + } + //Currently, only one broker is configured so brokerType = this.brokers[0].brokerType. In futere, use something like selectedBroker + this.brokerType = this.brokers[0].type; this.totalItems = headers.get('X-Total-Count'); } protected onError(errorMessage: string) { - alert('ERRORRRRRRRRRRRRRRRRRR '); - this.jhiAlertService.error('ERRORRRRRRRRRRRRRRRRRR' + errorMessage, null, null); + this.jhiAlertService.error(errorMessage, null, null); } } diff --git a/src/main/webapp/app/entities/queue/queue.module.ts b/src/main/webapp/app/entities/queue/queue.module.ts index cfef1db5f..376e26220 100644 --- a/src/main/webapp/app/entities/queue/queue.module.ts +++ b/src/main/webapp/app/entities/queue/queue.module.ts @@ -12,6 +12,7 @@ import { queueRoute } from './queue.route'; import { NgSelectModule } from '@ng-select/ng-select'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { QueueSearchByNamePipe } from './queue.searchbyname.pipe'; +import { QueueClearDialogComponent } from 'app/entities/queue/queue-clear-dialog.component'; @NgModule({ imports: [GatewaySharedModule, RouterModule.forChild(queueRoute), ReactiveFormsModule], @@ -21,8 +22,9 @@ import { QueueSearchByNamePipe } from './queue.searchbyname.pipe'; QueueUpdateComponent, QueueDeleteDialogComponent, QueueSearchByNamePipe, - QueueRowComponent + QueueRowComponent, + QueueClearDialogComponent ], - entryComponents: [QueueDeleteDialogComponent] + entryComponents: [QueueDeleteDialogComponent, QueueClearDialogComponent] }) export class GatewayQueueModule {} diff --git a/src/main/webapp/app/entities/queue/queue.searchbyname.pipe.ts b/src/main/webapp/app/entities/queue/queue.searchbyname.pipe.ts index db162e2bb..a249b3366 100644 --- a/src/main/webapp/app/entities/queue/queue.searchbyname.pipe.ts +++ b/src/main/webapp/app/entities/queue/queue.searchbyname.pipe.ts @@ -3,7 +3,16 @@ import { IAddress } from 'app/shared/model/address.model'; @Pipe({ name: 'QueueSearchByName' }) export class QueueSearchByNamePipe implements PipeTransform { - transform(addresses: IAddress[], searchText: string) { + transform(addresses: IAddress[], searchText: string, ascending: boolean, predicate: string) { + let asc: number = ascending ? 1 : -1; + + if (predicate == 'name') { + addresses = addresses.sort((a, b) => (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase() ? asc : asc * -1)); + } else if (predicate == 'numberOfConsumers') { + addresses = addresses.sort((a, b) => (a.numberOfConsumers <= b.numberOfConsumers ? asc : asc * -1)); + } else if (predicate == 'numberOfMessages') { + addresses = addresses.sort((a, b) => (a.numberOfMessages <= b.numberOfMessages ? asc : asc * -1)); + } return addresses.filter(address => address.name.toLocaleLowerCase().indexOf(searchText.toLocaleLowerCase()) !== -1); } } diff --git a/src/main/webapp/app/entities/queue/queue.service.ts b/src/main/webapp/app/entities/queue/queue.service.ts index fc6c34150..cab049c05 100644 --- a/src/main/webapp/app/entities/queue/queue.service.ts +++ b/src/main/webapp/app/entities/queue/queue.service.ts @@ -9,11 +9,13 @@ import { Router } from '@angular/router'; import { WindowRef } from 'app/shared'; import { IQueue } from 'app/shared/model/queue.model'; -import { IAddress, IAddresses } from 'app/shared/model/address.model'; +import { Address, IAddress, IAddresses, IRootAddress } from 'app/shared/model/address.model'; import * as SockJS from 'sockjs-client'; import * as Stomp from 'webstomp-client'; import { CSRFService } from 'app/core'; +import { BrokerService } from 'app/entities/broker'; +import { IBroker } from 'app/shared/model/broker.model'; type EntityResponseType = HttpResponse; type EntityArrayResponseType = HttpResponse; @@ -37,12 +39,20 @@ export class QueueService { private subscription: Subscription; private gatewayid = 1; + private brokerid = 1; + brokerType: string; - constructor(protected http: HttpClient, protected router: Router, protected $window: WindowRef, protected csrfService: CSRFService) { + constructor( + protected http: HttpClient, + protected router: Router, + protected $window: WindowRef, + protected csrfService: CSRFService, + protected brokerService: BrokerService + ) { this.connection = this.createConnection(); this.listener = this.createListener(); - this.brokerType = 'classic'; + // this.brokerType = 'classic'; } create(queue: IQueue): Observable { @@ -66,24 +76,40 @@ export class QueueService { return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); } - // getAllQueues(): Observable { - // return this.http.get(`${this.queueManagerResourceUrl}/queues?brokerType=${this.brokerType}`, { - // observe: 'response', - // responseType: 'text' - // }); - // } + getAllQueues(brokerType: string): Observable> { + return this.http.get(`${this.queueManagerResourceUrl}/${brokerType}/queues`, { + headers: new HttpHeaders({ PlaceholderReplacement: 'true', Accept: 'application/json' }), + observe: 'response' + }); + } + + getBrokers(): Observable> { + return this.http.get(`${this.queueManagerResourceUrl}`, { + headers: new HttpHeaders({ PlaceholderReplacement: 'true', Accept: 'application/json' }), + observe: 'response' + }); + } - getAllQueues(brokerType: string): Observable> { - return this.http.get(`${this.queueManagerResourceUrl}/${brokerType}/queues?brokerType=${brokerType}`, { - headers: new HttpHeaders({ PlaceholderReplacement: 'true', Accept: 'application/xml' }), + createQueue(name: string, brokerType: string): Observable> { + return this.http.post(`${this.queueManagerResourceUrl}/${brokerType}/queue/${name}`, null, { observe: 'response', responseType: 'text' }); } - // createQueue(queue: IAddress): Observable { - // return this.http.post(`${this.queueManagerResourceUrl}/queues/test12345?brokerType=${this.brokerType}`, { observe: 'response' }); - // } + deleteQueue(name: string, brokerType: string): Observable> { + return this.http.delete(`${this.queueManagerResourceUrl}/${brokerType}/queue/${name}`, { + observe: 'response', + responseType: 'text' + }); + } + + clearQueue(name: string, brokerType: string): Observable> { + return this.http.post(`${this.queueManagerResourceUrl}/${brokerType}/queue/${name}/clear`, null, { + observe: 'response', + responseType: 'text' + }); + } connect() { if (this.connectedPromise === null) { diff --git a/src/main/webapp/app/shared/model/address.model.ts b/src/main/webapp/app/shared/model/address.model.ts index eda496e73..814d63756 100644 --- a/src/main/webapp/app/shared/model/address.model.ts +++ b/src/main/webapp/app/shared/model/address.model.ts @@ -1,9 +1,9 @@ -export interface Welcome3 { +export interface IRootAddress { queues: IAddresses; } export interface IAddresses { - queues: IAddress[]; + queue: Address[]; } export interface IAddress { diff --git a/src/test/javascript/spec/app/entities/queue/queue-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/queue/queue-delete-dialog.component.spec.ts index 6829e6297..dad63d6fc 100644 --- a/src/test/javascript/spec/app/entities/queue/queue-delete-dialog.component.spec.ts +++ b/src/test/javascript/spec/app/entities/queue/queue-delete-dialog.component.spec.ts @@ -39,7 +39,7 @@ describe('Component Tests', () => { spyOn(service, 'delete').and.returnValue(of({})); // WHEN - comp.confirmDelete(123); + comp.confirmDelete('123'); tick(); // THEN diff --git a/src/test/javascript/spec/app/entities/queue/queue-update.component.spec.ts b/src/test/javascript/spec/app/entities/queue/queue-update.component.spec.ts index bee415b96..9cbdbe7c2 100644 --- a/src/test/javascript/spec/app/entities/queue/queue-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/queue/queue-update.component.spec.ts @@ -7,6 +7,7 @@ import { GatewayTestModule } from '../../../test.module'; import { QueueUpdateComponent } from 'app/entities/queue/queue-update.component'; import { QueueService } from 'app/entities/queue/queue.service'; import { Queue } from 'app/shared/model/queue.model'; +import { Address } from 'app/shared/model/address.model'; describe('Component Tests', () => { describe('Queue Management Update Component', () => { @@ -31,7 +32,7 @@ describe('Component Tests', () => { describe('save', () => { it('Should call update service on save for existing entity', fakeAsync(() => { // GIVEN - const entity = new Queue(123); + const entity = new Address(); spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); comp.updateForm(entity); // WHEN @@ -45,7 +46,7 @@ describe('Component Tests', () => { it('Should call create service on save for new entity', fakeAsync(() => { // GIVEN - const entity = new Queue(); + const entity = new Address(); spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); comp.updateForm(entity); // WHEN diff --git a/src/test/javascript/spec/app/entities/queue/queue.service.spec.ts b/src/test/javascript/spec/app/entities/queue/queue.service.spec.ts index 6b601c55c..9b6971fea 100644 --- a/src/test/javascript/spec/app/entities/queue/queue.service.spec.ts +++ b/src/test/javascript/spec/app/entities/queue/queue.service.spec.ts @@ -2,6 +2,7 @@ import { TestBed, getTestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { QueueService } from 'app/entities/queue/queue.service'; import { IQueue, Queue } from 'app/shared/model/queue.model'; +import { IRootAddress, IAddress } from 'app/shared/model/address.model'; describe('Service Tests', () => { describe('Queue Service', () => { @@ -9,7 +10,8 @@ describe('Service Tests', () => { let service: QueueService; let httpMock: HttpTestingController; let elemDefault: IQueue; - let expectedResult: IQueue | IQueue[] | boolean | null; + let elemDefIRootAddress: IRootAddress; + let expectedResult: IQueue | IQueue[] | IRootAddress | IAddress | IAddress[] | boolean | null; beforeEach(() => { TestBed.configureTestingModule({ @@ -71,7 +73,7 @@ describe('Service Tests', () => { expect(expectedResult).toMatchObject(expected); }); - it('should return a list of Queue', () => { + it('should return a IRootAddress with a list of queues', () => { const returnedFromService = Object.assign( { itemsOnPage: 1, @@ -79,7 +81,7 @@ describe('Service Tests', () => { selectedColumn: 'BBBBBB', orderColumn: 'BBBBBB' }, - elemDefault + elemDefIRootAddress ); const expected = Object.assign({}, returnedFromService);
Name Consumers Messages ActionsName Consumers Messages Actions