Apply Valid Value Constraints validation
[sdc.git] / catalog-ui / src / app / app.ts
index 305327c..a147f8c 100644 (file)
@@ -1,7 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
 'use strict';
 
 //import 'restangular';
 //import 'angular-ui-router';
+import * as _ from "lodash";
 import "reflect-metadata";
 import 'ng-infinite-scroll';
 import './modules/filters.ts';
@@ -9,35 +30,34 @@ import './modules/utils.ts';
 import './modules/directive-module.ts';
 import './modules/service-module';
 import './modules/view-model-module.ts';
+import {SdcUiComponentsNg1Module} from 'sdc-ui/lib/angular';
 
 import {
-    IUserResourceClass,
     DataTypesService,
     LeftPaletteLoaderService,
     EcompHeaderService,
     CookieService,
     ConfigurationUiService,
     CacheService,
-    IUserResource,
     SdcVersionService,
     ICategoryResourceClass,
     EntityService
 } from "./services";
+import { UserService } from "./ng2/services/user.service";
 import {forwardRef} from '@angular/core';
 import {UpgradeAdapter} from '@angular/upgrade';
-import {CHANGE_COMPONENT_CSAR_VERSION_FLAG, States} from "./utils";
+import {CHANGE_COMPONENT_CSAR_VERSION_FLAG, States, PREVIOUS_CSAR_COMPONENT} from "./utils";
 import {IAppConfigurtaion, IAppMenu, IMainCategory, Resource, IHostedApplication} from "./models";
 import {ComponentFactory} from "./utils/component-factory";
 import {ModalsHandler} from "./utils/modals-handler";
 import {downgradeComponent} from "@angular/upgrade/static";
 
 import {AppModule} from './ng2/app.module';
-import {PropertiesAssignmentComponent} from "./ng2/pages/properties-assignment/properties-assignment.page.component";
 import {Component} from "./models/components/component";
 import {ComponentServiceNg2} from "./ng2/services/component-services/component.service";
 import {ComponentMetadata} from "./models/component-metadata";
 import {Categories} from "./models/categories";
-
+import {IUserProperties} from "./models/user";
 
 let moduleName:string = 'sdcApp';
 let viewModelsModuleName:string = 'Sdc.ViewModels';
