fix(ui): allow to specify the connection path
Related: https://github.com/socketio/socket.io-admin-ui/issues/8
This commit is contained in:
parent
74f1c20f6a
commit
7ad384dd34
|
|
@ -16,6 +16,7 @@
|
||||||
:is-open="showConnectionModal"
|
:is-open="showConnectionModal"
|
||||||
:initial-server-url="serverUrl"
|
:initial-server-url="serverUrl"
|
||||||
:initial-ws-only="wsOnly"
|
:initial-ws-only="wsOnly"
|
||||||
|
:initial-path="path"
|
||||||
:is-connecting="isConnecting"
|
:is-connecting="isConnecting"
|
||||||
:error="connectionError"
|
:error="connectionError"
|
||||||
@submit="onSubmit"
|
@submit="onSubmit"
|
||||||
|
|
@ -61,6 +62,7 @@ export default {
|
||||||
...mapState({
|
...mapState({
|
||||||
serverUrl: (state) => state.connection.serverUrl,
|
serverUrl: (state) => state.connection.serverUrl,
|
||||||
wsOnly: (state) => state.connection.wsOnly,
|
wsOnly: (state) => state.connection.wsOnly,
|
||||||
|
path: (state) => state.connection.path,
|
||||||
backgroundColor: (state) =>
|
backgroundColor: (state) =>
|
||||||
state.config.darkTheme ? "" : "grey lighten-5",
|
state.config.darkTheme ? "" : "grey lighten-5",
|
||||||
}),
|
}),
|
||||||
|
|
@ -82,7 +84,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
tryConnect(serverUrl, auth, wsOnly) {
|
tryConnect(serverUrl, auth, wsOnly, path) {
|
||||||
this.isConnecting = true;
|
this.isConnecting = true;
|
||||||
if (SocketHolder.socket) {
|
if (SocketHolder.socket) {
|
||||||
SocketHolder.socket.disconnect();
|
SocketHolder.socket.disconnect();
|
||||||
|
|
@ -95,6 +97,7 @@ export default {
|
||||||
reconnection: false,
|
reconnection: false,
|
||||||
withCredentials: true, // needed for cookie-based sticky-sessions
|
withCredentials: true, // needed for cookie-based sticky-sessions
|
||||||
transports: wsOnly ? ["websocket"] : ["polling", "websocket"],
|
transports: wsOnly ? ["websocket"] : ["polling", "websocket"],
|
||||||
|
path,
|
||||||
auth,
|
auth,
|
||||||
});
|
});
|
||||||
socket.once("connect", () => {
|
socket.once("connect", () => {
|
||||||
|
|
@ -103,7 +106,11 @@ export default {
|
||||||
this.isConnecting = false;
|
this.isConnecting = false;
|
||||||
|
|
||||||
socket.io.reconnection(true);
|
socket.io.reconnection(true);
|
||||||
this.$store.commit("connection/saveConfig", { serverUrl, wsOnly });
|
this.$store.commit("connection/saveConfig", {
|
||||||
|
serverUrl,
|
||||||
|
wsOnly,
|
||||||
|
path,
|
||||||
|
});
|
||||||
SocketHolder.socket = socket;
|
SocketHolder.socket = socket;
|
||||||
this.registerEventListeners(socket);
|
this.registerEventListeners(socket);
|
||||||
});
|
});
|
||||||
|
|
@ -163,7 +170,8 @@ export default {
|
||||||
username: form.username,
|
username: form.username,
|
||||||
password: form.password,
|
password: form.password,
|
||||||
},
|
},
|
||||||
form.wsOnly
|
form.wsOnly,
|
||||||
|
form.path
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -173,13 +181,13 @@ export default {
|
||||||
|
|
||||||
if (this.serverUrl) {
|
if (this.serverUrl) {
|
||||||
const sessionId = this.$store.state.connection.sessionId;
|
const sessionId = this.$store.state.connection.sessionId;
|
||||||
const wsOnly = this.$store.state.connection.wsOnly;
|
|
||||||
this.tryConnect(
|
this.tryConnect(
|
||||||
this.serverUrl,
|
this.serverUrl,
|
||||||
{
|
{
|
||||||
sessionId,
|
sessionId,
|
||||||
},
|
},
|
||||||
wsOnly
|
this.wsOnly,
|
||||||
|
this.path
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.showConnectionModal = true;
|
this.showConnectionModal = true;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,11 @@
|
||||||
dense
|
dense
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<v-text-field
|
||||||
|
v-model="path"
|
||||||
|
:label="$t('connection.path')"
|
||||||
|
></v-text-field>
|
||||||
|
|
||||||
<v-btn
|
<v-btn
|
||||||
:loading="isConnecting"
|
:loading="isConnecting"
|
||||||
:disabled="isConnecting || !isValid"
|
:disabled="isConnecting || !isValid"
|
||||||
|
|
@ -57,6 +62,7 @@ export default {
|
||||||
isConnecting: Boolean,
|
isConnecting: Boolean,
|
||||||
initialServerUrl: String,
|
initialServerUrl: String,
|
||||||
initialWsOnly: Boolean,
|
initialWsOnly: Boolean,
|
||||||
|
initialPath: String,
|
||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -64,6 +70,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
serverUrl: this.initialServerUrl,
|
serverUrl: this.initialServerUrl,
|
||||||
wsOnly: this.initialWsOnly,
|
wsOnly: this.initialWsOnly,
|
||||||
|
path: this.initialPath,
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
};
|
};
|
||||||
|
|
@ -85,6 +92,7 @@ export default {
|
||||||
this.$emit("submit", {
|
this.$emit("submit", {
|
||||||
serverUrl: this.serverUrl,
|
serverUrl: this.serverUrl,
|
||||||
wsOnly: this.wsOnly,
|
wsOnly: this.wsOnly,
|
||||||
|
path: this.path,
|
||||||
username: this.username,
|
username: this.username,
|
||||||
password: this.password,
|
password: this.password,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"invalid-credentials": "Invalid credentials",
|
"invalid-credentials": "Invalid credentials",
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
"websocket-only": "WebSocket only?"
|
"websocket-only": "WebSocket only?",
|
||||||
|
"path": "Path"
|
||||||
},
|
},
|
||||||
"dashboard": {
|
"dashboard": {
|
||||||
"title": "Dashboard"
|
"title": "Dashboard"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@
|
||||||
"connect": "Se connecter",
|
"connect": "Se connecter",
|
||||||
"invalid-credentials": "Identifiants invalides",
|
"invalid-credentials": "Identifiants invalides",
|
||||||
"error": "Erreur",
|
"error": "Erreur",
|
||||||
"websocket-only": "WebSocket uniquement ?"
|
"websocket-only": "WebSocket uniquement ?",
|
||||||
|
"path": "Chemin HTTP"
|
||||||
},
|
},
|
||||||
"dashboard": {
|
"dashboard": {
|
||||||
"title": "Accueil"
|
"title": "Accueil"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ export default {
|
||||||
state: {
|
state: {
|
||||||
serverUrl: "",
|
serverUrl: "",
|
||||||
wsOnly: false,
|
wsOnly: false,
|
||||||
|
path: "/socket.io",
|
||||||
sessionId: "",
|
sessionId: "",
|
||||||
connected: false,
|
connected: false,
|
||||||
},
|
},
|
||||||
|
|
@ -14,14 +15,17 @@ export default {
|
||||||
state.serverUrl = localStorage.getItem("server_url");
|
state.serverUrl = localStorage.getItem("server_url");
|
||||||
state.wsOnly = localStorage.getItem("ws_only") === "true";
|
state.wsOnly = localStorage.getItem("ws_only") === "true";
|
||||||
state.sessionId = localStorage.getItem("session_id");
|
state.sessionId = localStorage.getItem("session_id");
|
||||||
|
state.path = localStorage.getItem("path") || "/socket.io";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveConfig(state, { serverUrl, wsOnly }) {
|
saveConfig(state, { serverUrl, wsOnly, path }) {
|
||||||
state.serverUrl = serverUrl;
|
state.serverUrl = serverUrl;
|
||||||
state.wsOnly = wsOnly;
|
state.wsOnly = wsOnly;
|
||||||
|
state.path = path;
|
||||||
if (isLocalStorageAvailable) {
|
if (isLocalStorageAvailable) {
|
||||||
localStorage.setItem("server_url", serverUrl);
|
localStorage.setItem("server_url", serverUrl);
|
||||||
localStorage.setItem("ws_only", wsOnly);
|
localStorage.setItem("ws_only", wsOnly);
|
||||||
|
localStorage.setItem("path", path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveSessionId(state, sessionId) {
|
saveSessionId(state, sessionId) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue