src/app/streams/streams-deploy/streams-deploy.component.ts
Component used to deploy stream definitions.
selector | app-streams-deploy |
templateUrl | ./streams-deploy.component.html |
Properties |
Methods |
Outputs |
constructor(streamsService: StreamsService, modalRef: BsModalRef, loggerService: LoggerService, blockerService: BlockerService, notificationService: NotificationService)
|
||||||||||||||||||||||||
Adds deployment properties to the FormBuilder
Parameters :
|
confirm
|
Output event throw after import completed $event type: EventEmitter
|
back |
back()
|
Back to the stream definitions list to deploy modal
Returns :
void
|
deployDefinitions |
deployDefinitions()
|
Applies the deploy process of multiple StreamDefinitions
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Will cleanup any {@link Subscription}s to prevent memory leaks.
Returns :
void
|
open | ||||||||
open(args: literal type)
|
||||||||
Initialize data
Parameters :
Returns :
Observable<any>
|
viewDeploymentProperties | ||||||||
viewDeploymentProperties(streamDefinition: StreamDefinition)
|
||||||||
Start the process to add deployment properties to a stream definition
Parameters :
Returns :
void
|
Private ngUnsubscribe$ |
ngUnsubscribe$:
|
Type : Subject<any>
|
Unsubscribe |
selectStreamDefinition |
selectStreamDefinition:
|
Type : StreamDefinition
|
StreamDefinition selected to edit deployment parameters |
streamDefinitions |
streamDefinitions:
|
Type : StreamDefinition[]
|
Collections of StreamDefinition to unregister |
import { Component, Output, EventEmitter, OnDestroy } from '@angular/core';
import { StreamsService } from '../streams.service';
import { StreamDefinition } from '../model/stream-definition';
import { BsModalRef } from 'ngx-bootstrap';
import { finalize, takeUntil } from 'rxjs/operators';
import { Modal } from '../../shared/components/modal/modal-abstract';
import { Observable, Subject } from 'rxjs';
import { NotificationService } from '../../shared/services/notification.service';
import { LoggerService } from '../../shared/services/logger.service';
import { AppError } from '../../shared/model/error.model';
import { BlockerService } from '../../shared/components/blocker/blocker.service';
/**
* Component used to deploy stream definitions.
*
* @author Damien Vitrac
* @author Gunnar Hillert
*/
@Component({
selector: 'app-streams-deploy',
templateUrl: './streams-deploy.component.html'
})
export class StreamsDeployComponent extends Modal implements OnDestroy {
/**
* Unsubscribe
*/
private ngUnsubscribe$: Subject<any> = new Subject();
/**
* Collections of StreamDefinition to unregister
*/
streamDefinitions: StreamDefinition[];
/**
* StreamDefinition selected to edit deployment parameters
*/
selectStreamDefinition: StreamDefinition;
/**
* Output event throw after import completed
*/
@Output() confirm = new EventEmitter();
/**
* Adds deployment properties to the FormBuilder
* @param modalRef Modal reference
* @param streamsService The service used to deploy the stream.
* @param blockerService
* @param notificationService used to display the status of a deployment
* @param loggerService
*/
constructor(private streamsService: StreamsService,
private modalRef: BsModalRef,
private loggerService: LoggerService,
private blockerService: BlockerService,
private notificationService: NotificationService) {
super(modalRef);
}
/**
* Initialize data
*/
open(args: { streamDefinitions: StreamDefinition[] }): Observable<any> {
this.streamDefinitions = args.streamDefinitions;
return this.confirm;
}
/**
* Will cleanup any {@link Subscription}s to prevent
* memory leaks.
*/
ngOnDestroy() {
this.ngUnsubscribe$.next();
this.ngUnsubscribe$.complete();
}
/**
* Applies the deploy process of multiple {@link StreamDefinition}s
*/
deployDefinitions() {
this.loggerService.log(`Proceeding to deploy ${this.streamDefinitions.length} stream definition(s).`, this.streamDefinitions);
this.blockerService.lock();
this.streamsService.deployMultipleStreamDefinitions(this.streamDefinitions)
.pipe(takeUntil(this.ngUnsubscribe$), finalize(() => this.blockerService.unlock()))
.subscribe((data) => {
this.notificationService.success(`${data.length} stream definition(s) deployed.`);
this.confirm.emit(data);
this.cancel();
}, (error) => {
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
});
}
/**
* Start the process to add deployment properties to a stream definition
*
* @param streamDefinition
*/
viewDeploymentProperties(streamDefinition: StreamDefinition) {
this.selectStreamDefinition = streamDefinition;
}
/**
* Back to the stream definitions list to deploy modal
*/
back() {
this.selectStreamDefinition = null;
}
}
<div *ngIf="streamDefinitions">
<div class="modal-content" *ngIf="!selectStreamDefinition" id="panel-stream">
<div class="modal-header">
<h4 class="modal-title pull-left">Confirm Deployment of Stream Definitions</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="cancel()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" *ngIf="streamDefinitions">
<p>
This action will deploy the <strong>{{ streamDefinitions.length }}
stream definition{{ streamDefinitions.length > 1 ? 's' : '' }}</strong> listed below.
Optionally, you can add deployment properties for each stream definition.
</p>
<br/>
<table id="table-stream" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Definition</th>
<th>Deployment properties</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of streamDefinitions">
<td>{{ item.name }}</td>
<td>
<app-stream-dsl>{{ item.dslText | truncate: 90 }}</app-stream-dsl>
</td>
<td width="10" nowrap="">
<div *ngIf="item.deploymentProperties && (item.deploymentProperties | keyvalue)?.length > 0">
<p style="padding-bottom: 6px">
<strong>{{ (item.deploymentProperties | keyvalue)?.length }}
propert{{ (item.deploymentProperties | keyvalue)?.length > 1 ? 'ies' : 'y' }}</strong>
</p>
</div>
<div>
<a class="btn btn-sm btn-default" (click)="viewDeploymentProperties(item)">
Edit deployment properties
</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" (click)="cancel()">Cancel</button>
<button type="button" class="btn btn-primary" (click)="deployDefinitions()">Deploy</button>
</div>
</div>
<div class="modal-content" *ngIf="selectStreamDefinition" id="panel-parameters">
<app-stream-deployment-properties [stream]="selectStreamDefinition" (submit)="back()" (cancel)="back()">
</app-stream-deployment-properties>
</div>
</div>