Skip to content

Commit

Permalink
Add chart.js and vue-chartjs integration
Browse files Browse the repository at this point in the history
Updated StatsGrid.vue to include chart.js for error logs visualization. Enhanced theming and accessibility across several components, fixed the error page styling, and updated `vite.config.js` for better build configuration.
  • Loading branch information
wkennedy committed Nov 20, 2024
1 parent c381587 commit 3009e72
Show file tree
Hide file tree
Showing 11 changed files with 439 additions and 174 deletions.
63 changes: 37 additions & 26 deletions sologger-ui/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@
<title>Error - Sologger</title>
<style>
:root {
--primary-400: #34d399;
--primary-500: #10b981;
--primary-600: #059669;
--surface-50: #fafafa;
--surface-100: #f4f4f5;
--surface-700: #3f3f46;
--surface-800: #27272a;
--surface-900: #18181b;
}

@media (prefers-color-scheme: dark) {
body {
background-color: var(--surface-900);
color: var(--surface-100);
}
--primary-50: #efede6;
--primary-100: #ddadd8;
--primary-200: #d37fcf;
--primary-300: #d8ca47;
--primary-400: #ff4513;
--primary-500: #302d37;
--surface-50: #e6efe9;
--surface-100: #0f4d42;
--surface-700: #0f4d42;
--surface-800: #052b25;
--surface-900: #021b17;
}

body {
Expand All @@ -32,7 +28,7 @@
flex-direction: column;
align-items: center;
justify-content: center;
background-color: var(--surface-50);
background-color: var(--primary-50);
color: var(--surface-800);
}

Expand All @@ -45,65 +41,80 @@
.logo {
font-size: 2.5rem;
font-weight: bold;
color: var(--primary-500);
color: var(--primary-400);
margin-bottom: 2rem;
}

.error-code {
font-size: 6rem;
font-weight: bold;
color: var(--primary-400);
color: var(--primary-200);
margin: 0;
line-height: 1;
}

.error-title {
font-size: 1.5rem;
margin: 1rem 0;
color: var(--surface-700);
color: var(--surface-100);
}

.error-message {
margin-bottom: 2rem;
line-height: 1.5;
color: var(--surface-100);
}

.button {
display: inline-block;
padding: 0.75rem 1.5rem;
background-color: var(--primary-500);
color: white;
background-color: var(--primary-300);
color: var(--surface-900);
text-decoration: none;
border-radius: 0.375rem;
font-weight: 500;
transition: background-color 0.2s;
}

.button:hover {
background-color: var(--primary-600);
background-color: var(--primary-400);
}

.info {
margin-top: 2rem;
font-size: 0.875rem;
color: var(--surface-700);
color: var(--surface-100);
}

.info a {
color: var(--primary-400);
}

@media (prefers-color-scheme: dark) {
body {
background-color: var(--surface-900);
color: var(--primary-50);
}

.error-title, .error-message, .info {
color: var(--primary-50);
}
}

