Modal confirm
pull/19/head
Aidaho12 2018-05-10 23:25:45 +06:00
parent 045f263767
commit a58f938503
6 changed files with 134 additions and 61 deletions

View File

@ -28,9 +28,9 @@ def get_overview():
funct.ssh_command(server[2], commands, server_status="1") funct.ssh_command(server[2], commands, server_status="1")
print('</td><td>') print('</td><td>')
if funct.is_admin(): if funct.is_admin():
print('<a id="%s" class="start" title="Start HAproxy service" onclick = "if (! confirm(\'Start service?\')) return false;"><img src=/image/pic/start.png alt="start" class="icon"></a>' % server[2]) print('<a id="%s" class="start" title="Start HAproxy service"><img src=/image/pic/start.png alt="start" class="icon"></a>' % server[2])
print('<a id="%s" class="stop" title="Stop HAproxy service" onclick = "return confirm(\'Stop service?\')"><img src=/image/pic/stop.png alt="start" class="icon"></a>' % server[2]) print('<a id="%s" class="stop" title="Stop HAproxy service"><img src=/image/pic/stop.png alt="start" class="icon"></a>' % server[2])
print('<a id="%s" class="restart" title="Restart HAproxy service" onclick = "if (! confirm(\'Restart service?\')) return false;"><img src=/image/pic/update.png alt="restart" class="icon"></a>' % server[2]) print('<a id="%s" class="restart" title="Restart HAproxy service"><img src=/image/pic/update.png alt="restart" class="icon"></a>' % server[2])
if funct.is_admin(level = 2): if funct.is_admin(level = 2):
print('<a href="/app/configshow.py?serv=%s&open=open#conf" title="Show config"><img src=/image/pic/show.png alt="show" class="icon"></a>' % server[2]) print('<a href="/app/configshow.py?serv=%s&open=open#conf" title="Show config"><img src=/image/pic/show.png alt="show" class="icon"></a>' % server[2])
print('<a href="/app/config.py?serv=%s&open=open#conf" title="Edit config"><img src=/image/pic/edit.png alt="edit" class="icon"></a>' % server[2]) print('<a href="/app/config.py?serv=%s&open=open#conf" title="Edit config"><img src=/image/pic/edit.png alt="edit" class="icon"></a>' % server[2])
@ -51,7 +51,7 @@ def get_overviewServers():
print('<tr><td class="overviewTr first-collumn"><a name="'+server[1]+'"></a><h3 title="IP ' + server[2] + '">' + server[1] + ':</h3></td>') print('<tr><td class="overviewTr first-collumn"><a name="'+server[1]+'"></a><h3 title="IP ' + server[2] + '">' + server[1] + ':</h3></td>')
print('<td class="overviewTd"><span>Total listen/frontend/backend:</span><pre>') print('<td class="overviewTd"><span>Total listen/frontend/backend:</span><pre>')
funct.ssh_command(server[2], commands) funct.ssh_command(server[2], commands)
print('</pre></td><td class="overviewTd"><pre>') print('</pre></td><td><pre>')
funct.ssh_command(server[2], commands1) funct.ssh_command(server[2], commands1)
print('</pre></td></tr>') print('</pre></td></tr>')

View File

