|
5 | 5 | <div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
|
6 | 6 | <!-- Nodes start -->
|
7 | 7 | <?php
|
8 |
| - $nodes = \webinterface\main::buildDefaultRequest("cluster", "GET"); |
9 | 8 |
|
| 9 | + use webinterface\main; |
10 | 10 |
|
11 |
| - foreach ($nodes['nodes'] as $node) { ?> |
| 11 | + $nodes = main::buildDefaultRequest("cluster", "GET"); |
| 12 | + |
| 13 | + |
| 14 | + foreach ($nodes as $node) { ?> |
12 | 15 |
|
13 | 16 | <div class="min-w-0 p-4 dark:bg-gray-800 bg-white rounded-lg shadow-lg border-t-4 border-green-600">
|
14 | 17 | <div class="flex items-center justify-between">
|
15 | 18 | <h4 class="mb-4 font-semibold text-blue-500"><?= $node['node']['uniqueId']; ?></h4>
|
16 | 19 | <!-- State Starting: bg-yellow-600 // State Stop: bg-red-600 -->
|
17 |
| - <?php if($node['available'] == true){ ?> |
| 20 | + <?php if (count($node['node']["listeners"]) != 0) { ?> |
18 | 21 | <span class="text-sm text-center text-white h-6 w-16 bg-green-600 rounded-full">Online</span>
|
19 | 22 | <?php } else { ?>
|
20 | 23 | <span class="text-sm text-center text-white h-6 w-16 bg-red-600 rounded-full">Offline</span>
|
21 | 24 | <?php } ?>
|
22 | 25 | </div>
|
23 | 26 | <div class="flex">
|
24 | 27 | <span class="text-gray-400">•</span>
|
25 |
| - <p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Memory Usage: <?= $node['nodeInfoSnapshot']['usedMemory']; ?>MB/<?= $node['nodeInfoSnapshot']['maxMemory']; ?>MB<br></p> |
| 28 | + <p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Memory |
| 29 | + Usage: <?= $node['nodeInfoSnapshot']['usedMemory']; ?> |
| 30 | + MB/<?= $node['nodeInfoSnapshot']['maxMemory']; ?>MB<br></p> |
26 | 31 | </div>
|
27 | 32 | <div class="flex">
|
28 | 33 | <span class="text-gray-400">•</span>
|
29 |
| - <p class="flex-1 dark:text-white text-gray-900 items-center pl-2">CPU Usage: <?= min(round($node['nodeInfoSnapshot']['processSnapshot']['cpuUsage'] * 100), 100); ?>%<br></p> |
| 34 | + <p class="flex-1 dark:text-white text-gray-900 items-center pl-2">CPU |
| 35 | + Usage: <?= min(round($node['nodeInfoSnapshot']['processSnapshot']['cpuUsage'] * 100), 100); ?> |
| 36 | + %<br></p> |
30 | 37 | </div>
|
31 | 38 | <div class="flex">
|
32 | 39 | <span class="text-gray-400">•</span>
|
33 |
| - <p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Version: <?= $node['nodeInfoSnapshot']['version'] ?><br></p> |
| 40 | + <p class="flex-1 dark:text-white text-gray-900 items-center pl-2"> |
| 41 | + Version: <?= $node['nodeInfoSnapshot']['version'] ?><br></p> |
34 | 42 | </div>
|
35 | 43 | <div class="flex">
|
36 | 44 | <span class="text-gray-400">•</span>
|
37 |
| - <p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Host: <?= $node['node']['listeners'][0]['host'].":".$node['node']['listeners'][0]['port']; ?> <br></p> |
| 45 | + <p class="flex-1 dark:text-white text-gray-900 items-center pl-2"> |
| 46 | + Host: <?= $node['node']['listeners'][0]['host'] . ":" . $node['node']['listeners'][0]['port']; ?> |
| 47 | + <br></p> |
38 | 48 | </div>
|
39 | 49 | <div class="flex justify-center mt-4 space-x-3 text-sm text-white">
|
40 | 50 | <div class="flex items-center">
|
|
43 | 53 | <input name="node_id" value="<?= $node['node']['uniqueId']; ?>" type="hidden">
|
44 | 54 | <input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
|
45 | 55 |
|
46 |
| - <button type="submit" class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 focus:outline-none focus:shadow-outline">Shutdown</button> |
| 56 | + <button type="submit" |
| 57 | + class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 focus:outline-none focus:shadow-outline"> |
| 58 | + Shutdown |
| 59 | + </button> |
47 | 60 | </form>
|
48 |
| - <form method="post"> |
49 |
| - <input name="action" value="deleteNode" type="hidden"> |
50 |
| - <input name="node_id" value="<?= $node['node']['uniqueId']; ?>" type="hidden"> |
51 |
| - <input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden"> |
| 61 | + <?php if (count($nodes) > 1) { ?> |
| 62 | + <form method="post"> |
| 63 | + <input name="action" value="deleteNode" type="hidden"> |
| 64 | + <input name="node_id" value="<?= $node['node']['uniqueId']; ?>" |
| 65 | + type="hidden"> |
| 66 | + <input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden"> |
52 | 67 |
|
53 |
| - <button type="submit" class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 focus:outline-none focus:shadow-outline">Delete</button> |
54 |
| - </form> |
| 68 | + <button type="submit" |
| 69 | + class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 focus:outline-none focus:shadow-outline"> |
| 70 | + Delete |
| 71 | + </button> |
| 72 | + </form> |
| 73 | + <?php } ?> |
55 | 74 | </div>
|
56 | 75 | </div>
|
57 | 76 | </div>
|
|
78 | 97 |
|
79 | 98 | <div class="flex-1 flex flex-col md:flex-row text-sm font-mono subpixel-antialiased">
|
80 | 99 | <div class="w-full flex-1 mx-2">
|
81 |
| - <input placeholder="Name" name="name" required class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 border-gray-100 rounded px-2 appearance-none outline-none w-full dark:text-white text-gray-900 focus:ring-2 focus:ring-blue-600"> |
| 100 | + <input placeholder="Name" name="name" required |
| 101 | + class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 border-gray-100 rounded px-2 appearance-none outline-none w-full dark:text-white text-gray-900 focus:ring-2 focus:ring-blue-600"> |
82 | 102 | </div>
|
83 | 103 | <div class="w-full flex-1 mx-2">
|
84 |
| - <input placeholder="Host" name="host" required class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 border-gray-100 rounded px-2 appearance-none outline-none w-full dark:text-white text-gray-900 focus:ring-2 focus:ring-blue-600"> |
| 104 | + <input placeholder="Host" name="host" required |
| 105 | + class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 border-gray-100 rounded px-2 appearance-none outline-none w-full dark:text-white text-gray-900 focus:ring-2 focus:ring-blue-600"> |
85 | 106 | </div>
|
86 | 107 | <div class="w-full flex-1 mx-2">
|
87 |
| - <input placeholder="Port" name="port" required class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 border-gray-100 rounded px-2 appearance-none outline-none w-full dark:text-white text-gray-900 focus:ring-2 focus:ring-blue-600"> |
| 108 | + <input placeholder="Port" name="port" required |
| 109 | + class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 border-gray-100 rounded px-2 appearance-none outline-none w-full dark:text-white text-gray-900 focus:ring-2 focus:ring-blue-600"> |
88 | 110 | </div>
|
89 | 111 | </div>
|
90 |
| - <button type="submit" class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 focus:outline-none focus:shadow-outline">Create</button> |
| 112 | + <button type="submit" |
| 113 | + class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 focus:outline-none focus:shadow-outline"> |
| 114 | + Create |
| 115 | + </button> |
91 | 116 | </form>
|
92 | 117 | </div>
|
93 | 118 | </div>
|
|
0 commit comments