#788 use device.name instead of device.dns for pseudo devices

This commit is contained in:
Oliver Gorwits
2021-07-14 12:04:29 +01:00
parent 668bcbe503
commit 0d1dc39d33
5 changed files with 15 additions and 9 deletions

View File

@@ -8,6 +8,7 @@
[BUG FIXES]
* #784 empty device_skip table when also emptying job queue
* #788 use device.name instead of device.dns for pseudo devices
2.047005 - 2021-02-24

View File

@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
);
our # try to hide from kwalitee
$VERSION = 64; # schema version used for upgrades, keep as integer
$VERSION = 65; # schema version used for upgrades, keep as integer
use Path::Class;
use File::ShareDir 'dist_dir';

View File

@@ -14,9 +14,9 @@ register_admin_task({
});
sub _sanity_ok {
return 0 unless param('dns')
and param('dns') =~ m/^[[:print:]]+$/
and param('dns') !~ m/[[:space:]]/;
return 0 unless param('name')
and param('name') =~ m/^[[:print:]]+$/
and param('name') !~ m/[[:space:]]/;
my $ip = NetAddr::IP::Lite->new(param('ip'));
return 0 unless ($ip and $ip->addr ne '0.0.0.0');
@@ -34,7 +34,7 @@ ajax '/ajax/control/admin/pseudodevice/add' => require_role admin => sub {
my $device = schema('netdisco')->resultset('Device')
->create({
ip => param('ip'),
dns => param('dns'),
name => param('name'),
vendor => 'netdisco',
layers => param('layers'),
last_discover => \'now()',

View File

@@ -0,0 +1,5 @@
BEGIN;
UPDATE device SET name = dns WHERE vendor = 'netdisco';
COMMIT;

View File

@@ -10,7 +10,7 @@
</thead>
<tbody>
<tr>
<td class="nd_center-cell"><input data-form="add" name="dns" type="text"></td>
<td class="nd_center-cell"><input data-form="add" name="name" type="text"></td>
<td class="nd_center-cell"><input data-form="add" name="ip" type="text"></td>
<td class="nd_center-cell"><input data-form="add" name="ports" type="number" value="1"></td>
<td class="nd_center-cell">
@@ -27,7 +27,7 @@
[% SET count = count + 1 %]
<tr>
<td class="nd_center-cell"><a class="nd_linkcell"
href="[% uri_for('/device') | none %]?q=[% row.ip | uri %]">[% row.dns | html_entity %]</a></td>
href="[% uri_for('/device') | none %]?q=[% row.ip | uri %]">[% row.name | html_entity %]</a></td>
<td class="nd_center-cell">[% row.ip | html_entity %]</td>
<td class="nd_center-cell">
<input data-form="update" name="ports" type="number" value="[% row.port_count | html_entity %]">
@@ -38,7 +38,7 @@
<input data-form="update" name="layers" type="hidden" value="[% row.layers | html_entity %]">
</td>
<td class="nd_center-cell">
<input data-form="update" name="dns" type="hidden" value="[% row.dns | html_entity %]">
<input data-form="update" name="name" type="hidden" value="[% row.name | html_entity %]">
<input data-form="update" name="ip" type="hidden" value="[% row.ip | html_entity %]">
<button class="btn nd_adminbutton" name="update" type="submit"><i class="icon-save text-warning"></i></button>
@@ -54,7 +54,7 @@
<div class="modal-body">
<blockquote>
<p class="text-info">
Pseudo-device &quot;[% row.dns | html_entity %] / [% row.ip | html_entity %]&quot; will be deleted.</p>
Pseudo-device &quot;[% row.name | html_entity %] / [% row.ip | html_entity %]&quot; will be deleted.</p>
</blockquote>
<input data-form="delete" name="device" type="hidden" value="[% row.ip | html_entity %]">
</div>