From: Marcin Haba Date: Thu, 2 May 2019 07:49:10 +0000 (+0200) Subject: baculum: Add status schedule page X-Git-Tag: Release-9.4.3~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=847a4e66f0d6d702e5add2c2d36a12f2e0cbb4ff;p=thirdparty%2Fbacula.git baculum: Add status schedule page --- diff --git a/gui/baculum/protected/Common/Class/BClientScript.php b/gui/baculum/protected/Common/Class/BClientScript.php index 216d7dfd6..6836fe067 100644 --- a/gui/baculum/protected/Common/Class/BClientScript.php +++ b/gui/baculum/protected/Common/Class/BClientScript.php @@ -24,7 +24,7 @@ Prado::using('System.Web.UI.WebControls.TClientScript'); class BClientScript extends TClientScript { - const SCRIPTS_VERSION = 2; + const SCRIPTS_VERSION = 3; public function getScriptUrl() { diff --git a/gui/baculum/protected/Web/JavaScript/misc.js b/gui/baculum/protected/Web/JavaScript/misc.js index bb7360d9c..aa74d594b 100644 --- a/gui/baculum/protected/Web/JavaScript/misc.js +++ b/gui/baculum/protected/Web/JavaScript/misc.js @@ -80,6 +80,18 @@ var Units = { } var ret = {value: time_seconds, format: f}; return ret; + }, + format_date: function(timestamp) { + if (typeof(timestamp) === 'string') { + timestamp = parseInt(timestamp, 10); + } + if (timestamp < 9999999999) { + timestamp *= 1000; + } + var d = new Date(timestamp); + var date = [d.getFullYear(), ('0' + (d.getMonth()+1)).slice(-2), ('0' + d.getDate()).slice(-2)].join('-'); + var time = [d.getHours(), ('0' + d.getMinutes()).slice(-2), ('0' + d.getSeconds()).slice(-2)].join(':'); + return (date + ' ' + time); } } diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index 5c643256f..c40801115 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 bfc857393..0bf5a0ba3 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -1993,3 +1993,39 @@ msgstr "Plugins" msgid "Add plugin" msgstr "Add plugin" + +msgid "Job schedules" +msgstr "Job schedules" + +msgid "Priority" +msgstr "Priority" + +msgid "Scheduled" +msgstr "Scheduled" + +msgid "FileSet" +msgstr "FileSet" + +msgid "Filters:" +msgstr "Filters:" + +msgid "Date from:" +msgstr "Date from:" + +msgid "Days:" +msgstr "Days:" + +msgid "Apply filters" +msgstr "Apply filters" + +msgid "You must enter an integer." +msgstr "You must enter an integer." + +msgid "Invalid date format." +msgstr "Invalid date format." + +msgid "Input must be between 1 and 1000." +msgstr "Input must be between 1 and 1000." + +msgid "Schedule status" +msgstr "Schedule status" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 1845bf294..b71ad3bde 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 3600886f8..e9765e27a 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -2094,3 +2094,39 @@ msgstr "Add plugin" msgid "Plugins" msgstr "Plugins" + +msgid "Job schedules" +msgstr "Job schedules" + +msgid "Priority" +msgstr "Priority" + +msgid "Scheduled" +msgstr "Scheduled" + +msgid "FileSet" +msgstr "FileSet" + +msgid "Filters:" +msgstr "Filters:" + +msgid "Date from:" +msgstr "Date from:" + +msgid "Days:" +msgstr "Days:" + +msgid "Apply filters" +msgstr "Apply filters" + +msgid "You must enter an integer." +msgstr "You must enter an integer." + +msgid "Invalid date format." +msgstr "Invalid date format." + +msgid "Input must be between 1 and 1000." +msgstr "Input must be between 1 and 1000." + +msgid "Schedule status" +msgstr "Schedule status" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 7c49bdcfb..281a5935e 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 6d2796206..e0eed90f3 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -2000,3 +2000,39 @@ msgstr "Dodaj wtyczkę" msgid "Plugins" msgstr "Wtyczki" + +msgid "Job schedules" +msgstr "Harmonogramy zadania" + +msgid "Priority" +msgstr "Priorytet" + +msgid "Scheduled" +msgstr "Zaplanowane" + +msgid "FileSet" +msgstr "FileSet" + +msgid "Filters:" +msgstr "Filtry:" + +msgid "Date from:" +msgstr "Data od:" + +msgid "Days:" +msgstr "Dni:" + +msgid "Apply filters" +msgstr "Zastosuj filtry" + +msgid "You must enter an integer." +msgstr "Musisz wprowadzić liczbę całkowitą." + +msgid "Invalid date format." +msgstr "Niepoprawny format daty." + +msgid "Input must be between 1 and 1000." +msgstr "Pole musi mieć wartość z zakresu 1-1000." + +msgid "Schedule status" +msgstr "Status harmonogramu zadań" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 40febb44d..fb7d7d741 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 0fc278262..50bb4272f 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -2008,3 +2008,39 @@ msgstr "Plugin" msgid "Plugins" msgstr "Plugins" + +msgid "Job schedules" +msgstr "Job schedules" + +msgid "Priority" +msgstr "Priority" + +msgid "Scheduled" +msgstr "Scheduled" + +msgid "FileSet" +msgstr "FileSet" + +msgid "Filters:" +msgstr "Filters:" + +msgid "Date from:" +msgstr "Date from:" + +msgid "Days:" +msgstr "Days:" + +msgid "Apply filters" +msgstr "Apply filters" + +msgid "You must enter an integer." +msgstr "You must enter an integer." + +msgid "Invalid date format." +msgstr "Invalid date format." + +msgid "Input must be between 1 and 1000." +msgstr "Input must be between 1 and 1000." + +msgid "Schedule status" +msgstr "Schedule status" diff --git a/gui/baculum/protected/Web/Pages/JobView.page b/gui/baculum/protected/Web/Pages/JobView.page index 99045a682..a79f5c1a8 100644 --- a/gui/baculum/protected/Web/Pages/JobView.page +++ b/gui/baculum/protected/Web/Pages/JobView.page @@ -34,6 +34,13 @@ OnClick="loadScheduleConfig" CommandParameter="show" /> +
+ diff --git a/gui/baculum/protected/Web/Pages/JobView.php b/gui/baculum/protected/Web/Pages/JobView.php index 78e17293e..559753b7d 100644 --- a/gui/baculum/protected/Web/Pages/JobView.php +++ b/gui/baculum/protected/Web/Pages/JobView.php @@ -49,6 +49,8 @@ class JobView extends BaculumWebPage { } $this->RunJobModal->setJobName($job_name); $this->setJobName($job_name); + $this->Schedules->setJob($job_name); + $this->Schedules->setDays(90); } /** @@ -119,5 +121,9 @@ class JobView extends BaculumWebPage { $this->ScheduleConfig->raiseEvent('OnDirectiveListLoad', $this, null); } } + + public function loadSchedules($sender, $param) { + $this->Schedules->loadSchedules(); + } } ?> diff --git a/gui/baculum/protected/Web/Pages/ScheduleList.page b/gui/baculum/protected/Web/Pages/ScheduleList.page index d3b294634..0f3552321 100644 --- a/gui/baculum/protected/Web/Pages/ScheduleList.page +++ b/gui/baculum/protected/Web/Pages/ScheduleList.page @@ -8,6 +8,7 @@
+
diff --git a/gui/baculum/protected/Web/Pages/ScheduleStatusList.php b/gui/baculum/protected/Web/Pages/ScheduleStatusList.php new file mode 100644 index 000000000..f10733b7a --- /dev/null +++ b/gui/baculum/protected/Web/Pages/ScheduleStatusList.php @@ -0,0 +1,27 @@ + diff --git a/gui/baculum/protected/Web/Pages/ScheduleStatusList.tpl b/gui/baculum/protected/Web/Pages/ScheduleStatusList.tpl new file mode 100644 index 000000000..d98a56c4a --- /dev/null +++ b/gui/baculum/protected/Web/Pages/ScheduleStatusList.tpl @@ -0,0 +1,7 @@ +<%@ MasterClass="Application.Web.Layouts.Main" Theme="Baculum-v2"%> + + + diff --git a/gui/baculum/protected/Web/Portlets/StatusSchedule.php b/gui/baculum/protected/Web/Portlets/StatusSchedule.php new file mode 100644 index 000000000..81b6e9129 --- /dev/null +++ b/gui/baculum/protected/Web/Portlets/StatusSchedule.php @@ -0,0 +1,219 @@ +getPage()->IsCallBack || $this->getPage()->IsPostBack) { + return; + } + $this->loadSchedules(); + $this->DatePicker->setDate(date('Y-m-d')); + + if ($this->getShowClientFilter()) { + $clients = $this->getClients(); + $this->Client->DataSource = array_combine($clients, $clients); + $this->Client->dataBind(); + } else { + $this->Client->Visible = false; + } + + if ($this->getShowScheduleFilter()) { + $schedules = $this->getSchedules(); + $this->Schedule->DataSource = array_combine($schedules, $schedules); + $this->Schedule->dataBind(); + } else { + $this->Schedule->Visible = false; + } + } + + public function loadSchedules() { + $query = array(); + $job = $this->getJob(); + if (!empty($job)) { + $query[] = 'job=' . rawurlencode($job); + } + $client = $this->getClient(); + if (!empty($client)) { + $query[] = 'client=' . rawurlencode($client); + } + $schedule = $this->getSchedule(); + if (!empty($schedule)) { + $query[] = 'schedule=' . rawurlencode($schedule); + } + $days = $this->getDays(); + if (!empty($days)) { + $query[] = 'days=' . $days; + } + $limit = $this->getLimit(); + if (!empty($limit)) { + $query[] = 'limit=' . $limit; + } + $time = $this->getTime(); + if (!empty($time)) { + $query[] = 'time=' . rawurlencode($time); + } + $params = array('schedules', 'status'); + if (count($query) > 0) { + $params[] = '?' . implode('&', $query); + } + + $result = $this->getModule('api')->get($params); + if ($result->error === 0) { + $schedules = $result->output; + if ($this->getPage()->IsCallBack) { + $this->getpage()->getcallbackclient()->callclientfunction( + 'set_job_schedule_data', + json_encode($schedules) + ); + $this->getpage()->getcallbackclient()->callclientfunction( + 'init_job_schedule' + ); + } else { + $this->schedules = $schedules; + } + } + } + + public function getClients() { + $clients = array(''); + $result = $this->getModule('api')->get(array('clients')); + if ($result->error === 0) { + for ($i = 0; $i < count($result->output); $i++) { + $clients[] = $result->output[$i]->name; + } + } + return $clients; + } + + public function getSchedules() { + $schedules = array(); + $result = $this->getModule('api')->get(array('schedules', 'resnames')); + if ($result->error === 0) { + $schedules = $result->output; + array_unshift($schedules, ''); + } + return $schedules; + } + + public function applyFilters($sender, $param) { + $time = $this->DatePicker->getDate() . ' 00:00:00'; + $this->setTime($time); + + $days = intval($this->Days->Text); + $this->setDays($days); + + if ($this->getShowClientFilter()) { + $this->setClient($this->Client->SelectedValue); + } + + if ($this->getShowScheduleFilter()) { + $this->setSchedule($this->Schedule->SelectedValue); + } + + $this->loadSchedules(); + } + + public function setJob($job) { + $this->setViewState(self::JOB, $job); + } + + public function getJob() { + return $this->getViewState(self::JOB); + } + + + public function setClient($client) { + $this->setViewState(self::CLIENT, $client); + } + + public function getClient() { + return $this->getViewState(self::CLIENT); + } + + public function setSchedule($schedule) { + $this->setViewState(self::SCHEDULE, $schedule); + } + + public function getSchedule() { + return $this->getViewState(self::SCHEDULE); + } + + public function setDays($days) { + $this->setViewState(self::DAYS, $days); + } + + public function getDays() { + return $this->getViewState(self::DAYS); + } + + public function setLimit($limit) { + $this->setViewState(self::LIMIT, $limit); + } + + public function getLimit() { + return $this->getViewState(self::LIMIT); + } + + public function setTime($time) { + $this->setViewState(self::TIME, $time); + } + + public function getTime() { + return $this->getViewState(self::TIME); + } + + public function setShowClientFilter($show) { + $show = TPropertyValue::ensureBoolean($show); + $this->setViewState(self::SHOW_CLIENT_FILTER, $show); + } + + public function getShowClientFilter() { + return $this->getViewState(self::SHOW_CLIENT_FILTER, false); + } + + public function setShowScheduleFilter($show) { + $show = TPropertyValue::ensureBoolean($show); + $this->setViewState(self::SHOW_SCHEDULE_FILTER, $show); + } + + public function getShowScheduleFilter() { + return $this->getViewState(self::SHOW_SCHEDULE_FILTER, false); + } +} +?> diff --git a/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl b/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl new file mode 100644 index 000000000..883d599b0 --- /dev/null +++ b/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl @@ -0,0 +1,191 @@ + +
+
+ <%[ Schedule status ]%> +
+
+
+
+ <%[ Filters: ]%> + <%[ Date from: ]%> + + + <%[ Days: ]%> + + + + + + + +  <%[ Apply filters ]%> + +
+
+ + + + + + + + <%=empty($this->getJob()) ? '': ''%> + + + + + + + +
<%[ Level ]%><%[ Type ]%><%[ Priority ]%><%[ Scheduled ]%>' . Prado::localize('Job name') . '<%[ Client ]%><%[ FileSet ]%><%[ Schedule ]%>
+
+ diff --git a/gui/baculum/protected/Web/endpoints.xml b/gui/baculum/protected/Web/endpoints.xml index 4a2d2729a..26684cbc7 100644 --- a/gui/baculum/protected/Web/endpoints.xml +++ b/gui/baculum/protected/Web/endpoints.xml @@ -20,6 +20,7 @@ +