Merge pull request #278 from ControlPanel-gg/product_linking
automatically select first options if there is only 1
This commit is contained in:
commit
b7a1bf93bc
|
@ -101,7 +101,7 @@
|
||||||
name="nest"
|
name="nest"
|
||||||
id="nest"
|
id="nest"
|
||||||
x-model="selectedNest"
|
x-model="selectedNest"
|
||||||
@change="setNests();">
|
@change="setEggs();">
|
||||||
<option selected disabled hidden
|
<option selected disabled hidden
|
||||||
value="null">{{count($nests) > 0 ? __('Please select software..') : __('---')}}</option>
|
value="null">{{count($nests) > 0 ? __('Please select software..') : __('---')}}</option>
|
||||||
@foreach ($nests as $nest)
|
@foreach ($nests as $nest)
|
||||||
|
@ -230,28 +230,33 @@
|
||||||
class="text-muted"></small>
|
class="text-muted"></small>
|
||||||
</div>
|
</div>
|
||||||
<template x-if="selectedProductObject?.name">
|
<template x-if="selectedProductObject?.name">
|
||||||
<ul class="pl-0">
|
<ul class="pl-0">
|
||||||
<li class="d-flex justify-content-between">
|
<li class="d-flex justify-content-between">
|
||||||
<small class="text-muted d-inline-block">{{__('Cpu')}}</small>
|
<small class="text-muted d-inline-block">{{__('Cpu')}}</small>
|
||||||
<small class="text-muted d-inline-block" x-text="selectedProductObject.cpu + ' %'"></small>
|
<small class="text-muted d-inline-block"
|
||||||
</li>
|
x-text="selectedProductObject.cpu + ' %'"></small>
|
||||||
<div class="d-flex justify-content-between">
|
</li>
|
||||||
<small class="text-muted d-inline-block">{{__('Memory')}}</small>
|
<div class="d-flex justify-content-between">
|
||||||
<small class="text-muted d-inline-block" x-text="selectedProductObject.memory + ' {{__('MB')}}'"></small>
|
<small class="text-muted d-inline-block">{{__('Memory')}}</small>
|
||||||
</div>
|
<small class="text-muted d-inline-block"
|
||||||
<div class="d-flex justify-content-between">
|
x-text="selectedProductObject.memory + ' {{__('MB')}}'"></small>
|
||||||
<small class="text-muted d-inline-block">{{__('Storage')}}</small>
|
</div>
|
||||||
<small class="text-muted d-inline-block" x-text="selectedProductObject.disk + ' {{__('MB')}}'"></small>
|
<div class="d-flex justify-content-between">
|
||||||
</div>
|
<small class="text-muted d-inline-block">{{__('Storage')}}</small>
|
||||||
<div class="d-flex justify-content-between">
|
<small class="text-muted d-inline-block"
|
||||||
<small class="text-muted d-inline-block">{{__('Databases')}}</small>
|
x-text="selectedProductObject.disk + ' {{__('MB')}}'"></small>
|
||||||
<small class="text-muted d-inline-block" x-text="selectedProductObject.databases + ' {{__('Mysql')}}'"></small>
|
</div>
|
||||||
</div>
|
<div class="d-flex justify-content-between">
|
||||||
<div class="d-flex justify-content-between">
|
<small class="text-muted d-inline-block">{{__('Databases')}}</small>
|
||||||
<small class="text-muted d-inline-block">{{__('Backups')}}</small>
|
<small class="text-muted d-inline-block"
|
||||||
<small class="text-muted d-inline-block" x-text="selectedProductObject.backups"></small>
|
x-text="selectedProductObject.databases + ' {{__('Mysql')}}'"></small>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
<div class="d-flex justify-content-between">
|
||||||
|
<small class="text-muted d-inline-block">{{__('Backups')}}</small>
|
||||||
|
<small class="text-muted d-inline-block"
|
||||||
|
x-text="selectedProductObject.backups"></small>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
@ -315,7 +320,7 @@
|
||||||
* @note called whenever a nest is selected
|
* @note called whenever a nest is selected
|
||||||
* @see selectedNest
|
* @see selectedNest
|
||||||
*/
|
*/
|
||||||
setNests() {
|
async setEggs() {
|
||||||
this.fetchedLocations = false;
|
this.fetchedLocations = false;
|
||||||
this.fetchedProducts = false;
|
this.fetchedProducts = false;
|
||||||
this.locations = [];
|
this.locations = [];
|
||||||
|
@ -325,6 +330,14 @@
|
||||||
this.selectedProduct = 'null';
|
this.selectedProduct = 'null';
|
||||||
|
|
||||||
this.eggs = this.eggsSave.filter(egg => egg.nest_id == this.selectedNest)
|
this.eggs = this.eggsSave.filter(egg => egg.nest_id == this.selectedNest)
|
||||||
|
|
||||||
|
//automatically select the first entry if there is only 1
|
||||||
|
if (this.eggs.length === 1) {
|
||||||
|
this.selectedEgg = this.eggs[0].id;
|
||||||
|
await this.fetchLocations();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.updateSelectedObjects()
|
this.updateSelectedObjects()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -347,6 +360,14 @@
|
||||||
|
|
||||||
this.fetchedLocations = true;
|
this.fetchedLocations = true;
|
||||||
this.locations = response.data
|
this.locations = response.data
|
||||||
|
|
||||||
|
//automatically select the first entry if there is only 1
|
||||||
|
if (this.locations.length === 1 && this.locations[0]?.nodes?.length === 1) {
|
||||||
|
this.selectedNode = this.locations[0].id;
|
||||||
|
await this.fetchProducts();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.updateSelectedObjects()
|
this.updateSelectedObjects()
|
||||||
},
|
},
|
||||||
|
@ -367,6 +388,12 @@
|
||||||
|
|
||||||
this.fetchedProducts = true;
|
this.fetchedProducts = true;
|
||||||
this.products = response.data
|
this.products = response.data
|
||||||
|
|
||||||
|
//automatically select the first entry if there is only 1
|
||||||
|
if (this.products.length === 1) {
|
||||||
|
this.selectedProduct = this.products[0].id;
|
||||||
|
}
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.updateSelectedObjects()
|
this.updateSelectedObjects()
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue