From 5797c4e8991a0d28320f5f0c5f3fcb1034e7fea0 Mon Sep 17 00:00:00 2001 From: Logan Nguyen Date: Thu, 21 Sep 2023 20:41:36 -0500 Subject: [PATCH] update: reworked base64 decoding/encoding UI logic Signed-off-by: Logan Nguyen --- src/components/values/BlobValue.vue | 37 +++++++++++++++++++++-------- src/pages/AccountDetails.vue | 8 +++++-- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/components/values/BlobValue.vue b/src/components/values/BlobValue.vue index 1d9365816..6f3053191 100644 --- a/src/components/values/BlobValue.vue +++ b/src/components/values/BlobValue.vue @@ -31,14 +31,19 @@ :style="{'max-width': windowWidth-limitingFactor + 'px'}">{{ decodedValue }}
{{ decodedValue }}
-
+
{{ decodedValue }}
- +
+ + +
{{ decodedValue }}
@@ -83,10 +88,10 @@ export default defineComponent({ base64Toggler: Function }, - methods: { - base64TogglerFn() { + watch: { + base64OptionSelected(option: string) { if (this.base64Toggler) { - this.base64Toggler() + this.base64Toggler(option) } } }, @@ -94,7 +99,12 @@ export default defineComponent({ setup(props) { const windowWidth = inject('windowWidth', 1280) const isMediumScreen = inject('isMediumScreen', true) + const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; + + type base64OptionsTypes = 'RAW' | 'BASE64_DECODED' + const base64OptionSelected = ref('RAW') + const base64Options = ['RAW', "BASE64_DECODED"] as base64OptionsTypes[] const isURL = computed(() => { let result: boolean @@ -153,6 +163,10 @@ export default defineComponent({ const initialLoading = inject(initialLoadingKey, ref(false)) + const makeBase64OptionLabels = (value: base64OptionsTypes) => { + return value === "RAW" ? "Original data" : "Decoded data" + } + return { isMediumScreen, windowWidth, @@ -161,6 +175,9 @@ export default defineComponent({ decodedValue, initialLoading, isBlobValueBase64candidate, + base64Options, + base64OptionSelected, + makeBase64OptionLabels } } }) diff --git a/src/pages/AccountDetails.vue b/src/pages/AccountDetails.vue index cdbb72a1a..cc0e39dfa 100644 --- a/src/pages/AccountDetails.vue +++ b/src/pages/AccountDetails.vue @@ -485,8 +485,12 @@ export default defineComponent({ // base64 decoding controler // const base64Option = ref(false) - const base64Toggler = () => { - base64Option.value = !base64Option.value + const base64Toggler = (base64SelectedOption: string) => { + if (base64SelectedOption === "RAW") { + base64Option.value = false + } else { + base64Option.value = true + } } return {