Add button to clear api cache

This commit is contained in:
Timothy Warren 2016-04-21 11:14:21 -04:00
parent 4e48c8c4fa
commit b2990e8457
7 changed files with 63 additions and 0 deletions

View File

@ -142,6 +142,12 @@ return [
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Default / Shared routes // Default / Shared routes
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
'cache_purge' => [
'path' => '/cache_purge',
'action' => 'clear_cache',
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
'verb' => 'get',
],
'login' => [ 'login' => [
'path' => '/login', 'path' => '/login',
'action' => 'login', 'action' => 'login',

3
app/views/blank.php Normal file
View File

@ -0,0 +1,3 @@
<main>
<h1><?= $title ?></h1>
</main>

View File

@ -30,6 +30,13 @@
[<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>] [<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>]
<?php endif ?> <?php endif ?>
</span> </span>
<?php if ($auth->is_authenticated()): ?>
<span class="flex-no-wrap">&nbsp;</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">&nbsp;</span>
<?php endif ?>
<span class="flex-no-wrap small-font"> <span class="flex-no-wrap small-font">
<?php if ($auth->is_authenticated()): ?> <?php if ($auth->is_authenticated()): ?>
<a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a> <a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a>

View File

@ -165,6 +165,17 @@ h1 a {
color: #fff; color: #fff;
} }
.user-btn {
border-color: #12db18;
color: #12db18;
}
.user-btn:hover,
.user-btn:active {
border-color: #db7d12;
background-color: #db7d12;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
CSS loading icon CSS loading icon
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

View File

@ -100,6 +100,15 @@ a:hover, a:active {
color:#fff; 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 CSS loading icon
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

View File

@ -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); })(AnimeClient);

View File

@ -27,6 +27,12 @@ class Controller {
use \Aviat\Ion\Di\ContainerAware; use \Aviat\Ion\Di\ContainerAware;
/**
* Cache manager
* @var \Aviat\Ion\Cache\CacheInterface
*/
protected $cache;
/** /**
* The global configuration object * The global configuration object
* @var object $config * @var object $config
@ -83,6 +89,7 @@ class Controller {
$this->setContainer($container); $this->setContainer($container);
$auraUrlGenerator = $container->get('aura-router')->getGenerator(); $auraUrlGenerator = $container->get('aura-router')->getGenerator();
$urlGenerator = $container->get('url-generator'); $urlGenerator = $container->get('url-generator');
$this->cache = $container->get('cache');
$this->config = $container->get('config'); $this->config = $container->get('config');
$this->request = $container->get('request'); $this->request = $container->get('request');
$this->response = $container->get('response'); $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 * Add a message box to the page
* *