From 895f508c29156b7b8066c1c8997c84aed21f26df Mon Sep 17 00:00:00 2001 From: flfeders Date: Sun, 7 Apr 2024 19:10:17 +0200 Subject: [PATCH] Changes --- spaces/pages/workingtimes/index.vue | 105 ++++++---------------------- 1 file changed, 22 insertions(+), 83 deletions(-) diff --git a/spaces/pages/workingtimes/index.vue b/spaces/pages/workingtimes/index.vue index 61f34ab..ed3e90d 100644 --- a/spaces/pages/workingtimes/index.vue +++ b/spaces/pages/workingtimes/index.vue @@ -4,9 +4,6 @@ import customParseFormat from "dayjs/plugin/customParseFormat" dayjs.extend(customParseFormat) - - - definePageMeta({ middleware: "auth" }) @@ -32,7 +29,9 @@ const filteredRows = computed(() => { let times = dataStore.workingtimes - if(dataStore.hasRight('viewTimes')) { + times = times.filter(i => i.profile === filterUser.value) + + /*if(dataStore.hasRight('viewTimes')) { if(filterUser.value !== "") { times = times.filter(i => i.profile === filterUser.value) } @@ -40,7 +39,7 @@ const filteredRows = computed(() => { times = times.filter(i => i.profile === dataStore.getOwnProfile.id) } else { times = [] - } + }*/ return times @@ -73,12 +72,12 @@ const columns = [ sortable:true }, { - key:"start", + key:"startDate", label:"Start", sortable:true }, { - key: "end", + key: "endDate", label: "Ende", sortable:true }, @@ -95,16 +94,12 @@ const columns = [ ] const runningTimeInfo = ref({}) -const configTimeMode = ref("create") - - const startTime = async () => { console.log("started") timeInfo.value = { profile: dataStore.activeProfile.id, - start: dayjs().format("HH:mm:ss"), - date: dayjs().format("YYYY-MM-DD"), + startDate: dayjs(), tenant: dataStore.currentTenant, state: "Im Web gestartet" } @@ -113,28 +108,19 @@ const startTime = async () => { .from("workingtimes") .insert([timeInfo.value]) .select() - if(error) { console.log(error) } else if(data) { //timeInfo.value = data[0] await dataStore.fetchWorkingTimes() - runningTimeInfo.value = dataStore.times.find(time => time.profile === dataStore.activeProfile.id && !time.end) + runningTimeInfo.value = timeInfo.value//dataStore.times.find(time => time.profile === dataStore.activeProfile.id && !time.endDate) } - } const stopStartedTime = async () => { - //console.log(runningTimeInfo.value) - - runningTimeInfo.value.end = dayjs().format("HH:mm:ssZ") + runningTimeInfo.value.endDate = dayjs() runningTimeInfo.value.state = "Im Web gestoppt" - /*const mapNumRange = (num, inMin, inMax, outMin, outMax) => - ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;*/ - - //runningTimeInfo.value.duration = Math.round(mapNumRange(Math.abs(new Date(runningTimeInfo.value.end) - new Date(runningTimeInfo.value.start))/1000/60,0,60,0,1)*100)/100 - const {data,error} = await supabase .from("workingtimes") .update(runningTimeInfo.value) @@ -151,54 +137,10 @@ const stopStartedTime = async () => { } } -if(dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.end)) { +if(dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.endDate)) { runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.end) } - -const createTime = async () => { - - const date = dayjs(itemInfo.value.start).format("YYYY-MM-DD") - const start = dayjs(itemInfo.value.start).format("HH:mm:ssZ") - const end = dayjs(itemInfo.value.end).format("HH:mm:ssZ") - - - - const {data,error} = await supabase - .from("workingtimes") - .insert({...itemInfo.value, date,start,end, tenant: dataStore.currentTenant}) - .select() - - if(error) { - console.log(error) - } else if(data) { - itemInfo.value = {} - toast.add({title: "Zeit erfolgreich erstellt"}) - await dataStore.fetchTimes() - - } -} - -const updateTime = async () => { - const {error} = await supabase - .from("workingTimes") - .update(itemInfo.value) - .eq('id',itemInfo.value.id) - - if(error) { - console.log(error) - } - - toast.add({title: "Zeit erfolgreich gespeichert"}) - await dataStore.fetchTimes() -} - -const format = (date) => { - let dateFormat = dayjs(date).format("DD.MM.YY HH:mm") - - return `${dateFormat}`; -} - const getDuration = (time) => { const minutes = Math.floor(dayjs(time.endDate).diff(dayjs(time.startDate),'minutes',true)) const hours = Math.floor(minutes/60) @@ -210,19 +152,11 @@ const getDuration = (time) => { } } -const setState = async (newState) => { - itemInfo.value.state = newState - await updateTime() -} -