Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2ad9273
feat: add probe log tab
PavelKopecky Aug 21, 2025
c6b4017
refactor!: add gp api url to nuxt config
PavelKopecky Aug 21, 2025
61d0b81
feat: limit the number of displayed logs
PavelKopecky Aug 21, 2025
1b8e5a3
refactor: improve tab logs code
PavelKopecky Aug 21, 2025
3a63260
fix: handle missing sum data
alexey-yarmosh Aug 28, 2025
a37eee3
Merge branch 'master' into gh-26
MartinKolarik Sep 4, 2025
978aab6
fix: add scope, adjust colors
MartinKolarik Sep 4, 2025
83e2794
feat: store active probe detail tab in URL
PavelKopecky Sep 6, 2025
eaa29d3
refactor: optimize tab logs with debounced scrolling and props usage
PavelKopecky Sep 6, 2025
f7460ff
feat: add LogLoader component with animated loading dots
PavelKopecky Sep 8, 2025
cc27a9a
feat: enhance TabLogs with live tail, improved layout, and refined lo…
PavelKopecky Sep 8, 2025
e0c06cd
refactor: clear debounce on TabLogs unmount
PavelKopecky Sep 8, 2025
b47a8da
refactor: update no probe logs available text
PavelKopecky Sep 8, 2025
ebc675f
fix: pluralize and mono
MartinKolarik Sep 8, 2025
8c7cb9c
refactor: adjust dot-pulse animation duration and delay
PavelKopecky Sep 10, 2025
4ee061f
fix: fetch probe logs by probe id and according to redis ids
PavelKopecky Sep 10, 2025
09c537e
refactor: update tab logs live tail checkbox and fix possible log dup…
PavelKopecky Sep 10, 2025
a4d42fd
refactor: replace debounce with throttle for scroll handling in TabLo…
PavelKopecky Sep 10, 2025
e48c599
fix: adjust styles and improve log handling readability
MartinKolarik Sep 10, 2025
8a5e4f1
fix: improve log display formatting and adjust responsive styles
MartinKolarik Sep 10, 2025
4e01b17
fix: restrict "Logs" tab visibility to admin users
MartinKolarik Sep 11, 2025
0982587
refactor: enable noUncheckedIndexedAccess option (#123)
alexey-yarmosh Aug 29, 2025
b021380
feat: update adoption without API response (#124)
alexey-yarmosh Sep 11, 2025
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
141 changes: 141 additions & 0 deletions components/probe/TabLogs.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<template>
<div
ref="logContainer"
class="relative flex flex-1 flex-col overflow-y-auto rounded-md border bg-surface-100 p-4 font-mono max-lg:p-2 max-md:gap-4 dark:bg-dark-950"
@scroll="autoScroll = false"
@scrollend="onScrollEnd"
>
<div
v-for="(log, index) in logs"
:key="index"
:class="{
'text-rose-600 dark:text-red-400': log.level?.toLowerCase() === 'error',
'text-orange-600 dark:text-yellow-300': log.level?.toLowerCase() === 'warn',
'text-gray-600 dark:text-gray-400': !['error','warn'].includes(log.level?.toLowerCase() || '')
}"
>
<span v-if="log.timestamp">[{{ log.timestamp.toUpperCase() }}] </span>
<span v-if="log.level">[{{ log.level.toUpperCase() }}] </span>
<span class="break-words">{{ log.message }}</span>
</div>
<span v-if="logs.length === 0" class="inset-0 m-auto text-gray-600 dark:text-gray-400">
<span v-if="pending && showLoader">
<span class="pi pi-spinner animate-spin text-2xl dark:text-gray-500"/>
</span>
<span v-else>
No logs available.
</span>
</span>
</div>
</template>

<script setup lang="ts">
import { useErrorToast } from '~/composables/useErrorToast';
const { isActive } = defineProps({
isActive: {
type: Boolean,
default: true,
},
});
const MAX_LOGS = 5000;
const config = useRuntimeConfig();
const route = useRoute();
const probeId = route.params.id as string;
const refreshInterval = ref<NodeJS.Timeout>();
const logContainer = ref<HTMLDivElement | null>(null);
const autoScroll = ref(true);
const logs = ref<ProbeLog[]>([]);
const lastFetched = ref(0);
const showLoader = ref(true);
const { data, refresh, pending, error } = await useLazyAsyncData<ProbeLog[]>(
() => $fetch(`${config.public.gpApiUrl}/v1/probes/${probeId}/logs`, {
params: {
since: lastFetched.value,
},
credentials: 'include',
}),
{
default: () => [],
immediate: false,
},
);
useErrorToast(error);
const refreshLogs = async () => {
return refresh().then(() => {
if (!error.value) {
lastFetched.value = Date.now();
}
}).catch(() => {}) // errors are displayed via useErrorToast
.finally(() => { showLoader.value = !isActive; }); // do not show the loader on further refetches
};
const onScrollEnd = () => {
const scrollHeight = logContainer.value?.scrollHeight ?? 0;
const scrollTop = logContainer.value?.scrollTop ?? 0;
const containerHeight = logContainer.value?.clientHeight ?? 0;
const scrolledTo = scrollTop + containerHeight;
// if the user scrolled down enough, re-enable autoscroll
if (scrollHeight - scrolledTo < 30) {
autoScroll.value = true;
}
};
const scrollToBottom = () => {
nextTick(() => {
if (logContainer.value && autoScroll) {
logContainer.value.scrollTop = logContainer.value.scrollHeight;
}
});
};
const setRefreshInterval = (timeout = 10000) => {
if (refreshInterval.value) {
clearInterval(refreshInterval.value);
}
refreshInterval.value = setInterval(() => {
refreshLogs();
}, timeout);
};
// append new logs to the already stored ones
watch(() => data.value?.length, () => {
logs.value.push(...data.value);
if (logs.value.length > MAX_LOGS) {
logs.value = logs.value.slice(-MAX_LOGS);
}
scrollToBottom();
});
watch(() => isActive, (active) => {
if (active) {
// fetch data manually on the first tab load
if (lastFetched.value === 0) {
refreshLogs();
}
autoScroll.value = true;
scrollToBottom();
setRefreshInterval();
} else {
showLoader.value = true;
clearInterval(refreshInterval.value);
}
});
onUnmounted(() => {
if (refreshInterval.value) {
clearInterval(refreshInterval.value);
}
});
</script>
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
</aside>

<div class="overflow-auto">
<div class="mx-auto max-w-[1664px]">
<div class="mx-auto h-full max-w-[1664px]">
<slot/>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ export default defineNuxtConfig({
runtimeConfig: {
serverUrl: process.env.DASH_URL || 'https://dash.globalping.io',
public: {
gpAuthUrl: process.env.GP_API_URL || 'https://auth.globalping.io',
gpAuthUrl: process.env.GP_AUTH_URL || 'https://auth.globalping.io',
directusUrl: process.env.DIRECTUS_URL || 'https://dash-directus.globalping.io',
gpApiUrl: process.env.GP_API_URL || 'https://api.globalping.io',
itemsPerTablePage: 10,
},
},
$development: {
runtimeConfig: {
serverUrl: process.env.DASH_URL || 'http://localhost:13010',
public: {
gpAuthUrl: process.env.GP_API_URL || 'http://localhost:13110',
gpAuthUrl: process.env.GP_AUTH_URL || 'http://localhost:13110',
directusUrl: process.env.DIRECTUS_URL || 'http://localhost:18055',
gpApiUrl: process.env.GP_API_URL || 'http://localhost:3000',
},
},
devtools: { enabled: true },
Expand Down
17 changes: 9 additions & 8 deletions pages/probes/[id].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="min-h-full p-6">
<div class="flex flex-col gap-4">
<div class="flex h-full flex-col p-6">
<div class="flex min-h-0 flex-1 flex-col gap-4">
<div class="flex gap-2">
<NuxtLink
:to="getBackToProbesHref()"
Expand Down Expand Up @@ -96,23 +96,23 @@
Your probe container is running an outdated software and we couldn't update it automatically. Please follow <NuxtLink class="font-semibold" to="#" @click="updateProbeDialog = true">our guide</NuxtLink> to update it manually.
</Message>

<Tabs value="0">
<Tabs v-model:value="activeTab" class="flex min-h-0 flex-1 flex-col">
<TabList ref="tabListRef" class="!border-b !border-surface-300 dark:!border-dark-600 [&_[data-pc-section='tablist']]:!border-none">
<Tab value="0" tabindex="0" class="!w-1/2 border-none !px-6 !py-2 !text-[14px] !font-bold sm:!w-auto">Details</Tab>
<!-- temporarily hide Logs tab while it's under construction -->
<!-- <Tab value="1" tabindex="0" class="!w-1/2 border-none !px-6 !py-2 !text-[14px] !font-bold sm:!w-auto">Logs</Tab> -->
<Tab value="1" tabindex="0" class="!w-1/2 border-none !px-6 !py-2 !text-[14px] !font-bold sm:!w-auto">Logs</Tab>
</TabList>

<TabPanels class="mt-6 !bg-transparent !p-0">
<TabPanels class="mt-6 flex min-h-0 flex-1 flex-col !bg-transparent !p-0">
<TabPanel v-if="probeDetails" value="0" tabindex="-1">
<ProbeTabDetails v-model:probe-details-updating="probeDetailsUpdating" v-model:probe="probeDetails"/>
</TabPanel>

<TabPanel value="1" tabindex="-1">
NO LOGS FOR NOW
<TabPanel class="flex min-h-0 flex-1 flex-col" value="1" tabindex="-1">
<ProbeTabLogs :is-active="activeTab === '1'"/>
</TabPanel>
</TabPanels>
</Tabs>

</div>

<GPDialog
Expand Down Expand Up @@ -145,6 +145,7 @@
const showMoreIps = ref(false);
const windowSize = useWindowSize();
const tabListRef = useTemplateRef('tabListRef');
const activeTab = ref('0');

const { data: probeDetails, error: probeDetailsError } = await useAsyncData<Probe>(() => $directus.request(readItem('gp_probes', probeId)));

Expand Down
7 changes: 7 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,11 @@ declare global {
creditsPerDollar: number;
creditsPerAdoptedProbe: number;
};

type ProbeLog = {
message: string;
scope?: string;
level?: string;
timestamp?: string;
};
}