about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore2
-rw-r--r--10.csv10
-rw-r--r--Dockerfile19
-rw-r--r--createsTables.sh7
-rwxr-xr-xdb-controllerbin0 -> 7955421 bytes
-rw-r--r--frontend/index.html22
-rwxr-xr-xtestInsertStarSingle.sh89
7 files changed, 114 insertions, 35 deletions
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
--- /dev/null
+++ b/db-controller
Binary files differdiff --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 @@
     <title>Galaxy Simulator</title>
 
     <!-- Bootstrap core CSS -->
-    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
+    <link href="css/bootstrap.min.css" rel="stylesheet">
 
     <!-- Custom styles for this template -->
     <link href="css/small-business.css" rel="stylesheet">
@@ -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 @@
         <div class="col-md-3 mb-4">
             <div class="bg-dark card h-100">
                 <div class="card-body">
-                    <form action="http://localhost:8081/newTree" method="post" id="insertform">
+                    <form action="http://localhost:8080/newTree" method="post" id="insertform">
                         <h2 class="card-title text-light">New tree</h2>
                         <p class="card-text text-light">Create a new tree</p>
 
@@ -220,7 +220,7 @@
         <div class="col-md-3 mb-4">
             <div class="bg-dark card h-100">
                 <div class="card-body">
-                    <form action="http://localhost:8081/insertStar" method="post" id="insertform">
+                    <form action="http://localhost:8080/insertStar" method="post" id="insertform">
                         <h2 class="card-title text-light">Insert star</h2>
                         <p class="card-text text-light">Insert a single star into the tree</p>
 
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"