FQDN support for allocations, and JS bug fix.

This commit is contained in:
Dane Everitt 2016-10-21 17:33:26 -04:00
parent 176d92176e
commit ad906e0680
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 51 additions and 37 deletions

View File

@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* New API endpoints for individual users to control their servers with at `/api/me/*`.
* Typeahead support for owner email when adding a new server.
* Scheduled command to clear out task log every month (configurable timespan).
* Support for allocating a FQDN as an allocation (panel will convert to IP and assign the FQDN as the alias automatically).
### Changed
* 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.
### Fixed
* Server overview listing the location short-code as the name of the node.
* Server task manager only sending commands every 5 minutes at the quickest.
* Fixes additional port allocation from removing the wrong row when clicking 'x'.
## v0.5.0-pre.2 (Bodacious Boreopterus)

View File

@ -164,7 +164,17 @@ class NodeRepository {
try {
foreach($allocations as $rawIP => $ports) {
$parsedIP = Network::parse($rawIP);
try {
$setAlias = null;
$parsedIP = Network::parse($rawIP);
} catch (\Exception $ex) {
try {
$setAlias = $rawIP;
$parsedIP = Network::parse(gethostbyname($rawIP));
} catch (\Exception $ex) {
throw $ex;
}
}
foreach($parsedIP as $ip) {
foreach($ports as $port) {
if (!is_int($port) && !preg_match('/^(\d{1,5})-(\d{1,5})$/', $port)) {
@ -182,6 +192,7 @@ class NodeRepository {
'node' => $node->id,
'ip' => $ip,
'port' => $assignPort,
'ip_alias' => $setAlias,
'assigned_to' => null
]);
$alloc->save();
@ -198,6 +209,7 @@ class NodeRepository {
'node' => $node->id,
'ip' => $ip,
'port' => $port,
'ip_alias' => $setAlias,
'assigned_to' => null
]);
$alloc->save();
@ -208,7 +220,7 @@ class NodeRepository {
}
DB::commit();
return true;
// return true;
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;

View File

@ -312,7 +312,7 @@
<form action="{{ route('admin.nodes.post.allocations', $node->id) }}" method="POST">
<div class="row" id="duplicate">
<div class="col-md-4 fuelux">
<label for="" class="control-label">IP Address</label>
<label for="" class="control-label">IP Address or FQDN</label>
<div class="input-group input-append dropdown combobox allocationComboBox" data-initialize="combobox">
<input type="text" name="allocate_ip[]" class="form-control pillbox_ip" style="border-right:0;">
<div class="input-group-btn">
@ -509,27 +509,27 @@ $(document).ready(function () {
$('.cloneElement').on('click', function (event) {
event.preventDefault();
var cloned = $('#duplicate').clone();
var rnd = randomKey(10);
var cloned = $('#duplicate').clone().attr('id', rnd);
cloned.find('.allocationPillbox').removeClass('allocationPillbox').addClass('allocationPillbox_' + rnd);
cloned.find('.pillboxMain').removeClass('pillboxMain').addClass('pillbox_' + rnd);
cloned.find('.removeClone').removeClass('disabled');
cloned.find('.removeClone').removeClass('disabled').attr('data-parent', rnd);
cloned.find('.pillbox_ip').removeClass('pillbox_ip').addClass('pillbox_ip_' + rnd);
cloned.insertAfter('#duplicate');
$('.allocationPillbox_' + rnd).pillbox();
$('.allocationPillbox_' + rnd).on('added.fu.pillbox edited.fu.pillbox removed.fu.pillbox', function pillboxChanged() {
$('.pillbox_' + rnd).val(JSON.stringify($('.allocationPillbox_' + rnd).pillbox('items')));
});
$('.removeClone').on('click', function (event) {
$('.removeClone').unbind().on('click', function (event) {
event.preventDefault();
var element = $(this);
element.parent().parent().slideUp(function () {
$('#' + element.attr('data-parent')).slideUp(function () {
element.remove();
$('.pillbox_' + rnd).remove();
$('.pillbox_ip_' + rnd).remove();
$('.pillbox_' + element.attr('data-parent')).remove();
$('.pillbox_ip_' + element.attr('data-parent')).remove();
});
});
})
});
$('.allocationPillbox').pillbox();
$('.allocationComboBox').combobox();
@ -628,35 +628,35 @@ $(document).ready(function () {
socket.on('live-stats', function (data) {
if (typeof memoryGraphSettings.data[0][100] !== 'undefined' || memoryGraphSettings.data[0][0].memory === -1) {
memoryGraphSettings.data[0].shift();
}
if (typeof cpuGraphSettings.data[0][100] !== 'undefined' || cpuGraphSettings.data[0][0].cpu === -1) {
cpuGraphSettings.data[0].shift();
}
if (typeof playersGraphSettings.data[0][100] !== 'undefined' || playersGraphSettings.data[0][0].players === -1) {
playersGraphSettings.data[0].shift();
}
// if (typeof memoryGraphSettings.data[0][100] !== 'undefined' || memoryGraphSettings.data[0][0].memory === -1) {
// memoryGraphSettings.data[0].shift();
// }
// if (typeof cpuGraphSettings.data[0][100] !== 'undefined' || cpuGraphSettings.data[0][0].cpu === -1) {
// cpuGraphSettings.data[0].shift();
// }
// if (typeof playersGraphSettings.data[0][100] !== 'undefined' || playersGraphSettings.data[0][0].players === -1) {
// playersGraphSettings.data[0].shift();
// }
memoryGraphSettings.data[0].push({
'date': new Date(),
'memory': parseInt(data.stats.memory / (1024 * 1024))
});
cpuGraphSettings.data[0].push({
'date': new Date(),
'cpu': data.stats.cpu
});
playersGraphSettings.data[0].push({
'date': new Date(),
'players': data.stats.players
});
MG.data_graphic(memoryGraphSettings);
MG.data_graphic(cpuGraphSettings);
MG.data_graphic(playersGraphSettings);
// memoryGraphSettings.data[0].push({
// 'date': new Date(),
// 'memory': parseInt(data.stats.memory / (1024 * 1024))
// });
//
// cpuGraphSettings.data[0].push({
// 'date': new Date(),
// 'cpu': data.stats.cpu
// });
//
// playersGraphSettings.data[0].push({
// 'date': new Date(),
// 'players': data.stats.players
// });
// MG.data_graphic(memoryGraphSettings);
// MG.data_graphic(cpuGraphSettings);
// MG.data_graphic(playersGraphSettings);
//
$.each(data.servers, function (uuid, info) {
var element = $('tr[data-server="' + uuid + '"]');
element.find('[data-action="status"]').html(Status[info.status]);