From 1f7c588a2b19c633352004b4326da796a182e64b Mon Sep 17 00:00:00 2001 From: Yann Stepienik Date: Fri, 6 Oct 2023 13:34:03 +0100 Subject: [PATCH] [release] v0.10.0-unstable21 --- client/src/api/constellation.tsx | 34 ++++++++++++++++++++------ client/src/pages/constellation/vpn.jsx | 4 ++- package.json | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/client/src/api/constellation.tsx b/client/src/api/constellation.tsx index 006037f..36774c0 100644 --- a/client/src/api/constellation.tsx +++ b/client/src/api/constellation.tsx @@ -57,13 +57,33 @@ function getLogs() { } function connect(file) { - return wrap(fetch('/cosmos/api/constellation/connect', { - method: 'POST', - headers: { - 'Content-Type': 'application/yaml' - }, - body: file, - })) + return new Promise((resolve, reject) => { + const reader = new FileReader(); + + reader.onload = () => { + fetch('/cosmos/api/constellation/connect', { + method: 'POST', + headers: { + 'Content-Type': 'text/plain', + }, + body: reader.result, + }) + .then(response => { + // Add additional response handling here if needed. + resolve(response); + }) + .catch(error => { + // Handle the error. + reject(error); + }); + }; + + reader.onerror = () => { + reject(new Error('Failed to read the file.')); + }; + + reader.readAsText(file); + }); } function block(nickname, devicename, block) { diff --git a/client/src/pages/constellation/vpn.jsx b/client/src/pages/constellation/vpn.jsx index d0913b3..289f38a 100644 --- a/client/src/pages/constellation/vpn.jsx +++ b/client/src/pages/constellation/vpn.jsx @@ -147,7 +147,9 @@ export const ConstellationVPN = () => { OnChange={async (e) => { let file = e.target.files[0]; await API.constellation.connect(file); - refreshConfig(); + setTimeout(() => { + refreshConfig(); + }, 1000); }} /> diff --git a/package.json b/package.json index 916009f..f6e5666 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.10.0-unstable20", + "version": "0.10.0-unstable21", "description": "", "main": "test-server.js", "bugs": {