@dative-gpi/foundation-core-components 1.0.110 → 1.0.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,280 @@
1
+ <template>
2
+ <FSDataTable
3
+ defaultMode="iterator"
4
+ :loading="fetchingDeviceExplorerElements"
5
+ :singleSelect="$props.singleSelect"
6
+ :items="deviceExplorerElements"
7
+ :showSelect="$props.editable"
8
+ :tableCode="$props.tableCode"
9
+ :itemTo="$props.itemTo"
10
+ :noSearch="true"
11
+ :modelValue="$props.modelValue"
12
+ @update:modelValue="$emit('update:modelValue', $event)"
13
+ v-model:search="search"
14
+ v-bind="$attrs"
15
+ >
16
+ <template
17
+ v-for="(_, name) in $slots"
18
+ v-slot:[name]="slotData"
19
+ >
20
+ <slot
21
+ :name="name"
22
+ v-bind="slotData"
23
+ />
24
+ </template>
25
+ <template
26
+ #header.imageId-title
27
+ >
28
+ <FSIcon>
29
+ mdi-panorama-variant-outline
30
+ </FSIcon>
31
+ </template>
32
+ <template
33
+ #header.connectivity-title
34
+ >
35
+ <FSIcon>
36
+ mdi-wifi
37
+ </FSIcon>
38
+ </template>
39
+ <template
40
+ #item.imageId="{ item }"
41
+ >
42
+ <FSImage
43
+ v-if="item.imageId"
44
+ height="32px"
45
+ width="32px"
46
+ :imageId="item.imageId"
47
+ :thumbnail="true"
48
+ />
49
+ </template>
50
+ <template
51
+ #item.tags="{ item }"
52
+ >
53
+ <FSTagGroup
54
+ variant="slide"
55
+ :editable="false"
56
+ :tags="item.tags"
57
+ />
58
+ </template>
59
+ <template
60
+ #item.type="{ item }"
61
+ >
62
+ <FSIcon
63
+ v-if="item.type === DeviceExplorerElementType.Group"
64
+ >
65
+ mdi-folder-outline
66
+ </FSIcon>
67
+ <FSIcon
68
+ v-else
69
+ >
70
+ mdi-widgets-outline
71
+ </FSIcon>
72
+ </template>
73
+
74
+ <template
75
+ #item.icon="{ item }"
76
+ >
77
+ <FSIcon
78
+ v-if="item.type === DeviceExplorerElementType.Group"
79
+ >
80
+ {{ item.icon }}
81
+ </FSIcon>
82
+ </template>
83
+ <template
84
+ #item.connectivity="{ item }"
85
+ >
86
+ <FSCol
87
+ v-if="item.type === DeviceExplorerElementType.DeviceOrganisation"
88
+ >
89
+ <FSConnectivity
90
+ v-if="item.connectivity.status != ConnectivityStatus.None"
91
+ :deviceConnectivity="item.connectivity"
92
+ />
93
+ </FSCol>
94
+ </template>
95
+ <template
96
+ #item.worstAlert="{ item }"
97
+ >
98
+ <FSWorstAlert
99
+ v-if="item.worstAlert"
100
+ :deviceWorstAlert="item.worstAlert"
101
+ :deviceAlerts="item.alerts"
102
+ :alertTo="$props.alertTo"
103
+ />
104
+ <div
105
+ v-else
106
+ />
107
+ </template>
108
+ <template
109
+ #item.alerts="{ item }"
110
+ >
111
+ <FSWorstAlert
112
+ v-if="item.worstAlert"
113
+ :deviceWorstAlert="item.worstAlert"
114
+ :deviceAlerts="item.alerts"
115
+ :alertTo="$props.alertTo"
116
+ />
117
+ <div
118
+ v-else
119
+ />
120
+ </template>
121
+ <template
122
+ #item.status="{ item }"
123
+ >
124
+ <FSStatusesCarousel
125
+ v-if="item.type === DeviceExplorerElementType.DeviceOrganisation"
126
+ :modelStatuses="item.modelStatuses"
127
+ :deviceStatuses="item.status.statuses"
128
+ />
129
+ </template>
130
+
131
+ <template
132
+ #item.tile="{ item, toggleSelect }"
133
+ >
134
+ <FSGroupTileUI
135
+ v-if="item.type === DeviceExplorerElementType.Group"
136
+ :to="$props.itemTo && $props.itemTo(item)"
137
+ :modelValue="isSelected(item.id)"
138
+ @update:modelValue="toggleSelect(item)"
139
+ v-bind="item"
140
+ />
141
+ <FSDeviceOrganisationTileUI
142
+ v-if="item.type === DeviceExplorerElementType.DeviceOrganisation"
143
+ :to="$props.itemTo && $props.itemTo(item)"
144
+ :deviceConnectivity="item.connectivity"
145
+ :deviceStatuses="item.status.statuses"
146
+ :deviceWorstAlert="item.worstAlert"
147
+ :deviceAlerts="item.alerts"
148
+ :alertTo="$props.alertTo"
149
+ :modelValue="isSelected(item.id)"
150
+ @update:modelValue="toggleSelect(item)"
151
+ v-bind="item"
152
+ />
153
+ </template>
154
+ </FSDataTable>
155
+ </template>
156
+
157
+ <script lang="ts">
158
+ import { computed, defineComponent, type PropType, ref, watch } from "vue";
159
+ import { type RouteLocation } from "vue-router";
160
+ import _ from "lodash";
161
+
162
+ import { type DeviceExplorerElementFilters, type DeviceExplorerElementInfos} from "@dative-gpi/foundation-core-domain/models";
163
+ import { ConnectivityStatus, DeviceExplorerElementType } from "@dative-gpi/foundation-shared-domain/enums";
164
+ import { useDeviceExplorerElements } from "@dative-gpi/foundation-core-services/composables";
165
+ import { useDebounce } from "@dative-gpi/foundation-shared-components/composables";
166
+
167
+ import FSDeviceOrganisationTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSDeviceOrganisationTileUI.vue";
168
+ import FSStatusesCarousel from "@dative-gpi/foundation-shared-components/components/deviceOrganisations/FSStatusesCarousel.vue";
169
+ import FSConnectivity from "@dative-gpi/foundation-shared-components/components/deviceOrganisations/FSConnectivity.vue";
170
+ import FSWorstAlert from "@dative-gpi/foundation-shared-components/components/deviceOrganisations/FSWorstAlert.vue";
171
+ import FSGroupTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSGroupTileUI.vue";
172
+ import FSTagGroup from "@dative-gpi/foundation-shared-components/components/FSTagGroup.vue";
173
+ import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
174
+
175
+ import FSDataTable from "../lists/FSDataTable.vue";
176
+
177
+ export default defineComponent({
178
+ name: "FSBaseDevicesExplorer",
179
+ components: {
180
+ FSDeviceOrganisationTileUI,
181
+ FSStatusesCarousel,
182
+ FSConnectivity,
183
+ FSGroupTileUI,
184
+ FSWorstAlert,
185
+ FSDataTable,
186
+ FSTagGroup,
187
+ FSImage
188
+ },
189
+ props: {
190
+ tableCode: {
191
+ type: String as PropType<string | null>,
192
+ required: false,
193
+ default: null
194
+ },
195
+ deviceExplorerElementFilters: {
196
+ type: Object as PropType<DeviceExplorerElementFilters>,
197
+ required: false,
198
+ default: null
199
+ },
200
+ connectedOnly: {
201
+ type: Boolean,
202
+ required: false,
203
+ default: false
204
+ },
205
+ itemTo: {
206
+ type: Function as PropType<(item: DeviceExplorerElementInfos) => Partial<RouteLocation>>,
207
+ required: false
208
+ },
209
+ alertTo: {
210
+ type: Function,
211
+ required: false,
212
+ default: null
213
+ },
214
+ editable: {
215
+ type: Boolean,
216
+ required: false,
217
+ default: true
218
+ },
219
+ singleSelect: {
220
+ type: Boolean,
221
+ required: false,
222
+ default: false
223
+ },
224
+ modelValue: {
225
+ type: Array as PropType<string[]>,
226
+ default: () => [],
227
+ required: false
228
+ }
229
+ },
230
+ emits: ["update:modelValue"],
231
+ setup(props) {
232
+ const { entities, fetching: fetchingDeviceExplorerElements, getMany: getManyDeviceExplorerElements } = useDeviceExplorerElements();
233
+ const { debounce } = useDebounce();
234
+
235
+ const search = ref("");
236
+
237
+ const deviceExplorerElements = computed((): DeviceExplorerElementInfos[] => {
238
+ if (props.connectedOnly) {
239
+ return entities.value.filter(dee =>
240
+ dee.type === DeviceExplorerElementType.Group ||
241
+ (dee.connectivity != null && dee.connectivity.status != ConnectivityStatus.None)
242
+ );
243
+ }
244
+ return entities.value;
245
+ });
246
+
247
+ const isSelected = (id: string): boolean => {
248
+ return props.modelValue.includes(id);
249
+ };
250
+
251
+ const fetch = () => {
252
+ getManyDeviceExplorerElements({ ...props.deviceExplorerElementFilters, search: search.value });
253
+ }
254
+
255
+ // Delay to wait before fetching after a search change
256
+ const debounceFetch = (): void => debounce(fetch, 1500);
257
+
258
+ watch(() => props.deviceExplorerElementFilters, (next, previous) => {
259
+ if ((!next && !previous) || !_.isEqual(next, previous)) {
260
+ fetch();
261
+ }
262
+ }, { immediate: true });
263
+
264
+ watch(search, (next, previous) => {
265
+ if (next !== previous && next.length === 0 || next.length >= 3) {
266
+ debounceFetch();
267
+ }
268
+ });
269
+
270
+ return {
271
+ fetchingDeviceExplorerElements,
272
+ DeviceExplorerElementType,
273
+ deviceExplorerElements,
274
+ ConnectivityStatus,
275
+ search,
276
+ isSelected
277
+ };
278
+ }
279
+ });
280
+ </script>
@@ -28,13 +28,6 @@
28
28
  mdi-panorama-variant-outline
