blob: 5ce79327551b9a167045706b23a28801acd2ac52 [file] [log] [blame]
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -05001const DataFormatterMixin = {
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07002 methods: {
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -05003 dataFormatter(value) {
Yoshie Muranakae24b17d2020-06-08 11:03:11 -07004 if (value === undefined || value === null || value === '') {
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07005 return '--';
Yoshie Muranaka202c5992020-06-18 12:02:57 -07006 } else if (typeof value === 'number') {
7 return parseFloat(value.toFixed(3));
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07008 } else {
9 return value;
10 }
11 },
12 statusIcon(status) {
13 switch (status) {
14 case 'OK':
15 return 'success';
16 case 'Warning':
17 return 'warning';
18 case 'Critical':
19 return 'danger';
20 default:
21 return '';
22 }
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070023 },
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050024 dataFormatterArray(value) {
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070025 return value.join(', ');
Derick Montague602e98a2020-10-21 16:20:00 -050026 },
27 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070028};
29
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050030export default DataFormatterMixin;