1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 10:22:46 +00:00

new admin libraries page

This commit is contained in:
lian
2016-05-25 10:45:22 +08:00
parent 37f6648a12
commit 72f4297934
32 changed files with 1880 additions and 65 deletions

View File

@@ -6,19 +6,20 @@ define([
'moment',
'sysadmin-app/views/device',
'sysadmin-app/collection/devices'
], function($, _, Backbone, Common, Moment, Device, DevicesCollection) {
], function($, _, Backbone, Common, Moment, Device, DeviceCollection) {
'use strict';
var DevicesView = Backbone.View.extend({
id: 'admin-devices',
template: _.template($("#admin-devices-tmpl").html()),
template: _.template($("#devices-tmpl").html()),
initialize: function() {
this.deviceCollection = new DevicesCollection();
this.deviceCollection = new DeviceCollection();
this.listenTo(this.deviceCollection, 'add', this.addOne);
this.listenTo(this.deviceCollection, 'reset', this.reset);
this.render();
},
render: function() {
@@ -47,23 +48,22 @@ define([
getNextPage: function() {
this.initPage();
var current_page = this.deviceCollection.state.current_page;
if (this.deviceCollection.state.hasNextPage) {
var _this = this;
this.deviceCollection.getNextPage({
reset:true,
this.deviceCollection.getPage(current_page + 1, {
reset: true,
data: {'platform': 'desktop'},
});
}
return false;
},
getPreviousPage: function() {
this.initPage();
if (this.deviceCollection.state.currentPage > 1) {
var _this = this;
this.deviceCollection.getPreviousPage({
reset:true,
var current_page = this.deviceCollection.state.current_page;
if (current_page > 1) {
this.deviceCollection.getPage(current_page - 1, {
reset: true,
data: {'platform': 'desktop'},
});
}
@@ -72,19 +72,22 @@ define([
hide: function() {
this.$el.detach();
this.attached = false;
},
show: function(option) {
this.option = option;
this.render();
$("#right-panel").html(this.$el);
if (!this.attached) {
this.attached = true;
$("#right-panel").html(this.$el);
}
this.showDesktopDevices();
},
showDesktopDevices: function() {
this.initPage();
var _this = this,
current_page = this.option.current_page || this.deviceCollection.state.currentPage;
current_page = this.option.current_page || 1;
this.deviceCollection.fetch({
data: {'platform': 'desktop', 'page': current_page},
@@ -108,18 +111,18 @@ define([
reset: function() {
var length = this.deviceCollection.length,
current_page = this.option.current_page || this.deviceCollection.state.currentPage;
current_page = this.deviceCollection.state.current_page;
this.$loadingTip.hide();
if (length > 0) {
this.deviceCollection.each(this.addOne, this);
this.$table.show();
this.renderPaginator();
} else {
this.$emptyTip.show();
}
this.renderPaginator();
app.router.navigate('desktop-devices/?page=' + current_page);
},
@@ -135,8 +138,8 @@ define([
this.$jsNext.hide();
}
var current_page = this.option.current_page || this.deviceCollection.state.currentPage;
if (current_page > 1 && this.deviceCollection.length > 0) {
var current_page = this.deviceCollection.state.current_page;
if (current_page > 1) {
this.$jsPrevious.show();
} else {
this.$jsPrevious.hide();
@@ -146,5 +149,4 @@ define([
});
return DevicesView;
});