1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-20 20:32:44 +00:00
seahub/static/scripts/sysadmin-app/views/dashboard.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-03-16 05:30:00 +00:00
define([
'jquery',
'underscore',
'backbone',
2016-03-16 08:21:53 +00:00
'common',
'sysadmin-app/models/sysinfo'
2016-03-16 08:21:53 +00:00
], function($, _, Backbone, Common, SysInfo) {
2016-03-16 05:30:00 +00:00
'use strict';
var DashboardView = Backbone.View.extend({
2016-04-23 10:07:09 +00:00
id: "admin-dashboard",
2016-03-16 08:21:53 +00:00
template: _.template($("#sysinfo-tmpl").html()),
2016-04-23 10:07:09 +00:00
headerTemplate: _.template($("#sysinfo-header-tmpl").html()),
2016-03-16 05:30:00 +00:00
initialize: function() {
2016-03-16 08:21:53 +00:00
this.sysinfo = new SysInfo();
2016-04-23 10:07:09 +00:00
this.render();
2016-03-16 05:30:00 +00:00
},
2016-04-23 10:07:09 +00:00
render: function() {
this.$el.html(this.headerTemplate());
this.$loadingTip = this.$('.loading-tip');
this.$sysinfo = this.$('.sysinfo');
2016-03-16 05:30:00 +00:00
},
2016-04-23 10:07:09 +00:00
showSysinfo: function() {
this.$sysinfo.empty();
this.$loadingTip.show();
2016-03-16 08:21:53 +00:00
var _this = this;
this.sysinfo.fetch({
2016-04-23 10:07:09 +00:00
cache: false, // for IE
2016-03-16 08:21:53 +00:00
success: function(model, response, options) {
2016-04-23 10:07:09 +00:00
_this.reset();
2016-03-16 08:21:53 +00:00
},
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');
}
});
2016-03-16 05:30:00 +00:00
},
hide: function() {
2016-04-23 10:07:09 +00:00
this.$el.detach();
2016-03-16 05:30:00 +00:00
},
show: function() {
2016-04-23 10:07:09 +00:00
$("#right-panel").html(this.$el);
this.showSysinfo();
2016-03-16 08:21:53 +00:00
},
2016-04-23 10:07:09 +00:00
reset: function() {
this.$loadingTip.hide();
this.$sysinfo.html(this.template(this.sysinfo.toJSON()));
2016-03-16 05:30:00 +00:00
}
});
return DashboardView;
});