UI/iwd: wifi machine module

This commit is contained in:
Johannes Kirschbauer
2024-09-04 15:21:37 +02:00
parent 87d47c7c31
commit 5da72f65c0
9 changed files with 293 additions and 133 deletions

View File

@@ -19,3 +19,27 @@ export const registerClan = async () => {
//
}
};
/**
* Opens the custom file dialog
* Returns a native FileList to allow interaction with the native input type="file"
*/
export const selectSshKeys = async (): Promise<FileList> => {
const dataTransfer = new DataTransfer();
const response = await callApi("open_file", {
file_request: {
title: "Select SSH Key",
mode: "open_file",
initial_folder: "~/.ssh",
},
});
if (response.status === "success" && response.data) {
// Add synthetic files to the DataTransfer object
// FileList cannot be instantiated directly.
response.data.forEach((filename) => {
dataTransfer.items.add(new File([], filename));
});
}
return dataTransfer.files;
};