mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
@@ -134,6 +134,13 @@ class DirentListView extends React.Component {
|
|||||||
this.props.sortItems(sortBy, sortOrder);
|
this.props.sortItems(sortBy, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortBySize = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const sortBy = 'size';
|
||||||
|
const sortOrder = this.props.sortOrder == 'asc' ? 'desc' : 'asc';
|
||||||
|
this.props.sortItems(sortBy, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
// for image popup
|
// for image popup
|
||||||
prepareImageItem = (item) => {
|
prepareImageItem = (item) => {
|
||||||
const useThumbnail = !this.repoEncrypted;
|
const useThumbnail = !this.repoEncrypted;
|
||||||
@@ -580,6 +587,7 @@ class DirentListView extends React.Component {
|
|||||||
// sort
|
// sort
|
||||||
const sortByName = sortBy == 'name';
|
const sortByName = sortBy == 'name';
|
||||||
const sortByTime = sortBy == 'time';
|
const sortByTime = sortBy == 'time';
|
||||||
|
const sortBySize = sortBy == 'size';
|
||||||
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -604,7 +612,7 @@ class DirentListView extends React.Component {
|
|||||||
<th width="39%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
|
<th width="39%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
|
||||||
<th width="6%">{/*tag */}</th>
|
<th width="6%">{/*tag */}</th>
|
||||||
<th width="18%">{/*operation */}</th>
|
<th width="18%">{/*operation */}</th>
|
||||||
<th width="11%">{gettext('Size')}</th>
|
<th width="11%"><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {sortBySize && sortIcon}</a></th>
|
||||||
<th width="15%"><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
|
<th width="15%"><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@@ -42,10 +42,18 @@ class SharedRepoListView extends React.Component {
|
|||||||
this.props.sortItems(sortBy, sortOrder);
|
this.props.sortItems(sortBy, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortBySize = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const sortBy = 'size';
|
||||||
|
const sortOrder = this.props.sortOrder == 'asc' ? 'desc' : 'asc';
|
||||||
|
this.props.sortItems(sortBy, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
getSortMetaData = () => {
|
getSortMetaData = () => {
|
||||||
return {
|
return {
|
||||||
sortByName: this.props.sortBy == 'name',
|
sortByName: this.props.sortBy == 'name',
|
||||||
sortByTime: this.props.sortBy == 'time',
|
sortByTime: this.props.sortBy == 'time',
|
||||||
|
sortBySize: this.props.sortBy == 'size',
|
||||||
sortIcon: this.props.sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>
|
sortIcon: this.props.sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -98,7 +106,7 @@ class SharedRepoListView extends React.Component {
|
|||||||
renderPCUI = () => {
|
renderPCUI = () => {
|
||||||
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
|
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
|
||||||
|
|
||||||
const { sortByName, sortByTime, sortIcon } = this.getSortMetaData();
|
const { sortByName, sortByTime, sortBySize, sortIcon } = this.getSortMetaData();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className={isShowTableThread ? '' : 'table-thead-hidden'}>
|
<table className={isShowTableThread ? '' : 'table-thead-hidden'}>
|
||||||
@@ -108,7 +116,7 @@ class SharedRepoListView extends React.Component {
|
|||||||
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
|
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
|
||||||
<th width="36%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
|
<th width="36%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
|
||||||
<th width="12%"><span className="sr-only">{gettext('Actions')}</span></th>
|
<th width="12%"><span className="sr-only">{gettext('Actions')}</span></th>
|
||||||
<th width={'14%'}>{gettext('Size')}</th>
|
<th width={'14%'}><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {sortBySize && sortIcon}</a></th>
|
||||||
<th width={'14%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
|
<th width={'14%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
|
||||||
<th width="16%">{gettext('Owner')}</th>
|
<th width="16%">{gettext('Owner')}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -13,6 +13,7 @@ class Dirent {
|
|||||||
this.isSelected = false; // is check or not
|
this.isSelected = false; // is check or not
|
||||||
this.starred = json.starred || false;
|
this.starred = json.starred || false;
|
||||||
if (json.type === 'file') {
|
if (json.type === 'file') {
|
||||||
|
this.size_original = json.size;
|
||||||
this.size = Utils.bytesToSize(json.size);
|
this.size = Utils.bytesToSize(json.size);
|
||||||
this.is_locked = json.is_locked || false;
|
this.is_locked = json.is_locked || false;
|
||||||
this.lock_time = json.lock_time || '';
|
this.lock_time = json.lock_time || '';
|
||||||
|
@@ -5,6 +5,7 @@ class Repo {
|
|||||||
this.repo_id = object.repo_id;
|
this.repo_id = object.repo_id;
|
||||||
this.repo_name = object.repo_name;
|
this.repo_name = object.repo_name;
|
||||||
this.permission = object.permission;
|
this.permission = object.permission;
|
||||||
|
this.size_original = object.size;
|
||||||
this.size = Utils.bytesToSize(object.size);
|
this.size = Utils.bytesToSize(object.size);
|
||||||
this.owner_name = object.owner_name;
|
this.owner_name = object.owner_name;
|
||||||
this.owner_email = object.owner_email;
|
this.owner_email = object.owner_email;
|
||||||
|
@@ -44,7 +44,7 @@ class GroupView extends React.Component {
|
|||||||
currentRepo: null,
|
currentRepo: null,
|
||||||
isStaff: false,
|
isStaff: false,
|
||||||
isOwner: false,
|
isOwner: false,
|
||||||
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time'
|
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or 'size'
|
||||||
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
||||||
repoList: [],
|
repoList: [],
|
||||||
libraryType: 'group',
|
libraryType: 'group',
|
||||||
|
@@ -65,7 +65,7 @@ class LibContentView extends React.Component {
|
|||||||
isDirentListLoading: true,
|
isDirentListLoading: true,
|
||||||
direntList: [],
|
direntList: [],
|
||||||
isDirentSelected: false,
|
isDirentSelected: false,
|
||||||
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time'
|
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or 'size'
|
||||||
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
||||||
isAllDirentSelected: false,
|
isAllDirentSelected: false,
|
||||||
dirID: '', // for update dir list
|
dirID: '', // for update dir list
|
||||||
|
@@ -24,7 +24,7 @@ class MyLibraries extends Component {
|
|||||||
isLoading: true,
|
isLoading: true,
|
||||||
repoList: [],
|
repoList: [],
|
||||||
isShowDetails: false,
|
isShowDetails: false,
|
||||||
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time'
|
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or 'size'
|
||||||
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -46,6 +46,13 @@ class MylibRepoListView extends React.Component {
|
|||||||
this.props.sortRepoList(sortBy, sortOrder);
|
this.props.sortRepoList(sortBy, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortBySize = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const sortBy = 'size';
|
||||||
|
const sortOrder = this.props.sortOrder == 'asc' ? 'desc' : 'asc';
|
||||||
|
this.props.sortRepoList(sortBy, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
renderRepoListView = () => {
|
renderRepoListView = () => {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
@@ -79,7 +86,7 @@ class MylibRepoListView extends React.Component {
|
|||||||
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
|
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
|
||||||
<th width="38%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {this.props.sortBy === 'name' && sortIcon}</a></th>
|
<th width="38%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {this.props.sortBy === 'name' && sortIcon}</a></th>
|
||||||
<th width="14%"><span className="sr-only">{gettext('Actions')}</span></th>
|
<th width="14%"><span className="sr-only">{gettext('Actions')}</span></th>
|
||||||
<th width={showStorageBackend ? '15%' : '20%'}>{gettext('Size')}</th>
|
<th width={showStorageBackend ? '15%' : '20%'}><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {this.props.sortBy === 'size' && sortIcon}</a></th>
|
||||||
{showStorageBackend ? <th width="10%">{gettext('Storage backend')}</th> : null}
|
{showStorageBackend ? <th width="10%">{gettext('Storage backend')}</th> : null}
|
||||||
<th width={showStorageBackend ? '15%' : '20%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {this.props.sortBy === 'time' && sortIcon}</a></th>
|
<th width={showStorageBackend ? '15%' : '20%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {this.props.sortBy === 'time' && sortIcon}</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -27,6 +27,13 @@ class Content extends Component {
|
|||||||
this.props.sortItems(sortBy, sortOrder);
|
this.props.sortItems(sortBy, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortBySize = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const sortBy = 'size';
|
||||||
|
const sortOrder = this.props.sortOrder == 'asc' ? 'desc' : 'asc';
|
||||||
|
this.props.sortItems(sortBy, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading, errorMsg, items, sortBy, sortOrder } = this.props;
|
const { loading, errorMsg, items, sortBy, sortOrder } = this.props;
|
||||||
|
|
||||||
@@ -45,6 +52,7 @@ class Content extends Component {
|
|||||||
// sort
|
// sort
|
||||||
const sortByName = sortBy == 'name';
|
const sortByName = sortBy == 'name';
|
||||||
const sortByTime = sortBy == 'time';
|
const sortByTime = sortBy == 'time';
|
||||||
|
const sortBySize = sortBy == 'size';
|
||||||
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
||||||
|
|
||||||
const desktopThead = (
|
const desktopThead = (
|
||||||
@@ -54,7 +62,7 @@ class Content extends Component {
|
|||||||
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
|
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
|
||||||
<th width="34%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
|
<th width="34%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
|
||||||
<th width="10%"><span className="sr-only">{gettext('Actions')}</span></th>
|
<th width="10%"><span className="sr-only">{gettext('Actions')}</span></th>
|
||||||
<th width="14%">{gettext('Size')}</th>
|
<th width="14%"><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {sortBySize && sortIcon}</a></th>
|
||||||
<th width="18%"><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
|
<th width="18%"><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
|
||||||
<th width="16%">{gettext('Owner')}</th>
|
<th width="16%">{gettext('Owner')}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -293,7 +301,7 @@ class SharedLibraries extends Component {
|
|||||||
loading: true,
|
loading: true,
|
||||||
errorMsg: '',
|
errorMsg: '',
|
||||||
items: [],
|
items: [],
|
||||||
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time'
|
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or 'size'
|
||||||
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ class PublicSharedView extends React.Component {
|
|||||||
errMessage: '',
|
errMessage: '',
|
||||||
emptyTip: '',
|
emptyTip: '',
|
||||||
repoList: [],
|
repoList: [],
|
||||||
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time'
|
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or 'size'
|
||||||
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
||||||
libraryType: 'public',
|
libraryType: 'public',
|
||||||
isCreateMenuShow: false,
|
isCreateMenuShow: false,
|
||||||
|
@@ -629,6 +629,25 @@ export const Utils = {
|
|||||||
return a.last_modified < b.last_modified ? 1 : -1;
|
return a.last_modified < b.last_modified ? 1 : -1;
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
case 'size-asc':
|
||||||
|
comparator = function(a, b) {
|
||||||
|
if (a.size === b.size) {
|
||||||
|
let result = _this.compareTwoWord(a.repo_name, b.repo_name);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return a.size_original < b.size_original ? -1 : 1;
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'size-desc':
|
||||||
|
comparator = function(a, b) {
|
||||||
|
if (a.size === b.size) {
|
||||||
|
let result = _this.compareTwoWord(a.repo_name, b.repo_name);
|
||||||
|
return -result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.size_original < b.size_original ? 1 : -1;
|
||||||
|
};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
repos.sort(comparator);
|
repos.sort(comparator);
|
||||||
@@ -662,6 +681,24 @@ export const Utils = {
|
|||||||
return a.mtime < b.mtime ? 1 : -1;
|
return a.mtime < b.mtime ? 1 : -1;
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
case 'size-asc':
|
||||||
|
comparator = function(a, b) {
|
||||||
|
if (a.type == 'dir' && b.type == 'dir') {
|
||||||
|
let result = _this.compareTwoWord(a.name, b.name);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return a.size_original < b.size_original ? -1 : 1;
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'size-desc':
|
||||||
|
comparator = function(a, b) {
|
||||||
|
if (a.type == 'dir' && b.type == 'dir') {
|
||||||
|
let result = _this.compareTwoWord(a.name, b.name);
|
||||||
|
return -result;
|
||||||
|
}
|
||||||
|
return a.size_original < b.size_original ? 1 : -1;
|
||||||
|
};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.sort((a, b) => {
|
items.sort((a, b) => {
|
||||||
|
Reference in New Issue
Block a user