diff --git a/Changes b/Changes index 6bcf003b..4e3aaeae 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.052009 - 2022-06-xx + + [NEW FEATURES] + + * #889 implement renumber in the web interface + 2.052008 - 2022-06-12 [NEW FEATURES] diff --git a/lib/App/Netdisco/Web/AdminTask.pm b/lib/App/Netdisco/Web/AdminTask.pm index a740ba88..2c7df48d 100644 --- a/lib/App/Netdisco/Web/AdminTask.pm +++ b/lib/App/Netdisco/Web/AdminTask.pm @@ -7,7 +7,7 @@ use Dancer::Plugin::Auth::Extensible; use NetAddr::IP qw/:rfc3021 :lower/; use App::Netdisco::JobQueue 'jq_insert'; -use App::Netdisco::Util::Device 'delete_device'; +use App::Netdisco::Util::Device qw/delete_device renumber_device/; sub add_job { my ($action, $device, $subaction) = @_; @@ -46,6 +46,21 @@ foreach my $action (@{ setting('job_prio')->{high} }, }; } +ajax qr{/ajax/control/admin/(?:\w+/)?renumber} => require_role setting('defanged_admin') => sub { + send_error('Missing device', 400) unless param('device'); + send_error('Missing new IP', 400) unless param('newip'); + + my $device = NetAddr::IP->new(param('device')); + send_error('Bad device', 400) + if ! $device or $device->addr eq '0.0.0.0'; + + my $newip = NetAddr::IP->new(param('newip')); + send_error('Bad new IP', 400) + if ! $newip or $newip->addr eq '0.0.0.0'; + + return renumber_device( $device->addr, $newip->addr ); +}; + ajax qr{/ajax/control/admin/(?:\w+/)?delete} => require_role setting('defanged_admin') => sub { send_error('Missing device', 400) unless param('device'); diff --git a/share/public/css/netdisco.css b/share/public/css/netdisco.css index c2f27456..8b8234e1 100644 --- a/share/public/css/netdisco.css +++ b/share/public/css/netdisco.css @@ -219,6 +219,11 @@ td > form.nd_inline-form { margin-bottom: 2px; } +/* pull right admin buttons in the device details view */ +.nd_pull-right-admin-button { + margin-right: 4px; +} + /* fix layout of form fields inside the (pseudo devices) table */ .nd_center-cell input { margin-bottom: 0px; diff --git a/share/views/ajax/device/details.tt b/share/views/ajax/device/details.tt index 0fc07588..002abb44 100644 --- a/share/views/ajax/device/details.tt +++ b/share/views/ajax/device/details.tt @@ -201,6 +201,10 @@ + + +
+ + [% END %]