Skip to content

Commit

Permalink
Merge pull request #32 from Geode-solutions/feat/dynamic_cli_args
Browse files Browse the repository at this point in the history
Feat/dynamic cli args
  • Loading branch information
JulienChampagnol authored Aug 30, 2024
2 parents 281c268 + 8967bf3 commit b42b3bc
Show file tree
Hide file tree
Showing 11 changed files with 4,208 additions and 6,955 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ logs
/build
/lock
/uploads
/vease_data
geodeapp_back.spec
geodeapp_viewer.spec
2 changes: 1 addition & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url("https://fonts.googleapis.com/css2?family=Michroma&display=swap");
@import "@fontsource/michroma";

* {
font-family: "Roboto", sans-serif;
Expand Down
10 changes: 4 additions & 6 deletions components/ImportFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</template>

<script setup>
import schemas from "@geode/opengeodeweb-viewer/schemas.json";
import schema from "@geode/opengeodeweb-back/schemas.json";
import viewer_schemas from "@geode/opengeodeweb-viewer/schemas.json";
import back_schemas from "@geode/opengeodeweb-back/schemas.json";
const emit = defineEmits(["update_values", "increment_step", "decrement_step"]);
Expand All @@ -25,20 +25,19 @@ const loading = ref(false);
const toggle_loading = useToggle(loading);
async function import_files() {
toggle_loading();
for (const filename of filenames) {
const params = {
input_geode_object,
filename,
};
await api_fetch(
{ schema: schema.opengeodeweb_back.save_viewable_file, params },
{ schema: back_schemas.opengeodeweb_back.save_viewable_file, params },
{
requestErrorFunction: () => {},
response_function: async (response) => {
await viewer_call({
schema: schemas.opengeodeweb_viewer.create_object_pipeline,
schema: viewer_schemas.opengeodeweb_viewer.create_object_pipeline,
params: {
id: response._data.id,
file_name: response._data.viewable_file_name,
Expand All @@ -48,6 +47,5 @@ async function import_files() {
}
);
}
toggle_loading();
}
</script>
1 change: 0 additions & 1 deletion electron-server/install_viewer.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Remove-Item -Recurse -Force /electron-server/venv_viewer/ -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force /electron-server/dist_viewer/ -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force /electron-server/build/ -ErrorAction:SilentlyContinue

$folder="electron-server/venv_viewer"
python -m venv $folder

Expand Down
2 changes: 1 addition & 1 deletion electron-server/requirements_viewer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --pre electron-server/requirements_viewer.in
# pip-compile electron-server/requirements_viewer.in
#
aiohttp==3.9.3
# via
Expand Down
31 changes: 29 additions & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ updateElectronApp();

process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";

const data_folder_path = "./vease_data/";

async function getAvailablePort(port) {
const available_port = await getPort({ port });
console.log("available_port", available_port);
Expand Down Expand Up @@ -89,6 +91,23 @@ app.whenReady().then(() => {
win.maximize();
win.setMinimumSize(800, 600);

win.webContents.session.webRequest.onBeforeSendHeaders(
(details, callback) => {
callback({ requestHeaders: { Origin: "*", ...details.requestHeaders } });
}
);

win.webContents.session.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
"Access-Control-Allow-Origin": ["*"],
// We use this to bypass headers
"Access-Control-Allow-Headers": ["*"],
...details.responseHeaders,
},
});
});

ipcMain.handle("run_back", async (event, ...args) => {
const port = await getAvailablePort(args[0]);
console.log("BACK PORT", port);
Expand All @@ -101,7 +120,13 @@ app.whenReady().then(() => {
await run_script(
win,
command,
["--port " + port, "--data_folder_path " + "./uploads"],
[
"--port " + port,
"--data_folder_path " + data_folder_path,
"--desktop",
"--allowed_origin ",
process.env.VITE_DEV_SERVER_URL,
],
"Serving Flask app"
);
return port;
Expand All @@ -119,14 +144,16 @@ app.whenReady().then(() => {
await run_script(
win,
command,
["--port " + port, "--data_folder_path " + "./uploads"],
["--port " + port, "--data_folder_path " + data_folder_path],
"Starting factory"
);
return port;
});
if (app.isPackaged) {
console.log("process.resourcesPath", process.resourcesPath);
win.loadFile(process.resourcesPath + "/index.html");
} else {
console.log("VITE_DEV_SERVER_URL", process.env.VITE_DEV_SERVER_URL);
win.loadURL(process.env.VITE_DEV_SERVER_URL);
win.webContents.openDevTools();
}
Expand Down
3 changes: 2 additions & 1 deletion forge.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ module.exports = {
"./.output/public/.",
"./dist-electron",
"//GEODEAPP_BACK",
"//GEODEAPP_VIEWER"
"//GEODEAPP_VIEWER",
],
ignore: ["./node_modules"],
},
rebuildConfig: {},

Expand Down
13 changes: 12 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default defineNuxtConfig({
},
},
],
disableDefaultOptions: true,
},

ssr: false,
Expand All @@ -45,6 +46,7 @@ export default defineNuxtConfig({
],
link: [{ rel: "icon", type: "image/ico", href: "/favicon.ico" }],
},
baseURL: "./",
},

imports: {
Expand All @@ -71,7 +73,16 @@ export default defineNuxtConfig({
optimizeDeps: {
include: ["@geode/opengeodeweb-front"],
},
watch: {
ignored: ["**"],
},
},

router: {
options: {
hashMode: true,
},
},

compatibilityDate: "2024-07-18",
compatibilityDate: "2024-06-30",
});
Loading

0 comments on commit b42b3bc

Please sign in to comment.