@dative-gpi/foundation-core-components 1.0.36 → 1.0.37-report-v1

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.
Files changed (84) hide show
  1. package/components/autocompletes/FSAutocompleteChart.vue +18 -8
  2. package/components/autocompletes/FSAutocompleteDashboard.vue +16 -6
  3. package/components/autocompletes/FSAutocompleteDashboardOrganisation.vue +7 -1
  4. package/components/autocompletes/FSAutocompleteDataCategory.vue +11 -5
  5. package/components/autocompletes/FSAutocompleteDataDefinition.vue +7 -1
  6. package/components/autocompletes/FSAutocompleteGroup.vue +7 -1
  7. package/components/autocompletes/FSAutocompleteLocation.vue +6 -0
  8. package/components/autocompletes/FSAutocompleteManufacturer.vue +8 -0
  9. package/components/autocompletes/FSAutocompleteModel.vue +9 -1
  10. package/components/autocompletes/FSAutocompleteOrganisationType.vue +7 -1
  11. package/components/autocompletes/FSAutocompleteRole.vue +17 -6
  12. package/components/autocompletes/FSAutocompleteServiceAccountRoleOrganisation.vue +7 -1
  13. package/components/autocompletes/FSAutocompleteUserOrganisation.vue +9 -1
  14. package/components/chips/FSChipGroupUserOrganisation.vue +61 -0
  15. package/components/chips/FSChipGroupUserOrganisationUI.vue +38 -0
  16. package/components/customProperties/FSMetaField.vue +31 -35
  17. package/components/customProperties/FSMetaHistory.vue +4 -4
  18. package/components/customProperties/FSMetaValue.vue +66 -33
  19. package/components/customProperties/helpers.ts +2 -1
  20. package/components/entities/FSBaseEntitiesList.vue +50 -0
  21. package/components/entities/FSDialogSelectEntities.vue +83 -0
  22. package/components/entities/FSEntityField.vue +203 -0
  23. package/components/entities/FSSelectEntitiesList.vue +209 -0
  24. package/components/entities/FSSimpleEntitiesList.vue +100 -0
  25. package/components/explorers/FSBaseDevicesExplorer.vue +310 -0
  26. package/components/explorers/FSBaseFoldersExplorer.vue +277 -0
  27. package/components/lists/FSDataTable.vue +23 -21
  28. package/components/lists/alerts/FSBaseAlertsList.vue +338 -0
  29. package/components/lists/alerts/FSButtonAcknowledgeAlert.vue +101 -0
  30. package/components/lists/authTokens/FSBaseAuthTokensList.vue +79 -0
  31. package/components/lists/chartOrganisationTypes/FSBaseChartOrganisationTypesList.vue +205 -0
  32. package/components/lists/chartOrganisations/FSBaseChartOrganisationsList.vue +206 -0
  33. package/components/lists/charts/FSBaseChartsList.vue +268 -0
  34. package/components/lists/comments/FSBaseCommentsList.vue +143 -0
  35. package/components/lists/connectivityScenarios/FSBaseConnectivityScenariosList.vue +128 -0
  36. package/components/lists/dashboardOrganisationTypes/FSBaseDashboardOrganisationTypesList.vue +179 -0
  37. package/components/lists/dashboards/FSBaseDashboardsList.vue +235 -0
  38. package/components/lists/dashboards/FSSimpleDashboardsList.vue +62 -0
  39. package/components/lists/dataCategories/FSBaseDataCategoriesList.vue +155 -0
  40. package/components/lists/dataDefinitions/FSBaseDataDefinitionsList.vue +130 -0
  41. package/components/lists/deviceOrganisations/FSBaseDeviceOrganisationsList.vue +378 -0
  42. package/components/lists/deviceOrganisations/FSSimpleDeviceOrganisationsList.vue +44 -0
  43. package/components/lists/folders/FSBaseFoldersList.vue +127 -0
  44. package/components/lists/folders/FSSimpleFoldersList.vue +44 -0
  45. package/components/lists/groups/FSBaseGroupsList.vue +136 -0
  46. package/components/lists/groups/FSSimpleGroupsList.vue +44 -0
  47. package/components/lists/locations/FSBaseLocationsList.vue +118 -0
  48. package/components/lists/locations/FSSimpleLocationsList.vue +44 -0
  49. package/components/lists/models/FSBaseModelsList.vue +155 -0
  50. package/components/lists/models/FSSimpleModelsList.vue +44 -0
  51. package/components/lists/reports/FSBaseReportExecutionsList.vue +137 -0
  52. package/components/lists/reports/FSBaseReportsList.vue +140 -0
  53. package/components/lists/roleOrganisationTypes/FSBaseRoleOrganisationTypesList.vue +128 -0
  54. package/components/lists/roleOrganisations/FSBaseRoleOrganisationsList.vue +128 -0
  55. package/components/lists/scenarioOrganisationTypes/FSBaseScenarioOrganisationTypesList.vue +157 -0
  56. package/components/lists/scenarioOrganisations/FSBaseScenarioOrganisationsList.vue +145 -0
  57. package/components/lists/scenarios/FSBaseScenariosList.vue +241 -0
  58. package/components/lists/serviceAccountOrganisations/FSBaseServiceAccountOrganisationsList.vue +155 -0
  59. package/components/lists/serviceAccountRoleOrganisations/FSBaseServiceAccountRoleOrganisationsList.vue +128 -0
  60. package/components/lists/userOrganisations/FSBaseUserOrganisationsList.vue +171 -0
  61. package/components/lists/userOrganisations/FSSimpleUserOrganisationsList.vue +45 -0
  62. package/components/tiles/FSChartTile.vue +70 -0
  63. package/components/tiles/FSDeviceOrganisationTile.vue +9 -2
  64. package/components/tiles/FSLocationTile.vue +66 -0
  65. package/components/treeviews/FSTreeViewFolder.vue +15 -3
  66. package/components/treeviews/FSTreeViewGroup.vue +22 -4
  67. package/package.json +9 -9
  68. package/utils/dashboards.ts +33 -5
  69. package/utils/index.ts +2 -2
  70. package/utils/permissions.ts +80 -0
  71. package/utils/roles.ts +4 -4
  72. package/utils/tables.ts +41 -0
  73. package/utils/users.ts +7 -4
  74. package/components/selects/FSAggregationSelector.vue +0 -51
  75. package/components/selects/FSAxisTypeSelector.vue +0 -48
  76. package/components/selects/FSDisplayAsSelector.vue +0 -52
  77. package/components/selects/FSFilterTypeSelector.vue +0 -53
  78. package/components/selects/FSHeatmapRuleSelector.vue +0 -52
  79. package/components/selects/FSOperationOnSelector.vue +0 -51
  80. package/components/selects/FSPlanningTypeSelector.vue +0 -51
  81. package/components/selects/FSPlotPerSelector.vue +0 -51
  82. package/components/selects/FSSelectSelectedEntities.vue +0 -59
  83. package/components/selects/FSSerieTypeSelector.vue +0 -51
  84. package/utils/charts.ts +0 -136
