From 55a773ec6fec0dfdfe254198ccd2b46f3e845104 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Fri, 16 Aug 2019 16:57:09 +0200 Subject: [PATCH] webui: Notify user about Bvfs cache update 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 --- webui/config/autoload/global.php.in | 7 +++++++ webui/install/configuration.ini.in | 5 +++++ .../Auth/src/Auth/Controller/AuthController.php | 3 +++ .../Restore/view/restore/restore/index.phtml | 14 ++++++++++++++ .../Restore/view/restore/restore/versions.phtml | 14 ++++++++++++++ 5 files changed, 43 insertions(+) diff --git a/webui/config/autoload/global.php.in b/webui/config/autoload/global.php.in index 861ce3bc980..097d01dde31 100644 --- a/webui/config/autoload/global.php.in +++ b/webui/config/autoload/global.php.in @@ -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; } diff --git a/webui/install/configuration.ini.in b/webui/install/configuration.ini.in index 62511697a61..1aa70a38b30 100644 --- a/webui/install/configuration.ini.in +++ b/webui/install/configuration.ini.in @@ -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 + diff --git a/webui/module/Auth/src/Auth/Controller/AuthController.php b/webui/module/Auth/src/Auth/Controller/AuthController.php index 63460e00ad1..2faf695979c 100644 --- a/webui/module/Auth/src/Auth/Controller/AuthController.php +++ b/webui/module/Auth/src/Auth/Controller/AuthController.php @@ -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(); diff --git a/webui/module/Restore/view/restore/restore/index.phtml b/webui/module/Restore/view/restore/restore/index.phtml index ed0acf913b2..d639bce3387 100644 --- a/webui/module/Restore/view/restore/restore/index.phtml +++ b/webui/module/Restore/view/restore/restore/index.phtml @@ -343,12 +343,24 @@ $this->headTitle($title); } + function displayBvfsCacheUpdateInfo() { + $('#filebrowser').append("
"); + $('#filebrowser').append(""); + } + $(".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' : { @@ -363,6 +375,7 @@ $this->headTitle($title); "

Data:

" + "
" + e.data + "
" ); + displayBvfsCacheUpdateInfo(); }, 'data' :{ 'url' : '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']; ?>', @@ -370,6 +383,7 @@ $this->headTitle($title); 'data' : function (node) { return { 'id' : node.id }; }, + timeout: , }, }, 'state' : { diff --git a/webui/module/Restore/view/restore/restore/versions.phtml b/webui/module/Restore/view/restore/restore/versions.phtml index 064e76093dd..823288e83fe 100644 --- a/webui/module/Restore/view/restore/restore/versions.phtml +++ b/webui/module/Restore/view/restore/restore/versions.phtml @@ -466,12 +466,24 @@ function updateRestoreParams(k, v) { return params.join('&'); } +function displayBvfsCacheUpdateInfo() { + $('#filebrowser').append("
"); + $('#filebrowser').append(""); +} + $(".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': { @@ -486,6 +498,7 @@ $('#filebrowser').jstree({ "

Data:

" + "
" + e.data + "
" ); + displayBvfsCacheUpdateInfo(); }, 'multiple': false, 'data': { @@ -497,6 +510,7 @@ $('#filebrowser').jstree({ 'state': {'checkbox_disabled': true} }; }, + timeout: , }, }, 'state' : {