refactor: cleaner code closes #605
This commit is contained in:
parent
3b2a851f4f
commit
1a75d63ba1
1 changed files with 18 additions and 12 deletions
|
@ -23,7 +23,7 @@
|
|||
<!-- END CONTENT HEADER -->
|
||||
|
||||
<!-- MAIN CONTENT -->
|
||||
<section x-data="{ ...serverApp(), submitClicked: false }" class="content">
|
||||
<section x-data="serverApp()" class="content">
|
||||
<div class="container-xxl">
|
||||
<!-- FORM -->
|
||||
<form action="{{ route('servers.store') }}" x-on:submit="submitClicked = true" method="post"
|
||||
|
@ -35,10 +35,10 @@
|
|||
<div class="card-title"><i class="fas fa-cogs mr-2"></i>{{ __('Server configuration') }}
|
||||
</div>
|
||||
</div>
|
||||
@if (!config("SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS"))
|
||||
@if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS'))
|
||||
<div class="alert alert-warning p-2 m-2">
|
||||
The creation of new servers has been disabled for regular users, enable it again
|
||||
<a href="{{route('admin.settings.system')}}">{{ __('here') }}</a>.
|
||||
<a href="{{ route('admin.settings.system') }}">{{ __('here') }}</a>.
|
||||
</div>
|
||||
@endif
|
||||
@if ($productCount === 0 || $nodeCount === 0 || count($nests) === 0 || count($eggs) === 0)
|
||||
|
@ -48,7 +48,7 @@
|
|||
@if (Auth::user()->role == 'admin')
|
||||
{{ __('Make sure to link your products to nodes and eggs.') }} <br>
|
||||
{{ __('There has to be at least 1 valid product for server creation') }}
|
||||
<a href="{{route('admin.overview.sync')}}">{{ __('Sync now') }}</a>
|
||||
<a href="{{ route('admin.overview.sync') }}">{{ __('Sync now') }}</a>
|
||||
@endif
|
||||
|
||||
</p>
|
||||
|
@ -103,8 +103,8 @@
|
|||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="nest">{{ __('Software / Games') }}</label>
|
||||
<select class="custom-select" required name="nest" id="nest" x-model="selectedNest"
|
||||
@change="setEggs();">
|
||||
<select class="custom-select" required name="nest" id="nest"
|
||||
x-model="selectedNest" @change="setEggs();">
|
||||
<option selected disabled hidden value="null">
|
||||
{{ count($nests) > 0 ? __('Please select software ...') : __('---') }}
|
||||
</option>
|
||||
|
@ -135,8 +135,8 @@
|
|||
|
||||
<div class="form-group">
|
||||
<label for="node">{{ __('Node') }}</label>
|
||||
<select name="node" required id="node" x-model="selectedNode" :disabled="!fetchedLocations"
|
||||
@change="fetchProducts();" class="custom-select">
|
||||
<select name="node" required id="node" x-model="selectedNode"
|
||||
:disabled="!fetchedLocations" @change="fetchProducts();" class="custom-select">
|
||||
<option x-text="getNodeInputText()" disabled selected hidden value="null">
|
||||
</option>
|
||||
|
||||
|
@ -209,14 +209,17 @@
|
|||
</li>
|
||||
<li class="d-flex justify-content-between">
|
||||
<span class="d-inline-block"><i class="fa fa-coins"></i>
|
||||
{{ __('Required') }} {{ CREDITS_DISPLAY_NAME }} {{ __('to create this server') }}</span>
|
||||
<span class="d-inline-block" x-text="product.minimum_credits === -1 ? {{ config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') }} : product.minimum_credit"></span>
|
||||
{{ __('Required') }} {{ CREDITS_DISPLAY_NAME }}
|
||||
{{ __('to create this server') }}</span>
|
||||
<span class="d-inline-block"
|
||||
x-text="product.minimum_credits === -1 ? {{ config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') }} : product.minimum_credit"></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="mt-2 mb-2">
|
||||
<span class="card-text text-muted">{{ __('Description') }}</span>
|
||||
<p class="card-text" style="white-space:pre-wrap" x-text="product.description"></p>
|
||||
<p class="card-text" style="white-space:pre-wrap"
|
||||
x-text="product.description"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-auto border rounded border-secondary">
|
||||
|
@ -285,6 +288,8 @@
|
|||
locations: [],
|
||||
products: [],
|
||||
|
||||
submitClicked: false,
|
||||
|
||||
|
||||
/**
|
||||
* @description set available eggs based on the selected nest
|
||||
|
@ -368,7 +373,8 @@
|
|||
|
||||
this.fetchedProducts = true;
|
||||
// TODO: Sortable by user chosen property (cpu, ram, disk...)
|
||||
this.products = response.data.sort((p1, p2) => parseInt(p1.price,10) > parseInt(p2.price,10) && 1 || -1)
|
||||
this.products = response.data.sort((p1, p2) => parseInt(p1.price, 10) > parseInt(p2.price, 10) &&
|
||||
1 || -1)
|
||||
|
||||
//divide cpu by 100 for each product
|
||||
this.products.forEach(product => {
|
||||
|
|
Loading…
Add table
Reference in a new issue