Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit ad67f6a

Browse files
author
Optischa
committed
Fix login and more
1 parent ab4ad0e commit ad67f6a

File tree

14 files changed

+392
-253
lines changed

14 files changed

+392
-253
lines changed

INSTALL.md

+36-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## Requirement
1010

11-
- CloudNet 3.5 and the Rest-Module
11+
- CloudNet 3.x and the Rest-Module
1212

1313
- Webserver (or Webspace)
1414
- PHP 8
@@ -21,10 +21,13 @@ You can download the latest version from https://project.the-systems.eu/resource
2121

2222
## Installation
2323

24-
1. Load the files into your Webserve
25-
2. Copy the file config/config-sample.php to config/config.php
26-
3. run the command "composer install" (If this doesn't work, go to "Install Composer")
27-
4. Setup the Webserver
24+
1. Delete the ```cloudnet-rest.jar in CloudNet``` Modul folder
25+
2. Download the modified cloudnet-rest module
26+
3. Restart CloudNet
27+
4. Load the files into your Webserve
28+
5. Copy the file config/config-sample.php to config/config.php
29+
6. run the command "composer install" (If this doesn't work, go to "Install Composer")
30+
7. Setup the Webserver
2831

2932
Info: The web interface also works on an external Webspace!
3033

@@ -103,10 +106,13 @@ Du kannst die aktuelle Version von https://project.the-systems.eu/resources/clou
103106

104107
## Installation
105108

106-
1. Lade die Dateien auf deinen Webserver
107-
2. Kopiere die config/config-sample.php in config/config.php und stelle diese ein
108-
3. Führe "composer install" aus (Sollte das nicht funktionieren, befolge "Composer installieren")
109-
4. Richte den Webserver ein
109+
1. Lösche das ```cloudnet-rest.jar``` Modul
110+
2. Lade dir das modifizierte cloudnet-rest Moodul herrunter
111+
3. CloudNet Neustarten
112+
4. Lade die Dateien auf deinen Webserver
113+
5. Kopiere die config/config-sample.php in config/config.php und stelle diese ein
114+
6. Führe "composer install" aus (Sollte das nicht funktionieren, befolge "Composer installieren")
115+
7. Richte den Webserver ein
110116

111117
Info: Das Webinterface funktioniert ebenfalls auf einem Externen Webserver/Webspace!
112118

@@ -149,3 +155,24 @@ Info: Das Webinterface funktioniert ebenfalls auf einem Externen Webserver/Websp
149155
curl -sS https://getcomposer.org/installer | php
150156
php composer.phar install --no-dev -o
151157

158+
## Docker
159+
160+
For the docker setup you just need to have `docker` and `git` installed.
161+
162+
## Clone the repository
163+
``git clone https://github.com/The-Systems/CloudNet3-WebInterface.git``
164+
165+
## Build the docker image
166+
167+
``docker build -t cloudnet-webinterface .``
168+
169+
## Run the image
170+
171+
The interface will run on port 8080 on the host.
172+
173+
```bash
174+
docker run -d --name cloudnet-webinterface \
175+
--port 8080:80 \
176+
cloudnet-webinterface
177+
```
178+

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
# <b>CloudNet3-Webinterface</b>
88

9-
### A Webinterface for CloudNet 3.5+
9+
### A Webinterface for CloudNet 3.x
1010

11-
## IMPORTANT: WEBINTERFACE IS NOT STABLE! IT IS STILL IN ALPHA. ONLY FOR CLOUDNET 3.5!
11+
## IMPORTANT: WEBINTERFACE IS NOT STABLE!
1212

1313
### <span style="color: red">The web interface is not compatible with CloudNet v2!</span>
1414

@@ -28,7 +28,7 @@
2828

2929
## License
3030

31-
Copyright 2021 TheSystems
31+
Copyright 2022 TheSystems
3232

3333
Licensed under the Apache License, Version 2.0 (the "License");
3434
you may not use this file except in compliance with the License.

config/config-sample.php

-26
This file was deleted.

config/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
$version = array(
3-
"version" => "1.0_alpha1",
3+
"version" => "1.0_alpha2",
44
"version_url" => "https://project.the-systems.eu/api/resource/?resourceid=14&type=allinfos"
55
);

pages/header.php

+59-93
Large diffs are not rendered by default.

pages/webinterface/cluster/index.php

+43-18
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,46 @@
55
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
66
<!-- Nodes start -->
77
<?php
8-
$nodes = \webinterface\main::buildDefaultRequest("cluster", "GET");
98

9+
use webinterface\main;
1010

11-
foreach ($nodes['nodes'] as $node) { ?>
11+
$nodes = main::buildDefaultRequest("cluster", "GET");
12+
13+
14+
foreach ($nodes as $node) { ?>
1215

1316
<div class="min-w-0 p-4 dark:bg-gray-800 bg-white rounded-lg shadow-lg border-t-4 border-green-600">
1417
<div class="flex items-center justify-between">
1518
<h4 class="mb-4 font-semibold text-blue-500"><?= $node['node']['uniqueId']; ?></h4>
1619
<!-- State Starting: bg-yellow-600 // State Stop: bg-red-600 -->
17-
<?php if($node['available'] == true){ ?>
20+
<?php if (count($node['node']["listeners"]) != 0) { ?>
1821
<span class="text-sm text-center text-white h-6 w-16 bg-green-600 rounded-full">Online</span>
1922
<?php } else { ?>
2023
<span class="text-sm text-center text-white h-6 w-16 bg-red-600 rounded-full">Offline</span>
2124
<?php } ?>
2225
</div>
2326
<div class="flex">
2427
<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>
2631
</div>
2732
<div class="flex">
2833
<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>
3037
</div>
3138
<div class="flex">
3239
<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>
3442
</div>
3543
<div class="flex">
3644
<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>
3848
</div>
3949
<div class="flex justify-center mt-4 space-x-3 text-sm text-white">
4050
<div class="flex items-center">
@@ -43,15 +53,24 @@
4353
<input name="node_id" value="<?= $node['node']['uniqueId']; ?>" type="hidden">
4454
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
4555

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>
4760
</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">
5267

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 } ?>
5574
</div>
5675
</div>
5776
</div>
@@ -78,16 +97,22 @@
7897

7998
<div class="flex-1 flex flex-col md:flex-row text-sm font-mono subpixel-antialiased">
8099
<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">
82102
</div>
83103
<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">
85106
</div>
86107
<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">
88110
</div>
89111
</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>
91116
</form>
92117
</div>
93118
</div>

pages/webinterface/dashboard.php

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<?php
2+
23
use webinterface\main;
34

45
$nodes = main::buildDefaultRequest("cluster", "GET");
56

67
$services = 0;
78

89
$connectedNodeCount = 0;
9-
$totalNodeCount = sizeof($nodes['nodes']);
10+
$totalNodeCount = 0;
11+
if (isset($nodes['nodes'])) {
12+
$totalNodeCount = sizeof($nodes['nodes']);
13+
}
1014

1115
$memory_min = 0;
1216
$memory_max = 0;
1317

1418
$cpu_used = 0;
1519
$cpu_max = 0;
1620

17-
foreach ($nodes['nodes'] as $node) {
18-
if ($node['available'] === false) {
19-
continue;
20-
}
21+
foreach ($nodes as $node) {
2122

2223
$connectedNodeCount++;
2324

@@ -42,8 +43,8 @@
4243
<img src="assets/icons/cluster.png"/>
4344
</div>
4445
<div>
45-
<p class="mb-2 text-base font-medium text-gray-400">Connected nodes</p>
46-
<p class="text-xl font-semibold dark:text-white text-gray-900"><?= $connectedNodeCount ?>/<?= $totalNodeCount ?></p>
46+
<p class="mb-2 text-base font-medium text-gray-400">Nodes</p>
47+
<p class="text-xl font-semibold dark:text-white text-gray-900"><?= $connectedNodeCount ?>
4748
</div>
4849
</div>
4950
<!-- Servers -->
@@ -63,7 +64,8 @@
6364
</div>
6465
<div>
6566
<p class="mb-2 text-base font-medium text-gray-400">CPU</p>
66-
<p class="text-xl font-semibold dark:text-white text-gray-900"><?= $cpu_used ?>%/<?= $cpu_max; ?>%</p>
67+
<p class="text-xl font-semibold dark:text-white text-gray-900"><?= $cpu_used ?>
68+
%/<?= $cpu_max; ?>%</p>
6769
</div>
6870
</div>
6971
<!-- Ram -->
@@ -149,19 +151,19 @@
149151
</div>
150152
<!-- Status -->
151153
<?php $version = main::testIfLatestVersion(); ?>
152-
<?php if(!$version['success']){ ?>
153-
<div class="min-w-0 p-4 text-white bg-gradient-to-br from-red-600 to-red-800 rounded-lg shadow-xs">
154-
<h4 class="mb-4 font-bold">Warning!</h4>
155-
<p>
156-
<?php if($version['response']['error_code'] == 202){ ?>
157-
Currently you are using an outdated Webinterface version (<?= $version['response']['error_extra']['current'] ?>), to keep the Webinterface up to
158-
date and
159-
to get support, update to the latest version (<?= $version['response']['error_extra']['latest'] ?>).
160-
<?php } else if($version['response']['error_code'] == 503){ ?>
161-
The TheSystems control server is currently unavailable.
162-
<?php } ?>
163-
</p>
164-
</div>
154+
<?php if (!$version['success']) { ?>
155+
<div class="min-w-0 p-4 text-white bg-gradient-to-br from-red-600 to-red-800 rounded-lg shadow-xs">
156+
<h4 class="mb-4 font-bold">Warning!</h4>
157+
<p>
158+
<?php if ($version['response']['error_code'] == 202) { ?>
159+
Currently you are using an outdated Webinterface version (<?= $version['response']['error_extra']['current'] ?>), to keep the Webinterface up to
160+
date and
161+
to get support, update to the latest version (<?= $version['response']['error_extra']['latest'] ?>).
162+
<?php } else if ($version['response']['error_code'] == 503) { ?>
163+
The TheSystems control server is currently unavailable.
164+
<?php } ?>
165+
</p>
166+
</div>
165167
<?php } ?>
166168
</div>
167169
</div>

0 commit comments

Comments
 (0)