Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 1 | const DataFormatterMixin = { |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 2 | methods: { |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 3 | dataFormatter(value) { |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 4 | if (value === undefined || value === null || value === '') { |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 5 | return '--'; |
Yoshie Muranaka | 202c599 | 2020-06-18 12:02:57 -0700 | [diff] [blame] | 6 | } else if (typeof value === 'number') { |
| 7 | return parseFloat(value.toFixed(3)); |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 8 | } 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 Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 23 | }, |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 24 | dataFormatterArray(value) { |
Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 25 | return value.join(', '); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 26 | }, |
| 27 | }, |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 30 | export default DataFormatterMixin; |