blob: 32610d993f9166edb94f1a5828247be400b23a86 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {Injectable} from "@angular/core";
2import {NgRedux} from "@angular-redux/store";
3import {AppState} from "../../../shared/store/reducers";
4import {AaiService} from "../../../shared/services/aaiService/aai.service";
5import {Subject} from "rxjs";
6import {ComponentInfoModel, ComponentInfoType} from "./component-info-model";
7import {ModelInformationItem} from "../../../shared/components/model-information/model-information.component";
8import * as _ from 'lodash';
Ittay Sternf7926712019-07-07 19:23:03 +03009import {SharedTreeService} from "../objectsToTree/shared.tree.service";
Ittay Stern6f900cc2018-08-29 17:01:32 +030010@Injectable()
11export class ComponentInfoService {
12 static triggerComponentInfoChange: Subject<ComponentInfoModel> = new Subject<ComponentInfoModel>();
Ittay Sternf7926712019-07-07 19:23:03 +030013 constructor( private _store: NgRedux<AppState>, private _aaiService : AaiService, private _sharedTreeService : SharedTreeService){ }
Ittay Stern6f900cc2018-08-29 17:01:32 +030014
15 getInfoForService(serviceModelId):ComponentInfoModel {
16 if(_.isNil(this._store.getState().service.serviceHierarchy[serviceModelId])) return null;
17
Ittay Sternf7926712019-07-07 19:23:03 +030018 const serviceHierarchy = this._store.getState().service.serviceHierarchy[serviceModelId].service;
Ittay Stern6f900cc2018-08-29 17:01:32 +030019 const serviceInstance = this._store.getState().service.serviceInstance[serviceModelId];
20 const modelInfoItems: ModelInformationItem[] = [
Ittay Sternf7926712019-07-07 19:23:03 +030021 ModelInformationItem.createInstance("Type", serviceHierarchy.serviceType),
22 ModelInformationItem.createInstance("Model version", serviceHierarchy.version ),
23 ModelInformationItem.createInstance("Model customization ID", serviceHierarchy.customizationUuid ),
24 ModelInformationItem.createInstance("Instance ID", serviceInstance.instanceId),
25 ModelInformationItem.createInstance("Subscriber name",this._aaiService.extractSubscriberNameBySubscriberId(serviceInstance.globalSubscriberId)),
26 ModelInformationItem.createInstance("Service type",serviceInstance.subscriptionServiceType),
27 ModelInformationItem.createInstance("Service role",serviceHierarchy.serviceRole),
Ittay Stern6f900cc2018-08-29 17:01:32 +030028 ];
Ittay Stern6f900cc2018-08-29 17:01:32 +030029
Ittay Sternf7926712019-07-07 19:23:03 +030030 return this._sharedTreeService.getComponentInfoModelByModelInformationItems(modelInfoItems, ComponentInfoType.SERVICE, serviceInstance );
Ittay Stern6f900cc2018-08-29 17:01:32 +030031 }
32}