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

Commit 55a3386

Browse files
author
Optischa
committed
Fix bug service start and added to dashboard charts data and added player and modules
1 parent a0b112b commit 55a3386

File tree

15 files changed

+491
-141
lines changed

15 files changed

+491
-141
lines changed

pages/header.php

Lines changed: 142 additions & 55 deletions
Large diffs are not rendered by default.

pages/webinterface/dashboard.php

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
$nodes = main::buildDefaultRequest("cluster", "GET");
66

7+
$rrdata = main::buildDefaultRequest("rrdata", "GET");
8+
79
$services = 0;
810

911
$connectedNodeCount = 0;
@@ -28,7 +30,7 @@
2830
$memory_min += $node['nodeInfoSnapshot']['usedMemory'];
2931

3032
$cpu_max += 100;
31-
$cpu_used += min(round($node['nodeInfoSnapshot']['processSnapshot']['cpuUsage'] * 100), 100);
33+
$cpu_used += min(round($node['nodeInfoSnapshot']['systemCpuUsage']), 100);
3234
}
3335
?>
3436

@@ -169,4 +171,125 @@
169171
</div>
170172
</main>
171173
</div>
172-
</main>
174+
</main>
175+
<?php
176+
177+
$cpuarraydata = "";
178+
$cpuarrayvalue = "";
179+
foreach ($rrdata["cpu"] as $cpu) {
180+
$cpuarraydata = $cpuarraydata . "'" .date("h:i", (intval($cpu["time"]) / 1000)) . "',";
181+
$cpuarrayvalue = $cpuarrayvalue . intval($cpu["cpu"]) . ",";
182+
}
183+
184+
$memoryarraydata = "";
185+
$memoryarrayvalue = "";
186+
foreach ($rrdata["memory"] as $memory) {
187+
$memoryarraydata = $memoryarraydata . "'" .date("h:i", (intval($memory["time"]) / 1000)) . "',";
188+
$memoryarrayvalue = $memoryarrayvalue . $memory["memory"] . ",";
189+
}
190+
?>
191+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
192+
<script>
193+
194+
const linecpuConfig = {
195+
type: 'line',
196+
data: {
197+
labels: [<?= $cpuarraydata ?>],
198+
datasets: [
199+
{
200+
label: 'Usage in %',
201+
backgroundColor: '#5b96f7',
202+
borderColor: '#5b96f7',
203+
data: [<?= $cpuarrayvalue ?>],
204+
fill: false,
205+
}
206+
],
207+
},
208+
options: {
209+
responsive: true,
210+
legend: {
211+
display: false,
212+
},
213+
tooltips: {
214+
mode: 'index',
215+
intersect: false,
216+
},
217+
hover: {
218+
mode: 'nearest',
219+
intersect: true,
220+
},
221+
scales: {
222+
x: {
223+
display: true,
224+
scaleLabel: {
225+
display: true,
226+
labelString: 'Value',
227+
},
228+
},
229+
y: {
230+
display: true,
231+
scaleLabel: {
232+
display: true,
233+
labelString: 'Value',
234+
},
235+
},
236+
},
237+
},
238+
}
239+
240+
const lineId = document.getElementById('cpu')
241+
if (lineId !== null) {
242+
window.myLine = new Chart(lineId, linecpuConfig)
243+
}
244+
245+
const lineConfig = {
246+
type: 'line',
247+
data: {
248+
labels: [<?= $memoryarraydata ?>],
249+
datasets: [
250+
{
251+
label: 'Usage in MB',
252+
backgroundColor: '#10b981',
253+
borderColor: '#10b981',
254+
data: [<?= $memoryarrayvalue ?>],
255+
fill: false,
256+
}
257+
],
258+
},
259+
options: {
260+
responsive: true,
261+
legend: {
262+
display: false,
263+
},
264+
tooltips: {
265+
mode: 'index',
266+
intersect: false,
267+
},
268+
hover: {
269+
mode: 'nearest',
270+
intersect: true,
271+
},
272+
scales: {
273+
x: {
274+
display: true,
275+
scaleLabel: {
276+
display: true,
277+
labelString: 'Value',
278+
},
279+
},
280+
y: {
281+
display: true,
282+
scaleLabel: {
283+
display: true,
284+
labelString: 'Value',
285+
},
286+
},
287+
},
288+
},
289+
}
290+
291+
const lineCtx = document.getElementById('ram')
292+
if (lineCtx !== null) {
293+
window.myLine = new Chart(lineCtx, lineConfig)
294+
}
295+
</script>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
$modules = \webinterface\main::buildDefaultRequest("modules")
4+
5+
?>
6+
<main class="w-full flex-grow p-6">
7+
<div class="py-3">
8+
<main class="h-full overflow-y-auto">
9+
<div class="container mx-auto grid">
10+
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
11+
<?php foreach ($modules as $module) { ?>
12+
<div class="min-w-0 p-4 dark:bg-gray-800 bg-white rounded-lg shadow-lg">
13+
<h4 class="mb-4 font-semibold text-blue-500"><?= $module["name"] ?></h4>
14+
<div class="flex">
15+
<p class="flex-1 dark:text-white text-gray-900 text-center p-5"><?= $module["description"] ?></p>
16+
</div>
17+
<div class="flex">
18+
<span class="text-gray-400">•</span>
19+
<p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Group: <?= $module["group"] ?></p>
20+
</div>
21+
<div class="flex">
22+
<span class="text-gray-400">•</span>
23+
<p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Version: <?= $module["version"] ?></p>
24+
</div>
25+
</div>
26+
<?php } ?>
27+
</div>
28+
</main>
29+
</div>
30+
</main>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
$players = \webinterface\main::buildDefaultRequest("players")
4+
5+
?>
6+
<main class="w-full flex-grow p-6">
7+
<div class="py-3">
8+
<main class="h-full overflow-y-auto">
9+
<div class="container mx-auto grid">
10+
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
11+
<?php foreach ($players as $player) { ?>
12+
<div class="min-w-0 p-5 dark:bg-gray-800 bg-white rounded-lg shadow-lg">
13+
<div class="hero container max-w-screen-lg mx-auto pb-5">
14+
<img
15+
alt=""
16+
class="m-auto h-64"
17+
src="https://mc-heads.net/body/<?= $player["uuid"] ?>"/>
18+
</div>
19+
<h4 class="mb-4 font-semibold text-blue-500 text-center"><?= $player["name"] ?></h4>
20+
<div class="flex">
21+
<p class="flex-1 dark:text-white text-gray-900 text-center p-2"><?php
22+
23+
foreach ($player["groups"] as $group) {
24+
echo '<span class="text-sm text-center text-white h-6 w-16 bg-gray-500 rounded-full py-1 px-2">' . $group["group"] . '</span>';
25+
}
26+
?></p>
27+
</div>
28+
<div class="flex">
29+
<span class="text-gray-400">•</span>
30+
<p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Letzter
31+
Login: <?= date("H:i:s d.m.y", intval($player["lastlogin"]) / 1000) ?></p>
32+
</div>
33+
<div class="flex">
34+
<span class="text-gray-400">•</span>
35+
<p class="flex-1 dark:text-white text-gray-900 items-center pl-2">Erster
36+
Login: <?= date("H:i:s d.m.y", intval($player["firstlogin"]) / 1000) ?></p>
37+
</div>
38+
</div>
39+
<?php } ?>
40+
</div>
41+
</main>
42+
</div>
43+
</main>

