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

Commit b1720a0

Browse files
author
Moritz Walter
committed
add update task
1 parent 2bb7e73 commit b1720a0

File tree

6 files changed

+275
-24
lines changed

6 files changed

+275
-24
lines changed

pages/webinterface/task/edit.php

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<main class="w-full flex-grow p-6">
2+
<div class="py-3">
3+
<main class="h-full overflow-y-auto">
4+
<div class="container mx-auto grid">
5+
<h6 class="mb-4 font-semibold dark:text-white text-gray-900">Edit <?= $task['task']['name']; ?></h6>
6+
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-1">
7+
8+
<div class="w-full">
9+
<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">
10+
11+
12+
<form method="post">
13+
<input name="action" value="editTask" type="hidden">
14+
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
15+
<div class="coding inverse-toggle px-5 pt-4 text-gray-100 dark:bg-gray-800 bg-white pb-6 pt-4 rounded-lg leading-normal overflow-hidden">
16+
<div class="top mb-2 flex">
17+
<h4 class="mb-2 font-semibold dark:text-white text-gray-900">Edit Task</h4>
18+
</div>
19+
<div class="flex-1 flex flex-col md:flex-row text-sm font-mono subpixel-antialiased">
20+
<div class="w-full flex-1 mx-2">
21+
<label for="name">Name</label>
22+
<input placeholder="Name"
23+
value="<?= $task['task']['name']; ?>"
24+
id="name"
25+
name="name"
26+
type="text"
27+
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"
28+
required
29+
>
30+
</div>
31+
<div class="w-full flex-1 mx-2">
32+
<label for="memory">Memory</label>
33+
<input placeholder="Ram"
34+
name="memory"
35+
id="memory"
36+
type="number"
37+
min="0"
38+
value="<?= $task['task']['processConfiguration']['maxHeapMemorySize']; ?>"
39+
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"
40+
required
41+
>
42+
</div>
43+
<div class="w-full flex-1 mx-2">
44+
<label for="environment">environment</label>
45+
<select
46+
name="environment"
47+
id="environment"
48+
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"
49+
required
50+
>
51+
<option disabled class="text-sm font-mono subpixel-antialiased">
52+
Select Environment
53+
</option>
54+
<option value="minecraft_server" <?php if($task['task']['processConfiguration']['environment'] == "MINECRAFT_SERVER") echo "selected"; ?>
55+
class="text-sm font-mono subpixel-antialiased">
56+
Minecraft Server
57+
</option>
58+
<option value="glowstone" <?php if($task['task']['processConfiguration']['environment'] == "GLOWSTONE") echo "selected"; ?>
59+
class="text-sm font-mono subpixel-antialiased">
60+
Glowstone
61+
</option>
62+
<option value="nukkit" <?php if($task['task']['processConfiguration']['environment'] == "NUKKIT") echo "selected"; ?>
63+
class="text-sm font-mono subpixel-antialiased">
64+
Nukkit
65+
</option>
66+
<option value="go_mint" <?php if($task['task']['processConfiguration']['environment'] == "GO_MINT") echo "selected"; ?>
67+
class="text-sm font-mono subpixel-antialiased">
68+
Go Mint
69+
</option>
70+
<option value="bungeecord" <?php if($task['task']['processConfiguration']['environment'] == "BUNGEECORD") echo "selected"; ?>
71+
class="text-sm font-mono subpixel-antialiased">
72+
Bungeecord
73+
</option>
74+
<option value="velocity" <?php if($task['task']['processConfiguration']['environment'] == "VELOCITY") echo "selected"; ?>
75+
class="text-sm font-mono subpixel-antialiased">
76+
Velocity
77+
</option>
78+
<option value="waterdog_pe" <?php if($task['task']['processConfiguration']['environment'] == "WATERDOG_PE") echo "selected"; ?>
79+
class="text-sm font-mono subpixel-antialiased">
80+
Waterdog PE
81+
</option>
82+
</select>
83+
</div>
84+
<div class="w-full flex-1 mx-2">
85+
<label for="nodes">Nodes</label>
86+
<select
87+
multiple
88+
name="node[]"
89+
id="nodes"
90+
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"
91+
required
92+
>
93+
<option disabled class="text-sm font-mono subpixel-antialiased">
94+
Select Node
95+
</option>
96+
<?php
97+
$nodes = \webinterface\main::buildDefaultRequest("cluster", "GET");
98+
foreach ($nodes['nodes'] as $node) { ?>
99+
<option class="text-sm font-mono subpixel-antialiased" <?php if(in_array($node['node']['uniqueId'], $task['task']['associatedNodes'])) echo "selected"; ?>
100+
><?= $node['node']['uniqueId']; ?></option>
101+
<?php } ?>
102+
</select>
103+
</div>
104+
<div class="w-full flex-1 mx-2">
105+
<label for="groups">Groups</label>
106+
<select
107+
multiple
108+
name="group[]"
109+
id="groups"
110+
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"
111+
required
112+
>
113+
<option disabled class="text-sm font-mono subpixel-antialiased">
114+
Select Group
115+
</option>
116+
<?php
117+
$groups = \webinterface\main::buildDefaultRequest("group", "GET");
118+
foreach ($groups['groups'] as $group) { ?>
119+
<option class="text-sm font-mono subpixel-antialiased" <?php if(in_array($group['name'], $task['task']['groups'])) echo "selected"; ?>
120+
><?= $group['name']; ?></option>
121+
<?php } ?>
122+
</select>
123+
</div>
124+
<div class="w-full flex-1 mx-2">
125+
<label for="port">Port</label>
126+
<input placeholder="Port"
127+
id="port"
128+
name="port"
129+
type="number"
130+
min="0"
131+
max="65535"
132+
value="<?= $task['task']['startPort']; ?>"
133+
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"
134+
required
135+
>
136+
</div>
137+
<div class="w-full flex-1 mx-2">
138+
<label class="inline-flex items-center mt-3">
139+
<input type="checkbox" name="static" class="form-checkbox h-5 w-5" <?php if($task['task']['staticServices']) echo "checked"; ?>>
140+
<span class="ml-2 dark:text-white text-gray-900">Static</span>
141+
</label>
142+
<label class="inline-flex items-center mt-3">
143+
<input type="checkbox" name="auto_delete_on_stop" <?php if($task['task']['autoDeleteOnStop']) echo "checked"; ?>
144+
class="form-checkbox h-5 w-5">
145+
<span class="ml-2 dark:text-white text-gray-900">AutoDeleteOnStop</span>
146+
</label>
147+
<label class="inline-flex items-center mt-3">
148+
<input type="checkbox" name="maintenance" class="form-checkbox h-5 w-5" <?php if($task['task']['maintenance']) echo "checked"; ?>>
149+
<span class="ml-2 dark:text-white text-gray-900">Maintenance</span>
150+
</label>
151+
</div>
152+
</div>
153+
<button type="submit"
154+
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">
155+
Save
156+
</button>
157+
</div>
158+
</form>
159+
</div>
160+
</div>
161+
</div>
162+
</div>
163+
</main>
164+
</div>
165+
</main>

