From 98ea6d0a94df342d5de3908df33601db7d6b31c2 Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 24 Mar 2019 14:51:29 +0100 Subject: committing untracked files --- .dockerignore | 2 ++ 10.csv | 10 ++++++ Dockerfile | 19 +++++++++++ createsTables.sh | 7 ++++ db-controller | Bin 0 -> 7955421 bytes frontend/index.html | 22 ++++++------ testInsertStarSingle.sh | 89 +++++++++++++++++++++++++++++++++++------------- 7 files changed, 114 insertions(+), 35 deletions(-) create mode 100644 .dockerignore create mode 100644 10.csv create mode 100644 Dockerfile create mode 100644 createsTables.sh create mode 100755 db-controller diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6db3394 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +go.mod +go.sum diff --git a/10.csv b/10.csv new file mode 100644 index 0000000..b2f1001 --- /dev/null +++ b/10.csv @@ -0,0 +1,10 @@ +8554945.051044,-4025399.880927,-7935760.860023 +3570615.513709,12127411.988239,4285439.764773 +-13566543.127857,-3003308.409342,-14792160.206778 +-9141184.373600,1781449.163816,1956837.877827 +7474166.997725,2520600.577583,-6712829.509149 +3700185.099210,10644548.404023,-12958298.492648 +8614191.662040,-3746585.482830,7526576.501262 +-1267947.608359,604271.841259,2541142.003207 +6929459.281344,-1079036.966713,-11817673.347549 +-14942166.360869,-10253775.555899,-5714109.182897 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8b5e53b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:latest + +# Copy the source files into the container +COPY . . +COPY frontend/ frontend/ +COPY backend/ frontend/ + +# Get dependencies +RUN ["go", "get", "git.darknebu.la/GalaxySimulator/structs"] +#RUN ["go", "get", "git.darknebu.la/GalaxySimulator/db-controller/frontend"] +RUN ["go", "get", "git.darknebu.la/GalaxySimulator/db-controller/backend"] +RUN ["go", "get", "github.com/gorilla/mux"] +RUN ["go", "get", "github.com/lib/pq"] + +# build an executable +RUN ["go", "build", "-o", "db-controller", "."] + +# Start the webserver +ENTRYPOINT ["./db-controller"] diff --git a/createsTables.sh b/createsTables.sh new file mode 100644 index 0000000..0f20c7b --- /dev/null +++ b/createsTables.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +echo "Recreating the tables..." +curl -X POST http://localhost:8080/createNodesTable +curl -X POST http://localhost:8080/createStarsTable + + diff --git a/db-controller b/db-controller new file mode 100755 index 0000000..69a2bc4 Binary files /dev/null and b/db-controller differ diff --git a/frontend/index.html b/frontend/index.html index 741f2fc..e4fdece 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -11,7 +11,7 @@ Galaxy Simulator - + @@ -20,7 +20,7 @@ function newTree() { var w = document.getElementById("w").value; - var url = "http://localhost:8081/newTree"; + var url = "http://localhost:8080/newTree"; var params = "w=" + w; console.log(params) var xhr = new XMLHttpRequest(); @@ -29,7 +29,7 @@ xhr.send(params); } function deleteAllStars() { - var url = "http://localhost:8081/deleteStars"; + var url = "http://localhost:8080/deleteStars"; var params = ""; var xhr = new XMLHttpRequest(); xhr.open("POST", url, true); @@ -37,7 +37,7 @@ xhr.send(params); } function deleteAllNodes() { - var url = "http://localhost:8081/deleteNodes"; + var url = "http://localhost:8080/deleteNodes"; var params = ""; var xhr = new XMLHttpRequest(); xhr.open("POST", url, true); @@ -45,7 +45,7 @@ xhr.send(params); } function updateTotalMass() { - var url = "http://localhost:8081/updateTotalMass"; + var url = "http://localhost:8080/updateTotalMass"; var params = "index=1"; var xhr = new XMLHttpRequest(); xhr.open("POST", url, true); @@ -53,7 +53,7 @@ xhr.send(params); } function updateCenterOfMass() { - var url = "http://localhost:8081/updateCenterOfMass"; + var url = "http://localhost:8080/updateCenterOfMass"; var params = "index=1"; var xhr = new XMLHttpRequest(); xhr.open("POST", url, true); @@ -61,7 +61,7 @@ xhr.send(params); } function generateForest() { - var url = "http://localhost:8081/genForestTree"; + var url = "http://localhost:8080/genForestTree"; var params = ""; var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); @@ -76,7 +76,7 @@ var m = document.getElementById("m").value; var index = document.getElementById("index").value; - var url = "http://localhost:8081/insertStar"; + var url = "http://localhost:8080/insertStar"; var params = "x=" + x + "&y=" + y + "&vx=" + vx + "&vy=" + vy + "&m=" + m + "&index=" + index; console.log(params) var xhr = new XMLHttpRequest(); @@ -85,7 +85,7 @@ xhr.send(params); } function insertList() { - var url = "http://localhost:8081/insertList"; + var url = "http://localhost:8080/insertList"; var params = ""; var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); @@ -129,7 +129,7 @@
-
+

