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