From edaa270a33d1b8049cfc0a320c118cd7b1b2fc00 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 31 Mar 2017 23:07:19 -0400 Subject: [PATCH] Add server descriptions, closes #338 :pig2: :pig: https://s3.kelp.in/D0n2Z.png --- .../Controllers/Admin/ServersController.php | 2 +- app/Repositories/ServerRepository.php | 25 ++------ ...3_31_221948_AddServerDescriptionColumn.php | 32 ++++++++++ public/themes/pterodactyl/css/pterodactyl.css | 9 +++ .../pterodactyl/admin/servers/new.blade.php | 21 ++++--- .../admin/servers/view/details.blade.php | 5 ++ .../themes/pterodactyl/base/index.blade.php | 60 +++++++++++-------- 7 files changed, 103 insertions(+), 51 deletions(-) create mode 100644 database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 9b239d8b8..07cba84fd 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -251,7 +251,7 @@ class ServersController extends Controller $repo = new ServerRepository; try { $repo->updateDetails($id, $request->intersect([ - 'owner_id', 'name', 'reset_token', + 'owner_id', 'name', 'description', 'reset_token', ])); Alert::success('Server details were successfully updated.')->flash(); diff --git a/app/Repositories/ServerRepository.php b/app/Repositories/ServerRepository.php index 1c6f01904..dc7e5515b 100644 --- a/app/Repositories/ServerRepository.php +++ b/app/Repositories/ServerRepository.php @@ -89,6 +89,7 @@ class ServerRepository $validator = Validator::make($data, [ 'user_id' => 'required|exists:users,id', 'name' => 'required|regex:/^([\w .-]{1,200})$/', + 'description' => 'sometimes|nullable|string', 'memory' => 'required|numeric|min:0', 'swap' => 'required|numeric|min:-1', 'io' => 'required|numeric|min:10|max:1000', @@ -363,6 +364,7 @@ class ServerRepository $validator = Validator::make($data, [ 'owner_id' => 'sometimes|required|integer|exists:users,id', 'name' => 'sometimes|required|regex:([\w .-]{1,200})', + 'description' => 'sometimes|required|string', 'reset_token' => 'sometimes|required|accepted', ]); @@ -384,24 +386,12 @@ class ServerRepository $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 - $server->save(); + $server->fill($data)->save(); // Do we need to update? If not, return successful. if (! $resetDaemonKey) { - DB::commit(); - - return true; + return DB::commit(); } $res = $server->node->guzzleClient([ @@ -418,16 +408,13 @@ class ServerRepository ]); if ($res->getStatusCode() === 204) { - DB::commit(); - - return true; + return DB::commit(); } else { throw new DisplayException('Daemon returned a a non HTTP/204 error code. HTTP/' + $res->getStatusCode()); } } catch (\Exception $ex) { DB::rollBack(); - Log::error($ex); - throw new DisplayException('An error occured while attempting to update this server\'s information.'); + throw $ex; } } diff --git a/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php b/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php new file mode 100644 index 000000000..1e5ce0273 --- /dev/null +++ b/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php @@ -0,0 +1,32 @@ +text('description')->after('name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('servers', function (Blueprint $table) { + $table->dropColumn('description'); + }); + } +} diff --git a/public/themes/pterodactyl/css/pterodactyl.css b/public/themes/pterodactyl/css/pterodactyl.css index aca92d909..e0c34798f 100644 --- a/public/themes/pterodactyl/css/pterodactyl.css +++ b/public/themes/pterodactyl/css/pterodactyl.css @@ -280,3 +280,12 @@ span[aria-labelledby="select2-pUserId-container"] { .strong { font-weight: bold !important; } + +.server-description > td { + padding-top: 0 !important; + border-top: 0 !important; +} + +tr:hover + tr.server-description { + background-color: #f5f5f5 !important; +} diff --git a/resources/themes/pterodactyl/admin/servers/new.blade.php b/resources/themes/pterodactyl/admin/servers/new.blade.php index 483831644..733798211 100644 --- a/resources/themes/pterodactyl/admin/servers/new.blade.php +++ b/resources/themes/pterodactyl/admin/servers/new.blade.php @@ -41,14 +41,21 @@

Core Details

-
- - -

Character limits: a-z A-Z 0-9 _ - . and [Space] (max 200 characters).

+
+
+ + +

Character limits: a-z A-Z 0-9 _ - . and [Space] (max 200 characters).

+
+
+ + +
-
- - +
+ + +

A brief description of this server.

diff --git a/resources/themes/pterodactyl/admin/servers/view/details.blade.php b/resources/themes/pterodactyl/admin/servers/view/details.blade.php index e2956d56c..145f540bc 100644 --- a/resources/themes/pterodactyl/admin/servers/view/details.blade.php +++ b/resources/themes/pterodactyl/admin/servers/view/details.blade.php @@ -71,6 +71,11 @@

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.

+
+ + +

A brief description of this server.

+
diff --git a/resources/themes/pterodactyl/base/index.blade.php b/resources/themes/pterodactyl/base/index.blade.php index b7d51e6ce..b127926ff 100644 --- a/resources/themes/pterodactyl/base/index.blade.php +++ b/resources/themes/pterodactyl/base/index.blade.php @@ -60,30 +60,35 @@ @lang('strings.status') @foreach($servers as $server) - - {{ $server->uuidShort }} - {{ $server->name }} - {{ $server->node->name }} - {{ $server->allocation->alias }}:{{ $server->allocation->port }} - -- / {{ $server->memory === 0 ? '∞' : $server->memory }} MB - -- % - - @if($server->user->id === Auth::user()->id) - @lang('strings.owner') - @elseif(Auth::user()->isRootAdmin()) - @lang('strings.admin') - @else - @lang('strings.subuser') - @endif - - - @if($server->suspended === 1) - @lang('strings.suspended') - @else - - @endif - - + + description)) rowspan="2" @endif>{{ $server->uuidShort }} + {{ $server->name }} + {{ $server->node->name }} + {{ $server->allocation->alias }}:{{ $server->allocation->port }} + -- / {{ $server->memory === 0 ? '∞' : $server->memory }} MB + -- % + + @if($server->user->id === Auth::user()->id) + @lang('strings.owner') + @elseif(Auth::user()->isRootAdmin()) + @lang('strings.admin') + @else + @lang('strings.subuser') + @endif + + + @if($server->suspended === 1) + @lang('strings.suspended') + @else + + @endif + + + @if (! empty($server->description)) + +

{{ str_limit($server->description, 400) }}

+ + @endif @endforeach @@ -100,5 +105,12 @@ @section('footer-scripts') @parent + {!! Theme::js('js/frontend/serverlist.js') !!} @endsection