]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add default days and limit values to status schedules API endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 4 Oct 2020 11:12:05 +0000 (13:12 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 4 Oct 2020 11:12:05 +0000 (13:12 +0200)
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.

gui/baculum/protected/API/Pages/API/ScheduleStatus.php
gui/baculum/protected/API/openapi_baculum.json
gui/baculum/protected/Web/Portlets/StatusSchedule.php
gui/baculum/protected/Web/Portlets/StatusSchedule.tpl

index 139171a1d59475d56a03210d9353ec7ff02be129..b96a4e45ab6ed0e616ee1acba31d96e01754c7cf 100644 (file)
@@ -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'] . '"';
index f29491277767415ef19405425a67a1bfbcd5a1eb..7100f1b97a828a561af198bb01c6751d2fd8d08f 100644 (file)
                                                "description": "Days number to show schedule",
                                                "schema": {
                                                        "type": "integer",
+                                                       "default": 30,
                                                        "minimum": 1
                                                }
                                        },
                                                "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
                                                }
                                        },
                                        {
index 704ed0b75485f72a9917543c3f40aa1c9cd39702..8ebf3fd7e1047e8c3ceeff46918d8d64222020e2 100644 (file)
@@ -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)) {
index 1855415f144435148fa6eb917575a4d19d200b14..cd67bec2bc2cfceb77de017693ad7fb7ea516f77 100644 (file)
@@ -31,7 +31,6 @@
                <%[ Days: ]%> <com:TTextBox
                        ID="Days"
                        Style.Width="50px"
-                       Text="90"
                />
                <com:TRequiredFieldValidator
                        ValidationGroup="ScheduleFilters"