implement host_group_displaynames and fix vlan save bug

This commit is contained in:
Oliver Gorwits
2017-12-23 22:06:24 +00:00
parent 35ed34ed2f
commit 9a13bb7f9b
5 changed files with 33 additions and 18 deletions

View File

@@ -16,6 +16,7 @@ set('connected_properties' => [
]);
hook 'before_template' => sub {
my $tokens = shift;
my $defaults = var('sidebar_defaults')->{'device_ports'}
or return;
@@ -34,6 +35,13 @@ hook 'before_template' => sub {
}
}
# used in the device search sidebar template to set selected items
foreach my $opt (qw/devgrp/) {
my $p = (ref [] eq ref param($opt) ? param($opt)
: (param($opt) ? [param($opt)] : []));
$tokens->{"${opt}_lkp"} = { map { $_ => 1 } @$p };
}
return if param('reset')
or not var('sidebar_key') or (var('sidebar_key') ne 'device_ports');
@@ -69,6 +77,7 @@ get '/device' => require_login sub {
params->{'tab'} ||= 'details';
template 'device', {
display_name => ($others ? $first->ip : ($first->dns || $first->ip)),
devgrp_list => setting('host_group_displaynames'),
device => params->{'tab'},
};
};

View File

@@ -133,6 +133,7 @@ sidebar_defaults:
mac_format: { default: IEEE }
neigh_id: { default: null }
device_netmap:
mapshow: { default: neighbors }
colorgroups: { default: checked }
report_moduleinventory:
fruonly: { default: checked }
@@ -180,6 +181,7 @@ host_groups:
- '::1'
- 'fe80::/10'
- '127.0.0.0/8'
host_group_displaynames: {}
device_identity: []
community: []
community_rw: []

View File

@@ -634,7 +634,7 @@ form .clearfix.success input {
}
.nd_netmap-sidebar {
margin-top: 7px;
/* margin-top: 7px; */
margin-left: -9px;
}

View File

@@ -120,9 +120,10 @@
});
$('#nd_netmap-save').on('click', function(event) {
event.preventDefault();
// if user enters vlan but does not submit this will save wrong data
$.post(
'[% uri_for('/ajax/data/device/netmappositions') %]'
,'vlan=[% params.vlan %]&positions=' + JSON.stringify(graph.positions())
,'vlan=' + $('#nd_vlan-entry').val() + '&positions=' + JSON.stringify(graph.positions())
);
});
$('#nd_netmap-zoomtodevice').on('click', function(event) {

View File

@@ -51,16 +51,18 @@
<div class="radio radio-success">
<input type="radio" name="mapshow" id="nd_mapshow-all"
[% 'checked' IF params.mapshow == 'all' %] value="all">
[% 'checked' IF vars.sidebar_defaults.device_netmap.mapshow == 'all' %] value="all">
<label for="nd_mapshow-all">All Devices</label>
</div>
<div class="radio radio-success">
<input type="radio" name="mapshow" id="nd_mapshow-neighbors" value="neighbors" checked>
<input type="radio" name="mapshow" id="nd_mapshow-neighbors"
[% 'checked' IF vars.sidebar_defaults.device_netmap.mapshow == 'neighbors' %] value="neighbors">
<label for="nd_mapshow-neighbors">Neighbors Only</label>
</div>
<div class="radio radio-success">
<input type="radio" name="mapshow" id="nd_mapshow-only"
[% 'checked' IF vars.sidebar_defaults.device_netmap.mapshow == 'only' %]
[% 'disabled' IF NOT devgrp_list.size %] value="only">
<label for="nd_mapshow-only">Host Groups</label>
</div>
@@ -70,8 +72,9 @@
<select class="nd_side-select" size="[% devgrp_list.size > 5 ? 5 : devgrp_list.size %]"
multiple="on" name="devgrp"
rel="tooltip" data-placement="left" data-offset="5" data-title="Host Groups"/>
[% FOREACH opt IN devgrp_list %]
<option[% ' selected="selected"' IF os_lkp.exists(opt) %]>[% opt | html_entity %]</option>
[% FOREACH opt IN devgrp_list.pairs %]
<option[% ' selected="selected"' IF devgrp_lkp.exists(opt.key) %]
value="[% opt.key %]">[% opt.value | html_entity %]</option>
[% END %]
</select>
</div>
@@ -82,8 +85,8 @@
[% IF devgrp_list.size %]
<div class="clearfix input-prepend">
<label class="add-on">
<input type="checkbox" id="colorgroups"
name="colorgroups"[% ' checked="checked"' IF vars.sidebar_defaults.device_netmap.colorgroups %]/>
<input type="checkbox" id="colorgroups" name="colorgroups"
[% 'checked="checked"' IF vars.sidebar_defaults.device_netmap.colorgroups %]/>
</label>
<label class="nd_checkboxlabel" for="colorgroups">
<span class="nd_searchcheckbox uneditable-input">Color Groups</span>
@@ -91,6 +94,16 @@
</div>
[% END %]
<div class="clearfix input-prepend">
<label class="add-on">
<input type="checkbox" id="dynamicsize" name="dynamicsize" disabled
[% 'checked="checked"' IF params.dynamicsize %]/>
</label>
<label class="nd_checkboxlabel" for="dynamicsize">
<span class="nd_searchcheckbox uneditable-input">Dynamic Size</span>
</label>
</div>
<div id="nd_vlan-label" class="control-group">
<div class="controls">
<label><span id="nd_vlan-label-text">Carrying VLAN: </span>
@@ -100,16 +113,6 @@
</div>
</div>
<div class="clearfix input-prepend">
<label class="add-on">
<input type="checkbox" id="dynamicsize" disabled
name="dynamicsize"[% ' checked="checked"' IF vars.sidebar_defaults.device_netmap.dynamicsize %]/>
</label>
<label class="nd_checkboxlabel" for="dynamicsize">
<span class="nd_searchcheckbox uneditable-input">Dynamic Size</span>
</label>
</div>
</div>
<button id="[% tab.tag %]_submit" type="submit" class="btn btn-info">