@@ -27,6 +27,7 @@ import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
2727import { URLBuilderService } from '~/app/shared/services/url-builder.service' ;
2828import { PlacementPipe } from './placement.pipe' ;
2929import { ServiceFormComponent } from './service-form/service-form.component' ;
30+ import { SettingsService } from '~/app/shared/api/settings.service' ;
3031
3132const BASE_URL = 'services' ;
3233
@@ -41,6 +42,8 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
4142 table : TableComponent ;
4243 @ViewChild ( 'runningTpl' , { static : true } )
4344 public runningTpl : TemplateRef < any > ;
45+ @ViewChild ( 'urlTpl' , { static : true } )
46+ public urlTpl : TemplateRef < any > ;
4447
4548 @Input ( ) hostname : string ;
4649
@@ -71,6 +74,8 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
7174 isLoadingServices = false ;
7275 selection : CdTableSelection = new CdTableSelection ( ) ;
7376 icons = Icons ;
77+ serviceUrls = { grafana : '' , prometheus : '' , alertmanager : '' } ;
78+ isMgmtGateway : boolean = false ;
7479
7580 constructor (
7681 private actionLabels : ActionLabelsI18n ,
@@ -80,7 +85,8 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
8085 private cephServiceService : CephServiceService ,
8186 private relativeDatePipe : RelativeDatePipe ,
8287 private taskWrapperService : TaskWrapperService ,
83- private router : Router
88+ private router : Router ,
89+ private settingsService : SettingsService
8490 ) {
8591 super ( ) ;
8692 this . permissions = this . authStorageService . getPermissions ( ) ;
@@ -148,7 +154,8 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
148154 {
149155 name : $localize `Service` ,
150156 prop : 'service_name' ,
151- flexGrow : 1
157+ flexGrow : 1 ,
158+ cellTemplate : this . urlTpl
152159 } ,
153160 {
154161 name : $localize `Placement` ,
@@ -178,6 +185,12 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
178185 this . orchStatus = status ;
179186 this . showDocPanel = ! status . available ;
180187 } ) ;
188+
189+ if ( ! this . isMgmtGateway ) {
190+ this . configureServiceUrl ( 'api/grafana/url' , 'grafana' ) ;
191+ this . configureServiceUrl ( 'ui-api/prometheus/prometheus-api-host' , 'prometheus' ) ;
192+ this . configureServiceUrl ( 'ui-api/prometheus/alertmanager-api-host' , 'alertmanager' ) ;
193+ }
181194 }
182195
183196 ngOnChanges ( ) {
@@ -219,6 +232,9 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
219232 this . services = services ;
220233 this . count = pagination_obs . count ;
221234 this . services = this . services . filter ( ( col : any ) => {
235+ if ( col . service_type === 'mgmt-gateway' && col . status . running ) {
236+ this . isMgmtGateway = true ;
237+ }
222238 return ! this . hiddenServices . includes ( col . service_name ) ;
223239 } ) ;
224240 this . isLoadingServices = false ;
@@ -229,6 +245,15 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
229245 context . error ( ) ;
230246 }
231247 ) ;
248+ if (
249+ this . isMgmtGateway &&
250+ ! this . services . find (
251+ ( service : CephServiceSpec ) =>
252+ service . service_type !== 'mgmt-gateway' && service . status . running > 0
253+ )
254+ ) {
255+ this . isMgmtGateway = false ;
256+ }
232257 }
233258
234259 updateSelection ( selection : CdTableSelection ) {
@@ -258,4 +283,10 @@ export class ServicesComponent extends ListWithDetails implements OnChanges, OnI
258283 )
259284 } ) ;
260285 }
286+
287+ private configureServiceUrl ( url : string , serviceType : string ) {
288+ this . settingsService . ifSettingConfigured ( url , ( url ) => {
289+ this . serviceUrls [ serviceType ] = url ;
290+ } ) ;
291+ }
261292}
0 commit comments