Merge branch 'feature/ipv6-addresses-9645-9826'

resolves #9645
resolves #9826
This commit is contained in:
Eric Lippmann 2015-09-28 15:49:58 +02:00
commit 0dc6925561
16 changed files with 80 additions and 34 deletions

View File

@ -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/selectable.js'
);
protected static $vendorFiles = array(

View File

@ -77,6 +77,7 @@ class HostController extends MonitoredObjectController
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_handled',
'service_description',
'service_display_name',

View File

@ -55,6 +55,7 @@ class HostsController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',
@ -92,6 +93,7 @@ class HostsController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',

View File

@ -58,7 +58,6 @@ class ListController extends Controller
'host_name',
'host_display_name',
'host_state' => $stateColumn,
'host_address',
'host_acknowledged',
'host_output',
'host_attempt',
@ -66,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);
@ -132,10 +126,6 @@ class ListController extends Controller
'host_name',
'host_display_name',
'host_state',
'host_state_type',
'host_last_state_change',
'host_address',
'host_handled',
'service_description',
'service_display_name',
'service_state' => $stateColumn,
@ -152,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);

View File

@ -56,6 +56,7 @@ class ServicesController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_output',
'host_state',
'host_problem',
@ -101,6 +102,7 @@ class ServicesController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_output',
'host_state',
'host_problem',

View File

@ -10,15 +10,18 @@ use Icinga\Module\Monitoring\Object\Host;
</td>
<td>
<?= $this->iconImage()->host($object) ?>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<strong class="selectable"><?= $this->escape($object->host_display_name); ?></strong>
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<small class="selectable">(<?= $this->escape($object->host_name); ?>)</small>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
<br/>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<span class="selectable" title="IPv6 address"><?= $this->escape($object->host_address6); ?></span>
<?php endif ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address); ?>
<span class="selectable" title="IPv4 address"><?= $this->escape($object->host_address); ?></span>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
</td>
</tr>
</table>

View File

@ -11,15 +11,17 @@ use Icinga\Module\Monitoring\Object\Service;
</td>
<td>
<?= $this->iconImage()->service($object) ?>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<strong class="selectable"><?= $this->escape($object->host_display_name); ?></strong>
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<small class="selectable">(<?= $this->escape($object->host_name); ?>)</small>
<?php endif ?>
<br/>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<span class="selectable" title="IPv6 address"><?= $this->escape($object->host_address6); ?></span>
<?php endif ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address); ?>
<span class="selectable" title="IPv4 address"><?= $this->escape($object->host_address); ?></span>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
</td>
</tr>
<tr class="state <?= Service::getStateText($object->service_state); ?><?= $object->service_handled ? ' handled' : ''; ?>">
@ -29,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service;
</td>
<td>
<?= $this->iconImage()->host($object) ?>
<strong><?= $this->translate('Service'); ?>: <?= $this->escape($object->service_display_name); ?></strong>
<strong><?= $this->translate('Service'); ?>: <span class="selectable"><?= $this->escape($object->service_display_name); ?></span></strong>
<?php if ($object->service_display_name !== $object->service_description): ?>
<small>(<?= $this->escape($object->service_description); ?>)</small>
<?php endif ?>

View File

@ -28,6 +28,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',

View File

@ -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',

View File

@ -16,6 +16,7 @@ class HostStatus extends DataView
'host_display_name',
'host_alias',
'host_address',
'host_address6',
'host_state',
'host_state_type',
'host_handled',

View File

@ -18,6 +18,7 @@ class ServiceStatus extends DataView
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_problem',
'host_handled',
'service_description',

View File

@ -95,6 +95,7 @@ class Host extends MonitoredObject
'host_active_checks_enabled',
'host_active_checks_enabled_changed',
'host_address',
'host_address6',
'host_alias',
'host_attempt',
'host_check_command',

View File

@ -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'
);

View File

@ -112,6 +112,7 @@ class Service extends MonitoredObject
'host_acknowledged',
'host_active_checks_enabled',
'host_address',
'host_address6',
'host_alias',
'host_display_name',
'host_handled',

View File

@ -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);
}

View File

@ -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);