pages/webinterface/task/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
<div class="flex items-center">
7171
<a href="/tasks/<?= $task['name']; ?>"
7272
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">Show</a>
73+
<a href="/tasks/<?= $task['name']; ?>/edit"
74+
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">Edit</a>
7375
</div>
7476
</div>
7577
</div>

pages/webinterface/task/task.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,34 @@
9797
</div>
9898
</div>
9999
</li>
100-
<div class="flex items-center p-4">
101-
<a href="<?= \webinterface\main::getUrl() . '/tasks/' . $task_name . '/' . $service['configuration']['serviceId']['uniqueId'] . '/console'; ?>"
102-
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">Console</a>
100+
<?php if ($service['lifeCycle'] == "RUNNING") { ?>
101+
<div class="flex items-center p-4">
102+
<a href="<?= \webinterface\main::getUrl() . '/tasks/' . $task_name . '/' . $service['configuration']['serviceId']['uniqueId'] . '/console'; ?>"
103+
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">Console</a>
103104

104-
<form method="post">
105-
<input name="action" value="stopService" type="hidden">
106-
<input name="service_id" value="<?= $service['configuration']['serviceId']['uniqueId']; ?>" type="hidden">
107-
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
108-
<button type="submit"
109-
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">
110-
Stop
111-
</button>
112-
</form>
113-
</div>
105+
<form method="post">
106+
<input name="action" value="stopService" type="hidden">
107+
<input name="service_id" value="<?= $service['configuration']['serviceId']['uniqueId']; ?>" type="hidden">
108+
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
109+
<button type="submit"
110+
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">
111+
Stop
112+
</button>
113+
</form>
114+
</div>
115+
<?php } else { ?>
116+
<div class="flex items-center p-4">
117+
<form method="post">
118+
<input name="action" value="startService" type="hidden">
119+
<input name="service_id" value="<?= $service['configuration']['serviceId']['uniqueId']; ?>" type="hidden">
120+
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
121+
<button type="submit"
122+
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">
123+
Start
124+
</button>
125+
</form>
126+
</div>
127+
<?php } ?>
114128
</div>
115129
<?php } ?>
116130
</div>
@@ -122,7 +136,7 @@ class="h-10 bg-blue-500 text-white rounded-md px-4 py-2 m-2 hover:bg-blue-600 fo
122136
</div>
123137

124138
<form method="post">
125-
<input name="action" value="startService" type="hidden">
139+
<input name="action" value="createService" type="hidden">
126140
<input name="csrf" value="<?= $_SESSION['cn3-wi-csrf'] ?>" type="hidden">
127141
<div class="flex-1 flex flex-col md:flex-row text-sm font-mono subpixel-antialiased">
128142
<div class="w-full flex-1 mx-2">

0 commit comments

Comments
 (0)