@@ -0,0 +1,277 @@
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
+ :modelValue="selecteds"
9
+ @update:modelValue="onSelect"
10
+ v-bind="$attrs"
11
+ >
12
+ <template
13
+ v-for="(_, name) in $slots"
14
+ v-slot:[name]="slotData"
15
+ >
16
+ <slot
17
+ :name="name"
18
+ v-bind="slotData"
19
+ />
20
+ </template>
21
+ <template
22
+ #header.imageId-title
23
+ >
24
+ <FSIcon>
25
+ mdi-panorama-variant-outline
26
+ </FSIcon>
27
+ </template>
28
+ <template
29
+ #item.imageId="{ item }"
30
+ >
31
+ <FSImage
32
+ v-if="item.imageId"
33
+ height="32px"
34
+ width="32px"
35
+ :imageId="item.imageId"
36
+ :thumbnail="true"
37
+ />
38
+ </template>
39
+ <template
40
+ #item.icon="{ item }"
41
+ >
42
+ <FSIcon>
43
+ {{ item.icon }}
44
+ </FSIcon>
45
+ </template>
46
+ <template
47
+ #item.main="{ item }"
48
+ >
49
+ <FSIcon
50
+ v-if="item.id === mainOrganisationDashboardId"
51
+ >
52
+ mdi-account-group-outline
53
+ </FSIcon>
54
+ <FSIcon
55
+ v-if="item.id === mainUserDashboardId"
56
+ >
57
+ mdi-home
58
+ </FSIcon>
59
+ </template>
60
+ <template
61
+ #item.locked="{ item }"
62
+ >
63
+ <FSIconCheck
64
+ :value="item.locked"
65
+ />
66
+ </template>
67
+ <template
68
+ #item.tags="{ item }"
69
+ >
70
+ <FSTagGroup
71
+ variant="slide"
72
+ :editable="false"
73
+ :tags="item.tags"
74
+ />
75
+ </template>
76
+ <template
77
+ #item.tile="{ item, toggleSelect }"
78
+ >
79
+ <FSFolderTileUI
80
+ v-if="item.type == FoldersListType.Folder"
81
+ :bottomColor="item.colors"
82
+ v-bind="item"
83
+ :modelValue="isSelected(item.id)"
84
+ @update:modelValue="toggleSelect(item)"
85
+ :to="$props.itemTo && $props.itemTo(item)"
86
+ />
87
+ <FSDashboardOrganisationTileUI
88
+ v-if="item.type == FoldersListType.Dashboard && item.dashboardType == DashboardType.Organisation"
89
+ :bottomColor="item.colors"
90
+ :modelValue="isSelected(item.id)"
91
+ @update:modelValue="toggleSelect(item)"
92
+ :to="$props.itemTo && $props.itemTo(item)"
93
+ v-bind="item"
94
+ />
95
+ <FSDashboardShallowTileUI
96
+ v-if="item.type == FoldersListType.Dashboard && item.dashboardType == DashboardType.Shallow"
97
+ :bottomColor="item.colors"
98
+ :modelValue="isSelected(item.id)"
99
+ @update:modelValue="toggleSelect(item)"
100
+ :to="$props.itemTo && $props.itemTo(item)"
101
+ v-bind="item"
102
+ />
103
+ </template>
104
+ </FSDataTable>
105
+ </template>
106
+
107
+ <script lang="ts">
108
+ import _ from "lodash";
109
+ import type { RouteLocation } from "vue-router";
110
+ import { computed, defineComponent, onMounted, type PropType, ref, watch } from "vue";
111
+
112
+ import { useOrganisation } from "@dative-gpi/foundation-shared-services/composables";
113
+ import { useDashboardOrganisations, useFolders, useDashboardShallows, useAppOrganisationId, useCurrentUserOrganisation } from "@dative-gpi/foundation-core-services/composables";
114
+
115
+ import { DashboardType } from "@dative-gpi/foundation-shared-domain/enums";
116
+ import { FoldersListType, type FoldersListItem } from "@dative-gpi/foundation-core-components/utils";
117
+ import type { FolderFilters, DashboardOrganisationFilters, DashboardShallowFilters, DashboardInfos } from "@dative-gpi/foundation-core-domain/models";
118
+
119
+ import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
120
+ import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
121
+ import FSTagGroup from "@dative-gpi/foundation-shared-components/components/FSTagGroup.vue";
122
+ import FSIconCheck from "@dative-gpi/foundation-shared-components/components/FSIconCheck.vue";
123
+ import FSFolderTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSFolderTileUI.vue";
124
+ import FSDashboardShallowTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSDashboardShallowTileUI.vue";
125
+ import FSDashboardOrganisationTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSDashboardOrganisationTileUI.vue";
126
+
127
+ import FSDataTable from "../lists/FSDataTable.vue";
128
+
129
+ export default defineComponent({
130
+ name: "FSBaseFoldersExplorer",
131
+ components: {
132
+ FSDashboardOrganisationTileUI,
133
+ FSDashboardShallowTileUI,
134
+ FSFolderTileUI,
135
+ FSDataTable,
136
+ FSIconCheck,
137
+ FSTagGroup,
138
+ FSImage,
139
+ FSIcon
140
+ },
141
+ props: {
142
+ foldersFilters: {
143
+ type: Object as PropType<FolderFilters>,
144
+ default: undefined,
145
+ required: false
146
+ },
147
+ dashboardOrganisationsFilters: {
148
+ type: Object as PropType<DashboardOrganisationFilters>,
149
+ default: undefined,
150
+ required: false
151
+ },
152
+ dashboardShallowsFilters: {
153
+ type: Object as PropType<DashboardShallowFilters>,
154
+ default: undefined,
155
+ required: false
156
+ },
157
+ modelValue: {
158
+ type: Array as PropType<string[]>,
159
+ required: false,
160
+ default: () => []
161
+ },
162
+ itemTo: {
163
+ type: Function as PropType<(item: DashboardInfos) => Partial<RouteLocation>>,
164
+ required: false
165
+ },
166
+ tableCode: {
167
+ type: String,
168
+ required: true
169
+ }
170
+ },
171
+ emits: ["update", "update:modelValue", "update:type", "update:dashboard-type"],
172
+ setup(props, { emit }) {
173
+
174
+ const { fetch: fetchUserOrganisation, entity: userOrganisation } = useCurrentUserOrganisation();
175
+ const { entity: organisation, get: getOrganisation } = useOrganisation();
176
+ const { organisationId } = useAppOrganisationId();
177
+
178
+ const { entities: dashboardOrganisations, fetching: fetchingDashboardOrganisations, getMany: getManyDashboardOrganisations } = useDashboardOrganisations();
179
+ const { entities: dashboardShallows, fetching: fetchingDashboardShallows, getMany: getManyDashboardShallows } = useDashboardShallows();
180
+ const { entities: folders, fetching: fetchingFolders, getMany: getManyFolders } = useFolders();
181
+
182
+ const selecteds = ref<string[]>([]);
183
+
184
+ const mainUserDashboardId = computed(() => {
185
+ return userOrganisation.value?.mainDashboardId;
186
+ });
187
+
188
+ const mainOrganisationDashboardId = computed(() => {
189
+ return organisation.value?.mainDashboardId;
190
+ });
191
+
192
+ const items = computed((): FoldersListItem[] => {
193
+ return [
194
+ ...folders.value.map(g => ({
195
+ ...g,
196
+ type: FoldersListType.Folder,
197
+ dashboardType: DashboardType.None
198
+ })) as FoldersListItem[],
199
+ ..._.sortBy([
200
+ ...dashboardOrganisations.value.map(d => ({
201
+ ...d,
202
+ type: FoldersListType.Dashboard,
203
+ dashboardType: DashboardType.Organisation
204
+ })) as FoldersListItem[],
205
+ ...dashboardShallows.value.map(d => ({
206
+ ...d,
207
+ type: FoldersListType.Dashboard,
208
+ dashboardType: DashboardType.Shallow
209
+ })) as FoldersListItem[]
210
+ ], d => d.label)
211
+ ]
212
+ })
213
+
214
+ const onSelect = (values: string[]) => {
215
+ selecteds.value = values;
216
+ const selectedItems = items.value.filter(i => selecteds.value!.includes(i.id));
217
+ const newDashboardType = selectedItems.map(i => i.dashboardType);
218
+ const newModelValue = selectedItems.map(i => i.id);
219
+ const newType = selectedItems.map(i => i.type);
220
+ emit("update:dashboard-type", newDashboardType);
221
+ emit("update:modelValue", newModelValue);
222
+ emit("update:type", newType);
223
+ emit("update", { dashboardType: newDashboardType, modelValue: newModelValue, type: newType });
224
+ };
225
+
226
+ const isSelected = (id: string) => {
227
+ return selecteds.value?.includes(id);
228
+ };
229
+
230
+ onMounted(() => {
231
+ fetchUserOrganisation();
232
+ })
233
+
234
+ watch(() => organisationId.value, () => {
235
+ if (organisationId.value) {
236
+ getOrganisation(organisationId.value);
237
+ }
238
+ }, { immediate: true });
239
+
240
+ watch(() => props.foldersFilters, (next, previous) => {
241
+ if ((!next && !previous) || !_.isEqual(next, previous)) {
242
+ getManyFolders(props.foldersFilters, f => f.parentId == props.foldersFilters?.parentId);
243
+ }
244
+ }, { immediate: true });
245
+
246
+ watch(() => props.dashboardOrganisationsFilters, (next, previous) => {
247
+ if ((!next && !previous) || !_.isEqual(next, previous)) {
248
+ getManyDashboardOrganisations(props.dashboardOrganisationsFilters, f => f.folderId == props.foldersFilters?.parentId);
249
+ }
250
+ }, { immediate: true });
251
+
252
+ watch(() => props.dashboardShallowsFilters, (next, previous) => {
253
+ if ((!next && !previous) || !_.isEqual(next, previous)) {
254
+ getManyDashboardShallows(props.dashboardShallowsFilters, f => f.folderId == props.foldersFilters?.parentId);
255
+ }
256
+ }, { immediate: true });
257
+
258
+ watch(() => props.modelValue, (next) => {
259
+ selecteds.value = next;
260
+ }, { immediate: true });
261
+
262
+ return {
263
+ fetchingDashboardOrganisations,
264
+ fetchingDashboardShallows,
265
+ fetchingFolders,
266
+ mainOrganisationDashboardId,
267
+ mainUserDashboardId,
268
+ selecteds,
269
+ items,
270
+ onSelect,
271
+ isSelected,
272
+ FoldersListType,
273
+ DashboardType
274
+ };
275
+ }
276
+ });
277
+ </script>
@@ -1,10 +1,11 @@
1
1
  <template>
