add admin actions: remove cache, export configuration
This commit is contained in:
parent
731d4f826b
commit
5e894f9f08
|
@ -24,5 +24,7 @@ return [
|
||||||
['name' => 'Js#config', 'url' => '/js/config', 'verb' => 'GET'],
|
['name' => 'Js#config', 'url' => '/js/config', 'verb' => 'GET'],
|
||||||
['name' => 'Nav#items', 'url' => '/nav/items', 'verb' => 'GET'],
|
['name' => 'Nav#items', 'url' => '/nav/items', 'verb' => 'GET'],
|
||||||
['name' => 'PersonalSetting#valueSet', 'url' => '/personalSetting/valueSet', 'verb' => 'POST'],
|
['name' => 'PersonalSetting#valueSet', 'url' => '/personalSetting/valueSet', 'verb' => 'POST'],
|
||||||
|
['name' => 'AdminSetting#removeCache', 'url' => '/admin/cache/remove', 'verb' => 'GET'],
|
||||||
|
['name' => 'AdminSetting#exportConfiguration', 'url' => '/admin/config/export', 'verb' => 'GET'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
92
lib/Controller/AdminSettingController.php
Normal file
92
lib/Controller/AdminSettingController.php
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\SideMenu\Controller;
|
||||||
|
|
||||||
|
use OCA\SideMenu\AppInfo\Application;
|
||||||
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\AppFramework\Http\DataDownloadResponse;
|
||||||
|
use OCP\AppFramework\Http\RedirectResponse;
|
||||||
|
use OCP\AppFramework\Http\Response;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IRequest;
|
||||||
|
use OCP\IURLGenerator;
|
||||||
|
|
||||||
|
class AdminSettingController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var IConfig
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IURLGenerator
|
||||||
|
*/
|
||||||
|
protected $urlGenerator;
|
||||||
|
|
||||||
|
public function __construct($appName, IRequest $request, IConfig $config, IURLGenerator $urlGenerator)
|
||||||
|
{
|
||||||
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
|
$this->config = $config;
|
||||||
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*
|
||||||
|
* @return RedirectResponse
|
||||||
|
*/
|
||||||
|
public function removeCache()
|
||||||
|
{
|
||||||
|
$this->config->setAppValue(Application::APP_ID, 'cache-categories', '[]');
|
||||||
|
|
||||||
|
return new RedirectResponse($this->urlGenerator->linkToRoute('settings.AdminSettings.index', [
|
||||||
|
'section' => Application::APP_ID,
|
||||||
|
]).'#more');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function exportConfiguration()
|
||||||
|
{
|
||||||
|
$keys = $this->config->getAppKeys(Application::APP_ID);
|
||||||
|
$config = [];
|
||||||
|
$excludedKeys = [
|
||||||
|
'cache',
|
||||||
|
'cache-categories',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
if (in_array($key, $excludedKeys)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config[$key] = $this->config->getAppValue(Application::APP_ID, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DataDownloadResponse(
|
||||||
|
json_encode($config, JSON_PRETTY_PRINT),
|
||||||
|
'config.json',
|
||||||
|
'text/json'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,3 +59,5 @@
|
||||||
"Use the avatar instead of the logo": "Verwenden Sie den Avatar anstelle des Logos"
|
"Use the avatar instead of the logo": "Verwenden Sie den Avatar anstelle des Logos"
|
||||||
"You do not have permission to change the settings.": "Sie haben keine Berechtigung zum Ändern der Einstellungen."
|
"You do not have permission to change the settings.": "Sie haben keine Berechtigung zum Ändern der Einstellungen."
|
||||||
"Force this configuration to users": "Erzwingen Sie diese Konfiguration für Benutzer"
|
"Force this configuration to users": "Erzwingen Sie diese Konfiguration für Benutzer"
|
||||||
|
"Export the configuration": "Exportieren Sie die Konfiguration"
|
||||||
|
"Remove the cache": "Entfernen Sie den Cache"
|
||||||
|
|
|
@ -59,3 +59,5 @@
|
||||||
"Use the avatar instead of the logo": "Utiliser l'avatar à la place du logo"
|
"Use the avatar instead of the logo": "Utiliser l'avatar à la place du logo"
|
||||||
"You do not have permission to change the settings.": "Vous n'avez pas la permission de changer les paramètres."
|
"You do not have permission to change the settings.": "Vous n'avez pas la permission de changer les paramètres."
|
||||||
"Force this configuration to users": "Forcer cette configuration aux utilisateurs"
|
"Force this configuration to users": "Forcer cette configuration aux utilisateurs"
|
||||||
|
"Export the configuration": "Exporter la configuration"
|
||||||
|
"Remove the cache": "Supprimer le cache"
|
||||||
|
|
|
@ -16,9 +16,16 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use OCP\IURLGenerator;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCA\SideMenu\AppInfo\Application;
|
||||||
|
|
||||||
script('side_menu', 'admin');
|
script('side_menu', 'admin');
|
||||||
style('side_menu', 'admin');
|
style('side_menu', 'admin');
|
||||||
|
|
||||||
|
$urlGenerator = \OC::$server[IURLGenerator::class];
|
||||||
|
$cacheSize = floor(mb_strlen(\OC::$server[IConfig::class]->getAppValue(Application::APP_ID, 'cache-categories', ''), '8bit') / 1024);
|
||||||
|
|
||||||
$choicesYesNo = [
|
$choicesYesNo = [
|
||||||
'No' => '0',
|
'No' => '0',
|
||||||
'Yes' => '1',
|
'Yes' => '1',
|
||||||
|
@ -30,6 +37,7 @@ $choicesSizes = [
|
||||||
'Normal' => 'normal',
|
'Normal' => 'normal',
|
||||||
'Big' => 'big',
|
'Big' => 'big',
|
||||||
];
|
];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div id="side-menu-section">
|
<div id="side-menu-section">
|
||||||
|
@ -488,9 +496,25 @@ $choicesSizes = [
|
||||||
|
|
||||||
<input type="hidden" id="side-menu-cache" name="cache" value="<?php print_unescaped($_['cache']); ?>" class="side-menu-setting">
|
<input type="hidden" id="side-menu-cache" name="cache" value="<?php print_unescaped($_['cache']); ?>" class="side-menu-setting">
|
||||||
|
|
||||||
<button id="side-menu-save" class="btn btn-primary"><?php p($l->t('Save')); ?></button>
|
<button id="side-menu-save" class="btn btn-info">
|
||||||
|
<?php p($l->t('Save')); ?>
|
||||||
|
</button>
|
||||||
|
|
||||||
<span id="side-menu-message" class="msg"></span>
|
<span id="side-menu-message" class="msg"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section" id="more">
|
||||||
|
<a href="<?php echo $urlGenerator->linkToRoute('side_menu.AdminSetting.exportConfiguration') ?>" target="_blank">
|
||||||
|
<button class="btn btn-primary" >
|
||||||
|
<?php p($l->t('Export the configuration')); ?>
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="<?php echo $urlGenerator->linkToRoute('side_menu.AdminSetting.removeCache') ?>">
|
||||||
|
<button class="btn btn-primary" >
|
||||||
|
<?php p($l->t('Remove the cache')); ?> (<?php echo $cacheSize ?> Kb)
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
<div style="height: 30px"></div>
|
<div style="height: 30px"></div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue