ITSM pandora_enterprise#11471
This commit is contained in:
parent
b27867d504
commit
dba0bbebeb
|
@ -429,7 +429,14 @@ class Widget
|
|||
case 'AvgSumMaxMinModule':
|
||||
case 'BasicChart':
|
||||
case 'AgentHive':
|
||||
$className .= '\\'.$name;
|
||||
break;
|
||||
|
||||
case 'ITSMIncidences':
|
||||
if (isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false) {
|
||||
$not_installed = true;
|
||||
}
|
||||
|
||||
$className .= '\\'.$name;
|
||||
break;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
use PandoraFMS\ITSM\ITSM;
|
||||
|
||||
global $config;
|
||||
|
||||
|
@ -178,8 +179,12 @@ class ITSMIncidences extends Widget
|
|||
|
||||
// This forces at least a first configuration.
|
||||
$this->configurationRequired = false;
|
||||
if (empty($this->values['fields']) === true) {
|
||||
if (isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
if (empty($this->values['customSearch']) === true || empty($this->values['fields']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -215,6 +220,10 @@ class ITSMIncidences extends Widget
|
|||
$values['limit'] = $decoder['limit'];
|
||||
}
|
||||
|
||||
if (isset($decoder['customSearch']) === true) {
|
||||
$values['customSearch'] = $decoder['customSearch'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -263,6 +272,28 @@ class ITSMIncidences extends Widget
|
|||
],
|
||||
];
|
||||
|
||||
$customSearches = [];
|
||||
if (isset($config['ITSM_enabled']) === true && (bool) $config['ITSM_enabled'] === true) {
|
||||
try {
|
||||
$ITSM = new ITSM();
|
||||
$customSearches = $ITSM->listCustomSearch();
|
||||
} catch (\Throwable $th) {
|
||||
$error = $th->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Custom search'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $customSearches,
|
||||
'name' => 'customSearch',
|
||||
'selected' => $values['customSearch'],
|
||||
'return' => true,
|
||||
'sort' => false,
|
||||
],
|
||||
];
|
||||
|
||||
$fields = [
|
||||
'idIncidence' => __('ID'),
|
||||
'title' => __('Title'),
|
||||
|
@ -304,6 +335,7 @@ class ITSMIncidences extends Widget
|
|||
|
||||
$values['fields'] = \get_parameter('fields', []);
|
||||
$values['limit'] = \get_parameter('limit', 20);
|
||||
$values['customSearch'] = \get_parameter('customSearch', 20);
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
@ -361,7 +393,10 @@ class ITSMIncidences extends Widget
|
|||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'operation/ITSM/itsm',
|
||||
'ajax_data' => ['method' => 'getListTickets'],
|
||||
'ajax_data' => [
|
||||
'method' => 'getListTickets',
|
||||
'customSearch' => $this->values['customSearch'],
|
||||
],
|
||||
'order' => [
|
||||
'field' => 'updateDate',
|
||||
'direction' => 'desc',
|
||||
|
|
|
@ -249,6 +249,14 @@ class ITSM
|
|||
$path = '/incidence/statistic/groupedByOwners';
|
||||
break;
|
||||
|
||||
case 'listCustomSearch':
|
||||
$path = '/customSearch/list';
|
||||
break;
|
||||
|
||||
case 'customSearch':
|
||||
$path = '/customSearch/'.$id;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Not posible.
|
||||
break;
|
||||
|
@ -382,4 +390,50 @@ class ITSM
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* List custom search.
|
||||
*
|
||||
* @return array Result.
|
||||
*/
|
||||
public function listCustomSearch(): array
|
||||
{
|
||||
$listCustomSearch = $this->callApi(
|
||||
'listCustomSearch',
|
||||
[
|
||||
'page' => 0,
|
||||
'sizePage' => 0,
|
||||
],
|
||||
['section' => 'incidences']
|
||||
);
|
||||
|
||||
$result = [];
|
||||
foreach ($listCustomSearch['data'] as $customSearch) {
|
||||
$result[$customSearch['idCustomSearch']] = $customSearch['name'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Custom search.
|
||||
*
|
||||
* @param integer $idCustomSearch Custom search ID.
|
||||
*
|
||||
* @return array Data custom search.
|
||||
*/
|
||||
public function getCustomSearch(int $idCustomSearch): array
|
||||
{
|
||||
$result = $this->callApi(
|
||||
'customSearch',
|
||||
[],
|
||||
[],
|
||||
$idCustomSearch,
|
||||
'GET'
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1095,6 +1095,19 @@ class Manager
|
|||
$order = get_datatable_order(true);
|
||||
$filters = get_parameter('filter', []);
|
||||
|
||||
$customSearch = (int) get_parameter('customSearch', 0);
|
||||
if (empty($customSearch) === false) {
|
||||
try {
|
||||
$ITSM = new ITSM();
|
||||
$customSearchData = ($ITSM->getCustomSearch($customSearch)['formValues'] ?? []);
|
||||
} catch (\Throwable $th) {
|
||||
$error = $th->getMessage();
|
||||
$customSearchData = [];
|
||||
}
|
||||
|
||||
$filters = $customSearchData;
|
||||
}
|
||||
|
||||
$externalIdLike = get_parameter('externalIdLike', '');
|
||||
if (empty($externalIdLike) === false) {
|
||||
$filters['externalIdLike'] = $externalIdLike;
|
||||
|
@ -1104,7 +1117,11 @@ class Manager
|
|||
unset($filters['status']);
|
||||
}
|
||||
|
||||
if (isset($filters['idGroup']) === true && empty($filters['idGroup']) === true) {
|
||||
if (isset($filters['priority']) === true && empty($filters['priority']) === true) {
|
||||
unset($filters['priority']);
|
||||
}
|
||||
|
||||
if (isset($filters['idGroup']) === true && (empty($filters['idGroup']) === true || $filters['idGroup'] < 0)) {
|
||||
unset($filters['idGroup']);
|
||||
}
|
||||
|
||||
|
|
|
@ -2356,16 +2356,9 @@ sub api_call {
|
|||
return $response->decoded_content;
|
||||
}
|
||||
|
||||
# TODO: change to logger.
|
||||
use Data::Dumper;
|
||||
$Data::Dumper::SortKeys = 1;
|
||||
#print Dumper($response);
|
||||
print Dumper($response->{'_rc'});
|
||||
print Dumper($response->{'_content'});
|
||||
print Dumper($response->{'_request'});
|
||||
|
||||
logger($pa_config, 'Api response failure: ' . $response->{'_rc'} . '. Description error: ' . $response->{'_content'}, 3);
|
||||
logger($pa_config, $response->{'_request'}, 3);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue