Commit 877ad265 authored by Franco Fichtner's avatar Franco Fichtner

filter: improve status reload page

parent 0dea657b
......@@ -169,7 +169,7 @@ function filter_configure_sync($delete_states_if_needed = true)
filter_pflog_start();
update_filter_reload_status(gettext("Initializing"));
update_filter_reload_status(gettext("Initializing"), true);
/* Get interface list to work with. */
filter_generate_optcfg_array();
......
......@@ -1090,9 +1090,19 @@ function format_bytes($bytes) {
}
}
function update_filter_reload_status($text)
function update_filter_reload_status($text, $first = false)
{
file_put_contents('/var/run/filter_reload_status', $text);
$filter_reload_status = '/var/run/filter_reload_status';
if ($first) {
@unlink($filter_reload_status);
}
file_put_contents(
$filter_reload_status,
sprintf("%s: %s\n", microtime(true), $text),
FILE_APPEND
);
}
/****** util/return_dir_as_array
......
......@@ -31,14 +31,15 @@ require_once("guiconfig.inc");
$pgtitle = array(gettext("Status"),gettext("Filter Reload Status"));
$shortcut_section = "firewall";
if (file_exists('/var/run/filter_reload_status')) {
$status = file_get_contents('/var/run/filter_reload_status');
}
if($_GET['getstatus']) {
echo "|{$status}|";
$status = '';
if (file_exists('/var/run/filter_reload_status')) {
$status = file_get_contents('/var/run/filter_reload_status');
}
echo $status;
exit;
}
if($_POST['reloadfilter']) {
configd_run("filter reload");
if ( isset($config['hasync']['synchronizetoip']) && trim($config['hasync']['synchronizetoip']) != "") {
......@@ -71,24 +72,13 @@ include("head.inc");
<div class="content-box ">
<div class="col-xs-12">
<br />
<form action="status_filter_reload.php" method="post" name="filter">
<p><form action="status_filter_reload.php" method="post" name="filter">
<input type="submit" value="Reload Filter" class="btn btn-primary" name="reloadfilter" id="reloadfilter" />
<?php if ($config['hasync'] && $config['hasync']["synchronizetoip"] != ""): ?>
<input type="submit" value="Force Config Sync" class="btn btn-primary" name="syncfilter" id="syncfilter" />
<?php endif; ?>
</form>
<br /><br /><br />
<div id="status" class="well">
<?php echo $status; ?>
</div>
</div>
<br/>
<div id="reloadinfo"><?=gettext("This page will automatically refresh every 3 seconds until the filter is done reloading"); ?>.</div>
</form></p>
<pre id="status"></pre>
</div>
</div>
</section>
......@@ -105,22 +95,8 @@ function update_status_thread() {
}
function update_data(obj) {
var result_text = obj.content;
var result_text_split = result_text.split("|");
result_text = result_text_split[1];
result_text = result_text.replace("\n","");
result_text = result_text.replace("\r","");
if (result_text) {
jQuery('#status').html('<span class="glyphicon glyphicon-refresh"></span> ' + result_text + '...');
} else {
jQuery('#status').html('<span class="glyphicon glyphicon-refresh"></span> Obtaining filter status...');
}
if(result_text == "Initializing") {
jQuery('#status').html('<span class="glyphicon glyphicon-refresh"></span> Initializing...');
} else if(result_text == "Done") {
jQuery('#status').html('Done. The filter rules have been reloaded.');
jQuery('#reloadinfo').css("visibility","hidden");
}
window.setTimeout('update_status_thread()', 2500);
jQuery('#status').html(result_text);
window.setTimeout('update_status_thread()', 200);
}
//]]>
</script>
......@@ -170,7 +146,7 @@ if (typeof getURL == 'undefined') {
http_request.send(null);
}
}
window.setTimeout('update_status_thread()', 2500);
update_status_thread();
//]]>
</script>
......
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