Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions src/api/socketActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,17 @@ export const SocketActions = {
)
},

serverFilesRoots (options?: NotifyOptions) {
return baseEmit<Moonraker.Files.RootsResponse>(
'server.files.roots',
{
dispatch: 'files/onServerFilesRoots',
wait: Waits.onFileSystemRoots,
...options
}
)
},

serverFilesList (root: string, options?: NotifyOptions) {
return baseEmit<Moonraker.Files.ListRootResponse>(
'server.files.list',
Expand Down
1 change: 1 addition & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ export const Waits = Object.freeze({
onExtruderChange: 'onExtruderChange',
onLoadLanguage: 'onLoadLanguage',
onFileSystem: 'onFileSystem',
onFileSystemRoots: 'onFileSystemRoots',
onJobQueue: 'onJobQueue',
onTimelapseSaveFrame: 'onTimelapseSaveFrame',
onManualProbe: 'onManualProbe',
Expand Down
4 changes: 4 additions & 0 deletions src/store/files/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export const actions = {
commit('setServerFilesGetDirectory', { path, content: { files, dirs: filteredDirs } })
},

async onServerFilesRoots ({ commit }, payload: Moonraker.Files.RootsResponse) {
commit('setServerFilesRoots', [...payload])
},

async onServerFilesListRoot ({ commit }, payload: ObjectWithRequest<Moonraker.Files.ListRootResponse>) {
const { root } = payload.__request__.params ?? {}

Expand Down
4 changes: 4 additions & 0 deletions src/store/files/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ export const getters = {
return state.currentPaths[root] ?? ''
},

getRootDetails: (state) => (root: string): Moonraker.Files.RootInfoWithPath | undefined => {
return state.roots?.find(rootInfo => rootInfo.name === root)
},

getDiskUsage: (state) => (root: string): AppDiskUsage | undefined => {
const diskUsage = state.diskUsage[root]

Expand Down
4 changes: 4 additions & 0 deletions src/store/files/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const mutations = {
Vue.set(state.pathContent, path, content)
},

setServerFilesRoots (state, payload: Moonraker.Files.RootInfoWithPath[]) {
state.roots = payload
},

setServerFilesListRoot (state, payload: { root: string, files: Moonraker.Files.RootFile[] }) {
const { root, files } = payload

Expand Down
1 change: 1 addition & 0 deletions src/store/files/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const defaultState = (): FilesState => {
return {
uploads: [],
download: null,
roots: null,
currentPaths: {},
diskUsage: {},
rootFiles: {},
Expand Down
3 changes: 2 additions & 1 deletion src/store/files/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export type { AppFileMeta }
export interface FilesState {
uploads: FileUpload[];
download: FileDownload | null;
currentPaths: Record<string, string>;
roots: Moonraker.Files.RootInfoWithPath[] | null;
currentPaths: Record<string, string | undefined>;
diskUsage: Record<string, Moonraker.Files.DiskUsage | undefined>;
rootFiles: Record<string, Moonraker.Files.RootFile[] | undefined>;
pathContent: Record<string, MoonrakerPathContent | undefined>;
Expand Down
7 changes: 7 additions & 0 deletions src/typings/moonraker.file_manager.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
declare namespace Moonraker.Files {
export interface RootsResponse extends Array<RootInfoWithPath> {
}

export interface ListRootResponse extends Array<RootFile> {
}

Expand Down Expand Up @@ -39,6 +42,10 @@ declare namespace Moonraker.Files {
permissions?: Moonraker.Files.FilePermissions;
}

export interface RootInfoWithPath extends RootInfo {
path: string;
}

export type FilePermissions = '' | 'r' | 'rw'

export interface File {
Expand Down