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