Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettify rendering of deserialized events and messages #140

Merged
8 commits merged into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ccscan-frontend",
"description": "CCDScan frontend",
"version": "1.5.19",
"version": "1.5.20",
"engine": "16",
"type": "module",
"private": true,
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,3 @@ body {
border: 1px solid #787594;
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.2);
}

.deserialized-message {
white-space: pre-line;
max-width: 775px;
overflow-wrap: break-word;

@media screen and (max-width: 900px) {
max-width: 240px;
}
}
10 changes: 9 additions & 1 deletion frontend/src/components/Details/Logs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
</div>
<template v-if="events?.nodes?.length">
<div v-for="(event, i) in events.nodes" :key="i" class="flex">
<code class="deserialized-message">
<code class="truncate w-96">
{{ event }}
</code>
<Modal :header-title="'Log'">
<template #body>
<code style="text-align: left">
<pre>{{ JSON.stringify(JSON.parse(event), null, 2) }}</pre>
</code>
</template>
</Modal>
<TextCopy
:text="event"
label="Click to copy events logs to clipboard"
Expand All @@ -21,6 +28,7 @@
import { Maybe, StringConnection } from '../../types/generated'
import TextCopy from '../../components/atoms/TextCopy.vue'
import InfoTooltip from '../atoms/InfoTooltip.vue'
import Modal from './Modal.vue'

