mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +00:00
Add queryAsyncOperationProgress API
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import cookie from 'react-cookies';
|
import cookie from 'react-cookies';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { gettext, siteRoot, username, canGenerateShareLink, canGenerateUploadLink, isDocs } from '../../utils/constants';
|
import { gettext, siteRoot, username, isDocs } from '../../utils/constants';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import collabServer from '../../utils/collab-server';
|
import collabServer from '../../utils/collab-server';
|
||||||
@@ -581,20 +581,36 @@ class LibContentView extends React.Component {
|
|||||||
let dirNames = this.getSelectedDirentNames();
|
let dirNames = this.getSelectedDirentNames();
|
||||||
|
|
||||||
seafileAPI.moveDir(repoID, destRepo.repo_id, destDirentPath, this.state.path, dirNames).then(res => {
|
seafileAPI.moveDir(repoID, destRepo.repo_id, destDirentPath, this.state.path, dirNames).then(res => {
|
||||||
|
if (repoID !== destRepo.repo_id) {
|
||||||
|
let taskId = res.data.task_id;
|
||||||
|
seafileAPI.queryAsyncOperationProgress(taskId).then(res => {
|
||||||
|
if (res.data.failed) {
|
||||||
|
let errMessage = Utils.getMoveFailedMessage(dirNames);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
direntPaths.forEach((direntPath, index) => {
|
||||||
|
if (this.state.currentMode === 'column') {
|
||||||
|
this.deleteTreeNode(direntPath);
|
||||||
|
}
|
||||||
|
this.moveDirent(direntPath);
|
||||||
|
});
|
||||||
|
let message = Utils.getMoveSuccessMessage(dirNames);
|
||||||
|
toaster.success(message);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
direntPaths.forEach((direntPath, index) => {
|
direntPaths.forEach((direntPath, index) => {
|
||||||
if (this.state.currentMode === 'column') {
|
if (this.state.currentMode === 'column') {
|
||||||
this.deleteTreeNode(direntPath);
|
this.deleteTreeNode(direntPath);
|
||||||
}
|
}
|
||||||
this.moveDirent(direntPath);
|
this.moveDirent(direntPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (repoID === destRepo.repo_id) {
|
|
||||||
if (this.state.currentMode === 'column') {
|
if (this.state.currentMode === 'column') {
|
||||||
this.updateMoveCopyTreeNode(destDirentPath);
|
this.updateMoveCopyTreeNode(destDirentPath);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let message = Utils.getMoveSuccessMessage(dirNames);
|
let message = Utils.getMoveSuccessMessage(dirNames);
|
||||||
toaster.success(message);
|
toaster.success(message);
|
||||||
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (errMessage === gettext('Error')) {
|
if (errMessage === gettext('Error')) {
|
||||||
@@ -610,16 +626,31 @@ class LibContentView extends React.Component {
|
|||||||
let dirNames = this.getSelectedDirentNames();
|
let dirNames = this.getSelectedDirentNames();
|
||||||
|
|
||||||
seafileAPI.copyDir(repoID, destRepo.repo_id, destDirentPath, this.state.path, dirNames).then(res => {
|
seafileAPI.copyDir(repoID, destRepo.repo_id, destDirentPath, this.state.path, dirNames).then(res => {
|
||||||
if (repoID === destRepo.repo_id) {
|
if (repoID !== destRepo.repo_id) {
|
||||||
if (this.state.currentMode === 'column') {
|
let taskId = res.data.task_id;
|
||||||
this.updateMoveCopyTreeNode(destDirentPath);
|
seafileAPI.queryAsyncOperationProgress(taskId).then(res => {
|
||||||
}
|
if (res.data.failed) {
|
||||||
|
let errMessage = Utils.getCopyFailedMessage(dirNames);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (destDirentPath === this.state.path) {
|
if (destDirentPath === this.state.path) {
|
||||||
this.loadDirentList(this.state.path);
|
this.loadDirentList(this.state.path);
|
||||||
}
|
}
|
||||||
let message = Utils.getCopySuccessfulMessage(dirNames);
|
let message = Utils.getCopySuccessfulMessage(dirNames);
|
||||||
toaster.success(message);
|
toaster.success(message);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (this.state.currentMode === 'column') {
|
||||||
|
this.updateMoveCopyTreeNode(destDirentPath);
|
||||||
|
}
|
||||||
|
if (destDirentPath === this.state.path) {
|
||||||
|
this.loadDirentList(this.state.path);
|
||||||
|
}
|
||||||
|
let message = Utils.getCopySuccessfulMessage(dirNames);
|
||||||
|
toaster.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (errMessage === gettext('Error')) {
|
if (errMessage === gettext('Error')) {
|
||||||
@@ -905,17 +936,35 @@ class LibContentView extends React.Component {
|
|||||||
}
|
}
|
||||||
let direntPath = Utils.joinPath(nodeParentPath, dirName);
|
let direntPath = Utils.joinPath(nodeParentPath, dirName);
|
||||||
seafileAPI.moveDir(repoID, destRepo.repo_id, moveToDirentPath, nodeParentPath, dirName).then(res => {
|
seafileAPI.moveDir(repoID, destRepo.repo_id, moveToDirentPath, nodeParentPath, dirName).then(res => {
|
||||||
|
|
||||||
|
if (repoID !== destRepo.repo_id) {
|
||||||
|
let taskId = res.data.task_id;
|
||||||
|
seafileAPI.queryAsyncOperationProgress(taskId).then(res => {
|
||||||
|
if (res.data.failed) {
|
||||||
|
let errMessage = gettext('Failed to moved %(name)s');
|
||||||
|
errMessage = errMessage.replace('%(name)s', dirName);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.state.currentMode === 'column') {
|
if (this.state.currentMode === 'column') {
|
||||||
this.deleteTreeNode(direntPath);
|
this.deleteTreeNode(direntPath);
|
||||||
if (repoID === destRepo.repo_id) {
|
|
||||||
this.updateMoveCopyTreeNode(moveToDirentPath);
|
|
||||||
}
|
}
|
||||||
|
this.moveDirent(direntPath, moveToDirentPath);
|
||||||
|
let message = gettext('Successfully moved %(name)s.');
|
||||||
|
message = message.replace('%(name)s', dirName);
|
||||||
|
toaster.success(message);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (this.state.currentMode === 'column') {
|
||||||
|
this.deleteTreeNode(direntPath);
|
||||||
|
this.updateMoveCopyTreeNode(moveToDirentPath);
|
||||||
}
|
}
|
||||||
this.moveDirent(direntPath, moveToDirentPath);
|
this.moveDirent(direntPath, moveToDirentPath);
|
||||||
|
|
||||||
let message = gettext('Successfully moved %(name)s.');
|
let message = gettext('Successfully moved %(name)s.');
|
||||||
message = message.replace('%(name)s', dirName);
|
message = message.replace('%(name)s', dirName);
|
||||||
toaster.success(message);
|
toaster.success(message);
|
||||||
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (errMessage === gettext('Error')) {
|
if (errMessage === gettext('Error')) {
|
||||||
@@ -936,10 +985,15 @@ class LibContentView extends React.Component {
|
|||||||
let direntPath = Utils.joinPath(nodeParentPath, dirName);
|
let direntPath = Utils.joinPath(nodeParentPath, dirName);
|
||||||
|
|
||||||
seafileAPI.copyDir(repoID, destRepo.repo_id, copyToDirentPath, nodeParentPath, dirName).then(res => {
|
seafileAPI.copyDir(repoID, destRepo.repo_id, copyToDirentPath, nodeParentPath, dirName).then(res => {
|
||||||
if (this.state.currentMode === 'column') {
|
|
||||||
if (repoID === destRepo.repo_id) {
|
if (repoID !== destRepo.repo_id) {
|
||||||
this.updateMoveCopyTreeNode(copyToDirentPath);
|
let taskId = res.data.task_id;
|
||||||
}
|
seafileAPI.queryAsyncOperationProgress(taskId).then(res => {
|
||||||
|
if (res.data.failed) {
|
||||||
|
let errMessage = gettext('Failed to copy %(name)s');
|
||||||
|
errMessage = errMessage.replace('%(name)s', dirName);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (copyToDirentPath === nodeParentPath) {
|
if (copyToDirentPath === nodeParentPath) {
|
||||||
this.loadDirentList(this.state.path);
|
this.loadDirentList(this.state.path);
|
||||||
@@ -947,6 +1001,18 @@ class LibContentView extends React.Component {
|
|||||||
let message = gettext('Successfully copied %(name)s.');
|
let message = gettext('Successfully copied %(name)s.');
|
||||||
message = message.replace('%(name)s', dirName);
|
message = message.replace('%(name)s', dirName);
|
||||||
toaster.success(message);
|
toaster.success(message);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (this.state.currentMode === 'column') {
|
||||||
|
this.updateMoveCopyTreeNode(copyToDirentPath);
|
||||||
|
}
|
||||||
|
if (copyToDirentPath === nodeParentPath) {
|
||||||
|
this.loadDirentList(this.state.path);
|
||||||
|
}
|
||||||
|
let message = gettext('Successfully copied %(name)s.');
|
||||||
|
message = message.replace('%(name)s', dirName);
|
||||||
|
toaster.success(message);
|
||||||
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (errMessage === gettext('Error')) {
|
if (errMessage === gettext('Error')) {
|
||||||
|
Reference in New Issue
Block a user