parent
660cdca940
commit
edaa270a33
7 changed files with 103 additions and 51 deletions
|
@ -251,7 +251,7 @@ class ServersController extends Controller
|
||||||
$repo = new ServerRepository;
|
$repo = new ServerRepository;
|
||||||
try {
|
try {
|
||||||
$repo->updateDetails($id, $request->intersect([
|
$repo->updateDetails($id, $request->intersect([
|
||||||
'owner_id', 'name', 'reset_token',
|
'owner_id', 'name', 'description', 'reset_token',
|
||||||
]));
|
]));
|
||||||
|
|
||||||
Alert::success('Server details were successfully updated.')->flash();
|
Alert::success('Server details were successfully updated.')->flash();
|
||||||
|
|
|
@ -89,6 +89,7 @@ class ServerRepository
|
||||||
$validator = Validator::make($data, [
|
$validator = Validator::make($data, [
|
||||||
'user_id' => 'required|exists:users,id',
|
'user_id' => 'required|exists:users,id',
|
||||||
'name' => 'required|regex:/^([\w .-]{1,200})$/',
|
'name' => 'required|regex:/^([\w .-]{1,200})$/',
|
||||||
|
'description' => 'sometimes|nullable|string',
|
||||||
'memory' => 'required|numeric|min:0',
|
'memory' => 'required|numeric|min:0',
|
||||||
'swap' => 'required|numeric|min:-1',
|
'swap' => 'required|numeric|min:-1',
|
||||||
'io' => 'required|numeric|min:10|max:1000',
|
'io' => 'required|numeric|min:10|max:1000',
|
||||||
|
@ -363,6 +364,7 @@ class ServerRepository
|
||||||
$validator = Validator::make($data, [
|
$validator = Validator::make($data, [
|
||||||
'owner_id' => 'sometimes|required|integer|exists:users,id',
|
'owner_id' => 'sometimes|required|integer|exists:users,id',
|
||||||
'name' => 'sometimes|required|regex:([\w .-]{1,200})',
|
'name' => 'sometimes|required|regex:([\w .-]{1,200})',
|
||||||
|
'description' => 'sometimes|required|string',
|
||||||
'reset_token' => 'sometimes|required|accepted',
|
'reset_token' => 'sometimes|required|accepted',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -384,24 +386,12 @@ class ServerRepository
|
||||||
$resetDaemonKey = true;
|
$resetDaemonKey = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Server Owner if it was passed.
|
|
||||||
if (isset($data['owner_id']) && (int) $data['owner_id'] !== $server->user->id) {
|
|
||||||
$server->owner_id = $data['owner_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Server Name if it was passed.
|
|
||||||
if (isset($data['name'])) {
|
|
||||||
$server->name = $data['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save our changes
|
// Save our changes
|
||||||
$server->save();
|
$server->fill($data)->save();
|
||||||
|
|
||||||
// Do we need to update? If not, return successful.
|
// Do we need to update? If not, return successful.
|
||||||
if (! $resetDaemonKey) {
|
if (! $resetDaemonKey) {
|
||||||
DB::commit();
|
return DB::commit();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $server->node->guzzleClient([
|
$res = $server->node->guzzleClient([
|
||||||
|
@ -418,16 +408,13 @@ class ServerRepository
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($res->getStatusCode() === 204) {
|
if ($res->getStatusCode() === 204) {
|
||||||
DB::commit();
|
return DB::commit();
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
throw new DisplayException('Daemon returned a a non HTTP/204 error code. HTTP/' + $res->getStatusCode());
|
throw new DisplayException('Daemon returned a a non HTTP/204 error code. HTTP/' + $res->getStatusCode());
|
||||||
}
|
}
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
Log::error($ex);
|
throw $ex;
|
||||||
throw new DisplayException('An error occured while attempting to update this server\'s information.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddServerDescriptionColumn extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->text('description')->after('name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('description');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -280,3 +280,12 @@ span[aria-labelledby="select2-pUserId-container"] {
|
||||||
.strong {
|
.strong {
|
||||||
font-weight: bold !important;
|
font-weight: bold !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.server-description > td {
|
||||||
|
padding-top: 0 !important;
|
||||||
|
border-top: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:hover + tr.server-description {
|
||||||
|
background-color: #f5f5f5 !important;
|
||||||
|
}
|
||||||
|
|
|
@ -41,14 +41,21 @@
|
||||||
<h3 class="box-title">Core Details</h3>
|
<h3 class="box-title">Core Details</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body row">
|
<div class="box-body row">
|
||||||
<div class="form-group col-sm-6">
|
<div class="col-md-6">
|
||||||
<label for="pName">Server Name</label>
|
<div class="form-group">
|
||||||
<input type="text" class="form-control" id="pName" name="name" value="{{ old('name') }}" placeholder="Server Name">
|
<label for="pName">Server Name</label>
|
||||||
<p class="small text-muted no-margin">Character limits: <code>a-z A-Z 0-9 _ - .</code> and <code>[Space]</code> (max 200 characters).</p>
|
<input type="text" class="form-control" id="pName" name="name" value="{{ old('name') }}" placeholder="Server Name">
|
||||||
|
<p class="small text-muted no-margin">Character limits: <code>a-z A-Z 0-9 _ - .</code> and <code>[Space]</code> (max 200 characters).</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pUserId">Server Owner</label>
|
||||||
|
<select class="form-control" style="padding-left:0;" name="user_id" id="pUserId"></select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="pUserId">Server Owner</label>
|
<label for="description" class="control-label">Server Description</label>
|
||||||
<select class="form-control" style="padding-left:0;" name="user_id" id="pUserId"></select>
|
<textarea name="description" rows="3" class="form-control">{{ old('description') }}</textarea>
|
||||||
|
<p class="text-muted small">A brief description of this server.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -71,6 +71,11 @@
|
||||||
</select>
|
</select>
|
||||||
<p class="text-muted small">You can change the owner of this server by changing this field to an email matching another use on this system. If you do this a new daemon security token will be generated automatically.</p>
|
<p class="text-muted small">You can change the owner of this server by changing this field to an email matching another use on this system. If you do this a new daemon security token will be generated automatically.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description" class="control-label">Server Description</label>
|
||||||
|
<textarea name="description" rows="3" class="form-control">{{ old('description', $server->description) }}</textarea>
|
||||||
|
<p class="text-muted small">A brief description of this server.</p>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name" class="control-label">Daemon Secret Token</label>
|
<label for="name" class="control-label">Daemon Secret Token</label>
|
||||||
<input type="text" disabled value="{{ $server->daemonSecret }}" class="form-control" />
|
<input type="text" disabled value="{{ $server->daemonSecret }}" class="form-control" />
|
||||||
|
|
|
@ -60,30 +60,35 @@
|
||||||
<th class="text-center">@lang('strings.status')</th>
|
<th class="text-center">@lang('strings.status')</th>
|
||||||
</tr>
|
</tr>
|
||||||
@foreach($servers as $server)
|
@foreach($servers as $server)
|
||||||
<tr class="dynamic-update" data-server="{{ $server->uuidShort }}">
|
<tr class="dynamic-update" data-server="{{ $server->uuidShort }}">
|
||||||
<td><code>{{ $server->uuidShort }}</code></td>
|
<td @if(! empty($server->description)) rowspan="2" @endif><code>{{ $server->uuidShort }}</code></td>
|
||||||
<td><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></td>
|
<td><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></td>
|
||||||
<td>{{ $server->node->name }}</td>
|
<td>{{ $server->node->name }}</td>
|
||||||
<td><code>{{ $server->allocation->alias }}:{{ $server->allocation->port }}</code></td>
|
<td><code>{{ $server->allocation->alias }}:{{ $server->allocation->port }}</code></td>
|
||||||
<td class="text-center hidden-sm hidden-xs"><span data-action="memory">--</span> / {{ $server->memory === 0 ? '∞' : $server->memory }} MB</td>
|
<td class="text-center hidden-sm hidden-xs"><span data-action="memory">--</span> / {{ $server->memory === 0 ? '∞' : $server->memory }} MB</td>
|
||||||
<td class="text-center hidden-sm hidden-xs"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">--</span> %</td>
|
<td class="text-center hidden-sm hidden-xs"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">--</span> %</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
@if($server->user->id === Auth::user()->id)
|
@if($server->user->id === Auth::user()->id)
|
||||||
<span class="label bg-purple">@lang('strings.owner')</span>
|
<span class="label bg-purple">@lang('strings.owner')</span>
|
||||||
@elseif(Auth::user()->isRootAdmin())
|
@elseif(Auth::user()->isRootAdmin())
|
||||||
<span class="label bg-maroon">@lang('strings.admin')</span>
|
<span class="label bg-maroon">@lang('strings.admin')</span>
|
||||||
@else
|
@else
|
||||||
<span class="label bg-blue">@lang('strings.subuser')</span>
|
<span class="label bg-blue">@lang('strings.subuser')</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center" data-action="status">
|
<td class="text-center" data-action="status">
|
||||||
@if($server->suspended === 1)
|
@if($server->suspended === 1)
|
||||||
<span class="label label-warning">@lang('strings.suspended')</span>
|
<span class="label label-warning">@lang('strings.suspended')</span>
|
||||||
@else
|
@else
|
||||||
<span class="label label-default"><i class="fa fa-refresh fa-fw fa-spin"></i></span>
|
<span class="label label-default"><i class="fa fa-refresh fa-fw fa-spin"></i></span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@if (! empty($server->description))
|
||||||
|
<tr class="server-description">
|
||||||
|
<td colspan="7"><p class="text-muted small no-margin">{{ str_limit($server->description, 400) }}</p></td>
|
||||||
|
</tr>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -100,5 +105,12 @@
|
||||||
|
|
||||||
@section('footer-scripts')
|
@section('footer-scripts')
|
||||||
@parent
|
@parent
|
||||||
|
<script>
|
||||||
|
$('tr.server-description').on('mouseenter mouseleave', function (event) {
|
||||||
|
$(this).prev('tr').css({
|
||||||
|
'background-color': (event.type === 'mouseenter') ? '#f5f5f5' : '',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{!! Theme::js('js/frontend/serverlist.js') !!}
|
{!! Theme::js('js/frontend/serverlist.js') !!}
|
||||||
@endsection
|
@endsection
|
||||||
|
|
Loading…
Reference in a new issue