Run project with docker compose
[asis23-votoe-client.git] / index.php
blob4f258974033af2606aa885ac4043654da91ed1d5
1 <?php
2 /**
3 * Helper to get a value from an array.
5 * @param array $haystack
6 * @param mixed $needle
7 * @param mixed $default
8 */
9 function array_get($haystack, $needle, $default = null) {
10 return isset($haystack[$needle])
11 ? $haystack[$needle]
12 : $default;
15 // Override environment variables array
16 $_ENV = getenv();
17 ?><!doctype html>
18 <html lang="en">
19 <head>
20 <meta charset="utf-8">
21 <title>VOTE REST API Client</title>
22 <link rel="stylesheet" href="styles/normalize.css"/>
23 <link rel="stylesheet" href="styles/main.css"/>
24 <link rel="stylesheet" href="styles/menu.css"/>
25 <link rel="stylesheet" href="styles/admin.css"/>
26 <link rel="stylesheet" href="styles/vote.css"/>
27 <link rel="stylesheet" href="styles/report.css"/>
28 </head>
29 <body>
30 <div id="menu">
31 <button>Admin</button>
32 <button>Vote</button>
33 <button>Report</button>
34 </div>
35 <hr/>
36 <div id="admin">
37 <ul>
38 <li>Name1 <button>Delete</button></li>
39 <li>Name2 <button>Delete</button></li>
40 <li>Name3 <button>Delete</button></li>
41 </ul>
42 <form action="" method="dialog">
43 <label>New:</label>
44 <input type="text" />
45 <input type="submit" value="Add" />
46 </form>
47 </div>
48 <div id="vote">
49 <ul>
50 <li><button>Name 1</button></li>
51 <li><button>Name 2</button></li>
52 <li><button>Name 3</button></li>
53 </ul>
54 </div>
55 <div id="report">
56 <table>
57 <thead>
58 <tr>
59 <th>Candidate</th>
60 <th>Votes</th>
61 </tr>
62 </thead>
63 <tbody>
64 <tr>
65 <td>Name 1</td>
66 <td>00</td>
67 </tr>
68 <tr>
69 <td>Name 2</td>
70 <td>00</td>
71 </tr>
72 <tr>
73 <td>Name 3</td>
74 <td>00</td>
75 </tr>
76 </tbody>
77 </table>
78 </div>
79 </body>
80 <script src="scripts/rest-api.js"></script>
81 <script src="scripts/menu.js"></script>
82 <script src="scripts/admin.js"></script>
83 <script src="scripts/vote.js"></script>
84 <script src="scripts/report.js"></script>
85 <script src="scripts/main.js"></script>
86 <script>
87 const config = (() => {
88 return {
89 restapi : {
90 host: '<?php echo array_get($_ENV, 'RESTAPI_HOST', '') ?>',
91 port: '<?php echo array_get($_ENV, 'RESTAPI_PORT', '') ?>',
94 })();
95 </script>
96 </html>