mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
108
frontend/src/components/file-view/file-view.js
Normal file
108
frontend/src/components/file-view/file-view.js
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import watermark from 'watermark-dom';
|
||||||
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
|
import { siteName } from '../../utils/constants';
|
||||||
|
import FileInfo from './file-info';
|
||||||
|
import FileToolbar from './file-toolbar';
|
||||||
|
import CommentPanel from './comment-panel';
|
||||||
|
|
||||||
|
import '../../css/file-view.css';
|
||||||
|
|
||||||
|
const propTypes = {
|
||||||
|
content: PropTypes.object.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
const { isStarred, isLocked, lockedByMe,
|
||||||
|
repoID, filePath, enableWatermark, userNickName
|
||||||
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
|
class FileView extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
isStarred: isStarred,
|
||||||
|
isLocked: isLocked,
|
||||||
|
lockedByMe: lockedByMe,
|
||||||
|
isCommentPanelOpen: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleCommentPanel = () => {
|
||||||
|
this.setState({
|
||||||
|
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleStar = () => {
|
||||||
|
if (this.state.isStarred) {
|
||||||
|
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
||||||
|
this.setState({
|
||||||
|
isStarred: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
seafileAPI.starItem(repoID, filePath).then((res) => {
|
||||||
|
this.setState({
|
||||||
|
isStarred: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleLockFile = () => {
|
||||||
|
if (this.state.isLocked) {
|
||||||
|
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
||||||
|
this.setState({
|
||||||
|
isLocked: false,
|
||||||
|
lockedByMe: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
||||||
|
this.setState({
|
||||||
|
isLocked: true,
|
||||||
|
lockedByMe: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="h-100 d-flex flex-column">
|
||||||
|
<div className="file-view-header d-flex justify-content-between">
|
||||||
|
<FileInfo
|
||||||
|
isStarred={this.state.isStarred}
|
||||||
|
isLocked={this.state.isLocked}
|
||||||
|
toggleStar={this.toggleStar}
|
||||||
|
/>
|
||||||
|
<FileToolbar
|
||||||
|
isLocked={this.state.isLocked}
|
||||||
|
lockedByMe={this.state.lockedByMe}
|
||||||
|
toggleLockFile={this.toggleLockFile}
|
||||||
|
toggleCommentPanel={this.toggleCommentPanel}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="file-view-body flex-auto d-flex">
|
||||||
|
{this.props.content}
|
||||||
|
{this.state.isCommentPanelOpen &&
|
||||||
|
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enableWatermark) {
|
||||||
|
watermark.init({
|
||||||
|
watermark_txt: `${siteName} ${userNickName}`,
|
||||||
|
watermark_alpha: 0.075
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView.propTypes = propTypes;
|
||||||
|
|
||||||
|
export default FileView;
|
@@ -1,98 +1,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
import FileView from './components/file-view/file-view';
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { siteName } from './utils/constants';
|
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
import AudioPlayer from './components/audio-player';
|
import AudioPlayer from './components/audio-player';
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/audio-file-view.css';
|
import './css/audio-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
err, rawPath
|
||||||
// the following are only for this type of file view
|
|
||||||
rawPath
|
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
class ViewFileAudio extends React.Component {
|
class ViewFileAudio extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,13 +41,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileAudio />,
|
<ViewFileAudio />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,99 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
import { seafileAPI } from './utils/seafile-api';
|
||||||
import { siteName, gettext, mediaUrl} from './utils/constants';
|
import { gettext, mediaUrl} from './utils/constants';
|
||||||
import FileInfo from './components/file-view/file-info';
|
import FileView from './components/file-view/file-view';
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
import Loading from './components/loading';
|
import Loading from './components/loading';
|
||||||
import PDFViewer from './components/pdf-viewer';
|
import PDFViewer from './components/pdf-viewer';
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/pdf-file-view.css';
|
import './css/pdf-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
repoID, filePath, err,
|
||||||
// the following are only for this type of file view
|
|
||||||
commitID, fileType
|
commitID, fileType
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
class ViewFileDocument extends React.Component {
|
class ViewFileDocument extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,13 +106,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileDocument />,
|
<ViewFileDocument />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,20 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { Utils } from './utils/utils';
|
import { Utils } from './utils/utils';
|
||||||
import { gettext, siteRoot, siteName } from './utils/constants';
|
import { gettext, siteRoot } from './utils/constants';
|
||||||
import FileInfo from './components/file-view/file-info';
|
import FileView from './components/file-view/file-view';
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/image-file-view.css';
|
import './css/image-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
repoID, filePath, err,
|
||||||
// the following are only for image file view
|
|
||||||
fileName, previousImage, nextImage, rawPath
|
fileName, previousImage, nextImage, rawPath
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
@@ -27,16 +21,14 @@ if (nextImage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ViewFileImage extends React.Component {
|
class ViewFileImage extends React.Component {
|
||||||
|
render() {
|
||||||
constructor(props) {
|
return (
|
||||||
super(props);
|
<FileView content={<FileContent />} />
|
||||||
this.state = {
|
);
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FileContent extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
document.addEventListener('keydown', (e) => {
|
document.addEventListener('keydown', (e) => {
|
||||||
@@ -49,75 +41,6 @@ class ViewFileImage extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className="h-100 d-flex flex-column">
|
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FileContent extends React.Component {
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (err) {
|
if (err) {
|
||||||
return <FileViewTip />;
|
return <FileViewTip />;
|
||||||
@@ -136,13 +59,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileImage />,
|
<ViewFileImage />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,104 +1,22 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
import FileView from './components/file-view/file-view';
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { siteName } from './utils/constants';
|
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
import PDFViewer from './components/pdf-viewer';
|
import PDFViewer from './components/pdf-viewer';
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/pdf-file-view.css';
|
import './css/pdf-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const { err } = window.app.pageOptions;
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
|
||||||
// the following are only for this type of file view
|
|
||||||
rawPath
|
|
||||||
} = window.app.pageOptions;
|
|
||||||
|
|
||||||
class ViewFilePDF extends React.Component {
|
class ViewFilePDF extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileContent extends React.Component {
|
class FileContent extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (err) {
|
if (err) {
|
||||||
return <FileViewTip />;
|
return <FileViewTip />;
|
||||||
@@ -112,13 +30,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFilePDF />,
|
<ViewFilePDF />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,98 +1,22 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
import { seafileAPI } from './utils/seafile-api';
|
||||||
import { siteRoot, siteName, gettext } from './utils/constants';
|
import { siteRoot, gettext } from './utils/constants';
|
||||||
import FileInfo from './components/file-view/file-info';
|
import FileView from './components/file-view/file-view';
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
import Loading from './components/loading';
|
import Loading from './components/loading';
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/spreadsheet-file-view.css';
|
import './css/spreadsheet-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
repoID, filePath, err,
|
||||||
// the following are only for this type of file view
|
|
||||||
commitID, fileType, fileName
|
commitID, fileType, fileName
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
class ViewFileSpreadsheet extends React.Component {
|
class ViewFileSpreadsheet extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,13 +105,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileSpreadsheet />,
|
<ViewFileSpreadsheet />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,103 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
import FileView from './components/file-view/file-view';
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { siteName } from './utils/constants';
|
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/svg-file-view.css';
|
import './css/svg-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
err, fileName, rawPath
|
||||||
// the following are only for svg file view
|
|
||||||
fileName, rawPath
|
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
class ViewFileSVG extends React.Component {
|
class ViewFileSVG extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileContent extends React.Component {
|
class FileContent extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (err) {
|
if (err) {
|
||||||
return <FileViewTip />;
|
return <FileViewTip />;
|
||||||
@@ -110,13 +30,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileSVG />,
|
<ViewFileSVG />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,13 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { Utils } from './utils/utils';
|
import { Utils } from './utils/utils';
|
||||||
import { siteName } from './utils/constants';
|
import FileView from './components/file-view/file-view';
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
|
|
||||||
import CodeMirror from 'react-codemirror';
|
import CodeMirror from 'react-codemirror';
|
||||||
import 'codemirror/mode/javascript/javascript';
|
import 'codemirror/mode/javascript/javascript';
|
||||||
@@ -22,13 +17,10 @@ import 'codemirror/mode/python/python';
|
|||||||
import 'codemirror/mode/htmlmixed/htmlmixed';
|
import 'codemirror/mode/htmlmixed/htmlmixed';
|
||||||
import 'codemirror/lib/codemirror.css';
|
import 'codemirror/lib/codemirror.css';
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/text-file-view.css';
|
import './css/text-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
err, fileExt, fileContent
|
||||||
// the following are only for text file view
|
|
||||||
fileExt, fileContent
|
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@@ -43,88 +35,15 @@ const options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ViewFileText extends React.Component {
|
class ViewFileText extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileContent extends React.Component {
|
class FileContent extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return <FileViewTip />;
|
return <FileViewTip />;
|
||||||
}
|
}
|
||||||
@@ -140,13 +59,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileText />,
|
<ViewFileText />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,100 +1,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
import FileView from './components/file-view/file-view';
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { siteName } from './utils/constants';
|
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
|
|
||||||
import './css/file-view.css';
|
const { err } = window.app.pageOptions;
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
|
||||||
repoID, filePath, err, enableWatermark, userNickName
|
|
||||||
} = window.app.pageOptions;
|
|
||||||
|
|
||||||
class ViewFileUnknown extends React.Component {
|
class ViewFileUnknown extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileContent extends React.Component {
|
class FileContent extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (err) {
|
if (err) {
|
||||||
return <FileViewTip />;
|
return <FileViewTip />;
|
||||||
@@ -102,13 +21,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileUnknown />,
|
<ViewFileUnknown />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,98 +1,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
import FileView from './components/file-view/file-view';
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
|
||||||
import { siteName } from './utils/constants';
|
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
import VideoPlayer from './components/video-player';
|
import VideoPlayer from './components/video-player';
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/video-file-view.css';
|
import './css/video-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const {
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
err, rawPath
|
||||||
// the following are only for this type of file view
|
|
||||||
rawPath
|
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
class ViewFileVideo extends React.Component {
|
class ViewFileVideo extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,13 +41,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileVideo />,
|
<ViewFileVideo />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
@@ -1,103 +1,22 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import watermark from 'watermark-dom';
|
import { siteRoot } from './utils/constants';
|
||||||
import { seafileAPI } from './utils/seafile-api';
|
import FileView from './components/file-view/file-view';
|
||||||
import { siteRoot, siteName } from './utils/constants';
|
|
||||||
import FileInfo from './components/file-view/file-info';
|
|
||||||
import FileToolbar from './components/file-view/file-toolbar';
|
|
||||||
import FileViewTip from './components/file-view/file-view-tip';
|
import FileViewTip from './components/file-view/file-view-tip';
|
||||||
import CommentPanel from './components/file-view/comment-panel';
|
|
||||||
|
|
||||||
import './css/file-view.css';
|
|
||||||
import './css/image-file-view.css';
|
import './css/image-file-view.css';
|
||||||
|
|
||||||
const { isStarred, isLocked, lockedByMe,
|
const { err, fileName, xmindImageSrc } = window.app.pageOptions;
|
||||||
repoID, filePath, err, enableWatermark, userNickName,
|
|
||||||
// the following are only for xmind file view
|
|
||||||
fileName, xmindImageSrc
|
|
||||||
} = window.app.pageOptions;
|
|
||||||
|
|
||||||
class ViewFileXmind extends React.Component {
|
class ViewFileXmind extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isStarred: isStarred,
|
|
||||||
isLocked: isLocked,
|
|
||||||
lockedByMe: lockedByMe,
|
|
||||||
isCommentPanelOpen: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCommentPanel = () => {
|
|
||||||
this.setState({
|
|
||||||
isCommentPanelOpen: !this.state.isCommentPanelOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleStar = () => {
|
|
||||||
if (this.state.isStarred) {
|
|
||||||
seafileAPI.unStarItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.starItem(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isStarred: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLockFile = () => {
|
|
||||||
if (this.state.isLocked) {
|
|
||||||
seafileAPI.unlockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: false,
|
|
||||||
lockedByMe: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
seafileAPI.lockfile(repoID, filePath).then((res) => {
|
|
||||||
this.setState({
|
|
||||||
isLocked: true,
|
|
||||||
lockedByMe: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="h-100 d-flex flex-column">
|
<FileView content={<FileContent />} />
|
||||||
<div className="file-view-header d-flex justify-content-between">
|
|
||||||
<FileInfo
|
|
||||||
isStarred={this.state.isStarred}
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
toggleStar={this.toggleStar}
|
|
||||||
/>
|
|
||||||
<FileToolbar
|
|
||||||
isLocked={this.state.isLocked}
|
|
||||||
lockedByMe={this.state.lockedByMe}
|
|
||||||
toggleLockFile={this.toggleLockFile}
|
|
||||||
toggleCommentPanel={this.toggleCommentPanel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="file-view-body flex-auto d-flex">
|
|
||||||
<FileContent />
|
|
||||||
{this.state.isCommentPanelOpen &&
|
|
||||||
<CommentPanel toggleCommentPanel={this.toggleCommentPanel} />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileContent extends React.Component {
|
class FileContent extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (err) {
|
if (err) {
|
||||||
return <FileViewTip />;
|
return <FileViewTip />;
|
||||||
@@ -110,13 +29,6 @@ class FileContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableWatermark) {
|
|
||||||
watermark.init({
|
|
||||||
watermark_txt: `${siteName} ${userNickName}`,
|
|
||||||
watermark_alpha: 0.075
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render (
|
ReactDOM.render (
|
||||||
<ViewFileXmind />,
|
<ViewFileXmind />,
|
||||||
document.getElementById('wrapper')
|
document.getElementById('wrapper')
|
||||||
|
Reference in New Issue
Block a user