summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts86
1 files changed, 86 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts
new file mode 100644
index 000000000..946c5cab5
--- /dev/null
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts
@@ -0,0 +1,86 @@
+import {Injectable} from "@angular/core";
+import {ActivatedRoute} from "@angular/router";
+import {addServiceAction} from "../../../shared/storeUtil/utils/service/service.actions";
+import {ServiceInstanceActions} from "../../../shared/models/serviceInstanceActions";
+import {AppState} from "../../../shared/store/reducers";
+import {DrawingBoardTreeComponent} from "../drawing-board-tree/drawing-board-tree.component";
+import {AuditInfoModalComponent} from "../../../shared/components/auditInfoModal/auditInfoModal.component";
+import {ServiceModel} from "../../../shared/models/serviceModel";
+import {NgRedux} from "@angular-redux/store";
+import * as _ from 'lodash';
+import {ErrorMsgService} from "../../../shared/components/error-msg/error-msg.service";
+import {DrawingBoardModes} from "../drawing-board.modes";
+import {ServiceInstance} from "../../../shared/models/serviceInstance";
+
+@Injectable()
+export class DrawingBoardHeaderService{
+
+ constructor(private route: ActivatedRoute, private store: NgRedux<AppState>, private errorMsgService: ErrorMsgService){}
+ generateOldViewEditPath(): string{
+ let query: string =
+ `subscriberId=${this.route.snapshot.queryParams['subscriberId']}&` +
+ `subscriberName=${this.route.snapshot.queryParams['subscriberName']}&` +
+ `serviceType=${this.route.snapshot.queryParams['serviceType']}&` +
+ `serviceInstanceId=${this.route.snapshot.queryParams['serviceInstanceId']}`;
+ return '../../serviceModels.htm#/instantiate?' + query;
+ }
+
+ deleteService(serviceModelId: string, isDeleted: boolean ) {
+ if(isDeleted){
+ this.store.dispatch(addServiceAction(serviceModelId, ServiceInstanceActions.Delete));
+ DrawingBoardTreeComponent.triggerDeleteActionService.next(serviceModelId);
+ } else{
+ this.store.dispatch(addServiceAction(serviceModelId, ServiceInstanceActions.None));
+ DrawingBoardTreeComponent.triggerUndoDeleteActionService.next(serviceModelId);
+ }
+ }
+
+ showAuditInfo(serviceModelId) : void {
+ let instance: ServiceInstance = this.store.getState().service.serviceInstance[serviceModelId];
+ let model = new ServiceModel(this.store.getState().service.serviceHierarchy[serviceModelId]);
+ AuditInfoModalComponent.openInstanceAuditInfoModal.next({instanceId : serviceModelId , type : 'SERVICE', model : model , instance : instance, trackById: instance.trackById});
+ }
+
+
+ /*************************************************
+ should return true if deploy should be disabled
+ *************************************************/
+ deployShouldBeDisabled(serviceInstanceId: string, mode : string) : boolean {
+ const serviceInstance = this.store.getState().service.serviceInstance[serviceInstanceId];
+ if(!_.isNil(serviceInstance)){
+ const validationCounter = serviceInstance.validationCounter;
+ if (!_.isNil(this.errorMsgService.errorMsgObject)&& mode !== DrawingBoardModes.RETRY_EDIT) return true;
+ if(validationCounter > 0) return true;
+ if(serviceInstance.action !== ServiceInstanceActions.None) return false;
+ if(mode === DrawingBoardModes.RETRY_EDIT) return false;
+ return !serviceInstance.isDirty;
+ }
+ return true;
+ }
+
+ getModeButton(mode : string) : string {
+ switch (mode) {
+ case DrawingBoardModes.EDIT:
+ return 'UPDATE';
+ case DrawingBoardModes.RETRY_EDIT:
+ return 'REDEPLOY';
+ default: return 'DEPLOY';
+ }
+ }
+ getButtonText(mode : DrawingBoardModes) : string {
+ switch (mode) {
+ case DrawingBoardModes.EDIT:
+ case DrawingBoardModes.VIEW:
+ return 'EDIT';
+ case DrawingBoardModes.RETRY_EDIT:
+ case DrawingBoardModes.RETRY:
+ return 'REDEPLOY';
+ }
+ }
+
+ showEditService(mode: DrawingBoardModes, serviceModelId: string): boolean{
+ const serviceInstance = this.store.getState().service.serviceInstance;
+ return mode === DrawingBoardModes.CREATE || ((mode === DrawingBoardModes.RETRY_EDIT || mode === DrawingBoardModes.EDIT)&&
+ !_.isNil(serviceInstance) && !_.isNil(serviceInstance[serviceModelId])&& serviceInstance[serviceModelId].action === ServiceInstanceActions.Create);
+ }
+}