fix(docker-event-display): EE-1968: support (event_name)[:extra info] for all event Actions, and append it to the output details (#6092)

Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
pull/6176/head
Sven Dowideit 3 years ago committed by GitHub
parent c24dc3112b
commit 120584909c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,9 +1,18 @@
function createEventDetails(event) { function createEventDetails(event) {
var eventAttr = event.Actor.Attributes; var eventAttr = event.Actor.Attributes;
var details = ''; var details = '';
var action = event.Action;
var extra = '';
var hasColon = action.indexOf(':');
if (hasColon != -1) {
extra = action.substring(hasColon);
action = action.substring(0, hasColon);
}
switch (event.Type) { switch (event.Type) {
case 'container': case 'container':
switch (event.Action) { switch (action) {
case 'stop': case 'stop':
details = 'Container ' + eventAttr.name + ' stopped'; details = 'Container ' + eventAttr.name + ' stopped';
break; break;
@ -64,20 +73,21 @@ function createEventDetails(event) {
case 'update': case 'update':
details = 'Container ' + eventAttr.name + ' updated'; details = 'Container ' + eventAttr.name + ' updated';
break; break;
case 'exec_create':
details = 'Exec instance created';
break;
case 'exec_start':
details = 'Exec instance started';
break;
case 'exec_die':
details = 'Exec instance exited';
break;
default: default:
if (event.Action.indexOf('exec_create') === 0) { details = 'Unsupported event';
details = 'Exec instance created';
} else if (event.Action.indexOf('exec_start') === 0) {
details = 'Exec instance started';
} else if (event.Action.indexOf('exec_die') === 0) {
details = 'Exec instance exited ';
} else {
details = 'Unsupported event';
}
} }
break; break;
case 'image': case 'image':
switch (event.Action) { switch (action) {
case 'delete': case 'delete':
details = 'Image deleted'; details = 'Image deleted';
break; break;
@ -107,7 +117,7 @@ function createEventDetails(event) {
} }
break; break;
case 'network': case 'network':
switch (event.Action) { switch (action) {
case 'create': case 'create':
details = 'Network ' + eventAttr.name + ' created'; details = 'Network ' + eventAttr.name + ' created';
break; break;
@ -128,7 +138,7 @@ function createEventDetails(event) {
} }
break; break;
case 'volume': case 'volume':
switch (event.Action) { switch (action) {
case 'create': case 'create':
details = 'Volume ' + event.Actor.ID + ' created'; details = 'Volume ' + event.Actor.ID + ' created';
break; break;
@ -148,7 +158,7 @@ function createEventDetails(event) {
default: default:
details = 'Unsupported event'; details = 'Unsupported event';
} }
return details; return details + extra;
} }
export function EventViewModel(data) { export function EventViewModel(data) {

Loading…
Cancel
Save