@media (max-width: 640px) {
.container {
padding: 1rem;
}

.error-code {
font-size: 4rem;
}

.error-title {
font-size: 1.25rem;
}
}
</style>
</head>
<!-- Rest of the HTML remains the same -->
<body>
<div class="container">
<div class="logo">Sologger</div>
Expand All @@ -116,7 +127,7 @@ <h2 class="error-title">Page Not Found</h2>
<a href="/" class="button">Return to Homepage</a>
<p class="info">
If you believe this is a mistake, please
<a href="https://github.com/wkennedy/issues"
<a href="https://github.com/brytelands/sologger/issues"
target="_blank"
rel="noopener noreferrer"
style="color: var(--primary-500);">
Expand Down
30 changes: 30 additions & 0 deletions sologger-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sologger-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
},
"dependencies": {
"@handsontable/vue3": "^14.6.1",
"chart.js": "^4.4.6",
"handsontable": "^14.6.1",
"primevue": "^4.2.1",
"tailwindcss-primeui": "^0.3.4",
"vue": "^3.5.12",
"vue-chartjs": "^5.3.2",
"vue-router": "^4.4.5"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions sologger-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
<div class="flex items-center gap-6">
<router-link
to="/"
class="hover:text-primary-400 transition-colors"
class="text-[#e6efe9] hover:text-primary-400 transition-colors"
>
Home
</router-link>
<router-link
to="/convert"
class="hover:text-primary-400 transition-colors"
class="text-[#e6efe9] hover:text-primary-400 transition-colors"
>
Convert Logs
</router-link>
<router-link
to="/about"
class="hover:text-primary-400 transition-colors"
class="text-[#e6efe9] hover:text-primary-400 transition-colors"
>
About
</router-link>
</div>

<div class="absolute left-1/2 transform -translate-x-1/2 flex items-center">
<span class="text-2xl font-bold text-primary-400">Sologger</span>
<span class="text-2xl font-bold text-primary-400"><img src="/sologger_header.png" alt="Sologger"/></span>
</div>

<div class="flex items-center">
<a
href="https://github.com/wkennedy"
href="https://github.com/brytelands/sologger"
target="_blank"
rel="noopener noreferrer"
class="hover:text-primary-400 transition-colors"
class="text-[#e6efe9] hover:text-primary-400 transition-colors"
>
<svg
class="h-6 w-6"
Expand Down
3 changes: 2 additions & 1 deletion sologger-ui/src/components/LogsTable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div class="pagination flex items-center justify-between p-4 bg-surface-50 border-t border-surface-200">
<span class="text-sm text-surface-600">
<span class="text-sm text-surface-0">
Showing {{ currentPage * pageSize + 1 }} - {{ Math.min((currentPage + 1) * pageSize, parsedLogs.length) }}
of {{ parsedLogs.length }} entries
</span>
Expand Down Expand Up @@ -84,6 +84,7 @@ export default {
afterChange: true,
columns: [
{ data: 'timestamp', title: 'Time' },
{ data: 'level', title: 'Level' },
{
data: 'signature',
title: 'Signature',
Expand Down
107 changes: 94 additions & 13 deletions sologger-ui/src/components/StatsGrid.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,103 @@
<template>
<div class="grid grid-cols-3 gap-4 mb-6">
<div class="bg-blue-100 p-4 rounded">
<h4 class="font-bold">Total Transactions</h4>
<p>{{ parsedLogs.length }}</p>
<div class="space-y-4 mb-6">
<div class="grid grid-cols-5 gap-4">
<div class="bg-blue-100 dark:bg-blue-900 p-4 rounded">
<h4 class="font-bold dark:text-white">Total Logs</h4>
<p class="dark:text-white">{{ parsedLogs.length }}</p>
</div>
<div class="bg-green-100 dark:bg-green-900 p-4 rounded">
<h4 class="font-bold dark:text-white">Unique Programs</h4>
<p class="dark:text-white">{{ uniqueProgramsCount }}</p>
</div>
<div class="bg-red-100 dark:bg-red-900 p-4 rounded">
<h4 class="font-bold dark:text-white">Error Logs</h4>
<p class="dark:text-white">{{ errorCount }}</p>
</div>
<div class="bg-emerald-100 dark:bg-emerald-900 p-4 rounded">
<h4 class="font-bold dark:text-white">Info Logs</h4>
<p class="dark:text-white">{{ infoCount }}</p>
</div>
<div class="bg-purple-100 dark:bg-purple-900 p-4 rounded">
<h4 class="font-bold dark:text-white">Last Update</h4>
<p class="dark:text-white">{{ lastUpdateTime }}</p>
</div>
</div>
<div class="bg-green-100 p-4 rounded">
<h4 class="font-bold">Unique Programs</h4>
<p>{{ uniqueProgramsCount }}</p>
</div>
<div class="bg-purple-100 p-4 rounded">
<h4 class="font-bold">Last Update</h4>
<p>{{ lastUpdateTime }}</p>
<div class="bg-surface-800 dark:bg-surface-50 p-4 rounded h-48">
<Line :data="chartData"
:options="chartOptions"
class="w-full h-full"
/>
</div>
</div>
</template>

<script>
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend } from 'chart.js';
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend);
export default {
props: ['parsedLogs', 'uniqueProgramsCount', 'lastUpdateTime']
components: { Line },
props: ['parsedLogs', 'uniqueProgramsCount', 'lastUpdateTime'],
computed: {
errorCount() {
return this.parsedLogs.filter(log => log.level === 'Error').length;
},
infoCount() {
return this.parsedLogs.filter(log => log.level === 'Info').length;
},
chartData() {
const timeLabels = [...new Set(this.parsedLogs.map(log => log.timestamp))].slice(-10);
const errorCounts = timeLabels.map(time =>
this.parsedLogs.filter(log => log.timestamp === time && log.level === 'Error').length
);
return {
labels: timeLabels,
datasets: [{
label: 'Errors Over Time',
data: errorCounts,
borderColor: '#ef4444',
backgroundColor: '#fee2e2',
tension: 0.4
}]
};
},
chartOptions() {
return {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: true,
labels: {
color: this.isDarkMode ? '#fff' : '#000'
}
}
},
scales: {
y: {
beginAtZero: true,
ticks: {
color: this.isDarkMode ? '#fff' : '#000'
}
},
x: {
ticks: {
color: this.isDarkMode ? '#fff' : '#000'
}
}
}
};
},
},
};
</script>
</script>

<style>
.dark .chartjs-render-monitor {
filter: invert(1) hue-rotate(180deg);
}
</style>
Loading

0 comments on commit 3009e72

Please sign in to comment.