pages/webinterface/profile/help.php

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$player = \webinterface\main::buildDefaultRequest("players/". $_SESSION["cn3-wi-user"])
4+
5+
?>
6+
<main class="w-full flex-grow p-6">
7+
<div class="py-3">
8+
<main class="h-full overflow-y-auto">
9+
<div class="container mx-auto grid">
10+
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
11+
<div class="min-w-0 p-5 dark:bg-gray-800 bg-white rounded-lg shadow-lg">
12+
<div class="hero container max-w-screen-lg mx-auto pb-5">
13+
<img
14+
alt=""
15+
class="m-auto h-128"
16+
src="https://mc-heads.net/body/<?= $_SESSION["cn3-wi-user"] ?>"/>
17+
</div>
18+
</div>
19+
</div>
20+
21+
</main>
22+
</div>
23+
</main>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

pages/webinterface/task/console.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@
88
<!-- Command input -->
99
<div class="w-full">
1010
<div class="coding inverse-toggle px-5 pt-4 shadow-lg text-gray-100 dark:bg-gray-800 bg-white pb-6 pt-4 rounded-lg leading-normal overflow-hidden">
11-
<div class="top mb-2 flex">
12-
<h4 class="mb-2 font-semibold dark:text-white text-gray-900">Send command</h4>
13-
</div>
14-
<div class="flex-1 flex flex-col md:flex-row text-sm font-mono subpixel-antialiased">
15-
<div class="w-full flex-1 mx-2">
16-
<input placeholder="Command"
17-
id="command-input"
18-
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">
11+
<form method="post">
12+
<input name="action" value="sendCommand" type="hidden">
13+
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
14+
<div class="top mb-2 flex">
15+
<h4 class="mb-2 font-semibold dark:text-white text-gray-900">Send command</h4>
1916
</div>
20-
</div>
21-
<button type="button"
22-
id="execute-command"
23-
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">
24-
Execute
25-
</button>
17+
<div class="flex-1 flex flex-col md:flex-row text-sm font-mono subpixel-antialiased">
18+
<div class="w-full flex-1 mx-2">
19+
<input placeholder="Command"
20+
id="command-input"
21+
name="command"
22+
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">
23+
</div>
24+
</div>
25+
<button type="button"
26+
id="execute-command"
27+
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">
28+
Execute
29+
</button>
30+
</form>
2631
</div>
2732
</div>
2833
<!-- Create text output node -->

