Skip to content

Commit 3d6de8a

Browse files
committed
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 <[email protected]>
1 parent f4bc03e commit 3d6de8a

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import { RgwMultisiteWizardComponent } from '../rgw-multisite-wizard/rgw-multisi
4343
import { RgwMultisiteSyncPolicyComponent } from '../rgw-multisite-sync-policy/rgw-multisite-sync-policy.component';
4444
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
4545
import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
46+
import { MgrModuleInfo } from '~/app/shared/models/mgr-modules.interface';
47+
import { RGW } from '../utils/constants';
4648

4749
const BASE_URL = 'rgw/multisite/configuration';
4850

@@ -307,20 +309,22 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
307309
);
308310

309311
// Only get the module status if you can read from configOpt
310-
if (this.permissions.configOpt.read) {
311-
this.mgrModuleService.list().subscribe((moduleData: any) => {
312-
this.rgwModuleData = moduleData.filter((module: object) => module['name'] === 'rgw');
313-
if (this.rgwModuleData.length > 0) {
314-
this.rgwModuleStatus = this.rgwModuleData[0].enabled;
315-
}
316-
});
317-
}
312+
if (this.permissions.configOpt.read) this.getRgwModuleStatus();
318313
}
319314

320315
ngOnDestroy() {
321316
this.sub.unsubscribe();
322317
}
323318

319+
private getRgwModuleStatus() {
320+
this.mgrModuleService.list().subscribe((moduleData: MgrModuleInfo[]) => {
321+
this.rgwModuleData = moduleData.filter((module: MgrModuleInfo) => module.name === RGW);
322+
if (this.rgwModuleData.length > 0) {
323+
this.rgwModuleStatus = this.rgwModuleData[0].enabled;
324+
}
325+
});
326+
}
327+
324328
private abstractTreeData(multisiteInfo: [object, object, object]): any[] {
325329
let allNodes: object[] = [];
326330
let rootNodes = {};
@@ -632,7 +636,7 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
632636
};
633637

634638
if (!this.rgwModuleStatus) {
635-
$obs = this.mgrModuleService.enable('rgw');
639+
$obs = this.mgrModuleService.enable(RGW);
636640
}
637641
$obs.subscribe(
638642
() => undefined,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const RGW = 'rgw';

src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Observable, timer as observableTimer } from 'rxjs';
66
import { NotificationService } from '../services/notification.service';
77
import { TableComponent } from '../datatable/table/table.component';
88
import { Router } from '@angular/router';
9+
import { MgrModuleInfo } from '../models/mgr-modules.interface';
910

1011
@Injectable({
1112
providedIn: 'root'
@@ -28,8 +29,8 @@ export class MgrModuleService {
2829
* Get the list of Ceph Mgr modules and their state (enabled/disabled).
2930
* @return {Observable<Object[]>}
3031
*/
31-
list(): Observable<Object[]> {
32-
return this.http.get<Object[]>(`${this.url}`);
32+
list(): Observable<MgrModuleInfo[]> {
33+
return this.http.get<MgrModuleInfo[]>(`${this.url}`);
3334
}
3435

3536
/**
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export interface MgrModuleInfo {
2+
name: string;
3+
enabled: boolean;
4+
always_on: boolean;
5+
options: Record<string, MgrModuleOption>;
6+
}
7+
8+
interface MgrModuleOption {
9+
name: string;
10+
type: string;
11+
level: string;
12+
flags: number;
13+
default_value: number;
14+
min: string;
15+
max: string;
16+
enum_allowed: string[];
17+
desc: string;
18+
long_desc: string;
19+
tags: string[];
20+
see_also: string[];
21+
}

0 commit comments

Comments
 (0)