mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 03:46:30 +01:00
Major speedup on Dashboard (latest pages using Flex)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
## mm/dd/2019
|
||||
|
||||
1. [](#improved)
|
||||
* Optimize admin for speed (only load frontend pages on demand)
|
||||
* Optimized admin for speed (only load frontend pages on demand)
|
||||
|
||||
# v1.10.0-beta.5
|
||||
## 08/11/2019
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Grav\Plugin\Admin;
|
||||
|
||||
use DateTime;
|
||||
use Grav\Common\Cache;
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Data;
|
||||
use Grav\Common\File\CompiledYamlFile;
|
||||
use Grav\Common\GPM\GPM;
|
||||
@@ -26,6 +27,7 @@ use Grav\Common\User\Interfaces\UserCollectionInterface;
|
||||
use Grav\Common\User\User;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Framework\Collection\ArrayCollection;
|
||||
use Grav\Framework\Flex\Flex;
|
||||
use Grav\Framework\Route\Route;
|
||||
use Grav\Framework\Route\RouteFactory;
|
||||
use Grav\Plugin\Login\Login;
|
||||
@@ -1157,6 +1159,15 @@ class Admin
|
||||
*/
|
||||
public function latestPages($count = 10)
|
||||
{
|
||||
/** @var Config $config */
|
||||
$config = $this->grav['config'];
|
||||
if ($config->get('system.pages.type') === 'flex') {
|
||||
/** @var Flex $flex */
|
||||
$flex = $this->grav['flex_objects'];
|
||||
$directory = $flex ? $flex->getDirectory('grav-pages') : null;
|
||||
return $directory ? $directory->getIndex()->sort(['timestamp' => 'DESC'])->slice(0, $count) : [];
|
||||
}
|
||||
|
||||
$pages = static::enablePages();
|
||||
|
||||
$latest = [];
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
<h1>{{ "PLUGIN_ADMIN.LATEST_PAGE_UPDATES"|tu }}</h1>
|
||||
<table>
|
||||
{% for latest in admin.latestPages if admin.latestPages %}
|
||||
{% set route = latest.rawRoute %}
|
||||
<tr>
|
||||
<td class="triple page-title">
|
||||
<a href="{{ base_url }}/pages/{{ latest.route|trim('/') }}"><i class="fa fa-fw fa-file-text-o"></i> {{ latest.title|e }}</a></td>
|
||||
<td class="triple page-route">{{ latest.route }}</td><td>{{ latest.modified|adminNicetime }}</td>
|
||||
<a href="{{ base_url }}/pages/{{ route|trim('/') }}"><i class="fa fa-fw fa-file-text-o"></i> {{ latest.title|e }}</a></td>
|
||||
<td class="triple page-route">{{ route }}</td><td>{{ latest.modified|adminNicetime }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user