fix: resolve IDE errors, minor UI tweaks, and implement file conflict resolution UI/API
Some checks failed
Automated Container Build / build-and-push (push) Failing after 1m13s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 1m13s
This commit is contained in:
parent
3e34a37c95
commit
10bab4ea5b
7 changed files with 625 additions and 58 deletions
|
|
@ -146,6 +146,14 @@ class ApiClient {
|
|||
}
|
||||
|
||||
// --- Files ---
|
||||
async checkConflicts(destPath: string, files: string[]) {
|
||||
const res = await this.request('/api/files/check-conflicts', {
|
||||
method: 'POST',
|
||||
body: { dest_path: destPath, files },
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async listDirectory(path: string = '.') {
|
||||
const res = await this.request(`/api/files/?path=${encodeURIComponent(path)}`);
|
||||
return res.json();
|
||||
|
|
@ -177,18 +185,18 @@ class ApiClient {
|
|||
return res.json();
|
||||
}
|
||||
|
||||
async move(sourcePath: string, destPath: string) {
|
||||
async move(sourcePath: string, destPath: string, resolution: string = "rename") {
|
||||
const res = await this.request('/api/files/move', {
|
||||
method: 'POST',
|
||||
body: { source_path: sourcePath, dest_path: destPath },
|
||||
body: { source_path: sourcePath, dest_path: destPath, resolution },
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async copy(sourcePath: string, destPath: string) {
|
||||
async copy(sourcePath: string, destPath: string, resolution: string = "rename") {
|
||||
const res = await this.request('/api/files/copy', {
|
||||
method: 'POST',
|
||||
body: { source_path: sourcePath, dest_path: destPath },
|
||||
body: { source_path: sourcePath, dest_path: destPath, resolution },
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
|
@ -200,7 +208,7 @@ class ApiClient {
|
|||
return res.json();
|
||||
}
|
||||
|
||||
upload(file: File, destPath: string, callbacks?: { onProgress?: (percent: number) => void }): Promise<void> {
|
||||
upload(file: File, destPath: string, options?: { onProgress?: (percent: number) => void, overwrite?: boolean }): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const upload = new tus.Upload(file, {
|
||||
endpoint: `${API_BASE}/api/tus/`,
|
||||
|
|
@ -211,13 +219,14 @@ class ApiClient {
|
|||
filename: file.name,
|
||||
filetype: file.type,
|
||||
path: destPath,
|
||||
overwrite: options?.overwrite ? "true" : "false",
|
||||
},
|
||||
onError: function (error) {
|
||||
reject(error);
|
||||
},
|
||||
onProgress: function (bytesUploaded, bytesTotal) {
|
||||
const percentage = (bytesUploaded / bytesTotal) * 100;
|
||||
callbacks?.onProgress?.(percentage);
|
||||
options?.onProgress?.(percentage);
|
||||
},
|
||||
onSuccess: function () {
|
||||
resolve();
|
||||
|
|
|
|||
Reference in a new issue