From a14f800d9e0223921336479657956c153cba0932 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 16 Jul 2015 10:35:28 +0200 Subject: [PATCH 1/6] Add support for IPv6 address refs #9645 --- .../application/controllers/HostController.php | 1 + .../application/controllers/HostsController.php | 2 ++ .../application/controllers/ListController.php | 2 ++ .../application/controllers/ServicesController.php | 2 ++ .../views/scripts/partials/host/object-header.phtml | 11 +++++++---- .../scripts/partials/service/object-header.phtml | 10 ++++++---- .../Monitoring/Backend/Ido/Query/HoststatusQuery.php | 1 + .../Backend/Ido/Query/ServicestatusQuery.php | 1 + .../Monitoring/Backend/Ido/Query/StatusQuery.php | 1 + .../library/Monitoring/DataView/Hoststatus.php | 1 + .../library/Monitoring/DataView/Servicestatus.php | 1 + .../monitoring/library/Monitoring/Object/Host.php | 1 + .../monitoring/library/Monitoring/Object/Macro.php | 12 +++++++----- .../monitoring/library/Monitoring/Object/Service.php | 1 + modules/monitoring/public/css/module.less | 11 +++++++++-- .../test/php/library/Monitoring/Object/MacroTest.php | 6 ++++++ 16 files changed, 49 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index a7659726e..514ff4544 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -77,6 +77,7 @@ class Monitoring_HostController extends MonitoredObjectController 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_handled', 'service_description', 'service_display_name', diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 740b5cb5c..477b27fe0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -52,6 +52,7 @@ class Monitoring_HostsController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_state', 'host_problem', 'host_handled', @@ -91,6 +92,7 @@ class Monitoring_HostsController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_state', 'host_problem', 'host_handled', diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 3625043a6..4cf7cbd74 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -75,6 +75,7 @@ class Monitoring_ListController extends Controller 'host_display_name', 'host_state' => $stateColumn, 'host_address', + 'host_address6', 'host_acknowledged', 'host_output', 'host_attempt', @@ -151,6 +152,7 @@ class Monitoring_ListController extends Controller 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_handled', 'service_description', 'service_display_name', diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index faebcd11c..36582eeaf 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -54,6 +54,7 @@ class Monitoring_ServicesController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_output', 'host_state', 'host_problem', @@ -101,6 +102,7 @@ class Monitoring_ServicesController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_output', 'host_state', 'host_problem', diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 1a2fc356d..75cdf2cb9 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -14,11 +14,14 @@ use Icinga\Module\Monitoring\Object\Host; host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) - host_address && $object->host_address !== $object->host_name): ?> -
- escape($object->host_address); ?> + render('partials/host/statusicons.phtml'); ?> +
+ host_address6 && $object->host_address6 !== $object->host_name): ?> + escape($object->host_address6); ?> + + host_address && $object->host_address !== $object->host_name): ?> + escape($object->host_address); ?> - render('partials/host/statusicons.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index c3df4044b..5a6fac2ea 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -15,11 +15,13 @@ use Icinga\Module\Monitoring\Object\Service; host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) - host_address && $object->host_address !== $object->host_name): ?> -
- escape($object->host_address); ?> +
+ host_address6 && $object->host_address6 !== $object->host_name): ?> + escape($object->host_address6); ?> + + host_address && $object->host_address !== $object->host_name): ?> + escape($object->host_address); ?> - render('partials/host/statusicons.phtml'); ?> diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 3feb37a9e..0e94b5f30 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -25,6 +25,7 @@ class HoststatusQuery extends IdoQuery 'host' => 'ho.name1 COLLATE latin1_general_ci', 'host_action_url' => 'h.action_url', 'host_address' => 'h.address', + 'host_address6' => 'h.address6', 'host_alias' => 'h.alias', 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_icon_image' => 'h.icon_image', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php index 0a03f273d..6362bb7ce 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php @@ -27,6 +27,7 @@ class ServicestatusQuery extends IdoQuery 'hosts' => array( 'host_action_url' => 'h.action_url', 'host_address' => 'h.address', + 'host_address6' => 'h.address6', 'host_alias' => 'h.alias COLLATE latin1_general_ci', 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_icon_image' => 'h.icon_image', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 5a3bba9e5..a5112d0ea 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -39,6 +39,7 @@ class StatusQuery extends IdoQuery 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_alias' => 'h.alias', 'host_address' => 'h.address', + 'host_address6' => 'h.address6', 'host_ipv4' => 'INET_ATON(h.address)', 'host_icon_image' => 'h.icon_image', 'host_icon_image_alt' => 'h.icon_image_alt', diff --git a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php index 9c2848618..3cd76b1ce 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php @@ -15,6 +15,7 @@ class HostStatus extends DataView 'host_display_name', 'host_alias', 'host_address', + 'host_address6', 'host_state', 'host_state_type', 'host_handled', diff --git a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php index a4516a93a..82f02ee58 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php @@ -29,6 +29,7 @@ class ServiceStatus extends DataView 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_problem', 'host_handled', 'service_description', diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 3bb10d77e..77ee8db6b 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -96,6 +96,7 @@ class Host extends MonitoredObject 'host_active_checks_enabled', 'host_active_checks_enabled_changed', 'host_address', + 'host_address6', 'host_alias', 'host_check_command', 'host_check_execution_time', diff --git a/modules/monitoring/library/Monitoring/Object/Macro.php b/modules/monitoring/library/Monitoring/Object/Macro.php index 4a9045b58..a8a3552dd 100644 --- a/modules/monitoring/library/Monitoring/Object/Macro.php +++ b/modules/monitoring/library/Monitoring/Object/Macro.php @@ -14,11 +14,13 @@ class Macro * @var array */ private static $icingaMacros = array( - 'HOSTNAME' => 'host_name', - 'HOSTADDRESS' => 'host_address', - 'SERVICEDESC' => 'service_description', - 'host.name' => 'host_name', - 'host.address' => 'host_address', + 'HOSTNAME' => 'host_name', + 'HOSTADDRESS' => 'host_address', + 'HOSTADDRESS6' => 'host_address6', + 'SERVICEDESC' => 'service_description', + 'host.name' => 'host_name', + 'host.address' => 'host_address', + 'host.address6' => 'host_address6', 'service.description' => 'service_description' ); diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 855e62882..85668f4b4 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -111,6 +111,7 @@ class Service extends MonitoredObject 'host_acknowledged', 'host_active_checks_enabled', 'host_address', + 'host_address6', 'host_alias', 'host_display_name', 'host_handled', diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 406031c19..a8a53293e 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -4,12 +4,19 @@ width: 16em; } -p.pluginoutput { - width: 100%; +.padded { + padding: 0 5px; +} + +.address, p.pluginoutput { white-space: pre-wrap; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'DejaVu Sans Mono', 'Courier New', Courier, monospace; } +p.pluginoutput { + width: 100%; +} + table.action td .pluginoutput { font-size: 0.875em; line-height: 1.2em; diff --git a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php index e1b3595e3..89dae3b4d 100644 --- a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php @@ -16,11 +16,14 @@ class MacroTest extends BaseTestCase $hostMock = Mockery::mock('host'); $hostMock->host_name = 'test'; $hostMock->host_address = '1.1.1.1'; + $hostMock->host_address6 = '::1'; $this->assertEquals(Macro::resolveMacros('$HOSTNAME$', $hostMock), $hostMock->host_name); $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS$', $hostMock), $hostMock->host_address); + $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS6$', $hostMock), $hostMock->host_address6); $this->assertEquals(Macro::resolveMacros('$host.name$', $hostMock), $hostMock->host_name); $this->assertEquals(Macro::resolveMacros('$host.address$', $hostMock), $hostMock->host_address); + $this->assertEquals(Macro::resolveMacros('$host.address6$', $hostMock), $hostMock->host_address6); } public function testServiceMacros() @@ -28,13 +31,16 @@ class MacroTest extends BaseTestCase $svcMock = Mockery::mock('service'); $svcMock->host_name = 'test'; $svcMock->host_address = '1.1.1.1'; + $svcMock->host_address6 = '::1'; $svcMock->service_description = 'a service'; $this->assertEquals(Macro::resolveMacros('$HOSTNAME$', $svcMock), $svcMock->host_name); $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS$', $svcMock), $svcMock->host_address); + $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS6$', $svcMock), $svcMock->host_address6); $this->assertEquals(Macro::resolveMacros('$SERVICEDESC$', $svcMock), $svcMock->service_description); $this->assertEquals(Macro::resolveMacros('$host.name$', $svcMock), $svcMock->host_name); $this->assertEquals(Macro::resolveMacros('$host.address$', $svcMock), $svcMock->host_address); + $this->assertEquals(Macro::resolveMacros('$host.address6$', $svcMock), $svcMock->host_address6); $this->assertEquals(Macro::resolveMacros('$service.description$', $svcMock), $svcMock->service_description); } From 083900dae05ef9e499519135df390620ea4802c0 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 4 Aug 2015 14:06:33 +0200 Subject: [PATCH 2/6] Implement DblClickSelect as a Icinga Behavior refs #9826 --- library/Icinga/Web/JavaScript.php | 3 +- .../scripts/partials/host/object-header.phtml | 8 ++-- .../partials/service/object-header.phtml | 10 ++--- public/js/icinga/behavior/dblclickselect.js | 45 +++++++++++++++++++ 4 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 public/js/icinga/behavior/dblclickselect.js diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index ed39c1b39..dafdee32a 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -27,7 +27,8 @@ class JavaScript 'js/icinga/behavior/tristate.js', 'js/icinga/behavior/navigation.js', 'js/icinga/behavior/form.js', - 'js/icinga/behavior/actiontable.js' + 'js/icinga/behavior/actiontable.js', + 'js/icinga/behavior/dblclickselect.js' ); protected static $vendorFiles = array( diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 75cdf2cb9..b9ad79f00 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -10,17 +10,17 @@ use Icinga\Module\Monitoring\Object\Host; iconImage()->host($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>) render('partials/host/statusicons.phtml'); ?>
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 5a6fac2ea..67f48e195 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -11,16 +11,16 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->service($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>)
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> @@ -31,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->host($object) ?> - translate('Service'); ?>: escape($object->service_display_name); ?> + translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/public/js/icinga/behavior/dblclickselect.js b/public/js/icinga/behavior/dblclickselect.js new file mode 100644 index 000000000..142857063 --- /dev/null +++ b/public/js/icinga/behavior/dblclickselect.js @@ -0,0 +1,45 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +(function(Icinga, $) { + + "use strict"; + + Icinga.Behaviors = Icinga.Behaviors || {}; + + var DblClickSelect = function (icinga) { + Icinga.EventListener.call(this, icinga); + this.on('rendered', this.onRendered, this); + }; + DblClickSelect.prototype = new Icinga.EventListener(); + + DblClickSelect.prototype.onRendered = function(evt) { + $(evt.target).on('dblclick', '.dblclickselect', function() { $(this).selectText(); }); + }; + + /** + * extend jQuery with a selectText function + * + * This function will create a browser selection of the choosen DOM object. + */ + $.fn.selectText = function() { + if (this.length === 0) return; + var e = this[0]; + + var b = document.body, r; + if (b.createTextRange) { + r = b.createTextRange(); + r.moveToElementText(e); + r.select(); + } else if (window.getSelection) { + var s = window.getSelection(); + r = document.createRange(); + r.selectNodeContents(e); + s.removeAllRanges(); + s.addRange(r); + } + }; + + // Export + Icinga.Behaviors.DblClickSelect = DblClickSelect; + +}) (Icinga, jQuery); From 82914cf9a3794918d643909939fe7a0a00acdbe1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 28 Sep 2015 14:54:49 +0200 Subject: [PATCH 3/6] monitoring: Don't select unncessary columns in the hosts overview --- .../application/controllers/ListController.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b4d126275..d404ee00b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -58,8 +58,6 @@ class ListController extends Controller 'host_name', 'host_display_name', 'host_state' => $stateColumn, - 'host_address', - 'host_address6', 'host_acknowledged', 'host_output', 'host_attempt', @@ -67,15 +65,10 @@ class ListController extends Controller 'host_is_flapping', 'host_state_type', 'host_handled', - 'host_last_check', 'host_last_state_change' => $stateChangeColumn, 'host_notifications_enabled', - 'host_action_url', - 'host_notes_url', 'host_active_checks_enabled', - 'host_passive_checks_enabled', - 'host_current_check_attempt', - 'host_max_check_attempts' + 'host_passive_checks_enabled' ), $this->addColumns())); $this->applyRestriction('monitoring/filter/objects', $query); $this->filterQuery($query); From 2c73d9fad77b03b2d178f0d687a7a350367c4ca5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 28 Sep 2015 14:56:36 +0200 Subject: [PATCH 4/6] monitoring: Don't select unncessary columns in the services overview --- .../application/controllers/ListController.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index d404ee00b..d8be4970f 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -126,11 +126,6 @@ class ListController extends Controller 'host_name', 'host_display_name', 'host_state', - 'host_state_type', - 'host_last_state_change', - 'host_address', - 'host_address6', - 'host_handled', 'service_description', 'service_display_name', 'service_state' => $stateColumn, @@ -147,14 +142,9 @@ class ListController extends Controller 'service_state_type', 'service_handled', 'service_severity', - 'service_last_check', 'service_notifications_enabled', - 'service_action_url', - 'service_notes_url', 'service_active_checks_enabled', - 'service_passive_checks_enabled', - 'current_check_attempt' => 'service_current_check_attempt', - 'max_check_attempts' => 'service_max_check_attempts' + 'service_passive_checks_enabled' ), $this->addColumns()); $query = $this->backend->select()->from('servicestatus', $columns); $this->applyRestriction('monitoring/filter/objects', $query); From 3e06a9c8aa8e7deab0487913897fec0ca4027e3c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 28 Sep 2015 14:57:56 +0200 Subject: [PATCH 5/6] monitoring: Revert CSS styles for address6 support We're rewriting the whole style in a different branch. refs #9645 --- modules/monitoring/public/css/module.less | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 7fd37dbbe..405d2a6aa 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -4,17 +4,10 @@ width: 16em; } -.padded { - padding: 0 5px; -} - -.address, p.pluginoutput { - white-space: pre-wrap; - font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'DejaVu Sans Mono', 'Courier New', Courier, monospace; -} - p.pluginoutput { width: 100%; + white-space: pre-wrap; + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'DejaVu Sans Mono', 'Courier New', Courier, monospace; } table.action td .pluginoutput { From d03647f2e6c60c18378134014fabfd42a392a8ef Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 28 Sep 2015 15:44:25 +0200 Subject: [PATCH 6/6] JS: Rename dblclickselect to selectable refs #9826 --- library/Icinga/Web/JavaScript.php | 2 +- .../scripts/partials/host/object-header.phtml | 8 ++-- .../partials/service/object-header.phtml | 10 ++--- public/js/icinga/behavior/dblclickselect.js | 45 ------------------- public/js/icinga/behavior/selectable.js | 36 +++++++++++++++ 5 files changed, 46 insertions(+), 55 deletions(-) delete mode 100644 public/js/icinga/behavior/dblclickselect.js create mode 100644 public/js/icinga/behavior/selectable.js diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index b40fe8b30..6c53d6700 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -28,7 +28,7 @@ class JavaScript 'js/icinga/behavior/navigation.js', 'js/icinga/behavior/form.js', 'js/icinga/behavior/actiontable.js', - 'js/icinga/behavior/dblclickselect.js' + 'js/icinga/behavior/selectable.js' ); protected static $vendorFiles = array( diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index b9ad79f00..6b8cbc8d1 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -10,17 +10,17 @@ use Icinga\Module\Monitoring\Object\Host; iconImage()->host($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>) render('partials/host/statusicons.phtml'); ?>
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 67f48e195..908ddb37f 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -11,16 +11,16 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->service($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>)
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> @@ -31,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->host($object) ?> - translate('Service'); ?>: escape($object->service_display_name); ?> + translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/public/js/icinga/behavior/dblclickselect.js b/public/js/icinga/behavior/dblclickselect.js deleted file mode 100644 index 142857063..000000000 --- a/public/js/icinga/behavior/dblclickselect.js +++ /dev/null @@ -1,45 +0,0 @@ -/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ - -(function(Icinga, $) { - - "use strict"; - - Icinga.Behaviors = Icinga.Behaviors || {}; - - var DblClickSelect = function (icinga) { - Icinga.EventListener.call(this, icinga); - this.on('rendered', this.onRendered, this); - }; - DblClickSelect.prototype = new Icinga.EventListener(); - - DblClickSelect.prototype.onRendered = function(evt) { - $(evt.target).on('dblclick', '.dblclickselect', function() { $(this).selectText(); }); - }; - - /** - * extend jQuery with a selectText function - * - * This function will create a browser selection of the choosen DOM object. - */ - $.fn.selectText = function() { - if (this.length === 0) return; - var e = this[0]; - - var b = document.body, r; - if (b.createTextRange) { - r = b.createTextRange(); - r.moveToElementText(e); - r.select(); - } else if (window.getSelection) { - var s = window.getSelection(); - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - }; - - // Export - Icinga.Behaviors.DblClickSelect = DblClickSelect; - -}) (Icinga, jQuery); diff --git a/public/js/icinga/behavior/selectable.js b/public/js/icinga/behavior/selectable.js new file mode 100644 index 000000000..a628ed729 --- /dev/null +++ b/public/js/icinga/behavior/selectable.js @@ -0,0 +1,36 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +;(function(Icinga, $) { + 'use strict'; + + Icinga.Behaviors = Icinga.Behaviors || {}; + + var Selectable = function(icinga) { + Icinga.EventListener.call(this, icinga); + this.on('rendered', this.onRendered, this); + }; + + $.extend(Selectable.prototype, new Icinga.EventListener(), { + onRendered: function(e) { + $('.selectable', e.target).on('dblclick', e.data.self.selectText); + }, + + selectText: function(e) { + var b = document.body, + r; + if (b.createTextRange) { + r = b.createTextRange(); + r.moveToElementText(e.target); + r.select(); + } else if (window.getSelection) { + var s = window.getSelection(); + r = document.createRange(); + r.selectNodeContents(e.target); + s.removeAllRanges(); + s.addRange(r); + } + } + }); + + Icinga.Behaviors.Selectable = Selectable; +})(Icinga, jQuery);