From: Pedro Gonzalez Gomez Date: Wed, 24 Apr 2024 08:48:11 +0000 (+0200) Subject: mgr/dashboard: fix readonly landingpage X-Git-Tag: v20.0.0~1857^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7abae5c982ee1fd7de74653bdd5ad46dbc4ae388;p=ceph.git mgr/dashboard: fix readonly landingpage Fixes: https://tracker.ceph.com/issues/65643 Signed-off-by: Pedro Gonzalez Gomez --- diff --git a/src/pybind/mgr/dashboard/controllers/health.py b/src/pybind/mgr/dashboard/controllers/health.py index 633d37a327eaf..3edc386b01232 100644 --- a/src/pybind/mgr/dashboard/controllers/health.py +++ b/src/pybind/mgr/dashboard/controllers/health.py @@ -300,3 +300,7 @@ class Health(BaseController): @Endpoint() def get_cluster_fsid(self): return mgr.get('config')['fsid'] + + @Endpoint() + def get_telemetry_status(self): + return mgr.get_module_option_ex('telemetry', 'enabled', False) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts index 9b3c050064f95..c0ec766ab8b98 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts @@ -100,17 +100,20 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit ngOnInit() { super.ngOnInit(); - this.isHardwareEnabled$ = this.getHardwareConfig(); - this.hardwareSummary$ = this.hardwareSubject.pipe( - switchMap(() => - this.hardwareService.getSummary().pipe( - switchMap((data: any) => { - this.hasHardwareError = data.host.flawed; - return of(data); - }) + if (this.permissions.configOpt.read) { + this.isHardwareEnabled$ = this.getHardwareConfig(); + this.hardwareSummary$ = this.hardwareSubject.pipe( + switchMap(() => + this.hardwareService.getSummary().pipe( + switchMap((data: any) => { + this.hasHardwareError = data.host.flawed; + return of(data); + }) + ) ) - ) - ); + ); + this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS'); + } this.interval = this.refreshIntervalService.intervalData$.subscribe(() => { this.getHealth(); this.getCapacityCardData(); @@ -119,7 +122,6 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit this.getPrometheusData(this.prometheusService.lastHourDateObject); this.getDetailsCardData(); this.getTelemetryReport(); - this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS'); this.prometheusAlertService.getAlerts(true); } @@ -180,8 +182,8 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit } private getTelemetryReport() { - this.mgrModuleService.getConfig('telemetry').subscribe((resp: any) => { - this.telemetryEnabled = resp?.enabled; + this.healthService.getTelemetryStatus().subscribe((enabled: boolean) => { + this.telemetryEnabled = enabled; }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.ts index 8ddbddf2fe814..054ebf8bba112 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.ts @@ -3,6 +3,8 @@ import { Router } from '@angular/router'; import { Subscription } from 'rxjs'; import { MultiClusterService } from '~/app/shared/api/multi-cluster.service'; +import { Permissions } from '~/app/shared/models/permissions'; +import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; import { FaviconService } from '~/app/shared/services/favicon.service'; import { SummaryService } from '~/app/shared/services/summary.service'; @@ -16,18 +18,24 @@ import { TaskManagerService } from '~/app/shared/services/task-manager.service'; }) export class WorkbenchLayoutComponent implements OnInit, OnDestroy { private subs = new Subscription(); + permissions: Permissions; constructor( public router: Router, private summaryService: SummaryService, private taskManagerService: TaskManagerService, private multiClusterService: MultiClusterService, - private faviconService: FaviconService - ) {} + private faviconService: FaviconService, + private authStorageService: AuthStorageService + ) { + this.permissions = this.authStorageService.getPermissions(); + } ngOnInit() { - this.subs.add(this.multiClusterService.startPolling()); - this.subs.add(this.multiClusterService.startClusterTokenStatusPolling()); + if (this.permissions.configOpt.read) { + this.subs.add(this.multiClusterService.startPolling()); + this.subs.add(this.multiClusterService.startClusterTokenStatusPolling()); + } this.subs.add(this.summaryService.startPolling()); this.subs.add(this.taskManagerService.init(this.summaryService)); this.faviconService.init(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/health.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/health.service.ts index 42634a1481cf2..b04a27b644d50 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/health.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/health.service.ts @@ -26,4 +26,8 @@ export class HealthService { getOrchestratorName() { return this.http.get('api/health/get_orchestrator_name'); } + + getTelemetryStatus() { + return this.http.get('api/health/get_telemetry_status'); + } } diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 1c004bd8b3c70..4954e8552b492 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -4916,6 +4916,28 @@ paths: - jwt: [] tags: - Health + /api/health/get_telemetry_status: + get: + parameters: [] + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: OK + '400': + description: Operation exception. Please check the response body for details. + '401': + description: Unauthenticated access. Please login first. + '403': + description: Unauthorized access. Please check your permissions. + '500': + description: Unexpected error. Please check the response body for the stack + trace. + security: + - jwt: [] + tags: + - Health /api/health/minimal: get: parameters: []