@dative-gpi/foundation-shared-components 1.0.156 → 1.0.157
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.
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import { inject, type PropType,
|
|
6
|
+
import { inject, type PropType, type Ref, watch, ref, onUnmounted, onMounted } from 'vue';
|
|
7
7
|
|
|
8
|
-
import { type Map,
|
|
8
|
+
import { type Map, divIcon, type LatLng, marker, type Marker, type MarkerClusterGroup, type LeafletMouseEvent } from 'leaflet';
|
|
9
9
|
|
|
10
10
|
import { useColors } from "../../composables";
|
|
11
11
|
|
|
@@ -49,87 +49,90 @@ export default {
|
|
|
49
49
|
const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(MARKERCLUSTERGROUP, ref(null));
|
|
50
50
|
|
|
51
51
|
const { getColors } = useColors();
|
|
52
|
-
|
|
53
|
-
const lastMarker = ref<Marker | null>(null);
|
|
54
|
-
|
|
55
|
-
if(!map) {
|
|
56
|
-
throw new Error('FSMapTileLayer must be used inside a FSMap component');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if(!map.value) {
|
|
60
|
-
throw new Error('FSMapTileLayer must be used inside a FSMap component with a map');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const updateMarker = () => {
|
|
64
|
-
if(!map.value || !props.latlng) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if(lastMarker.value) {
|
|
69
|
-
if(markerClusterGroup && markerClusterGroup.value) {
|
|
70
|
-
markerClusterGroup.value.removeLayer(lastMarker.value as Marker);
|
|
71
|
-
} else {
|
|
72
|
-
map.value.removeLayer(lastMarker.value as Marker);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let icon: DivIcon | null = null;
|
|
52
|
+
const getMarkerIcon = () => {
|
|
77
53
|
if(props.variant === 'gps') {
|
|
78
54
|
const size = 16;
|
|
79
|
-
|
|
55
|
+
return divIcon({
|
|
80
56
|
html: gpsMarkerHtml(),
|
|
81
57
|
className: 'fs-map-mylocation',
|
|
82
58
|
iconSize: [size, size],
|
|
83
59
|
iconAnchor: [size / 2, size / 2],
|
|
84
60
|
});
|
|
85
|
-
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if(props.variant === 'location') {
|
|
86
64
|
const size = 36;
|
|
87
|
-
|
|
65
|
+
return divIcon({
|
|
88
66
|
html: locationMarkerHtml(props.icon ?? "mdi-map-marker", getColors(props.color).base, props.label),
|
|
89
67
|
iconSize: [size, size],
|
|
90
68
|
className: props.selected ? 'fs-map-marker fs-map-location fs-map-location-selected' : 'fs-map-marker fs-map-location',
|
|
91
69
|
iconAnchor: [size / 2, size / 2],
|
|
92
70
|
});
|
|
93
|
-
} else {
|
|
94
|
-
const size = 16;
|
|
95
|
-
icon = divIcon({
|
|
96
|
-
html: pinMarkerHtml(getColors(props.color).base, props.label),
|
|
97
|
-
iconSize: [size, size],
|
|
98
|
-
className: props.selected ? 'fs-map-marker fs-map-pin fs-map-pin-selected' : 'fs-map-marker fs-map-pin',
|
|
99
|
-
iconAnchor: [size / 2, size / 2],
|
|
100
|
-
});
|
|
101
71
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
72
|
+
|
|
73
|
+
const size = 16;
|
|
74
|
+
return divIcon({
|
|
75
|
+
html: pinMarkerHtml(getColors(props.color).base, props.label),
|
|
76
|
+
iconSize: [size, size],
|
|
77
|
+
className: props.selected ? 'fs-map-marker fs-map-pin fs-map-pin-selected' : 'fs-map-marker fs-map-pin',
|
|
78
|
+
iconAnchor: [size / 2, size / 2],
|
|
106
79
|
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const actualMarker = ref(marker(props.latlng ?? [0, 0], { icon: getMarkerIcon() }));
|
|
83
|
+
|
|
84
|
+
if(!map) {
|
|
85
|
+
throw new Error('FSMapTileLayer must be used inside a FSMap component');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if(!map.value) {
|
|
89
|
+
throw new Error('FSMapTileLayer must be used inside a FSMap component with a map');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
watch(map, () => {
|
|
93
|
+
if(!map.value) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
107
96
|
|
|
108
97
|
if(markerClusterGroup && markerClusterGroup.value) {
|
|
109
|
-
|
|
98
|
+
actualMarker.value.addTo(markerClusterGroup.value);
|
|
110
99
|
} else {
|
|
111
|
-
|
|
100
|
+
actualMarker.value.addTo(map.value);
|
|
112
101
|
}
|
|
113
|
-
};
|
|
102
|
+
}, { immediate: true });
|
|
103
|
+
|
|
104
|
+
watch([() => props.variant, () => props.color, () => props.selected], () => {
|
|
105
|
+
if(!actualMarker.value || !map.value) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const icon = getMarkerIcon();
|
|
110
|
+
actualMarker.value?.setIcon(icon);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
watch([() => props.latlng?.lat, () => props.latlng?.lng], () => {
|
|
114
|
+
if(!actualMarker.value || !map.value || !props.latlng) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
actualMarker.value.setLatLng(props.latlng);
|
|
119
|
+
});
|
|
114
120
|
|
|
115
121
|
onMounted(() => {
|
|
116
|
-
|
|
122
|
+
actualMarker.value.on('click', (event: LeafletMouseEvent) => {
|
|
123
|
+
emit('click', event);
|
|
124
|
+
});
|
|
117
125
|
});
|
|
118
126
|
|
|
119
127
|
onUnmounted(() => {
|
|
120
|
-
if(
|
|
128
|
+
if(actualMarker.value && map.value) {
|
|
121
129
|
if(markerClusterGroup && markerClusterGroup.value) {
|
|
122
|
-
markerClusterGroup.value.removeLayer(
|
|
130
|
+
markerClusterGroup.value.removeLayer(actualMarker.value as Marker);
|
|
123
131
|
} else {
|
|
124
|
-
map.value.removeLayer(
|
|
132
|
+
map.value.removeLayer(actualMarker.value as Marker);
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
|
-
lastMarker.value = null;
|
|
128
135
|
})
|
|
129
|
-
|
|
130
|
-
watch([() => props.variant, () => props.color, () => props.latlng?.lat, () => props.latlng?.lng, () => props.selected],
|
|
131
|
-
updateMarker,
|
|
132
|
-
);
|
|
133
136
|
}
|
|
134
137
|
};
|
|
135
138
|
</script>
|
|
@@ -58,27 +58,30 @@ export default {
|
|
|
58
58
|
if (!map.value) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
+
|
|
61
62
|
const layers = markerClusterGroup.value.getLayers();
|
|
62
|
-
if (layers.length === props.expectedLayers && !added) {
|
|
63
|
-
markerClusterGroup.value.addTo(map.value);
|
|
64
|
-
added = true;
|
|
65
|
-
}
|
|
66
63
|
|
|
67
64
|
if (layers.length === 0 && added) {
|
|
68
65
|
map.value.removeLayer(markerClusterGroup.value as unknown as L.Layer);
|
|
69
66
|
added = false;
|
|
67
|
+
return;
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (layer.getBounds) {
|
|
75
|
-
bounds.extend(layer.getBounds());
|
|
76
|
-
} else if (layer.getLatLng) {
|
|
77
|
-
bounds.extend(layer.getLatLng());
|
|
78
|
-
}
|
|
69
|
+
if (layers.length === props.expectedLayers && !added) {
|
|
70
|
+
markerClusterGroup.value.addTo(map.value);
|
|
71
|
+
added = true;
|
|
79
72
|
}
|
|
73
|
+
if (layers.length === props.expectedLayers) {
|
|
74
|
+
const bounds = new LatLngBounds([]);
|
|
75
|
+
for (const layer of layers as any[]) {
|
|
76
|
+
if (layer.getBounds) {
|
|
77
|
+
bounds.extend(layer.getBounds());
|
|
78
|
+
} else if (layer.getLatLng) {
|
|
79
|
+
bounds.extend(layer.getLatLng());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
emit("update:bounds", layers.length > 0 ? bounds : null);
|
|
84
|
+
}
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
markerClusterGroup.value.on("layeradd", handleLayerChange);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.157",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "1.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.157",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.157"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "0aedaf4c6e5f977982f18d5936f5cdfaf7ab86a4"
|
|
39
39
|
}
|
package/tools/alertsTools.ts
CHANGED
|
@@ -21,19 +21,19 @@ export const AlertTools = {
|
|
|
21
21
|
statusLabel(value: AlertStatus): string {
|
|
22
22
|
switch (value) {
|
|
23
23
|
case AlertStatus.Pending:
|
|
24
|
-
return $tr('ui.alert-status.pending','Pending');
|
|
24
|
+
return $tr('ui.alert-status.pending', 'Pending');
|
|
25
25
|
case AlertStatus.Untriggered:
|
|
26
|
-
return $tr('ui.alert-status.untriggered','Untriggered');
|
|
26
|
+
return $tr('ui.alert-status.untriggered', 'Untriggered');
|
|
27
27
|
case AlertStatus.Unresolved:
|
|
28
|
-
return $tr('ui.alert-status.unresolved','Unresolved');
|
|
28
|
+
return $tr('ui.alert-status.unresolved', 'Unresolved');
|
|
29
29
|
case AlertStatus.Resolved:
|
|
30
|
-
return $tr('ui.alert-status.resolved','Resolved');
|
|
30
|
+
return $tr('ui.alert-status.resolved', 'Resolved');
|
|
31
31
|
case AlertStatus.Expired:
|
|
32
|
-
return $tr('ui.alert-status.expired','Expired');
|
|
32
|
+
return $tr('ui.alert-status.expired', 'Expired');
|
|
33
33
|
case AlertStatus.Triggered:
|
|
34
|
-
return $tr('ui.alert-status.triggered','Triggered');
|
|
34
|
+
return $tr('ui.alert-status.triggered', 'Triggered');
|
|
35
35
|
case AlertStatus.Abandoned:
|
|
36
|
-
return $tr('ui.alert-status.abandoned','Abandoned');
|
|
36
|
+
return $tr('ui.alert-status.abandoned', 'Abandoned');
|
|
37
37
|
default: return "";
|
|
38
38
|
}
|
|
39
39
|
},
|
|
@@ -74,11 +74,43 @@ export const AlertTools = {
|
|
|
74
74
|
},
|
|
75
75
|
criticityLabel(value: Criticity): string {
|
|
76
76
|
switch (value) {
|
|
77
|
-
case Criticity.Warning: return $tr('ui.common.warning','Warning');
|
|
78
|
-
case Criticity.Error: return $tr('ui.common.error','Error');
|
|
79
|
-
default: return $tr('ui.common.information','Information');
|
|
77
|
+
case Criticity.Warning: return $tr('ui.common.warning', 'Warning');
|
|
78
|
+
case Criticity.Error: return $tr('ui.common.error', 'Error');
|
|
79
|
+
default: return $tr('ui.common.information', 'Information');
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
statusColor(status: AlertStatus): ColorEnum {
|
|
83
|
+
switch (status) {
|
|
84
|
+
case AlertStatus.None:
|
|
85
|
+
case AlertStatus.Pending:
|
|
86
|
+
case AlertStatus.Expired:
|
|
87
|
+
return ColorEnum.Warning;
|
|
88
|
+
case AlertStatus.Unresolved:
|
|
89
|
+
case AlertStatus.Triggered:
|
|
90
|
+
return ColorEnum.Error;
|
|
91
|
+
case AlertStatus.Resolved:
|
|
92
|
+
case AlertStatus.Untriggered:
|
|
93
|
+
return ColorEnum.Success;
|
|
94
|
+
default:
|
|
95
|
+
return ColorEnum.Warning;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
formatValue(value: string) {
|
|
100
|
+
const n = parseFloat(value);
|
|
101
|
+
|
|
102
|
+
if (isNaN(n)) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (Number.isInteger(n)) {
|
|
107
|
+
return n;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return n.toFixed(2);
|
|
80
111
|
}
|
|
81
112
|
}
|
|
113
|
+
|
|
82
114
|
}
|
|
83
115
|
|
|
84
116
|
export const prettyDuration = (n: number | undefined) => {
|