Skip to content

Commit 926aedf

Browse files
author
Dnyaneshwari
committed
mgr/dashboard: list smb
Tracker: https://tracker.ceph.com/issues/69080 Signed-off-by: Dnyaneshwari Talwekar <[email protected]>
1 parent 4509ec2 commit 926aedf

File tree

14 files changed

+271
-5
lines changed

14 files changed

+271
-5
lines changed

src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/navigation.po.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export class NavigationPageHelper extends PageHelper {
4848
menu: 'File',
4949
submenus: [
5050
{ menu: 'File Systems', component: 'cd-cephfs-list' },
51-
{ menu: 'NFS', component: 'cd-error' }
51+
{ menu: 'NFS', component: 'cd-error' },
52+
{ menu: 'SMB', component: 'cd-smb-cluster-list' }
5253
]
5354
},
5455
{

src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { UpgradeProgressComponent } from './ceph/cluster/upgrade/upgrade-progres
5151
import { MultiClusterComponent } from './ceph/cluster/multi-cluster/multi-cluster.component';
5252
import { MultiClusterListComponent } from './ceph/cluster/multi-cluster/multi-cluster-list/multi-cluster-list.component';
5353
import { MultiClusterDetailsComponent } from './ceph/cluster/multi-cluster/multi-cluster-details/multi-cluster-details.component';
54+
import { SmbClusterListComponent } from './ceph/smb/smb-cluster-list/smb-cluster-list.component';
5455

5556
@Injectable()
5657
export class PerformanceCounterBreadcrumbsResolver extends BreadcrumbsResolver {
@@ -429,6 +430,13 @@ const routes: Routes = [
429430
data: { breadcrumbs: ActionLabels.EDIT }
430431
}
431432
]
433+
},
434+
{
435+
path: 'smb',
436+
data: {
437+
breadcrumbs: 'File/SMB'
438+
},
439+
children: [{ path: '', component: SmbClusterListComponent }]
432440
}
433441
]
434442
},

src/pybind/mgr/dashboard/frontend/src/app/ceph/ceph.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ClusterModule } from './cluster/cluster.module';
77
import { DashboardModule } from './dashboard/dashboard.module';
88
import { NfsModule } from './nfs/nfs.module';
99
import { PerformanceCounterModule } from './performance-counter/performance-counter.module';
10+
import { SmbModule } from './smb/smb.module';
1011

