remove job types from web code
This commit is contained in:
@@ -7,23 +7,8 @@ use Dancer::Plugin::Auth::Extensible;
|
|||||||
|
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
|
|
||||||
# we have a separate list for jobs needing a device to avoid queueing
|
|
||||||
# such a job when there's no device param (it could still be duff, tho).
|
|
||||||
my %jobs = map { $_ => 1} qw/
|
|
||||||
discover
|
|
||||||
macsuck
|
|
||||||
arpnip
|
|
||||||
nbtstat
|
|
||||||
/;
|
|
||||||
my %jobs_all = map {$_ => 1} qw/
|
|
||||||
discoverall
|
|
||||||
macwalk
|
|
||||||
arpwalk
|
|
||||||
nbtwalk
|
|
||||||
/;
|
|
||||||
|
|
||||||
sub add_job {
|
sub add_job {
|
||||||
my ($jobtype, $device, $subaction) = @_;
|
my ($action, $device, $subaction) = @_;
|
||||||
|
|
||||||
if ($device) {
|
if ($device) {
|
||||||
$device = NetAddr::IP::Lite->new($device);
|
$device = NetAddr::IP::Lite->new($device);
|
||||||
@@ -35,28 +20,22 @@ sub add_job {
|
|||||||
try {
|
try {
|
||||||
schema('netdisco')->resultset('Admin')->create({
|
schema('netdisco')->resultset('Admin')->create({
|
||||||
($device ? (device => $device->addr) : ()),
|
($device ? (device => $device->addr) : ()),
|
||||||
action => $jobtype,
|
action => $action,
|
||||||
($subaction ? (subaction => $subaction) : ()),
|
($subaction ? (subaction => $subaction) : ()),
|
||||||
status => 'queued',
|
status => 'queued',
|
||||||
(exists $jobs{$jobtype} ? (username => session('logged_in_user')) : ()),
|
username => session('logged_in_user'),
|
||||||
userip => request->remote_address,
|
userip => request->remote_address,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $jobtype (keys %jobs_all, keys %jobs) {
|
foreach my $action (keys %{ setting('job_types') }) {
|
||||||
ajax "/ajax/control/admin/$jobtype" => require_role admin => sub {
|
ajax "/ajax/control/admin/$action" => require_role admin => sub {
|
||||||
send_error('Missing device', 400)
|
add_job($action, param('device'), param('extra'));
|
||||||
if exists $jobs{$jobtype} and not param('device');
|
|
||||||
|
|
||||||
add_job($jobtype, param('device'), param('extra'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
post "/admin/$jobtype" => require_role admin => sub {
|
post "/admin/$action" => require_role admin => sub {
|
||||||
send_error('Missing device', 400)
|
add_job($action, param('device'), param('extra'));
|
||||||
if exists $jobs{$jobtype} and not param('device');
|
|
||||||
|
|
||||||
add_job($jobtype, param('device'), param('extra'));
|
|
||||||
redirect uri_for('/admin/jobqueue')->path;
|
redirect uri_for('/admin/jobqueue')->path;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user