Skip to content

Commit b650c1e

Browse files
feat: use configuration api path for frontend properties
1 parent e78529c commit b650c1e

File tree

10 files changed

+86
-9
lines changed

10 files changed

+86
-9
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ VITE_API_URI="/"
33
VITE_NEXTCLOUD_URI="/nextcloud"
44
VITE_AXIOS_TIMEOUT=10000
55

6-
VITE_WEBSOCKET_API_URL=""
7-
86
VITE_USER_INFO_API_URI=""
97

108
VITE_PROXY_API_URL="http://localhost:8090"

.env.production

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ VITE_BASE_URI="/collabsoft"
22
VITE_API_URI="/collabsoft"
33
VITE_AXIOS_TIMEOUT=10000
44

5-
VITE_WEBSOCKET_API_URL=""
6-
75
VITE_USER_INFO_API_URI="/portail/api/v5-1/userinfo?claims=private,name&groups="

src/main/java/fr/recia/collabsoft/configuration/CollabsoftProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import fr.recia.collabsoft.configuration.bean.CorsProperties;
20+
import fr.recia.collabsoft.configuration.bean.FrontProperties;
2021
import fr.recia.collabsoft.configuration.bean.SecurityProperties;
2122
import fr.recia.collabsoft.configuration.bean.SoffitProperties;
2223
import fr.recia.collabsoft.configuration.bean.StorageProperties;
@@ -39,6 +40,7 @@
3940
public class CollabsoftProperties {
4041

4142
private CorsProperties cors = new CorsProperties();
43+
private FrontProperties front = new FrontProperties();
4244
private SecurityProperties security = new SecurityProperties();
4345
private SoffitProperties soffit = new SoffitProperties();
4446
private StorageProperties storage = new StorageProperties();
@@ -52,6 +54,7 @@ private void init() throws JsonProcessingException {
5254
public String toString() {
5355
return "{\n"
5456
+ cors + ",\n"
57+
+ front + ",\n"
5558
+ security + ",\n"
5659
+ soffit + "\n"
5760
+ storage
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2023 GIP-RECIA, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package fr.recia.collabsoft.configuration.bean;
17+
18+
import lombok.Data;
19+
20+
@Data
21+
public class FrontProperties {
22+
23+
private WebsocketProperties websocket = new WebsocketProperties();
24+
25+
@Data
26+
public static class WebsocketProperties {
27+
28+
private String url;
29+
30+
@Override
31+
public String toString() {
32+
return "{" +
33+
"\n\t\t\"url\": \"" + url + "\"" +
34+
"\n}";
35+
}
36+
37+
}
38+
39+
@Override
40+
public String toString() {
41+
return "\"FrontProperties\": {" +
42+
"\n\t\"websocket\": \"" + websocket + "\"" +
43+
"\n}";
44+
}
45+
46+
}

src/main/java/fr/recia/collabsoft/web/rest/ConfigurationController.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,32 @@
1515
*/
1616
package fr.recia.collabsoft.web.rest;
1717

18+
import fr.recia.collabsoft.configuration.CollabsoftProperties;
1819
import lombok.extern.slf4j.Slf4j;
20+
import org.springframework.beans.factory.annotation.Autowired;
1921
import org.springframework.http.HttpStatus;
2022
import org.springframework.http.ResponseEntity;
2123
import org.springframework.web.bind.annotation.GetMapping;
2224
import org.springframework.web.bind.annotation.RequestMapping;
2325
import org.springframework.web.bind.annotation.RestController;
2426

27+
import java.util.HashMap;
28+
import java.util.Map;
29+
2530
@Slf4j
2631
@RestController
2732
@RequestMapping(value = "/api/config")
2833
public class ConfigurationController {
2934

35+
@Autowired
36+
private CollabsoftProperties collabsoftProperties;
37+
3038
@GetMapping
3139
public ResponseEntity<Object> getConfiguration() {
32-
return new ResponseEntity<>(HttpStatus.OK);
40+
Map<String, Object> data = new HashMap<>();
41+
data.put("websocketApiUrl", collabsoftProperties.getFront().getWebsocket().getUrl());
42+
43+
return new ResponseEntity<>(data, HttpStatus.OK);
3344
}
3445

3546
}

src/main/resources/config/application-prod.example.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ app:
2121

2222
soffit:
2323
jwt-signature-key: ''
24+
25+
storage:
26+
location: ''
27+
28+
front:
29+
websocket:
30+
url: ''

src/main/resources/config/application.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ app:
6464

6565
soffit:
6666
jwt-signature-key: ''
67+
68+
storage:
69+
location: ''
70+
71+
front:
72+
websocket:
73+
url: ''

src/main/webapp/src/stores/configurationStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const useConfigurationStore = defineStore('configuration', () => {
8686
const isSettings = ref<boolean>(false);
8787

8888
return {
89+
configuration,
8990
init,
9091
isReady,
9192
user,
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export type Configuration = {};
1+
export type Configuration = {
2+
websocketApiUrl: string;
3+
};

src/main/webapp/src/views/app/tldraw/CollaborativeTldrawView.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<script setup lang="ts">
2-
import { useCollaborativeStore } from '@/stores/collaborativeStore';
2+
import { useCollaborativeStore } from '@/stores/collaborativeStore.ts';
3+
import { useConfigurationStore } from '@/stores/configurationStore.ts';
34
import { AppSlug } from '@/types/enums/AppSlug.ts';
45
import { headObserver, styleObserver } from '@/utils/tldrawUtils.ts';
56
import { storeToRefs } from 'pinia';
67
import { onMounted, onUnmounted } from 'vue';
78
import { useRoute, useRouter } from 'vue-router';
89
import { useTheme } from 'vuetify';
910
10-
const { VITE_API_URI, VITE_WEBSOCKET_API_URL, VITE_USER_INFO_API_URI } = import.meta.env;
11+
const { VITE_API_URI, VITE_USER_INFO_API_URI } = import.meta.env;
12+
13+
const configurationStore = useConfigurationStore();
14+
const { configuration } = configurationStore;
1115
1216
const collaborativeStore = useCollaborativeStore();
1317
const { initFileId } = storeToRefs(collaborativeStore);
@@ -33,7 +37,7 @@ onUnmounted(() => {
3337

3438
<template>
3539
<tldraw-multiplayer
36-
:websocket-api-url="VITE_WEBSOCKET_API_URL"
40+
:websocket-api-url="configuration?.websocketApiUrl"
3741
:room-id="`${roomId}-${AppSlug.tldraw}`"
3842
:init-url="initFileId ? `${VITE_API_URI}/api/file/${initFileId}` : ''"
3943
:user-info-api-url="VITE_USER_INFO_API_URI"

0 commit comments

Comments
 (0)