mirror of https://github.com/Aidaho12/haproxy-wi
parent
e8229080f0
commit
d3dc41715e
11
app/funct.py
11
app/funct.py
|
@ -95,8 +95,11 @@ def telegram_send_mess(mess, **kwargs):
|
||||||
import telebot
|
import telebot
|
||||||
from telebot import apihelper
|
from telebot import apihelper
|
||||||
import sql
|
import sql
|
||||||
|
|
||||||
telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
|
if kwargs.get('telegram_channel_id'):
|
||||||
|
telegrams = sql.get_telegram_by_id(kwargs.get('telegram_channel_id'))
|
||||||
|
else:
|
||||||
|
telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
|
||||||
proxy = sql.get_setting('proxy')
|
proxy = sql.get_setting('proxy')
|
||||||
|
|
||||||
for telegram in telegrams:
|
for telegram in telegrams:
|
||||||
|
@ -115,7 +118,7 @@ def telegram_send_mess(mess, **kwargs):
|
||||||
bot = telebot.TeleBot(token=token_bot)
|
bot = telebot.TeleBot(token=token_bot)
|
||||||
bot.send_message(chat_id=channel_name, text=mess)
|
bot.send_message(chat_id=channel_name, text=mess)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e).decode(encoding='UTF-8'))
|
print(str(e))
|
||||||
logging('localhost', str(e).decode(encoding='UTF-8'), haproxywi=1)
|
logging('localhost', str(e).decode(encoding='UTF-8'), haproxywi=1)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
@ -1044,7 +1047,7 @@ def out_error(e):
|
||||||
error = e
|
error = e
|
||||||
else:
|
else:
|
||||||
error = e.args[0]
|
error = e.args[0]
|
||||||
print(error)
|
print('error: '+error)
|
||||||
|
|
||||||
|
|
||||||
def get_users_params(**kwargs):
|
def get_users_params(**kwargs):
|
||||||
|
|
|
@ -133,8 +133,8 @@
|
||||||
<span class="auto-refresh">
|
<span class="auto-refresh">
|
||||||
<a onclick="pauseAutoRefresh()" class="auto-refresh-pause" style="display: none; margin-top: 4px;"></a>
|
<a onclick="pauseAutoRefresh()" class="auto-refresh-pause" style="display: none; margin-top: 4px;"></a>
|
||||||
<a onclick="pauseAutoResume()" class="auto-refresh-resume" style="display: none; margin-top: 4px;"></a>
|
<a onclick="pauseAutoResume()" class="auto-refresh-resume" style="display: none; margin-top: 4px;"></a>
|
||||||
<a id="0"><span class="service-reload"></span> Auto-refresh</a>
|
<a id="0"><span class="service-reload auto-refresh-reload-icon"></span> Auto-refresh</a>
|
||||||
<a id="1" style="display: none;"><span class="service-reload"></span> Auto-refresh</a>
|
<a id="1" style="display: none;"><span class="service-reload auto-refresh-reload-icon"></span> Auto-refresh</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -146,14 +146,14 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="auto-refresh-interval">
|
<div class="auto-refresh-interval">
|
||||||
<div class="auto-refresh-ul">
|
<div class="auto-refresh-ul">
|
||||||
<ul>
|
<ul style="width: 60px;">
|
||||||
<li>
|
<li>
|
||||||
<a class="ui-button ui-widget ui-corner-all" onclick="setRefreshInterval(0)" title="Turn off auto-refresh">Off</a>
|
<a class="ui-button ui-widget ui-corner-all" onclick="setRefreshInterval(0)" title="Turn off auto-refresh">Off</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="auto-refresh-ul" id="secIntervals">
|
<div class="auto-refresh-ul" id="secIntervals">
|
||||||
<ul>
|
<ul style="width: 100px;">
|
||||||
<li>
|
<li>
|
||||||
<a title="Auto-refresh every 5 seconds" onclick="setRefreshInterval(5000)">5 seconds</a>
|
<a title="Auto-refresh every 5 seconds" onclick="setRefreshInterval(5000)">5 seconds</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="auto-refresh-ul">
|
<div class="auto-refresh-ul">
|
||||||
<ul>
|
<ul style="width: 100px;">
|
||||||
<li>
|
<li>
|
||||||
<a title="Auto-refresh every 1 minute" onclick="setRefreshInterval(60000)">1 minute</a>
|
<a title="Auto-refresh every 1 minute" onclick="setRefreshInterval(60000)">1 minute</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="auto-refresh-ul">
|
<div class="auto-refresh-ul">
|
||||||
<ul>
|
<ul style="width: 100px;">
|
||||||
<li>
|
<li>
|
||||||
<a title="Auto-refresh every 1 hour" onclick="setRefreshInterval(3600000)">1 hour</a>
|
<a title="Auto-refresh every 1 hour" onclick="setRefreshInterval(3600000)">1 hour</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -51,9 +51,9 @@
|
||||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s[1]}}"></tr>
|
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s[1]}}"></tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<table class="overview-wi" style="height: 170;">
|
<table class="overview-wi">
|
||||||
<tr class="overviewHead" style="height: 40px;">
|
<tr class="overviewHead" style="height: 40px;">
|
||||||
<td class="padding10 first-collumn-wi">
|
<td class="padding10 first-collumn-wi" colspan="2">
|
||||||
{% if role <= 1 %}
|
{% if role <= 1 %}
|
||||||
<a href="/app/viewlogs.py?viewlogs={{haproxy_wi_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View HAProxy-WI logs" class="logs_link">
|
<a href="/app/viewlogs.py?viewlogs={{haproxy_wi_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View HAProxy-WI logs" class="logs_link">
|
||||||
HAProxy-WI server status
|
HAProxy-WI server status
|
||||||
|
@ -79,8 +79,8 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<table class="overview-wi" style="height: 160;">
|
<table class="overview-wi">
|
||||||
<tr class="overviewHead" style="height: 40px;">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn-wi" colspan=4>
|
<td class="padding10 first-collumn-wi" colspan=4>
|
||||||
Tools status
|
Tools status
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -157,20 +157,24 @@ function autoRefreshStyle(autoRefresh) {
|
||||||
$('.auto-refresh-resume').css('display', 'none');
|
$('.auto-refresh-resume').css('display', 'none');
|
||||||
$('.auto-refresh-pause').css('margin-left', "-25px");
|
$('.auto-refresh-pause').css('margin-left', "-25px");
|
||||||
$('.auto-refresh-resume').css('margin-left', "-25px");
|
$('.auto-refresh-resume').css('margin-left', "-25px");
|
||||||
|
$('#browse_histroy').css("border-bottom", "none");
|
||||||
$('.auto-refresh img').remove();
|
$('.auto-refresh img').remove();
|
||||||
}
|
}
|
||||||
function setRefreshInterval(interval) {
|
function setRefreshInterval(interval) {
|
||||||
if (interval == "0") {
|
if (interval == "0") {
|
||||||
Cookies.remove('auto-refresh');
|
var autoRefresh = Cookies.get('auto-refresh');
|
||||||
pauseAutoRefresh();
|
if (autoRefresh !== undefined) {
|
||||||
$('.auto-refresh').prepend('<span class="service-reload"></span>');
|
Cookies.remove('auto-refresh');
|
||||||
$('.auto-refresh').css('margin-top', '-3px');
|
pauseAutoRefresh();
|
||||||
$('#1').text('Auto-refresh');
|
$('.auto-refresh').prepend('<span class="service-reload auto-refresh-reload-icon"></span>');
|
||||||
$('#0').text('Auto-refresh');
|
$('.auto-refresh').css('font-size', '15px');
|
||||||
$('.auto-refresh-pause').css('display', 'none');
|
$('#1').text('Auto-refresh');
|
||||||
$('.auto-refresh-resume').css('display', 'none');
|
$('#0').text('Auto-refresh');
|
||||||
|
$('.auto-refresh-pause').css('display', 'none');
|
||||||
|
$('.auto-refresh-resume').css('display', 'none');
|
||||||
|
$.getScript("/inc/fontawesome.min.js")
|
||||||
|
}
|
||||||
hideAutoRefreshDiv();
|
hideAutoRefreshDiv();
|
||||||
$.getScript("/inc/fontawesome.min.js")
|
|
||||||
} else {
|
} else {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
Cookies.set('auto-refresh', interval, { expires: 365 });
|
Cookies.set('auto-refresh', interval, { expires: 365 });
|
||||||
|
@ -302,6 +306,9 @@ function showLog() {
|
||||||
var hour1 = $('#time_range_out_hour1').val()
|
var hour1 = $('#time_range_out_hour1').val()
|
||||||
var minut1 = $('#time_range_out_minut1').val()
|
var minut1 = $('#time_range_out_minut1').val()
|
||||||
var service = $('#service').val()
|
var service = $('#service').val()
|
||||||
|
if (service == 'None') {
|
||||||
|
service = 'haproxy';
|
||||||
|
}
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -917,11 +924,11 @@ function listHistroy() {
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
browse_history[2] = cur_url[0]
|
browse_history[2] = cur_url[0]
|
||||||
}
|
}
|
||||||
$( function() {
|
$( function() {
|
||||||
$('.menu li ul li').each(function () {
|
$('.menu li ul li').each(function () {
|
||||||
var link1 = $(this).find('a').attr('href');
|
var link1 = $(this).find('a').attr('href');
|
||||||
var link2 = link1.split('/')[2]
|
var link2 = link1.split('/')[2]
|
||||||
if (browse_history[i] == link2) {
|
if (browse_history[i] == link2) {
|
||||||
title[i] = $(this).find('a').attr('title');
|
title[i] = $(this).find('a').attr('title');
|
||||||
link_text[i] = $(this).find('a').text();
|
link_text[i] = $(this).find('a').text();
|
||||||
history_link = '<li><a href="'+browse_history[i]+'" title="'+title[i]+'">'+link_text[i]+'</a></li>'
|
history_link = '<li><a href="'+browse_history[i]+'" title="'+title[i]+'">'+link_text[i]+'</a></li>'
|
||||||
|
@ -939,4 +946,4 @@ function changeCurrentGroupF(){
|
||||||
Cookies.remove('group');
|
Cookies.remove('group');
|
||||||
Cookies.set('group', $('#newCurrentGroup').val(), { path: '/app', sameSite: 'Strict', Secure: 'True' });
|
Cookies.set('group', $('#newCurrentGroup').val(), { path: '/app', sameSite: 'Strict', Secure: 'True' });
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,12 @@ h3 {
|
||||||
}
|
}
|
||||||
ul#browse_histroy {
|
ul#browse_histroy {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
margin-bottom: 5px;
|
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
border-bottom: 1px solid #D9D9D9;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
clear: both;
|
||||||
}
|
}
|
||||||
ul#browse_histroy li {
|
ul#browse_histroy li {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
@ -197,7 +199,7 @@ pre {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
border-bottom: solid 1px #D9D9D9;
|
//border-bottom: solid 1px #D9D9D9;
|
||||||
border-top: solid 1px #D9D9D9;
|
border-top: solid 1px #D9D9D9;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
@ -217,8 +219,7 @@ pre {
|
||||||
padding: 0px 15px;
|
padding: 0px 15px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
margin-left: 70%;
|
margin-left: 60%;
|
||||||
border-bottom: solid 1px #D9D9D9;
|
|
||||||
}
|
}
|
||||||
.auto-refresh-ul{
|
.auto-refresh-ul{
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -243,6 +244,12 @@ pre {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
height: 15;
|
height: 15;
|
||||||
}
|
}
|
||||||
|
.auto-refresh-reload-icon {
|
||||||
|
margin-top: 3px;
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
.configShow, .diff {
|
.configShow, .diff {
|
||||||
margin-left: 16%;
|
margin-left: 16%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
@ -371,6 +378,7 @@ pre {
|
||||||
min-height: 160px;
|
min-height: 160px;
|
||||||
float: left;
|
float: left;
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
.overviewHead {
|
.overviewHead {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
@ -866,6 +874,74 @@ label {
|
||||||
.restart, .reload, .stop, .stop-waf, .restart-waf {
|
.restart, .reload, .stop, .stop-waf, .restart-waf {
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
}
|
}
|
||||||
|
.main {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
.sort_menu {
|
||||||
|
clear: both;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.smon_group {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
.group_name {
|
||||||
|
font-size: 18px;
|
||||||
|
padding: 20px;
|
||||||
|
padding-left:15px;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
}
|
||||||
|
.smon_services {
|
||||||
|
width: 190px;
|
||||||
|
height: 160px;
|
||||||
|
float: left;
|
||||||
|
background-color: #fbfbfb;;
|
||||||
|
margin: 10px;
|
||||||
|
padding-left: 15px;
|
||||||
|
border: 1px solid #A4C7F5;
|
||||||
|
}
|
||||||
|
#good_services {
|
||||||
|
clear: both;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
#err_services {
|
||||||
|
clear: both;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
.ip {
|
||||||
|
font-size: 18px;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 3px;
|
||||||
|
color: #5d9ceb;
|
||||||
|
border-bottom: 1px solid #A4C7F5;
|
||||||
|
width: 93%;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.desc, .res_time {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.desc {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
.res_time {
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
.up, .down, .disable {
|
||||||
|
height: 45px;
|
||||||
|
width: 177px;
|
||||||
|
font-size: 30px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.up {
|
||||||
|
background-color: #5CB85C;
|
||||||
|
}
|
||||||
|
.down {
|
||||||
|
background-color: red;
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
.disable {
|
||||||
|
background-color: grey;
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
@media (max-width: 1920px) {
|
@media (max-width: 1920px) {
|
||||||
#logo_span {
|
#logo_span {
|
||||||
margin-left: 17%;
|
margin-left: 17%;
|
||||||
|
|
151
inc/users.js
151
inc/users.js
|
@ -478,7 +478,7 @@ $( function() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
if (data.indexOf('error') != '-1') {
|
if (data.indexOf('error') != '-1') {
|
||||||
$("#ajax-group").append(data);
|
$("#ajax-group").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
|
||||||
$('#errorMess').click(function() {
|
$('#errorMess').click(function() {
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
|
@ -515,7 +515,7 @@ $( function() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
if (data.indexOf('error') != '-1') {
|
if (data.indexOf('error') != '-1') {
|
||||||
$("#ajax-ssh").append(data);
|
$("#ajax-ssh").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
|
||||||
$('#errorMess').click(function() {
|
$('#errorMess').click(function() {
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
|
@ -554,7 +554,7 @@ $( function() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
if (data.indexOf('error') != '-1') {
|
if (data.indexOf('error') != '-1') {
|
||||||
$("#ajax-telegram").append(data);
|
$("#ajax-telegram").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
|
||||||
$('#errorMess').click(function() {
|
$('#errorMess').click(function() {
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
|
@ -677,6 +677,34 @@ $( function() {
|
||||||
$('#add-backup-button').click(function() {
|
$('#add-backup-button').click(function() {
|
||||||
addBackupDialog.dialog('open');
|
addBackupDialog.dialog('open');
|
||||||
});
|
});
|
||||||
|
var addSmonServer = $( "#smon-add-table" ).dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
resizable: false,
|
||||||
|
height: "auto",
|
||||||
|
width: 600,
|
||||||
|
modal: true,
|
||||||
|
title: "Create a new server for monitoring",
|
||||||
|
show: {
|
||||||
|
effect: "fade",
|
||||||
|
duration: 200
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
effect: "fade",
|
||||||
|
duration: 200
|
||||||
|
},
|
||||||
|
buttons: {
|
||||||
|
"Add": function() {
|
||||||
|
addNewSmonServer();
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
clearTips();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-smon-button').click(function() {
|
||||||
|
addSmonServer.dialog('open');
|
||||||
|
});
|
||||||
$( "#ajax-users input" ).change(function() {
|
$( "#ajax-users input" ).change(function() {
|
||||||
var id = $(this).attr('id').split('-');
|
var id = $(this).attr('id').split('-');
|
||||||
updateUser(id[1])
|
updateUser(id[1])
|
||||||
|
@ -791,12 +819,84 @@ function clearTips() {
|
||||||
function checkLength( o, n, min ) {
|
function checkLength( o, n, min ) {
|
||||||
if ( o.val().length < min ) {
|
if ( o.val().length < min ) {
|
||||||
o.addClass( "ui-state-error" );
|
o.addClass( "ui-state-error" );
|
||||||
updateTips("Filed "+n+" required");
|
updateTips("Filed "+n+" is required");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function addNewSmonServer() {
|
||||||
|
var valid = true;
|
||||||
|
$('#error').remove();
|
||||||
|
allFields = $( [] ).add( $('#new-smon-ip') ).add( $('#new-smon-port') )
|
||||||
|
allFields.removeClass( "ui-state-error" );
|
||||||
|
valid = valid && checkLength( $('#new-smon-ip'), "IP", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-port'), "Port", 1 );
|
||||||
|
if ($('#new-smon-proto').val() != '' || $('#new-smon-uri').val() != '') {
|
||||||
|
allFields = $( [] ).add( $('#new-smon-ip') ).add( $('#new-smon-port') )
|
||||||
|
.add( $('#new-smon-proto') ).add( $('#new-smon-uri') );
|
||||||
|
allFields.removeClass( "ui-state-error" );
|
||||||
|
valid = valid && checkLength( $('#new-smon-ip'), "IP", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-port'), "Port", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-proto'), "Protocol", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-uri'), "URI", 1 );
|
||||||
|
}
|
||||||
|
if( $('#new-smon-body').val() != '') {
|
||||||
|
allFields = $( [] ).add( $('#new-smon-ip') ).add( $('#new-smon-port') )
|
||||||
|
.add( $('#new-smon-proto') ).add( $('#new-smon-uri') );
|
||||||
|
allFields.removeClass( "ui-state-error" );
|
||||||
|
valid = valid && checkLength( $('#new-smon-ip'), "IP", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-port'), "Port", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-proto'), "Protocol", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-uri'), "URI", 1 );
|
||||||
|
valid = valid && checkLength( $('#new-smon-body'), "Body", 1 );
|
||||||
|
}
|
||||||
|
var enable = 0;
|
||||||
|
if ($('#new-smon-enable').is(':checked')) {
|
||||||
|
enable = '1';
|
||||||
|
}
|
||||||
|
if (valid) {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
newsmon: $('#new-smon-ip').val(),
|
||||||
|
newsmonport: $('#new-smon-port').val(),
|
||||||
|
newsmonenable: enable,
|
||||||
|
newsmonproto: $('#new-smon-proto').val(),
|
||||||
|
newsmonuri: $('#new-smon-uri').val(),
|
||||||
|
newsmonbody: $('#new-smon-body').val(),
|
||||||
|
newsmongroup: $('#new-smon-group').val(),
|
||||||
|
newsmondescription: $('#new-smon-description').val(),
|
||||||
|
newsmontelegram: $('#new-smon-telegram').val(),
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
data = data.replace(/\s+/g,' ');
|
||||||
|
if (data.indexOf('error') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
|
$("#ajax").html('<div class="alert alert-danger" style="width: 50%;">'+data+'</div><br /><br />');;
|
||||||
|
$('#errorMess').click(function() {
|
||||||
|
$('#error').remove();
|
||||||
|
$('.alert-danger').remove();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('.alert-danger').remove();
|
||||||
|
$("#ajax-smon").append(data);
|
||||||
|
$(".newserver").addClass( "update", 1000 );
|
||||||
|
$( "input[type=submit], button" ).button();
|
||||||
|
$( "input[type=checkbox]" ).checkboxradio();
|
||||||
|
$( "select" ).selectmenu();
|
||||||
|
$.getScript(awesome);
|
||||||
|
setTimeout(function() {
|
||||||
|
$( ".newserver" ).removeClass( "update" );
|
||||||
|
}, 2500 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
clearTips();
|
||||||
|
$( "#smon-add-table" ).dialog("close" );
|
||||||
|
}
|
||||||
|
}
|
||||||
function addUser() {
|
function addUser() {
|
||||||
var valid = true;
|
var valid = true;
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
|
@ -826,7 +926,7 @@ function addUser() {
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error') != '-1') {
|
if (data.indexOf('error') != '-1') {
|
||||||
$("#ajax-users").append(data);
|
$("#ajax-users").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
|
||||||
$('#errorMess').click(function() {
|
$('#errorMess').click(function() {
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
|
@ -836,7 +936,6 @@ function addUser() {
|
||||||
$("#ajax-users").append(data);
|
$("#ajax-users").append(data);
|
||||||
var getId = new RegExp('[0-9]+');
|
var getId = new RegExp('[0-9]+');
|
||||||
var id = data.match(getId);
|
var id = data.match(getId);
|
||||||
console.log(id[0])
|
|
||||||
addUserGroup(id[0]);
|
addUserGroup(id[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,7 +996,7 @@ function addServer() {
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error') != '-1') {
|
if (data.indexOf('error') != '-1') {
|
||||||
$("#ajax-servers").append(data);
|
$("#ajax-servers").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
|
||||||
$('#errorMess').click(function() {
|
$('#errorMess').click(function() {
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
|
@ -1124,6 +1223,24 @@ function confirmDeleteBackup(id) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function confirmDeleteSmon(id) {
|
||||||
|
$( "#dialog-confirm" ).dialog({
|
||||||
|
resizable: false,
|
||||||
|
height: "auto",
|
||||||
|
width: 400,
|
||||||
|
modal: true,
|
||||||
|
title: "Are you sure you want to delete server " +$('#smon-ip-'+id).val() + "?",
|
||||||
|
buttons: {
|
||||||
|
"Delete": function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
removeSmon(id);
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
function cloneServer(id) {
|
function cloneServer(id) {
|
||||||
$( "#add-server-button" ).trigger( "click" );
|
$( "#add-server-button" ).trigger( "click" );
|
||||||
if ($('#enable-'+id).is(':checked')) {
|
if ($('#enable-'+id).is(':checked')) {
|
||||||
|
@ -1305,6 +1422,25 @@ function removeBackup(id) {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
function removeSmon(id) {
|
||||||
|
$("#smon-"+id).css("background-color", "#f2dede");
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
smondel: id,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
data = data.replace(/\s+/g,' ');
|
||||||
|
if(data == "Ok ") {
|
||||||
|
$("#smon-"+id).remove();
|
||||||
|
} else {
|
||||||
|
alert(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
function updateUser(id) {
|
function updateUser(id) {
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
cur_url[0] = cur_url[0].split('#')[0]
|
cur_url[0] = cur_url[0].split('#')[0]
|
||||||
|
@ -1396,7 +1532,6 @@ function updateServer(id) {
|
||||||
if (cur_url[0].split('#')[0] == "servers.py") {
|
if (cur_url[0].split('#')[0] == "servers.py") {
|
||||||
servergroup = $('#new-server-group-add').val();
|
servergroup = $('#new-server-group-add').val();
|
||||||
}
|
}
|
||||||
console.log(servergroup)
|
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
|
|
Loading…
Reference in New Issue