1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 10:58:33 +00:00
Files
seahub/frontend/src/utils/editor-utilities.js

93 lines
2.2 KiB
JavaScript
Raw Normal View History

import { repoID, historyRepoID } from './constants';
import { seafileAPI } from './seafile-api';
2018-09-04 17:16:50 +08:00
class EditorUtilities {
listRepoDir() {
2018-09-12 17:01:48 +08:00
return seafileAPI.listDir(repoID, '/',{recursive: true}).then(items => {
const files = items.data.dirent_list.map(item => {
2018-09-12 17:01:48 +08:00
return {
name: item.name,
type: item.type === 'dir' ? 'dir' : 'file',
isExpanded: item.type === 'dir' ? true : false,
parent_path: item.parent_dir,
last_update_time: item.mtime,
2018-09-29 15:47:53 +08:00
permission: item.permission,
2018-09-12 17:01:48 +08:00
size: item.size
};
});
return files;
});
}
2018-09-04 17:16:50 +08:00
deleteFile(filePath) {
2018-09-12 17:01:48 +08:00
return seafileAPI.deleteFile(repoID, filePath);
2018-09-04 17:16:50 +08:00
}
renameFile(filePath, newFileName) {
2018-09-12 17:01:48 +08:00
return seafileAPI.renameFile(repoID, filePath, newFileName);
2018-09-04 17:16:50 +08:00
}
createDir(dirPath) {
2018-09-12 17:01:48 +08:00
return seafileAPI.createDir(repoID, dirPath);
2018-09-04 17:16:50 +08:00
}
deleteDir(dirPath) {
2018-09-12 17:01:48 +08:00
return seafileAPI.deleteDir(repoID, dirPath);
2018-09-04 17:16:50 +08:00
}
renameDir(dirPath, newDirName) {
2018-09-12 17:01:48 +08:00
return seafileAPI.renameDir(repoID, dirPath, newDirName);
2018-09-04 17:16:50 +08:00
}
getWikiFileContent(slug, filePath) {
return seafileAPI.getWikiFileContent(slug, filePath);
}
getSource() {
return seafileAPI.getSource();
}
searchFiles(queryData,cancelToken) {
return seafileAPI.searchFiles(queryData,cancelToken);
}
getAccountInfo() {
return seafileAPI.getAccountInfo();
}
2018-09-12 17:01:48 +08:00
// file history
getFileDownloadLink(filePath) {
return seafileAPI.getFileDownloadLink(historyRepoID, filePath);
}
getFileContent(filePath) {
return seafileAPI.getFileContent(filePath);
}
listFileHistoryRecords(filePath, page, per_page) {
return seafileAPI.listFileHistoryRecords(historyRepoID, filePath, page, per_page);
2018-09-12 17:01:48 +08:00
}
2018-09-12 17:01:48 +08:00
revertFile(filePath, commitID) {
return seafileAPI.revertFile(historyRepoID, filePath, commitID);
}
2018-09-15 16:14:17 +08:00
2018-09-29 15:47:53 +08:00
zipDownload(parent_dir, dirents) {
return seafileAPI.zipDownload(repoID, parent_dir, dirents);
}
queryZipProgress(zip_token) {
return seafileAPI.queryZipProgress(zip_token);
}
cancelZipTask(zip_token) {
return seafileAPI.cancelZipTask(zip_token);
2018-09-29 15:47:53 +08:00
}
2018-09-04 17:16:50 +08:00
}
const editorUtilities = new EditorUtilities();
export default editorUtilities;