From: Marcin Haba Date: Sun, 25 Oct 2020 06:41:25 +0000 (+0100) Subject: baculum: Add searching jobs by filename in restore wizard - idea proposed by Wanderle... X-Git-Tag: Release-9.6.7~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57914052a69e5503ed875e10a48d4a8d2c6c7aaa;p=thirdparty%2Fbacula.git baculum: Add searching jobs by filename in restore wizard - idea proposed by Wanderlei Huttel --- diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index 368f5a97d..01d671f5f 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index c4e676d70..936ee4629 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -3061,3 +3061,15 @@ msgstr "The API hosts define connection parameters to hosts with the Baculum API msgid "Set all CommandAcls used by Baculum Web" msgstr "Set all CommandAcls used by Baculum Web" + +msgid "Find job by filename (without path):" +msgstr "Find job by filename (without path):" + +msgid "File" +msgstr "File" + +msgid "match exact filename" +msgstr "match exact filename" + +msgid "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." +msgstr "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 51c51b8f4..b74b610fe 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index 51cb5ae7e..2400ae006 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -3147,3 +3147,15 @@ msgstr "The API hosts define connection parameters to hosts with the Baculum API msgid "Set all CommandAcls used by Baculum Web" msgstr "Set all CommandAcls used by Baculum Web" + +msgid "Find job by filename (without path):" +msgstr "Find job by filename (without path):" + +msgid "File" +msgstr "File" + +msgid "match exact filename" +msgstr "match exact filename" + +msgid "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." +msgstr "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index bbf162e61..77e676a6d 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index 8f4aef09b..2ba865292 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -3072,3 +3072,15 @@ msgstr "Hosty API definiują parametry połączenia do hostów z instancjami Bac msgid "Set all CommandAcls used by Baculum Web" msgstr "Ustaw wszystkie wartości CommandAcl używane przez Baculum Web" + +msgid "Find job by filename (without path):" +msgstr "Znajdź zadanie według nazwy pliku (bez ścieżki):" + +msgid "File" +msgstr "Plik" + +msgid "match exact filename" +msgstr "dopasuj dokładną nazwę pliku" + +msgid "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." +msgstr "Z tą opcją są przeszukiwane pliki z nazwą równą dostarczonej nazwie pliku, w przeciwnym razie są wyszukiwane pliki z nazwami zawierającymi podaną nazwę pliku, np. *nazwapliku*." diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 4f3c2f91f..1dba63d4b 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index 216858d2b..2eed72e18 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -3072,3 +3072,14 @@ msgstr "O host de API define parâmetros de conexão para hosts com as instânci msgid "Set all CommandAcls used by Baculum Web" msgstr "Definir todos os comandos ACL's usados pelo Baculum" +msgid "Find job by filename (without path):" +msgstr "Find job by filename (without path):" + +msgid "File" +msgstr "File" + +msgid "match exact filename" +msgstr "match exact filename" + +msgid "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." +msgstr "With this option are searched files with names equal provided filename, otherwise there are searched files with names containing provided filename like *filename*." diff --git a/gui/baculum/protected/Web/Layouts/Wizard.tpl b/gui/baculum/protected/Web/Layouts/Wizard.tpl index 2f443e99b..a06ec9154 100644 --- a/gui/baculum/protected/Web/Layouts/Wizard.tpl +++ b/gui/baculum/protected/Web/Layouts/Wizard.tpl @@ -16,6 +16,9 @@ /> /> /> + /> + /> + /> /> /> /> diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.page b/gui/baculum/protected/Web/Pages/RestoreWizard.page index 14e8fa682..df85974b4 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.page +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.page @@ -92,9 +92,10 @@  <%[ Previous ]%> <%[ Next ]%>  @@ -160,20 +161,26 @@ /> - +

<%[ Note: if you select incremental or differential backup, on the next step will be also loaded all directories and files from older backups required to do the job restore. In other words, the selected backup determines time point from which will be loaded the selected backup and other older backups (incremental, differential) backups up till closest full backup. ]%>