2
2
  <FSLoadDataTable
3
- v-if="!initialized || gettingUserOrganisationTable"
3
+ v-if="($props.tableCode && !initialized) || gettingUserOrganisationTable || !table"
4
4
  />
5
5
  <FSDataTableUI
6
6
  v-else
7
7
  @update:rowsPerPage="table.rowsPerPage = $event"
8
+ @update:showFilters="table.showFilters = $event"
8
9
  @update:filters="table.filters = $event"
9
10
  @update:headers="table.headers = $event"
10
11
  @update:sortBy="table.sortBy = $event"
@@ -29,6 +30,7 @@ import { computed, defineComponent, onUnmounted, type PropType, watch } from "vu
29
30
 
30
31
  import { useUserOrganisationTable, useUpdateUserOrganisationTable, useDataTables } from "@dative-gpi/foundation-core-services/composables";
31
32
  import { useDebounce, useTables } from "@dative-gpi/foundation-shared-components/composables";
33
+ import { type FSDataTableColumn } from "@dative-gpi/foundation-shared-components/models";
32
34
 
33
35
  import FSLoadDataTable from "@dative-gpi/foundation-shared-components/components/lists/FSLoadDataTable.vue";
34
36
  import FSDataTableUI from "@dative-gpi/foundation-shared-components/components/lists/FSDataTableUI.vue";