1112
@NgModule({
1213
imports: [
@@ -16,6 +17,7 @@ import { PerformanceCounterModule } from './performance-counter/performance-coun
1617
PerformanceCounterModule,
1718
CephfsModule,
1819
NfsModule,
20+
SmbModule,
1921
SharedModule
2022
],
2123
declarations: []
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<ng-container *ngIf="smbClusters$ | async as smbClusters">
2+
<cd-table
3+
#table
4+
[data]="smbClusters"
5+
columnMode="flex"
6+
[columns]="columns"
7+
identifier="id"
8+
forceIdentifier="true"
9+
selectionType="single"
10+
[hasDetails]="false"
11+
(setExpandedRow)="setExpandedRow($event)"
12+
(fetchData)="loadSMBCluster($event)"
13+
>
14+
</cd-table>
15+
</ng-container>

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.scss

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SmbClusterListComponent } from './smb-cluster-list.component';
4+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
5+
import { SharedModule } from '~/app/shared/shared.module';
6+
import { HttpClientTestingModule } from '@angular/common/http/testing';
7+
import { RouterTestingModule } from '@angular/router/testing';
8+
9+
import { ToastrModule } from 'ngx-toastr';
10+
11+
describe('SmbClusterListComponent', () => {
12+
let component: SmbClusterListComponent;
13+
let fixture: ComponentFixture<SmbClusterListComponent>;
14+
15+
beforeEach(async () => {
16+
await TestBed.configureTestingModule({
17+
imports: [
18+
BrowserAnimationsModule,
19+
SharedModule,
20+
HttpClientTestingModule,
21+
ToastrModule.forRoot(),
22+
RouterTestingModule
23+
],
24+
declarations: [SmbClusterListComponent]
25+
}).compileComponents();
26+
27+
fixture = TestBed.createComponent(SmbClusterListComponent);
28+
component = fixture.componentInstance;
29+
fixture.detectChanges();
30+
});
31+
32+
it('should create', () => {
33+
expect(component).toBeTruthy();
34+
});
35+
});
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { Component, OnInit, ViewChild } from '@angular/core';
2+
import { catchError, switchMap } from 'rxjs/operators';
3+
import { BehaviorSubject, Observable, of } from 'rxjs';
4+
5+
import _ from 'lodash';
6+
7+
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
8+
import { TableComponent } from '~/app/shared/datatable/table/table.component';
9+
import { CdTableAction } from '~/app/shared/models/cd-table-action';
10+
import { CdTableColumn } from '~/app/shared/models/cd-table-column';
11+
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
12+
import { ListWithDetails } from '~/app/shared/classes/list-with-details.class';
13+
import { Permission } from '~/app/shared/models/permissions';
14+
15+
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
16+
import { SmbService } from '~/app/shared/api/smb.service';
17+
import { SMBCluster } from '../smb.model';
18+
19+
@Component({
20+
selector: 'cd-smb-cluster-list',
21+
templateUrl: './smb-cluster-list.component.html',
22+
styleUrls: ['./smb-cluster-list.component.scss']
23+
})
24+
export class SmbClusterListComponent extends ListWithDetails implements OnInit {
25+
@ViewChild('table', { static: true })
26+
table: TableComponent;
27+
columns: CdTableColumn[];
28+
permission: Permission;
29+
tableActions: CdTableAction[];
30+
context: CdTableFetchDataContext;
31+
32+
smbClusters$: Observable<SMBCluster[]>;
33+
subject$ = new BehaviorSubject<SMBCluster[]>([]);
34+
35+
constructor(
36+
private authStorageService: AuthStorageService,
37+
public actionLabels: ActionLabelsI18n,
38+
private smbService: SmbService
39+
) {
40+
super();
41+
this.permission = this.authStorageService.getPermissions().smb;
42+
}
43+
44+
ngOnInit() {
45+
this.columns = [
46+
{
47+
name: $localize`Name`,
48+
prop: 'cluster_id',
49+
flexGrow: 2
50+
},
51+
{
52+
name: $localize`Authentication Mode`,
53+
prop: 'auth_mode',
54+
flexGrow: 2
55+
}
56+
];
57+
58+
this.smbClusters$ = this.subject$.pipe(
59+
switchMap(() =>
60+
this.smbService.listClusters().pipe(
61+
catchError(() => {
62+
this.context.error();
63+
return of(null);
64+
})
65+
)
66+
)
67+
);
68+
}
69+
70+
loadSMBCluster() {
71+
this.subject$.next([]);
72+
}
73+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { CephServicePlacement } from '~/app/shared/models/service.interface';
2+
3+
export interface SMBCluster {
4+
cluster_id: string;
5+
auth_mode: AuthMode;
6+
intent: string;
7+
domain_settings?: DomainSettings;
8+
user_group_settings?: string[];
9+
custom_dns?: string[];
10+
placement?: CephServicePlacement;
11+
clustering?: string;
12+
public_addrs?: PublicAddress;
13+
}
14+
15+
export interface DomainSettings {
16+
realm?: string;
17+
join_sources_ref?: string[];
18+
}
19+
20+
export interface PublicAddress {
21+
address: string;
22+
destination: string;
23+
}
24+
25+
export interface AuthMode {
26+
user: 'User';
27+
activeDirectory: 'active-directory';
28+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { ReactiveFormsModule } from '@angular/forms';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { NgbNavModule, NgbTooltipModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
7+
8+
import { SharedModule } from '~/app/shared/shared.module';
9+
10+
import {
11+
ButtonModule,
12+
GridModule,
13+
IconModule,
14+
IconService,
15+
InputModule,
16+
SelectModule
17+
} from 'carbon-components-angular';
18+
19+
import Close from '@carbon/icons/es/close/32';
20+
import { SmbClusterListComponent } from './smb-cluster-list/smb-cluster-list.component';
21+
22+
@NgModule({
23+
imports: [
24+
ReactiveFormsModule,
25+
RouterModule,
26+
SharedModule,
27+
NgbNavModule,
28+
CommonModule,
29+
NgbTypeaheadModule,
30+
NgbTooltipModule,
31+
GridModule,
32+
SelectModule,
33+
InputModule,
34+
ButtonModule,
35+
IconModule
36+
],
37+
exports: [SmbClusterListComponent],
38+
declarations: [SmbClusterListComponent]
39+
})
40+
export class SmbModule {
41+
constructor(private iconService: IconService) {
42+
this.iconService.registerAll([Close]);
43+
}
44+
}

src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
<!-- Filesystem -->
241241
<cds-sidenav-menu title="File"
242242
i18n-title
243-
*ngIf="permissions.nfs.read && enabledFeature.nfs || permissions.cephfs.read && enabledFeature.cephfs"
243+
*ngIf="permissions.nfs.read && enabledFeature.nfs || permissions.cephfs.read && enabledFeature.cephfs || permissions.smb.read"
244244
class="tc_menuitem_file">
245245
<svg cdsIcon="file-storage"
246246
icon
@@ -257,6 +257,12 @@
257257
i18n-title
258258
*ngIf="permissions.nfs.read && enabledFeature.nfs"
259259
class="tc_submenuitem tc_submenuitem_file_nfs"><span i18n>NFS</span></cds-sidenav-item>
260+
<cds-sidenav-item route="/cephfs/smb"
261+
[useRouter]="true"
262+
title="SMB"
263+
i18n-title
264+
*ngIf="permissions.smb.read"
265+
class="tc_submenuitem tc_submenuitem_file_smb"><span i18n>SMB</span></cds-sidenav-item>
260266
</cds-sidenav-menu>
261267
<!-- Observability -->
262268
<cds-sidenav-menu title="Observability"

0 commit comments

Comments
 (0)