1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-19 03:42:52 +00:00
seahub/static/scripts/sysadmin-app/views/system-repo.js

76 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-05-25 02:45:22 +00:00
define([
'jquery',
'underscore',
'backbone',
'common',
2016-05-27 08:42:40 +00:00
'sysadmin-app/models/system-repo'
], function($, _, Backbone, Common, SystemRepo) {
2016-05-25 02:45:22 +00:00
'use strict';
2016-05-27 08:42:40 +00:00
var SystemRepoView = Backbone.View.extend({
2016-05-25 02:45:22 +00:00
2016-05-27 08:42:40 +00:00
id: "system-library",
2016-05-25 02:45:22 +00:00
tabNavTemplate: _.template($("#libraries-tabnav-tmpl").html()),
2016-05-25 02:45:22 +00:00
template: _.template($("#system-library-tmpl").html()),
itemTemplate: _.template($("#system-library-item-tmpl").html()),
initialize: function() {
2016-05-27 08:42:40 +00:00
this.systemRepo = new SystemRepo();
2016-05-25 02:45:22 +00:00
this.render();
},
render: function() {
var $tabnav = $(this.tabNavTemplate({'cur_tab': 'system'}));
this.$el.append($tabnav);
this.$el.append(this.template());
2016-05-25 02:45:22 +00:00
this.$table = this.$('table');
this.$tableBody = $('tbody', this.$table);
this.$loadingTip = this.$('.loading-tip');
},
initPage: function() {
this.$table.hide();
this.$tableBody.empty();
this.$loadingTip.show();
},
showSystemLibrary: function() {
this.initPage();
var _this = this;
2016-05-27 08:42:40 +00:00
this.systemRepo.fetch({
2016-05-25 02:45:22 +00:00
url: Common.getUrl({name: 'admin-system-library'}),
cache: false, // for IE
reset: true,
success: function(model, response, options) {
_this.reset();
},
error: function(model, response, options) {
2018-07-31 10:15:44 +00:00
var err_msg = Common.prepareCollectionFetchErrorMsg(collection, response, opts);
2016-05-25 02:45:22 +00:00
Common.feedback(err_msg, 'error');
}
});
},
hide: function() {
this.$el.detach();
},
show: function() {
$("#right-panel").html(this.$el);
this.showSystemLibrary();
},
reset: function() {
this.$loadingTip.hide();
2016-05-27 08:42:40 +00:00
this.$tableBody.html(this.itemTemplate(this.systemRepo.toJSON()));
2016-05-25 02:45:22 +00:00
this.$table.show();
}
});
2016-05-27 08:42:40 +00:00
return SystemRepoView;
2016-05-25 02:45:22 +00:00
});