diff --git a/library/Icingadb/Common/ObjectInspectionDetail.php b/library/Icingadb/Common/ObjectInspectionDetail.php index 87c9b526..0c2bb5bd 100644 --- a/library/Icingadb/Common/ObjectInspectionDetail.php +++ b/library/Icingadb/Common/ObjectInspectionDetail.php @@ -21,6 +21,7 @@ use ipl\Html\HtmlElement; use ipl\Html\Table; use ipl\Html\Text; use ipl\Orm\Model; +use ipl\Web\Widget\CopyToClipboard; abstract class ObjectInspectionDetail extends BaseHtmlElement { @@ -88,9 +89,17 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement 'active' ]; + $execCommand = new HtmlElement( + 'pre', + null, + Text::create($command) + ); + + CopyToClipboard::attachTo($execCommand); + return [ new HtmlElement('h2', null, Text::create(t('Executed Command'))), - new HtmlElement('pre', null, Text::create($command)), + $execCommand, new HtmlElement('h2', null, Text::create(t('Execution Details'))), $this->createNameValueTable( array_diff_key($this->attrs['last_check_result'], array_flip($denylist)), @@ -313,6 +322,10 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement $value = call_user_func($formatters[$name], $value); } else { $value = $this->formatJson($value); + + if ($value instanceof BaseHtmlElement) { + CopyToClipboard::attachTo($value); + } } } catch (Exception $e) { $value = new EmptyState(IcingaException::describe($e)); diff --git a/library/Icingadb/Widget/Detail/EventDetail.php b/library/Icingadb/Widget/Detail/EventDetail.php index e4eb47eb..a0e7fa30 100644 --- a/library/Icingadb/Widget/Detail/EventDetail.php +++ b/library/Icingadb/Widget/Detail/EventDetail.php @@ -26,6 +26,7 @@ use Icinga\Module\Icingadb\Model\NotificationHistory; use Icinga\Module\Icingadb\Model\StateHistory; use Icinga\Module\Icingadb\Util\PluginOutput; use Icinga\Module\Icingadb\Widget\EmptyState; +use ipl\Web\Widget\CopyToClipboard; use ipl\Web\Widget\HorizontalKeyValue; use Icinga\Module\Icingadb\Widget\ItemTable\UserTable; use Icinga\Module\Icingadb\Widget\PluginOutputContainer; @@ -79,6 +80,8 @@ class EventDetail extends BaseHtmlElement ? $this->event->host->checkcommand_name : $this->event->service->checkcommand_name) ); + + CopyToClipboard::attachTo($notificationText); } $pluginOutput = [ @@ -189,6 +192,8 @@ class EventDetail extends BaseHtmlElement (new PluginOutput($stateChange->output . "\n" . $stateChange->long_output)) ->setCommandName($commandName) ); + + CopyToClipboard::attachTo($commandOutput); } $pluginOutput = [ diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index cc57eb44..7aa2af6e 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -33,6 +33,7 @@ use Icinga\Module\Icingadb\Util\PluginOutput; use Icinga\Module\Icingadb\Widget\ItemList\DowntimeList; use Icinga\Module\Icingadb\Widget\EmptyState; use Icinga\Module\Icingadb\Widget\StateChange; +use ipl\Web\Widget\CopyToClipboard; use ipl\Web\Widget\HorizontalKeyValue; use Icinga\Module\Icingadb\Widget\ItemList\CommentList; use Icinga\Module\Icingadb\Widget\PluginOutputContainer; @@ -418,6 +419,7 @@ class ObjectDetail extends BaseHtmlElement $pluginOutput = new EmptyState(t('Output unavailable.')); } else { $pluginOutput = new PluginOutputContainer(PluginOutput::fromObject($this->object)); + CopyToClipboard::attachTo($pluginOutput); } return [