Add button to clear api cache
This commit is contained in:
parent
47b8a83d86
commit
675ccac14d
@ -142,6 +142,12 @@ return [
|
||||
// ---------------------------------------------------------------------
|
||||
// Default / Shared routes
|
||||
// ---------------------------------------------------------------------
|
||||
'cache_purge' => [
|
||||
'path' => '/cache_purge',
|
||||
'action' => 'clear_cache',
|
||||
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'get',
|
||||
],
|
||||
'login' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
|
3
app/views/blank.php
Normal file
3
app/views/blank.php
Normal file
@ -0,0 +1,3 @@
|
||||
<main>
|
||||
<h1><?= $title ?></h1>
|
||||
</main>
|
@ -30,6 +30,13 @@
|
||||
[<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>]
|
||||
<?php endif ?>
|
||||
</span>
|
||||
<?php if ($auth->is_authenticated()): ?>
|
||||
<span class="flex-no-wrap"> </span>
|
||||
<span class="flex-no-wrap small-font">
|
||||
<button type="button" class="js-clear-cache user-btn">Clear API Cache</button>
|
||||
</span>
|
||||
<span class="flex-no-wrap"> </span>
|
||||
<?php endif ?>
|
||||
<span class="flex-no-wrap small-font">
|
||||
<?php if ($auth->is_authenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a>
|
||||
|
@ -165,6 +165,17 @@ h1 a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.user-btn {
|
||||
border-color: #12db18;
|
||||
color: #12db18;
|
||||
}
|
||||
|
||||
.user-btn:hover,
|
||||
.user-btn:active {
|
||||
border-color: #db7d12;
|
||||
background-color: #db7d12;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
CSS loading icon
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -100,6 +100,15 @@ a:hover, a:active {
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
.user-btn {
|
||||
border-color: var(--edit-link-color);
|
||||
color: var(--edit-link-color);
|
||||
}
|
||||
.user-btn:hover, .user-btn:active {
|
||||
border-color: var(--edit-link-hover-color);
|
||||
background-color: var(--edit-link-hover-color);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
CSS loading icon
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -20,4 +20,11 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Clear the api cache
|
||||
ac.on('.js-clear-cache', 'click', function (event) {
|
||||
ac.get('/cache_purge', () => {
|
||||
ac.showMessage('success', `Sucessfully purged api cache`);
|
||||
});
|
||||
});
|
||||
|
||||
})(AnimeClient);
|
@ -27,6 +27,12 @@ class Controller {
|
||||
|
||||
use \Aviat\Ion\Di\ContainerAware;
|
||||
|
||||
/**
|
||||
* Cache manager
|
||||
* @var \Aviat\Ion\Cache\CacheInterface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The global configuration object
|
||||
* @var object $config
|
||||
@ -83,6 +89,7 @@ class Controller {
|
||||
$this->setContainer($container);
|
||||
$auraUrlGenerator = $container->get('aura-router')->getGenerator();
|
||||
$urlGenerator = $container->get('url-generator');
|
||||
$this->cache = $container->get('cache');
|
||||
$this->config = $container->get('config');
|
||||
$this->request = $container->get('request');
|
||||
$this->response = $container->get('response');
|
||||
@ -354,6 +361,19 @@ class Controller {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purges the API cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear_cache()
|
||||
{
|
||||
$this->cache->purge();
|
||||
$this->outputHTML('blank', [
|
||||
'title' => 'Cache cleared'
|
||||
], NULL, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message box to the page
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user