File
Metadata
selector |
app-stream-deployment-properties-info |
styleUrls |
deployment-properties-info.component.scss |
templateUrl |
./deployment-properties-info.component.html |
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Accessors
|
|
Methods
Private extractData
|
extractData(deploymentProperties: any)
|
|
Parameters :
Name |
Type |
Optional |
Description |
deploymentProperties |
any
|
|
|
|
Private extractSingleApp
|
extractSingleApp(app: string, data: any)
|
|
Parameters :
Name |
Type |
Optional |
Description |
app |
string
|
|
|
data |
any
|
|
|
|
Public deploymentProperties
|
deploymentProperties: Observable<[]>
|
Type : Observable<[]>
|
|
Accessors
streamDefinition
|
setstreamDefinition(streamDef: )
|
|
Parameters :
Name |
Type |
Optional |
Description |
streamDef |
|
|
|
|
import { Component, Input } from '@angular/core';
import { Observable, of } from 'rxjs';
import { share } from 'rxjs/operators';
import { StreamDefinition } from '../../model/stream-definition';
import { StreamsService } from '../../streams.service';
const VERSION_PROPERTY_KEY_PREFIX = 'maven://';
export class KeyValuePair {
constructor(public key: string,
public value: string) {
}
}
export class DeployedAppProperties {
constructor(public name: string,
public version: string,
public props: KeyValuePair[]) {
}
}
@Component({
selector: 'app-stream-deployment-properties-info',
templateUrl: './deployment-properties-info.component.html',
styleUrls: ['./deployment-properties-info.component.scss'],
})
/**
* Component that shows stream deployment info.
*
* @author Alex Boyko
*/
export class DeploymentPropertiesInfoComponent {
public deploymentProperties: Observable<DeployedAppProperties[]>;
constructor(private streamsService: StreamsService) {
}
@Input()
set streamDefinition(streamDef: StreamDefinition) {
if (streamDef.deploymentProperties) {
this.deploymentProperties = of(this.extractData(streamDef.deploymentProperties)).pipe(share());
} else {
this.deploymentProperties = this.streamsService.getDeploymentInfo(streamDef.name.toString()).map(d => {
streamDef.deploymentProperties = d.deploymentProperties;
return this.extractData(streamDef.deploymentProperties);
}).pipe(share());
}
}
getAppTitle(app: DeployedAppProperties): string {
if (app.version) {
return `${app.name} (${app.version})`;
} else {
return app.name;
}
}
private extractData(deploymentProperties: any) {
return Object.keys(deploymentProperties).map(k => this.extractSingleApp(k, deploymentProperties[k]));
}
private extractSingleApp(app: string, data: any) {
const props = [];
let version;
Object.keys(data).forEach(k => {
if (k.startsWith(VERSION_PROPERTY_KEY_PREFIX)) {
version = data[k];
} else {
props.push(new KeyValuePair(k, data[k]));
}
});
return new DeployedAppProperties(app, version, props);
}
}
<div *ngIf="deploymentProperties | async as appsProperties; else loading">
<div *ngFor="let app of appsProperties">
<div class="deployment-properties-app"><strong>{{ getAppTitle(app) }}</strong></div>
<div class="table-responsive">
<table *ngIf="app.props.length" class="table table-bordered">
<tr *ngFor="let pair of app.props">
<td class="deployment-properties-key">{{ pair.key }}</td>
<td class="deployment-properties-value">{{ pair.value }}</td>
</tr>
</table>
</div>
</div>
</div>
<ng-template #loading>
<div style="padding:5px;line-height:26px">
<app-loader></app-loader>
</div>
</ng-template>
Legend
Html element with directive