Skip to content

Commit 4266e41

Browse files
authored
Merge pull request ceph#57775 from rhcs-dashboard/add-urls
mgr/dashboard: adds links to the services Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: Nizamudeen A <[email protected]>
2 parents be1db6e + 6f71e47 commit 4266e41

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/services.component.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,24 @@
3737
[ngClass]="[icons.warning]">
3838
</i>
3939
</ng-template>
40+
41+
<ng-template #urlTpl
42+
let-row="row">
43+
<ng-container *ngIf="serviceUrls[row.service_type] else noUrl">
44+
<a *ngIf="!isMgmtGateway else mgmtGateway"
45+
target="_blank"
46+
[href]="serviceUrls[row.service_type]">
47+
{{ row.service_name }}
48+
<i class="fa fa-external-link"></i>
49+
</a>
50+
51+
<ng-template #mgmtGateway>
52+
<a target="_blank"
53+
[href]="row.service_type">
54+
{{ row.service_name }}
55+
<i class="fa fa-external-link"></i>
56+
</a>
57+
</ng-template>
58+
</ng-container>
59+
<ng-template #noUrl>{{row.service_name}}</ng-template>
60+
</ng-template>

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/services.component.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
2727
import { URLBuilderService } from '~/app/shared/services/url-builder.service';
2828
import { PlacementPipe } from './placement.pipe';
2929
import { ServiceFormComponent } from './service-form/service-form.component';
30+
import { SettingsService } from '~/app/shared/api/settings.service';
3031

3132
const 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

Comments
 (0)