Search in your project where is this Dashboardlayout registered to Vue, and do the same with your Playerlayout component. If you use Vue router or bootstrap.js or app.js or whatever. Seems like the component is not registered at all. Because your index method just returns a JSON response.
Multiple dashboards
Hi!
Have created a laravel8.x / vue.js application
My system use roles and permissions
Try to implement another dashboard, but no luck New dashboard dosent show up (only blank page) ? Dosent get any errors ?
My new dashboard is called player
Here is what i have API-route
<?php
Route::group(['prefix' => 'v1', 'as' => 'api.', 'namespace' => 'Api\V1\Admin', 'middleware' => ['auth:sanctum']], function () {
// Abilities
// Locales
Route::get('locales/languages', 'LocalesController@languages')->name('locales.languages');
Route::get('locales/messages', 'LocalesController@messages')->name('locales.messages');
// Dashboards
Route::get('dashboard', 'DashboardApiController@index')->name('dashboard');
// Dashboard - player
Route::get('player', 'PlayerApiController@index')->name('player');
// Permissions
Route::resource('permissions', 'PermissionsApiController');
// Roles
Route::resource('roles', 'RolesApiController');
// Users
Route::resource('users', 'UsersApiController');
});
My dashboard that are working fine is;
Route::get('dashboard', 'DashboardApiController@index')->name('dashboard');
Dashboard that are not working is:
Route::get('player', 'PlayerApiController@index')->name('player');
My controller for dashboard
<?php
namespace App\Http\Controllers\Api\V1\Admin;
use App\Http\Controllers\Controller;
use App\Services\ChartsService;
use Illuminate\Support\Facades\Auth;
class DashboardApiController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
* Check if user is logged in
*/
public function __construct()
{
$this->middleware(['auth', 'verified']);
}
public function index()
{
$onlineusers = new ChartsService([
'title' => 'Pålogget brukere',
'icongraf' => 'usersonline',
'chart_icon' => 'wc',
'chart_type' => 'latest',
'model' => 'App\Models\User',
'column_class' => 'col-md-12',
'fields' => ['name', 'email'],
'limit' => 5,
'filter_by_field' => 'online',
'filter_by_onlinestatus' => 1,
'filter_by_period' => 'year',
]);
return response()->json(compact('onlineusers'));
}
}
My dashboard for player
<?php
namespace App\Http\Controllers\Api\V1\Admin;
use App\Http\Controllers\Controller;
use App\Services\ChartsService;
use Illuminate\Support\Facades\Auth;
class PlayerApiController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
* Check if user is logged in
*/
public function __construct()
{
$this->middleware(['auth', 'verified']);
}
public function index()
{
$onlineusers = new ChartsService([
'title' => 'TESTING NEW DASHBOARD',
'icongraf' => 'usersonline',
'chart_icon' => 'wc',
'chart_type' => 'latest',
'model' => 'App\Models\User',
'column_class' => 'col-md-12',
'fields' => ['name', 'email'],
'limit' => 5,
'filter_by_field' => 'online',
'filter_by_onlinestatus' => 1,
'filter_by_period' => 'year',
]);
return response()->json(compact('onlineusers'));
}
}
/Pages/Layout/Dashboardlayout.vue
<template>
<div class="wrapper" :class="{ 'nav-open': $sidebar.showSidebar }">
<event-hub></event-hub>
<side-bar :sidebarLinks="sidebarLinks">
<mobile-menu slot="content"></mobile-menu>
</side-bar>
<div class="main-panel">
<top-navbar></top-navbar>
<div class="content">
<dashboard-content></dashboard-content>
</div>
</div>
</div>
</template>
<script>
import DashboardContent from './Content.vue'
import ContentFooter from './ContentFooter.vue'
import TopNavbar from './TopNavbar.vue'
import MobileMenu from './MobileMenu.vue'
export default {
components: {
DashboardContent,
TopNavbar,
ContentFooter,
MobileMenu
},
data() {
return {
sidebarLinks: [
{
title: 'global.dashboard',
icon: 'dashboard',
path: { name: 'dashboard' }
},
{
title: 'cruds.userManagement.title',
icon: 'person',
path: { name: 'user_management' },
gate: 'user_management_access',
children: [
{
title: 'cruds.permission.title',
icon: 'perm_data_setting',
path: { name: 'permissions.index' },
gate: 'permission_access'
},
{
title: 'cruds.role.title',
icon: 'group',
path: { name: 'roles.index' },
gate: 'role_access'
},
{
title: 'cruds.user.title',
icon: 'person',
path: { name: 'users.index' },
gate: 'user_access'
}
]
},
{
title: 'cruds.contentManagement.title',
icon: 'table_view',
path: { name: 'content_management' },
gate: 'content_management_access',
children: [
{
title: 'cruds.contentCategory.title',
icon: 'table_view',
path: { name: 'content_categories.index' },
gate: 'content_category_access'
},
{
title: 'cruds.contentTag.title',
icon: 'table_view',
path: { name: 'content_tags.index' },
gate: 'content_tag_access'
},
{
title: 'cruds.contentPage.title',
icon: 'table_view',
path: { name: 'content_pages.index' },
gate: 'content_page_access'
}
]
},
{
title: 'cruds.amin.title',
icon: 'admin_panel_settings',
path: { name: 'amin' },
gate: 'amin_access',
children: [
{
title: 'cruds.country.title',
icon: 'table_view',
path: { name: 'countries.index' },
gate: 'country_access'
},
{
title: 'cruds.golfclub.title',
icon: 'table_view',
path: { name: 'golfclubs.index' },
gate: 'golfclub_access'
}
]
},
{
title: 'cruds.forbund.title',
icon: 'golf_course',
path: { name: 'forbund' },
gate: 'forbund_access',
children: [
{
title: 'cruds.grad.title',
icon: 'golf_course',
path: { name: 'grads.index' },
gate: 'grad_access'
},
{
title: 'cruds.dommereb.title',
icon: 'golf_course',
path: { name: 'dommerebs.index' },
gate: 'dommereb_access'
}
]
},
{
title: 'cruds.lokaleregler.title',
icon: 'local_library',
path: { name: 'lokalereglers.index' },
gate: 'lokaleregler_access'
},
{
title: 'cruds.walkieTalkie.title',
icon: 'mic',
path: { name: 'walkie_talkies.index' },
gate: 'walkie_talkie_access'
},
{
title: 'cruds.chat.title',
icon: 'chat',
path: { name: 'chats.index' },
gate: 'chat_access'
},
{
title: 'cruds.testing.title',
icon: 'table_view',
path: { name: 'testings.index' },
gate: 'testing_access'
},
{
title: 'cruds.Flightdata.title',
icon: 'table_view',
path: { name: 'Flightdata.index' },
gate: 'Flightdata_access'
},
{
title: 'cruds.gpstrackerclub.title',
icon: 'gps_fixed',
path: { name: 'gpstrackerclubs.index' },
gate: 'gpstrackerclub_access'
},
{
title: 'cruds.golfclubfeedback.title',
icon: 'comment',
path: { name: 'golfclubfeedbacks.index' },
gate: 'golfclubfeedback_access'
},
{
title: 'cruds.investor.title',
icon: 'account_circle',
path: { name: 'investors.index' },
gate: 'investor_access'
},
{
title: 'cruds.turnements.title',
icon: 'sports_golf',
path: { name: 'turnements.index' },
gate: 'turnement_access',
children: [
{
title: 'cruds.turnements.title',
icon: 'comment',
path: { name: 'turnements.index' },
gate: 'turnement_access'
},
{
title: 'cruds.startliste.title',
icon: 'format_list_numbered',
path: { name: 'startlistes.index' },
gate: 'startliste_access'
}
]
},
{
title: 'cruds.configuration.title',
icon: 'table_view',
path: { name: 'configurations.index' },
gate: 'configuration_access'
}
],
}
}
}
</script>
/Pages/Layout/Playerlayout.vue:
<template>
<div class="wrapper" :class="{ 'nav-open': $sidebar.showSidebar }">
<event-hub></event-hub>
<side-bar :sidebarLinks="sidebarLinks">
<mobile-menu slot="content"></mobile-menu>
</side-bar>
<div class="main-panel">
<top-navbar></top-navbar>
<div class="content">
<dashboard-content></dashboard-content>
</div>
</div>
</div>
</template>
<script>
import DashboardContent from './Content.vue'
import TopNavbar from './TopNavbar.vue'
import MobileMenu from './MobileMenu.vue'
export default {
components: {
DashboardContent,
TopNavbar,
MobileMenu
},
data() {
return {
sidebarLinks: [
{
title: 'global.dashboard',
icon: 'dashboard',
path: { name: 'player' }
},
{
title: 'cruds.userManagement.title',
icon: 'person',
path: { name: 'user_management' },
gate: 'user_management_access',
children: [
{
title: 'cruds.permission.title',
icon: 'perm_data_setting',
path: { name: 'permissions.index' },
gate: 'permission_access'
},
{
title: 'cruds.role.title',
icon: 'group',
path: { name: 'roles.index' },
gate: 'role_access'
},
{
title: 'cruds.user.title',
icon: 'person',
path: { name: 'users.index' },
gate: 'user_access'
}
]
},
{
title: 'cruds.contentManagement.title',
icon: 'table_view',
path: { name: 'content_management' },
gate: 'content_management_access',
children: [
{
title: 'cruds.contentCategory.title',
icon: 'table_view',
path: { name: 'content_categories.index' },
gate: 'content_category_access'
},
{
title: 'cruds.contentTag.title',
icon: 'table_view',
path: { name: 'content_tags.index' },
gate: 'content_tag_access'
},
{
title: 'cruds.contentPage.title',
icon: 'table_view',
path: { name: 'content_pages.index' },
gate: 'content_page_access'
}
]
},
{
title: 'cruds.amin.title',
icon: 'admin_panel_settings',
path: { name: 'amin' },
gate: 'amin_access',
children: [
{
title: 'cruds.country.title',
icon: 'table_view',
path: { name: 'countries.index' },
gate: 'country_access'
},
{
title: 'cruds.golfclub.title',
icon: 'table_view',
path: { name: 'golfclubs.index' },
gate: 'golfclub_access'
}
]
},
{
title: 'cruds.forbund.title',
icon: 'golf_course',
path: { name: 'forbund' },
gate: 'forbund_access',
children: [
{
title: 'cruds.grad.title',
icon: 'golf_course',
path: { name: 'grads.index' },
gate: 'grad_access'
},
{
title: 'cruds.dommereb.title',
icon: 'golf_course',
path: { name: 'dommerebs.index' },
gate: 'dommereb_access'
}
]
},
{
title: 'cruds.lokaleregler.title',
icon: 'local_library',
path: { name: 'lokalereglers.index' },
gate: 'lokaleregler_access'
},
{
title: 'cruds.walkieTalkie.title',
icon: 'mic',
path: { name: 'walkie_talkies.index' },
gate: 'walkie_talkie_access'
},
{
title: 'cruds.chat.title',
icon: 'chat',
path: { name: 'chats.index' },
gate: 'chat_access'
},
{
title: 'cruds.testing.title',
icon: 'table_view',
path: { name: 'testings.index' },
gate: 'testing_access'
},
{
title: 'cruds.Flightdata.title',
icon: 'table_view',
path: { name: 'Flightdata.index' },
gate: 'Flightdata_access'
},
{
title: 'cruds.gpstrackerclub.title',
icon: 'gps_fixed',
path: { name: 'gpstrackerclubs.index' },
gate: 'gpstrackerclub_access'
},
{
title: 'cruds.golfclubfeedback.title',
icon: 'comment',
path: { name: 'golfclubfeedbacks.index' },
gate: 'golfclubfeedback_access'
},
{
title: 'cruds.turnement.title',
icon: 'table_view',
path: { name: 'turnement' },
gate: 'turnement_access',
children: [
{
title: 'cruds.turnement.title',
icon: 'comment',
path: { name: 'turnement.index' },
gate: 'turnement_access'
},
{
title: 'cruds.startliste.title',
icon: 'format_list_numbered',
path: { name: 'startlistes.index' },
gate: 'startliste_access'
}
]
},
]
}
}
}
</script>
Is there somthing missing ?
Here is an article that can help: https://nickescobedo.com/1252/easy-way-to-have-multiple-layouts-for-your-vue-js-app
Please or to participate in this conversation.