mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 15:24:05 +02:00
Allow to export the host and service detail views to JSON
resolves #12820
This commit is contained in:
parent
4f6c54e62c
commit
1b6e7177a3
@ -75,6 +75,7 @@ abstract class MonitoredObjectController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->object->populate();
|
$this->object->populate();
|
||||||
|
$this->handleFormatRequest();
|
||||||
$toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array(
|
$toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array(
|
||||||
'backend' => $this->backend,
|
'backend' => $this->backend,
|
||||||
'objects' => $this->object
|
'objects' => $this->object
|
||||||
@ -134,6 +135,26 @@ abstract class MonitoredObjectController extends Controller
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export to JSON if requested
|
||||||
|
*/
|
||||||
|
protected function handleFormatRequest($query = null)
|
||||||
|
{
|
||||||
|
if ($this->params->get('format') === 'json'
|
||||||
|
|| $this->getRequest()->getHeader('Accept') === 'application/json'
|
||||||
|
) {
|
||||||
|
$payload = (array) $this->object->properties;
|
||||||
|
$payload += array(
|
||||||
|
'contacts' => $this->object->contacts->fetchPairs(),
|
||||||
|
'contact_groups' => $this->object->contactgroups->fetchPairs(),
|
||||||
|
'vars' => $this->object->customvars
|
||||||
|
);
|
||||||
|
$groupName = $this->object->getType() . 'groups';
|
||||||
|
$payload[$groupName] = $this->object->$groupName;
|
||||||
|
$this->getResponse()->json()->setSuccessData($payload)->sendResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acknowledge a problem
|
* Acknowledge a problem
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user