blob: 5aee65890a2f192e0e62dd48243b597ef1bf82d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { Pipe, PipeTransform } from '@angular/core';
import _ from 'lodash';
@Pipe({
name: 'placement'
})
export class PlacementPipe implements PipeTransform {
/**
* Convert the placement configuration into human readable form.
* The output is equal to the column 'PLACEMENT' in 'ceph orch ls'.
* @param serviceSpec The service specification to process.
* @return The placement configuration as human readable string.
*/
transform(serviceSpec: object | undefined): string {
if (_.isUndefined(serviceSpec)) {
return $localize`no spec`;
}
if (_.get(serviceSpec, 'unmanaged', false)) {
return $localize`unmanaged`;
}
const kv: Array<any> = [];
const hosts: Array<string> = _.get(serviceSpec, 'placement.hosts');
const count: number = _.get(serviceSpec, 'placement.count');
const label: string = _.get(serviceSpec, 'placement.label');
const hostPattern: string = _.get(serviceSpec, 'placement.host_pattern');
if (_.isArray(hosts)) {
kv.push(...hosts);
}
if (_.isNumber(count)) {
kv.push($localize`count:${count}`);
}
if (_.isString(label)) {
kv.push($localize`label:${label}`);
}
if (_.isString(hostPattern)) {
kv.push(hostPattern);
}
return kv.join(';');
}
}
|