about summary refs log tree commit diff
path: root/frontend/index.html
blob: e4fdece40b4dc5810050a94c3b10ddf9a3c32147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Galaxy Simulator</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/small-business.css" rel="stylesheet">

    <script>
        function newTree() {
            var w = document.getElementById("w").value;

            var url = "http://localhost:8080/newTree";
            var params = "w=" + w;
            console.log(params)
            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function deleteAllStars() {
            var url = "http://localhost:8080/deleteStars";
            var params = "";
            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function deleteAllNodes() {
            var url = "http://localhost:8080/deleteNodes";
            var params = "";
            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function updateTotalMass() {
            var url = "http://localhost:8080/updateTotalMass";
            var params = "index=1";
            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function updateCenterOfMass() {
            var url = "http://localhost:8080/updateCenterOfMass";
            var params = "index=1";
            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function generateForest() {
            var url = "http://localhost:8080/genForestTree";
            var params = "";
            var xhr = new XMLHttpRequest();
            xhr.open("GET", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function insertStar() {
            var x = document.getElementById("x").value;
            var y = document.getElementById("y").value;
            var vx = document.getElementById("vx").value;
            var vy = document.getElementById("vy").value;
            var m = document.getElementById("m").value;
            var index = document.getElementById("index").value;

            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();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
        function insertList() {
            var url = "http://localhost:8080/insertList";
            var params = "";
            var xhr = new XMLHttpRequest();
            xhr.open("GET", url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
    </script>

</head>

<body class="bg-secondary">

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
        <a class="navbar-brand" href="#">Galaxy Simulator</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">

                <li class="nav-item active">
                    <a class="nav-link" href="#">Home
                        <span class="sr-only">(current)</span>
                    </a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<br>

<!-- Page Content -->
<div class="container-fluid">

    <!-- content row -->
    <div class="row">

        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <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>

                        <div class="row">
                            <div class="col">
                                <input type="text" class="form-control" name="w" id="w" placeholder="w">
                            </div>
                        </div>
                    </form>

                </div>

                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="newTree()">Insert star</button>
                </div>

            </div>
        </div>

        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <h2 class="card-title text-light">Delete all stars</h2>
                    <p class="card-text text-light">Delete all the stars in the stars table</p>
                </div>
                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="deleteAllStars()">Delete all stars</button>
                </div>
            </div>
        </div>

        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <h2 class="card-title text-light">Delete all nodes</h2>
                    <p class="card-text text-light">Delete all the nodes in the nodes table</p>
                </div>
                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="deleteAllNodes()">Delete all nodes</button>
                </div>
            </div>
        </div>


        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <h2 class="card-title text-light">Update total mass</h2>
                    <p class="card-text text-light">Update the total mass of all the nodes in the tree</p>
                </div>
                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="updateTotalMass()">Update total mass</button>
                </div>
            </div>
        </div>

    </div>
    <!-- /.row -->

    <!-- content row -->
    <div class="row">

        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <h2 class="card-title text-light">Update center of mass</h2>
                    <p class="card-text text-light">Update the center of mass of all nodes in the tree</p>
                </div>
                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="updateCenterOfMass()">Update center of mass</button>
                </div>
            </div>
        </div>

        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <h2 class="card-title text-light">Generate Forest Tree</h2>
                    <p class="card-text text-light">Generate a representation of the tree in LaTeX forest syntax</p>
                </div>
                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="generateForest()">Generate Forest</button>
                </div>
            </div>
        </div>


        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <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>

                        <div class="row">
                            <div class="col">
                                <input type="text" class="form-control" name="x" id="x" placeholder="x">
                            </div>
                            <div class="col">
                                <input type="text" class="form-control" name="y" id="y" placeholder="y">
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <div class="col">
                                <input type="text" class="form-control" name="vx" id="vx" placeholder="vx">
                            </div>
                            <div class="col">
                                <input type="text" class="form-control" name="vy" id="vy" placeholder="vy">
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <div class="col">
                                <input type="text" class="form-control" name="m" id="m" placeholder="m">
                            </div>
                            <div class="col">
                                <input type="text" class="form-control" name="index" id="index" placeholder="index">
                            </div>
                        </div>
                    </form>

                </div>

                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="insertStar()">Insert star</button>
                </div>

            </div>
        </div>

        <div class="col-md-3 mb-4">
            <div class="bg-dark card h-100">
                <div class="card-body">
                    <h2 class="card-title text-light">Insert list of stars</h2>
                    <p class="card-text text-light">Select a .csv to insert into the tree</p>

                    <div class="form-group mh-100">
                        <select multiple class="form-control mh-100" id="exampleFormControlSelect2">
                            <option>1</option>
                            <option>2</option>
                            <option>3</option>
                            <option>4</option>
                            <option>5</option>
                        </select>
                    </div>

                </div>
                <div class="card-footer">
                    <button class="btn btn-primary" formmethod="post" type="button" onclick="insertList()">Insert list</button>
                </div>
            </div>
        </div>

    </div>

    <!-- content row -->
    <div class="row">


    </div>

</div>
<!-- /.container -->

<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>

</html>