New tree

Create a new tree

@@ -220,7 +220,7 @@
- +

Insert star

Insert a single star into the tree

diff --git a/testInsertStarSingle.sh b/testInsertStarSingle.sh index 36c94a2..57f1377 100755 --- a/testInsertStarSingle.sh +++ b/testInsertStarSingle.sh @@ -1,26 +1,67 @@ #!/usr/bin/env bash -echo "Recreating the tables..." -curl -X POST http://localhost:8081/createNodesTable -curl -X POST http://localhost:8081/createStarsTable -echo "Done" - -echo "Deleting preexisting tables..." -curl -X POST http://localhost:8081/deleteStars -curl -X POST http://localhost:8081/deleteNodes -echo "Done" - -echo "Inserting all stars from teststars.csv..." -curl -X POST --data "filename=100" http://localhost:8081/insertStarList -echo "Done" - -echo "Inserting a list of stars..." -echo "Done" - -echo "Getting the forest representation of the tree..." -curl -X GET http://localhost:8081/genForestTree?index=1 -echo "Done" - -echo "Getting a list of all stars..." -curl -X GET http://localhost:8081/starslist/csv -echo "Done" +################################################################################ +# init +################################################################################ + +# create tables +printf "Recreating the tables... " +curl -X POST http://db-controller.docker.localhost/createNodesTable +curl -X POST http://db-controller.docker.localhost/createStarsTable +printf "Done " +read -n 1 -s -r -p "Press any key to continue (delete preexisting tables)" + +# delete preexisting table entries +printf "\nDeleting preexisting tables... " +curl -X POST http://db-controller.docker.localhost/deleteStars +curl -X POST http://db-controller.docker.localhost/deleteNodes +printf "Done " +read -n 1 -s -r -p "Press any key to continue (create a new tree)" + +# create a new tree +printf "\nCreating a new tree... " +curl -X POST --data "w=100000000000" http://db-controller.docker.localhost/newTree +printf "Done " +read -n 1 -s -r -p "Press any key to continue (insert stars from 10.csv)" + +################################################################################ +# insert +################################################################################ + +# insert all stars from csv +printf "\nInserting all stars from 10.csv..." +curl -X POST --data "filename=10" http://db-controller.docker.localhost/insertStarList +printf "Done " +read -n 1 -s -r -p "Press any key to continue (update total mass) " + +################################################################################ +# update +################################################################################ + +printf "\nInserting all stars from 10.csv..." +curl -X POST --data "index=1" http://db-controller.docker.localhost/updateTotalMass +printf "Done " +read -n 1 -s -r -p "Press any key to continue (update center of mass) " + +printf "\nInserting all stars from 10.csv..." +curl -X POST --data "index=1" http://db-controller.docker.localhost/updateCenterOfMass +printf "Done " +read -n 1 -s -r -p "Press any key to continue (forest representation) " + +################################################################################ +# forest +################################################################################ + +printf "\nGetting the forest representation of the tree..." +curl -X GET http://db-controller.docker.localhost/genForestTree?index=1 +printf "Done " +read -n 1 -s -r -p "Press any key to continue (get a list of all stars)" + +################################################################################ +# list of stars +################################################################################ + +printf "\nGetting a list of all stars... " +curl -X GET http://db-controller.docker.localhost/starslist/csv +printf "Done " +read -n 1 -s -r -p "Press any key to continue" -- cgit 1.4.1