-
Notifications
You must be signed in to change notification settings - Fork 6
Feat: dashboard + subscribers #76
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
Open
TatevikGr
wants to merge
52
commits into
dev
Choose a base branch
from
feat/dashboard
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
1a9c129
Remove ApiClient
tatevikg1 21d04aa
Login
tatevikg1 722c663
PublicRoute Attr
tatevikg1 9e0378b
SessionAuthenticator
tatevikg1 fea446d
Vue dashboard
tatevikg1 718c53a
Icons
tatevikg1 3cd30a2
Css
tatevikg1 b5e79c4
Css + bootstrap
tatevikg1 b49da9b
Sidebar
tatevikg1 23a30de
grid
tatevikg1 e5a566d
sticky
tatevikg1 3113743
routes
tatevikg1 c97e79e
Update rest-client and core
tatevikg1 f698b69
Redirect to home if logged in
tatevikg1 3af41b4
Exclude api from firewall
tatevikg1 a9477f4
ApiSessionListener
tatevikg1 6d656e9
SubscribersController
tatevikg1 582cdfe
testing
tatevikg1 56b2e6f
Use tailwind
tatevikg1 183507f
Subscribers
tatevikg1 0bfde9d
Subscribers pass data
tatevikg1 04b4195
Color ext-wf1
tatevikg1 a781f1a
Align icon with text
tatevikg1 5be4574
Mobile
tatevikg1 aa6f146
Filter subscribers
tatevikg1 58cca2a
Filter subscribers
tatevikg1 9e22373
Fix: created
tatevikg1 77c007b
ref: SubscribersController
tatevikg1 9989080
Fix: loading for SPA
tatevikg1 e18b4cc
Fix: test
tatevikg1 0244cc1
Fix: style
tatevikg1 f8b6b27
Fix: tests
tatevikg1 781b71a
spa.html.twig
tatevikg1 4e40cf2
subscriberFilters
tatevikg1 ef19e4e
find subscriber by email
tatevikg1 2b22265
find subscriber by email, foreign key and unique id
tatevikg1 1257a70
download csv
tatevikg1 cdb7416
Export CSV
tatevikg1 5732a0c
Apache config
tatevikg1 f1df0b7
Export filtered
tatevikg1 1e18e5f
Sort
tatevikg1 36212bb
Fix: logout
tatevikg1 48b17d4
Fix: autowiring
tatevikg1 05ddd4c
Add: auth user data retrieval
tatevikg1 6efdda9
remove example page
tatevikg1 6fcb278
Logout button
tatevikg1 f5d7fda
Add subscriber modal
tatevikg1 349d2f0
Add details to subscriber modal
tatevikg1 b0f88ca
install js client
tatevikg1 b516203
Fix: js client
tatevikg1 36560f4
Fix: filter
tatevikg1 b0cd9da
ImportSubscribers
tatevikg1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| #!/bin/sh | ||
| . "$(dirname "$0")/_/husky.sh" | ||
|
|
||
| echo "🔍 Running PHPStan..." | ||
| php vendor/bin/phpstan analyse -l 5 src/ tests/ || exit 1 | ||
|
|
||
| echo "📏 Running PHPMD..." | ||
| php vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml || exit 1 | ||
|
|
||
| echo "🧹 Running PHPCS..." | ||
| php vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/ || exit 1 | ||
| #echo "🔍 Running PHPStan..." | ||
| #php vendor/bin/phpstan analyse -l 5 src/ tests/ || exit 1 | ||
| # | ||
| #echo "📏 Running PHPMD..." | ||
| #php vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml || exit 1 | ||
| # | ||
| #echo "🧹 Running PHPCS..." | ||
| #php vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/ || exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import { createApp } from 'vue'; | ||
| import App from './vue/App.vue'; | ||
| import { router } from './router'; | ||
|
|
||
| // Mount the main app if the element exists | ||
| const appElement = document.getElementById('vue-app'); | ||
| if (appElement) { | ||
| createApp(App).mount('#vue-app'); | ||
| const app = createApp(App); | ||
| app.use(router); | ||
| app.mount('#vue-app'); | ||
| } | ||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { createRouter, createWebHistory } from 'vue-router'; | ||
| import DashboardView from '../vue/views/DashboardView.vue' | ||
| import SubscribersView from '../vue/views/SubscribersView.vue' | ||
|
|
||
| export const router = createRouter({ | ||
| history: createWebHistory(), | ||
| routes: [ | ||
| { path: '/dashboard', name: 'dashboard', component: DashboardView }, | ||
| { path: '/subscribers', name: 'subscribers', component: SubscribersView }, | ||
| { path: '/:pathMatch(.*)*', redirect: '/' }, | ||
| ], | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,13 @@ | ||
| <template> | ||
| <div> | ||
| <h2>Hello from Vue</h2> | ||
| <p>{{ message }}</p> | ||
| <div class="d-flex" style="min-height: 100vh;"> | ||
| <AppSidebar /> | ||
|
|
||
| <main class="flex-grow-1"> | ||
| <RouterView /> | ||
| </main> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| name: 'App', | ||
| data() { | ||
| return { | ||
| message: 'This is a reusable component!' | ||
| } | ||
| }, | ||
| created() { | ||
| console.log('App component created'); | ||
| }, | ||
| mounted() { | ||
| console.log('App component mounted'); | ||
| }, | ||
| updated() { | ||
| console.log('App component updated'); | ||
| } | ||
| } | ||
| <script setup> | ||
| import AppSidebar from './components/sidebar/AppSidebar.vue' | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <!-- assets/vue/components/base/BaseBadge.vue --> | ||
| <template> | ||
| <span :class="badgeClass"> | ||
| <slot /> | ||
| </span> | ||
| <!-- Renders a Bootstrap badge; styling controlled via variant prop --> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { computed } from 'vue' | ||
| const props = defineProps({ | ||
| variant: { | ||
| type: String, | ||
| default: 'neutral', // neutral | counter | ||
| }, | ||
| }) | ||
|
|
||
| const badgeClass = computed(() => { | ||
| switch (props.variant) { | ||
| case 'counter': | ||
| return 'badge badge-primary'; | ||
| case 'neutral': | ||
| default: | ||
| return 'badge badge-secondary'; | ||
| } | ||
| }) | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <!-- assets/vue/components/base/BaseButton.vue --> | ||
| <template> | ||
| <button | ||
| :class="buttonClass" | ||
| type="button" | ||
| v-bind="$attrs" | ||
| > | ||
| <slot /> | ||
| </button> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { computed } from 'vue' | ||
|
|
||
| const props = defineProps({ | ||
| variant: { | ||
| type: String, | ||
| default: 'primary', // primary | secondary | ghost | ||
| }, | ||
| }) | ||
|
|
||
| const buttonClass = computed(() => { | ||
| switch (props.variant) { | ||
| case 'secondary': | ||
| return 'btn btn-secondary'; | ||
| case 'ghost': | ||
| return 'btn btn-link text-primary'; | ||
| case 'primary': | ||
| default: | ||
| return 'btn btn-primary'; | ||
| } | ||
| }) | ||
| </script> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <template> | ||
| <div :class="cardClasses"> | ||
| <div :class="bodyClasses"> | ||
| <slot /> | ||
| </div> | ||
| </div> | ||
|
|
||
| </template> | ||
|
|
||
| <script setup> | ||
| const props = defineProps({ | ||
| variant: { | ||
| type: String, | ||
| default: 'default', // default | subtle | danger | success | ||
| }, | ||
| }) | ||
|
|
||
| const cardVariantMap = { | ||
| default: 'card shadow-sm border-0 bg-white', | ||
| subtle: 'card shadow-sm border-0 bg-light', | ||
| danger: 'card shadow-sm border-0 bg-danger text-white', | ||
| success: 'card shadow-sm border-0 bg-success text-white', | ||
| } | ||
|
|
||
| const bodyVariantMap = { | ||
| default: 'card-body p-4', | ||
| subtle: 'card-body p-4', | ||
| danger: 'card-body p-4', | ||
| success: 'card-body p-4', | ||
| } | ||
|
|
||
| const cardClasses = cardVariantMap[props.variant] || cardVariantMap.default | ||
| const bodyClasses = bodyVariantMap[props.variant] || bodyVariantMap.default | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <template> | ||
| <!-- Wrapper handles layout & color via Bootstrap utilities --> | ||
| <span :class="wrapperClass" v-html="svg" aria-hidden="true"></span> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { computed } from "vue"; | ||
|
|
||
| const props = defineProps({ | ||
| name: { type: String, required: true }, | ||
|
|
||
| size: { | ||
| type: String, | ||
| default: "md", // "sm", "md", "lg" | ||
| }, | ||
|
|
||
| muted: { | ||
| type: Boolean, | ||
| default: true, | ||
| }, | ||
| }); | ||
|
|
||
| // Simple internal SVG registry | ||
| const icons = { | ||
| users: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-users text-slate-400 group-hover:text-slate-600" aria-hidden="true"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path><path d="M16 3.128a4 4 0 0 1 0 7.744"></path><path d="M22 21v-2a4 4 0 0 0-3-3.87"></path><circle cx="9" cy="7" r="4"></circle></svg><span class="font-medium text-sm">`, | ||
|
|
||
| plane: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-send text-slate-400 group-hover:text-slate-600" aria-hidden="true"><path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"></path><path d="m21.854 2.147-10.94 10.939"></path></svg><span class="font-medium text-sm">`, | ||
|
|
||
| grid: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-layout-dashboard text-indigo-600" aria-hidden="true"><rect width="7" height="9" x="3" y="3" rx="1"></rect><rect width="7" height="5" x="14" y="3" rx="1"></rect><rect width="7" height="9" x="14" y="12" rx="1"></rect><rect width="7" height="5" x="3" y="16" rx="1"></rect></svg><span class="font-medium text-sm">`, | ||
|
|
||
| list: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-list-tree text-slate-400 group-hover:text-slate-600" aria-hidden="true"><path d="M21 12h-8"></path><path d="M21 6H8"></path><path d="M21 18h-8"></path><path d="M3 6v4c0 1.1.9 2 2 2h3"></path><path d="M3 10v6c0 1.1.9 2 2 2h3"></path></svg><span class="font-medium text-sm">`, | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| layout: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-file-text text-slate-400 group-hover:text-slate-600" aria-hidden="true"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path><path d="M14 2v4a2 2 0 0 0 2 2h4"></path><path d="M10 9H8"></path><path d="M16 13H8"></path><path d="M16 17H8"></path></svg><span class="font-medium text-sm">`, | ||
|
|
||
| chart: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chart-column text-slate-400 group-hover:text-slate-600" aria-hidden="true"><path d="M3 3v16a2 2 0 0 0 2 2h16"></path><path d="M18 17V9"></path><path d="M13 17V5"></path><path d="M8 17v-3"></path></svg>`, | ||
|
|
||
| settings: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-settings text-slate-400 group-hover:text-slate-600" aria-hidden="true"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"></path><circle cx="12" cy="12" r="3"></circle></svg>`, | ||
|
|
||
| rate: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trending-up" aria-hidden="true"><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`, | ||
|
|
||
| info: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-alert" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" x2="12" y1="8" y2="12"></line><line x1="12" x2="12.01" y1="16" y2="16"></line></svg>`, | ||
|
|
||
| notification: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bell" aria-hidden="true"><path d="M10.268 21a2 2 0 0 0 3.464 0"></path><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path></svg>`, | ||
|
|
||
| search: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-search absolute left-3 top-1/2 -translate-y-1/2 transition-colors text-slate-400" aria-hidden="true"><path d="m21 21-4.34-4.34"></path><circle cx="11" cy="11" r="8"></circle></svg>`, | ||
|
|
||
| filter: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-funnel" aria-hidden="true"><path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"></path></svg>`, | ||
|
|
||
| edit: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pen" aria-hidden="true"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"></path></svg></button>`, | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| delete: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2 lucide-trash-2" aria-hidden="true"><path d="M10 11v6"></path><path d="M14 11v6"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M3 6h18"></path><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>`, | ||
| }; | ||
|
|
||
| const svg = computed(() => icons[props.name] || ""); | ||
|
|
||
| const wrapperClass = computed(() => { | ||
| const classes = [ | ||
| "d-inline-flex", | ||
| "align-items-center", | ||
| "justify-content-center", | ||
| ]; | ||
|
|
||
| if (props.muted) { | ||
| classes.push("text-secondary"); | ||
| } | ||
|
|
||
| if (props.size === "sm") { | ||
| classes.push("me-1"); | ||
| } else if (props.size === "lg") { | ||
| classes.push("me-2"); | ||
| } | ||
|
|
||
| return classes.join(" "); | ||
| }); | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <!-- assets/vue/components/base/BaseProgressBar.vue --> | ||
| <template> | ||
| <div class="progress bg-secondary bg-opacity-25 rounded-pill" :style="wrapperStyle"> | ||
| <div | ||
| class="progress-bar bg-primary rounded-pill" | ||
| role="progressbar" | ||
| :style="{ width: value + '%' }" | ||
| :aria-valuenow="value" | ||
| aria-valuemin="0" | ||
| aria-valuemax="100" | ||
| ></div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| const props = defineProps({ | ||
| value: { | ||
| type: Number, | ||
| default: 0, | ||
| }, | ||
| height: { | ||
| type: String, | ||
| default: "6px", // allows easy overrides: "4px", "10px", etc. | ||
| }, | ||
| }) | ||
|
|
||
| const wrapperStyle = { | ||
| height: props.height, | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| <!-- assets/vue/components/charts/LineChart.vue --> | ||
| <template> | ||
| <div class="w-100"> | ||
| <svg | ||
| class="w-100" | ||
| :style="{ height }" | ||
| viewBox="0 0 100 40" | ||
| preserveAspectRatio="none" | ||
| > | ||
| <!-- grid lines --> | ||
| <line | ||
| v-for="y in 4" | ||
| :key="'grid-' + y" | ||
| :x1="0" | ||
| :x2="100" | ||
| :y1="y * 10" | ||
| :y2="y * 10" | ||
| stroke="#e5e7eb" | ||
| stroke-width="0.3" | ||
| /> | ||
|
|
||
| <!-- series polylines --> | ||
| <polyline | ||
| v-for="(path, idx) in paths" | ||
| :key="'series-' + idx" | ||
| :points="path" | ||
| fill="none" | ||
| stroke-width="1.8" | ||
| :stroke="seriesColors[idx % seriesColors.length]" | ||
| /> | ||
| </svg> | ||
|
|
||
| <div class="d-flex justify-content-between mt-2 small text-secondary"> | ||
| <span | ||
| v-for="(label, idx) in labels" | ||
| :key="'label-' + idx" | ||
| class="flex-fill text-truncate text-center" | ||
| > | ||
| {{ label }} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { computed } from 'vue' | ||
|
|
||
| const props = defineProps({ | ||
| labels: { | ||
| type: Array, | ||
| default: () => [], | ||
| }, | ||
| // series: [{ name: string, data: number[] }] | ||
| series: { | ||
| type: Array, | ||
| default: () => [], | ||
| }, | ||
| // control rendered SVG height (Bootstrap handles width) | ||
| height: { | ||
| type: String, | ||
| default: '210px', | ||
| }, | ||
| // optional custom colors for series | ||
| colors: { | ||
| type: Array, | ||
| default: () => [ | ||
| '#0d6efd', // primary | ||
| '#198754', // success | ||
| '#dc3545', // danger | ||
| '#0dcaf0', // info | ||
| ], | ||
| }, | ||
| }) | ||
|
|
||
| const seriesColors = computed(() => props.colors) | ||
|
|
||
| const paths = computed(() => { | ||
| if (!props.series.length || !props.labels.length) return [] | ||
|
|
||
| const pointCount = props.labels.length | ||
| const allValues = props.series.flatMap((s) => s.data) | ||
| const max = Math.max(...allValues) | ||
| const min = Math.min(...allValues) | ||
| const range = max === min ? 1 : max - min | ||
|
|
||
| return props.series.map((s) => { | ||
| return s.data | ||
| .map((value, index) => { | ||
| const x = pointCount === 1 ? 50 : (index / (pointCount - 1)) * 100 | ||
| const normalized = (value - min) / range | ||
| const y = 35 - normalized * 25 // padding top/bottom | ||
| return `${x},${y}` | ||
| }) | ||
| .join(' ') | ||
| }) | ||
| }) | ||
| </script> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.