pages/webinterface/task/edit.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 bo
9595
</option>
9696
<?php
9797
$nodes = \webinterface\main::buildDefaultRequest("cluster", "GET");
98-
foreach ($nodes['nodes'] as $node) { ?>
98+
foreach ($nodes as $node) { ?>
9999
<option class="text-sm font-mono subpixel-antialiased" <?php if(in_array($node['node']['uniqueId'], $task['task']['associatedNodes'])) echo "selected"; ?>
100100
><?= $node['node']['uniqueId']; ?></option>
101101
<?php } ?>
@@ -114,8 +114,8 @@ class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 bo
114114
Select Group
115115
</option>
116116
<?php
117-
$groups = \webinterface\main::buildDefaultRequest("group", "GET");
118-
foreach ($groups['groups'] as $group) { ?>
117+
$groups = \webinterface\main::buildDefaultRequest("groups", "GET");
118+
foreach ($groups as $group) { ?>
119119
<option class="text-sm font-mono subpixel-antialiased" <?php if(in_array($group['name'], $task['task']['groups'])) echo "selected"; ?>
120120
><?= $group['name']; ?></option>
121121
<?php } ?>

pages/webinterface/task/index.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
1+
<?php
2+
3+
/*if (isset($_GET["action"])) {
4+
$_GET["action"] = "";
5+
?>
6+
7+
<div x-data="{ showModal : true }">
8+
<!-- Modal Background -->
9+
10+
<div
11+
class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full"
12+
x-show="showModal"
13+
id="my-modal"
14+
></div>
15+
<div x-show="showModal" class="fixed text-gray-600 flex items-center justify-center overflow-auto z-50 bg-black bg-opacity-40 left-0 right-0 top-0 bottom-0" x-transition:enter="transition ease duration-300" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition ease duration-300" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0">
16+
<!-- Modal -->
17+
<div x-show="showModal" class="dark:bg-gray-800 dark:text-white bg-white rounded-xl shadow-2xl p-6 sm:w-10/12 mx-10" @click.away="showModal = false" x-transition:enter="transition ease duration-100 transform" x-transition:enter-start="opacity-0 scale-90 translate-y-1" x-transition:enter-end="opacity-100 scale-100 translate-y-0" x-transition:leave="transition ease duration-100 transform" x-transition:leave-start="opacity-100 scale-100 translate-y-0" x-transition:leave-end="opacity-0 scale-90 translate-y-1">
18+
19+
<?php if ($_GET["success"] === "true") { ?>
20+
<img src="/assets/icons/success.svg" />
21+
<?php } else { ?>
22+
<img src="/assets/icons/error.svg" />
23+
<?php } ?>
24+
25+
<!-- Title -->
26+
<span class="font-bold block text-2xl mb-3"></span>
27+
28+
<!-- Buttons -->
29+
<div class="text-right space-x-5 mt-5">
30+
<button @click="showModal = !showModal" class="px-4 py-2 text-sm bg-white rounded-xl border transition-colors duration-150 ease-linear border-gray-200 text-gray-500 focus:outline-none focus:ring-0 font-bold hover:bg-gray-50 focus:bg-indigo-50 focus:text-indigo">Cancel</button>
31+
<a href="https://www.buymeacoffee.com/fricki" target="_blank" class="px-4 py-2 text-sm bg-white rounded-xl border transition-colors duration-150 ease-linear border-gray-200 text-gray-500 focus:outline-none focus:ring-0 font-bold hover:bg-gray-50 focus:bg-indigo-50 focus:text-indigo">🍺 Buy me a beer!</a>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
<?php
37+
}*/
38+
39+
?>
140
<main class="w-full flex-grow p-6">
241
<div class="py-3">
342
<main class="h-full overflow-y-auto">
443
<div class="container mx-auto grid">
44+
545
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
646
<!-- Tasks start -->
747
<?php
@@ -169,7 +209,7 @@ class="my-2 p-2 dark:bg-gray-900 bg-gray-100 flex border dark:border-gray-900 bo
169209
</option>
170210
<?php
171211
$nodes = main::buildDefaultRequest("cluster", "GET");
172-
foreach ($nodes['nodes'] as $node) { ?>
212+
foreach ($nodes as $node) { ?>
173213
<option class="text-sm font-mono subpixel-antialiased"><?= $node['node']['uniqueId']; ?></option>
174214
<?php } ?>
175215
</select>

0 commit comments

Comments
 (0)