@dative-gpi/foundation-core-components 1.1.12 → 1.1.13

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.
package/utils/tables.ts CHANGED
@@ -1,32 +1,36 @@
1
1
 
2
- export const DASHBOARDS_EXPLORER_MAIN = "ui.tables.folder-mock.explorer-main";
3
- export const DASHBOARDS_EXPLORER_SHARED = "ui.tables.dashboard-mock.explorer-shared";
4
- export const DEVICES_EXPLORER_MAIN = "ui.tables.group-mock.explorer-main";
2
+ export const DASHBOARDS_EXPLORER_MAIN = "ui.tables.dashboard-explorer-element.main";
3
+ export const DASHBOARDS_ORGANISATION_TYPE_MAIN = "ui.tables.dashboard-organisation-type.main";
4
+
5
+ export const DEVICES_EXPLORER_MAIN = "ui.tables.device-explorer-element.main";
5
6
 
6
7
  export const DEVICES_LIST_MAIN = "ui.tables.device.main";
7
8
  export const DEVICES_MAINTENANCE = "ui.tables.device.maintenance";
8
9
  export const LOCATIONS_LIST_MAIN = "ui.tables.location.main";
9
10
 
10
- export const CHARTS_LIST_MAIN = "ui.tables.chart.main";
11
+ export const CHARTS_LIST_ORGANISATION = "ui.tables.chart.organisation";
11
12
  export const CHARTS_LIST_SHARED = "ui.tables.chart.shared";
12
13
 
13
14
  export const SCENARIOS_LIST_MAIN = "ui.tables.scenario.main";
15
+ export const SCENARIOS_LIST_ORGANISATION = "ui.tables.scenario.organisation";
14
16
  export const SCENARIOS_LIST_SHARED = "ui.tables.scenario.shared";
15
17
  export const CONNECTIVITY_SCENARIOS_LIST_MAIN = "ui.tables.connectivity-scenario.main";
16
18
 
17
19
  export const ALERTS_LIST_MAIN = "ui.tables.alert.main";
18
20
  export const CONNECTIVITY_ALERTS_LIST_MAIN = "ui.tables.connectivity-alert.main";
19
21
 
22
+ export const GROUPINGS_LIST_MAIN = "ui.tables.grouping.main";
23
+
24
+ export const CHARTS_LIST_SELECT = "ui.tables.chart.select";
25
+ export const DATA_CATEGORIES_SELECT = "ui.tables.data-category.select";
20
26
  export const DEVICES_SELECT = "ui.tables.device.select";
21
27
  export const GROUPS_SELECT = "ui.tables.group.select";
22
28
  export const LOCATIONS_SELECT = "ui.tables.location.select";
23
29
  export const MODELS_SELECT = "ui.tables.model.select";
24
- export const DASHBOARDS_SELECT = "ui.tables.dashboard-mock.select";
30
+ export const DASHBOARDS_SELECT = "ui.tables.dashboard-explorer-element.select";
25
31
  export const GROUPINGS_SELECT = "ui.tables.grouping.select";
26
32
  export const SUBGROUPINGS_SELECT = "ui.tables.subgrouping.select";
27
33
 
28
- export const WIDGET_DASHBOARDS_EXPLORER = "ui.tables.folder-mock.widget";
29
-
30
34
  export const LOCATION_DEVICES = "ui.tables.device.location-devices";
31
35
  export const DEVICE_ALERTS = "ui.tables.alert.device-alerts";
32
36
  export const DEVICE_CONNECTIVITY_ALERTS = "ui.tables.connectivity-alerts.device-connectivity-alerts";
