mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 15:26:19 +00:00
update ui
This commit is contained in:
@@ -1,36 +1,175 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Modal, ModalBody } from 'reactstrap';
|
import { Button, Modal, ModalBody, ModalFooter, Label, Alert } from 'reactstrap';
|
||||||
import { gettext } from '../../utils/constants';
|
import SeahubModalHeader from '../common/seahub-modal-header';
|
||||||
import SeahubModalHeader from '@/components/common/seahub-modal-header';
|
import { gettext, isPro } from '../../utils/constants';
|
||||||
import Loading from '../loading';
|
import wikiAPI from '../../utils/wiki-api';
|
||||||
|
import { Utils } from '../../utils/utils';
|
||||||
import '../../css/seahub-io-dialog.css';
|
import toaster from '../toast';
|
||||||
|
import { SeahubSelect } from '../common/select';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
toggleDialog: PropTypes.func.isRequired,
|
toggleCancel: PropTypes.func.isRequired,
|
||||||
|
importConfluence: PropTypes.func.isRequired,
|
||||||
|
currentDeptID: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImportConfluenceDialog extends React.Component {
|
class ImportConfluenceDialog extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
name: '',
|
||||||
|
isSubmitBtnActive: false,
|
||||||
|
selectedOption: null,
|
||||||
|
options: [],
|
||||||
|
selectedFile: null,
|
||||||
|
isUploading: false
|
||||||
|
};
|
||||||
|
this.fileInputRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle = () => {
|
componentDidMount() {
|
||||||
this.props.toggleDialog();
|
if (!isPro) return;
|
||||||
|
wikiAPI.listWikiDepartments().then(res => {
|
||||||
|
const departments = res.data.sort((a, b) => {
|
||||||
|
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||||
|
});
|
||||||
|
let options = [];
|
||||||
|
for (let i = 0 ; i < departments.length; i++) {
|
||||||
|
let obj = {};
|
||||||
|
obj.value = departments[i].name;
|
||||||
|
obj.id = departments[i].id;
|
||||||
|
obj.email = departments[i].email;
|
||||||
|
obj.label = departments[i].name;
|
||||||
|
options.push(obj);
|
||||||
|
}
|
||||||
|
this.setState({ options });
|
||||||
|
if (this.props.currentDeptID) {
|
||||||
|
const selectedOption = options.find(op => op.id == this.props.currentDeptID);
|
||||||
|
this.setState({ selectedOption });
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleKeyDown = (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
this.handleSubmit();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleFileChange = (e) => {
|
||||||
|
const file = e.target.files[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
if (!file.name.endsWith('.html.zip')) {
|
||||||
|
toaster.danger(gettext('Please select a valid Confluence HTML export file (.html.zip)'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedFile: file,
|
||||||
|
name: file.name.replace('.html.zip', '')
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSubmit = () => {
|
||||||
|
if (!this.state.selectedFile) {
|
||||||
|
toaster.danger(gettext('Please select a Confluence export file'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ isUploading: true });
|
||||||
|
let departmentID = this.state.selectedOption ? this.state.selectedOption.id : '';
|
||||||
|
|
||||||
|
this.props.importConfluence(this.state.selectedFile, departmentID)
|
||||||
|
.then((res) => {
|
||||||
|
toaster.success(gettext('Successfully imported Confluence data'));
|
||||||
|
this.props.toggleCancel();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
let errorMsg = Utils.getErrorMsg(error);
|
||||||
|
toaster.danger(errorMsg || gettext('Failed to import Confluence data'));
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.setState({ isUploading: false });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
triggerFileInput = () => {
|
||||||
|
this.fileInputRef.current.click();
|
||||||
|
};
|
||||||
|
|
||||||
|
toggle = () => {
|
||||||
|
this.props.toggleCancel();
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSelectChange = (option) => {
|
||||||
|
this.setState({ selectedOption: option });
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { selectedFile, isUploading } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal className='seahub-io-dialog' isOpen={true} toggle={this.toggle}>
|
<Modal isOpen={true} autoFocus={false} toggle={this.toggle}>
|
||||||
<SeahubModalHeader toggle={this.toggle}>{gettext('Import Confluence')}</SeahubModalHeader>
|
<SeahubModalHeader toggle={this.toggle}>{gettext('Import Confluence Wiki')}</SeahubModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<>
|
<Label>{gettext('Confluence Export File')}</Label>
|
||||||
<Loading/>
|
<div className="d-flex align-items-center">
|
||||||
<div className="seahub-io-dialog-parsing-text">{gettext('Importing Confluence...')}</div>
|
<input
|
||||||
</>
|
type="file"
|
||||||
|
ref={this.fileInputRef}
|
||||||
|
style={{ display: 'none' }}
|
||||||
|
accept=".html.zip"
|
||||||
|
onChange={this.handleFileChange}
|
||||||
|
/>
|
||||||
|
<Button color="primary" onClick={this.triggerFileInput} disabled={isUploading}>
|
||||||
|
{gettext('Select File')}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<span className="ml-2">
|
||||||
|
{selectedFile ? selectedFile.name : gettext('No file selected')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<small className="form-text text-muted">
|
||||||
|
{gettext('Please select a Confluence HTML export file (.html.zip)')}
|
||||||
|
</small>
|
||||||
|
<br />
|
||||||
|
{isPro &&
|
||||||
|
<>
|
||||||
|
<Label className='mt-4'>{gettext('Wiki owner')} ({gettext('Optional')})</Label>
|
||||||
|
<SeahubSelect
|
||||||
|
onChange={this.handleSelectChange}
|
||||||
|
options={this.state.options}
|
||||||
|
hideSelectedOptions={true}
|
||||||
|
placeholder={gettext('Select a department')}
|
||||||
|
maxMenuHeight={200}
|
||||||
|
value={this.state.selectedOption}
|
||||||
|
noOptionsMessage={() => {return gettext('No options available');}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
{selectedFile &&
|
||||||
|
<Alert color="info" className="mt-3">
|
||||||
|
{gettext('The import process may take several minutes depending on the size of your Confluence export.')}
|
||||||
|
</Alert>
|
||||||
|
}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button color="secondary" onClick={this.toggle} disabled={isUploading}>{gettext('Cancel')}</Button>
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onClick={this.handleSubmit}
|
||||||
|
disabled={!this.state.selectedFile || !this.state.name.trim() || isUploading}
|
||||||
|
>
|
||||||
|
{isUploading ? gettext('Importing...') : gettext('Import')}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -102,53 +102,64 @@ class Wikis extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
toggleImportConfluenceDialog = (value) => {
|
toggleImportConfluenceDialog = (currentDeptID) => {
|
||||||
if (value == false) {
|
if (this.state.isShowImportConfluenceDialog) {
|
||||||
this.setState({
|
this.setState({
|
||||||
isShowImportConfluenceDialog: false,
|
isShowImportConfluenceDialog: false,
|
||||||
});
|
currentDeptID: '',
|
||||||
} else if (value == true) {
|
|
||||||
this.setState({
|
|
||||||
isShowImportConfluenceDialog: true,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
isShowImportConfluenceDialog: !this.state.isShowImportConfluenceDialog,
|
isShowImportConfluenceDialog: true,
|
||||||
|
currentDeptID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
importWikiFromConfluenceZip = () => {
|
importConfluence = (file, currentDeptID) => {
|
||||||
const fileInput = document.createElement('input');
|
if (!file) return;
|
||||||
fileInput.type = 'file';
|
if (!file.name.endsWith('.html.zip')) {
|
||||||
fileInput.accept = '.zip';
|
toaster.danger(gettext('Please select a valid Confluence HTML export file (.html.zip)'));
|
||||||
fileInput.addEventListener('change', (event) => {
|
return;
|
||||||
const file = event.target.files[0];
|
}
|
||||||
if (!file) return;
|
|
||||||
|
|
||||||
if (file.type !== 'application/zip' && !file.name.endsWith('.zip')) {
|
return wikiAPI.importConfluence(file, currentDeptID).then((res) => {
|
||||||
toaster.danger(gettext('Please select a valid ZIP file'));
|
let wikis = this.state.wikis.slice(0);
|
||||||
return;
|
let groupWikis = this.state.groupWikis;
|
||||||
}
|
let new_wiki = res.data;
|
||||||
this.toggleImportConfluenceDialog(true);
|
new_wiki['version'] = 'v2';
|
||||||
wikiAPI.importConfluence(file).then((res) => {
|
new_wiki['admins'] = new_wiki.group_admins;
|
||||||
let wikis = this.state.wikis.slice(0);
|
let findGroup = false;
|
||||||
let new_wiki = res.data;
|
if (currentDeptID) {
|
||||||
new_wiki['version'] = 'v2';
|
groupWikis.filter(group => {
|
||||||
new_wiki['admins'] = new_wiki.group_admins;
|
if (group.group_id === currentDeptID) {
|
||||||
|
group.wiki_info.push(new_wiki);
|
||||||
|
findGroup = true;
|
||||||
|
}
|
||||||
|
return group;
|
||||||
|
});
|
||||||
|
if (findGroup) {
|
||||||
|
this.setState({
|
||||||
|
groupWikis: groupWikis,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
groupWikis.push({
|
||||||
|
group_id: currentDeptID,
|
||||||
|
group_name: new_wiki.group_name,
|
||||||
|
wiki_info: [new_wiki],
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
groupWikis: groupWikis,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
wikis.unshift(new_wiki);
|
wikis.unshift(new_wiki);
|
||||||
this.setState({
|
this.setState({
|
||||||
wikis,
|
wikis: wikis,
|
||||||
});
|
});
|
||||||
toaster.success(gettext('Successfully uploaded Confluence data'));
|
}
|
||||||
}).catch((error) => {
|
return res;
|
||||||
let errorMsg = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errorMsg || gettext('Failed to upload Confluence data'));
|
|
||||||
}).finally(() => {
|
|
||||||
this.toggleImportConfluenceDialog(false);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
fileInput.click();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
addWiki = (wikiName, currentDeptID) => {
|
addWiki = (wikiName, currentDeptID) => {
|
||||||
@@ -165,14 +176,18 @@ class Wikis extends Component {
|
|||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
});
|
});
|
||||||
|
this.setState({
|
||||||
|
currentDeptID: '',
|
||||||
|
groupWikis,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
wikis.push(new_wiki);
|
wikis.push(new_wiki);
|
||||||
|
wikis.unshift(new_wiki);
|
||||||
|
this.setState({
|
||||||
|
wikis,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.setState({
|
|
||||||
wikis,
|
|
||||||
currentDeptID: '',
|
|
||||||
groupWikis,
|
|
||||||
});
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
@@ -182,6 +197,11 @@ class Wikis extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
deleteWiki = (wiki) => {
|
deleteWiki = (wiki) => {
|
||||||
|
const owner = wiki.owner;
|
||||||
|
let isGroupWiki = false;
|
||||||
|
if (owner.includes('@seafile_group')) {
|
||||||
|
isGroupWiki = true;
|
||||||
|
}
|
||||||
if (wiki.version === 'v1') {
|
if (wiki.version === 'v1') {
|
||||||
wikiAPI.deleteWiki(wiki.id).then(() => {
|
wikiAPI.deleteWiki(wiki.id).then(() => {
|
||||||
let wikis = this.state.wikis.filter(item => {
|
let wikis = this.state.wikis.filter(item => {
|
||||||
@@ -203,17 +223,22 @@ class Wikis extends Component {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
wikiAPI.deleteWiki2(wiki.id).then(() => {
|
wikiAPI.deleteWiki2(wiki.id).then(() => {
|
||||||
let wikis = this.state.wikis.filter(item => {
|
if (isGroupWiki) {
|
||||||
return item.id !== wiki.id;
|
let groupWikis = this.state.groupWikis.filter(group => {
|
||||||
});
|
group.wiki_info = group.wiki_info.filter(item => item.name !== wiki.name);
|
||||||
let groupWikis = this.state.groupWikis.filter(group => {
|
return group;
|
||||||
group.wiki_info = group.wiki_info.filter(item => item.name !== wiki.name);
|
});
|
||||||
return group;
|
this.setState({
|
||||||
});
|
groupWikis: groupWikis,
|
||||||
this.setState({
|
});
|
||||||
wikis: wikis,
|
} else {
|
||||||
groupWikis: groupWikis,
|
let wikis = this.state.wikis.filter(item => {
|
||||||
});
|
return item.id !== wiki.id;
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
wikis: wikis,
|
||||||
|
});
|
||||||
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
let errorMsg = error.response.data.error_msg;
|
let errorMsg = error.response.data.error_msg;
|
||||||
@@ -378,7 +403,9 @@ class Wikis extends Component {
|
|||||||
{this.state.isShowImportConfluenceDialog &&
|
{this.state.isShowImportConfluenceDialog &&
|
||||||
<ModalPortal>
|
<ModalPortal>
|
||||||
<ImportConfluenceDialog
|
<ImportConfluenceDialog
|
||||||
toggleDialog={this.toggleImportConfluenceDialog}
|
toggleCancel={this.toggleImportConfluenceDialog}
|
||||||
|
importConfluence={this.importConfluence}
|
||||||
|
currentDeptID={this.state.currentDeptID}
|
||||||
/>
|
/>
|
||||||
</ModalPortal>
|
</ModalPortal>
|
||||||
}
|
}
|
||||||
@@ -392,7 +419,7 @@ class Wikis extends Component {
|
|||||||
withPlusIcon={true}
|
withPlusIcon={true}
|
||||||
opList={[
|
opList={[
|
||||||
{ 'text': gettext('Add Wiki'), 'onClick': () => this.toggleAddWikiDialog() },
|
{ 'text': gettext('Add Wiki'), 'onClick': () => this.toggleAddWikiDialog() },
|
||||||
{ 'text': gettext('Import Confluence'), 'onClick': () => this.importWikiFromConfluenceZip() }
|
{ 'text': gettext('Import Confluence'), 'onClick': () => this.toggleImportConfluenceDialog() }
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@@ -302,10 +302,11 @@ class WikiAPI {
|
|||||||
return this._sendPostRequest(url, form);
|
return this._sendPostRequest(url, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
importConfluence(file) {
|
importConfluence(file, departmentID) {
|
||||||
const url = this.server + '/api/v2.1/import-confluence/';
|
const url = this.server + '/api/v2.1/import-confluence/';
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
formData.append('group_id', departmentID);
|
||||||
return this._sendPostRequest(url, formData);
|
return this._sendPostRequest(url, formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,6 +66,7 @@ from seahub.constants import PERMISSION_READ_WRITE
|
|||||||
from seaserv import ccnet_api
|
from seaserv import ccnet_api
|
||||||
from seahub.share.utils import is_repo_admin
|
from seahub.share.utils import is_repo_admin
|
||||||
from seahub.api2.endpoints.utils import confluence_to_wiki
|
from seahub.api2.endpoints.utils import confluence_to_wiki
|
||||||
|
from seahub.group.utils import group_id_to_name
|
||||||
|
|
||||||
|
|
||||||
HTTP_520_OPERATION_FAILED = 520
|
HTTP_520_OPERATION_FAILED = 520
|
||||||
@@ -1658,7 +1659,15 @@ class ImportConfluenceView(APIView):
|
|||||||
|
|
||||||
if not request.user.permissions.can_create_wiki():
|
if not request.user.permissions.can_create_wiki():
|
||||||
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to create wiki.')
|
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to create wiki.')
|
||||||
|
group_id = request.data.get('group_id', None)
|
||||||
|
if not group_id:
|
||||||
|
wiki_owner = request.user.username
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
group_id = int(group_id)
|
||||||
|
wiki_owner = "%s@seafile_group" % group_id
|
||||||
|
except:
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, 'group_id invalid')
|
||||||
# create wiki
|
# create wiki
|
||||||
org_id = -1
|
org_id = -1
|
||||||
if is_org_context(request):
|
if is_org_context(request):
|
||||||
@@ -1673,10 +1682,43 @@ class ImportConfluenceView(APIView):
|
|||||||
# The manually exported file name is Confluence-space-export-id.html.zip
|
# The manually exported file name is Confluence-space-export-id.html.zip
|
||||||
wiki_name = filename[:-len('.html.zip')]
|
wiki_name = filename[:-len('.html.zip')]
|
||||||
space_key = filename[len('Confluence-space-export-'):-len('.html.zip')]
|
space_key = filename[len('Confluence-space-export-'):-len('.html.zip')]
|
||||||
if org_id and org_id > 0:
|
|
||||||
repo_id = seafile_api.create_org_repo(wiki_name, '', username, org_id)
|
permission = PERMISSION_READ_WRITE
|
||||||
|
if group_id:
|
||||||
|
group_id = int(group_id)
|
||||||
|
# only group admin can create wiki
|
||||||
|
if not is_group_admin(group_id, request.user.username):
|
||||||
|
error_msg = 'Permission denied.'
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
|
group_quota = seafile_api.get_group_quota(group_id)
|
||||||
|
group_quota = int(group_quota)
|
||||||
|
if group_quota <= 0 and group_quota != -2:
|
||||||
|
error_msg = 'No group quota.'
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
|
# create group owned repo
|
||||||
|
password = None
|
||||||
|
if is_pro_version() and ENABLE_STORAGE_CLASSES:
|
||||||
|
if STORAGE_CLASS_MAPPING_POLICY in ('USER_SELECT', 'ROLE_BASED'):
|
||||||
|
storage_id = None
|
||||||
|
repo_id = seafile_api.add_group_owned_repo(group_id,
|
||||||
|
wiki_name,
|
||||||
|
permission,
|
||||||
|
password,
|
||||||
|
enc_version=ENCRYPTED_LIBRARY_VERSION,
|
||||||
|
storage_id=storage_id)
|
||||||
|
else:
|
||||||
|
repo_id = SeafileAPI.add_group_owned_repo(
|
||||||
|
group_id, wiki_name, password, permission, org_id=org_id)
|
||||||
|
else:
|
||||||
|
repo_id = SeafileAPI.add_group_owned_repo(
|
||||||
|
group_id, wiki_name, password, permission, org_id=org_id)
|
||||||
else:
|
else:
|
||||||
repo_id = seafile_api.create_repo(wiki_name, '', username)
|
if org_id and org_id > 0:
|
||||||
|
repo_id = seafile_api.create_org_repo(wiki_name, '', username, org_id)
|
||||||
|
else:
|
||||||
|
repo_id = seafile_api.create_repo(wiki_name, '', username)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
seafile_db_api = SeafileDB()
|
seafile_db_api = SeafileDB()
|
||||||
@@ -1710,14 +1752,15 @@ class ImportConfluenceView(APIView):
|
|||||||
if not os.path.exists(extract_dir):
|
if not os.path.exists(extract_dir):
|
||||||
extract_dir = self._extract_html_zip(file, space_key)
|
extract_dir = self._extract_html_zip(file, space_key)
|
||||||
sdoc_output_dir = self._download_sdoc_files(repo_id, space_key, username)
|
sdoc_output_dir = self._download_sdoc_files(repo_id, space_key, username)
|
||||||
sdoc_files = list(Path(sdoc_output_dir).glob('*.sdoc'))
|
if sdoc_output_dir:
|
||||||
self._process_zip_file(wiki, extract_dir, sdoc_files, cf_id_to_cf_title_map, username)
|
sdoc_files = list(Path(sdoc_output_dir).glob('*.sdoc'))
|
||||||
# delete server tmp dir
|
self._process_zip_file(wiki, extract_dir, sdoc_files, cf_id_to_cf_title_map, username)
|
||||||
seafile_api.del_file(repo_id, '/',
|
# delete server tmp dir
|
||||||
json.dumps(['tmp']), username)
|
seafile_api.del_file(repo_id, '/',
|
||||||
# clean repo trash
|
json.dumps(['tmp']), username)
|
||||||
seafile_api.clean_up_repo_history(repo_id, 0)
|
# clean repo trash
|
||||||
shutil.rmtree(extract_dir)
|
seafile_api.clean_up_repo_history(repo_id, 0)
|
||||||
|
shutil.rmtree(extract_dir)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
if os.path.exists(extract_dir):
|
if os.path.exists(extract_dir):
|
||||||
@@ -1725,10 +1768,11 @@ class ImportConfluenceView(APIView):
|
|||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
wiki = Wiki(repo, username)
|
wiki = Wiki(repo, wiki_owner)
|
||||||
wiki_info = wiki.to_dict()
|
wiki_info = wiki.to_dict()
|
||||||
wiki_info['owner_nickname'] = email2nickname(wiki.owner)
|
wiki_info['owner_nickname'] = email2nickname(wiki.owner)
|
||||||
|
if group_id:
|
||||||
|
wiki_info['group_name'] = group_id_to_name(group_id)
|
||||||
return Response(wiki_info)
|
return Response(wiki_info)
|
||||||
|
|
||||||
def _upload_zip_file(self, repo_id, zip_file, username):
|
def _upload_zip_file(self, repo_id, zip_file, username):
|
||||||
@@ -1792,6 +1836,8 @@ class ImportConfluenceView(APIView):
|
|||||||
def _download_sdoc_files(self, repo_id, space_key, username):
|
def _download_sdoc_files(self, repo_id, space_key, username):
|
||||||
server_wiki_tmp_sdoc_output_dir = 'tmp/sdoc_archive.zip'
|
server_wiki_tmp_sdoc_output_dir = 'tmp/sdoc_archive.zip'
|
||||||
file_id = seafile_api.get_file_id_by_path(repo_id, server_wiki_tmp_sdoc_output_dir)
|
file_id = seafile_api.get_file_id_by_path(repo_id, server_wiki_tmp_sdoc_output_dir)
|
||||||
|
if not file_id:
|
||||||
|
return None
|
||||||
download_token = seafile_api.get_fileserver_access_token(repo_id, file_id, 'download', username)
|
download_token = seafile_api.get_fileserver_access_token(repo_id, file_id, 'download', username)
|
||||||
download_url = gen_file_get_url(download_token, 'sdoc_archive.zip')
|
download_url = gen_file_get_url(download_token, 'sdoc_archive.zip')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user