Skip to content

Commit ad906e0

Browse files
committed
FQDN support for allocations, and JS bug fix.
1 parent 176d921 commit ad906e0

File tree

3 files changed

+51
-37
lines changed

3 files changed

+51
-37
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1212
* New API endpoints for individual users to control their servers with at `/api/me/*`.
1313
* Typeahead support for owner email when adding a new server.
1414
* Scheduled command to clear out task log every month (configurable timespan).
15+
* Support for allocating a FQDN as an allocation (panel will convert to IP and assign the FQDN as the alias automatically).
1516

1617
### Changed
1718
* Creating a user, server, or node now returns `HTTP/1.1 200` and a JSON element with the user/server/node's ID.
@@ -23,6 +24,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
2324
### Fixed
2425
* Server overview listing the location short-code as the name of the node.
2526
* Server task manager only sending commands every 5 minutes at the quickest.
27+
* Fixes additional port allocation from removing the wrong row when clicking 'x'.
2628

2729
## v0.5.0-pre.2 (Bodacious Boreopterus)
2830

app/Repositories/NodeRepository.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,17 @@ public function addAllocations($id, array $allocations)
164164

165165
try {
166166
foreach($allocations as $rawIP => $ports) {
167-
$parsedIP = Network::parse($rawIP);
167+
try {
168+
$setAlias = null;
169+
$parsedIP = Network::parse($rawIP);
170+
} catch (\Exception $ex) {
171+
try {
172+
$setAlias = $rawIP;
173+
$parsedIP = Network::parse(gethostbyname($rawIP));
174+
} catch (\Exception $ex) {
175+
throw $ex;
176+
}
177+
}
168178
foreach($parsedIP as $ip) {
169179
foreach($ports as $port) {
170180
if (!is_int($port) && !preg_match('/^(\d{1,5})-(\d{1,5})$/', $port)) {
@@ -182,6 +192,7 @@ public function addAllocations($id, array $allocations)
182192
'node' => $node->id,
183193
'ip' => $ip,
184194
'port' => $assignPort,
195+
'ip_alias' => $setAlias,
185196
'assigned_to' => null
186197
]);
187198
$alloc->save();
@@ -198,6 +209,7 @@ public function addAllocations($id, array $allocations)
198209
'node' => $node->id,
199210
'ip' => $ip,
200211
'port' => $port,
212+
'ip_alias' => $setAlias,
201213
'assigned_to' => null
202214
]);
203215
$alloc->save();
@@ -208,7 +220,7 @@ public function addAllocations($id, array $allocations)
208220
}
209221