29
29
  </FSIcon>
30
30
  </template>
31
- <template
32
- #header.connectable-title
33
- >
34
- <FSIcon>
35
- mdi-wifi
36
- </FSIcon>
37
- </template>
38
31
  <template
39
32
  #header.connectivity-title
40
33
  >
@@ -53,16 +46,6 @@
53
46
  :thumbnail="true"
54
47
  />
55
48
  </template>
56
- <template
57
- #item.connectable="{ item }"
58
- >
59
- <FSCol>
60
- <FSConnectivity
61
- v-if="item.connectivity.status != ConnectivityStatus.None"
62
- :deviceConnectivity="item.connectivity"
63
- />
64
- </FSCol>
65
- </template>
66
49
  <template
67
50
  #item.connectivity="{ item }"
68
51
  >
@@ -262,33 +245,6 @@ export default defineComponent({
262
245
  });
263
246
 
264
247
  const headersOptions = computed(() => ({
265
- connectable: {
266
- fixedFilters: [{
267
- value: ConnectivityStatus.None,
268
- text: "—"
269
- }, {
270
- value: ConnectivityStatus.Offline,
271
- text: connectivityLabel(ConnectivityStatus.Offline)
272
- }, {
273
- value: ConnectivityStatus.AlmostOffline,
274
- text: connectivityLabel(ConnectivityStatus.AlmostOffline)
275
- }, {
276
- value: ConnectivityStatus.PartiallyConnected,
277
- text: connectivityLabel(ConnectivityStatus.PartiallyConnected)
278
- }, {
279
- value: ConnectivityStatus.Connected,
280
- text: connectivityLabel(ConnectivityStatus.Connected)
281
- }],
282
- methodFilter: (value: ConnectivityStatus, item: DeviceConnectivityDetails) => {
283
- switch(value) {
284
- case ConnectivityStatus.None:
285
- return !item.status;
286
- default:
287
- return item.status == value;
288
- }
289
- },
290
- sort: (a: DeviceConnectivityDetails, b: DeviceConnectivityDetails) => alphanumericSort(a?.status, b?.status)
291
- },
292
248
  connectivity: {
293
249
  fixedFilters: [{
294
250
  value: ConnectivityStatus.None,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-core-components",
3
3
  "sideEffects": false,
4
- "version": "1.0.110",
4
+ "version": "1.0.111",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,11 +10,11 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dative-gpi/foundation-core-domain": "1.0.110",
14
- "@dative-gpi/foundation-core-services": "1.0.110",
15
- "@dative-gpi/foundation-shared-components": "1.0.110",
16
- "@dative-gpi/foundation-shared-domain": "1.0.110",
17
- "@dative-gpi/foundation-shared-services": "1.0.110"
13
+ "@dative-gpi/foundation-core-domain": "1.0.111",
14
+ "@dative-gpi/foundation-core-services": "1.0.111",
15
+ "@dative-gpi/foundation-shared-components": "1.0.111",
16
+ "@dative-gpi/foundation-shared-domain": "1.0.111",
17
+ "@dative-gpi/foundation-shared-services": "1.0.111"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@dative-gpi/bones-ui": "^1.0.0",
@@ -26,5 +26,5 @@
26
26
  "sass": "1.71.1",
27
27
  "sass-loader": "13.3.2"
28
28
  },
29
- "gitHead": "ce27d3542d6a82946127e9004d82ff2f401d7242"
29
+ "gitHead": "8a5582e544900743384c63aa9cf137b780e65ecc"
30
30
  }