From 88ecb2c1f5bc5ec437c48272995fefb19b35b025 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 11 Nov 2023 01:00:58 +0100 Subject: [PATCH 1/3] feat: Allow pasting log entries Signed-off-by: Ferdinand Thiessen --- lib/Constants.php | 23 ++- src/App.vue | 15 ++ src/components/settings/SettingsActions.vue | 13 ++ src/store/logging.spec.ts | 153 +++++++++++++++++--- src/store/logging.ts | 34 ++++- 5 files changed, 210 insertions(+), 28 deletions(-) diff --git a/lib/Constants.php b/lib/Constants.php index b0cc9c99..8e79c27a 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -28,22 +28,41 @@ // !! Keep in sync with src/constants.ts class Constants { + // Used config Keys + /** - * Used AppConfig Keys + * Logging levels to show, used for filtering */ public const CONFIG_KEY_SHOWNLEVELS = 'shownLevels'; + /** + * The backend logging level + */ public const CONFIG_KEY_LOGLEVEL = 'logLevel'; + /** + * Display format of the timestamp + */ public const CONFIG_KEY_DATETIMEFORMAT = 'dateTimeFormat'; + /** + * If relative dates should be shown for the timestamp (e.g. '3 hours ago') + */ public const CONFIG_KEY_RELATIVEDATES = 'relativedates'; + /** + * If automatic updates of the UI are enabled (polling for new entries) + */ public const CONFIG_KEY_LIVELOG = 'liveLog'; + + /** + * All valid config keys + */ public const CONFIG_KEYS = [ self::CONFIG_KEY_SHOWNLEVELS, self::CONFIG_KEY_LOGLEVEL, self::CONFIG_KEY_DATETIMEFORMAT, self::CONFIG_KEY_RELATIVEDATES, - self::CONFIG_KEY_LIVELOG + self::CONFIG_KEY_LIVELOG, ]; + // other constants public const LOGGING_LEVELS = [0, 1, 2, 3, 4]; public const LOGGING_LEVEL_NAMES = [ 'debug', diff --git a/src/App.vue b/src/App.vue index 862a1dab..725fc43b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -81,6 +81,21 @@ const onShowServerLog = () => { loggingStore.loadMore() } +/** + * Handle pressing ctrl + v to paste log entries + * @param event The keyboard event + */ +const onHandlePaste = (event: KeyboardEvent) => { + // Check Ctrl + v (be tolerant: ignore caps lock) and only intercept if target is no input for pasting + if ((event.key === 'v' || event.key === 'V') && event.ctrlKey && (event.target as HTMLElement)?.tagName !== 'INPUT') { + loggingStore.loadClipboard() + event.stopPropagation() + } +} +// Add / remove event listeners +onMounted(() => window.addEventListener('keyup', onHandlePaste)) +onUnmounted(() => window.removeEventListener('keyup', onHandlePaste)) + /** * Toggle polling if live log is dis- / enabled */ diff --git a/src/components/settings/SettingsActions.vue b/src/components/settings/SettingsActions.vue index db234084..c4d899ac 100644 --- a/src/components/settings/SettingsActions.vue +++ b/src/components/settings/SettingsActions.vue @@ -1,5 +1,9 @@