+
+ <%[ Find job by filename (without path): ]%> + <%[ match exact filename ]%>   +
+ + @@ -184,29 +191,159 @@ + +
JobId <%[ Job name ]%><%[ File ]%> <%[ Type ]%> <%[ Level ]%> <%[ Job status ]%> <%[ Size ]%> <%[ Files ]%><%[ Start time ]%> <%[ End time ]%> <%[ Select ]%>
JobId <%[ Job name ]%><%[ File ]%> <%[ Type ]%> <%[ Level ]%> <%[ Job status ]%> <%[ Size ]%> <%[ Files ]%><%[ Start time ]%> <%[ End time ]%> <%[ Select ]%>
+ + + oJobsToRestoreList.show_find_job_by_filename_loader(true); + + + oJobsToRestoreList.show_find_job_by_filename_loader(false); + <%=$this->Session->contains('restore_jobid') ? 'oJobsToRestoreList.set_jobid(' . $this->Session['restore_jobid'] . ');' : ''%> + +
diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.php b/gui/baculum/protected/Web/Pages/RestoreWizard.php index 67f20faf5..559e8de48 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.php @@ -51,6 +51,9 @@ class RestoreWizard extends BaculumWebPage */ private $jobstatus = ['T', 'W', 'A', 'E', 'e', 'f']; + const JOB_LIST_BY_CLIENT = 1; + const JOB_LIST_BY_FILENAME = 2; + /** * File browser special directories. */ @@ -306,7 +309,67 @@ class RestoreWizard extends BaculumWebPage ['clients', $clientid, 'jobs'] )->output; $jobs = $this->getModule('misc')->objectToArray($jobs_for_client); - $this->jobs_to_restore = array_filter($jobs, [$this, 'isJobToRestore']); + function add_file($item) { + $item['file'] = ''; + return $item; + } + $jobs = array_map('add_file', $jobs); + return array_filter($jobs, [$this, 'isJobToRestore']); + } + + /** + * Load backups for selected client by filename (Step 2). + * + * @param string $filename filename to find a backup + * @param boolean $strict strict mode with exact matching name == filename + * @return array job list with files + */ + private function loadBackupsByFilename($filename, $strict) { + $clientid = $this->BackupClient->SelectedValue; + $query = [ + 'clientid' => $clientid, + 'filename' => rawurlencode($filename), + 'strict' => $strict + ]; + $params = [ + 'jobs', + 'files', + '?' . http_build_query($query) + ]; + $result = $this->getModule('api')->get($params); + $ret = []; + if ($result->error == 0) { + $jobs = $this->getModule('misc')->objectToArray($result->output); + $ret = array_filter($jobs, [$this, 'isJobToRestore']); + } + return $ret; + } + + /** + * Load job list. + * Common method both for loading job list for a client and for job list displayed + * after providing filename saved in backup. + * It is responsible for loading job list to select by user for restore. + * + * @param TCallback $sender sender object + * @param TCallbackEventParameter $param param object + * @return none + */ + public function loadJobList($sender, $param) { + $prop = $param->getCallbackParameter(); + $jobs = []; + $list_type = self::JOB_LIST_BY_CLIENT; + if (is_object($prop) && !empty($prop->filename)) { + $list_type = self::JOB_LIST_BY_FILENAME; + $jobs = $this->loadBackupsByFilename($prop->filename, $prop->strict); + } else { + $list_type = self::JOB_LIST_BY_CLIENT; + $jobs = $this->loadBackupsForClient(); + } + $this->getCallbackClient()->callClientFunction( + 'oJobsToRestoreList.update_table', + [array_values($jobs), $list_type] + ); } /** diff --git a/gui/baculum/themes/Baculum-v2/css/baculum.css b/gui/baculum/themes/Baculum-v2/css/baculum.css index 366f3c793..c8a6550f8 100644 --- a/gui/baculum/themes/Baculum-v2/css/baculum.css +++ b/gui/baculum/themes/Baculum-v2/css/baculum.css @@ -133,6 +133,20 @@ div.table_toolbar select { margin-right: 2px; } +#table_filters { + display: inline-block; + vertical-align: text-top; +} + +#table_filters span.text { + font-size: 12px; +} + +#table_filters input, span.text { + vertical-align: middle; + top: 0; +} + table.dataTable tbody > tr.selected, table.dataTable tbody > tr > .selected { background-color: #f5a55b !important; }