From: Marcin Haba Date: Wed, 31 May 2023 08:03:38 +0000 (+0200) Subject: baculum: Add joberrors filter to sources endpoint X-Git-Tag: Release-13.0.4~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09cc0e93778550c88884be1d2291a46ef9c6d4a2;p=thirdparty%2Fbacula.git baculum: Add joberrors filter to sources endpoint --- diff --git a/gui/baculum/protected/API/Pages/API/Sources.php b/gui/baculum/protected/API/Pages/API/Sources.php index d400960d3..00aad05bf 100644 --- a/gui/baculum/protected/API/Pages/API/Sources.php +++ b/gui/baculum/protected/API/Pages/API/Sources.php @@ -49,6 +49,10 @@ class Sources extends BaculumAPIServer { $order_by = $this->Request->contains('order_by') && $misc->isValidColumn($this->Request['order_by']) ? $this->Request['order_by']: null; $order_direction = $this->Request->contains('order_direction') && $misc->isValidOrderDirection($this->Request['order_direction']) ? $this->Request['order_direction']: 'DESC'; $mode = ($this->Request->contains('overview') && $misc->isValidBooleanTrue($this->Request['overview'])) ? SourceManager::SOURCE_RESULT_MODE_OVERVIEW : SourceManager::SOURCE_RESULT_MODE_NORMAL; + $joberrors = null; + if ($this->Request->contains('joberrors') && $misc->isValidBoolean($this->Request['joberrors'])) { + $joberrors = $misc->isValidBooleanTrue($this->Request['joberrors']) ? true : false; + } $allowed_sort_fields = ['job', 'client', 'fileset', 'starttime', 'endtime', 'jobid', 'content', 'type', 'jobstatus', 'joberrors']; if (is_string($order_by) && !in_array($order_by, $allowed_sort_fields)) { @@ -123,6 +127,21 @@ class Sources extends BaculumAPIServer { } } + if (!is_null($joberrors)) { + if ($joberrors === true) { + $params['jres.JobErrors'] = []; + $params['jres.JobErrors'][] = [ + 'operator' => '>', + 'vals' => 0 + ]; + } elseif ($joberrors === false) { + $params['jres.JobErrors'] = []; + $params['jres.JobErrors'][] = [ + 'vals' => 0 + ]; + } + } + $sources = $this->getModule('source')->getSources( $params, $props, diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index 986b77eda..b9c3e28e8 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -9179,6 +9179,15 @@ "enum": ["C", "R", "B", "T", "W", "E", "e", "f", "D", "A", "I", "F", "S", "m", "M", "s", "j", "c", "d", "t", "p", "i", "a", "l", "L"] } }, + { + "name": "joberrors", + "in": "query", + "required": false, + "description": "Show objects from jobs that contain or that do not contain errors.", + "schema": { + "type": "boolean" + } + }, { "name": "hasobject", "in": "query",