mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
Implement Sysinfo
This commit is contained in:
17
static/scripts/sysadmin-app/models/sysinfo.js
Normal file
17
static/scripts/sysadmin-app/models/sysinfo.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var SysInfo = Backbone.Model.extend({
|
||||
|
||||
url: function () {
|
||||
return Common.getUrl({name: 'sysinfo'});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
return SysInfo;
|
||||
});
|
@@ -41,6 +41,7 @@ define([
|
||||
showDashboard: function() {
|
||||
this.switchCurrentView(this.dashboardView);
|
||||
this.sideNavView.setCurTab('dashboard');
|
||||
this.dashboardView.show();
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -2,23 +2,43 @@ define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'common',
|
||||
'sysadmin-app/models/SysInfo'
|
||||
], function($, _, Backbone, Common, SysInfo) {
|
||||
'use strict';
|
||||
|
||||
var DashboardView = Backbone.View.extend({
|
||||
|
||||
tagName: 'div',
|
||||
template: _.template($("#sysinfo-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
|
||||
this.sysinfo = new SysInfo();
|
||||
},
|
||||
|
||||
events: {
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
||||
var _this = this;
|
||||
this.sysinfo.fetch({
|
||||
success: function(model, response, options) {
|
||||
_this._showContent();
|
||||
},
|
||||
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() {
|
||||
@@ -26,7 +46,15 @@ define([
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.render();
|
||||
},
|
||||
|
||||
|
||||
_showContent: function() {
|
||||
console.log(this.sysinfo.toJSON());
|
||||
this.$el.html(this.template(this.sysinfo.toJSON()));
|
||||
$("#right-panel").html(this.$el);
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user