@ -1,6 +1,9 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<script src="/inc/users.js"></script> <script src="/inc/users.js"></script>
<div id="dialog-confirm" title="Are you sure you want to delete?" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Deleting irreversibly all data will be lost?</p>
</div>
<div id="tabs"> <div id="tabs">
<ul> <ul>
<li><a href="#users">Users</a></li> <li><a href="#users">Users</a></li>
@ -50,7 +53,7 @@
{% endfor %} {% endfor %}
</select> </select>
</td> </td>
<td><a class="delete" onclick="removeUser({{user.0}})" style="cursor: pointer;"></a></td> <td><a class="delete" onclick="confirmDeleteUser({{user.0}})" style="cursor: pointer;"></a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
@ -120,7 +123,7 @@
<input type="text" id="descript-{{ group.0 }}" value="{{ group.2 }}" class="form-control" size="100"> <input type="text" id="descript-{{ group.0 }}" value="{{ group.2 }}" class="form-control" size="100">
</td> </td>
<td> <td>
<a class="delete" onclick="removeGroup({{ group.0 }})" style="cursor: pointer;"></a> <a class="delete" onclick="confirmDeleteGroup({{ group.0 }})" style="cursor: pointer;"></a>
</td> </td>
{% endif %} {% endif %}
</tr> </tr>
@ -207,7 +210,7 @@
</select> </select>
</td> </td>
<td> <td>
<a class="delete" onclick="removeServer({{server.0}})" style="cursor: pointer;"></a> <a class="delete" onclick="confirmDeleteServer({{server.0}})" style="cursor: pointer;"></a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -1,8 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<script> <script>
if (cur_url[0] == overview.py) { if (cur_url[0] == "overview.py") {
$(#secIntervals).css(display, none); $("#secIntervals").css("display", "none");
} }
</script> </script>
{% if role <= 1 %} {% if role <= 1 %}
@ -84,6 +84,9 @@
</tr> </tr>
<tbody id="ajaxservers"></tbody> <tbody id="ajaxservers"></tbody>
</table> </table>
<div id="dialog-confirm" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Are you sure?</p>
</div>
<script> <script>
window.onload = showOverview() window.onload = showOverview()
</script> </script>

View File

@ -25,17 +25,17 @@ function ajaxActionServers(action, id) {
$( function() { $( function() {
$('.start').click(function() { $('.start').click(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
ajaxActionServers("start", id); confirmAjaxAction("start", id);
}); });
$('.stop').click(function() { $('.stop').click(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
ajaxActionServers("stop", id); confirmAjaxAction("stop", id);
}); });
$('.restart').click(function() { $('.restart').click(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
ajaxActionServers("restart", id); confirmAjaxAction("restart", id);
}); });
$ ( "#show-all-users" ).click( function() { $( "#show-all-users" ).click( function() {
if($( "#show-all-users" ).text() == "Show all") { if($( "#show-all-users" ).text() == "Show all") {
$( ".show-users" ).show("fast"); $( ".show-users" ).show("fast");
$( "#show-all-users" ).text("Hide"); $( "#show-all-users" ).text("Hide");
@ -47,4 +47,22 @@ $( function() {
} }
}); });
$('#secIntervals').css('display', 'none'); $('#secIntervals').css('display', 'none');
}); });
function confirmAjaxAction(action, id) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
title: "Are you sure you want "+ action + " " + id + "?",
buttons: {
"Sure": function() {
$( this ).dialog( "close" );
ajaxActionServers(action, id);
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}

View File

@ -166,7 +166,6 @@ function showMap() {
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
$("#ajax").html(data); $("#ajax").html(data);
//window.history.pushState("Map", "Map", cur_url[0]+"?serv="+$("#serv").val());
} }
} ); } );
} }
@ -202,7 +201,6 @@ function showCompare() {
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
$("#ajax").html(data); $("#ajax").html(data);
//window.history.pushState("Compare", "Compare", cur_url[0]+"?serv="+$("#serv").val()+"&open=open&left="+$("#left").val()+"&right="+$("#right").val());
$.getScript(url); $.getScript(url);
} }
} ); } );
@ -218,7 +216,6 @@ function showCompareConfigs() {
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
$("#ajax-compare").html(data); $("#ajax-compare").html(data);
//window.history.pushState("Compare", "Compare", cur_url[0]+"?serv="+$("#serv").val()+"&open=open");
$.getScript(url); $.getScript(url);
} }
} ); } );
@ -233,7 +230,6 @@ function showConfig() {
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
$("#ajax").html(data); $("#ajax").html(data);
//window.history.pushState("Show config", "Show config", cur_url[0]+"?serv="+$("#serv").val()+"&open=open");
var urlConfigShowJs = '/inc/configshow.js'; var urlConfigShowJs = '/inc/configshow.js';
$.getScript(urlConfigShowJs); $.getScript(urlConfigShowJs);
} }
@ -726,8 +722,6 @@ $( function() {
}, },
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
//data = data.replace(/\s+/g,' ');
//data = data.split(" ");
if (data.indexOf('danger') != '-1') { if (data.indexOf('danger') != '-1') {
$("#ajax-show-ssl").html(data); $("#ajax-show-ssl").html(data);
} else { } else {

View File

@ -267,57 +267,112 @@ $( function() {
} else { } else {
$('#ssh_pass').css('display', 'block'); $('#ssh_pass').css('display', 'block');
} }
} ); } );
function confirmDeleteUser(id) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
title: "Are you sure you want to delete " +$('#login-'+id).val() + "?",
buttons: {
"Delete": function() {
$( this ).dialog( "close" );
removeUser(id);
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}
function confirmDeleteGroup(id) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
title: "Are you sure you want to delete " +$('#name-'+id).val() + "?",
buttons: {
"Delete": function() {
$( this ).dialog( "close" );
removeGroup(id);
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}
function confirmDeleteServer(id) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
title: "Are you sure you want to delete " +$('#hostname-'+id).val() + "?",
buttons: {
"Delete": function() {
$( this ).dialog( "close" );
removeServer(id);
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}
function removeUser(id) { function removeUser(id) {
$("#user-"+id).css("background-color", "#f2dede"); $("#user-"+id).css("background-color", "#f2dede");
$.ajax( { $.ajax( {
url: "sql.py", url: "sql.py",
data: { data: {
userdel: id, userdel: id,
}, },
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if(data == "Ok ") { if(data == "Ok ") {
$("#user-"+id).remove(); $("#user-"+id).remove();
} }
} }
} ); } );
} }
function removeServer(id) { function removeServer(id) {
$("#server-"+id).css("background-color", "#f2dede"); $("#server-"+id).css("background-color", "#f2dede");
$.ajax( { $.ajax( {
url: "sql.py", url: "sql.py",
data: { data: {
serverdel: id, serverdel: id,
}, },
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if(data == "Ok ") { if(data == "Ok ") {
$("#server-"+id).remove(); $("#server-"+id).remove();
} }
} }
} ); } );
} }
function removeGroup(id) { function removeGroup(id) {
$("#group-"+id).css("background-color", "#f2dede"); $("#group-"+id).css("background-color", "#f2dede");
$.ajax( { $.ajax( {
url: "sql.py", url: "sql.py",
data: { data: {
groupdel: id, groupdel: id,
}, },
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if(data == "Ok ") { if(data == "Ok ") {
$("#group-"+id).remove(); $("#group-"+id).remove();
$('select:regex(id, group) option[value='+id+']').remove(); $('select:regex(id, group) option[value='+id+']').remove();
$('select:regex(id, group)').selectmenu("refresh"); $('select:regex(id, group)').selectmenu("refresh");
} }
} }
} ); } );
} }
function updateUser(id) { function updateUser(id) {
$('.alert-danger').remove(); $('.alert-danger').remove();
$.ajax( { $.ajax( {