2016-04-15 01:53:10 +08:00
|
|
|
var jsTranslatedAddText;
|
|
|
|
var jsTranslatedCloneText;
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function setButtonStates( element ) {
|
|
|
|
var form = element.form;
|
|
|
|
var checked = 0;
|
|
|
|
for ( var i = 0; i < form.elements.length; i++ ) {
|
|
|
|
if ( form.elements[i].type == "checkbox" ) {
|
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
if ( checked++ > 1 )
|
|
|
|
break;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2017-05-19 02:24:09 +08:00
|
|
|
$(element).closest("tr").toggleClass("danger");
|
2017-10-24 08:01:43 +08:00
|
|
|
form.editBtn.disabled = checked ? false : true;
|
2017-05-19 01:50:56 +08:00
|
|
|
form.addBtn.value = (checked==1) ? jsTranslatedCloneText:jsTranslatedAddText;
|
2016-04-15 01:53:10 +08:00
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
form.deleteBtn.disabled = (checked==0);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-10-27 09:56:10 +08:00
|
|
|
function addMonitor(element) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
var dupParam;
|
|
|
|
var monitorId=-1;
|
|
|
|
if (form.addBtn.value == jsTranslatedCloneText) {
|
|
|
|
// get the value of the first checkbox
|
|
|
|
for ( var i = 0; i < form.elements.length; i++ ) {
|
|
|
|
if ( form.elements[i].type == "checkbox" ) {
|
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
monitorId = form.elements[i].value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-03-18 15:00:51 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId;
|
|
|
|
createPopup( '?view=monitor'+dupParam, 'zmMonitor0', 'monitor' );
|
2016-04-15 01:53:10 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function editMonitor( element ) {
|
|
|
|
var form = element.form;
|
2017-10-24 08:01:43 +08:00
|
|
|
var monitorIds = Array();
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
for ( var i = 0; i < form.elements.length; i++ ) {
|
|
|
|
if ( form.elements[i].type == "checkbox" ) {
|
|
|
|
if ( form.elements[i].checked ) {
|
2017-10-24 08:01:43 +08:00
|
|
|
monitorIds.push( form.elements[i].value );
|
|
|
|
//form.elements[i].checked = false;
|
|
|
|
//setButtonStates( form.elements[i] );
|
2017-05-19 01:50:56 +08:00
|
|
|
//$(form.elements[i]).getParent( 'tr' ).removeClass( 'highlight' );
|
2017-10-24 08:01:43 +08:00
|
|
|
//break;
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-10-24 08:01:43 +08:00
|
|
|
} // end foreach checkboxes
|
|
|
|
if ( monitorIds.length == 1 )
|
|
|
|
createPopup( '?view=monitor&mid='+monitorIds[0], 'zmMonitor'+monitorIds[0], 'monitor' );
|
|
|
|
else if ( monitorIds.length > 1 )
|
|
|
|
createPopup( '?view=monitors&'+(monitorIds.map(function(mid){return 'mids[]='+mid;}).join('&')), 'zmMonitors', 'monitors' );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function deleteMonitor( element ) {
|
|
|
|
if ( confirm( 'Warning, deleting a monitor also deletes all events and database entries associated with it.\nAre you sure you wish to delete?' ) ) {
|
|
|
|
var form = element.form;
|
|
|
|
form.elements['action'].value = 'delete';
|
|
|
|
form.submit();
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function reloadWindow() {
|
|
|
|
window.location.replace( thisUrl );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function initPage() {
|
|
|
|
jsTranslatedAddText = translatedAddText;
|
|
|
|
jsTranslatedCloneText = translatedCloneText;
|
|
|
|
reloadWindow.periodical( consoleRefreshTimeout );
|
|
|
|
if ( showVersionPopup )
|
|
|
|
createPopup( '?view=version', 'zmVersion', 'version' );
|
|
|
|
if ( showDonatePopup )
|
|
|
|
createPopup( '?view=donate', 'zmDonate', 'donate' );
|
2017-05-26 03:03:30 +08:00
|
|
|
|
|
|
|
// Makes table sortable
|
|
|
|
$j( function() {
|
|
|
|
$j( "#consoleTableBody" ).sortable({
|
|
|
|
handle: ".glyphicon-sort",
|
|
|
|
update: applySort,
|
|
|
|
axis:'Y' } );
|
|
|
|
$j( "#consoleTableBody" ).disableSelection();
|
|
|
|
} );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-01-23 23:12:57 +08:00
|
|
|
function applySort(event, ui) {
|
|
|
|
var monitor_ids = $j(this).sortable('toArray');
|
|
|
|
var ajax = new Request.JSON( {
|
2017-12-07 04:43:33 +08:00
|
|
|
url: 'index.php?request=console',
|
2017-01-23 23:12:57 +08:00
|
|
|
data: { monitor_ids: monitor_ids, action: 'sort' },
|
2017-02-03 01:15:16 +08:00
|
|
|
method: 'post',
|
2017-01-23 23:12:57 +08:00
|
|
|
timeout: AJAX_TIMEOUT
|
|
|
|
} );
|
|
|
|
ajax.send();
|
|
|
|
} // end function applySort(event,ui)
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
window.addEvent( 'domready', initPage );
|