jeroennoten / Laravel-AdminLTE

Easy AdminLTE integration with Laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] Menu permissions list caching?

thomark1 opened this issue · comments

When dealing with a lot of users permissions (LARATRUST package - 150 permissions in my case) and menu custom (with a couple of submenus) filtering -> page load time (TTFB) is increasing significantly (in my case it's 1.5 sec). Is there a way to speed up the filtering process? My menu is looking like this:

[
    'type'         => 'navbar-search',
    'text'         => 'search',
    'topnav_right' => true,
],
[
    'type'         => 'fullscreen-widget',
    'topnav_right' => true,
],
[
    'type'         => 'darkmode-widget',
    'topnav_right' => true,
],
[
    'type' => 'sidebar-menu-search',
    'text' => 'search',
],
[
    'text'          => 'shops',
    'url'           => 'shops',
    'permission'    => ['shops-create', 'shops-read', 'shops-update', 'shops-delete'],
    'icon'          => 'fas fa-fw fa-shopping-cart',
],
[
    'text'          => 'orders',
    'permission'    => ['orders-create', 'orders-read', 'orders-update', 'orders-delete', 'orders-archive-create', 'orders-archive-read', 'orders-archive-update', 'orders-archive-delete'],
    'icon'          => 'fas fa-fw fa-list',
    'submenu'       => [
        [
            'text'          => 'orders',
            'url'           => 'orders',
            'permission'    => ['orders-create', 'orders-read', 'orders-update', 'orders-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-list',
        ],
        [
            'text'          => 'orders-archive',
            'url'           => 'orders-archive',
            'permission'    => ['orders-archive-create', 'orders-archive-read', 'orders-archive-update', 'orders-archive-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-archive',
        ],
    ],
],
[
    'text'          => 'products',
    'permission'    => ['products-create', 'products-read', 'products-update', 'products-delete', 'products-mappings-create', 'products-mappings-read', 'products-mappings-update', 'products-mappings-delete', 'products-clp-create', 'products-clp-read', 'products-clp-update', 'products-clp-delete', 'products-mixingroom-converter-create', 'products-mixingroom-converter-read', 'products-mixingroom-converter-update', 'products-mixingroom-converter-delete', 'products-specific-prices-create', 'products-specific-prices-read', 'products-specific-prices-update', 'products-specific-prices-delete', 'products-specific-prices-mappings-create', 'products-specific-prices-mappings-read', 'products-specific-prices-mappings-update', 'products-specific-prices-mappings-delete', 'products-categories-create', 'products-categories-read', 'products-categories-update', 'products-categories-delete', 'products-manufacturers-create', 'products-manufacturers-read', 'products-manufacturers-update', 'products-manufacturers-delete', 'products-suppliers-create', 'products-suppliers-read', 'products-suppliers-update', 'products-suppliers-delete', 'products-features-create', 'products-features-read', 'products-features-update', 'products-features-delete', 'products-attachments-create', 'products-attachments-read', 'products-attachments-update', 'products-attachments-delete'],
    'icon'          => 'fas fa-fw fa-cubes',
    'submenu'       => [
        [
            'text'          => 'products',
            'url'           => 'products',
            'permission'    => ['products-create', 'products-read', 'products-update', 'products-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-cube',
        ],
        [
            'text'          => 'products-mappings',
            'url'           => 'products_mappings',
            'permission'    => ['products-mappings-create', 'products-mappings-read', 'products-mappings-update', 'products-mappings-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-link',
        ],
        [
            'text'          => 'products-clp',
            'url'           => 'products_clp',
            'permission'    => ['products-clp-create', 'products-clp-read', 'products-clp-update', 'products-clp-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-exclamation-triangle',
        ],
        [
            'text'          => 'products-mixingroom-converter',
            'url'           => 'products_mixingroom_converter',
            'permission'    => ['products-mixingroom-converter-create', 'products-mixingroom-converter-read', 'products-mixingroom-converter-update', 'products-mixingroom-converter-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-tint',
        ],
        [
            'text'          => 'products-specific-prices',
            'url'           => 'products_specific_prices',
            'permission'    => ['products-specific-prices-create', 'products-specific-prices-read', 'products-specific-prices-update', 'products-specific-prices-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-dollar-sign',
        ],
        [
            'text'          => 'products-specific-prices-mappings',
            'url'           => 'products_specific_prices_mappings',
            'permission'    => ['products-specific-prices-mappings-create', 'products-specific-prices-mappings-read', 'products-specific-prices-mappings-update', 'products-specific-prices-mappings-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-link',
        ],
        [
            'text'          => 'products-categories',
            'url'           => 'products_categories',
            'permission'    => ['products-categories-create', 'products-categories-read', 'products-categories-update', 'products-categories-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-project-diagram',
        ],
        [
            'text'          => 'products-manufacturers',
            'url'           => 'products_manufacturers',
            'permission'    => ['products-manufacturers-create', 'products-manufacturers-read', 'products-manufacturers-update', 'products-manufacturers-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-building',
        ],
        [
            'text'          => 'products-suppliers',
            'url'           => 'products_suppliers',
            'permission'    => ['products-suppliers-create', 'products-suppliers-read', 'products-suppliers-update', 'products-suppliers-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-dolly-flatbed',
        ],
        [
            'text'          => 'products-features',
            'url'           => 'products_features',
            'permission'    => ['products-features-create', 'products-features-read', 'products-features-update', 'products-features-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-list-alt',
        ],
        [
            'text'          => 'products-attachments',
            'url'           => 'products_attachments',
            'permission'    => ['products-attachments-create', 'products-attachments-read', 'products-attachments-update', 'products-attachments-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-file',
        ],
    ],
],
[
    'text'          => 'carriers',
    'permission'    => ['carriers-create', 'carriers-read', 'carriers-update', 'carriers-delete', 'countries-create', 'countries-read', 'countries-update', 'countries-delete', 'zones-create', 'zones-read', 'zones-update', 'zones-delete'],
    'icon'          => 'fas fa-fw fa-shipping-fast',
    'submenu'       => [
        [
            'text'          => 'carriers',
            'url'           => 'carriers',
            'permission'    => ['carriers-create', 'carriers-read', 'carriers-update', 'carriers-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-shipping-fast',
        ],
        [
            'text'          => 'countries',
            'url'           => 'countries',
            'permission'    => ['countries-create', 'countries-read', 'countries-update', 'countries-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-flag',
        ],
        [
            'text'          => 'zones',
            'url'           => 'zones',
            'permission'    => ['zones-create', 'zones-read', 'zones-update', 'zones-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-globe',
        ],
    ],
],
[
    'text'          => 'kolorbox',
    'permission'    => ['colors-create', 'colors-read', 'colors-update', 'colors-delete', 'kolorbox-mappings-create', 'kolorbox-mappings-read', 'kolorbox-mappings-update', 'kolorbox-mappings-delete', 'kolorbox-features-create', 'kolorbox-features-read', 'kolorbox-features-update', 'kolorbox-features-delete', 'kolorbox-attachments-create', 'kolorbox-attachments-read', 'kolorbox-attachments-update', 'kolorbox-attachments-delete'],
    'icon'          => 'fas fa-fw fa-swatchbook',
    'submenu'       => [
        [
            'text'          => 'colors',
            'url'           => 'kolorbox',
            'permission'    => ['colors-create', 'colors-read', 'colors-update', 'colors-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-tint',
        ],
        [
            'text'          => 'kolorbox-mappings',
            'url'           => 'kolorbox_mappings',
            'permission'    => ['kolorbox-mappings-create', 'kolorbox-mappings-read', 'kolorbox-mappings-update', 'kolorbox-mappings-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-link',
        ],
        [
            'text'          => 'kolorbox-features',
            'url'           => 'kolorbox_features',
            'permission'    => ['kolorbox-features-create', 'kolorbox-features-read', 'kolorbox-features-update', 'kolorbox-features-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-list-alt',
        ],
        [
            'text'          => 'kolorbox-attachments',
            'url'           => 'kolorbox_attachments',
            'permission'    => ['kolorbox-attachments-create', 'kolorbox-attachments-read', 'kolorbox-attachments-update', 'kolorbox-attachments-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-file',
        ],
    ],
],
[
    'text'          => 'logins',
    'url'           => 'links',
    'permission'    => ['logins-create', 'logins-read', 'logins-update', 'logins-delete'],
    'icon'          => 'fas fa-fw fa-link',
],
[
    'text'          => 'users',
    'permission'    => ['users-create', 'users-read', 'users-update', 'users-delete', 'users-roles-create', 'users-roles-read', 'users-roles-update', 'users-roles-delete', 'users-permissions-create', 'users-permissions-read', 'users-permissions-update', 'users-permissions-delete', 'users-roles-assignment-create', 'users-roles-assignment-read', 'users-roles-assignment-update', 'users-roles-assignment-delete'],
    'icon'          => 'fas fa-fw fa-users',
    'submenu'       => [
        [
            'text'          => 'users',
            'url'           => 'users',
            'permission'    => ['users-create', 'users-read', 'users-update', 'users-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-users',
        ],
        [
            'text'          => 'users-roles',
            'url'           => 'roles',
            'permission'    => ['users-roles-create', 'users-roles-read', 'users-roles-update', 'users-roles-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-user',
            'active'        => [ 'roles', 'roles/*' ],
        ],
        [
            'text'          => 'users-permissions',
            'url'           => 'permissions',
            'permission'    => ['users-permissions-create', 'users-permissions-read', 'users-permissions-update', 'users-permissions-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-lock',
            'active'        => [ 'permissions*' ],
        ],
        [
            'text'          => 'users-roles-assignment',
            'url'           => 'roles-assignment',
            'permission'    => ['users-roles-assignment-create', 'users-roles-assignment-read', 'users-roles-assignment-update', 'users-roles-assignment-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-random',
            'active'        => [ 'roles-assignment*' ],
        ],
    ],
],
[
    'text'          => 'todos',
    'url'           => 'todos',
    'permission'    => ['todos-create', 'todos-read', 'todos-update', 'todos-delete'],
    'icon'          => 'fas fa-fw fa-lightbulb',
],
[
    'text'          => 'tasks',
    'url'           => 'tasks',
    'permission'    => ['tasks-create', 'tasks-read', 'tasks-update', 'tasks-delete'],
    'icon'          => 'fas fa-fw fa-tasks',
],
[
    'text'          => 'languages',
    'url'           => 'languages',
    'permission'    => ['languages-create', 'languages-read', 'languages-update', 'languages-delete'],
    'icon'          => 'fas fa-fw fa-language',
],
[
    'text'          => 'currencies',
    'url'           => 'currencies',
    'permission'    => ['currencies-create', 'currencies-read', 'currencies-update', 'currencies-delete'],
    'icon'          => 'fas fa-fw fa-dollar-sign',
],
[
    'text'          => 'groups',
    'url'           => 'groups',
    'permission'    => ['groups-create', 'groups-read', 'groups-update', 'groups-delete'],
    'icon'          => 'fas fa-fw fa-object-group',
],
[
    'text'          => 'geolocations',
    'url'           => 'geolocations',
    'permission'    => ['geolocations-create', 'geolocations-read', 'geolocations-update', 'geolocations-delete'],
    'icon'          => 'fas fa-fw fa-map-marker',
],
[
    'text'          => 'activities',
    'url'           => 'activities',
    'permission'    => ['activities-create', 'activities-read', 'activities-update', 'activities-delete'],
    'icon'          => 'fas fa-fw fa-history',
],
[
    'text'          => 'translations',
    'url'           => 'translations',
    'permission'    => ['translations-create', 'translations-read', 'translations-update', 'translations-delete'],
    'icon'          => 'fas fa-fw fa-language',
],
[
    'text'          => 'automation',
    'url'           => 'totem',
    'permission'    => ['automation-create', 'automation-read', 'automation-update', 'automation-delete'],
    'icon'          => 'fas fa-fw fa-retweet',
],
[
    'text'          => 'server',
    'icon'          => 'fas fa-fw fa-server',
    'permission'    => ['commands-create', 'commands-read', 'commands-update', 'commands-delete', 'procedures-create', 'procedures-read', 'procedures-update', 'procedures-delete'],
    'submenu'       => [
        [
            'text'          => 'commands',
            'url'           => 'command',
            'permission'    => ['commands-create', 'commands-read', 'commands-update', 'commands-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-terminal',
        ],
        [
            'text'          => 'procedures',
            'url'           => 'procedures',
            'permission'    => ['procedures-create', 'procedures-read', 'procedures-update', 'procedures-delete'],
            'classes'       => 'nav-child-indent',
            'icon'          => 'fas fa-fw fa-random',
        ],
    ],
],
[
    'text'          => 'konsystem',
    'url'           => 'konsystem',
    'permission'    => ['konsystem-create', 'konsystem-read', 'konsystem-update', 'konsystem-delete'],
    'icon'          => 'fas fa-fw fa-building',
],

Hi @thomark1 , I think there is nothing implemented related to this. Some questions:

  1. How do you integrated the Laratrust package?
  2. Could you try the measurements of times without the filter created for the Laratrust package?

First, we need to be sure delay isn't introduced by the Laratrust package. If that's not the case, then with your help, we may try to track down what logic is actually consuming most of the time and try to make some improvements for the future. The menu building procedure starts on the call to registerMenu() in the src/AdminLteServiceProvider.php file, and follows with a call to the add() method of the file src/Menu/Builder.php.

No feedback