/usr/share/shinken/htdocs/js/shinken-refresh.js is in shinken-module-broker-webui 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | /*Copyright (C) 2009-2011 :
Gabes Jean, naparuba@gmail.com
Gerhard Lausser, Gerhard.Lausser@consol.de
Gregory Starck, g.starck@gmail.com
Hartmut Goebel, h.goebel@goebel-consult.de
Andreas Karfusehr, andreas@karfusehr.de
This file is part of Shinken.
Shinken is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Shinken is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Shinken. If not, see <http://www.gnu.org/licenses/>.
*/
/* By default, we set the page to reload each 60s*/
var refresh_timeout = 60;
var nb_refresh_try = 0;
function postpone_refresh(){
// If we are not in our first try, warn the user
if (nb_refresh_try > 0){
$.meow({
message: 'The UI backend is not available.',
icon: '/static/images/errorMedium.png'
});
}
nb_refresh_try += 1;
/* Ok, we are now for a new loop of 60s before retrying... */
reinit_refresh();
}
/* React to an action return of the /action page. Look at status
to see if it's ok or not */
function check_gotfirstdata_result(response){
//alert('In gotfirstdata_result'+ response+response.status);
//alert(response.status == 200);
if(response.status == 200 && response.text == '1'){
// Go Refresh
location.assign(location.href);
}else{
postpone_refresh();
}
}
/* We will try to see if the UI is not in restating mode, and so
don't have enough data to refresh the page as it should. (force login) */
function check_for_data(){
// this code will send a data object via a GET request and alert the retrieved data.
//alert('Try to get' + url+'?callback=?');
$.jsonp({
"url": '/gotfirstdata?callback=?',
"success": check_gotfirstdata_result,
"error": postpone_refresh
});
}
/* Each second, we check for timeout and restart page */
function check_refresh(){
if(refresh_timeout < 0){
// We will first check ifthe backend is available or not. It's useless to refresh
// if the backend is reloading, because it will prompt for login, when wait a little bit
// will make the data available.
check_for_data();
}
refresh_timeout = refresh_timeout - 1;
}
/* Someone ask us to reinit the refresh so the user will have time to
do some thigns like ask actions or something like that */
function reinit_refresh(){
refresh_timeout = 60;
console.log('Reinitialize refresh');
}
/* We will check timeout each 1s*/
$(document).ready(function(){
setInterval("check_refresh();", 1000);
});
|