diff --git a/.gitignore b/.gitignore index 9485e1fe2..921068d4a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,34 @@ package-lock.json # Ignore generated public directory from `winter:mirror public` public +composer.json +plugins/winter/debugbar/.gitignore +plugins/winter/debugbar/icon.png +plugins/winter/debugbar/LICENSE +plugins/winter/debugbar/Plugin.php +plugins/winter/debugbar/README.md +plugins/winter/debugbar/assets/css/debugbar.css +plugins/winter/debugbar/assets/less/debugbar.less +plugins/winter/debugbar/assets/less/vendor.less +plugins/winter/debugbar/classes/JavascriptRenderer.php +plugins/winter/debugbar/classes/ServiceProvider.php +plugins/winter/debugbar/classes/WinterDebugbar.php +plugins/winter/debugbar/collectors/BackendCollector.php +plugins/winter/debugbar/collectors/CmsCollector.php +plugins/winter/debugbar/collectors/ComponentsCollector.php +plugins/winter/debugbar/collectors/ModelsCollector.php +plugins/winter/debugbar/config/config.php +plugins/winter/debugbar/lang/en/lang.php +plugins/winter/debugbar/lang/ru/lang.php +plugins/winter/debugbar/lang/sl/lang.php +plugins/winter/debugbar/middleware/InjectDebugbar.php +plugins/winter/debugbar/middleware/InterpretsAjaxExceptions.php +plugins/winter/debugbar/screenshots/collapsed.png +plugins/winter/debugbar/screenshots/expanded-queries.png +plugins/winter/debugbar/screenshots/expanded-timeline.png +plugins/winter/debugbar/twig/extension/Debug.php +plugins/winter/debugbar/twig/extension/Dump.php +plugins/winter/debugbar/twig/extension/Stopwatch.php +plugins/winter/debugbar/twig/node/StopwatchNode.php +plugins/winter/debugbar/twig/tokenparser/StopwatchTokenParser.php +plugins/winter/debugbar/updates/version.yaml diff --git a/modules/system/controllers/EventLogs.php b/modules/system/controllers/EventLogs.php index 5c870e54d..c0ee5f06e 100644 --- a/modules/system/controllers/EventLogs.php +++ b/modules/system/controllers/EventLogs.php @@ -1,12 +1,13 @@ listRefresh(); } + /** + * Show a popup to ask user his choices about clearing the log + */ + public function index_onClearLog() + { + $config = $this->makeConfig([ + 'fields' => [ + 'message' => [ + 'type' => 'text', + 'label' => 'system::lang.event_log.delete_filtered_search', + 'comment' => 'system::lang.event_log.delete_filtered_search_comment', + 'span' => 'full', + ], + 'date_start' => [ + 'type' => 'datepicker', + 'label' => 'system::lang.event_log.delete_filtered_date_start', + 'span' => 'left', + 'mode' => 'datetime', + ], + 'date_end' => [ + 'type' => 'datepicker', + 'label' => 'system::lang.event_log.delete_filtered_date_end', + 'span' => 'right', + 'mode' => 'datetime', + ], + ], + ]); + $config->model = new EventLog; + + $formWidget = $this->makeWidget('Backend\Widgets\Form', $config); + $formWidget->bindToController(); + + return $this->makePartial('delete_filtered_form', [ + 'formWidget' => $formWidget, + ]); + } + + /** + * Return informations about the log to be cleared + */ + public function index_onClearLogInfos() + { + $message = post('message'); + $dateStart = post('date_start'); + $dateEnd = post('date_end'); + + if (!$message && !$dateStart && !$dateEnd) { + return [ + '#deleteFilteredList' => '', + '#deleteFilteredResults' => '', + ]; + } + + $events = EventLog + ::when($message, fn ($q) => $q->where('message', 'like', '%' . str_replace( + ['\\', '%', '_'], + ['\\\\', '\\%', '\\_'], + $message + ) . '%')) + ->when($dateStart, fn ($q) => $q->where('created_at', '>=', $dateStart)) + ->when($dateEnd, fn ($q) => $q->where('created_at', '<=', $dateEnd)) + ->orderBy('created_at', 'desc') + ->get(); + + $config = $this->makeConfig('~/modules/system/models/eventlog/columns.yaml'); + $config->model = new EventLog; + + $controlList = $this->makeWidget('Backend\Widgets\Lists', $config); + $controlList->bindEvent('list.extendRecords', function ($records) use ($events, $message) { + if ($events->count() > 0) { + return $events; + } + return collect([]); + }); + + $controlList->bindToController(); + + return [ + 'total' => $events->count(), + '#deleteFilteredList' => $controlList->render(), + '#deleteFilteredResults' => Lang::get('system::lang.event_log.delete_filtered_results', [ + 'what' => mb_strtolower(Str::plural(Lang::get('system::lang.event_log.preview_title'), $events->count())), + 'count' => $events->count(), + ]) + ]; + } + + /** + * Delete the filtered events log + */ + public function index_onClearLogDelete() + { + $message = post('message'); + $dateStart = post('date_start'); + $dateEnd = post('date_end'); + $eventLog = new EventLog; + + $eventLog = EventLog + ::when($message, fn ($q) => $q->where('message', 'like', '%' . str_replace( + ['\\', '%', '_'], + ['\\\\', '\\%', '\\_'], + $message + ) . '%')) + ->when($dateStart, fn ($q) => $q->where('created_at', '>=', $dateStart)) + ->when($dateEnd, fn ($q) => $q->where('created_at', '<=', $dateEnd)); + + $events = $eventLog->get(); + $eventLog->delete(); + + Flash::success(Lang::get('system::lang.event_log.delete_filtered_success', [ + 'what' => mb_strtolower(Str::plural(Lang::get('system::lang.event_log.preview_title'), $events->count())), + 'count' => $events->count(), + ])); + return $this->listRefresh(); + } + public function index_onEmptyLog() { EventLog::truncate(); diff --git a/modules/system/controllers/eventlogs/_delete_filtered_form.php b/modules/system/controllers/eventlogs/_delete_filtered_form.php new file mode 100644 index 000000000..9015a2ce7 --- /dev/null +++ b/modules/system/controllers/eventlogs/_delete_filtered_form.php @@ -0,0 +1,118 @@ +
+ 'deleteFiltered']) ?> + + + + + + + +
+ + diff --git a/modules/system/controllers/eventlogs/_list_toolbar.php b/modules/system/controllers/eventlogs/_list_toolbar.php index 4dd78a55c..3b0ee3628 100644 --- a/modules/system/controllers/eventlogs/_list_toolbar.php +++ b/modules/system/controllers/eventlogs/_list_toolbar.php @@ -6,6 +6,15 @@ class="btn btn-primary wn-icon-refresh"> + + + 'Message', 'level' => 'Level', 'preview_title' => 'Event', + 'delete_filtered_confirm' => 'Delete the filtered events?', + 'delete_filtered_date_start' => 'Starting date', + 'delete_filtered_date_end' => 'Ending date', + 'delete_filtered_link' => 'Delete filtered events', + 'delete_filtered_loading' => 'Search for events matching your criteria', + 'delete_filtered_search' => 'Messages containing', + 'delete_filtered_success' => ':count :what successfully deleted', + 'delete_filtered_search_comment' => 'select all event log messages containing the following text', + 'delete_filtered_results' => ':count :what matching your criteria', ], 'request_log' => [ 'hint' => 'This log displays a list of browser requests that may require attention. For example, if a visitor opens a CMS page that cannot be found, a record is created with the status code 404.', diff --git a/modules/system/lang/fr/lang.php b/modules/system/lang/fr/lang.php index 57a25e478..de24d2110 100644 --- a/modules/system/lang/fr/lang.php +++ b/modules/system/lang/fr/lang.php @@ -352,6 +352,15 @@ 'message' => 'Message', 'level' => 'Niveau', 'preview_title' => 'Évènement', + 'delete_filtered_confirm' => 'Supprimer les évènement filtrés?', + 'delete_filtered_date_start' => 'Depuis le', + 'delete_filtered_date_end' => 'Jusqu\'au', + 'delete_filtered_link' => 'Supprimer des évènements', + 'delete_filtered_loading' => 'Recherche des évènements correspondant à vos critères', + 'delete_filtered_search' => 'Message contenant', + 'delete_filtered_success' => ':count :what supprimés avec succès', + 'delete_filtered_search_comment' => 'sélectionner tous les messages du journal des événements contenant le texte suivant', + 'delete_filtered_results' => ':count :what correspondant à votre recherche', ], 'request_log' => [ 'hint' => 'Ce journal affiche une liste de requêtes potentiellement suspectes. Par exemple, si un visiteur ouvre une page introuvable du CMS, une ligne avec le code statut 404 est alors créée.', diff --git a/plugins/hounddd/testbatches b/plugins/hounddd/testbatches new file mode 160000 index 000000000..2fba53232 --- /dev/null +++ b/plugins/hounddd/testbatches @@ -0,0 +1 @@ +Subproject commit 2fba5323263773c47db41a98a463449d8b7dd3d5