complete job queue delete and kill running timers properly when reloading page
This commit is contained in:
@@ -4,10 +4,13 @@
|
|||||||
|
|
||||||
* Finally we have a discover/refresh daemon job :)
|
* Finally we have a discover/refresh daemon job :)
|
||||||
* Also... a Scheduler which removes need for crontab installation
|
* 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
|
* Select MAC Address display format on Node and Device Port search
|
||||||
* Helper script to import the Netdisco 1.x Topology file to the database
|
* Helper script to import the Netdisco 1.x Topology file to the database
|
||||||
* Support for pseudo devices (useful for dummy device links)
|
* 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]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ register_admin_task({
|
|||||||
label => 'Job Queue',
|
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 {
|
ajax '/ajax/content/admin/jobqueue' => sub {
|
||||||
return unless var('user') and var('user')->admin;
|
return unless var('user') and var('user')->admin;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ sub _sanity_ok {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ajax '/ajax/content/admin/pseudodevice/add' => sub {
|
ajax '/ajax/control/admin/pseudodevice/add' => sub {
|
||||||
return unless _sanity_ok();
|
return unless _sanity_ok();
|
||||||
|
|
||||||
schema('netdisco')->txn_do(sub {
|
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();
|
return unless _sanity_ok();
|
||||||
|
|
||||||
schema('netdisco')->txn_do(sub {
|
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();
|
return unless _sanity_ok();
|
||||||
|
|
||||||
schema('netdisco')->txn_do(sub {
|
schema('netdisco')->txn_do(sub {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ sub _sanity_ok {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ajax '/ajax/content/admin/topology/add' => sub {
|
ajax '/ajax/control/admin/topology/add' => sub {
|
||||||
return unless _sanity_ok();
|
return unless _sanity_ok();
|
||||||
|
|
||||||
my $device = schema('netdisco')->resultset('Topology')
|
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();
|
return unless _sanity_ok();
|
||||||
|
|
||||||
schema('netdisco')->txn_do(sub {
|
schema('netdisco')->txn_do(sub {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<table class="table table-bordered table-condensed">
|
<table class="table table-bordered table-condensed table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="nd_center-cell">Entered</th>
|
<th class="nd_center-cell">Entered</th>
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
// ajax content is loaded
|
// ajax content is loaded
|
||||||
var path = 'admin';
|
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
|
// this is called by do_search to support local code
|
||||||
// which might need to act on the newly inserted content
|
// which might need to act on the newly inserted content
|
||||||
// but which cannot use jQuery delegation via .on()
|
// but which cannot use jQuery delegation via .on()
|
||||||
@@ -10,18 +13,23 @@
|
|||||||
// reload this table every 10 seconds
|
// reload this table every 10 seconds
|
||||||
if (tab == 'jobqueue') {
|
if (tab == 'jobqueue') {
|
||||||
$('#nd_device-name').text('10');
|
$('#nd_device-name').text('10');
|
||||||
setTimeout(function() { $('#nd_device-name').text('9') }, 1000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('9') }, 1000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('8') }, 2000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('8') }, 2000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('7') }, 3000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('7') }, 3000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('6') }, 4000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('6') }, 4000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('5') }, 5000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('5') }, 5000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('4') }, 6000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('4') }, 6000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('3') }, 7000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('3') }, 7000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('2') }, 8000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('2') }, 8000 ));
|
||||||
setTimeout(function() { $('#nd_device-name').text('1') }, 9000 );
|
nd_timers.push(setTimeout(function() { $('#nd_device-name').text('1') }, 9000 ));
|
||||||
setTimeout(function() {
|
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');
|
$('#' + tab + '_form').trigger('submit');
|
||||||
}, 10000);
|
}, 10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// activate typeahead on the topo boxes
|
// activate typeahead on the topo boxes
|
||||||
@@ -79,16 +87,21 @@
|
|||||||
// stop form from submitting normally
|
// stop form from submitting normally
|
||||||
event.preventDefault();
|
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
|
// submit the query and put results into the tab pane
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
,async: true
|
,async: true
|
||||||
,dataType: 'html'
|
,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()
|
,data: $(this).serializeArray()
|
||||||
,beforeSend: function() {
|
,beforeSend: function() {
|
||||||
$(target).html(
|
$(target).html(
|
||||||
'<div class="span2 alert">Waiting for results...</div>'
|
'<div class="span2 alert">Request submitted...</div>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
,success: function(content) {
|
,success: function(content) {
|
||||||
@@ -97,7 +110,7 @@
|
|||||||
,error: function() {
|
,error: function() {
|
||||||
$(target).html(
|
$(target).html(
|
||||||
'<div class="span5 alert alert-error">' +
|
'<div class="span5 alert alert-error">' +
|
||||||
'Update failed! Please contact your site administrator.</div>'
|
'Request failed! Please contact your site administrator.</div>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user