Commit 4d69c674 authored by Pascal Dreissen's avatar Pascal Dreissen

Datalogstatus notification implementation (as discussed:...

Datalogstatus notification implementation (as discussed: https://www.howtoforge.com/community/threads/datalogstatus.73719/)
parent 89391e17
......@@ -740,7 +740,8 @@ class db extends mysqli
global $app;
$return = array('count' => 0, 'entries' => array());
if($_SESSION['s']['user']['typ'] == 'admin') return $return; // these information should not be displayed to admin users
//if($_SESSION['s']['user']['typ'] == 'admin') return $return; // these information should not be displayed to admin users
// removed in favor of new non intrusive datalogstatus notification header
if($login == '' && isset($_SESSION['s']['user'])) {
$login = $_SESSION['s']['user']['username'];
......
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
error_reporting(E_ALL|E_STRICT);
require_once '../lib/config.inc.php';
require_once '../lib/app.inc.php';
// Check if we have an active users ession and redirect to login if thats not the case.
if($_SESSION['s']['user']['active'] != 1) {
header('Location: /login/');
die();
}
$datalogstatus = json_encode($app->db->datalogStatus());
echo ($datalogstatus);
?>
......@@ -346,6 +346,7 @@ var ISPConfig = {
ISPConfig.loadMenus();
ISPConfig.keepalive();
ISPConfig.datalognotification();
setTimeout(function() {
try {
$('form#pageForm').find('input[name="username"]').focus();
......@@ -493,7 +494,34 @@ var ISPConfig = {
}
});
},
datalognotification: function() {
var notificationContent = $.ajax({
type: "GET",
url: "datalogstatus.php",
dataType: "json",
success: function(data, textStatus, jqXHR) {
var dataLogItems = [];
$.each( data['entries'], function( key, val ) {
dataLogItems.push('<li><strong>' + val['text'] + ':</strong> ' + val['count'] + '</li>');
});
if(data['count'] > 0) {
$('.modal-body').html(dataLogItems.join(""));
$('.notification_text').text(data['count']);
$('.notification').css('display','');
setTimeout( function() { ISPConfig.datalognotification(); }, 2000 );
} else {
$('.notification').css('display','none');
$('.modal-body').html('');
setTimeout( function() { ISPConfig.datalognotification(); }, 5000 );
}
},
error: function() {
ISPConfig.reportError('Notification not loading, aborting.');
$('.notification').css('display','none');
}
});
},
addAdditionalTemplate: function(){
var tpl_add = $('#template_additional').val();
var addTemplate = $('#tpl_add_select').val().split('|',2);
......@@ -701,7 +729,6 @@ $(document).on("click", "[data-uncheck-fields] > input[type='checkbox']", functi
}
});
$(document).on('ready', function () {
$.fn.extend({
insertAtCaret: function(myValue){
......@@ -779,3 +806,4 @@ $(document).on('ready', function () {
return iCaretPos;
};
});
......@@ -722,4 +722,44 @@ input[type="password"].form-control[readonly] {
}
.tooltip-inner {
max-width: 100%;
<<<<<<< HEAD
}
.notification {
width: 35px;
height: 35px;
background: #c70f19;
border-radius: 50%;
display: inline-flex;
margin-right: 15px;
margin-top: 15px;
cursor: pointer;
}
.notification {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
background: #ff000e;
}
50% {
background: #c70f19;
}
100% {
background: #ff000e;
}
}
.systemmonitor-state.state-info {
display: none;
}
span.notification_text {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
font-family: inherit;
color: white;
=======
>>>>>>> 89391e179a7677045efd1f15df091696b5f55e7e
}
\ No newline at end of file
......@@ -61,6 +61,31 @@
</tmpl_if>
</div>
</div>
<div class="notification" data-toggle="modal" data-target="#myModal" style="display: none;">
<span class="notification_text">{tmpl_var name="datalog_changes_count"}</span>
</div>
<!-- Datalogstatus Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">{tmpl_var name="datalog_changes_txt"}</h4>
</div>
<div class="modal-body">
<ul>
<tmpl_loop name="datalog_changes">
<li><strong>{tmpl_var name="text"}:</strong> {tmpl_var name="count"}</li>
</tmpl_loop>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- END Datalogstatus Modal -->
<tmpl_if name='logged_in' value='y'><div id='topnav-container'>
</div></tmpl_if>
<div class='clear'>
......@@ -122,4 +147,4 @@
</script>
</body>
</html>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment