import { Constants } from '../Common/Constants' ; import { ActivatedRouteSnapshot } from '@angular/router' ; export class IdUtils { public static getParam ( route , key ) { if ( route != null ) { const param = route . params [ key ] ; if ( param === undefined ) { return IdUtils . getParam ( route . parent , key ) ; } else { return param ; } } else { return undefined ; } } public static getAppId ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'appId' ) ) ; } public static getPartitionId ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'partitionId' ) ) ; } public static getReplicaId ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'replicaId' ) ) ; } public static getServiceId ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'serviceId' ) ) ; } public static getServicePackageActivationId ( route ) { const id = IdUtils . getParam ( route , 'activationId' ) ; return id ? decodeURIComponent ( id ) : '' ; } public static getAppTypeName ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'appTypeName' ) ) ; } public static getCodePackageName ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'codePackageName' ) ) ; } public static getContainerLogs ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'codePackageName' ) ) ; } public static getNodeName ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'nodeName' ) ) ; } public static getBackupPolicyName ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'backupPolicyName' ) ) ; } public static getNetworkName ( route ) { return decodeURIComponent ( IdUtils . getParam ( route , 'networkName' ) ) ; } public static idToName ( id ) { return Constants . FabricPrefix + id ; } public static nameToId ( name ) { if ( name . startsWith ( Constants . FabricPrefix ) ) { return name . substr ( Constants . FabricPrefix . length ) ; } return name ; } }