1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 07:08:55 +00:00

Merge branch '7.0'

This commit is contained in:
plt
2019-06-28 17:49:04 +08:00
23 changed files with 120 additions and 13 deletions

View File

@@ -76,7 +76,20 @@ class App extends Component {
}
}
navigateClientUrlToLib = () =>{
if(window.location.hash && window.location.hash.indexOf('common/lib') != -1){
let splitUrlArray = window.location.hash.split('/');
let repoID = splitUrlArray[splitUrlArray.length - 2];
let url = siteRoot + 'library/' + repoID + '/';
navigate(url, {repalce: true});
}
}
componentDidMount() {
// url from client e.g. http://127.0.0.1:8000/#common/lib/34e7fb92-e91d-499d-bcde-c30ea8af9828/
// navigate to library page http://127.0.0.1:8000/library/34e7fb92-e91d-499d-bcde-c30ea8af9828/
this.navigateClientUrlToLib();
// e.g. from http://127.0.0.1:8000/drafts/reviews/
// get reviews
// TODO: need refactor later

View File

@@ -86,7 +86,7 @@ class DirPath extends React.Component {
<span className="path-split">/</span>
</Fragment>
)}
{currentPath === '/' ?
{(currentPath === '/' || currentPath === '') ?
<span>{repoName}</span>:
<a className="path-link" data-path="/" onClick={this.onPathClick}>{repoName}</a>
}

View File

@@ -1,5 +1,6 @@
import React from 'react';
import { gettext, siteRoot } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import toaster from '../toast';
const { avatarURL, csrfToken } = window.app.pageOptions;
@@ -50,7 +51,25 @@ class UserAvatarForm extends React.Component {
return false;
}
this.form.current.submit();
//this.form.current.submit();
seafileAPI.updateUserAvatar(file, 160).then((res) => {
this.setState({
avatarSrc: res.data.avatar_url
});
toaster.success(gettext('Success'));
}).catch((error) => {
let errorMsg = '';
if (error.response) {
if (error.response.data && error.response.data['error_msg']) {
errorMsg = error.response.data['error_msg'];
} else {
errorMsg = gettext('Error');
}
} else {
errorMsg = gettext('Please check the network.');
}
toaster.danger(errorMsg);
});
}
openFileInput = () => {
@@ -75,7 +94,7 @@ class UserAvatarForm extends React.Component {
<input type="hidden" name="csrfmiddlewaretoken" value={csrfToken} />
<label className="col-sm-1 col-form-label">{gettext('Avatar:')}</label>
<div className="col-auto position-relative" onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
<img src={avatarURL} width="80" height="80" alt="" className="user-avatar" />
<img src={this.state.avatarSrc} width="80" height="80" alt="" className="user-avatar" />
<input type="file" name="avatar" className="d-none" onChange={this.fileInputChange} ref={this.fileInput} />
<span className={`avatar-edit fas fa-edit ${!this.state.isEditShown && 'd-none'}`} onClick={this.openFileInput}></span>
</div>

View File

@@ -86,6 +86,30 @@
background: #ff0;
box-shadow: 0px 2px 10px #ff0;
}
.annotationLayer .textAnnotation img {
position: absolute;
cursor: pointer;
}
.annotationLayer .popupWrapper {
position: absolute;
width: 20em;
}
.annotationLayer .popup {
position: absolute;
z-index: 200;
max-width: 20em;
background-color: #FFFF99;
box-shadow: 0px 2px 5px #333;
border-radius: 2px;
padding: 0.6em;
margin-left: 5px;
cursor: pointer;
font: message-box;
word-wrap: break-word;
}
/* annotationLayer ends */
#fileInput {
display:none;

View File

@@ -9,6 +9,8 @@ class Group {
this.parent_group_id = object.parent_group_id;
this.wiki_enabled = object.wiki_enabled;
this.repos = object.repos || [];
this.group_quota = object.group_quota;
this.group_quota_usage = object.group_quota_usage;
}
}

View File

@@ -388,7 +388,10 @@ class GroupView extends React.Component {
<span className="path-split">/</span>
<span>{currentGroup.name}</span>
{currentGroup.parent_group_id !== 0 && (
<span className="department-group-icon fas fa-building" title={gettext('This is a special group representing a department.')}></span>
<Fragment>
<span className="department-group-icon fas fa-building" title={gettext('This is a special group representing a department.')}></span>
<span>{' '}{''}{gettext('Used:')}{' '}{Utils.bytesToSize(currentGroup.group_quota_usage)}{'/'}{Utils.bytesToSize(currentGroup.group_quota)}{''}</span>
</Fragment>
)}
</div>
<div className="path-tool">

View File

@@ -9,7 +9,7 @@ import './css/image-file-view.css';
const {
repoID, filePath, err,
fileName, previousImage, nextImage, rawPath
fileName, previousImage, nextImage, rawPath, thumbnailSizeForOriginal,
} = window.app.pageOptions;
let previousImageUrl, nextImageUrl;
@@ -30,6 +30,14 @@ class ViewFileImage extends React.Component {
class FileContent extends React.Component {
constructor(props) {
super(props);
this.state = {
thumbnailError: false,
};
this.thumbnailSuffixList = ['tiff', 'eps', 'psd'];
}
componentDidMount() {
document.addEventListener('keydown', (e) => {
if (previousImage && e.keyCode == 37) { // press '<-'
@@ -41,10 +49,20 @@ class FileContent extends React.Component {
});
}
handleError = () => {
this.setState({
thumbnailError: true
});
};
render() {
if (err) {
if (err || this.state.thumbnailError) {
return <FileViewTip />;
}
let thumbnailUrl = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${Utils.encodePath(filePath)}`;
let imageSuffix = fileName.split('.').pop();
let isPreviewThumbnail = this.thumbnailSuffixList.includes(imageSuffix);
return (
<div className="file-view-content flex-1 image-file-view">
{previousImage && (
@@ -53,7 +71,10 @@ class FileContent extends React.Component {
{nextImage && (
<a href={nextImageUrl} id="img-next" title={gettext('you can also press →')}><span className="fas fa-chevron-right"></span></a>
)}
<img src={rawPath} alt={fileName} id="image-view" />
{isPreviewThumbnail ?
<img src={thumbnailUrl} alt={fileName} id="image-view" onError={this.handleError}/> :
<img src={rawPath} alt={fileName} id="image-view"/>
}
</div>
);
}