@@ -80,6 +100,7 @@ let dependentModules:Array<string> = [
     'angular-clipboard',
     'angularResizable',
     'infinite-scroll',
+    SdcUiComponentsNg1Module.name,
     viewModelsModuleName,
     directivesModuleName,
     servicesModuleName,
@@ -124,7 +145,6 @@ _.each(hostedApplications, (hostedApp)=> {
 // ===================== Hosted applications section ====================
 
 export const ng1appModule:ng.IModule = angular.module(moduleName, dependentModules);
-angular.module('sdcApp').directive('propertiesAssignment', downgradeComponent({component: PropertiesAssignmentComponent}) as angular.IDirectiveFactory);
 
 ng1appModule.config([
     '$stateProvider',
@@ -141,7 +161,7 @@ ng1appModule.config([
      NotificationProvider:any):void => {
 
         NotificationProvider.setOptions({
-            delay: 10000,
+            delay: 5000,
             startTop: 10,
             startRight: 10,
             closeOnClick: true,
@@ -150,6 +170,7 @@ ng1appModule.config([
             positionX: 'right',
             positionY: 'top'
         });
+        NotificationProvider.options.templateUrl = 'notification-custom-template.html';
 
         $translateProvider.useStaticFilesLoader({
             prefix: pathPrefix + 'assets/languages/',
@@ -165,7 +186,7 @@ ng1appModule.config([
 
         $stateProvider.state(
             'dashboard', {
-                url: '/dashboard?show&folder',
+                url: '/dashboard?show&folder&filter.term&filter.status&filter.distributed',
                 templateUrl: "./view-models/dashboard/dashboard-view.html",
                 controller: viewModelsModuleName + '.DashboardViewModel',
             }
@@ -180,23 +201,64 @@ ng1appModule.config([
         );
 
         let componentsParam:Array<any> = ['$stateParams', 'Sdc.Services.EntityService', 'Sdc.Services.CacheService', ($stateParams:any, EntityService:EntityService, cacheService:CacheService) => {
-            if (cacheService.get('breadcrumbsComponents')) {
-                return cacheService.get('breadcrumbsComponents');
+            if (cacheService.get('breadcrumbsComponentsState') === $stateParams.previousState) {
+                const breadcrumbsComponents = cacheService.get('breadcrumbsComponents');
+                if (breadcrumbsComponents) {
+                    return breadcrumbsComponents;
+                }
             } else {
-                return EntityService.getCatalog();
+                let breadcrumbsComponentsPromise;
+                if ($stateParams.previousState === 'dashboard') {
+                    breadcrumbsComponentsPromise = EntityService.getAllComponents(true);
+                } else if ($stateParams.previousState === 'catalog') {
+                    breadcrumbsComponentsPromise = EntityService.getCatalog();
+                } else {
+                    cacheService.remove('breadcrumbsComponentsState');
+                    cacheService.remove('breadcrumbsComponents');
+                    return [];
+                }
+                breadcrumbsComponentsPromise.then((components) => {
+                    cacheService.set('breadcrumbsComponentsState', $stateParams.previousState);
+                    cacheService.set('breadcrumbsComponents', components);
+                });
+                return breadcrumbsComponentsPromise;
             }
         }];
 
+        const oldWorkspaceController:Array<any> = ['$location', ($location:ng.ILocationService) => {
+            // redirect old /workspace/* urls to /catalog/workspace/* url
+            const newUrl = '/catalog' + $location.url();
+            console.log('old workspace path - redirecting to:', newUrl);
+            $location.url(newUrl);
+        }];
+
+        $stateProvider.state(
+            'workspace-old', {
+                url: '/workspace/:id/:type/*workspaceInnerPath',
+                controller: oldWorkspaceController
+            }
+        );
+
         $stateProvider.state(
             'workspace', {
-                url: '/workspace/:id/:type/',
+                url: '/:previousState/workspace/:id/:type/',
                 params: {'importedFile': null, 'componentCsar': null, 'resourceType': null, 'disableButtons': null},
                 templateUrl: './view-models/workspace/workspace-view.html',
                 controller: viewModelsModuleName + '.WorkspaceViewModel',
                 resolve: {
-                    injectComponent: ['$stateParams', 'ComponentFactory', 'ComponentServiceNg2', function ($stateParams, ComponentFactory:ComponentFactory, ComponentServiceNg2:ComponentServiceNg2) {
-                        if ($stateParams.id) {
-                            return ComponentFactory.getComponentWithMetadataFromServer($stateParams.type.toUpperCase(), $stateParams.id);
+                    injectComponent: ['$stateParams', 'ComponentFactory', 'Sdc.Services.CacheService', 'ComponentServiceNg2', function ($stateParams, ComponentFactory:ComponentFactory, cacheService:CacheService, ComponentServiceNg2:ComponentServiceNg2) {
+
+                        if ($stateParams.id && $stateParams.id.length) { //need to check length in case ID is an empty string
+                            return ComponentFactory.getComponentWithMetadataFromServer($stateParams.type.toUpperCase(), $stateParams.id).then(
+                                (component:Component)=> {
+                                if ($stateParams.componentCsar && component.isResource()){
+                                    if((<Resource>component).csarVersion != $stateParams.componentCsar.csarVersion) {
+                                        cacheService.set(PREVIOUS_CSAR_COMPONENT, angular.copy(component));
+                                    }
+                                    component = ComponentFactory.updateComponentFromCsar($stateParams.componentCsar, <Resource>component);
+                                }
+                                return component;
+                            });
                         } else if ($stateParams.componentCsar && $stateParams.componentCsar.csarUUID) {
                             return $stateParams.componentCsar;
                         } else {
@@ -225,17 +287,6 @@ ng1appModule.config([
                 data: {unsavedChanges: false, bodyClass: 'general'}
             }
         );
-        //
-        $stateProvider.state(
-            States.WORKSPACE_ICONS, {
-                url: 'icons',
-                parent: 'workspace',
-                controller: viewModelsModuleName + '.IconsViewModel',
-                templateUrl: './view-models/workspace/tabs/icons/icons-view.html',
-                data: {unsavedChanges: false, bodyClass: 'icons'}
-
-            }
-        );
 
         $stateProvider.state(
             States.WORKSPACE_ACTIVITY_LOG, {
@@ -243,7 +294,6 @@ ng1appModule.config([
                 parent: 'workspace',
                 controller: viewModelsModuleName + '.ActivityLogViewModel',
                 templateUrl: './view-models/workspace/tabs/activity-log/activity-log.html',
-                data: {unsavedChanges: false}
             }
         );
 
@@ -259,17 +309,6 @@ ng1appModule.config([
             }
         );
 
-        $stateProvider.state(
-            States.WORKSPACE_HIERARCHY, {
-                url: 'hierarchy',
-                parent: 'workspace',
-                controller: viewModelsModuleName + '.ProductHierarchyViewModel',
-                templateUrl: './view-models/workspace/tabs/product-hierarchy/product-hierarchy-view.html',
-                data: {unsavedChanges: false}
-
-            }
-        );
-
         $stateProvider.state(
             States.WORKSPACE_INFORMATION_ARTIFACTS, {
                 url: 'information_artifacts',
@@ -306,18 +345,6 @@ ng1appModule.config([
             }
         );
 
-        $stateProvider.state(
-            States.WORKSPACE_SERVICE_INPUTS, {
-                url: 'service_inputs',
-                parent: 'workspace',
-                controller: viewModelsModuleName + '.ServiceInputsViewModel',
-                templateUrl: './view-models/workspace/tabs/inputs/service-input/service-inputs-view.html',
-                data: {
-                    bodyClass: 'workspace-inputs'
-                }
-            }
-        );
-
         $stateProvider.state(
             States.WORKSPACE_PROPERTIES_ASSIGNMENT, {
                 url: 'properties_assignment',
@@ -337,18 +364,6 @@ ng1appModule.config([
             }
         );
 
-        $stateProvider.state(
-            States.WORKSPACE_RESOURCE_INPUTS, {
-                url: 'resource_inputs',
-                parent: 'workspace',
-                controller: viewModelsModuleName + '.ResourceInputsViewModel',
-                templateUrl: './view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html',
-                data: {
-                    bodyClass: 'workspace-inputs'
-                }
-            }
-        );
-
         $stateProvider.state(
             States.WORKSPACE_ATTRIBUTES, {
                 url: 'attributes',
@@ -373,6 +388,18 @@ ng1appModule.config([
             }
         );
 
+        $stateProvider.state(
+            States.WORKSPACE_REQUIREMENTS_AND_CAPABILITIES_EDITABLE, {
+                url: 'req_and_capabilities_editable',
+                parent: 'workspace',
+                controller: viewModelsModuleName + '.ReqAndCapabilitiesViewModel',
+                templateUrl: './view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-editable-view.html',
+                data: {
+                    bodyClass: 'attributes'
+                }
+            }
+        );
+
 
         $stateProvider.state(
             States.WORKSPACE_MANAGEMENT_WORKFLOW, {
@@ -502,6 +529,44 @@ ng1appModule.config([
                 controller: viewModelsModuleName + '.ResourceArtifactsViewModel'
             }
         );
+        $stateProvider.state(
+            'workspace.composition.consumption', {
+                url: 'consumption',
+                parent: 'workspace.composition',
+                templateUrl: './view-models/workspace/tabs/composition/tabs/service-consumption/service-consumption-view.html',
+                controller: viewModelsModuleName + '.ServiceConsumptionViewModel'
+            }
+        );
+        $stateProvider.state(
+            'workspace.composition.dependencies', {
+                url: 'dependencies',
+                parent: 'workspace.composition',
+                templateUrl: './view-models/workspace/tabs/composition/tabs/service-dependencies/service-dependencies-view.html',
+                controller: viewModelsModuleName + '.ServiceDependenciesViewModel'
+            }
+        );
+
+        $stateProvider.state(
+            States.WORKSPACE_INTERFACE_OPERATION, {
+                url: 'interface_operation',
+                parent: 'workspace',
+                controller: viewModelsModuleName + '.InterfaceOperationViewModel',
+                templateUrl: './view-models/workspace/tabs/interface-operation/interface-operation-view.html',
+                data: {
+                    bodyClass: 'interface_operation'
+                }
+            }
+        );
+
+        $stateProvider.state(
+            'workspace.plugins', {
+                url: 'plugins/*path',
+                parent: 'workspace',
+                params: {'queryParams': null},
+                templateUrl: './view-models/workspace/tabs/plugins/plugins-context-view.html',
+                controller: viewModelsModuleName + '.PluginsContextViewModel'
+            }
+        );
 
         $stateProvider.state(
             'adminDashboard', {
@@ -520,6 +585,14 @@ ng1appModule.config([
             }
         );
 
+        $stateProvider.state(
+            'plugins', {
+                url: '/plugins/*path',
+                templateUrl: './view-models/plugins/plugins-tab-view.html',
+                controller: viewModelsModuleName + '.PluginsTabViewModel'
+            }
+        );
+
         // Build the states for all hosted apps dynamically
         _.each(hostedApplications, (hostedApp)=> {
             if (hostedApp.exists) {
@@ -535,12 +608,12 @@ ng1appModule.config([
 
         $stateProvider.state(
             'catalog', {
-                url: '/catalog',
+                url: '/catalog?filter.components&filter.resourceSubTypes&filter.categories&filter.statuses&filter.order&filter.term&filter.active',
                 templateUrl: './view-models/catalog/catalog-view.html',
                 controller: viewModelsModuleName + '.CatalogViewModel',
                 resolve: {
-                    auth: ["$q", "Sdc.Services.UserResourceService", ($q:any, userResourceService:IUserResourceClass) => {
-                        let userInfo:IUserResource = userResourceService.getLoggedinUser();
+                    auth: ["$q", "UserServiceNg2", ($q:any, userService:UserService) => {
+                        let userInfo:IUserProperties = userService.getLoggedinUser();
                         if (userInfo) {
                             return $q.when(userInfo);
                         } else {
@@ -582,9 +655,10 @@ ng1appModule.value('ValidationPattern', /^[\s\w\&_.:-]{1,1024}$/);
 ng1appModule.value('ComponentNameValidationPattern', /^(?=.*[^. ])[\s\w\&_.:-]{1,1024}$/); //DE250513 - same as ValidationPattern above, plus requirement that name not consist of dots and/or spaces alone.
 ng1appModule.value('PropertyNameValidationPattern', /^[a-zA-Z0-9_:-]{1,50}$/);// DE210977
 ng1appModule.value('TagValidationPattern', /^[\s\w_.-]{1,50}$/);
-ng1appModule.value('VendorValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,25}$/);
+ng1appModule.value('VendorReleaseValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,25}$/);
 ng1appModule.value('VendorNameValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,60}$/);
 ng1appModule.value('VendorModelNumberValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,65}$/);
+ng1appModule.value('ServiceTypeAndRoleValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,256}$/);
 ng1appModule.value('ContactIdValidationPattern', /^[\s\w-]{1,50}$/);
 ng1appModule.value('UserIdValidationPattern', /^[\s\w-]{1,50}$/);
 ng1appModule.value('ProjectCodeValidationPattern', /^[\s\w-]{5,50}$/);
@@ -607,7 +681,7 @@ ng1appModule.run([
     'Sdc.Services.CacheService',
     'Sdc.Services.CookieService',
     'Sdc.Services.ConfigurationUiService',
-    'Sdc.Services.UserResourceService',
+    'UserServiceNg2',
     'Sdc.Services.CategoryResourceService',
     'Sdc.Services.SdcVersionService',
     '$state',
@@ -619,11 +693,12 @@ ng1appModule.run([
     'LeftPaletteLoaderService',
     'Sdc.Services.DataTypesService',
     'AngularJSBridge',
+    '$templateCache',
     ($http:ng.IHttpService,
      cacheService:CacheService,
      cookieService:CookieService,
      ConfigurationUi:ConfigurationUiService,
-     UserResourceClass:IUserResourceClass,
+     userService:UserService,
      categoryResourceService:ICategoryResourceClass,
      sdcVersionService:SdcVersionService,
      $state:ng.ui.IStateService,
@@ -634,8 +709,10 @@ ng1appModule.run([
      ecompHeaderService:EcompHeaderService,
      LeftPaletteLoaderService:LeftPaletteLoaderService,
      DataTypesService:DataTypesService,
-     AngularJSBridge):void => {
-
+     AngularJSBridge,
+     $templateCache:ng.ITemplateCacheService):void => {
+        $templateCache.put('notification-custom-template.html', require('./view-models/shared/notification-custom-template.html'));
+        $templateCache.put('notification-custom-template.html', require('./view-models/shared/notification-custom-template.html'));
         //handle cache data - version
         let initAsdcVersion:Function = ():void => {
 
@@ -676,7 +753,6 @@ ng1appModule.run([
             categoryResourceService.getAllCategories((categories: Categories):void => {
                 cacheService.set('serviceCategories', categories.serviceCategories);
                 cacheService.set('resourceCategories', categories.resourceCategories);
-                cacheService.set('productCategories', categories.productCategories);
             }, onError);
         };
 
@@ -699,6 +775,10 @@ ng1appModule.run([
                 deregisterStateChangeStartWatcher();
                 deregisterStateChangeStartWatcher = null;
             }
+            if (deregisterStateChangeSuccessWatcher) {
+                deregisterStateChangeSuccessWatcher();
+                deregisterStateChangeSuccessWatcher = null;
+            }
         };
 
         let removeLoader:Function = ():void => {
@@ -727,51 +807,30 @@ ng1appModule.run([
         let onStateChangeStart:Function = (event, toState, toParams, fromState, fromParams):void => {
             console.info((new Date()).getTime());
             console.info('$stateChangeStart', toState.name);
-            //set body class
-            $rootScope['bodyClass'] = 'default-class';
-            if (toState.data && toState.data.bodyClass) {
-                $rootScope['bodyClass'] = toState.data.bodyClass;
-            }
 
-            // Workaround in case we are entering other state then workspace (user move to catalog)
-            // remove the changeComponentCsarVersion, user should open again the VSP list and select one for update.
-            if (toState.name.indexOf('workspace') === -1) {
-                if (cacheService.contains(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) {
-                    cacheService.remove(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
+            if (toState.name !== 'error-403' && !userService.getLoggedinUser()) {
+                if (toState.name !== 'welcome') {
+                    event.preventDefault();
                 }
-            }
 
-            //saving last state to params , for breadcrumbs
-            if (['dashboard', 'catalog', 'onboardVendor'].indexOf(fromState.name) > -1) {
-                toParams.previousState = fromState.name;
-            } else {
-                toParams.previousState = fromParams.previousState;
-            }
-
-            if (toState.name !== 'error-403' && !UserResourceClass.getLoggedinUser()) {
-                internalDeregisterStateChangeStartWatcher();
-                event.preventDefault();
-
-                UserResourceClass.authorize().$promise.then((user:IUserResource) => {
-                    if (!doesUserHasAccess(toState, user)) {
+                userService.authorize().subscribe((userInfo:IUserProperties) => {
+                    if (!doesUserHasAccess(toState, userInfo)) {
                         $state.go('error-403');
                         console.info('User has no permissions');
-                        registerStateChangeStartWatcher();
                         return;
                     }
-                    UserResourceClass.setLoggedinUser(user);
-                    cacheService.set('user', user);
+                    userService.setLoggedinUser(userInfo);
+                    cacheService.set('user', userInfo);
                     initCategories();
-                    //   initEcompMenu(user);
+                    //   initEcompMenu(userInfo);
                     setTimeout(function () {
 
                         removeLoader();
 
                         // initCategories();
-                        if (UserResourceClass.getLoggedinUser().role === 'ADMIN') {
+                        if (userService.getLoggedinUser().role === 'ADMIN') {
                             // toState.name = "adminDashboard";
                             $state.go("adminDashboard", toParams);
-                            registerStateChangeStartWatcher();
                             return;
                         }
 
@@ -782,8 +841,6 @@ ng1appModule.run([
                             }
 
                             console.log("------$state.current.name=" + $state.current.name);
-                            console.info('-----registerStateChangeStartWatcher authorize $stateChangeStart');
-                            registerStateChangeStartWatcher();
 
                         }, 1000);
 
@@ -791,14 +848,10 @@ ng1appModule.run([
 
                 }, () => {
                     $state.go('error-403');
-
-                    console.info('registerStateChangeStartWatcher error-403 $stateChangeStart');
-                    registerStateChangeStartWatcher();
                 });
             }
-            else if (UserResourceClass.getLoggedinUser()) {
-                internalDeregisterStateChangeStartWatcher();
-                if (!doesUserHasAccess(toState, UserResourceClass.getLoggedinUser())) {
+            else if (userService.getLoggedinUser()) {
+                if (!doesUserHasAccess(toState, userService.getLoggedinUser())) {
                     event.preventDefault();
                     $state.go('error-403');
                     console.info('User has no permissions');
@@ -806,7 +859,7 @@ ng1appModule.run([
                 if (toState.name === "welcome") {
                     $state.go("dashboard");
                 }
-                registerStateChangeStartWatcher();
+
                 //if form is dirty and not save  - notify to user
                 if (fromState.data && fromState.data.unsavedChanges && fromParams.id != toParams.id) {
                     event.preventDefault();
@@ -814,6 +867,36 @@ ng1appModule.run([
                 }
             }
 
+            // if enetering workspace, set the previousState param
+            if (toState.name.indexOf('workspace') !== -1) {
+                if (!toParams.previousState) {
+                    const tmpPreviousState1 = fromParams && fromParams.previousState;
+                    const tmpPreviousState2 = (['dashboard', 'catalog'].indexOf(fromState.name) !== -1) ? fromState.name : 'catalog';
+                    toParams.previousState = tmpPreviousState1 || tmpPreviousState2;
+                }
+            }
+
+        };
+
+        let onStateChangeSuccess:Function = (event, toState, toParams, fromState, fromParams):void => {
+            console.info('$stateChangeSuccess', toState.name);
+
+            // Workaround in case we are entering other state then workspace (user move to catalog)
+            // remove the changeComponentCsarVersion, user should open again the VSP list and select one for update.
+            if (toState.name.indexOf('workspace') === -1) {
+                if (cacheService.contains(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) {
+                    cacheService.remove(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
+                }
+                if (cacheService.contains(PREVIOUS_CSAR_COMPONENT)){
+                    cacheService.remove(PREVIOUS_CSAR_COMPONENT);
+                }
+            }
+
+            //set body class
+            $rootScope['bodyClass'] = 'default-class';
+            if (toState.data && toState.data.bodyClass) {
+                $rootScope['bodyClass'] = toState.data.bodyClass;
+            }
         };
 
         let doesUserHasAccess:Function = (toState, user):boolean => {
@@ -825,6 +908,7 @@ ng1appModule.run([
             return isUserHasAccess;
         };
         let deregisterStateChangeStartWatcher:Function;
+        let deregisterStateChangeSuccessWatcher:Function;
 
         let registerStateChangeStartWatcher:Function = ():void => {
             internalDeregisterStateChangeStartWatcher();
@@ -832,6 +916,9 @@ ng1appModule.run([
             deregisterStateChangeStartWatcher = $rootScope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams):void => {
                 onStateChangeStart(event, toState, toParams, fromState, fromParams);
             });
+            deregisterStateChangeSuccessWatcher = $rootScope.$on('$stateChangeSuccess', (event, toState, toParams, fromState, fromParams):void => {
+                onStateChangeSuccess(event, toState, toParams, fromState, fromParams);
+            });
         };
 
         registerStateChangeStartWatcher();