From 6f2fcabf2279e39a320d4883ef60a5601a8439d3 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 26 May 2018 23:17:02 -0700 Subject: [PATCH] Add very basic server search and dynamic rendering functionality --- .../Controllers/Base/DashboardController.php | 54 +++++++++++ resources/assets/scripts/app.js | 11 ++- .../assets/scripts/components/base/Base.vue | 0 .../scripts/components/dashboard/Account.vue | 13 +++ .../components/dashboard/Dashboard.vue | 94 +++++++++++++++++++ .../pterodactyl/templates/base/core.blade.php | 42 +-------- routes/base.php | 1 + 7 files changed, 169 insertions(+), 46 deletions(-) create mode 100644 app/Http/Controllers/Base/DashboardController.php delete mode 100644 resources/assets/scripts/components/base/Base.vue create mode 100644 resources/assets/scripts/components/dashboard/Account.vue create mode 100644 resources/assets/scripts/components/dashboard/Dashboard.vue diff --git a/app/Http/Controllers/Base/DashboardController.php b/app/Http/Controllers/Base/DashboardController.php new file mode 100644 index 000000000..8351b037a --- /dev/null +++ b/app/Http/Controllers/Base/DashboardController.php @@ -0,0 +1,54 @@ +repository = $repository; + } + + public function servers(Request $request) + { + $servers = $this->repository->setSearchTerm($request->input('query'))->filterUserAccessServers( + $request->user(), User::FILTER_LEVEL_ALL + ); + + $data = []; + foreach ($servers->items() as $server) { + $cleaned = collect($server)->only([ + 'uuidShort', + 'uuid', + 'name', + 'cpu', + 'memory', + ]); + + $data[] = array_merge($cleaned->toArray(), [ + 'allocation' => [ + 'ip' => $server->allocation->ip, + 'port' => $server->allocation->port, + ], + 'node_name' => $server->node->name, + ]); + } + + return response()->json($data); + } +} diff --git a/resources/assets/scripts/app.js b/resources/assets/scripts/app.js index 2581626f5..15fb4af18 100644 --- a/resources/assets/scripts/app.js +++ b/resources/assets/scripts/app.js @@ -10,7 +10,8 @@ import { flash } from './mixins/flash'; // Base Vuejs Templates import Login from './components/auth/Login'; -import Base from './components/base/Base'; +import Dashboard from './components/dashboard/Dashboard'; +import Account from './components/dashboard/Account'; import ResetPassword from './components/auth/ResetPassword'; window.events = new Vue; @@ -45,10 +46,10 @@ const router = new VueRouter({ return { token: route.params.token, email: route.query.email || '' }; } }, - { name : 'index', path: '/', component: Base }, - { name : 'account', path: '/account', component: Base }, - { name : 'account-api', path: '/account/api', component: Base }, - { name : 'account-security', path: '/account/security', component: Base }, + { name : 'index', path: '/', component: Dashboard }, + { name : 'account', path: '/account', component: Account }, + { name : 'account-api', path: '/account/api', component: Account }, + { name : 'account-security', path: '/account/security', component: Account }, ] }); diff --git a/resources/assets/scripts/components/base/Base.vue b/resources/assets/scripts/components/base/Base.vue deleted file mode 100644 index e69de29bb..000000000 diff --git a/resources/assets/scripts/components/dashboard/Account.vue b/resources/assets/scripts/components/dashboard/Account.vue new file mode 100644 index 000000000..281ce77b9 --- /dev/null +++ b/resources/assets/scripts/components/dashboard/Account.vue @@ -0,0 +1,13 @@ + + + + + diff --git a/resources/assets/scripts/components/dashboard/Dashboard.vue b/resources/assets/scripts/components/dashboard/Dashboard.vue new file mode 100644 index 000000000..1da8cf667 --- /dev/null +++ b/resources/assets/scripts/components/dashboard/Dashboard.vue @@ -0,0 +1,94 @@ + + + diff --git a/resources/themes/pterodactyl/templates/base/core.blade.php b/resources/themes/pterodactyl/templates/base/core.blade.php index 353d1f3d3..b9ad7ebb3 100644 --- a/resources/themes/pterodactyl/templates/base/core.blade.php +++ b/resources/themes/pterodactyl/templates/base/core.blade.php @@ -33,47 +33,7 @@ @endsection @section('container') - -
- @foreach($servers as $server) -
-
-
-
-
-
-
{{ $server->name }}
-
-
-
-
CPU
-
-
-
Memory
-
-
-
-
- {{ rand(1, 200) }} - % -
-
- {{ rand(128, 2048) }} - Mb -
-
-
-
-

{{ $server->node->name }}

-

{{ $server->allocation->ip }}:{{ $server->allocation->port }}

-
-
-
-
- @endforeach -
+

{!! trans('strings.copyright', ['year' => date('Y')]) !!} diff --git a/routes/base.php b/routes/base.php index 88058345f..3c2a67829 100644 --- a/routes/base.php +++ b/routes/base.php @@ -7,6 +7,7 @@ * https://opensource.org/licenses/MIT */ Route::get('/', 'IndexController@index')->name('index'); +Route::get('/dashboard/servers', 'DashboardController@servers')->name('dashboard.servers'); Route::get('/status/{server}', 'IndexController@status')->name('index.status'); /*