summaryrefslogtreecommitdiff
path: root/src/components/Mixins/TableDataFormatterMixin.js
blob: 026f8749fcf6ca785468ea592ab76172da2b779f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const TableDataFormatterMixin = {
  methods: {
    tableFormatter(value) {
      if (value === undefined || value === null || value === '') {
        return '--';
      } else if (typeof value === 'number') {
        return parseFloat(value.toFixed(3));
      } else {
        return value;
      }
    },
    statusIcon(status) {
      switch (status) {
        case 'OK':
          return 'success';
        case 'Warning':
          return 'warning';
        case 'Critical':
          return 'danger';
        default:
          return '';
      }
    },
    tableFormatterArray(value) {
      return value.join(', ');
    },
  },
};

export default TableDataFormatterMixin;