]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: add types for mgr-module list
authorNizamudeen A <nia@redhat.com>
Fri, 14 Mar 2025 07:10:45 +0000 (12:40 +0530)
committerNizamudeen A <nia@redhat.com>
Wed, 19 Mar 2025 14:23:35 +0000 (19:53 +0530)
also introducing a const for rgw

Fixes: https://tracker.ceph.com/issues/70331
Signed-off-by: Nizamudeen A <nia@redhat.com>
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 fa1af615b27bf11bfc2365d099c53d6ccc3916f8..ed21e126507f3c600bacc4aecf82970d289bae8c 100644 (file)
@@ -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 (file)
index 0000000..a369498
--- /dev/null
@@ -0,0 +1 @@
+export const RGW = 'rgw';
index 6859ca7188435164c862fb61d7f59750f80da5ff..c0532f5dc6706324c0a0a6a2ec2e6a1593128201 100644 (file)
@@ -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<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[];
+}