]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add types for mgr-module list 62454/head
authorNizamudeen A <nia@redhat.com>
Fri, 14 Mar 2025 07:10:45 +0000 (12:40 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 3 Mar 2026 10:12:18 +0000 (15:42 +0530)
also introducing a const for rgw

Fixes: https://tracker.ceph.com/issues/70331
Signed-off-by: Nizamudeen A <nia@redhat.com>
(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

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/utils/constants.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/models/mgr-modules.interface.ts [new file with mode: 0644]

index b05112863a8ae3abce44f6fc5a40e55fbccc9112..fde984865392f2148a0a0c5d8a9c12612bad776f 100644 (file)
@@ -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 (file)
index 0000000..a369498
--- /dev/null
@@ -0,0 +1 @@
+export const RGW = 'rgw';
index 3942a1a44780e59f9e002e8ff9f17d04d1978822..8aaffed257a9ab4523b2e597fb69c4ba4b37f1d8 100644 (file)
@@ -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<Object[]>}
    */
-  list(): Observable<Object[]> {
-    return this.http.get<Object[]>(`${this.url}`);
+  list(): Observable<MgrModuleInfo[]> {
+    return this.http.get<MgrModuleInfo[]>(`${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 (file)
index 0000000..72669bf
--- /dev/null
@@ -0,0 +1,21 @@
+export interface MgrModuleInfo {
+  name: string;
+  enabled: boolean;
+  always_on: boolean;
+  options: Record<string, MgrModuleOption>;
+}
+
+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[];
+}