Now you can clone available users/servers/telegram settings as template for new user/server/telegram channel
pull/113/head
Aidaho12 2019-02-04 12:37:41 +06:00
parent 2c6af6d1d2
commit 512a69a305
4 changed files with 85 additions and 3 deletions

View File

@ -29,6 +29,7 @@
<td>Role</td>
<td>Group</td>
<td></td>
<td></td>
</tr>
<tr>
{% for user in users %}
@ -85,7 +86,12 @@
{% endfor %}
</select>
</td>
<td><a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a></td>
<td>
<a class="add" onclick="cloneUser({{user.0}})" id="clone-{{user.0}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
</table>
@ -160,6 +166,7 @@
<td class="cred-field">Credentials</td>
<td>Desciption</td>
<td></td>
<td></td>
</tr>
{% for server in servers %}
@ -254,6 +261,9 @@
<input type="text" id="desc-{{server.0}}" value="" size="30" class="form-control">
{% endif %}
</td>
<td>
<a class="add" onclick="cloneServer({{server.0}})" id="clone-{{server.0}}" title="Clone {{server.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteServer({{server.0}})" title="Delete server {{server.1}}" style="cursor: pointer;"></a>
</td>
@ -406,6 +416,7 @@
<td>Chanel name</td>
<td>Group</td>
<td></td>
<td></td>
</tr>
{% for telegram in telegrams %}
<tr id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
@ -427,6 +438,9 @@
{% endfor %}
</select>
</td>
<td>
<a class="add" onclick="cloneTelegram({{telegram.0}})" id="clone-{{telegram.0}}" title="Clone {{telegram.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteTelegram({{telegram.0}})" title="Delete channel {{telegram.2}}" style="cursor: pointer;"></a>
</td>
@ -594,7 +608,7 @@
<tr>
<td class="padding20" title="Vitrual IP, something like VRRP">Virt</td>
<td>
<label for="typeip"></label><input type="checkbox" id="typeip">
<label for="typeip"></label><input type="checkbox" id="typeip" name="typeip">
</td>
</tr>
<tr>

View File

@ -115,7 +115,7 @@
</ul>
</nav>
<div class="copyright-menu">
<a href="https://github.com/aidaho12/haproxy-wi/" title="Github repo" target="_blank" style="color: #fff">HAproxy-WI v3.4.3</a>
<a href="https://github.com/aidaho12/haproxy-wi/" title="Github repo" target="_blank" style="color: #fff">HAproxy-WI v3.4.4</a>
<br>
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 30px; color: red;" class="patreon"> Patreon</a>
</div>

View File

@ -28,6 +28,7 @@
<td>Email</td>
<td>Role</td>
<td></td>
<td></td>
</tr>
<tr>
{% for user in users %}
@ -76,6 +77,9 @@
{% endfor %}
</select>
</td>
<td>
<a class="add" onclick="cloneUser({{user.0}})" id="clone-{{user.0}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a>
</td>
@ -102,6 +106,7 @@
<td class="cred-field">Credentials</td>
<td>Desciption</td>
<td></td>
<td></td>
</tr>
{% set ssh_group = [] %}
{% for server in servers %}
@ -186,6 +191,9 @@
<input type="text" id="desc-{{server.0}}" value="" size="30" class="form-control">
{% endif %}
</td>
<td>
<a class="add" onclick="cloneServer({{server.0}})" id="clone-{{server.0}}" title="Clone {{server.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteServer({{server.0}})" title="Delete server {{server.1}}" style="cursor: pointer;"></a>
</td>

View File

@ -682,6 +682,66 @@ function confirmDeleteTelegram(id) {
}
});
}
function cloneServer(id) {
$( "#add-server-button" ).trigger( "click" );
if ($('#enable-'+id).is(':checked')) {
$('#enable').prop('checked', true)
} else {
$('#enable').prop('checked', false)
}
if ($('#typeip-'+id).is(':checked')) {
$('#typeip').prop('checked', true)
} else {
$('#typeip').prop('checked', false)
}
if ($('#alert-'+id).is(':checked')) {
$('#alert').prop('checked', true)
} else {
$('#alert').prop('checked', false)
}
if ($('#metrics-'+id).is(':checked')) {
$('#metrics').prop('checked', true)
} else {
$('#metrics').prop('checked', false)
}
if ($('#active-'+id).is(':checked')) {
$('#active').prop('checked', true)
} else {
$('#active').prop('checked', false)
}
$('#enable').checkboxradio("refresh");
$('#typeip').checkboxradio("refresh");
$('#alert').checkboxradio("refresh");
$('#active').checkboxradio("refresh");
$('#new-server-add').val($('#hostname-'+id).val())
$('#new-ip').val($('#ip-'+id).val())
$('#new-port').val($('#port-'+id).val())
$('#desc').val($('#desc-'+id).val())
$('#slavefor').val($('#slavefor-'+id+' option:selected').val()).change()
$('#slavefor').selectmenu("refresh");
$('#credentials').val($('#credentials-'+id+' option:selected').val()).change()
$('#credentials').selectmenu("refresh");
$('#new-server-group-add').val($('#servergroup-'+id+' option:selected').val()).change()
$('#new-server-group-add').selectmenu("refresh");
}
function cloneUser(id) {
$( "#add-user-button" ).trigger( "click" );
if ($('#activeuser-'+id).is(':checked')) {
$('#activeuser').prop('checked', true)
} else {
$('#activeuser').prop('checked', false)
}
$('#activeuser').checkboxradio("refresh");
$('#new-role').val($('#role-'+id+' option:selected').val()).change()
$('#new-role').selectmenu("refresh");
$('#new-group').val($('#usergroup-'+id+' option:selected').val()).change()
$('#new-group').selectmenu("refresh");
}
function cloneTelegram(id) {
$( "#add-telegram-button" ).trigger( "click" );
$('#telegram-token-add').val($('#telegram-token-'+id).val())
$('#telegram-chanel-add').val($('#telegram-chanel-'+id).val())
}
function removeUser(id) {
$("#user-"+id).css("background-color", "#f2dede");
$.ajax( {