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:
@@ -3856,3 +3856,12 @@ img.thumbnail {
|
|||||||
width:800px;
|
width:800px;
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
}
|
}
|
||||||
|
/* system info */
|
||||||
|
.license-file-upload {
|
||||||
|
margin-top:5px;
|
||||||
|
position:relative;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.license-file-upload-btn {
|
||||||
|
white-space:nowrap;
|
||||||
|
}
|
||||||
|
@@ -413,7 +413,7 @@ SITE_TITLE = 'Private Seafile'
|
|||||||
SITE_NAME = 'Seafile'
|
SITE_NAME = 'Seafile'
|
||||||
|
|
||||||
# Path to the license file(relative to the media path)
|
# 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)
|
# Path to the favicon file (relative to the media path)
|
||||||
# tip: use a different name when modify it.
|
# tip: use a different name when modify it.
|
||||||
|
@@ -93,7 +93,7 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="sysinfo-header-tmpl">
|
<script type="text/template" id="sysinfo-tmpl">
|
||||||
<div class="header-bar">
|
<div class="header-bar">
|
||||||
<h3 class="">{% trans "Info" %}</h3>
|
<h3 class="">{% trans "Info" %}</h3>
|
||||||
</div>
|
</div>
|
||||||
@@ -102,16 +102,20 @@
|
|||||||
<span class="loading-icon loading-tip"></span>
|
<span class="loading-icon loading-tip"></span>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="sysinfo-tmpl">
|
<script type="text/template" id="sysinfo-con-tmpl">
|
||||||
<dl>
|
<dl>
|
||||||
<dt>{% trans "System Info" %}</dt>
|
<dt>{% trans "System Info" %}</dt>
|
||||||
<dd><% if (is_pro) { %>
|
<dd>
|
||||||
|
<% if (is_pro) { %>
|
||||||
{% trans "Professional Edition" %}
|
{% trans "Professional Edition" %}
|
||||||
<% if (with_license) { %>
|
<% if (with_license) { %>
|
||||||
{% trans "licensed to" %} <%- license_to %>
|
{% trans "licensed to" %} <%- license_to %>,
|
||||||
,
|
|
||||||
{% trans "expires on" %} <%- license_expiration %>
|
{% 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 { %>
|
<% } else { %>
|
||||||
{% trans "Community Edition" %}
|
{% 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>
|
<a href="http://manual.seafile.com/deploy_pro/migrate_from_seafile_community_server.html" target="_blank">{% trans "Upgrade to Pro Edition" %}</a>
|
||||||
|
@@ -40,16 +40,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% 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 %}
|
|
||||||
|
@@ -33,10 +33,6 @@
|
|||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% 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>
|
<h4>{% trans "User" %}</h4>
|
||||||
|
|
||||||
{% with type="checkbox" setting_name="ENABLE_SIGNUP" setting_val=config_dict.ENABLE_SIGNUP %}
|
{% 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) {
|
switch(input_name) {
|
||||||
case 'logo': url = '{% url 'api-v2.1-admin-logo' %}'; break;
|
case 'logo': url = '{% url 'api-v2.1-admin-logo' %}'; break;
|
||||||
case 'favicon': url = '{% url 'api-v2.1-admin-favicon' %}'; 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);
|
fd.append(input_name, file);
|
||||||
|
@@ -185,6 +185,8 @@ define([
|
|||||||
case 'admin_shares': return siteRoot + 'api/v2.1/admin/shares/';
|
case 'admin_shares': return siteRoot + 'api/v2.1/admin/shares/';
|
||||||
case 'sys_group_admin_export_excel': return siteRoot + 'sys/groupadmin/export-excel/';
|
case 'sys_group_admin_export_excel': return siteRoot + 'sys/groupadmin/export-excel/';
|
||||||
case 'admin-logs': return siteRoot + 'api/v2.1/admin/admin-logs/';
|
case 'admin-logs': return siteRoot + 'api/v2.1/admin/admin-logs/';
|
||||||
|
|
||||||
|
case 'license': return siteRoot + 'api/v2.1/admin/license/';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -12,15 +12,48 @@ define([
|
|||||||
id: "admin-dashboard",
|
id: "admin-dashboard",
|
||||||
|
|
||||||
template: _.template($("#sysinfo-tmpl").html()),
|
template: _.template($("#sysinfo-tmpl").html()),
|
||||||
headerTemplate: _.template($("#sysinfo-header-tmpl").html()),
|
conTemplate: _.template($("#sysinfo-con-tmpl").html()),
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.sysinfo = new SysInfo();
|
this.sysinfo = new SysInfo();
|
||||||
this.render();
|
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() {
|
render: function() {
|
||||||
this.$el.html(this.headerTemplate());
|
this.$el.html(this.template());
|
||||||
this.$loadingTip = this.$('.loading-tip');
|
this.$loadingTip = this.$('.loading-tip');
|
||||||
this.$sysinfo = this.$('.sysinfo');
|
this.$sysinfo = this.$('.sysinfo');
|
||||||
},
|
},
|
||||||
@@ -59,11 +92,22 @@ define([
|
|||||||
this.showSysinfo();
|
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() {
|
reset: function() {
|
||||||
this.$loadingTip.hide();
|
this.$loadingTip.hide();
|
||||||
var json_data = this.sysinfo.toJSON();
|
var json_data = this.sysinfo.toJSON();
|
||||||
json_data['formatted_storage'] = Common.quotaSizeFormat(json_data['total_storage'], 1)
|
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