module Sfx { export class RoutesService { private _forceSingleEncode : boolean = false ; constructor ( private $interval , private $location ) { } public navigate ( pathGetter ) { let path ; try { this . forceSingleEncode ( true ) ; path = pathGetter ( ) ; } finally { this . forceSingleEncode ( false ) ; } this . $interval ( ( ) => { this . $location . path ( path . substring ( 1 ) ) ; } , 0 , 1 ) ; } public getTabViewPath ( baseViewPath , tabId ) { return _ . trimEnd ( baseViewPath , "/" ) + "/tab/" + tabId ; } public getClusterViewPath ( ) { return "#/" ; } public getNodesViewPath ( ) { return "#/nodes" ; } public getSystemAppsViewPath ( ) { return "#/system/apps" ; } public getAppsViewPath ( ) { return "#/apps" ; } public getAppTypesViewPath ( ) { return "#/appTypes" ; } public getNodeViewPath ( nodeName ) { return "#/node/" + this . doubleEncode ( nodeName ) ; } public getNetworksViewPath ( ) { return "#/networks" ; } public getNetworkViewPath ( networkName ) { return "#/network/" + this . doubleEncode ( networkName ) ; } public getDeployedAppViewPath ( nodeName , appId ) { return "#/node/" + this . doubleEncode ( nodeName ) + "/deployedapp/" + this . doubleEncode ( appId ) ; } public getDeployedServiceViewPath ( nodeName , appId , serviceId , activationId ) { return "#/node/" + this . doubleEncode ( nodeName ) + "/deployedapp/" + this . doubleEncode ( appId ) + "/deployedservice/" + this . doubleEncode ( serviceId ) + ( activationId ? "/activationid/" + this . doubleEncode ( activationId ) : "" ) ; } public getDeployedReplicasViewPath ( nodeName , appId , serviceId , activationId ) { return "#/node/" + this . doubleEncode ( nodeName ) + "/deployedapp/" + this . doubleEncode ( appId ) + "/deployedservice/" + this . doubleEncode ( serviceId ) + ( activationId ? "/activationid/" + this . doubleEncode ( activationId ) : "" ) + "/replicas/" ; } public getDeployedCodePackagesViewPath ( nodeName , appId , serviceId , activationId ) { return "#/node/" + this . doubleEncode ( nodeName ) + "/deployedapp/" + this . doubleEncode ( appId ) + "/deployedservice/" + this . doubleEncode ( serviceId ) + ( activationId ? "/activationid/" + this . doubleEncode ( activationId ) : "" ) + "/codepackages/" ; } public getDeployedReplicaViewPath ( nodeName , appId , serviceId , activationId , partitionId , replicaId ) { return "#/node/" + this . doubleEncode ( nodeName ) + "/deployedapp/" + this . doubleEncode ( appId ) + "/deployedservice/" + this . doubleEncode ( serviceId ) + ( activationId ? "/activationid/" + this . doubleEncode ( activationId ) : "" ) + "/partition/" + this . doubleEncode ( partitionId ) + "/replica/" + this . doubleEncode ( replicaId ) ; } public getCodePackageViewPath ( nodeName , appId , serviceId , activationId , codePackageName ) { return "#/node/" + this . doubleEncode ( nodeName ) + "/deployedapp/" + this . doubleEncode ( appId ) + "/deployedservice/" + this . doubleEncode ( serviceId ) + ( activationId ? "/activationid/" + this . doubleEncode ( activationId ) : "" ) + "/codepackage/" + this . doubleEncode ( codePackageName ) ; } public getAppTypeViewPath ( appTypeName ) { return "#/apptype/" + this . doubleEncode ( appTypeName ) ; } public getAppViewPath ( appTypeName , appId ) { return "#/apptype/" + this . doubleEncode ( appTypeName ) + "/app/" + this . doubleEncode ( appId ) ; } public getServiceViewPath ( appTypeName , appId , serviceId ) { return "#/apptype/" + this . doubleEncode ( appTypeName ) + "/app/" + this . doubleEncode ( appId ) + "/service/" + this . doubleEncode ( serviceId ) ; } public getPartitionViewPath ( appTypeName , appId , serviceId , partitionId ) { return "#/apptype/" + this . doubleEncode ( appTypeName ) + "/app/" + this . doubleEncode ( appId ) + "/service/" + this . doubleEncode ( serviceId ) + "/partition/" + this . doubleEncode ( partitionId ) ; } public getReplicaViewPath ( appTypeName , appId , serviceId , partitionId , replicaId ) { return "#/apptype/" + this . doubleEncode ( appTypeName ) + "/app/" + this . doubleEncode ( appId ) + "/service/" + this . doubleEncode ( serviceId ) + "/partition/" + this . doubleEncode ( partitionId ) + "/replica/" + this . doubleEncode ( replicaId ) ; } public doubleEncode ( str ) { return this . _forceSingleEncode ? encodeURIComponent ( str ) : encodeURIComponent ( encodeURIComponent ( str ) ) ; } private forceSingleEncode ( force ) { this . _forceSingleEncode = force ; } } ( function ( ) { param $routeProvider param paths param route function whenWithTabs ( $routeProvider , paths , route ) { route . reloadOnSearch = false ; route . requireADLogin = true ; if ( ! _ . isArray ( paths ) ) { paths = [ paths ] ; } _ . each ( paths , ( path ) => { $routeProvider . when ( path , route ) . when ( _ . trimEnd ( path , "/" ) + "/tab/:tabId" , route ) ; } ) ; } ; let module = angular . module ( "routes" , [ "ngRoute" ] ) ; module . factory ( "routes" , [ "$interval" , "$location" , ( $interval , $location ) => new RoutesService ( $interval , $location ) ] ) ; module . config ( [ "$routeProvider" , "$httpProvider" , function ( $routeProvider , $httpProvider ) { whenWithTabs ( $routeProvider , "/" , { templateUrl : "partials/cluster.html" , controller : "ClusterViewController" , controllerAs : "clusterCtrl" } ) ; whenWithTabs ( $routeProvider , "/apps" , { templateUrl : "partials/apps.html" , controller : "AppsViewController" , controllerAs : "appsCtrl" } ) ; whenWithTabs ( $routeProvider , "/system/apps" , { templateUrl : "partials/system-apps.html" , controller : "SystemAppsViewController" , controllerAs : "systemAppsCtrl" } ) ; whenWithTabs ( $routeProvider , "/nodes" , { templateUrl : "partials/nodes.html" , controller : "NodesViewController" , controllerAs : "nodesCtrl" } ) ; whenWithTabs ( $routeProvider , "/node/:nodeName" , { templateUrl : "partials/node.html" , controller : "NodeViewController" , controllerAs : "nodeCtrl" } ) ; whenWithTabs ( $routeProvider , "/node/:nodeName/deployedapp/:appId" , { templateUrl : "partials/deployed-app.html" , controller : "DeployedAppViewController" , controllerAs : "deployedAppCtrl" } ) ; whenWithTabs ( $routeProvider , "/networks" , { templateUrl : "partials/networks.html" , controller : "NetworksViewController" , controllerAs : "networksCtrl" } ) ; whenWithTabs ( $routeProvider , "/network/:networkName" , { templateUrl : "partials/network.html" , controller : "NetworkViewController" , controllerAs : "networkCtrl" } ) ; whenWithTabs ( $routeProvider , [ "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId" , "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/activationid/:activationId" ] , { templateUrl : "partials/deployed-service-package.html" , controller : "DeployedServiceViewController" , controllerAs : "deployedServicePackageCtrl" } ) ; whenWithTabs ( $routeProvider , [ "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/codepackages" , "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/activationid/:activationId/codepackages" ] , { templateUrl : "partials/deployed-code-packages.html" , controller : "DeployedServiceCodePackagesViewController" , controllerAs : "deployedCodePackagesCtrl" } ) ; whenWithTabs ( $routeProvider , [ "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/replicas" , "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/activationid/:activationId/replicas" ] , { templateUrl : "partials/deployed-replicas.html" , controller : "DeployedServiceReplicasViewController" , controllerAs : "deployedReplicasCtrl" } ) ; whenWithTabs ( $routeProvider , [ "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/partition/:partitionId/replica/:replicaId" , "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/activationid/:activationId/partition/:partitionId/replica/:replicaId" ] , { templateUrl : "partials/deployed-replica.html" , controller : "DeployedReplicaViewController" , controllerAs : "deployedReplicaCtrl" } ) ; whenWithTabs ( $routeProvider , [ "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/codepackage/:codePackageName" , "/node/:nodeName/deployedapp/:appId/deployedservice/:serviceId/activationid/:activationId/codepackage/:codePackageName" ] , { templateUrl : "partials/deployed-code-package.html" , controller : "DeployedCodePackageViewController" , controllerAs : "codePackageCtrl" } ) ; whenWithTabs ( $routeProvider , "/apptype/:appTypeName" , { templateUrl : "partials/app-type.html" , controller : "AppTypeViewController" , controllerAs : "appTypeCtrl" } ) ; whenWithTabs ( $routeProvider , "/apptype/:appTypeName/app/:appId" , { templateUrl : "partials/app.html" , controller : "AppViewController" , controllerAs : "appCtrl" } ) ; whenWithTabs ( $routeProvider , "/apptype/:appTypeName/app/:appId/service/:serviceId" , { templateUrl : "partials/service.html" , controller : "ServiceViewController" , controllerAs : "serviceCtrl" } ) ; whenWithTabs ( $routeProvider , "/apptype/:appTypeName/app/:appId/service/:serviceId/partition/:partitionId" , { templateUrl : "partials/partition.html" , controller : "PartitionViewController" , controllerAs : "partitionCtrl" } ) ; whenWithTabs ( $routeProvider , "/apptype/:appTypeName/app/:appId/service/:serviceId/partition/:partitionId/replica/:replicaId" , { templateUrl : "partials/replica.html" , controller : "ReplicaViewController" , controllerAs : "replicaCtrl" } ) ; $routeProvider . otherwise ( { templateUrl : "partials/cluster.html" , controller : "ClusterViewController" , controllerAs : "clusterCtrl" } ) ; } ] ) ; } ) ( ) ; }