From d94b391a44b21528855d63cbd4290f6596907a7c 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 (cherry picked from commit 3d6de8a669887c57711f176b3a75f2f2a635a23e) Conflicts: src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts - kept only the import that is relavant src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts - same as above --- .../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 b05112863a8a..fde984865392 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 @@ -38,6 +38,8 @@ import { MgrModuleService } from '~/app/shared/api/mgr-module.service'; import { BlockUI, NgBlockUI } from 'ng-block-ui'; import { Router } from '@angular/router'; import { RgwMultisiteSyncPolicyComponent } from '../rgw-multisite-sync-policy/rgw-multisite-sync-policy.component'; +import { MgrModuleInfo } from '~/app/shared/models/mgr-modules.interface'; +import { RGW } from '../utils/constants'; @Component({ selector: 'cd-rgw-multisite-details', @@ -265,20 +267,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 = {}; @@ -572,7 +576,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 000000000000..a369498cf70b --- /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 3942a1a44780..8aaffed257a9 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 @@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; +import { MgrModuleInfo } from '../models/mgr-modules.interface'; @Injectable({ providedIn: 'root' @@ -15,8 +16,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 000000000000..72669bf9b00b --- /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.47.3