@dative-gpi/foundation-shared-components 1.0.137 → 1.0.139-auth-token

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.
@@ -1,20 +1,25 @@
1
+ /// <reference types="@types/google.maps" />
1
2
  import _ from "lodash";
2
3
 
3
4
  import { Address, type Place } from "@dative-gpi/foundation-shared-domain/models";
5
+ import { useAppLanguageCode } from '@dative-gpi/foundation-shared-services/composables';
4
6
 
5
7
  export const useAddress = () => {
6
8
  const enabled = true;
9
+ const { languageCode } = useAppLanguageCode();
10
+
7
11
  let initialized = false;
12
+ let userLocation: google.maps.LatLngLiteral | null;
8
13
  let searchService: google.maps.places.AutocompleteService;
9
14
  let placeService: google.maps.places.PlacesService;
10
15
  let sessionId: google.maps.places.AutocompleteSessionToken;
11
-
12
16
 
13
17
  const init = async () => {
14
18
  await window.initMap;
19
+ userLocation = await getCurrentLocation();
15
20
  searchService = new google.maps.places.AutocompleteService();
16
21
  placeService = new google.maps.places.PlacesService(
17
- document.getElementById("places") as HTMLDivElement
22
+ document.createElement("div")
18
23
  );
19
24
  sessionId = new google.maps.places.AutocompleteSessionToken();
20
25
  initialized = true;
@@ -25,11 +30,12 @@ export const useAddress = () => {
25
30
  await init();
26
31
  }
27
32
 
28
- return _search(search).then(result => {
29
- return _.map(result, r => ({ id: r.place_id, label: r.description }));
30
- }).catch(() => {
31
- return [];
32
- });
33
+ const mapsResults = await _search(search);
34
+
35
+ return mapsResults.map((result) => ({
36
+ id: result.place_id,
37
+ label: result.description
38
+ }));
33
39
  }
34
40
 
35
41
  const get = async (place: Place): Promise<Address> => {
@@ -78,16 +84,42 @@ export const useAddress = () => {
78
84
  });
79
85
  }
80
86
 