@@ -1,337 +0,0 @@
1
- <template>
2
- <FSDataTable
3
- defaultMode="iterator"
4
- :items="items"
5
- :item-to="$props.itemTo"
6
- :loading="fetchingFolders || fetchingDashboardOrganisations || fetchingDashboardShallows"
7
- :tableCode="$props.tableCode"
8
- :headersOptions="headersOptions"
9
- :modelValue="selecteds"
10
- :selectable="$props.selectable"
11
- @update:modelValue="onSelect"
12
- v-bind="$attrs"
13
- >
14
- <template
15
- v-for="(_, name) in $slots"
16
- v-slot:[name]="slotData"
17
- >
18
- <slot
19
- :name="name"
20
- v-bind="slotData"
21
- />
22
- </template>
23
- <template
24
- #header.imageId-title
25
- >
26
- <FSIcon>
27
- mdi-panorama-variant-outline
28
- </FSIcon>
29
- </template>
30
- <template
31
- #item.imageId="{ item }"
32
- >
33
- <FSImage
34
- v-if="item.imageId"
35
- height="32px"
36
- width="32px"
37
- :imageId="item.imageId"
38
- :thumbnail="true"
39
- />
40
- </template>
41
- <template
42
- #item.icon="{ item }"
43
- >
44
- <FSIcon>
45
- {{ item.icon }}
46
- </FSIcon>
47
- </template>
48
- <template
49
- #item.main="{ item }"
50
- >
51
- <FSIcon
52
- v-if="item.id === mainOrganisationDashboardId"
53
- >
54
- mdi-account-group-outline
55
- </FSIcon>
56
- <FSIcon
57
- v-if="item.id === mainUserDashboardId"
58
- >
59
- mdi-home
60
- </FSIcon>
61
- </template>
62
- <template
63
- #item.locked="{ item }"
64
- >
65
- <FSIconCheck
66
- :value="item.locked"
67
- />
68
- </template>
69
- <template
70
- #item.tags="{ item }"
71
- >
72
- <FSTagGroup
73
- variant="slide"
74
- :showRemove="false"
75
- :tags="item.tags"
76
- />
77
- </template>
78
- <template
79
- #item.dashboardType="{ item }"
80
- >
81
- <FSChip
82
- v-if="item.type === FoldersListType.Dashboard"
83
- :color="ColorEnum.Light"
84
- :label="dashboardTypeLabel(item.dashboardType)"
85
- />
86
- <FSChip
87
- v-else-if="item.type === FoldersListType.Folder"
88
- :color="ColorEnum.Light"
89
- :label="$tr('ui.common.folder', 'Folder')"
90
- />
91
- </template>
92
- <template
93
- #item.tile="{ index, item, toggleSelect }"
94
- >
95
- <FSFolderTileUI
96
- v-if="item.type == FoldersListType.Folder"
97
- :key="index"
98
- :bottomColor="item.colors"
99
- v-bind="item"
100
- :selectable="$props.selectable"
101
- :modelValue="isSelected(item.id)"
102
- @update:modelValue="toggleSelect(item)"
103
- :to="$props.itemTo && $props.itemTo(item)"
104
- />
105
- <FSDashboardOrganisationTileUI
106
- v-if="item.type == FoldersListType.Dashboard && item.dashboardType == DashboardType.Organisation"
107
- :key="index"
108
- :bottomColor="item.colors"
109
- :selectable="$props.selectable"
110
- :modelValue="isSelected(item.id)"
111
- @update:modelValue="toggleSelect(item)"
112
- :to="$props.itemTo && $props.itemTo(item)"
113
- v-bind="item"
114
- />
115
- <FSDashboardShallowTileUI
116
- v-if="item.type == FoldersListType.Dashboard && item.dashboardType == DashboardType.Shallow"
117
- :key="index"
118
- :bottomColor="item.colors"
119
- :selectable="$props.selectable"
120
- :modelValue="isSelected(item.id)"
121
- @update:modelValue="toggleSelect(item)"
122
- :to="$props.itemTo && $props.itemTo(item)"
123
- v-bind="item"
124
- />
125
- </template>
126
- </FSDataTable>
127
- </template>
128
-
129
- <script lang="ts">
130
- import _ from "lodash";
131
- import type { RouteLocation } from "vue-router";
132
- import { computed, defineComponent, onMounted, type PropType, ref, watch } from "vue";
133
-
134
- import { useOrganisation } from "@dative-gpi/foundation-shared-services/composables";
135
- import { useDashboardOrganisations, useFolders, useDashboardShallows, useAppOrganisationId, useCurrentUserOrganisation } from "@dative-gpi/foundation-core-services/composables";
136
-
137
- import { DashboardType } from "@dative-gpi/foundation-shared-domain/enums";
138
- import { dashboardTypeLabel, FoldersListType, type FoldersListItem } from "@dative-gpi/foundation-core-components/utils";
139
- import type { FolderFilters, DashboardOrganisationFilters, DashboardShallowFilters, DashboardInfos } from "@dative-gpi/foundation-core-domain/models";
140
-
141
- import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
142
- import FSChip from '@dative-gpi/foundation-shared-components/components/FSChip.vue';
143
- import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
144
- import FSTagGroup from "@dative-gpi/foundation-shared-components/components/FSTagGroup.vue";
145
- import FSIconCheck from "@dative-gpi/foundation-shared-components/components/FSIconCheck.vue";
146
- import FSFolderTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSFolderTileUI.vue";
147
- import FSDashboardShallowTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSDashboardShallowTileUI.vue";
148
- import FSDashboardOrganisationTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSDashboardOrganisationTileUI.vue";
149
-
150
- import FSDataTable from "../lists/FSDataTable.vue";
151
- import { ColorEnum } from '@dative-gpi/foundation-shared-components/models';
152
- import { useTranslations } from '@dative-gpi/bones-ui';
153
-
154
- export default defineComponent({
155
- name: "FSBaseFoldersExplorer",
156
- components: {
157
- FSDashboardOrganisationTileUI,
158
- FSDashboardShallowTileUI,
159
- FSFolderTileUI,
160
- FSDataTable,
161
- FSIconCheck,
162
- FSTagGroup,
163
- FSImage,
164
- FSChip,
165
- FSIcon
166
- },
167
- props: {
168
- foldersFilters: {
169
- type: Object as PropType<FolderFilters>,
170
- default: undefined,
171
- required: false
172
- },
173
- dashboardOrganisationsFilters: {
174
- type: Object as PropType<DashboardOrganisationFilters>,
175
- default: undefined,
176
- required: false
177
- },
178
- dashboardShallowsFilters: {
179
- type: Object as PropType<DashboardShallowFilters>,
180
- default: undefined,
181
- required: false
182
- },
183
- modelValue: {
184
- type: Array as PropType<string[]>,
185
- required: false,
186
- default: () => []
187
- },
188
- itemTo: {
189
- type: Function as PropType<(item: DashboardInfos) => Partial<RouteLocation>>,
190
- required: false
191
- },
192
- tableCode: {
193
- type: String,
194
- required: true
195
- },
196
- selectable: {
197
- type: Boolean,
198
- required: false,
199
- default: true
200
- }
201
- },
202
- emits: ["update", "update:modelValue", "update:type", "update:dashboard-type"],
203
- setup(props, { emit }) {
204
- const { $tr } = useTranslations();
205
- const { fetch: fetchUserOrganisation, entity: userOrganisation } = useCurrentUserOrganisation();
206
- const { entity: organisation, get: getOrganisation } = useOrganisation();
207
- const { organisationId } = useAppOrganisationId();
208
-
209
- const { entities: dashboardOrganisations, fetching: fetchingDashboardOrganisations, getMany: getManyDashboardOrganisations } = useDashboardOrganisations();
210
- const { entities: dashboardShallows, fetching: fetchingDashboardShallows, getMany: getManyDashboardShallows } = useDashboardShallows();
211
- const { entities: folders, fetching: fetchingFolders, getMany: getManyFolders } = useFolders();
212
-
213
- const selecteds = ref<string[]>([]);
214
-
215
- const mainUserDashboardId = computed(() => {
216
- return userOrganisation.value?.mainDashboardId;
217
- });
218
-
219
- const mainOrganisationDashboardId = computed(() => {
220
- return organisation.value?.mainDashboardId;
221
- });
222
-
223
- const items = computed((): FoldersListItem[] => {
224
- return [
225
- ...folders.value.map(g => ({
226
- ...g,
227
- type: FoldersListType.Folder,
228
- dashboardType: DashboardType.None
229
- })) as FoldersListItem[],
230
- ..._.sortBy([
231
- ...dashboardOrganisations.value.map(d => ({
232
- ...d,
233
- type: FoldersListType.Dashboard,
234
- dashboardType: DashboardType.Organisation
235
- })) as FoldersListItem[],
236
- ...dashboardShallows.value.map(d => ({
237
- ...d,
238
- type: FoldersListType.Dashboard,
239
- dashboardType: DashboardType.Shallow
240
- })) as FoldersListItem[]
241
- ], d => d.label)
242
- ]
243
- });
244
-
245
- const headersOptions = computed(() => ({
246
- dashboardType: {
247
- fixedFilters: [
248
- {
249
- value: DashboardType.Organisation,
250
- text: dashboardTypeLabel(DashboardType.Organisation)
251
- },
252
- {
253
- value: DashboardType.Shallow,
254
- text: dashboardTypeLabel(DashboardType.Shallow)
255
- },
256
- {
257
- value: 10,
258
- text: $tr("ui.common.folder", "Folder")
259
- },
260
- ],
261
- methodFilter: (value: number, dashboardType: DashboardType) => {
262
- if(dashboardType !== DashboardType.None) {
263
- return value === dashboardType;
264
- } else {
265
- return value === 10;
266
- }
267
- }
268
- }
269
- }));
270
-
271
- const onSelect = (values: string[]) => {
272
- selecteds.value = values;
273
- const selectedItems = items.value.filter(i => selecteds.value!.includes(i.id));
274
- const newDashboardType = selectedItems.map(i => i.dashboardType);
275
- const newModelValue = selectedItems.map(i => i.id);
276
- const newType = selectedItems.map(i => i.type);
277
- emit("update:dashboard-type", newDashboardType);
278
- emit("update:modelValue", newModelValue);
279
- emit("update:type", newType);
280
- emit("update", { dashboardType: newDashboardType, modelValue: newModelValue, type: newType });
281
- };
282
-
283
- const isSelected = (id: string) => {
284
- return selecteds.value?.includes(id);
285
- };
286
-
287
- onMounted(() => {
288
- fetchUserOrganisation();
289
- })
290
-
291
- watch(() => organisationId.value, () => {
292
- if (organisationId.value) {
293
- getOrganisation(organisationId.value);
294
- }
295
- }, { immediate: true });
296
-
297
- watch(() => props.foldersFilters, (next, previous) => {
298
- if ((!next && !previous) || !_.isEqual(next, previous)) {
299
- getManyFolders(props.foldersFilters, f => f.parentId == props.foldersFilters?.parentId);
300
- }
301
- }, { immediate: true });
302
-
303
- watch(() => props.dashboardOrganisationsFilters, (next, previous) => {
304
- if ((!next && !previous) || !_.isEqual(next, previous)) {
305
- getManyDashboardOrganisations(props.dashboardOrganisationsFilters, f => f.folderId == props.foldersFilters?.parentId);
306
- }
307
- }, { immediate: true });
308
-
309
- watch(() => props.dashboardShallowsFilters, (next, previous) => {
310
- if ((!next && !previous) || !_.isEqual(next, previous)) {
311
- getManyDashboardShallows(props.dashboardShallowsFilters, f => f.folderId == props.foldersFilters?.parentId);
312
- }
313
- }, { immediate: true });
314
-
315
- watch(() => props.modelValue, (next) => {
316
- selecteds.value = next;
317
- }, { immediate: true });
318
-
319
- return {
320
- fetchingDashboardOrganisations,
321
- fetchingDashboardShallows,
322
- fetchingFolders,
323
- mainOrganisationDashboardId,
324
- mainUserDashboardId,
325
- headersOptions,
326
- ColorEnum,
327
- selecteds,
328
- items,
329
- onSelect,
330
- isSelected,
331
- FoldersListType,
332
- DashboardType,
333
- dashboardTypeLabel
334
- };
335
- }
336
- });
337
- </script>