const assignVCADetails: VCADETAILS[] = [];
const setModels: SETMODELS[] = [];
Object.keys(list.vcaStatus).forEach((key: string): void => {
- const vcaApplication: VCAAPPLICATIONS[] = this.appData(list.vcaStatus[key].applications);
- const vcaUnits: VCAUNITS[] = this.unitsData(vcaApplication);
- const vcaMachines: MACHINES[] = this.machinesData(list.vcaStatus[key].machines);
- const assignNSInstancesID: string = key;
- list.vcaStatus[key].units = vcaUnits;
- list.vcaStatus[key].applications = vcaApplication;
- list.vcaStatus[key].machines = vcaMachines;
- // eslint-disable-next-line no-self-assign
- list.vcaStatus[key].relations = list.vcaStatus[key].relations;
- // eslint-disable-next-line no-self-assign
- list.vcaStatus[key].model = list.vcaStatus[key].model;
- const getEachModelData: SETMODELS = this.assignVCAStatusOfEachModel(list.vcaStatus[key]);
- setModels.push(getEachModelData);
- list.vcaStatus[assignNSInstancesID].vca_id = key;
- list.vcaStatus[assignNSInstancesID].vca_name = list.name;
- list.vcaStatus[assignNSInstancesID].ns_id = list.id;
- list.vcaStatus[assignNSInstancesID].isLiveloading = liveData;
- list.vcaStatus[assignNSInstancesID].timeOutSeconds = timeOutSeconds;
- list.vcaStatus[assignNSInstancesID].vcaStatusModels = setModels;
- const getAssignedData: VCADETAILS = this.formVCADetails(list.vcaStatus[assignNSInstancesID]);
- assignVCADetails.push(getAssignedData);
+ let vcaStatus = [];
+ vcaStatus = Object.values(list.vcaStatus[key]);
+ if (!isNullOrUndefined(vcaStatus)) {
+ vcaStatus.forEach((data): void => {
+ const vcaApplication: VCAAPPLICATIONS[] = this.appData(data.applications);
+ const vcaUnits: VCAUNITS[] = this.unitsData(vcaApplication);
+ const vcaMachines: MACHINES[] = this.machinesData(data.machines);
+ const assignNSInstancesID: string = key;
+ data.units = vcaUnits;
+ data.applications = vcaApplication;
+ data.machines = vcaMachines;
+ // eslint-disable-next-line no-self-assign
+ data.relations = data.relations;
+ // eslint-disable-next-line no-self-assign
+ data.model = data.model;
+ const getEachModelData: SETMODELS = this.assignVCAStatusOfEachModel(data);
+ setModels.push(getEachModelData);
+ list.vcaStatus[assignNSInstancesID].vca_id = key;
+ list.vcaStatus[assignNSInstancesID].vca_name = list.name;
+ list.vcaStatus[assignNSInstancesID].ns_id = list.id;
+ list.vcaStatus[assignNSInstancesID].isLiveloading = liveData;
+ list.vcaStatus[assignNSInstancesID].timeOutSeconds = timeOutSeconds;
+ list.vcaStatus[assignNSInstancesID].vcaStatusModels = setModels;
+ const getAssignedData: VCADETAILS = this.formVCADetails(list.vcaStatus[assignNSInstancesID]);
+ assignVCADetails.push(getAssignedData);
+ });
+ }
});
return assignVCADetails[0];
}
public appData(applicationData: VCAAPPLICATIONS): VCAAPPLICATIONS[] {
const vcaApplication: VCAAPPLICATIONS[] = [];
Object.keys(applicationData).forEach((applicationKey: string): void => {
- const charmSplitlist: string[] = applicationData[applicationKey].charm.split('/');
- const status: string = applicationData[applicationKey].status.status;
- // eslint-disable-next-line deprecation/deprecation
- const charm: string = charmSplitlist[1].substr(0, charmSplitlist[1].lastIndexOf('-'));
- // eslint-disable-next-line deprecation/deprecation
- const store: string = charmSplitlist[0].substr(0, charmSplitlist[0].lastIndexOf(':'));
- applicationData[applicationKey].app_id = applicationKey;
- applicationData[applicationKey].charm = charm;
- applicationData[applicationKey].status = status;
- applicationData[applicationKey].scale = Object.keys(applicationData[applicationKey].units).length;
- applicationData[applicationKey].store = store;
- applicationData[applicationKey].configs = !isNullOrUndefined(applicationData[applicationKey].configs) ?
- applicationData[applicationKey].configs : null;
- applicationData[applicationKey].actions = !isNullOrUndefined(applicationData[applicationKey].actions) ?
- applicationData[applicationKey].actions : null;
- vcaApplication.push(applicationData[applicationKey]);
+ if (!isNullOrUndefined(applicationData[applicationKey].charm)) {
+ const charmSplitlist: string[] = applicationData[applicationKey].charm.split('/');
+ const status: string = applicationData[applicationKey].status.status;
+ // eslint-disable-next-line deprecation/deprecation
+ const charm: string = charmSplitlist[1].substr(0, charmSplitlist[1].lastIndexOf('-'));
+ // eslint-disable-next-line deprecation/deprecation
+ const store: string = charmSplitlist[0].substr(0, charmSplitlist[0].lastIndexOf(':'));
+ applicationData[applicationKey].app_id = applicationKey;
+ applicationData[applicationKey].charm = charm;
+ applicationData[applicationKey].status = status;
+ applicationData[applicationKey].scale = Object.keys(applicationData[applicationKey].units).length;
+ applicationData[applicationKey].store = store;
+ applicationData[applicationKey].configs = !isNullOrUndefined(applicationData[applicationKey].configs) ?
+ applicationData[applicationKey].configs : null;
+ applicationData[applicationKey].actions = !isNullOrUndefined(applicationData[applicationKey].actions) ?
+ applicationData[applicationKey].actions : null;
+ vcaApplication.push(applicationData[applicationKey]);
+ }
});
return vcaApplication;
}