show log message in toastr
This commit is contained in:
@@ -12,11 +12,11 @@ ajax '/ajax/portcontrol' => sub {
|
||||
(param('action') || ''), (param('value') || '');
|
||||
|
||||
my %action_map = (
|
||||
'location' => 'location',
|
||||
'contact' => 'contact',
|
||||
'c_port' => 'portcontrol',
|
||||
'c_name' => 'portname',
|
||||
'c_vlan' => 'vlan',
|
||||
'location' => 'location',
|
||||
'contact' => 'contact',
|
||||
'c_port' => 'portcontrol',
|
||||
'c_name' => 'portname',
|
||||
'c_vlan' => 'vlan',
|
||||
);
|
||||
|
||||
my $action = $action_map{ param('field') };
|
||||
@@ -25,14 +25,14 @@ ajax '/ajax/portcontrol' => sub {
|
||||
: param('value'));
|
||||
|
||||
schema('netdisco')->resultset('Admin')->create({
|
||||
device => param('device'),
|
||||
port => param('port'),
|
||||
action => $action,
|
||||
subaction => $subaction,
|
||||
status => 'queued',
|
||||
username => session('user'),
|
||||
userip => request->remote_address,
|
||||
log => $log,
|
||||
device => param('device'),
|
||||
port => param('port'),
|
||||
action => $action,
|
||||
subaction => $subaction,
|
||||
status => 'queued',
|
||||
username => session('user'),
|
||||
userip => request->remote_address,
|
||||
log => $log,
|
||||
});
|
||||
}
|
||||
catch {
|
||||
@@ -54,8 +54,14 @@ ajax '/ajax/userlog' => sub {
|
||||
});
|
||||
|
||||
my %status = (
|
||||
'done' => $rs->search({status => 'done'})->count(),
|
||||
'error' => $rs->search({status => 'error'})->count(),
|
||||
'done' => [
|
||||
map {s/\[\]/<empty>/; $_}
|
||||
$rs->search({status => 'done'})->get_column('log')->all
|
||||
],
|
||||
'error' => [
|
||||
map {s/\[\]/<empty>/; $_}
|
||||
$rs->search({status => 'error'})->get_column('log')->all
|
||||
],
|
||||
);
|
||||
|
||||
content_type('application/json');
|
||||
|
||||
@@ -30,18 +30,12 @@ function port_control (e) {
|
||||
,success: function(data) {
|
||||
// console.log(data);
|
||||
|
||||
if (data['error'] == 1 ) {
|
||||
toastr.error('1 recent failed change request');
|
||||
}
|
||||
else if (data['error'] > 1) {
|
||||
toastr.error(data['error'] + ' recent failed change requests');
|
||||
for (var i = 0; i < data['error'].length; i++) {
|
||||
toastr.error(data['error'][i], 'Failed Change Request');
|
||||
}
|
||||
|
||||
if (data['done'] == 1 ) {
|
||||
toastr.success('1 recent successful change request');
|
||||
}
|
||||
else if (data['done'] > 1) {
|
||||
toastr.success(data['done'] + ' recent successful change requests');
|
||||
for (var i = 0; i < data['done'].length; i++) {
|
||||
toastr.success(data['done'][i], 'Successful Change Request');
|
||||
}
|
||||
|
||||
// Schedule next request when the current one's complete
|
||||
|
||||
Reference in New Issue
Block a user