Skip to content

Commit 7ad384d

Browse files
fix(ui): allow to specify the connection path
Related: #8
1 parent 74f1c20 commit 7ad384d

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

ui/src/App.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:is-open="showConnectionModal"
1717
:initial-server-url="serverUrl"
1818
:initial-ws-only="wsOnly"
19+
:initial-path="path"
1920
:is-connecting="isConnecting"
2021
:error="connectionError"
2122
@submit="onSubmit"
@@ -61,6 +62,7 @@ export default {
6162
...mapState({
6263
serverUrl: (state) => state.connection.serverUrl,
6364
wsOnly: (state) => state.connection.wsOnly,
65+
path: (state) => state.connection.path,
6466
backgroundColor: (state) =>
6567
state.config.darkTheme ? "" : "grey lighten-5",
6668
}),
@@ -82,7 +84,7 @@ export default {
8284
},
8385
8486
methods: {
85-
tryConnect(serverUrl, auth, wsOnly) {
87+
tryConnect(serverUrl, auth, wsOnly, path) {
8688
this.isConnecting = true;
8789
if (SocketHolder.socket) {
8890
SocketHolder.socket.disconnect();
@@ -95,6 +97,7 @@ export default {
9597
reconnection: false,
9698
withCredentials: true, // needed for cookie-based sticky-sessions
9799
transports: wsOnly ? ["websocket"] : ["polling", "websocket"],
100+
path,
98101
auth,
99102
});
100103
socket.once("connect", () => {
@@ -103,7 +106,11 @@ export default {
103106
this.isConnecting = false;
104107
105108
socket.io.reconnection(true);
106-
this.$store.commit("connection/saveConfig", { serverUrl, wsOnly });
109+
this.$store.commit("connection/saveConfig", {
110+
serverUrl,
111+
wsOnly,
112+
path,
113+
});
107114
SocketHolder.socket = socket;
108115
this.registerEventListeners(socket);
109116
});
@@ -163,7 +170,8 @@ export default {
163170
username: form.username,
164171
password: form.password,
165172
},
166-
form.wsOnly
173+
form.wsOnly,
174+
form.path
167175
);
168176
},
169177
},
@@ -173,13 +181,13 @@ export default {
173181
174182
if (this.serverUrl) {
175183
const sessionId = this.$store.state.connection.sessionId;
176-
const wsOnly = this.$store.state.connection.wsOnly;
177184
this.tryConnect(
178185
this.serverUrl,
179186
{
180187
sessionId,
181188
},
182-
wsOnly
189+
this.wsOnly,
190+
this.path
183191
);
184192
} else {
185193
this.showConnectionModal = true;

ui/src/components/ConnectionModal.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
dense
3333
/>
3434

35+
<v-text-field
36+
v-model="path"
37+
:label="$t('connection.path')"
38+
></v-text-field>
39+
3540
<v-btn
3641
:loading="isConnecting"
3742
:disabled="isConnecting || !isValid"
@@ -57,13 +62,15 @@ export default {
5762
isConnecting: Boolean,
5863
initialServerUrl: String,
5964
initialWsOnly: Boolean,
65+
initialPath: String,
6066
error: String,
6167
},
6268
6369
data() {
6470
return {
6571
serverUrl: this.initialServerUrl,
6672
wsOnly: this.initialWsOnly,
73+
path: this.initialPath,
6774
username: "",
6875
password: "",
6976
};
@@ -85,6 +92,7 @@ export default {
8592
this.$emit("submit", {
8693
serverUrl: this.serverUrl,
8794
wsOnly: this.wsOnly,
95+
path: this.path,
8896
username: this.username,
8997
password: this.password,
9098
});

ui/src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"connect": "Connect",
2323
"invalid-credentials": "Invalid credentials",
2424
"error": "Error",
25-
"websocket-only": "WebSocket only?"
25+
"websocket-only": "WebSocket only?",
26+
"path": "Path"
2627
},
2728
"dashboard": {
2829
"title": "Dashboard"

ui/src/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"connect": "Se connecter",
2323
"invalid-credentials": "Identifiants invalides",
2424
"error": "Erreur",
25-
"websocket-only": "WebSocket uniquement ?"
25+
"websocket-only": "WebSocket uniquement ?",
26+
"path": "Chemin HTTP"
2627
},
2728
"dashboard": {
2829
"title": "Accueil"

ui/src/store/modules/connection.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default {
55
state: {
66
serverUrl: "",
77
wsOnly: false,
8+
path: "/socket.io",
89
sessionId: "",
910
connected: false,
1011
},
@@ -14,14 +15,17 @@ export default {
1415
state.serverUrl = localStorage.getItem("server_url");
1516
state.wsOnly = localStorage.getItem("ws_only") === "true";
1617
state.sessionId = localStorage.getItem("session_id");
18+
state.path = localStorage.getItem("path") || "/socket.io";
1719
}
1820
},
19-
saveConfig(state, { serverUrl, wsOnly }) {
21+
saveConfig(state, { serverUrl, wsOnly, path }) {
2022
state.serverUrl = serverUrl;
2123
state.wsOnly = wsOnly;
24+
state.path = path;
2225
if (isLocalStorageAvailable) {
2326
localStorage.setItem("server_url", serverUrl);
2427
localStorage.setItem("ws_only", wsOnly);
28+
localStorage.setItem("path", path);
2529
}
2630
},
2731
saveSessionId(state, sessionId) {

0 commit comments

Comments
 (0)