Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | import {Injectable} from "@angular/core"; |
| 2 | import {NgRedux} from "@angular-redux/store"; |
| 3 | import {AppState} from "../../../shared/store/reducers"; |
| 4 | import {AaiService} from "../../../shared/services/aaiService/aai.service"; |
| 5 | import {Subject} from "rxjs"; |
| 6 | import {ComponentInfoModel, ComponentInfoType} from "./component-info-model"; |
| 7 | import {ModelInformationItem} from "../../../shared/components/model-information/model-information.component"; |
| 8 | import * as _ from 'lodash'; |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 9 | import {SharedTreeService} from "../objectsToTree/shared.tree.service"; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 10 | @Injectable() |
| 11 | export class ComponentInfoService { |
| 12 | static triggerComponentInfoChange: Subject<ComponentInfoModel> = new Subject<ComponentInfoModel>(); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 13 | constructor( private _store: NgRedux<AppState>, private _aaiService : AaiService, private _sharedTreeService : SharedTreeService){ } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 14 | |
| 15 | getInfoForService(serviceModelId):ComponentInfoModel { |
| 16 | if(_.isNil(this._store.getState().service.serviceHierarchy[serviceModelId])) return null; |
| 17 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 18 | const serviceHierarchy = this._store.getState().service.serviceHierarchy[serviceModelId].service; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 19 | const serviceInstance = this._store.getState().service.serviceInstance[serviceModelId]; |
| 20 | const modelInfoItems: ModelInformationItem[] = [ |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 21 | 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 Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 28 | ]; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 29 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 30 | return this._sharedTreeService.getComponentInfoModelByModelInformationItems(modelInfoItems, ComponentInfoType.SERVICE, serviceInstance ); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 31 | } |
| 32 | } |