type Props = {
events?: Maybe<StringConnection>
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/Details/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
<InfoTooltip text="Input parameters given to activity entrypoint." />
</div>
<div class="flex">
<code class="deserialized-message">
<code class="truncate w-96">
{{ message }}
</code>
<Modal :header-title="'Message'">
<template #body>
<code style="text-align: left">
<pre>{{ JSON.stringify(JSON.parse(message), null, 2) }}</pre>
</code>
</template>
</Modal>
<TextCopy
v-if="message"
:text="message"
Expand All @@ -19,6 +26,7 @@
<script lang="ts" setup>
import InfoTooltip from '../atoms/InfoTooltip.vue'
import TextCopy from '../atoms/TextCopy.vue'
import Modal from './Modal.vue'

type Props = {
message: string
Expand Down
103 changes: 103 additions & 0 deletions frontend/src/components/Details/Modal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<template>
<button
class="transition-colors text-theme-faded hover:text-theme-interactiveHover inline"
style="width: 24px"
@click="toggleModalVisible"
>
<OverlayIcon class="inline align-text-top h-4" />
</button>
<transition name="modal-fade">
<span v-if="isVisible">
<div class="modal-backdrop">
<div class="modal">
<header class="modal-header">
<h3 class="text-2xl">
{{ props.headerTitle }}
</h3>
<button type="button" @click="closeModal">
<XIcon class="h-6" />
</button>
</header>
<section class="modal-body">
<slot name="body" />
</section>
</div>
</div>
</span>
</transition>
</template>
<script setup lang="ts">
import { XIcon } from '@heroicons/vue/solid'
import OverlayIcon from '../icons/OverlayIcon.vue'

type Props = {
headerTitle: string
}
const props = defineProps<Props>()

const isVisible = ref(false)
const toggleModalVisible = () => {
isVisible.value = !isVisible.value
}
const closeModal = () => {
isVisible.value = false
}
</script>
<style>
.modal-body pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}

.modal-backdrop {
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 100;
background-color: rgba(0, 0, 0, 0.8);
position: fixed;
display: flex;
justify-content: center;
align-items: center;
}

.modal {
background-color: var(--color-background-elevated-nontrans);
width: 1000px;
height: 90%;
border-radius: 16px;
box-shadow: 0px 0px 50px 0px rgba(0, 0, 0, 0.5);
overflow-x: auto;
display: flex;
flex-direction: column;
}

.modal-header {
display: flex;
flex-direction: row;
padding: 30px;
justify-content: space-between;

@media screen and (max-width: 640px) {
padding: 20px;
}
}

.modal-body {
height: 76vh;
overflow-x: hidden;
overflow-y: scroll;
color: #4aae9b;
padding: 0 40px 40px;

@media screen and (max-width: 640px) {
padding: 0 10px 10px;
}
}
</style>
Empty file.
12 changes: 12 additions & 0 deletions frontend/src/components/icons/ArrowsPointingOut.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="w-5 h-5"
>
<path
d="M13.28 7.78l3.22-3.22v2.69a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h2.69l-3.22 3.22a.75.75 0 001.06 1.06zM2 17.25v-4.5a.75.75 0 011.5 0v2.69l3.22-3.22a.75.75 0 011.06 1.06L4.56 16.5h2.69a.75.75 0 010 1.5h-4.5a.747.747 0 01-.75-.75zM12.22 13.28l3.22 3.22h-2.69a.75.75 0 000 1.5h4.5a.747.747 0 00.75-.75v-4.5a.75.75 0 00-1.5 0v2.69l-3.22-3.22a.75.75 0 10-1.06 1.06zM3.5 4.56l3.22 3.22a.75.75 0 001.06-1.06L4.56 3.5h2.69a.75.75 0 000-1.5h-4.5a.75.75 0 00-.75.75v4.5a.75.75 0 001.5 0V4.56z"
/>
</svg>
</template>
24 changes: 24 additions & 0 deletions frontend/src/components/icons/OverlayIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<SVG
stroke="currentColor"
fill="currentColor"
stroke-width="1"
viewBox="0 0 24 24"
height="100%"
width="100%"
>
<rect x="6.40778" y="0.602356" width="14" height="14" rx="2" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M7.74111 5.60236C7.74111 5.32621 7.96497 5.10236 8.24111 5.10236H9.90777C10.1839 5.10236 10.4078 5.32621 10.4078 5.60236C10.4078 5.8785 10.1839 6.10236 9.90777 6.10236H8.24111C7.96497 6.10236 7.74111 5.8785 7.74111 5.60236ZM12.0744 5.60236C12.0744 5.32621 12.2983 5.10236 12.5744 5.10236H13.4078C13.7458 5.10236 14.0694 5.16973 14.3649 5.29225C14.62 5.39803 14.741 5.69056 14.6352 5.94564C14.5294 6.20072 14.2369 6.32176 13.9818 6.21598C13.8057 6.14293 13.6121 6.10236 13.4078 6.10236H12.5744C12.2983 6.10236 12.0744 5.8785 12.0744 5.60236ZM15.0645 6.37492C15.3196 6.26914 15.6121 6.39017 15.7179 6.64525C15.8404 6.94072 15.9078 7.2643 15.9078 7.60236V8.43569C15.9078 8.71183 15.6839 8.93569 15.4078 8.93569C15.1316 8.93569 14.9078 8.71183 14.9078 8.43569V7.60236C14.9078 7.39805 14.8672 7.20448 14.7942 7.02831C14.6884 6.77323 14.8094 6.48069 15.0645 6.37492ZM15.4078 10.6024C15.6839 10.6024 15.9078 10.8262 15.9078 11.1024V12.769C15.9078 13.0452 15.6839 13.269 15.4078 13.269C15.1316 13.269 14.9078 13.0452 14.9078 12.769V11.1024C14.9078 10.8262 15.1316 10.6024 15.4078 10.6024Z"
/>
<path
d="M6.40778 5.10236H3.40778C2.02706 5.10236 0.907776 6.22164 0.907776 7.60236V17.6024C0.907776 18.9831 2.02706 20.1024 3.40778 20.1024H13.4078C14.7885 20.1024 15.9078 18.9831 15.9078 17.6024V14.6024H14.9078V17.6024C14.9078 18.4308 14.2362 19.1024 13.4078 19.1024H3.40778C2.57935 19.1024 1.90778 18.4308 1.90778 17.6024V7.60236C1.90778 6.77393 2.57935 6.10236 3.40778 6.10236H6.40778V5.10236Z"
/>
</SVG>
</template>

<script lang="ts" setup>
import SVG from '~/components/atoms/SVG.vue'
</script>