Enhance login functionality in AuthController and AuthService; add optional action parameter to login method, execute corresponding actions post-login, and handle action warnings. Update frontend components to trigger data refresh on successful login and display warnings if actions fail. Adjust SQL query in TimeEntryService for improved grouping.
This commit is contained in:
@@ -39,7 +39,9 @@
|
||||
import { onMounted, onBeforeUnmount, ref, computed } from 'vue'
|
||||
import { useTimeStore } from '../stores/timeStore'
|
||||
import { useAuthStore } from '../stores/authStore'
|
||||
import { API_BASE_URL } from '@/config/api'
|
||||
|
||||
const API_URL = API_BASE_URL
|
||||
const timeStore = useTimeStore()
|
||||
const authStore = useAuthStore()
|
||||
const stats = ref({})
|
||||
@@ -92,7 +94,7 @@ const fetchStats = async () => {
|
||||
|
||||
const fetchCurrentState = async () => {
|
||||
try {
|
||||
const response = await fetch('${API_URL}/time-entries/current-state', {
|
||||
const response = await fetch(`${API_URL}/time-entries/current-state`, {
|
||||
headers: authStore.getAuthHeaders()
|
||||
})
|
||||
|
||||
@@ -108,7 +110,7 @@ const fetchCurrentState = async () => {
|
||||
// Lade die aktuellen Worklog-Daten (nur einmal pro Minute)
|
||||
const fetchWorklogData = async () => {
|
||||
try {
|
||||
const response = await fetch('${API_URL}/time-entries/running', {
|
||||
const response = await fetch(`${API_URL}/time-entries/running`, {
|
||||
headers: authStore.getAuthHeaders()
|
||||
})
|
||||
|
||||
@@ -277,7 +279,7 @@ const handleAction = async (action) => {
|
||||
try {
|
||||
loading.value = true
|
||||
|
||||
const response = await fetch('${API_URL}/time-entries/clock', {
|
||||
const response = await fetch(`${API_URL}/time-entries/clock`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...authStore.getAuthHeaders(),
|
||||
@@ -341,6 +343,14 @@ const rightButton = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
// Event-Handler für Login
|
||||
const handleLoginCompleted = async () => {
|
||||
console.log('DEBUG: Login completed, lade Daten neu...')
|
||||
await fetchCurrentState()
|
||||
await fetchWorklogData()
|
||||
await fetchStats()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Initiales Laden
|
||||
await fetchCurrentState()
|
||||
@@ -359,11 +369,15 @@ onMounted(async () => {
|
||||
updateCurrentlyWorkedTime()
|
||||
updateOpenTime()
|
||||
}, 500)
|
||||
|
||||
// Event-Listener für Login
|
||||
window.addEventListener('login-completed', handleLoginCompleted)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (dataFetchInterval) clearInterval(dataFetchInterval)
|
||||
if (displayUpdateInterval) clearInterval(displayUpdateInterval)
|
||||
window.removeEventListener('login-completed', handleLoginCompleted)
|
||||
})
|
||||
|
||||
const displayRows = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user