1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-10-09 00:25:53 +00:00
Files
.tx
fabfile
locale
media
seahub
sql
static
css
scripts
app
i18n
lib
sysadmin-app
collection
models
views
dashboard.js
desktop-devices.js
device-error.js
device-errors.js
device.js
dir.js
dirent.js
mobile-devices.js
repo.js
repos.js
search-repos.js
search-trash-repos.js
side-nav.js
system-repo.js
trash-repo.js
trash-repos.js
main.js
router.js
build.js
common.js
file-tree.js
main.js
pinyin-by-unicode.js
sysadmin-main.js
tests
thirdpart
tools
.gitignore
.travis.yml
CONTRIBUTORS
HACKING
LICENSE.txt
Makefile
README.markdown
code-check.sh
i18n.sh
manage.py
pylintrc
pylintrc.template
pytest.ini
requirements.txt
run-seahub.sh.template
send_user_notifications.sh.template
setenv.sh.template
test-requirements.txt
seahub/static/scripts/sysadmin-app/views/system-repo.js

85 lines
2.5 KiB
JavaScript
Raw Normal View History

2016-05-25 10:45:22 +08:00
define([
'jquery',
'underscore',
'backbone',
'common',
2016-05-27 16:42:40 +08:00
'sysadmin-app/models/system-repo'
], function($, _, Backbone, Common, SystemRepo) {
2016-05-25 10:45:22 +08:00
'use strict';
2016-05-27 16:42:40 +08:00
var SystemRepoView = Backbone.View.extend({
2016-05-25 10:45:22 +08:00
2016-05-27 16:42:40 +08:00
id: "system-library",
2016-05-25 10:45:22 +08:00
tabNavTemplate: _.template($("#libraries-tabnav-tmpl").html()),
2016-05-25 10:45:22 +08:00
template: _.template($("#system-library-tmpl").html()),
itemTemplate: _.template($("#system-library-item-tmpl").html()),
initialize: function() {
2016-05-27 16:42:40 +08:00
this.systemRepo = new SystemRepo();
2016-05-25 10:45:22 +08:00
this.render();
},
render: function() {
var $tabnav = $(this.tabNavTemplate({'cur_tab': 'system'}));
this.$el.append($tabnav);
this.$el.append(this.template());
2016-05-25 10:45:22 +08: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 16:42:40 +08:00
this.systemRepo.fetch({
2016-05-25 10:45:22 +08: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) {
var err_msg;
if (response.responseText) {
if (response['status'] == 401 || response['status'] == 403) {
err_msg = gettext("Permission error");
} else {
err_msg = $.parseJSON(response.responseText).error_msg;
}
} else {
err_msg = gettext("Failed. Please check the network.");
}
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 16:42:40 +08:00
this.$tableBody.html(this.itemTemplate(this.systemRepo.toJSON()));
2016-05-25 10:45:22 +08:00
this.$table.show();
}
});
2016-05-27 16:42:40 +08:00
return SystemRepoView;
2016-05-25 10:45:22 +08:00
});