From: Marcin Haba Date: Sun, 4 Oct 2020 11:12:05 +0000 (+0200) Subject: baculum: Add default days and limit values to status schedules API endpoint X-Git-Tag: Release-9.6.7~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6eebdcffe42185ec50743c01f26ebfe42c5f104d;p=thirdparty%2Fbacula.git baculum: Add default days and limit values to status schedules API endpoint It also fixes displaying schedule status for all scheduled jobs. For Director < 9.6.0 there was a bug in displaying the full schedule status that caused showing an incomplete schedule list. This change guarantes having in Baculum API always complete schedule list for all Director versions which support 'status schedule' command. --- diff --git a/gui/baculum/protected/API/Pages/API/ScheduleStatus.php b/gui/baculum/protected/API/Pages/API/ScheduleStatus.php index 139171a1d..b96a4e45a 100644 --- a/gui/baculum/protected/API/Pages/API/ScheduleStatus.php +++ b/gui/baculum/protected/API/Pages/API/ScheduleStatus.php @@ -31,6 +31,16 @@ Prado::using('Application.API.Class.Bconsole'); */ class ScheduleStatus extends BaculumAPIServer { + /** + * Default days limit. + */ + const DEF_DAYS = 30; + + /** + * Default list items limit. + */ + const DEF_LIMIT = 30; + public function get() { $misc = $this->getModule('misc'); $cmd = array('status', 'schedule'); @@ -45,9 +55,19 @@ class ScheduleStatus extends BaculumAPIServer { } if ($this->Request->contains('days') && $misc->isValidInteger($this->Request['days'])) { $cmd[] = 'days="' . $this->Request['days'] . '"'; + } else { + /** + * For Director < 9.6.0 there was a bug in displaying the full schedule status + * that caused showing an incomplete schedule list. Providing days limit + * is a workaround to have always complete schedule list for all Director versions + * which support 'status schedule' command. + */ + $cmd[] = 'days="' . self::DEF_DAYS . '"'; } if ($this->Request->contains('limit') && $misc->isValidInteger($this->Request['limit'])) { $cmd[] = 'limit="' . $this->Request['limit'] . '"'; + } elseif (!$this->Request->contains('days')) { + $cmd[] = 'limit="' . self::DEF_LIMIT . '"'; } if ($this->Request->contains('time') && $misc->isValidBDateAndTime($this->Request['time'])) { $cmd[] = 'time="' . $this->Request['time'] . '"'; diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index f29491277..7100f1b97 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -3409,6 +3409,7 @@ "description": "Days number to show schedule", "schema": { "type": "integer", + "default": 30, "minimum": 1 } }, @@ -3416,10 +3417,11 @@ "name": "limit", "in": "query", "required": false, - "description": "Schedule results limit", + "description": "Schedule results limit. Setting zero disables the limit. Default value is taken into account only if the days parameter is not set.", "schema": { "type": "integer", - "minimum": 1 + "default": 30, + "minimum": 0 } }, { diff --git a/gui/baculum/protected/Web/Portlets/StatusSchedule.php b/gui/baculum/protected/Web/Portlets/StatusSchedule.php index 704ed0b75..8ebf3fd7e 100644 --- a/gui/baculum/protected/Web/Portlets/StatusSchedule.php +++ b/gui/baculum/protected/Web/Portlets/StatusSchedule.php @@ -33,6 +33,11 @@ Prado::using('Application.Web.Portlets.Portlets'); */ class StatusSchedule extends Portlets { + /** + * Default days limit. + */ + const DEF_DAYS = 90; + const JOB = 'Job'; const CLIENT = 'Client'; const SCHEDULE = 'Schedule'; @@ -50,6 +55,7 @@ class StatusSchedule extends Portlets { return; } $this->loadSchedules(); + $this->Days->Text = self::DEF_DAYS; $this->DatePicker->setDate(date('Y-m-d')); if ($this->getShowClientFilter()) { @@ -86,10 +92,14 @@ class StatusSchedule extends Portlets { $days = $this->getDays(); if (!empty($days)) { $query[] = 'days=' . $days; + } else { + $query[] = 'days=' . self::DEF_DAYS; } $limit = $this->getLimit(); if (!empty($limit)) { $query[] = 'limit=' . $limit; + } else { + $query[] = 'limit=0'; } $time = $this->getTime(); if (!empty($time)) { diff --git a/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl b/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl index 1855415f1..cd67bec2b 100644 --- a/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl +++ b/gui/baculum/protected/Web/Portlets/StatusSchedule.tpl @@ -31,7 +31,6 @@ <%[ Days: ]%>