210222
DB::commit();
211-
return true;
223+
// return true;
212224
} catch (\Exception $ex) {
213225
DB::rollBack();
214226
throw $ex;

resources/views/admin/nodes/view.blade.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
<form action="{{ route('admin.nodes.post.allocations', $node->id) }}" method="POST">
313313
<div class="row" id="duplicate">
314314
<div class="col-md-4 fuelux">
315-
<label for="" class="control-label">IP Address</label>
315+
<label for="" class="control-label">IP Address or FQDN</label>
316316
<div class="input-group input-append dropdown combobox allocationComboBox" data-initialize="combobox">
317317
<input type="text" name="allocate_ip[]" class="form-control pillbox_ip" style="border-right:0;">
318318
<div class="input-group-btn">
@@ -509,27 +509,27 @@
509509
510510
$('.cloneElement').on('click', function (event) {
511511
event.preventDefault();
512-
var cloned = $('#duplicate').clone();
513512
var rnd = randomKey(10);
513+
var cloned = $('#duplicate').clone().attr('id', rnd);
514514
cloned.find('.allocationPillbox').removeClass('allocationPillbox').addClass('allocationPillbox_' + rnd);
515515
cloned.find('.pillboxMain').removeClass('pillboxMain').addClass('pillbox_' + rnd);
516-
cloned.find('.removeClone').removeClass('disabled');
516+
cloned.find('.removeClone').removeClass('disabled').attr('data-parent', rnd);
517517
cloned.find('.pillbox_ip').removeClass('pillbox_ip').addClass('pillbox_ip_' + rnd);
518518
cloned.insertAfter('#duplicate');
519519
$('.allocationPillbox_' + rnd).pillbox();
520520
$('.allocationPillbox_' + rnd).on('added.fu.pillbox edited.fu.pillbox removed.fu.pillbox', function pillboxChanged() {
521521
$('.pillbox_' + rnd).val(JSON.stringify($('.allocationPillbox_' + rnd).pillbox('items')));
522522
});
523-
$('.removeClone').on('click', function (event) {
523+
$('.removeClone').unbind().on('click', function (event) {
524524
event.preventDefault();
525525
var element = $(this);
526-
element.parent().parent().slideUp(function () {
526+
$('#' + element.attr('data-parent')).slideUp(function () {
527527
element.remove();
528-
$('.pillbox_' + rnd).remove();
529-
$('.pillbox_ip_' + rnd).remove();
528+
$('.pillbox_' + element.attr('data-parent')).remove();
529+
$('.pillbox_ip_' + element.attr('data-parent')).remove();
530530
});
531531
});
532-
})
532+
});
533533
534534
$('.allocationPillbox').pillbox();
535535
$('.allocationComboBox').combobox();
@@ -628,35 +628,35 @@
628628
629629
socket.on('live-stats', function (data) {
630630
631-
if (typeof memoryGraphSettings.data[0][100] !== 'undefined' || memoryGraphSettings.data[0][0].memory === -1) {
632-
memoryGraphSettings.data[0].shift();
633-
}
634-
if (typeof cpuGraphSettings.data[0][100] !== 'undefined' || cpuGraphSettings.data[0][0].cpu === -1) {
635-
cpuGraphSettings.data[0].shift();
636-
}
637-
if (typeof playersGraphSettings.data[0][100] !== 'undefined' || playersGraphSettings.data[0][0].players === -1) {
638-
playersGraphSettings.data[0].shift();
639-
}
640-
641-
memoryGraphSettings.data[0].push({
642-
'date': new Date(),
643-
'memory': parseInt(data.stats.memory / (1024 * 1024))
644-
});
645-
646-
cpuGraphSettings.data[0].push({
647-
'date': new Date(),
648-
'cpu': data.stats.cpu
649-
});
650-
651-
playersGraphSettings.data[0].push({
652-
'date': new Date(),
653-
'players': data.stats.players
654-
});
631+
// if (typeof memoryGraphSettings.data[0][100] !== 'undefined' || memoryGraphSettings.data[0][0].memory === -1) {
632+
// memoryGraphSettings.data[0].shift();
633+
// }
634+
// if (typeof cpuGraphSettings.data[0][100] !== 'undefined' || cpuGraphSettings.data[0][0].cpu === -1) {
635+
// cpuGraphSettings.data[0].shift();
636+
// }
637+
// if (typeof playersGraphSettings.data[0][100] !== 'undefined' || playersGraphSettings.data[0][0].players === -1) {
638+
// playersGraphSettings.data[0].shift();
639+
// }
655640
656-
MG.data_graphic(memoryGraphSettings);
657-
MG.data_graphic(cpuGraphSettings);
658-
MG.data_graphic(playersGraphSettings);
641+
// memoryGraphSettings.data[0].push({
642+
// 'date': new Date(),
643+
// 'memory': parseInt(data.stats.memory / (1024 * 1024))
644+
// });
645+
//
646+
// cpuGraphSettings.data[0].push({
647+
// 'date': new Date(),
648+
// 'cpu': data.stats.cpu
649+
// });
650+
//
651+
// playersGraphSettings.data[0].push({
652+
// 'date': new Date(),
653+
// 'players': data.stats.players
654+
// });
659655
656+
// MG.data_graphic(memoryGraphSettings);
657+
// MG.data_graphic(cpuGraphSettings);
658+
// MG.data_graphic(playersGraphSettings);
659+
//
660660
$.each(data.servers, function (uuid, info) {
661661
var element = $('tr[data-server="' + uuid + '"]');
662662
element.find('[data-action="status"]').html(Status[info.status]);

0 commit comments

Comments
 (0)