summaryrefslogtreecommitdiff
path: root/src/components/_sila/Global/SilaComponents/Tables/AccessoryTableWithLabel.vue
blob: 37de1c6b47b2539ec590361e47947a09f3883e45 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
  <section class="bootstrap-table__section">
    <span class="bold-12px__caps">
      {{ $t('fansPage.valueIndicators') }}
    </span>
    <b-table
      responsive="md"
      class="table-accessory"
      no-border-collapse
      :items="records.items"
      :fields="records.fields"
    >
      <template #cell(name)="{ value, index }">
        <div
          class="fans-colors"
          :style="`background-color: ${colors[index]}`"
        ></div>
        <span class="light-12px">
          {{ value }}
        </span>
      </template>
      <template #cell(minDate)="{ value }">
        <span class="regular-12px">
          {{ value.time }}
        </span>
        <span class="regular-12px tretiatry">
          {{ value.date }}
        </span>
      </template>
      <template #cell(maxDate)="{ value }">
        <span class="regular-12px">
          {{ value.time }}
        </span>
        <span class="regular-12px tretiatry">
          {{ value.date }}
        </span>
      </template>
      <template #head(currentPower)="{ label }">
        <span class="semi-bold-12px">
          {{ label }}
        </span>
        <span class="semi-bold-12px errors">
          {{ '(15)' }}
        </span>
      </template>
      <template #cell(currentPower)="{ value }">
        <row>
          <span class="light-12px">
            {{ value }}
          </span>
        </row>
      </template>
    </b-table>
  </section>
</template>

<script>
export default {
  props: {
    records: {
      type: Object,
      default: null,
    },
  },
  data() {
    return {
      colors: [],
    };
  },
  watch: {
    'records.items'(value) {
      if (value && value.length > 0) {
        this.colors = this.$randomColor({
          count: value.length,
          hue: 'random',
          luminosity: 'random',
        });
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.fans-colors {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.row {
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.errors {
  color: $indicators-errors;
}
</style>