diff --git a/Netdisco/Changes b/Netdisco/Changes index 680aa8fd..d4eb608a 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -4,10 +4,13 @@ * Finally we have a discover/refresh daemon job :) * Also... a Scheduler which removes need for crontab installation - * The netdisco-do script can run any one-off job + * The netdisco-do script can queue any one-off job * Select MAC Address display format on Node and Device Port search * Helper script to import the Netdisco 1.x Topology file to the database * Support for pseudo devices (useful for dummy device links) + * Manual Topology editing via the web + * Job Queue view and delete page + * Empty device table prompts initial discover on homepage [ENHANCEMENTS] diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/JobQueue.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/JobQueue.pm index 49efcdc2..8a67a359 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/JobQueue.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/JobQueue.pm @@ -11,6 +11,16 @@ register_admin_task({ label => 'Job Queue', }); +ajax '/ajax/control/admin/jobqueue/del' => sub { + return unless var('user') and var('user')->admin; + return unless length param('job'); + + schema('netdisco')->txn_do(sub { + my $device = schema('netdisco')->resultset('Admin') + ->search({job => param('job')})->delete; + }); +}; + ajax '/ajax/content/admin/jobqueue' => sub { return unless var('user') and var('user')->admin; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm index d6ea76df..64fe8b06 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm @@ -28,7 +28,7 @@ sub _sanity_ok { return 1; } -ajax '/ajax/content/admin/pseudodevice/add' => sub { +ajax '/ajax/control/admin/pseudodevice/add' => sub { return unless _sanity_ok(); schema('netdisco')->txn_do(sub { @@ -48,7 +48,7 @@ ajax '/ajax/content/admin/pseudodevice/add' => sub { }); }; -ajax '/ajax/content/admin/pseudodevice/del' => sub { +ajax '/ajax/control/admin/pseudodevice/del' => sub { return unless _sanity_ok(); schema('netdisco')->txn_do(sub { @@ -60,7 +60,7 @@ ajax '/ajax/content/admin/pseudodevice/del' => sub { }); }; -ajax '/ajax/content/admin/pseudodevice/update' => sub { +ajax '/ajax/control/admin/pseudodevice/update' => sub { return unless _sanity_ok(); schema('netdisco')->txn_do(sub { diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/Topology.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/Topology.pm index 269213bf..f18e0579 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/Topology.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/Topology.pm @@ -27,7 +27,7 @@ sub _sanity_ok { return 1; } -ajax '/ajax/content/admin/topology/add' => sub { +ajax '/ajax/control/admin/topology/add' => sub { return unless _sanity_ok(); my $device = schema('netdisco')->resultset('Topology') @@ -39,7 +39,7 @@ ajax '/ajax/content/admin/topology/add' => sub { }); }; -ajax '/ajax/content/admin/topology/del' => sub { +ajax '/ajax/control/admin/topology/del' => sub { return unless _sanity_ok(); schema('netdisco')->txn_do(sub { diff --git a/Netdisco/share/views/ajax/admintask/jobqueue.tt b/Netdisco/share/views/ajax/admintask/jobqueue.tt index 9a818ef0..56ade7fd 100644 --- a/Netdisco/share/views/ajax/admintask/jobqueue.tt +++ b/Netdisco/share/views/ajax/admintask/jobqueue.tt @@ -1,4 +1,4 @@ -
| Entered | diff --git a/Netdisco/share/views/js/admintask.js b/Netdisco/share/views/js/admintask.js index 3a6e1fba..7d405e3c 100644 --- a/Netdisco/share/views/js/admintask.js +++ b/Netdisco/share/views/js/admintask.js @@ -2,6 +2,9 @@ // ajax content is loaded var path = 'admin'; + // keep track of timers so we can kill them + var nd_timers = new Array(); + // this is called by do_search to support local code // which might need to act on the newly inserted content // but which cannot use jQuery delegation via .on() @@ -10,18 +13,23 @@ // reload this table every 10 seconds if (tab == 'jobqueue') { $('#nd_device-name').text('10'); - setTimeout(function() { $('#nd_device-name').text('9') }, 1000 ); - setTimeout(function() { $('#nd_device-name').text('8') }, 2000 ); - setTimeout(function() { $('#nd_device-name').text('7') }, 3000 ); - setTimeout(function() { $('#nd_device-name').text('6') }, 4000 ); - setTimeout(function() { $('#nd_device-name').text('5') }, 5000 ); - setTimeout(function() { $('#nd_device-name').text('4') }, 6000 ); - setTimeout(function() { $('#nd_device-name').text('3') }, 7000 ); - setTimeout(function() { $('#nd_device-name').text('2') }, 8000 ); - setTimeout(function() { $('#nd_device-name').text('1') }, 9000 ); - setTimeout(function() { + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('9') }, 1000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('8') }, 2000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('7') }, 3000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('6') }, 4000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('5') }, 5000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('4') }, 6000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('3') }, 7000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('2') }, 8000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('1') }, 9000 )); + nd_timers.push(setTimeout(function() { + // clear any running timers + for (var i = 0; i < nd_timers.length; i++) { + clearTimeout(nd_timers[i]); + } + // reload the tab content $('#' + tab + '_form').trigger('submit'); - }, 10000); + }, 10000)); } // activate typeahead on the topo boxes @@ -79,16 +87,21 @@ // stop form from submitting normally event.preventDefault(); + // clear any running timers + for (var i = 0; i < nd_timers.length; i++) { + clearTimeout(nd_timers[i]); + } + // submit the query and put results into the tab pane $.ajax({ type: 'POST' ,async: true ,dataType: 'html' - ,url: uri_base + '/ajax/content/admin/' + tab + '/' + $(this).attr('name') + ,url: uri_base + '/ajax/control/admin/' + tab + '/' + $(this).attr('name') ,data: $(this).serializeArray() ,beforeSend: function() { $(target).html( - '
|---|