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

feat: actions on log messages #2572

Merged
merged 12 commits into from
Dec 9, 2023
4 changes: 4 additions & 0 deletions assets/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ declare module 'vue' {
BarChart: typeof import('./components/BarChart.vue')['default']
'Carbon:caretDown': typeof import('~icons/carbon/caret-down')['default']
'Carbon:circleSolid': typeof import('~icons/carbon/circle-solid')['default']
'Carbon:copyFile': typeof import('~icons/carbon/copy-file')['default']
'Carbon:information': typeof import('~icons/carbon/information')['default']
'Carbon:macShift': typeof import('~icons/carbon/mac-shift')['default']
'Carbon:play': typeof import('~icons/carbon/play')['default']
'Carbon:restart': typeof import('~icons/carbon/restart')['default']
'Carbon:rowCollapse': typeof import('~icons/carbon/row-collapse')['default']
'Carbon:rowExpand': typeof import('~icons/carbon/row-expand')['default']
'Carbon:star': typeof import('~icons/carbon/star')['default']
'Carbon:starFilled': typeof import('~icons/carbon/star-filled')['default']
'Carbon:stopFilledAlt': typeof import('~icons/carbon/stop-filled-alt')['default']
Expand All @@ -28,6 +31,7 @@ declare module 'vue' {
ContainerStat: typeof import('./components/LogViewer/ContainerStat.vue')['default']
ContainerTable: typeof import('./components/ContainerTable.vue')['default']
ContainerTitle: typeof import('./components/LogViewer/ContainerTitle.vue')['default']
CopyLogMessage: typeof import('./components/LogViewer/CopyLogMessage.vue')['default']
DateTime: typeof import('./components/common/DateTime.vue')['default']
DistanceTime: typeof import('./components/common/DistanceTime.vue')['default']
DockerEventLogItem: typeof import('./components/LogViewer/DockerEventLogItem.vue')['default']
Expand Down
4 changes: 3 additions & 1 deletion assets/components/LogViewer/ComplexLogItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex gap-x-2">
<div class="relative flex gap-x-2">
<div v-if="showStd">
<log-std :std="logEntry.std"></log-std>
</div>
Expand All @@ -22,6 +22,7 @@
</ul>
<field-list :fields="logEntry.unfilteredMessage" :expanded="expanded" :visible-keys="visibleKeys"></field-list>
</div>
<copy-log-message :message="JSON.stringify(logEntry.message)" />
</div>
</template>
<script lang="ts" setup>
Expand All @@ -45,6 +46,7 @@ const validValues = computed(() => {
.text-light {
@apply text-base-content/70;
}

.fields {
&:hover {
akash-ramaswamy marked this conversation as resolved.
Show resolved Hide resolved
&::after {
Expand Down
35 changes: 35 additions & 0 deletions assets/components/LogViewer/CopyLogMessage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<div
class="absolute -right-1 flex min-w-[0.98rem] items-start justify-end align-bottom hover:cursor-pointer"
akash-ramaswamy marked this conversation as resolved.
Show resolved Hide resolved
v-if="message.trim() != ''"
title="Copy Log"
akash-ramaswamy marked this conversation as resolved.
Show resolved Hide resolved
>
<span
class="rounded bg-slate-800/60 px-1.5 py-1 text-primary opacity-0 transition-opacity delay-500 duration-1000 hover:bg-slate-700 group-hover/entry:opacity-100"
akash-ramaswamy marked this conversation as resolved.
Show resolved Hide resolved
@click="copyLogMessageToClipBoard()"
>
<carbon:copy-file />
</span>
</div>
</template>

<script lang="ts" setup>
const { message } = defineProps<{
message: string;
}>();

const { showToast } = useToast();

function copyLogMessageToClipBoard() {
navigator.clipboard.writeText(message);
akash-ramaswamy marked this conversation as resolved.
Show resolved Hide resolved

showToast(
{
title: "Copied",
message: "Log message copied to clipboard",
akash-ramaswamy marked this conversation as resolved.
Show resolved Hide resolved
type: "info",
},
{ expire: 2000 },
);
}
</script>
1 change: 1 addition & 0 deletions assets/components/LogViewer/LogViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:key="item.id"
:data-key="item.id"
:class="{ 'border border-secondary': toRaw(item) === toRaw(lastSelectedItem) }"
class="group/entry"
>
<a
class="jump-context tooltip tooltip-right tooltip-primary"
Expand Down
3 changes: 2 additions & 1 deletion assets/components/LogViewer/SimpleLogItem.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<template>
<div class="flex items-start gap-x-2">
<div class="relative flex w-full items-start gap-x-2">
<log-std :std="logEntry.std" v-if="showStd" />
<log-date :date="logEntry.date" v-if="showTimestamp" />
<log-level class="flex" :level="logEntry.level" :position="logEntry.position" />
<div class="whitespace-pre-wrap group-[.disable-wrap]:whitespace-nowrap" v-html="colorize(logEntry.message)"></div>
<copy-log-message :message="logEntry.message" />
</div>
</template>
<script lang="ts" setup>
Expand Down
Loading