mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 07:01:12 +00:00
update
This commit is contained in:
@@ -2,12 +2,12 @@ define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/models/library-dirent'
|
||||
], function(_, Backbone, Common, LibraryDirentModel) {
|
||||
'sysadmin-app/models/dirent'
|
||||
], function(_, Backbone, Common, DirentModel) {
|
||||
'use strict';
|
||||
|
||||
var LibraryDirentCollection = Backbone.Collection.extend({
|
||||
model: LibraryDirentModel,
|
||||
var DirentCollection = Backbone.Collection.extend({
|
||||
model: DirentModel,
|
||||
parse: function (data) {
|
||||
this.repo_name = data.repo_name;
|
||||
this.repo_id = data.repo_id;
|
||||
@@ -20,5 +20,5 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
return LibraryDirentCollection;
|
||||
return DirentCollection;
|
||||
});
|
@@ -2,12 +2,12 @@ define([
|
||||
'underscore',
|
||||
'backbone.paginator',
|
||||
'common',
|
||||
'sysadmin-app/models/library'
|
||||
], function(_, BackbonePaginator, Common, LibraryModel) {
|
||||
'sysadmin-app/models/repo'
|
||||
], function(_, BackbonePaginator, Common, RepoModel) {
|
||||
'use strict';
|
||||
|
||||
var LibraryCollection = Backbone.PageableCollection.extend({
|
||||
model: LibraryModel,
|
||||
var RepoCollection = Backbone.PageableCollection.extend({
|
||||
model: RepoModel,
|
||||
state: {pageSize: 100},
|
||||
parseState: function(data) {
|
||||
return {hasNextPage: data[0].has_next_page, current_page: data[0].current_page};
|
||||
@@ -20,5 +20,5 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
return LibraryCollection;
|
||||
return RepoCollection;
|
||||
});
|
@@ -1,17 +0,0 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/models/trash-library'
|
||||
], function(_, Backbone, Common, TrashLibraryModel) {
|
||||
'use strict';
|
||||
|
||||
var TrashLibraryCollection = Backbone.Collection.extend({
|
||||
model: TrashLibraryModel,
|
||||
url: function () {
|
||||
return Common.getUrl({name: 'admin-trash-libraries'});
|
||||
}
|
||||
});
|
||||
|
||||
return TrashLibraryCollection;
|
||||
});
|
17
static/scripts/sysadmin-app/collection/trash-repos.js
Normal file
17
static/scripts/sysadmin-app/collection/trash-repos.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/models/trash-repo'
|
||||
], function(_, Backbone, Common, TrashRepoModel) {
|
||||
'use strict';
|
||||
|
||||
var TrashRepoCollection = Backbone.Collection.extend({
|
||||
model: TrashRepoModel,
|
||||
url: function () {
|
||||
return Common.getUrl({name: 'admin-trash-libraries'});
|
||||
}
|
||||
});
|
||||
|
||||
return TrashRepoCollection;
|
||||
});
|
@@ -5,7 +5,7 @@ define([
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var LibraryDirentModel = Backbone.Model.extend({
|
||||
var DirentModel = Backbone.Model.extend({
|
||||
|
||||
// get the absolute path within the library
|
||||
getPath: function() {
|
||||
@@ -50,5 +50,5 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
return LibraryDirentModel;
|
||||
return DirentModel;
|
||||
});
|
@@ -1,11 +0,0 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var LibraryModel = Backbone.Model.extend({});
|
||||
|
||||
return LibraryModel;
|
||||
});
|
27
static/scripts/sysadmin-app/models/repo.js
Normal file
27
static/scripts/sysadmin-app/models/repo.js
Normal file
@@ -0,0 +1,27 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var RepoModel = Backbone.Model.extend({
|
||||
getIconUrl: function(size) {
|
||||
var is_encrypted = this.get('encrypted');
|
||||
return Common.getLibIconUrl(is_encrypted, false, size);
|
||||
},
|
||||
|
||||
getIconTitle: function() {
|
||||
var icon_title = '';
|
||||
if (this.get('encrypted')) {
|
||||
icon_title = gettext("Encrypted library");
|
||||
} else {
|
||||
icon_title = gettext("Read-Write library");
|
||||
}
|
||||
|
||||
return icon_title;
|
||||
}
|
||||
});
|
||||
|
||||
return RepoModel;
|
||||
});
|
@@ -1,11 +0,0 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var SystemLibrary = Backbone.Model.extend({});
|
||||
|
||||
return SystemLibrary;
|
||||
});
|
@@ -5,7 +5,7 @@ define([
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var TrashLibrary = Backbone.Model.extend({});
|
||||
var SystemRepo = Backbone.Model.extend({});
|
||||
|
||||
return TrashLibrary;
|
||||
return SystemRepo;
|
||||
});
|
19
static/scripts/sysadmin-app/models/trash-repo.js
Normal file
19
static/scripts/sysadmin-app/models/trash-repo.js
Normal file
@@ -0,0 +1,19 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var TrashRepo = Backbone.Model.extend({
|
||||
getIconUrl: function(size) {
|
||||
return Common.getLibIconUrl(false, false, size);
|
||||
},
|
||||
|
||||
getIconTitle: function() {
|
||||
return gettext("Read-Write library");
|
||||
}
|
||||
});
|
||||
|
||||
return TrashRepo;
|
||||
});
|
@@ -8,15 +8,15 @@ define([
|
||||
'sysadmin-app/views/desktop-devices',
|
||||
'sysadmin-app/views/mobile-devices',
|
||||
'sysadmin-app/views/device-errors',
|
||||
'sysadmin-app/views/libraries',
|
||||
'sysadmin-app/views/library-dir',
|
||||
'sysadmin-app/views/system-library',
|
||||
'sysadmin-app/views/trash-libraries',
|
||||
'sysadmin-app/views/repos',
|
||||
'sysadmin-app/views/dir',
|
||||
'sysadmin-app/views/system-repo',
|
||||
'sysadmin-app/views/trash-repos',
|
||||
'app/views/account'
|
||||
], function($, Backbone, Common, SideNavView, DashboardView,
|
||||
DesktopDevicesView, MobileDevicesView, DeviceErrorsView,
|
||||
LibrariesView, LibraryDirView, SystemLibrariesView,
|
||||
TrashLibrariesView, AccountView) {
|
||||
ReposView, DirView, SystemReposView,
|
||||
TrashReposView, AccountView) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -50,10 +50,10 @@ define([
|
||||
this.desktopDevicesView = new DesktopDevicesView();
|
||||
this.mobileDevicesView = new MobileDevicesView();
|
||||
this.deviceErrorsView = new DeviceErrorsView();
|
||||
this.librariesView = new LibrariesView();
|
||||
this.systemLibrariesView = new SystemLibrariesView();
|
||||
this.trashLibrariesView = new TrashLibrariesView();
|
||||
this.libraryDirView = new LibraryDirView();
|
||||
this.reposView = new ReposView();
|
||||
this.systemReposView = new SystemReposView();
|
||||
this.trashReposView = new TrashReposView();
|
||||
this.dirView = new DirView();
|
||||
|
||||
app.ui.accountView = this.accountView = new AccountView();
|
||||
|
||||
@@ -115,9 +115,9 @@ define([
|
||||
} else {
|
||||
var current_page = null;
|
||||
}
|
||||
this.switchCurrentView(this.librariesView);
|
||||
this.switchCurrentView(this.reposView);
|
||||
this.sideNavView.setCurTab('libraries');
|
||||
this.librariesView.show({'current_page': current_page});
|
||||
this.reposView.show({'current_page': current_page});
|
||||
},
|
||||
|
||||
showLibraryDir: function(repo_id, path) {
|
||||
@@ -126,21 +126,21 @@ define([
|
||||
} else {
|
||||
path = '/';
|
||||
}
|
||||
this.switchCurrentView(this.libraryDirView);
|
||||
this.libraryDirView.show(repo_id, path);
|
||||
this.switchCurrentView(this.dirView);
|
||||
this.dirView.show(repo_id, path);
|
||||
this.sideNavView.setCurTab('libraries');
|
||||
},
|
||||
|
||||
showSystemLibrary: function() {
|
||||
this.switchCurrentView(this.systemLibrariesView);
|
||||
this.switchCurrentView(this.systemReposView);
|
||||
this.sideNavView.setCurTab('libraries');
|
||||
this.systemLibrariesView.show();
|
||||
this.systemReposView.show();
|
||||
},
|
||||
|
||||
showTrashLibraries: function() {
|
||||
this.switchCurrentView(this.trashLibrariesView);
|
||||
this.switchCurrentView(this.trashReposView);
|
||||
this.sideNavView.setCurTab('libraries');
|
||||
this.trashLibrariesView.show();
|
||||
this.trashReposView.show();
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -5,8 +5,8 @@ define([
|
||||
'common',
|
||||
'moment',
|
||||
'app/views/fileupload',
|
||||
'sysadmin-app/views/library-dirent',
|
||||
'sysadmin-app/collection/library-dirents'
|
||||
'sysadmin-app/views/dirent',
|
||||
'sysadmin-app/collection/dirents'
|
||||
], function($, _, Backbone, Common, Moment, FileUploadView,
|
||||
DirentView, DirentCollection) {
|
||||
'use strict';
|
@@ -8,7 +8,7 @@ define([
|
||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||
'use strict';
|
||||
|
||||
var LibraryDirentView = HLItemView.extend({
|
||||
var DirentView = HLItemView.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template($('#dirent-item-tmpl').html()),
|
||||
@@ -76,5 +76,5 @@ define([
|
||||
|
||||
});
|
||||
|
||||
return LibraryDirentView;
|
||||
return DirentView;
|
||||
});
|
@@ -11,7 +11,7 @@ define([
|
||||
Select2, HLItemView) {
|
||||
'use strict';
|
||||
|
||||
var LibraryView = HLItemView.extend({
|
||||
var RepoView = HLItemView.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template($('#library-item-tmpl').html()),
|
||||
@@ -107,8 +107,12 @@ define([
|
||||
|
||||
render: function() {
|
||||
var data = this.model.toJSON(),
|
||||
icon_size = Common.isHiDPI() ? 96 : 24,
|
||||
icon_url = this.model.getIconUrl(icon_size),
|
||||
last_accessed = Moment(data['last_accessed']);
|
||||
|
||||
data['icon_url'] = icon_url;
|
||||
data['icon_title'] = this.model.getIconTitle();
|
||||
data['enable_sys_admin_view_repo'] = app.pageOptions.enable_sys_admin_view_repo;
|
||||
data['is_pro'] = app.pageOptions.is_pro;
|
||||
data['time'] = last_accessed.format('LLLL');
|
||||
@@ -121,5 +125,5 @@ define([
|
||||
|
||||
});
|
||||
|
||||
return LibraryView;
|
||||
return RepoView;
|
||||
});
|
@@ -4,26 +4,26 @@ define([
|
||||
'backbone',
|
||||
'common',
|
||||
'moment',
|
||||
'sysadmin-app/views/library',
|
||||
'sysadmin-app/collection/libraries'
|
||||
], function($, _, Backbone, Common, Moment, LibraryView, LibraryCollection) {
|
||||
'sysadmin-app/views/repo',
|
||||
'sysadmin-app/collection/repos'
|
||||
], function($, _, Backbone, Common, Moment, RepoView, RepoCollection) {
|
||||
'use strict';
|
||||
|
||||
var LibrariesView = Backbone.View.extend({
|
||||
var ReposView = Backbone.View.extend({
|
||||
|
||||
id: 'admin-libraries',
|
||||
id: 'libraries',
|
||||
|
||||
template: _.template($("#libraries-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.libraryCollection = new LibraryCollection();
|
||||
this.listenTo(this.libraryCollection, 'add', this.addOne);
|
||||
this.listenTo(this.libraryCollection, 'reset', this.reset);
|
||||
this.repoCollection = new RepoCollection();
|
||||
this.listenTo(this.repoCollection, 'add', this.addOne);
|
||||
this.listenTo(this.repoCollection, 'reset', this.reset);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data = {'cur_tab': 'all',};
|
||||
var data = {'cur_tab': 'all'};
|
||||
this.$el.html(this.template(data));
|
||||
this.$table = this.$('table');
|
||||
this.$tableBody = $('tbody', this.$table);
|
||||
@@ -49,9 +49,9 @@ define([
|
||||
|
||||
getNextPage: function() {
|
||||
this.initPage();
|
||||
var current_page = this.libraryCollection.state.current_page;
|
||||
if (this.libraryCollection.state.hasNextPage) {
|
||||
this.libraryCollection.getPage(current_page + 1, {
|
||||
var current_page = this.repoCollection.state.current_page;
|
||||
if (this.repoCollection.state.hasNextPage) {
|
||||
this.repoCollection.getPage(current_page + 1, {
|
||||
reset: true
|
||||
});
|
||||
}
|
||||
@@ -61,9 +61,9 @@ define([
|
||||
|
||||
getPreviousPage: function() {
|
||||
this.initPage();
|
||||
var current_page = this.libraryCollection.state.current_page;
|
||||
var current_page = this.repoCollection.state.current_page;
|
||||
if ( current_page > 1) {
|
||||
this.libraryCollection.getPage(current_page - 1, {
|
||||
this.repoCollection.getPage(current_page - 1, {
|
||||
reset: true
|
||||
});
|
||||
}
|
||||
@@ -89,7 +89,7 @@ define([
|
||||
var _this = this,
|
||||
current_page = this.option.current_page || 1;
|
||||
|
||||
this.libraryCollection.fetch({
|
||||
this.repoCollection.fetch({
|
||||
data: {'page': current_page},
|
||||
cache: false, // for IE
|
||||
reset: true,
|
||||
@@ -110,13 +110,13 @@ define([
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
var length = this.libraryCollection.length,
|
||||
current_page = this.libraryCollection.state.current_page;
|
||||
var length = this.repoCollection.length,
|
||||
current_page = this.repoCollection.state.current_page;
|
||||
|
||||
this.$loadingTip.hide();
|
||||
|
||||
if (length > 0) {
|
||||
this.libraryCollection.each(this.addOne, this);
|
||||
this.repoCollection.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
this.renderPaginator();
|
||||
} else {
|
||||
@@ -127,13 +127,13 @@ define([
|
||||
},
|
||||
|
||||
renderPaginator: function() {
|
||||
if (this.libraryCollection.state.hasNextPage) {
|
||||
if (this.repoCollection.state.hasNextPage) {
|
||||
this.$jsNext.show();
|
||||
} else {
|
||||
this.$jsNext.hide();
|
||||
}
|
||||
|
||||
var current_page = this.libraryCollection.state.current_page;
|
||||
var current_page = this.repoCollection.state.current_page;
|
||||
if (current_page > 1) {
|
||||
this.$jsPrevious.show();
|
||||
} else {
|
||||
@@ -142,11 +142,11 @@ define([
|
||||
},
|
||||
|
||||
addOne: function(library) {
|
||||
var view = new LibraryView({model: library});
|
||||
var view = new RepoView({model: library});
|
||||
this.$tableBody.append(view.render().el);
|
||||
}
|
||||
});
|
||||
|
||||
return LibrariesView;
|
||||
return ReposView;
|
||||
|
||||
});
|
@@ -3,19 +3,19 @@ define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/models/system-library'
|
||||
], function($, _, Backbone, Common, SystemLibrary) {
|
||||
'sysadmin-app/models/system-repo'
|
||||
], function($, _, Backbone, Common, SystemRepo) {
|
||||
'use strict';
|
||||
|
||||
var SystemLibraryView = Backbone.View.extend({
|
||||
var SystemRepoView = Backbone.View.extend({
|
||||
|
||||
id: "admin-system-library",
|
||||
id: "system-library",
|
||||
|
||||
template: _.template($("#system-library-tmpl").html()),
|
||||
itemTemplate: _.template($("#system-library-item-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.systemLibrary = new SystemLibrary();
|
||||
this.systemRepo = new SystemRepo();
|
||||
this.render();
|
||||
},
|
||||
|
||||
@@ -37,7 +37,7 @@ define([
|
||||
this.initPage();
|
||||
var _this = this;
|
||||
|
||||
this.systemLibrary.fetch({
|
||||
this.systemRepo.fetch({
|
||||
url: Common.getUrl({name: 'admin-system-library'}),
|
||||
cache: false, // for IE
|
||||
reset: true,
|
||||
@@ -71,11 +71,11 @@ define([
|
||||
|
||||
reset: function() {
|
||||
this.$loadingTip.hide();
|
||||
this.$tableBody.html(this.itemTemplate(this.systemLibrary.toJSON()));
|
||||
this.$tableBody.html(this.itemTemplate(this.systemRepo.toJSON()));
|
||||
this.$table.show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return SystemLibraryView;
|
||||
return SystemRepoView;
|
||||
});
|
@@ -8,7 +8,7 @@ define([
|
||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||
'use strict';
|
||||
|
||||
var LibraryView = HLItemView.extend({
|
||||
var TrashRepoView = HLItemView.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template($('#trash-library-item-tmpl').html()),
|
||||
@@ -60,8 +60,12 @@ define([
|
||||
|
||||
render: function() {
|
||||
var data = this.model.toJSON(),
|
||||
icon_size = Common.isHiDPI() ? 96 : 24,
|
||||
icon_url = this.model.getIconUrl(icon_size),
|
||||
delete_time = Moment(data['delete_time']);
|
||||
|
||||
data['icon_url'] = icon_url;
|
||||
data['icon_title'] = this.model.getIconTitle();
|
||||
data['time'] = delete_time.format('LLLL');
|
||||
data['time_from_now'] = Common.getRelativeTimeStr(delete_time);
|
||||
|
||||
@@ -72,5 +76,5 @@ define([
|
||||
|
||||
});
|
||||
|
||||
return LibraryView;
|
||||
return TrashRepoView;
|
||||
});
|
@@ -4,22 +4,22 @@ define([
|
||||
'backbone',
|
||||
'common',
|
||||
'moment',
|
||||
'sysadmin-app/views/trash-library',
|
||||
'sysadmin-app/collection/trash-libraries'
|
||||
], function($, _, Backbone, Common, Moment, TrashLibraryView,
|
||||
TrashLibraryCollection) {
|
||||
'sysadmin-app/views/trash-repo',
|
||||
'sysadmin-app/collection/trash-repos'
|
||||
], function($, _, Backbone, Common, Moment, TrashRepoView,
|
||||
TrashRepoCollection) {
|
||||
'use strict';
|
||||
|
||||
var TrashLibrariesView = Backbone.View.extend({
|
||||
var TrashReposView = Backbone.View.extend({
|
||||
|
||||
id: 'admin-trash-libraries',
|
||||
id: 'trash-libraries',
|
||||
|
||||
template: _.template($("#trash-libraries-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.trashLibraryCollection = new TrashLibraryCollection();
|
||||
this.listenTo(this.trashLibraryCollection, 'add', this.addOne);
|
||||
this.listenTo(this.trashLibraryCollection, 'reset', this.reset);
|
||||
this.trashRepoCollection = new TrashRepoCollection();
|
||||
this.listenTo(this.trashRepoCollection, 'add', this.addOne);
|
||||
this.listenTo(this.trashRepoCollection, 'reset', this.reset);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
@@ -75,7 +75,7 @@ define([
|
||||
this.initPage();
|
||||
var _this = this;
|
||||
|
||||
this.trashLibraryCollection.fetch({
|
||||
this.trashRepoCollection.fetch({
|
||||
data: {},
|
||||
cache: false, // for IE
|
||||
reset: true,
|
||||
@@ -96,12 +96,12 @@ define([
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
var length = this.trashLibraryCollection.length;
|
||||
var length = this.trashRepoCollection.length;
|
||||
|
||||
this.$loadingTip.hide();
|
||||
|
||||
if (length > 0) {
|
||||
this.trashLibraryCollection.each(this.addOne, this);
|
||||
this.trashRepoCollection.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
@@ -109,11 +109,11 @@ define([
|
||||
},
|
||||
|
||||
addOne: function(library) {
|
||||
var view = new TrashLibraryView({model: library});
|
||||
var view = new TrashRepoView({model: library});
|
||||
this.$tableBody.append(view.render().el);
|
||||
}
|
||||
});
|
||||
|
||||
return TrashLibrariesView;
|
||||
return TrashReposView;
|
||||
|
||||
});
|
Reference in New Issue
Block a user