mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +00:00
[system repo admin] fix, improvement, supplement, clean
This commit is contained in:
@@ -3,16 +3,16 @@ define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'moment',
|
||||
'sysadmin-app/views/repo',
|
||||
'sysadmin-app/collection/repos'
|
||||
], function($, _, Backbone, Common, Moment, RepoView, RepoCollection) {
|
||||
], function($, _, Backbone, Common, RepoView, RepoCollection) {
|
||||
'use strict';
|
||||
|
||||
var ReposView = Backbone.View.extend({
|
||||
|
||||
id: 'libraries',
|
||||
|
||||
tabNavTemplate: _.template($("#libraries-tabnav-tmpl").html()),
|
||||
template: _.template($("#libraries-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
@@ -23,8 +23,10 @@ define([
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data = {'cur_tab': 'all'};
|
||||
this.$el.html(this.template(data));
|
||||
var $tabnav = $(this.tabNavTemplate({'cur_tab': 'all'}));
|
||||
this.$el.append($tabnav);
|
||||
this.$el.append(this.template());
|
||||
|
||||
this.$table = this.$('table');
|
||||
this.$tableBody = $('tbody', this.$table);
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
@@ -50,7 +52,7 @@ define([
|
||||
getNextPage: function() {
|
||||
this.initPage();
|
||||
var current_page = this.repoCollection.state.current_page;
|
||||
if (this.repoCollection.state.hasNextPage) {
|
||||
if (this.repoCollection.state.has_next_page) {
|
||||
this.repoCollection.getPage(current_page + 1, {
|
||||
reset: true
|
||||
});
|
||||
@@ -62,7 +64,7 @@ define([
|
||||
getPreviousPage: function() {
|
||||
this.initPage();
|
||||
var current_page = this.repoCollection.state.current_page;
|
||||
if ( current_page > 1) {
|
||||
if (current_page > 1) {
|
||||
this.repoCollection.getPage(current_page - 1, {
|
||||
reset: true
|
||||
});
|
||||
@@ -81,19 +83,17 @@ define([
|
||||
this.attached = true;
|
||||
$("#right-panel").html(this.$el);
|
||||
}
|
||||
this.showLibraries();
|
||||
this.getContent();
|
||||
},
|
||||
|
||||
showLibraries: function() {
|
||||
getContent: function() {
|
||||
this.initPage();
|
||||
var _this = this,
|
||||
current_page = this.option.current_page || 1;
|
||||
|
||||
var _this = this;
|
||||
this.repoCollection.fetch({
|
||||
data: {'page': current_page},
|
||||
cache: false, // for IE
|
||||
data: {'page': this.option.page},
|
||||
cache: false,
|
||||
reset: true,
|
||||
error: function (collection, response, opts) {
|
||||
error: function(collection, response, opts) {
|
||||
var err_msg;
|
||||
if (response.responseText) {
|
||||
if (response['status'] == 401 || response['status'] == 403) {
|
||||
@@ -105,29 +105,30 @@ define([
|
||||
err_msg = gettext("Failed. Please check the network.");
|
||||
}
|
||||
Common.feedback(err_msg, 'error');
|
||||
},
|
||||
complete:function() {
|
||||
_this.$loadingTip.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
var length = this.repoCollection.length,
|
||||
current_page = this.repoCollection.state.current_page;
|
||||
// update the url
|
||||
var current_page = this.repoCollection.state.current_page;
|
||||
app.router.navigate('all-libs/?page=' + current_page);
|
||||
|
||||
this.$loadingTip.hide();
|
||||
|
||||
if (length > 0) {
|
||||
if (this.repoCollection.length > 0) {
|
||||
this.repoCollection.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
this.renderPaginator();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
}
|
||||
|
||||
app.router.navigate('libraries/?page=' + current_page);
|
||||
},
|
||||
|
||||
renderPaginator: function() {
|
||||
if (this.repoCollection.state.hasNextPage) {
|
||||
if (this.repoCollection.state.has_next_page) {
|
||||
this.$jsNext.show();
|
||||
} else {
|
||||
this.$jsNext.hide();
|
||||
|
Reference in New Issue
Block a user