Combine Locations and Nodes on Create Server page (#641)
This commit is contained in:
parent
2f696ddd6e
commit
0c21d401e3
3 changed files with 14 additions and 36 deletions
|
@ -81,6 +81,8 @@ class Server extends Model implements CleansAttributes, ValidableContract
|
|||
'disk' => 'required',
|
||||
'service_id' => 'required',
|
||||
'option_id' => 'required',
|
||||
'node_id' => 'required',
|
||||
'allocation_id' => 'required',
|
||||
'pack_id' => 'sometimes',
|
||||
'auto_deploy' => 'sometimes',
|
||||
'custom_id' => 'sometimes',
|
||||
|
|
|
@ -27,9 +27,6 @@ $(document).ready(function() {
|
|||
$('#pPackId').select2({
|
||||
placeholder: 'Select a Service Pack',
|
||||
});
|
||||
$('#pLocationId').select2({
|
||||
placeholder: 'Select a Location',
|
||||
}).change();
|
||||
$('#pNodeId').select2({
|
||||
placeholder: 'Select a Node',
|
||||
});
|
||||
|
@ -100,29 +97,9 @@ $(document).on('click', function (event) {
|
|||
lastActiveBox.addClass('box-primary');
|
||||
});
|
||||
|
||||
var currentLocation = null;
|
||||
var curentNode = null;
|
||||
var NodeData = [];
|
||||
|
||||
$('#pLocationId').on('change', function (event) {
|
||||
showLoader();
|
||||
currentLocation = $(this).val();
|
||||
currentNode = null;
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: Router.route('admin.servers.new.nodes'),
|
||||
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') },
|
||||
data: { location: currentLocation },
|
||||
}).done(function (data) {
|
||||
NodeData = data;
|
||||
$('#pNodeId').html('').select2({data: data}).change();
|
||||
}).fail(function (jqXHR) {
|
||||
cosole.error(jqXHR);
|
||||
currentLocation = null;
|
||||
}).always(hideLoader);
|
||||
});
|
||||
|
||||
$('#pNodeId').on('change', function (event) {
|
||||
currentNode = $(this).val();
|
||||
$.each(NodeData, function (i, v) {
|
||||
|
|
|
@ -78,21 +78,20 @@
|
|||
</div>
|
||||
<div class="box-body row">
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="pLocationId">Location</label>
|
||||
<select name="location_id" id="pLocationId" class="form-control">
|
||||
<label for="pNodeId">Node</label>
|
||||
<select name="node_id" id="pNodeId" class="form-control">
|
||||
@foreach($locations as $location)
|
||||
<option value="{{ $location->id }}"
|
||||
@if($location->id === old('location_id'))
|
||||
selected
|
||||
@endif
|
||||
>{{ $location->long }} ({{ $location->short }})</option>
|
||||
<optgroup label="{{ $location->long }} ({{ $location->short }})">
|
||||
@foreach($location->nodes as $node)
|
||||
|
||||
<option value="{{ $node->id }}"
|
||||
@if($location->id === old('location_id')) selected @endif
|
||||
>{{ $node->name }}</option>
|
||||
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
</select>
|
||||
<p class="small text-muted no-margin">The location in which this server will be deployed.</p>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="pNodeId">Node</label>
|
||||
<select name="node_id" id="pNodeId" class="form-control"></select>
|
||||
<p class="small text-muted no-margin">The node which this server will be deployed to.</p>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
|
@ -100,7 +99,7 @@
|
|||
<select name="allocation_id" id="pAllocation" class="form-control"></select>
|
||||
<p class="small text-muted no-margin">The main allocation that will be assigned to this server.</p>
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="pAllocationAdditional">Additional Allocation(s)</label>
|
||||
<select name="allocation_additional[]" id="pAllocationAdditional" class="form-control" multiple></select>
|
||||
<p class="small text-muted no-margin">Additional allocations to assign to this server on creation.</p>
|
||||
|
|
Loading…
Reference in a new issue