1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

[system admin] enable user to upload a license file

This commit is contained in:
llj
2017-07-04 10:39:11 +08:00
parent 3149a4d49d
commit 0015a9a6c8
7 changed files with 68 additions and 27 deletions

View File

@@ -3856,3 +3856,12 @@ img.thumbnail {
width:800px;
overflow:auto;
}
/* system info */
.license-file-upload {
margin-top:5px;
position:relative;
overflow:hidden;
}
.license-file-upload-btn {
white-space:nowrap;
}

View File

@@ -413,7 +413,7 @@ SITE_TITLE = 'Private Seafile'
SITE_NAME = 'Seafile'
# Path to the license file(relative to the media path)
LICENSE_PATH = os.path.join(PROJECT_ROOT, '../../seafile_license.txt')
LICENSE_PATH = os.path.join(PROJECT_ROOT, '../../seafile-license.txt')
# Path to the favicon file (relative to the media path)
# tip: use a different name when modify it.

View File

@@ -93,7 +93,7 @@
<% } %>
</script>
<script type="text/template" id="sysinfo-header-tmpl">
<script type="text/template" id="sysinfo-tmpl">
<div class="header-bar">
<h3 class="">{% trans "Info" %}</h3>
</div>
@@ -102,16 +102,20 @@
<span class="loading-icon loading-tip"></span>
</script>
<script type="text/template" id="sysinfo-tmpl">
<script type="text/template" id="sysinfo-con-tmpl">
<dl>
<dt>{% trans "System Info" %}</dt>
<dd><% if (is_pro) { %>
<dd>
<% if (is_pro) { %>
{% trans "Professional Edition" %}
<% if (with_license) { %>
{% trans "licensed to" %} <%- license_to %>
,
{% trans "licensed to" %} <%- license_to %>,
{% trans "expires on" %} <%- license_expiration %>
<% } %>
<div class="license-file-upload">
<input type="file" name="license" class="license-file-upload-input transparent-file-input" />
<button type="button" class="license-file-upload-btn">{% trans "Upload licence" %}</button>
</div>
<% } else { %>
{% trans "Community Edition" %}
<a href="http://manual.seafile.com/deploy_pro/migrate_from_seafile_community_server.html" target="_blank">{% trans "Upgrade to Pro Edition" %}</a>

View File

@@ -40,16 +40,3 @@
</div>
</form>
{% endif %}
{% if type == 'license' %}
<form class="web-setting-form" action="">{% csrf_token %}
<h5 class="web-setting-name">{{ setting_display_name }}</h5>
<div class="web-setting-input web-setting-file-input">
<p class="tip">{{ help_tip }}</p>
<div class="web-setting-file-upload">
<input type="file" name="{{ setting_name }}" class="web-setting-file-upload-input transparent-file-input" />
<button type="button" class="web-setting-file-upload-btn">{% trans "Change" %}</button>
</div>
</div>
</form>
{% endif %}

View File

@@ -33,10 +33,6 @@
{% include "snippets/web_settings_form.html" %}
{% endwith %}
{% with type="license" setting_display_name="License" setting_name="license" help_tip="seafile_license.txt" %}
{% include "snippets/web_settings_form.html" %}
{% endwith %}
<h4>{% trans "User" %}</h4>
{% with type="checkbox" setting_name="ENABLE_SIGNUP" setting_val=config_dict.ENABLE_SIGNUP %}
@@ -284,7 +280,6 @@ $('.web-setting-file-upload-input').change(function() {
switch(input_name) {
case 'logo': url = '{% url 'api-v2.1-admin-logo' %}'; break;
case 'favicon': url = '{% url 'api-v2.1-admin-favicon' %}'; break;
case 'license': url = '{% url 'api-v2.1-admin-license' %}'; break;
}
fd.append(input_name, file);

View File

@@ -185,6 +185,8 @@ define([
case 'admin_shares': return siteRoot + 'api/v2.1/admin/shares/';
case 'sys_group_admin_export_excel': return siteRoot + 'sys/groupadmin/export-excel/';
case 'admin-logs': return siteRoot + 'api/v2.1/admin/admin-logs/';
case 'license': return siteRoot + 'api/v2.1/admin/license/';
}
},

View File

@@ -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();
}
});