87
+ const getCurrentLocation = async (): Promise<google.maps.LatLngLiteral | null> => {
88
+ if (!navigator.geolocation) {
89
+ return null;
90
+ }
91
+
92
+ return new Promise((resolve) => {
93
+ navigator.geolocation.getCurrentPosition(
94
+ (position) => {
95
+ resolve({
96
+ lat: position.coords.latitude,
97
+ lng: position.coords.longitude
98
+ });
99
+ },
100
+ () => resolve(null)
101
+ );
102
+ });
103
+ };
104
+
81
105
  const _search = (search: string) => {
82
106
  if (!enabled) {
83
107
  throw new Error("offline mode, do not call this method");
84
108
  }
85
109
  return new Promise<google.maps.places.AutocompletePrediction[]>(
86
110
  (resolve, reject) => {
111
+ /**
112
+ * ISO 3166 language code
113
+ */
114
+ const isoLanguageCode = languageCode.value?.split("-")[0];
115
+
87
116
  searchService!.getPlacePredictions(
88
117
  {
89
118
  input: search,
90
- sessionToken: sessionId!
119
+ region: isoLanguageCode,
120
+ language: isoLanguageCode,
121
+ sessionToken: sessionId,
122
+ locationBias: userLocation,
91
123
  },
92
124
  function (result, status) {
93
125
  if (status != google.maps.places.PlacesServiceStatus.OK || !result) {
package/models/map.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  import { type Layer } from "leaflet";
2
2
 
3
- import { type Address } from "@dative-gpi/foundation-shared-domain/models";
4
-
5
3
  export interface MapLayer {
6
- name : string;
4
+ name : MapLayers;
7
5
  label: string;
8
6
  image: string;
9
- layer: Layer;
7
+ layers: Layer[];
10
8
  }
11
9
 
12
- export interface FSLocation {
13
- id: string;
14
- label: string;
15
- icon: string | null;
16
- address: Address;
17
- color: string | null;
10
+ export enum MapLayers {
11
+ Map = "map",
12
+ Imagery = "imagery",
13
+ Snow= "snow"
14
+ }
15
+
16
+ export enum MapOverlayPositions {
17
+ Expand = "expand",
18
+ Half = "half",
19
+ Collapse = "collapse",
18
20
  }
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.137",
4
+ "version": "1.0.139-auth-token",
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.137",
14
- "@dative-gpi/foundation-shared-services": "1.0.137"
13
+ "@dative-gpi/foundation-shared-domain": "1.0.139-auth-token",
14
+ "@dative-gpi/foundation-shared-services": "1.0.139-auth-token"
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": "676162c4362dd556d5ef714f7b17a047ad7f2bad"
38
+ "gitHead": "af9d894b3fa209b796f8466b8545bb1ecc46a399"
39
39
  }
@@ -6,7 +6,15 @@
6
6
  .fs-leaflet-container {
7
7
  width: 100%;
8
8
  height: 100%;
9
- filter: grayscale(var(--fs-map-container-grayscale));
9
+ z-index: 0;
10
+
11
+ .fs-map-tile-base-layer {
12
+ filter: grayscale(var(--fs-map-container-grayscale));
13
+ }
14
+
15
+ .fs-map-tile-grayscale-layer {
16
+ filter: grayscale(100%);
17
+ }
10
18
  }
11
19
 
12
20
  .fs-map-overlay-mobile {
@@ -77,17 +85,10 @@
77
85
  }
78
86
  }
79
87
 
80
- .fs-map-point-pin {
81
- background-color: var(--fs-map-point-pin-color);
82
- border-radius: 100%;
83
- }
84
-
85
- .fs-map-location > div {
88
+ .fs-map-marker > div {
86
89
  display: flex;
87
90
  height: 100%;
88
- color: var(--fs-map-location-pin-color);
89
91
  border-radius: 50%;
90
- background-color: white;
91
92
  filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.4));
92
93
  align-items: center;
93
94
  justify-content: center;
@@ -103,7 +104,7 @@
103
104
  }
104
105
  }
105
106
 
106
- .fs-map-location-full > div {
107
+ .fs-map-cluster-marker > div {
107
108
  background-color: var(--fs-map-location-pin-color);
108
109
  color: white;
109
110
  }
@@ -126,6 +127,41 @@
126
127
  }
127
128
  }
128
129
 
130
+ .fs-map-location > div {
131
+ color: var(--fs-map-location-pin-color);
132
+ background-color: white;
133
+ }
134
+
135
+ .fs-map-pin > div {
136
+ background-color: var(--fs-map-point-pin-color);
137
+ position: relative;
138
+
139
+ transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
140
+ }
141
+
142
+ .fs-map-pin > div::before {
143
+ content: "";
144
+ position: absolute;
145
+ top: -4px;
146
+ left: -4px;
147
+ width: calc(100% + 8px);
148
+ height: calc(100% + 8px);
149
+ border-radius: 50%;
150
+ border: 2px solid var(--fs-map-point-pin-color);
151
+ opacity: 0.4;
152
+
153
+ @include clickscreen {
154
+ &:hover {
155
+ opacity: 1;
156
+ }
157
+ }
158
+ }
159
+
160
+ .fs-map-pin-selected > div {
161
+ transform: scale(1.35);
162
+ }
163
+
164
+
129
165
  .fs-map-site {
130
166
  opacity: 0.6;
131
167
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
package/tools/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./alertsTools";
2
2
  export * from "./chartsTools";
3
+ export * from "./reportsTools";
3
4
  export * from "./timeRangeTools";
@@ -0,0 +1,38 @@
1
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
2
+ import { ColorEnum } from "../models";
3
+ import { JobState } from "@dative-gpi/foundation-shared-domain/enums";
4
+
5
+ const { $tr } = useTranslationsProvider();
6
+
7
+ export const getColorByState = (state: number | JobState | undefined) => {
8
+ switch (state) {
9
+ case JobState.Succeeded:
10
+ return ColorEnum.Success;
11
+ case JobState.Failed:
12
+ return ColorEnum.Error;
13
+ default:
14
+ return ColorEnum.Primary;
15
+ }
16
+ };
17
+
18
+ export const getIconByState = (state: number | JobState | undefined) => {
19
+ switch (state) {
20
+ case JobState.Succeeded:
21
+ return 'mdi-check-circle-outline';
22
+ case JobState.Failed:
23
+ return 'mdi-alert-circle-outline';
24
+ default:
25
+ return 'mdi-alert-circle-outline';
26
+ }
27
+ };
28
+
29
+ export const getLabelByState = (state: number | JobState | undefined) => {
30
+ switch (state) {
31
+ case JobState.Succeeded:
32
+ return $tr('ui.common.success', 'Success');
33
+ case JobState.Failed:
34
+ return $tr('ui.common.error', 'Error');
35
+ default:
36
+ return $tr('ui.common.executed', 'Executed');
37
+ }
38
+ };