mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 07:01:12 +00:00
[system admin] enable user to upload a license file
This commit is contained in:
@@ -12,15 +12,48 @@ define([
|
||||
id: "admin-dashboard",
|
||||
|
||||
template: _.template($("#sysinfo-tmpl").html()),
|
||||
headerTemplate: _.template($("#sysinfo-header-tmpl").html()),
|
||||
conTemplate: _.template($("#sysinfo-con-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.sysinfo = new SysInfo();
|
||||
this.render();
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .license-file-upload-input': 'uploadLicenseFile'
|
||||
},
|
||||
|
||||
uploadLicenseFile: function() {
|
||||
var $input = this.$('.license-file-upload-input');
|
||||
var file;
|
||||
if ($input[0].files) {
|
||||
file = $input[0].files[0];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var input_name = $input.attr('name');
|
||||
var fd = new FormData();
|
||||
|
||||
fd.append(input_name, file);
|
||||
$.ajax({
|
||||
url: Common.getUrl({'name': 'license'}),
|
||||
type: 'POST',
|
||||
data: fd,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
beforeSend: Common.prepareCSRFToken,
|
||||
success: function(){
|
||||
location.reload(true);
|
||||
},
|
||||
error: function(xhr) {
|
||||
Common.ajaxErrorHandler(xhr);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.headerTemplate());
|
||||
this.$el.html(this.template());
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$sysinfo = this.$('.sysinfo');
|
||||
},
|
||||
@@ -59,11 +92,22 @@ define([
|
||||
this.showSysinfo();
|
||||
},
|
||||
|
||||
setLicenceUploadUI: function() {
|
||||
var $btn = this.$('.license-file-upload-btn');
|
||||
this.$('.license-file-upload').css({
|
||||
'width': $btn.outerWidth()
|
||||
});
|
||||
this.$('.license-file-upload-input').css({
|
||||
'height': $btn.outerHeight()
|
||||
});
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.$loadingTip.hide();
|
||||
var json_data = this.sysinfo.toJSON();
|
||||
json_data['formatted_storage'] = Common.quotaSizeFormat(json_data['total_storage'], 1)
|
||||
this.$sysinfo.html(this.template(json_data));
|
||||
this.$sysinfo.html(this.conTemplate(json_data));
|
||||
this.setLicenceUploadUI();
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user