summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
diff options
context:
space:
mode:
authorSonsino, Ofir (os0695) <os0695@intl.att.com>2018-07-10 15:57:37 +0300
committerSonsino, Ofir (os0695) <os0695@intl.att.com>2018-07-10 15:57:37 +0300
commitff76b5ed0aa91d5fdf9dc4f95e8b20f91ed9d072 (patch)
treeaae42404a93fdffdd16ff050eaa28129959f7577 /vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
parentc72d565bb58226b20625b2bce5f0019046bee649 (diff)
New Angular UI from 1806
Change-Id: I39c160db0e0a6ec2e587ccf007ee1b23c6a08666 Issue-ID: VID-208 Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts')
-rw-r--r--vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts75
1 files changed, 75 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
new file mode 100644
index 000000000..293397cc9
--- /dev/null
+++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
@@ -0,0 +1,75 @@
+import {Injectable} from '@angular/core';
+import {ServiceInfoModel, ServiceInfoUiModel} from '../shared/server/serviceInfo/serviceInfo.model';
+import {isNullOrUndefined} from "util";
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/observable/of';
+
+export let PENDING : string = "pending";
+export let INPROGRESS : string = "inprogress";
+export let PAUSE : string = "pause";
+export let X_O : string = "X_o";
+export let SUCCESS_CIRCLE : string = "success+Circle";
+export let STOPED : string = "stoped";
+
+
+@Injectable()
+export class InstantiationStatusComponentService {
+ generateServiceInfoDataMapping(arr: Array<ServiceInfoModel>) : { [serviceInstanceId: string]: Array<ServiceInfoModel>}{
+ let serviceInfoData: { [serviceInstanceId: string]: Array<ServiceInfoModel>; } = {};
+ for(let item of arr){
+ if(isNullOrUndefined(serviceInfoData[item.templateId])){
+ serviceInfoData[item.templateId] = [item];
+ }else {
+ serviceInfoData[item.templateId].push(item);
+ }
+ }
+ return serviceInfoData;
+ }
+
+ convertObjectToArray(arr: Array<ServiceInfoModel>) : Observable<Array<ServiceInfoUiModel>>{
+ const obj = this.generateServiceInfoDataMapping(arr);
+ let index:number = 0;
+ let result = [];
+ for(let item in obj) {
+ obj[item].map(item => {
+ item['serviceStatus'] = this.getStatus(item.jobStatus);
+ item['serviceIndex'] = index;
+ });
+ index++;
+ result = result.concat(obj[item]);
+ }
+
+ console.log(result);
+ return Observable.of(result);
+ }
+
+ getStatus(status : string) : ServiceStatus {
+ switch(status.toUpperCase()) {
+ case 'PENDING' :
+ return new ServiceStatus(PENDING, '#009FDB', 'Pending: The service will automatically be sent for instantiation as soon as possible.');
+ case 'IN_PROGRESS' :
+ return new ServiceStatus(INPROGRESS, '#009FDB', 'In-progress: the service is in process of instantiation.');
+ case 'PAUSED' :
+ return new ServiceStatus(PAUSE, '#009FDB', 'Paused: Service has paused and waiting for your action.\n Select actions from the menu to the right.');
+ case 'FAILED' :
+ return new ServiceStatus(X_O, '#D02B2B', 'Failed: Service instantiation has failed, load the service to see the error returned.');
+ case 'COMPLETED' :
+ return new ServiceStatus(SUCCESS_CIRCLE, '#53AD15', 'Completed successfully: Service is successfully instantiated.');
+ case 'STOPPED' :
+ return new ServiceStatus(STOPED, '#D02B2B', 'Stopped: Due to previous failure, will not be instantiated.');
+ }
+ }
+}
+
+
+export class ServiceStatus {
+ iconClassName : string;
+ color : string;
+ tooltip : string;
+
+ constructor(_iconClassName : string, _color : string, _tooltip : string){
+ this.iconClassName = _iconClassName;
+ this.color = _color;
+ this.tooltip = _tooltip;
+ }
+}