feat: Update contribution tracking to use backend-provided weekday values and enhance UI components
This commit is contained in:
parent
c1278d2e45
commit
cec1bdead6
@ -8,6 +8,7 @@
|
||||
icon="pi pi-upload"
|
||||
@click="showUploadDialog = true"
|
||||
severity="success"
|
||||
class="ml-auto"
|
||||
outlined
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -124,10 +124,13 @@ const contributionGrid = computed(() => {
|
||||
firstSunday.setDate(firstSunday.getDate() - 1)
|
||||
}
|
||||
|
||||
// Create a map of dates to contribution counts
|
||||
// Backend already provides weekday values (0=Sun, 6=Sat), use them directly
|
||||
const contributionMap = {}
|
||||
contributionData.value.forEach(day => {
|
||||
contributionMap[day.date] = day.count
|
||||
contributionMap[day.date] = {
|
||||
count: day.count,
|
||||
weekday: day.weekday // Use weekday from backend
|
||||
}
|
||||
})
|
||||
|
||||
let col = 1
|
||||
@ -136,12 +139,15 @@ const contributionGrid = computed(() => {
|
||||
|
||||
while (currentDate <= lastDay || currentDate.getDay() !== 0) {
|
||||
const dateStr = currentDate.toISOString().split('T')[0]
|
||||
const weekday = currentDate.getDay() // 0 = Sunday, 6 = Saturday
|
||||
const contributionInfo = contributionMap[dateStr]
|
||||
|
||||
// Use weekday from backend if available, otherwise calculate it
|
||||
const weekday = contributionInfo ? contributionInfo.weekday : currentDate.getDay()
|
||||
const row = weekday + 1 // Grid row: 1-7 (Sunday-Saturday)
|
||||
|
||||
// Only add cells for the current year
|
||||
if (currentDate.getFullYear() === currentYear.value) {
|
||||
const count = contributionMap[dateStr] || 0
|
||||
const count = contributionInfo ? contributionInfo.count : 0
|
||||
const date = new Date(currentDate)
|
||||
|
||||
grid.push({
|
||||
@ -301,6 +307,10 @@ async function loadContributions() {
|
||||
|
||||
const data = await response.json()
|
||||
contributionData.value = data.contributions || []
|
||||
|
||||
// Debug: Log first few contributions to check weekday values
|
||||
console.log('Loaded contributions sample:', contributionData.value.slice(0, 5))
|
||||
console.log('Total contributions:', contributionData.value.length)
|
||||
} catch (err) {
|
||||
console.error('Error loading contributions:', err)
|
||||
error.value = err.message
|
||||
@ -438,7 +448,11 @@ defineExpose({
|
||||
}
|
||||
|
||||
.intensity-0 {
|
||||
background-color: var(--surface-200);
|
||||
background-color: #ebedf0;
|
||||
}
|
||||
|
||||
:global(.dark) .intensity-0 {
|
||||
background-color: #161b22;
|
||||
}
|
||||
|
||||
.intensity-1 {
|
||||
@ -457,10 +471,6 @@ defineExpose({
|
||||
background-color: #216e39;
|
||||
}
|
||||
|
||||
:global(.dark) .intensity-0 {
|
||||
background-color: var(--surface-700);
|
||||
}
|
||||
|
||||
.legend {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -563,13 +563,18 @@
|
||||
:modal="true"
|
||||
:style="{ width: '1400px' }"
|
||||
>
|
||||
<TabView>
|
||||
<!-- Project Data Tab -->
|
||||
<TabPanel header="Projektdaten">
|
||||
<div class="flex flex-col gap-4">
|
||||
<!-- Basic Information -->
|
||||
<div class="p-4 border-round border-1 surface-border">
|
||||
<div class="font-semibold text-lg mb-3">Grunddaten</div>
|
||||
<Tabs value="0">
|
||||
<TabList>
|
||||
<Tab value="0">Projektdaten</Tab>
|
||||
<Tab value="1">Git Repositories</Tab>
|
||||
</TabList>
|
||||
<TabPanels>
|
||||
<!-- Project Data Tab -->
|
||||
<TabPanel value="0">
|
||||
<div class="flex flex-col gap-4">
|
||||
<!-- Basic Information -->
|
||||
<div class="p-4 border-round border-1 surface-border">
|
||||
<div class="font-semibold text-lg mb-3">Grunddaten</div>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="font-medium text-sm text-500">Projektname</label>
|
||||
@ -677,7 +682,7 @@
|
||||
</TabPanel>
|
||||
|
||||
<!-- Git Repository Tab -->
|
||||
<TabPanel header="Git Repositories">
|
||||
<TabPanel value="1">
|
||||
<div v-if="gitRepositories.length === 0" class="text-center py-8 text-500">
|
||||
<i class="pi pi-github text-6xl mb-3"></i>
|
||||
<p>Keine Git-Repositories verknüpft</p>
|
||||
@ -742,7 +747,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</TabPanel>
|
||||
</TabView>
|
||||
</TabPanels>
|
||||
</Tabs>
|
||||
|
||||
<template #footer>
|
||||
<Button label="Schließen" @click="viewDialog = false" />
|
||||
@ -765,7 +771,10 @@ import DatePicker from 'primevue/datepicker'
|
||||
import InputNumber from 'primevue/inputnumber'
|
||||
import RadioButton from 'primevue/radiobutton'
|
||||
import Tag from 'primevue/tag'
|
||||
import TabView from 'primevue/tabview'
|
||||
import Tabs from 'primevue/tabs'
|
||||
import TabList from 'primevue/tablist'
|
||||
import Tab from 'primevue/tab'
|
||||
import TabPanels from 'primevue/tabpanels'
|
||||
import TabPanel from 'primevue/tabpanel'
|
||||
import DataTable from 'primevue/datatable'
|
||||
import Column from 'primevue/column'
|
||||
|
||||
@ -8,6 +8,8 @@ use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use App\Repository\GitRepositoryRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@ -25,6 +27,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
normalizationContext: ['groups' => ['git_repo:read']],
|
||||
denormalizationContext: ['groups' => ['git_repo:write']]
|
||||
)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['project' => 'exact'])]
|
||||
class GitRepository
|
||||
{
|
||||
#[ORM\Id]
|
||||
|
||||
@ -100,10 +100,14 @@ class GitHubService
|
||||
$dayKey = $date->format('Y-m-d');
|
||||
|
||||
if (!isset($dailyContributions[$dayKey])) {
|
||||
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
|
||||
$phpWeekday = (int)$date->format('N'); // 1-7
|
||||
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
|
||||
|
||||
$dailyContributions[$dayKey] = [
|
||||
'date' => $dayKey,
|
||||
'count' => 0,
|
||||
'weekday' => (int)$date->format('N')
|
||||
'weekday' => $jsWeekday
|
||||
];
|
||||
}
|
||||
|
||||
@ -119,10 +123,14 @@ class GitHubService
|
||||
$dayKey = $date->format('Y-m-d');
|
||||
|
||||
if (!isset($dailyContributions[$dayKey])) {
|
||||
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
|
||||
$phpWeekday = (int)$date->format('N'); // 1-7
|
||||
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
|
||||
|
||||
$dailyContributions[$dayKey] = [
|
||||
'date' => $dayKey,
|
||||
'count' => 0,
|
||||
'weekday' => (int)$date->format('N')
|
||||
'weekday' => $jsWeekday
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,10 +119,14 @@ class GitService
|
||||
$dayKey = $date->format('Y-m-d');
|
||||
|
||||
if (!isset($dailyContributions[$dayKey])) {
|
||||
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
|
||||
$phpWeekday = (int)$date->format('N'); // 1-7
|
||||
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
|
||||
|
||||
$dailyContributions[$dayKey] = [
|
||||
'date' => $dayKey,
|
||||
'count' => 0,
|
||||
'weekday' => (int)$date->format('N') // 1 = Monday, 7 = Sunday
|
||||
'weekday' => $jsWeekday
|
||||
];
|
||||
}
|
||||
|
||||
@ -137,10 +141,14 @@ class GitService
|
||||
$dayKey = $date->format('Y-m-d');
|
||||
|
||||
if (!isset($dailyContributions[$dayKey])) {
|
||||
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
|
||||
$phpWeekday = (int)$date->format('N'); // 1-7
|
||||
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
|
||||
|
||||
$dailyContributions[$dayKey] = [
|
||||
'date' => $dayKey,
|
||||
'count' => 0,
|
||||
'weekday' => (int)$date->format('N')
|
||||
'weekday' => $jsWeekday
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,10 +101,14 @@ class GiteaService
|
||||
$dayKey = $date->format('Y-m-d');
|
||||
|
||||
if (!isset($dailyContributions[$dayKey])) {
|
||||
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
|
||||
$phpWeekday = (int)$date->format('N'); // 1-7
|
||||
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
|
||||
|
||||
$dailyContributions[$dayKey] = [
|
||||
'date' => $dayKey,
|
||||
'count' => 0,
|
||||
'weekday' => (int)$date->format('N')
|
||||
'weekday' => $jsWeekday
|
||||
];
|
||||
}
|
||||
|
||||
@ -116,10 +120,14 @@ class GiteaService
|
||||
$dayKey = $date->format('Y-m-d');
|
||||
|
||||
if (!isset($dailyContributions[$dayKey])) {
|
||||
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
|
||||
$phpWeekday = (int)$date->format('N'); // 1-7
|
||||
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
|
||||
|
||||
$dailyContributions[$dayKey] = [
|
||||
'date' => $dayKey,
|
||||
'count' => 0,
|
||||
'weekday' => (int)$date->format('N')
|
||||
'weekday' => $jsWeekday
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user