Skip to content

Commit 3a9fd84

Browse files
authored
Merge pull request ceph#57070 from rhcs-dashboard/fix-read-only-landing-page
mgr/dashboard: fix readonly landingpage Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: ivoalmeida <NOT@FOUND> Reviewed-by: Nizamudeen A <[email protected]>
2 parents 607f687 + 7abae5c commit 3a9fd84

File tree

5 files changed

+57
-17
lines changed

5 files changed

+57
-17
lines changed

src/pybind/mgr/dashboard/controllers/health.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,7 @@ def get_cluster_capacity(self):
300300
@Endpoint()
301301
def get_cluster_fsid(self):
302302
return mgr.get('config')['fsid']
303+
304+
@Endpoint()
305+
def get_telemetry_status(self):
306+
return mgr.get_module_option_ex('telemetry', 'enabled', False)

src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,20 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
101101

102102
ngOnInit() {
103103
super.ngOnInit();
104-
this.isHardwareEnabled$ = this.getHardwareConfig();
105-
this.hardwareSummary$ = this.hardwareSubject.pipe(
106-
switchMap(() =>
107-
this.hardwareService.getSummary().pipe(
108-
switchMap((data: any) => {
109-
this.hasHardwareError = data.host.flawed;
110-
return of(data);
111-
})
104+
if (this.permissions.configOpt.read) {
105+
this.isHardwareEnabled$ = this.getHardwareConfig();
106+
this.hardwareSummary$ = this.hardwareSubject.pipe(
107+
switchMap(() =>
108+
this.hardwareService.getSummary().pipe(
109+
switchMap((data: any) => {
110+
this.hasHardwareError = data.host.flawed;
111+
return of(data);
112+
})
113+
)
112114
)
113-
)
114-
);
115+
);
116+
this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS');
117+
}
115118
this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
116119
this.getHealth();
117120
this.getCapacityCardData();
@@ -120,7 +123,6 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
120123
this.getPrometheusData(this.prometheusService.lastHourDateObject);
121124
this.getDetailsCardData();
122125
this.getTelemetryReport();
123-
this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS');
124126
this.prometheusAlertService.getAlerts(true);
125127
}
126128

@@ -184,8 +186,8 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
184186
}
185187

186188
private getTelemetryReport() {
187-
this.mgrModuleService.getConfig('telemetry').subscribe((resp: any) => {
188-
this.telemetryEnabled = resp?.enabled;
189+
this.healthService.getTelemetryStatus().subscribe((enabled: boolean) => {
190+
this.telemetryEnabled = enabled;
189191
});
190192
}
191193

src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Router } from '@angular/router';
33

44
import { Subscription } from 'rxjs';
55
import { MultiClusterService } from '~/app/shared/api/multi-cluster.service';
6+
import { Permissions } from '~/app/shared/models/permissions';
7+
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
68

79
import { FaviconService } from '~/app/shared/services/favicon.service';
810
import { SummaryService } from '~/app/shared/services/summary.service';
@@ -16,18 +18,24 @@ import { TaskManagerService } from '~/app/shared/services/task-manager.service';
1618
})
1719
export class WorkbenchLayoutComponent implements OnInit, OnDestroy {
1820
private subs = new Subscription();
21+
permissions: Permissions;
1922

2023
constructor(
2124
public router: Router,
2225
private summaryService: SummaryService,
2326
private taskManagerService: TaskManagerService,
2427
private multiClusterService: MultiClusterService,
25-
private faviconService: FaviconService
26-
) {}
28+
private faviconService: FaviconService,
29+
private authStorageService: AuthStorageService
30+
) {
31+
this.permissions = this.authStorageService.getPermissions();
32+
}
2733

2834
ngOnInit() {
29-
this.subs.add(this.multiClusterService.startPolling());
30-
this.subs.add(this.multiClusterService.startClusterTokenStatusPolling());
35+
if (this.permissions.configOpt.read) {
36+
this.subs.add(this.multiClusterService.startPolling());
37+
this.subs.add(this.multiClusterService.startClusterTokenStatusPolling());
38+
}
3139
this.subs.add(this.summaryService.startPolling());
3240
this.subs.add(this.taskManagerService.init(this.summaryService));
3341
this.faviconService.init();

src/pybind/mgr/dashboard/frontend/src/app/shared/api/health.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ export class HealthService {
2626
getOrchestratorName() {
2727
return this.http.get('api/health/get_orchestrator_name');
2828
}
29+
30+
getTelemetryStatus() {
31+
return this.http.get('api/health/get_telemetry_status');
32+
}
2933
}

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4916,6 +4916,28 @@ paths:
49164916
- jwt: []
49174917
tags:
49184918
- Health
4919+
/api/health/get_telemetry_status:
4920+
get:
4921+
parameters: []
4922+
responses:
4923+
'200':
4924+
content:
4925+
application/vnd.ceph.api.v1.0+json:
4926+
type: object
4927+
description: OK
4928+
'400':
4929+
description: Operation exception. Please check the response body for details.
4930+
'401':
4931+
description: Unauthenticated access. Please login first.
4932+
'403':
4933+
description: Unauthorized access. Please check your permissions.
4934+
'500':
4935+
description: Unexpected error. Please check the response body for the stack
4936+
trace.
4937+
security:
4938+
- jwt: []
4939+
tags:
4940+
- Health
49194941
/api/health/minimal:
49204942
get:
49214943
parameters: []

0 commit comments

Comments
 (0)