@dative-gpi/foundation-shared-services 1.0.106 → 1.0.108
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/composables/app/index.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
const host = ref<string | undefined>(undefined);
|
|
4
|
+
|
|
5
|
+
export const useAppHost = () => {
|
|
6
|
+
const setAppHost = (payload: string) => {
|
|
7
|
+
host.value = payload;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const ready = computed(() => host.value !== null);
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
host,
|
|
14
|
+
ready,
|
|
15
|
+
setAppHost
|
|
16
|
+
};
|
|
17
|
+
}
|
package/composables/index.ts
CHANGED
package/composables/useFiles.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { FILE_URL } from "../config/urls";
|
|
2
2
|
|
|
3
|
-
import { useAppAuthToken } from "@dative-gpi/foundation-shared-services/composables";
|
|
3
|
+
import { useAppAuthToken, useRouting } from "@dative-gpi/foundation-shared-services/composables";
|
|
4
4
|
|
|
5
5
|
export const useFiles = () => {
|
|
6
6
|
const { authToken } = useAppAuthToken();
|
|
7
|
+
const { openTab } = useRouting();
|
|
7
8
|
|
|
8
9
|
const downloadFile = (id: string): void => {
|
|
9
|
-
|
|
10
|
+
openTab(FILE_URL(id, authToken.value));
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
const readFile = (file: File): Promise<string | ArrayBuffer | null> => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type RouteLocation, useRouter } from "vue-router";
|
|
2
|
+
|
|
3
|
+
import { useAppHost } from "@dative-gpi/foundation-shared-services/composables";
|
|
4
|
+
|
|
5
|
+
export const useRouting = () => {
|
|
6
|
+
const { host } = useAppHost();
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
|
|
9
|
+
const handleRoutingEvent = (event: MouseEvent, target: string | RouteLocation, handleDefaultBehavior: boolean = false): void => {
|
|
10
|
+
// If a redirection is requested, check if it comes from an extension and act accordingly
|
|
11
|
+
if (event.ctrlKey || event.metaKey || event.button === 1) {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
openTab(target);
|
|
14
|
+
}
|
|
15
|
+
else if (handleDefaultBehavior) {
|
|
16
|
+
router.push(target);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const openTab = (target: string | RouteLocation): void => {
|
|
21
|
+
// Check if target is a href (string) or a to (RouteLocation), get the absolute url in either case
|
|
22
|
+
const href = typeof target === "string" ? target : router.resolve(target).href;
|
|
23
|
+
|
|
24
|
+
// If the app is in an iframe, open the link in a new tab with the parent iframe host
|
|
25
|
+
if (window.top != window.self && host.value) {
|
|
26
|
+
window.open(host.value + href, "_blank");
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
window.open(href, "_blank");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
handleRoutingEvent,
|
|
35
|
+
openTab
|
|
36
|
+
};
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-services",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.108",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.108"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"vue": "^3.4.29",
|
|
19
19
|
"vue-router": "^4.3.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "f5ec01bfa6108f5140a55273e0abfc6b9b2e69bc"
|
|
22
22
|
}
|