1 import * as moment from 'moment';
2 import * as _ from 'lodash';
3 import {InstantiationBase} from "../../../models/serviceBase";
5 export class InstantiationTemplatesRowModel extends InstantiationBase{
6 readonly userId ?: string;
7 readonly createDate ?: string;
8 readonly instanceName ?: string;
9 readonly instantiationStatus?: string;
10 readonly summary?: string;
11 readonly region?: string;
12 readonly tenant?: string;
13 readonly aicZone?: string;
17 this.userId = !_.isNil(data.created) ? data.userId : null;
18 this.createDate = !_.isNil(data.created) ? moment(data.created).format("YYYY-MM-DD HH:mm:ss") : null;
19 this.instanceName = this.getInstanceName(data.serviceInstanceName);
20 this.instantiationStatus = !_.isNil(data.jobStatus) ? data.jobStatus : null;
22 this.region = this.getRegion(data.regionId, data.owningEntityName);
23 this.tenant = !_.isNil(data.tenantName) ? data.tenantName : null;
24 this.aicZone = !_.isNil(data.aicZoneName) ? data.aicZoneName : null;
28 /**************************************************************************************************
29 return the LCP region and in brackets the cloud owner removing the “att-“ with capital letters.
30 **************************************************************************************************/
31 getCloudOwner = (owningEntityName: string): string => {
32 const splitByAtt: string[] = owningEntityName.split('att-');
33 let owning: string = splitByAtt[splitByAtt.length - 1];
34 return owning.toUpperCase();
37 getRegion = (regionId: string, owningEntityName: string): string => {
38 const convertOwning = !_.isNil(owningEntityName) ? `(${this.getCloudOwner(owningEntityName)})` : '';
39 return `${regionId} ${convertOwning}`.trim();
43 getInstanceName = (instanceName?: string): string => {
44 if (_.isNil(instanceName)) {
45 return '<Automatically generated>';