From 3d6de8a669887c57711f176b3a75f2f2a635a23e Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Fri, 14 Mar 2025 12:40:45 +0530 Subject: [PATCH] mgr/dashboard: add types for mgr-module list also introducing a const for rgw Fixes: https://tracker.ceph.com/issues/70331 Signed-off-by: Nizamudeen A --- .../rgw-multisite-details.component.ts | 22 +++++++++++-------- .../src/app/ceph/rgw/utils/constants.ts | 1 + .../src/app/shared/api/mgr-module.service.ts | 5 +++-- .../shared/models/mgr-modules.interface.ts | 21 ++++++++++++++++++ 4 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/utils/constants.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/models/mgr-modules.interface.ts diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts index fa1af615b27bf..ed21e126507f3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts @@ -43,6 +43,8 @@ import { RgwMultisiteWizardComponent } from '../rgw-multisite-wizard/rgw-multisi import { RgwMultisiteSyncPolicyComponent } from '../rgw-multisite-sync-policy/rgw-multisite-sync-policy.component'; import { ModalCdsService } from '~/app/shared/services/modal-cds.service'; import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service'; +import { MgrModuleInfo } from '~/app/shared/models/mgr-modules.interface'; +import { RGW } from '../utils/constants'; const BASE_URL = 'rgw/multisite/configuration'; @@ -307,20 +309,22 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit { ); // Only get the module status if you can read from configOpt - if (this.permissions.configOpt.read) { - this.mgrModuleService.list().subscribe((moduleData: any) => { - this.rgwModuleData = moduleData.filter((module: object) => module['name'] === 'rgw'); - if (this.rgwModuleData.length > 0) { - this.rgwModuleStatus = this.rgwModuleData[0].enabled; - } - }); - } + if (this.permissions.configOpt.read) this.getRgwModuleStatus(); } ngOnDestroy() { this.sub.unsubscribe(); } + private getRgwModuleStatus() { + this.mgrModuleService.list().subscribe((moduleData: MgrModuleInfo[]) => { + this.rgwModuleData = moduleData.filter((module: MgrModuleInfo) => module.name === RGW); + if (this.rgwModuleData.length > 0) { + this.rgwModuleStatus = this.rgwModuleData[0].enabled; + } + }); + } + private abstractTreeData(multisiteInfo: [object, object, object]): any[] { let allNodes: object[] = []; let rootNodes = {}; @@ -632,7 +636,7 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit { }; if (!this.rgwModuleStatus) { - $obs = this.mgrModuleService.enable('rgw'); + $obs = this.mgrModuleService.enable(RGW); } $obs.subscribe( () => undefined, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/utils/constants.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/utils/constants.ts new file mode 100644 index 0000000000000..a369498cf70ba --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/utils/constants.ts @@ -0,0 +1 @@ +export const RGW = 'rgw'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts index 6859ca7188435..c0532f5dc6706 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts @@ -6,6 +6,7 @@ import { Observable, timer as observableTimer } from 'rxjs'; import { NotificationService } from '../services/notification.service'; import { TableComponent } from '../datatable/table/table.component'; import { Router } from '@angular/router'; +import { MgrModuleInfo } from '../models/mgr-modules.interface'; @Injectable({ providedIn: 'root' @@ -28,8 +29,8 @@ export class MgrModuleService { * Get the list of Ceph Mgr modules and their state (enabled/disabled). * @return {Observable} */ - list(): Observable { - return this.http.get(`${this.url}`); + list(): Observable { + return this.http.get(`${this.url}`); } /** diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/mgr-modules.interface.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/mgr-modules.interface.ts new file mode 100644 index 0000000000000..72669bf9b00b7 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/mgr-modules.interface.ts @@ -0,0 +1,21 @@ +export interface MgrModuleInfo { + name: string; + enabled: boolean; + always_on: boolean; + options: Record; +} + +interface MgrModuleOption { + name: string; + type: string; + level: string; + flags: number; + default_value: number; + min: string; + max: string; + enum_allowed: string[]; + desc: string; + long_desc: string; + tags: string[]; + see_also: string[]; +} -- 2.39.5