1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 21:39:40 +02:00
portainer/js/filters.js

63 lines
1.8 KiB
JavaScript
Raw Normal View History

2013-06-08 15:12:14 -09:00
'use strict';
2013-06-08 16:20:29 -09:00
angular.module('dockerui.filters', [])
.filter('truncate', function() {
return function(text, length, end) {
if (isNaN(length))
length = 10;
if (end === undefined)
end = "...";
if (text.length <= length || text.length - end.length <= length) {
return text;
}
else {
return String(text).substring(0, length-end.length) + end;
}
};
})
.filter('statusbadge', function() {
return function(text) {
if (text === 'Ghost') {
return 'important';
2013-06-09 14:56:54 -09:00
} else if (text.indexOf('Exit') != -1 && text !== 'Exit 0') {
return 'warning';
2013-06-08 16:20:29 -09:00
}
return 'success';
};
2013-06-09 14:11:40 -09:00
})
2013-06-09 16:31:05 -09:00
.filter('getstatetext', function() {
return function(state) {
if (state == undefined) return '';
if (state.Ghost && state.Running) {
return 'Ghost';
}
if (state.Running) {
return 'Running';
}
return 'Stopped';
};
})
.filter('getstatelabel', function() {
return function(state) {
if (state == undefined) return '';
if (state.Ghost && state.Running) {
return 'label-important';
}
if (state.Running) {
return 'label-success';
}
return '';
};
})
2013-06-09 14:11:40 -09:00
.filter('getdate', function() {
return function(data) {
//Multiply by 1000 for the unix format
var date = new Date(data * 1000);
return date.toDateString();
};
2013-06-08 16:20:29 -09:00
});