module Sfx { export interface IServiceViewScope extends angular . IScope { service : Service ; serviceManifest : string ; listSettings : ListSettings ; healthEventsListSettings : ListSettings ; unhealthyEvaluationsListSettings : ListSettings ; serviceEvents : ServiceEventList ; serviceBackupConfigurationInfoListSettings : ListSettings ; } export class ServiceViewController extends MainViewController { public appTypeName : string ; public appId : string ; public serviceId : string ; constructor ( $injector , public $scope ) { super ( $injector , { "essentials" : { name : "Essentials" } , "details" : { name : "Details" } , "manifest" : { name : "Manifest" } , "events" : { name : "Events" } } ) ; this . tabs [ "essentials" ] . refresh = ( messageHandler ) => this . refreshEssentials ( messageHandler ) ; this . tabs [ "manifest" ] . refresh = ( messageHandler ) => this . refreshManifest ( messageHandler ) ; this . tabs [ "events" ] . refresh = ( messageHandler ) => this . refreshEvents ( messageHandler ) ; let routeParams = this . routeParams ; this . appTypeName = IdUtils . getAppTypeName ( routeParams ) ; this . appId = IdUtils . getAppId ( routeParams ) ; this . serviceId = IdUtils . getServiceId ( routeParams ) ; if ( this . appTypeName === Constants . SystemAppTypeName ) { delete ( this . tabs [ "manifest" ] ) ; this . selectTreeNode ( [ IdGenerator . cluster ( ) , IdGenerator . systemAppGroup ( ) , IdGenerator . service ( this . serviceId ) ] ) ; } else { this . selectTreeNode ( [ IdGenerator . cluster ( ) , IdGenerator . appGroup ( ) , IdGenerator . appType ( this . appTypeName ) , IdGenerator . app ( this . appId ) , IdGenerator . service ( this . serviceId ) ] ) ; } this . $scope . listSettings = this . settings . getNewOrExistingListSettings ( "partitions" , [ "id" ] , [ new ListColumnSettingForLink ( "id" , "Id" , item => item . viewPath ) , new ListColumnSettingWithFilter ( "partitionInformation.raw.ServicePartitionKind" , "Partition Kind" ) , new ListColumnSettingForBadge ( "healthState" , "Health State" ) , new ListColumnSettingWithFilter ( "raw.PartitionStatus" , "Status" ) , ] ) ; this . $scope . serviceBackupConfigurationInfoListSettings = this . settings . getNewOrExistingListSettings ( "serviceBackupConfigurationInfoListSettings" , [ "raw.PolicyName" ] , [ new ListColumnSetting ( "raw.PolicyName" , "Policy Name" , [ "raw.PolicyName" ] , false , ( item , property ) => `<a href='${ item . parent . viewPath }/tab/details'>${ property }</a>` , 1 , item => item . action . runWithCallbacks . apply ( item . action ) ) , new ListColumnSetting ( "raw.Kind" , "Kind" ) , new ListColumnSetting ( "raw.PolicyInheritedFrom" , "Policy Inherited From" ) , new ListColumnSetting ( "raw.PartitionId" , "Partition Id" ) , new ListColumnSetting ( "raw.SuspensionInfo.IsSuspended" , "Is Suspended" ) , new ListColumnSetting ( "raw.SuspensionInfo.SuspensionInheritedFrom" , "Suspension Inherited From" ) , ] ) ; this . $scope . healthEventsListSettings = this . settings . getNewOrExistingHealthEventsListSettings ( ) ; this . $scope . unhealthyEvaluationsListSettings = this . settings . getNewOrExistingUnhealthyEvaluationsListSettings ( ) ; this . $scope . serviceEvents = this . data . createServiceEventList ( this . serviceId ) ; this . refresh ( ) ; } protected refreshCommon ( messageHandler ? ) { return this . data . getService ( this . appId , this . serviceId , true , messageHandler ) . then ( service => { this . $scope . service = service ; this . data . clusterManifest . ensureInitialized ( ) . then ( ( ) => { if ( this . data . clusterManifest . isBRSEnabled ) { this . data . backupPolicies . refresh ( messageHandler ) ; if ( this . $scope . service . isStatefulService ) { this . $scope . service . serviceBackupConfigurationInfoCollection . refresh ( messageHandler ) ; } } } ) ; return this . $q . all ( [ this . $scope . service . health . refresh ( messageHandler ) , this . $scope . service . description . refresh ( messageHandler ) ] ) ; } ) ; } private refreshEssentials ( messageHandler ? ) { return this . $scope . service . partitions . refresh ( messageHandler ) ; } private refreshManifest ( messageHandler ? ) { let app = this . $scope . service . parent ; return this . data . getServiceType ( app . raw . TypeName , app . raw . TypeVersion , this . $scope . service . description . raw . ServiceTypeName , true , messageHandler ) . then ( serviceType => { return serviceType . manifest . refresh ( messageHandler ) . then ( ( ) => { this . $scope . serviceManifest = serviceType . manifest . raw . Manifest ; } ) ; } ) ; } private refreshEvents ( messageHandler ? ) { return this . $scope . serviceEvents . refresh ( new EventsStoreResponseMessageHandler ( messageHandler ) ) ; } } ( function ( ) { let module = angular . module ( "serviceViewController" , [ ] ) ; module . controller ( "ServiceViewController" , [ "$injector" , "$scope" , ServiceViewController ] ) ; } ) ( ) ; }