Skip to content

Commit 5899991

Browse files
committed
More improvements to add server page.
1 parent 8f96b35 commit 5899991

File tree

3 files changed

+164
-60
lines changed

3 files changed

+164
-60
lines changed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ public function postNewServerGetNodes(Request $request)
120120
$nodes = Models\Node::with('allocations')->where('location_id', $request->input('location'))->get();
121121
return $nodes->map(function ($item) {
122122
$filtered = $item->allocations->map(function($map) {
123-
return collect($map)->only(['ip', 'port']);
123+
return collect($map)->only(['id', 'ip', 'port']);
124124
});
125125

126-
$item->ports = $filtered->unique('ip')->map(function ($map) use ($item) {
126+
$item->ports = $filtered->map(function ($map) use ($item) {
127127
return [
128-
'ip' => $map['ip'],
129-
'ports' => $item->allocations->where('ip', $map['ip'])->pluck('port')->all(),
128+
'id' => $map['id'],
129+
'text' => $map['ip'] . ':' . $map['port'],
130130
];
131131
})->values();
132132

public/themes/pterodactyl/css/pterodactyl.css

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,60 @@ li.select2-results__option--highlighted[aria-selected="false"] > .user-block > .
141141
color: #eee;
142142
}
143143

144+
.select2-search--inline .select2-search__field:focus {
145+
outline: none;
146+
border: 0 !important;
147+
}
148+
144149
.img-bordered-xs {
145150
border: 1px solid #d2d6de;
146151
padding: 1px;
147152
}
148153

149-
span[aria-labelledby="select2-pOwner-container"] {
154+
span[aria-labelledby="select2-pUserId-container"] {
150155
padding-left: 2px !important;
151156
}
157+
158+
.callout-slim a {
159+
color: #555 !important;
160+
}
161+
162+
.callout.callout-info.callout-slim {
163+
border: 1px solid #0097bc !important;
164+
border-left: 5px solid #0097bc !important;
165+
border-right: 5px solid #0097bc !important;
166+
color: #777 !important;
167+
background: transparent !important;
168+
}
169+
170+
.callout.callout-danger.callout-slim {
171+
border: 1px solid #c23321 !important;
172+
border-left: 5px solid #c23321 !important;
173+
border-right: 5px solid #c23321 !important;
174+
color: #777 !important;
175+
background: transparent !important;
176+
}
177+
178+
.callout.callout-warning.callout-slim {
179+
border: 1px solid #c87f0a !important;
180+
border-left: 5px solid #c87f0a !important;
181+
border-right: 5px solid #c87f0a !important;
182+
color: #777 !important;
183+
background: transparent !important;
184+
}
185+
186+
.callout.callout-success.callout-slim {
187+
border: 1px solid #00733e !important;
188+
border-left: 5px solid #00733e !important;
189+
border-right: 5px solid #00733e !important;
190+
color: #777 !important;
191+
background: transparent !important;
192+
}
193+
194+
.callout.callout-default.callout-slim {
195+
border: 1px solid #eee !important;
196+
border-left: 5px solid #eee !important;
197+
border-right: 5px solid #eee !important;
198+
color: #777 !important;
199+
background: transparent !important;
200+
}

resources/themes/pterodactyl/admin/servers/new.blade.php

Lines changed: 110 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<form action="{{ route('admin.servers.new') }}" method="POST">
3737
<div class="row">
3838
<div class="col-xs-12">
39-
<div class="box box-primary">
39+
<div class="box">
4040
<div class="box-header with-border">
4141
<h3 class="box-title">Core Details</h3>
4242
</div>
@@ -62,36 +62,29 @@
6262
<h3 class="box-title">Allocation Management</h3>
6363
</div>
6464
<div class="box-body row">
65-
<div class="form-group col-sm-6">
65+
<div class="form-group col-sm-4">
6666
<label for="pLocationId">Location</label>
6767
<select name="location_id" id="pLocationId" class="form-control">
68-
<option disabled selected>Select a Location</option>
6968
@foreach($locations as $location)
7069
<option value="{{ $location->id }}">{{ $location->long }} ({{ $location->short }})</option>
7170
@endforeach
7271
</select>
7372
<p class="small text-muted no-margin">The location in which this server will be deployed.</p>
7473
</div>
75-
<div class="form-group col-sm-6">
74+
<div class="form-group col-sm-4">
7675
<label for="pNodeId">Node</label>
77-
<select name="node_id" id="pNodeId" class="form-control">
78-
<option disabled selected>Select a Node</option>
79-
</select>
76+
<select name="node_id" id="pNodeId" class="form-control"></select>
8077
<p class="small text-muted no-margin">The node which this server will be deployed to.</p>
8178
</div>
82-
<div class="form-group col-sm-6">
83-
<label for="pIp">IP Address</label>
84-
<select name="ip" id="pIp" class="form-control">
85-
<option disabled selected>Select an IP</option>
86-
</select>
87-
<p class="small text-muted no-margin">The IP address that this server will be allocated to.</p>
79+
<div class="form-group col-sm-4">
80+
<label for="pAllocation">Default Allocation</label>
81+
<select name="allocation_id" id="pAllocation" class="form-control"></select>
82+
<p class="small text-muted no-margin">The main allocation that will be assigned to this server.</p>
8883
</div>
89-
<div class="form-group col-sm-6">
90-
<label for="pPort">Port</label>
91-
<select name="port" id="pPort" class="form-control">
92-
<option disabled selected>Select a Port</option>
93-
</select>
94-
<p class="small text-muted no-margin">The port that this server will be allocated to.</p>
84+
<div class="form-group col-sm-12">
85+
<label for="pAllocationAdditional">Additional Allocation(s)</label>
86+
<select name="allocation_additional" id="pAllocationAdditional" class="form-control" multiple></select>
87+
<p class="small text-muted no-margin">Additional allocations to assign to this server on creation.</p>
9588
</div>
9689
</div>
9790
<div class="box-footer">
@@ -103,17 +96,92 @@
10396
</div>
10497
</div>
10598
</div>
99+
<div class="row">
100+
<div class="col-xs-12">
101+
<div class="box">
102+
<div class="box-header with-border">
103+
<h3 class="box-title">Resource Management</h3>
104+
</div>
105+
<div class="box-body row">
106+
<div class="form-group col-sm-4">
107+
<label for="pMemory">Memory</label>
108+
<div class="input-group">
109+
<input type="text" class="form-control" name="memory" id="pMemory" />
110+
<span class="input-group-addon">MB</span>
111+
</div>
112+
</div>
113+
<div class="form-group col-sm-4">
114+
<label for="pSwap">Swap</label>
115+
<div class="input-group">
116+
<input type="text" class="form-control" name="swap" id="pSwap" />
117+
<span class="input-group-addon">MB</span>
118+
</div>
119+
</div>
120+
<div class="form-group col-sm-4">
121+
<label for="pOOMDisabled">Out-of-Memory Killer</label>
122+
<div class="input-group">
123+
<span class="input-group-addon">
124+
<input type="checkbox" id="pOOMDisabled" name="oom_disabled"/>
125+
</span>
126+
<input type="text" class="form-control" readonly style="background:transparent !important;" value="Disable OOM Killer" />
127+
</div>
128+
</div>
129+
</div>
130+
<div class="box-footer no-border" style="padding: 0 10px 10px;">
131+
<div class="callout callout-info callout-slim no-margin">
132+
<p class="small no-margin">If you do not want to assign swap space to a server simply put <code>0</code> for the value, or <code>-1</code> to allow unlimited swap space. If you want to disable memory limiting on a server simply enter <code>0</code> into the memory field. We suggest leaving OOM Killer enabled unless you know what you are doing, disabling it could cause your server to hang unexpectedly.<p>
133+
</div>
134+
</div>
135+
<div class="box-body row">
136+
<div class="form-group col-sm-4">
137+
<label for="pDisk">Disk Space</label>
138+
<div class="input-group">
139+
<input type="text" class="form-control" name="disk" id="pDisk" />
140+
<span class="input-group-addon">GB</span>
141+
</div>
142+
</div>
143+
<div class="form-group col-sm-4">
144+
<label for="pCPU">CPU Limit</label>
145+
<div class="input-group">
146+
<input type="text" class="form-control" name="cpu" id="pCPU" />
147+
<span class="input-group-addon">%</span>
148+
</div>
149+
</div>
150+
<div class="form-group col-sm-4">
151+
<label for="pIO">Block IO Weight</label>
152+
<div class="input-group">
153+
<input type="text" class="form-control" value="500" name="io" id="pIO" />
154+
<span class="input-group-addon">I/O</span>
155+
</div>
156+
</div>
157+
</div>
158+
<div class="box-footer no-border" style="padding: 0 10px 10px;">
159+
<div class="callout callout-info callout-slim">
160+
<p class="small no-margin">If you do not want to limit CPU usage set the value to <code>0</code>. To determine a value, take the number <em>physical</em> cores and multiply it by 100. For example, on a quad core system <code>(4 * 100 = 400)</code> there is <code>400%</code> available. To limit a server to using half of a single core, you would set the value to <code>50</code>. To allow a server to use up to two physical cores, set the value to <code>200</code>. BlockIO should be a value between <code>10</code> and <code>1000</code>. Please see <a href="https://docs.docker.com/engine/reference/run/#/block-io-bandwidth-blkio-constraint" target="_blank">this documentation</a> for more information about it.<p>
161+
</div>
162+
</div>
163+
</div>
164+
</div>
165+
</div>
106166
</form>
107167
@endsection
108168

109169
@section('footer-scripts')
110170
@parent
111171
<script>
112172
$(document).ready(function() {
113-
$('#pLocationId').select2();
114-
$('#pNodeId').select2();
115-
$('#pIp').select2();
116-
$('#pPort').select2();
173+
$('#pLocationId').select2({
174+
placeholder: 'Select a Location',
175+
}).change();
176+
$('#pNodeId').select2({
177+
placeholder: 'Select a Node',
178+
});
179+
$('#pAllocation').select2({
180+
placeholder: 'Select a Default Allocation',
181+
});
182+
$('#pAllocationAdditional').select2({
183+
placeholder: 'Select Additional Allocations',
184+
});
117185
118186
$('#pUserId').select2({
119187
ajax: {
@@ -165,16 +233,22 @@ function showLoader() {
165233
$('#allocationLoader').show();
166234
}
167235
236+
var lastActiveBox = null;
237+
$(document).on('click', function (event) {
238+
if (lastActiveBox !== null) {
239+
lastActiveBox.removeClass('box-primary');
240+
}
241+
242+
lastActiveBox = $(event.target).closest('.box');
243+
lastActiveBox.addClass('box-primary');
244+
});
245+
168246
var currentLocation = null;
169247
var curentNode = null;
170-
var currentIP = null;
171-
172-
var NodeDataIdentifier = null;
173248
var NodeData = [];
174-
var AllocationsForNode = null;
175249
176250
$('#pLocationId').on('change', function (event) {
177-
showLoader()
251+
showLoader();
178252
currentLocation = $(this).val();
179253
currentNode = null;
180254
@@ -185,8 +259,7 @@ function showLoader() {
185259
data: { location: currentLocation },
186260
}).done(function (data) {
187261
NodeData = data;
188-
console.log(data);
189-
$('#pNodeId').select2({data: data});
262+
$('#pNodeId').select2({data: data}).change();
190263
}).fail(function (jqXHR) {
191264
cosole.error(jqXHR);
192265
currentLocation = null;
@@ -197,31 +270,13 @@ function showLoader() {
197270
currentNode = $(this).val();
198271
$.each(NodeData, function (i, v) {
199272
if (v.id == currentNode) {
200-
NodeDataIdentifier = i;
201-
$('#pIp').select2({
202-
data: $.map(v.allocations, function (item) {
203-
return {
204-
id: item.ip,
205-
text: item.ip,
206-
}
207-
}),
208-
})
209-
}
210-
});
211-
});
212-
213-
$('#pIp').on('change', function (event) {
214-
currentIP = $(this).val();
215-
$.each(NodeData[NodeDataIdentifier].allocations, function (i, v) {
216-
if (v.ip == currentIP) {
217-
$('#pPort').val(null);
218-
$('#pPort').select2({
219-
data: $.map(v.ports, function (item) {
220-
return {
221-
id: item,
222-
text: item,
223-
}
224-
}),
273+
$('#pAllocation').select2({
274+
data: v.allocations,
275+
placeholder: 'Select a Default Allocation',
276+
});
277+
$('#pAllocationAdditional').select2({
278+
data: v.allocations,
279+
placeholder: 'Select Additional Allocations',
225280
})
226281
}
227282
});

0 commit comments

Comments
 (0)