Skip to content

Commit

Permalink
webui: Notify user about Bvfs cache update
Browse files Browse the repository at this point in the history
Display an bvfs update cache notification in the restore filetree
container while loading the tree and in case of an error after tree
loading failed.

The filetree refresh timeout is now configurable by the
filetree_refresh_timeout parameter in the restore section of the
configuration.ini file. The default of the parameter is
set to 120 seconds.

[restore]
; Restore filetree refresh timeout after n milliseconds
; Default: 120000 milliseconds
filetree_refresh_timeout=120000
  • Loading branch information
fbergkemper committed Aug 19, 2019
1 parent b944cfb commit 55a773e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions webui/config/autoload/global.php.in
Expand Up @@ -117,6 +117,13 @@ function read_configuration_ini($configuration, $configuration_ini)
$arr['dashboard']['autorefresh_interval'] = 60000;
}

if( array_key_exists('restore', $configuration) && array_key_exists('filetree_refresh_timeout', $configuration['restore']) && isset($configuration['restore']['filetree_refresh_timeout']) ) {
$arr['restore']['filetree_refresh_timeout'] = $configuration['restore']['filetree_refresh_timeout'];
}
else {
$arr['restore']['filetree_refresh_timeout'] = 120000;
}

return $arr;
}

Expand Down
5 changes: 5 additions & 0 deletions webui/install/configuration.ini.in
Expand Up @@ -45,3 +45,8 @@ save_previous_state=false
; Default: none
labelpooltype=scratch

[restore]
; Restore filetree refresh timeout after n milliseconds
; Default: 120000 milliseconds
filetree_refresh_timeout=120000

3 changes: 3 additions & 0 deletions webui/module/Auth/src/Auth/Controller/AuthController.php
Expand Up @@ -207,6 +207,9 @@ public function loginAction()
}
// Push dashboard configuration settings into SESSION context.
$_SESSION['bareos']['dashboard_autorefresh_interval'] = $configuration['configuration']['dashboard']['autorefresh_interval'];
// Push restore configuration settings into SESSION context.
$_SESSION['bareos']['filetree_refresh_timeout'] = $configuration['configuration']['restore']['filetree_refresh_timeout'];

if($this->params()->fromQuery('req')) {
$redirect = $this->params()->fromQuery('req');
$request = $this->getRequest();
Expand Down
14 changes: 14 additions & 0 deletions webui/module/Restore/view/restore/restore/index.phtml
Expand Up @@ -343,12 +343,24 @@ $this->headTitle($title);

}

function displayBvfsCacheUpdateInfo() {
$('#filebrowser').append("<br>");
$('#filebrowser').append("<div id='alert-bvfs' class='alert alert-info' role='alert'>");
$('#alert-bvfs').append("Update the Bvfs cache frequently to avoid timeouts.<br>");
$('#alert-bvfs').append("Please read the Bareos Documentation for further details.");
$('#filebrowser').append("</div>");
}

$(".search-input").keyup(function() {
var searchString = $(this).val();
console.log(searchString);
$('#filebrowser').jstree('search', searchString);
});

$("#filebrowser").bind("loading.jstree", function() {
displayBvfsCacheUpdateInfo();
});

$('#filebrowser').jstree({
'plugins' : [ "grid", "checkbox", "state", "sort", "search", "types" ],
'core' : {
Expand All @@ -363,13 +375,15 @@ $this->headTitle($title);
"<p><b>Data:</b></p>" +
"<pre><code>" + e.data + "</code></pre>"
);
displayBvfsCacheUpdateInfo();
},
'data' :{
'url' : '<?php echo $this->basePath() . "/restore/filebrowser?type=" . $this->restore_params['type'] . "&jobid=" . $this->restore_params['jobid'] . "&mergefilesets=" . $this->restore_params['mergefilesets'] . "&mergejobs=" . $this->restore_params['mergejobs'] . "&limit=" . $this->restore_params['limit']; ?>',
'dataType' : 'json',
'data' : function (node) {
return { 'id' : node.id };
},
timeout: <?php echo $_SESSION['bareos']['filetree_refresh_timeout']; ?>,
},
},
'state' : {
Expand Down
14 changes: 14 additions & 0 deletions webui/module/Restore/view/restore/restore/versions.phtml
Expand Up @@ -466,12 +466,24 @@ function updateRestoreParams(k, v) {
return params.join('&');
}

function displayBvfsCacheUpdateInfo() {
$('#filebrowser').append("<br>");
$('#filebrowser').append("<div id='alert-bvfs' class='alert alert-info' role='alert'>");
$('#alert-bvfs').append("Update the Bvfs cache frequently to avoid timeouts.<br>");
$('#alert-bvfs').append("Please read the Bareos Documentation for further details.");
$('#filebrowser').append("</div>");
}

$(".search-input").keyup(function () {
var searchString = $(this).val();
console.log(searchString);
$('#filebrowser').jstree('search', searchString);
});

$("#filebrowser").bind("loading.jstree", function() {
displayBvfsCacheUpdateInfo();
});

$('#filebrowser').jstree({
'plugins': ["grid", "state", "sort", "search", "types"],
'core': {
Expand All @@ -486,6 +498,7 @@ $('#filebrowser').jstree({
"<p><b>Data:</b></p>" +
"<pre><code>" + e.data + "</code></pre>"
);
displayBvfsCacheUpdateInfo();
},
'multiple': false,
'data': {
Expand All @@ -497,6 +510,7 @@ $('#filebrowser').jstree({
'state': {'checkbox_disabled': true}
};
},
timeout: <?php echo $_SESSION['bareos']['filetree_refresh_timeout']; ?>,
},
},
'state' : {
Expand Down

0 comments on commit 55a773e

Please sign in to comment.