portainer/js/filters.js

35 lines
978 B
JavaScript
Raw Normal View History

2013-06-09 00:12:14 +00:00
'use strict';
2013-06-09 01:20:29 +00: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';
}
return 'success';
};
2013-06-09 23:11:40 +00: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-09 01:20:29 +00:00
});