Fix #2136 add button to reset the cleanup exception list

This commit is contained in:
Kijin Sung 2023-07-04 22:43:17 +09:00
parent e98ba87f8e
commit d285a90e88
6 changed files with 32 additions and 1 deletions

View file

@ -9,6 +9,7 @@
<action name="procAdminRecompileCacheFile" class="Controllers\Maintenance\CacheReset" />
<action name="dispAdminCleanupList" class="Controllers\Maintenance\Cleanup" />
<action name="procAdminAddCleanupException" class="Controllers\Maintenance\Cleanup" />
<action name="procAdminResetCleanupException" class="Controllers\Maintenance\Cleanup" />
<action name="procAdminCleanupFiles" class="Controllers\Maintenance\Cleanup" />
<!-- Server Env -->
<action name="dispAdminViewServerEnv" class="Controllers\ServerEnv" />

View file

@ -22,6 +22,14 @@ class Cleanup extends Base
$cleanup_list = $this->checkFiles();
Context::set('cleanup_list', $cleanup_list);
// Get current configuration.
$config = ModuleModel::getModuleConfig('admin') ?: new \stdClass;
if (!isset($config->cleanup_exceptions))
{
$config->cleanup_exceptions = [];
}
Context::set('exceptions', $config->cleanup_exceptions);
// Check previous errors.
Context::set('cleanup_errors', $_SESSION['admin_cleanup_errors'] ?? []);
unset($_SESSION['admin_cleanup_errors']);
@ -54,6 +62,16 @@ class Cleanup extends Base
ModuleController::getInstance()->insertModuleConfig('admin', $config);
}
/**
* Reset the exception list.
*/
public function procAdminResetCleanupException()
{
$config = ModuleModel::getModuleConfig('admin') ?: new \stdClass;
$config->cleanup_exceptions = [];
ModuleController::getInstance()->insertModuleConfig('admin', $config);
}
/**
* Cleanup action.
*/

View file

@ -429,6 +429,7 @@ $lang->cmd_cleanup_filetype_file = 'file';
$lang->cmd_cleanup_filetype_directory = 'directory';
$lang->cmd_cleanup_filetype_symlink = 'symbolic link';
$lang->cmd_cleanup_exception = 'Add exception';
$lang->cmd_cleanup_reset_exception = 'Reset exceptions (%d paths)';
$lang->cmd_cleanup_reason = 'Reason to delete';
$lang->cmd_cleanup_reason_deleted = 'Not used anymore';
$lang->cmd_cleanup_reason_deleted_xe = 'This %s was only used in XE';

View file

@ -426,6 +426,7 @@ $lang->cmd_cleanup_filetype_directory = '디렉토리';
$lang->cmd_cleanup_filetype_symlink = '심볼릭 링크';
$lang->cmd_cleanup_reason = '삭제 이유';
$lang->cmd_cleanup_exception = '제외';
$lang->cmd_cleanup_reset_exception = '제외 목록 초기화 (%d개)';
$lang->cmd_cleanup_reason_deleted = '사용하지 않음';
$lang->cmd_cleanup_reason_deleted_xe = 'XE에서 사용하던 %s';
$lang->cmd_cleanup_reason_deleted_xmllang = 'XE에서 사용하던 XML 언어 파일';

View file

@ -65,6 +65,9 @@
</tbody>
</table>
<div class="x_clearfix btnArea">
<div class="x_pull-left">
<button type="button" class="x_btn reset_exception">{sprintf($lang->cmd_cleanup_reset_exception, count($exceptions))}</button>
</div>
<div class="x_pull-right">
<button type="submit" class="x_btn x_btn-primary">{$lang->cmd_delete}</button>
</div>

View file

@ -2,11 +2,18 @@
(function() {
$(function() {
$('.add_cleanup_exception').on('click', function() {
$('.add_cleanup_exception').on('click', function(event) {
event.preventDefault();
const row = $(this).parents('tr');
exec_json('admin.procAdminAddCleanupException', { path: $(this).data('path') }, function() {
row.fadeOut();
});
});
$('.reset_exception').on('click', function(event) {
event.preventDefault();
exec_json('admin.procAdminResetCleanupException', {}, function() {
window.location.reload();
});
})
});
})();