fix(containers): add support for the 'dead' status (#1048)

pull/1052/head
Anthony Lapenna 7 years ago committed by GitHub
parent 57fde5ae7c
commit 29d66bfd97

@ -1,3 +1,9 @@
function includeString(text, values) {
return values.some(function(val){
return text.indexOf(val) !== -1;
});
}
angular.module('portainer.filters', []) angular.module('portainer.filters', [])
.filter('truncate', function () { .filter('truncate', function () {
'use strict'; 'use strict';
@ -35,15 +41,13 @@ angular.module('portainer.filters', [])
'use strict'; 'use strict';
return function (text) { return function (text) {
var status = _.toLower(text); var status = _.toLower(text);
if (status.indexOf('new') !== -1 || status.indexOf('allocated') !== -1 || if (includeString(status, ['new', 'allocated', 'assigned', 'accepted'])) {
status.indexOf('assigned') !== -1 || status.indexOf('accepted') !== -1) {
return 'info'; return 'info';
} else if (status.indexOf('pending') !== -1) { } else if (includeString(status, ['pending'])) {
return 'warning'; return 'warning';
} else if (status.indexOf('shutdown') !== -1 || status.indexOf('failed') !== -1 || } else if (includeString(status, ['shutdown', 'failed', 'rejected'])) {
status.indexOf('rejected') !== -1) {
return 'danger'; return 'danger';
} else if (status.indexOf('complete') !== -1) { } else if (includeString(status, ['complete'])) {
return 'primary'; return 'primary';
} }
return 'success'; return 'success';
@ -53,11 +57,11 @@ angular.module('portainer.filters', [])
'use strict'; 'use strict';
return function (text) { return function (text) {
var status = _.toLower(text); var status = _.toLower(text);
if (status.indexOf('paused') !== -1 || status.indexOf('starting') !== -1) { if (includeString(status, ['paused', 'starting'])) {
return 'warning'; return 'warning';
} else if (status.indexOf('created') !== -1) { } else if (includeString(status, ['created'])) {
return 'info'; return 'info';
} else if (status.indexOf('stopped') !== -1 || status.indexOf('unhealthy') !== -1) { } else if (includeString(status, ['stopped', 'unhealthy', 'dead'])) {
return 'danger'; return 'danger';
} }
return 'success'; return 'success';
@ -67,17 +71,19 @@ angular.module('portainer.filters', [])
'use strict'; 'use strict';
return function (text) { return function (text) {
var status = _.toLower(text); var status = _.toLower(text);
if (status.indexOf('paused') !== -1) { if (includeString(status, ['paused'])) {
return 'paused'; return 'paused';
} else if (status.indexOf('created') !== -1) { } else if (includeString(status, ['dead'])) {
return 'dead';
} else if (includeString(status, ['created'])) {
return 'created'; return 'created';
} else if (status.indexOf('exited') !== -1) { } else if (includeString(status, ['exited'])) {
return 'stopped'; return 'stopped';
} else if (status.indexOf('(healthy)') !== -1) { } else if (includeString(status, ['(healthy)'])) {
return 'healthy'; return 'healthy';
} else if (status.indexOf('(unhealthy)') !== -1) { } else if (includeString(status, ['(unhealthy)'])) {
return 'unhealthy'; return 'unhealthy';
} else if (status.indexOf('(health: starting)') !== -1) { } else if (includeString(status, ['(health: starting)'])) {
return 'starting'; return 'starting';
} }
return 'running'; return 'running';
@ -113,6 +119,9 @@ angular.module('portainer.filters', [])
if (state === undefined) { if (state === undefined) {
return ''; return '';
} }
if (state.Dead) {
return 'Dead';
}
if (state.Ghost && state.Running) { if (state.Ghost && state.Running) {
return 'Ghost'; return 'Ghost';
} }

Loading…
Cancel
Save