v8.1.8: Add new SSL management table and improve JS logic

Introduced an SSL management table with dynamic fields for server, type, domain, and credentials in `ssl.html`. Simplified JS logic by removing redundant conditions and enhanced `showConfigFiles` to support preselection. Added `makeid` function for generating random strings.
pull/418/head
Aidaho 2025-04-16 19:12:26 +03:00
parent 3ca015d279
commit 615c4b3e4c
2 changed files with 92 additions and 12 deletions

View File

@ -48,19 +48,10 @@ $( function() {
let link = $(this).find('a').attr('href');
let full_uri = window.location.pathname
let full_uri1 = window.location.hash
let params = new URL(document.location.toString()).searchParams;
if (full_uri === link) {
show_current_page($(this))
} else if (link === full_uri + full_uri1) {
show_current_page($(this))
} else if (link === '/add/haproxy#ssl' && full_uri1 === '#ssl' && params.get("service") != 'nginx') {
show_current_page($(this))
} else if (link === '/add/haproxy#ssl' && full_uri1 === '#ssl' && params.get("service") === 'nginx') {
show_current_page($(this))
} else if (full_uri === 'add/haproxy?service=nginx#ssl' && cur_url[1].split('?')[1] === 'service=nginx#ssl' && full_uri1 === 'add/haproxy?service=nginx#ssl') {
show_current_page($(this))
} else if (full_uri === 'add/haproxy?service=apache#ssl' && cur_url[1].split('?')[1] === 'service=apache#ssl' && full_uri1 === 'add/haproxy?service=apache#ssl') {
show_current_page($(this))
}
});
});
@ -307,7 +298,7 @@ function showConfig() {
let config_file_name = encodeURI(config_file);
if (service === 'nginx' || service === 'apache') {
if (config_file === undefined || config_file === null) {
config_file_name = cur_url[4]
config_file_name = cur_url[7]
if (config_file_name === '') {
toastr.warning('Select a config file first');
return false;
@ -347,7 +338,7 @@ function showConfig() {
}
});
}
function showConfigFiles(not_redirect=false) {
function showConfigFiles(not_redirect=false, config_file_name=null) {
var service = $('#service').val();
var server_ip = $("#serv").val();
clearAllAjaxFields();
@ -364,6 +355,10 @@ function showConfigFiles(not_redirect=false) {
} else {
toastr.clear();
$("#ajax-config_file_name").html(data);
if (config_file_name) {
$('#config_file_name').val(config_file_name);
$('#config_file_name').selectmenu('refresh');
}
if (findGetParameter('findInConfig') === null) {
if (not_redirect) {
window.history.pushState("Show config", "Show config", "/config/" + service + "/" + server_ip + "/show-files");
@ -497,7 +492,7 @@ $( function() {
try {
var cur_path = window.location.pathname;
var attr = $(this).attr('href');
if (cur_path == '/add/haproxy' || cur_path == '/add/nginx' || cur_path == '/admin' || cur_path == '/install' || cur_path == '/runtimeapi') {
if (cur_path == '/install' || cur_path == '/runtimeapi') {
if (typeof attr !== typeof undefined && attr !== false) {
$('title').text($(this).attr('title'));
history.pushState({}, '', $(this).attr('href'));
@ -1378,3 +1373,12 @@ function openUserSettings(user_id) {
function generateSelect(select_id, option_value, option_name, is_selected='') {
$(select_id).append('<option value="' + option_value + '" '+is_selected+'>' + option_name + '</option>');
}
function makeid(length) {
let result = '';
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let charactersLength = characters.length;
for ( let i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}

View File

@ -76,4 +76,80 @@
<pre id="dialog-confirm-body"></pre>
</div>
<input type="hidden" id="group_id" value="{{ g.user_params['group_id']|string() }}">
<div id="le-add-table" style="display: none;">
<table class="overview" id="group-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new3}} {{lang.words.group2}}">
{% include 'include/tr_validate_tips.html' %}
<tr>
<td class="padding20 first-collumn">
{{ lang.words.server|title() }}
</td>
<td>
{{ select('new-le-server_id', values=all_servers, is_servers='true', by_id=1) }}
</td>
</tr>
<tr>
<td class="padding20 first-collumn">
{{ lang.words.type|title() }}
</td>
<td>
<select id="new-le-type">
<option value="standalone">Stand alone</option>
<option value="route53">Route 53</option>
<option value="cloudflare">CloudFlare</option>
<option value="digitalocean">DigitalOcean</option>
<option value="linode">Linode</option>
</select>
</td>
</tr>
<tr>
<td class="padding20 first-collumn">
{{ lang.words.domains|title() }}
</td>
<td>
{{ input('new-le-domain') }}
<div class="tooltip tooltipTop">{{ lang.add_page.desc.comma_separated }}</div>
</td>
</tr>
<tr class="le-standalone">
<td class="padding20 first-collumn">
{{ lang.words.email|title() }}
</td>
<td>
{{ input('new-le-email') }}
</td>
</tr>
<tr class="le-dns" style="display: none;">
<td class="padding20 first-collumn">
{{ lang.words.token|title() }}
</td>
<td>
{{ input('new-le-token') }}
</td>
</tr>
<tr class="le-aws" style="display: none;">
<td class="padding20 first-collumn">
Access key ID
</td>
<td>
{{ input('new-le-access_key_id') }}
</td>
</tr>
<tr class="le-aws" style="display: none;">
<td class="padding20 first-collumn">
Secret access key
</td>
<td>
{{ input('new-le-secret_access_key') }}
</td>
</tr>
<tr>
<td class="padding20 first-collumn">
{{ lang.words.desc|title() }}
</td>
<td>
{{ input('new-le-description') }}
</td>
</tr>
</table>
</div>
{% endblock %}