mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Add CopyToClipboard button to copy executed command in Source tab (#758)
This commit is contained in:
parent
c193b51b7f
commit
d462a4fae7
3 changed files with 21 additions and 1 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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 [
|
||||
|
|
|
|||
Loading…
Reference in a new issue