@@ -40,22 +42,28 @@ export default defineComponent({
40
42
  FSDataTableUI
41
43
  },
42
44
  props: {
45
+ defaultMode: {
46
+ type: String as PropType<"table" | "iterator">,
47
+ required: false,
48
+ default: "table"
49
+ },
43
50
  tableCode: {
44
- type: String,
45
- required: true
51
+ type: String as PropType<string | null>,
52
+ required: false,
53
+ default: null
46
54
  },
47
55
  debounceTime: {
48
56
  type: Number,
49
57
  required: false,
50
58
  default: 1000
51
59
  },
52
- customSorts: {
53
- type: Object as PropType<{ [key: string]: any }>,
60
+ extraHeaders: {
61
+ type: Array as PropType<FSDataTableColumn[]>,
54
62
  required: false,
55
- default: () => ({})
63
+ default: () => []
56
64
  },
57
- customSortRaws: {
58
- type: Object as PropType<{ [key: string]: any }>,
65
+ headersOptions: {
66
+ type: Object as PropType<{ [key: string]: Partial<FSDataTableColumn> }>,
59
67
  required: false,
60
68
  default: () => ({})
61
69
  }
@@ -67,7 +75,7 @@ export default defineComponent({
67
75
  const { getTable, setTable } = useTables();
68
76
  const { debounce, cancel } = useDebounce();
69
77
 
70
- const computedTable = computed(() => computeTable(props.customSorts, props.customSortRaws));
78
+ const computedTable = computed(() => computeTable(props.headersOptions, props.defaultMode, props.extraHeaders));
71
79
 
72
80
  onUnmounted(() => {
73
81
  cancel();
@@ -75,23 +83,17 @@ export default defineComponent({
75
83
  });
76
84
 
77
85
  const update = () => {
78
- updateTable(
79
- updateUserOrganisationTable,
80
- setTable,
81
- props.tableCode
82
- );
86
+ if (props.tableCode) {
87
+ updateTable(updateUserOrganisationTable, setTable, props.tableCode, props.defaultMode);
88
+ }
83
89
  }
84
90
 
85
91
  watch(() => props.tableCode, async (): Promise<void> => {
86
- onTableCodeChange(
87
- getUserOrganisationTable,
88
- getTable,
89
- props.tableCode
90
- );
92
+ onTableCodeChange(getUserOrganisationTable, getTable, props.tableCode, props.defaultMode);
91
93
  }, { immediate: true });
92
94
 
93
- watch(() => table.value, () => {
94
- if (table.value && initialized.value) {
95
+ watch(() => (table.value ? { ...table.value } : null), (_, former) => {
96
+ if (table.value && former && initialized.value) {
95
97
  debounce(update, props.debounceTime);
96
98
  }
97
99
  }, { deep: true });
@@ -0,0 +1,338 @@
1
+ <template>
2
+ <FSDataTable
3
+ rowGap="6px"
4
+ :rowColor="criticityColor"
5
+ :itemTo="$props.itemTo"
6
+ :items="alertsOrdered"
7
+ :loading="fetchingAlerts"
8
+ :tableCode="$props.tableCode"
9
+ :modelValue="$props.modelValue"
10
+ @update:modelValue="$emit('update:modelValue', $event)"
11
+ v-bind="$attrs"
12
+ >
13
+ <template
14
+ v-for="(_, name) in $slots"
15
+ v-slot:[name]="slotData"
16
+ >
17
+ <slot
18
+ :name="name"
19
+ v-bind="slotData"
20
+ />
21
+ </template>
22
+
23
+ <template
24
+ #item.criticity="{ item }"
25
+ >
26
+ <FSRow
27
+ :wrap="false"
28
+ align="center-left"
29
+ gap="2px"
30
+ >
31
+ <FSIcon
32
+ :color="AlertTools.criticityColor(item.criticity)"
33
+ >
34
+ {{ AlertTools.criticityIcon(item.criticity) }}
35
+ </FSIcon>
36
+ <FSSpan>
37
+ {{ AlertTools.criticityLabel(item.criticity) }}
38
+ </FSSpan>
39
+ </FSRow>
40
+ </template>
41
+ <template
42
+ #item.icon="{ item }"
43
+ >
44
+ <FSIcon>
45
+ {{ item.icon }}
46
+ </FSIcon>
47
+ </template>
48
+ <template
49
+ #item.tags="{ item }"
50
+ >
51
+ <FSTagGroup
52
+ variant="slide"
53
+ :editable="false"
54
+ :tags="item.tags"
55
+ />
56
+ </template>
57
+ <template
58
+ #item.groupByValues="{ item }"
59
+ >
60
+ <FSTagGroup
61
+ variant="slide"
62
+ :tags="item.groupByValues.map((gbv: any) => `${gbv.label}: ${gbv.value}`)"
63
+ :editable="false"
64
+ />
65
+ </template>
66
+ <template
67
+ #item.deviceOrganisationImageId="{ item }"
68
+ >
69
+ <FSImage
70
+ v-if="item.deviceOrganisationImageId != null"
71
+ width="32px"
72
+ height="32px"
73
+ :imageId="item.deviceOrganisationImageId"
74
+ :thumbnail="true"
75
+ />
76
+ </template>
77
+ <template
78
+ #item.acknowledged="{ item }"
79
+ >
80
+ <FSSpan
81
+ v-if="item.acknowledged"
82
+ font="text-overline"
83
+ >
84
+ {{ $tr('entity.alert.acknowledged', 'Acknowledged') }}
85
+ </FSSpan>
86
+ <FSButtonAcknowledgeAlert
87
+ v-else-if="!item.acknowledged && $props.allowAcknowledge"
88
+ :alertId="item.id"
89
+ />
90
+ <FSSpan
91
+ v-else
92
+ font="text-overline"
93
+ >
94
+ {{ $tr('ui.alert.not-acknowledged', 'Not acknowledged') }}
95
+ </FSSpan>
96
+ </template>
97
+ <template
98
+ #item.acknowledgingUserImageId="{ item }"
99
+ >
100
+ <FSImage
101
+ v-if="item.acknowledged && item.acknowledgingUserImageId != null"
102
+ width="32px"
103
+ height="32px"
104
+ :imageId="item.acknowledgingUserImageId"
105
+ :thumbnail="true"
106
+ />
107
+ </template>
108
+ <template
109
+ #item.acknowledgingTimestamp="{ item }"
110
+ >
111
+ <FSSpan
112
+ font="text-overline"
113
+ >
114
+ {{ epochToShortTimeFormat(item.acknowledgingTimestamp) }}
115
+ </FSSpan>
116
+ </template>
117
+ <template
118
+ #item.history="{ item }"
119
+ >
120
+ <FSTagGroup
121
+ variant="slide"
122
+ :tags="item.history.map((h: any) => AlertTools.statusLabel(h.status))"
123
+ :editable="false"
124
+ />
125
+ </template>
126
+ <template
127
+ #item.initialState="{ item }"
128
+ >
129
+ <FSSpan
130
+ font="text-overline"
131
+ >
132
+ {{ AlertTools.statusLabel(item.initialState.status) }}
133
+ </FSSpan>
134
+ </template>
135
+ <template
136
+ #item.triggerSourceTimestamp="{ item }"
137
+ >
138
+ <FSSpan
139
+ font="text-overline"
140
+ >
141
+ {{ epochToShortTimeFormat(item.triggerSourceTimestamp) }}
142
+ </FSSpan>
143
+ </template>
144
+ <template
145
+ #item.triggerEnqueuedTimestamp="{ item }"
146
+ >
147
+ <FSSpan
148
+ font="text-overline"
149
+ >
150
+ {{ epochToShortTimeFormat(item.triggerEnqueuedTimestamp) }}
151
+ </FSSpan>
152
+ </template>
153
+ <template
154
+ #item.triggerProcessedTimestamp="{ item }"
155
+ >
156
+ <FSSpan
157
+ font="text-overline"
158
+ >
159
+ {{ epochToShortTimeFormat(item.triggerProcessedTimestamp) }}
160
+ </FSSpan>
161
+ </template>
162
+ <template
163
+ #item.lastState="{ item }"
164
+ >
165
+ <FSSpan
166
+ font="text-overline"
167
+ >
168
+ {{ AlertTools.statusLabel(item.lastState.status) }}
169
+ </FSSpan>
170
+ </template>
171
+ <template
172
+ #item.currentSourceTimestamp="{ item }"
173
+ >
174
+ <FSSpan
175
+ font="text-overline"
176
+ >
177
+ {{ epochToShortTimeFormat(item.currentSourceTimestamp) }}
178
+ </FSSpan>
179
+ </template>
180
+ <template
181
+ #item.currentEnqueuedTimestamp="{ item }"
182
+ >
183
+ <FSSpan
184
+ font="text-overline"
185
+ >
186
+ {{ epochToShortTimeFormat(item.currentEnqueuedTimestamp) }}
187
+ </FSSpan>
188
+ </template>
189
+ <template
190
+ #item.currentProcessedTimestamp="{ item }"
191
+ >
192
+ <FSSpan
193
+ font="text-overline"
194
+ >
195
+ {{ epochToShortTimeFormat(item.currentProcessedTimestamp) }}
196
+ </FSSpan>
197
+ </template>
198
+ <template
199
+ #item.tile="{ item }"
200
+ >
201
+ <FSAlertTileUI
202
+ variant="standard"
203
+ :label="item.label"
204
+ :deviceOrganisationLabel="item.deviceOrganisationLabel"
205
+ :icon="item.icon"
206
+ :triggerProcessedTimestamp="item.triggerProcessedTimestamp"
207
+ :to="$props.itemTo && $props.itemTo(item)"
208
+ :color="alertColorByCriticity(item.criticity)"
209
+ />
210
+ </template>
211
+ </FSDataTable>
212
+ </template>
213
+
214
+ <script lang="ts">
215
+ import type { PropType} from "vue";
216
+ import type { RouteLocation } from "vue-router";
217
+ import { computed, defineComponent, watch } from "vue";
218
+ import _ from "lodash";
219
+
220
+ import type { AlertFilters, AlertInfos } from "@dative-gpi/foundation-core-domain/models";
221
+ import { useDateFormat } from "@dative-gpi/foundation-shared-services/composables";
222
+ import { useAlerts } from "@dative-gpi/foundation-core-services/composables";
223
+ import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
224
+ import type { Criticity } from "@dative-gpi/foundation-shared-domain/enums";
225
+ import { AlertStatus } from "@dative-gpi/foundation-shared-domain/enums";
226
+
227
+ import { AlertTools } from "@dative-gpi/foundation-shared-components/tools";
228
+
229
+ import FSDataTable from "../FSDataTable.vue";
230
+ import FSButtonAcknowledgeAlert from "./FSButtonAcknowledgeAlert.vue";
231
+ import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
232
+ import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
233
+ import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
234
+ import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
235
+ import FSTagGroup from "@dative-gpi/foundation-shared-components/components/FSTagGroup.vue";
236
+ import FSAlertTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSAlertTileUI.vue";
237
+
238
+ export default defineComponent({
239
+ name: "FSBaseAlertsList",
240
+ components: {
241
+ FSButtonAcknowledgeAlert,
242
+ FSAlertTileUI,
243
+ FSDataTable,
244
+ FSTagGroup,
245
+ FSImage,
246
+ FSIcon,
247
+ FSSpan,
248
+ FSRow
249
+ },
250
+ props: {
251
+ tableCode: {
252
+ type: String as PropType<string | null>,
253
+ required: false,
254
+ default: null
255
+ },
256
+ alertFilters: {
257
+ type: Object as PropType<AlertFilters>,
258
+ required: false,
259
+ default: null
260
+ },
261
+ notAcknowledged:{
262
+ type: Boolean,
263
+ required: false,
264
+ },
265
+ hidePending:{
266
+ type: Boolean,
267
+ required: false,
268
+ },
269
+ modelValue: {
270
+ type: Array as PropType<string[]>,
271
+ required: false,
272
+ default: () => []
273
+ },
274
+ allowAcknowledge: {
275
+ type: Boolean,
276
+ required: false,
277
+ default: false
278
+ },
279
+ itemTo: {
280
+ type: Function as PropType<(item: AlertInfos) => Partial<RouteLocation>>,
281
+ required: false
282
+ },
283
+ },
284
+ emits: ["update:modelValue"],
285
+ setup(props) {
286
+ const { getMany: getManyAlerts, entities: alerts, fetching : fetchingAlerts } = useAlerts();
287
+ const { epochToShortTimeFormat } = useDateFormat();
288
+
289
+
290
+ const criticityColor = (row: any) => {
291
+ return AlertTools.criticityColor(row.criticity);
292
+ };
293
+
294
+ const alertColorByCriticity = (criticity: Criticity | number) => {
295
+ return AlertTools.criticityColor(criticity);
296
+ };
297
+
298
+ const alertsOrdered = computed(() => {
299
+ const als = [...alerts.value]
300
+ return als.sort((a: AlertInfos, b: AlertInfos) => {
301
+ return (a.acknowledged === b.acknowledged) ?
302
+ +b.currentSourceTimestamp! - +a.currentSourceTimestamp! : a.acknowledged ? 1 : -1
303
+ });
304
+ });
305
+
306
+ watch(() => [props.alertFilters, props.notAcknowledged, props.hidePending], (next, previous) => {
307
+ if (!_.isEqual(next, previous)) {
308
+ if(props.notAcknowledged){
309
+ getManyAlerts({
310
+ ...props.alertFilters,
311
+ acknowledged: false,
312
+ statuses: [AlertStatus.Unresolved, AlertStatus.Triggered],
313
+ });
314
+ }
315
+ else{
316
+ getManyAlerts({
317
+ ...props.alertFilters,
318
+ statuses: props.hidePending ?
319
+ [AlertStatus.Unresolved, AlertStatus.Resolved, AlertStatus.Triggered] : props.alertFilters?.statuses
320
+ }); // TODO, gérer les conditions pour que les alertes s'affichent ici notamment lorsqu'elles sont acquittées
321
+ // la FilterFactory gère pas ces conditions correctement
322
+ }
323
+ }
324
+ }, { immediate: true });
325
+
326
+
327
+ return {
328
+ fetchingAlerts,
329
+ alertsOrdered,
330
+ AlertTools,
331
+ ColorEnum,
332
+ epochToShortTimeFormat,
333
+ alertColorByCriticity,
334
+ criticityColor
335
+ };
336
+ }
337
+ });
338
+ </script>