Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-132372 / 25.04 / Add /dev/zvol root for explorer #11106

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[tooltip]="helptext.source_path_tooltip | translate"
[required]="true"
[multiple]="false"
[root]="'/'"
[nodeProvider]="fileNodeProvider"
></ix-explorer>
</ix-fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ export class CloudBackupFormComponent implements OnInit {
}

private setFileNodeProvider(): void {
this.fileNodeProvider = this.filesystemService.getFilesystemNodeProvider({ directoriesOnly: true });
this.fileNodeProvider = this.filesystemService.getFilesystemNodeProvider({
dsAndZvols: true,
});
}

private setBucketNodeProvider(): void {
Expand Down
37 changes: 29 additions & 8 deletions src/app/services/filesystem.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { map } from 'rxjs';
import { map, of } from 'rxjs';
import { ExplorerNodeType } from 'app/enums/explorer-type.enum';
import { FileAttribute } from 'app/enums/file-attribute.enum';
import { FileType } from 'app/enums/file-type.enum';
Expand All @@ -9,6 +9,12 @@ import { ExplorerNodeData, TreeNode } from 'app/interfaces/tree-node.interface';
import { TreeNodeProvider } from 'app/modules/forms/ix-forms/components/ix-explorer/tree-node-provider.interface';
import { ApiService } from 'app/services/websocket/api.service';

export interface ProviderOptions {
directoriesOnly?: boolean;
showHiddenFiles?: boolean;
includeSnapshots?: boolean;
dsAndZvols?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not abbreviate

}
@Injectable({ providedIn: 'root' })
export class FilesystemService {
constructor(
Expand All @@ -18,19 +24,34 @@ export class FilesystemService {
/**
* Returns a pre-configured node provider for files and directories.
*/
getFilesystemNodeProvider(providerOptions?: {
directoriesOnly?: boolean;
showHiddenFiles?: boolean;
includeSnapshots?: boolean;
}): TreeNodeProvider {
const options = {
getFilesystemNodeProvider(providerOptions?: ProviderOptions): TreeNodeProvider {
const options: ProviderOptions = {
directoriesOnly: false,
showHiddenFiles: false,
includeSnapshots: true,
dsAndZvols: false,
...providerOptions,
};

return (node: TreeNode<ExplorerNodeData>) => {
if (options.dsAndZvols) {
if (node.data.path.trim() === '/') {
return of([
{
path: '/mnt',
name: '/mnt',
hasChildren: true,
type: ExplorerNodeType.Directory,
},
{
path: '/dev/zvol',
name: '/dev/zvol',
hasChildren: true,
type: ExplorerNodeType.Directory,
},
] as ExplorerNodeData[]);
}
}
const typeFilter: [QueryFilter<FileRecord>?] = [];
if (options.directoriesOnly) {
typeFilter.push(['type', '=', FileType.Directory]);
Expand All @@ -50,7 +71,7 @@ export class FilesystemService {
map((files) => {
const children: ExplorerNodeData[] = [];
files.forEach((file) => {
if (file.type === FileType.Symlink || !file.hasOwnProperty('name')) {
if ((!options.dsAndZvols && file.type === FileType.Symlink) || !file.hasOwnProperty('name')) {
return;
}

Expand Down
Loading