notifications js config

This commit is contained in:
Andy Miller
2019-02-11 14:33:48 -07:00
parent 560edf21f4
commit 7601ad7052
3 changed files with 17 additions and 3 deletions

View File

@@ -563,6 +563,7 @@ class AdminPlugin extends Plugin
$twig->twig_vars['location'] = $this->template;
$twig->twig_vars['base_url_relative_frontend'] = $twig->twig_vars['base_url_relative'] ?: '/';
$twig->twig_vars['admin_route'] = trim($this->admin_route, '/');
$twig->twig_vars['template_route'] = $this->template;
$twig->twig_vars['current_route'] = '/' . $twig->twig_vars['admin_route'] . '/' . $this->template . '/' . $this->route;
$twig->twig_vars['base_url_relative'] = $twig->twig_vars['base_url_simple'] . '/' . $twig->twig_vars['admin_route'];
$twig->twig_vars['current_url'] = rtrim($twig->twig_vars['base_url_relative'] . '/' . $this->template . '/' . $this->route, '/');

View File

@@ -1346,8 +1346,8 @@ class Admin
$timeout = $this->grav['config']->get('system.session.timeout', 1800);
if ($force || !$last_checked || empty($notifications) || (time() - $last_checked > $timeout)) {
$body = Response::get('https://getgrav.org/notifications.json?' . time());
// $body = Response::get('http://localhost/notifications.json?' . time());
// $body = Response::get('https://getgrav.org/notifications.json?' . time());
$body = Response::get('http://localhost/notifications.json?' . time());
$notifications = json_decode($body, true);
// Sort by date

View File

@@ -1,5 +1,15 @@
{% if authorize(['admin.login', 'admin.super']) %}
{% set notifications = (config.plugins.admin.widgets['dashboard-notifications'] or config.plugins.admin.notifications.dashboard or config.plugins.admin.notifications.plugins or config.plugins.admin.notifications.themes) ? 1 : 0 %}
{% switch template_route %}
{% case 'dashboard' %}
{% set notifications_filters = 'feed,dashboard,top' %}
{% case 'plugins' %}
{% set notifications_filters = 'plugins,top' %}
{% case 'themes' %}
{% set notifications_filters = 'themes,top' %}
{% default %}
{% set notifications_filters = 'top' %}
{% endswitch %}
<script type="text/javascript">
window.GravAdmin = window.GravAdmin || {};
window.GravAdmin.config = {
@@ -15,7 +25,10 @@
admin_nonce: '{{ admin.getNonce }}',
language: '{{ grav.user.language|default('en') }}',
pro_enabled: '{{ config.plugins["admin-pro"].enabled }}',
notifications: {{ notifications }},
notifications: {
enabled: {{ notifications }},
filters: '{{ notifications_filters }}'
},
local_notifications: '{{ config.system.local_notifications|default(false) }}',
site: {
delimiter: '{{ config.site.summary.delimiter|default('===') }}'