added displayRunningTime.vue
This commit is contained in:
@@ -7,9 +7,18 @@ const toast = useToast()
|
|||||||
|
|
||||||
const runningTimeInfo = ref({})
|
const runningTimeInfo = ref({})
|
||||||
|
|
||||||
|
const projects = ref([])
|
||||||
|
const platform = ref("default")
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
runningTimeInfo.value = (await supabase.from("workingtimes").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
|
runningTimeInfo.value = (await supabase.from("times").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
|
||||||
console.log(runningTimeInfo.value)
|
|
||||||
|
projects.value = (await useSupabaseSelect("projects"))
|
||||||
|
|
||||||
|
if(await useCapacitor().getIsPhone()) {
|
||||||
|
platform.value = "mobile"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
@@ -24,12 +33,12 @@ const startTime = async () => {
|
|||||||
profile: profileStore.activeProfile.id,
|
profile: profileStore.activeProfile.id,
|
||||||
startDate: dayjs(),
|
startDate: dayjs(),
|
||||||
tenant: profileStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
state: "Im Web gestartet",
|
state: platform.value === "mobile" ? "In der App gestartet" : "Im Web gestartet",
|
||||||
source: "Dashboard"
|
source: "Dashboard"
|
||||||
}
|
}
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("workingtimes")
|
.from("times")
|
||||||
.insert([runningTimeInfo.value])
|
.insert([runningTimeInfo.value])
|
||||||
.select()
|
.select()
|
||||||
if(error) {
|
if(error) {
|
||||||
@@ -38,16 +47,16 @@ const startTime = async () => {
|
|||||||
} else if(data) {
|
} else if(data) {
|
||||||
toast.add({title: "Zeit erfolgreich gestartet"})
|
toast.add({title: "Zeit erfolgreich gestartet"})
|
||||||
runningTimeInfo.value = data[0]
|
runningTimeInfo.value = data[0]
|
||||||
console.log(runningTimeInfo.value)
|
//console.log(runningTimeInfo.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopStartedTime = async () => {
|
const stopStartedTime = async () => {
|
||||||
runningTimeInfo.value.endDate = dayjs()
|
runningTimeInfo.value.endDate = dayjs()
|
||||||
runningTimeInfo.value.state = "Im Web gestoppt"
|
runningTimeInfo.value.state = platform.value === "mobile" ? "In der App gestoppt" : "Im Web gestoppt"
|
||||||
|
|
||||||
const {error,status} = await supabase
|
const {error,status} = await supabase
|
||||||
.from("workingtimes")
|
.from("times")
|
||||||
.update(runningTimeInfo.value)
|
.update(runningTimeInfo.value)
|
||||||
.eq('id',runningTimeInfo.value.id)
|
.eq('id',runningTimeInfo.value.id)
|
||||||
|
|
||||||
@@ -79,6 +88,20 @@ const stopStartedTime = async () => {
|
|||||||
v-model="runningTimeInfo.notes"
|
v-model="runningTimeInfo.notes"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
class="mt-2"
|
||||||
|
label="Projekt:"
|
||||||
|
>
|
||||||
|
<USelectMenu
|
||||||
|
v-model="runningTimeInfo.project"
|
||||||
|
:options="projects"
|
||||||
|
searchable
|
||||||
|
:search-attributes="['name','notes','customer']"
|
||||||
|
searchable-placeholder="Suche"
|
||||||
|
value-attribute="id"
|
||||||
|
option-attribute="name"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
<UButton
|
<UButton
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
@click="stopStartedTime"
|
@click="stopStartedTime"
|
||||||
@@ -88,7 +111,7 @@ const stopStartedTime = async () => {
|
|||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<p>Keine Anwesenheit gestartet</p>
|
<p>Keine Zeit gestartet</p>
|
||||||
<UButton
|
<UButton
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
@click="startTime"
|
@click="startTime"
|
||||||
|
|||||||
@@ -47,6 +47,10 @@
|
|||||||
>
|
>
|
||||||
<display-running-time/>
|
<display-running-time/>
|
||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
|
<UDashboardCard
|
||||||
|
>
|
||||||
|
<display-running-working-time/>
|
||||||
|
</UDashboardCard>
|
||||||
<UDashboardCard
|
<UDashboardCard
|
||||||
title="Aufgaben"
|
title="Aufgaben"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ const profileStore = useProfileStore()
|
|||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
<UDashboardCard
|
<UDashboardCard
|
||||||
title="Anwesenheit"
|
title="Anwesenheit"
|
||||||
|
>
|
||||||
|
<display-running-working-time/>
|
||||||
|
</UDashboardCard>
|
||||||
|
<UDashboardCard
|
||||||
|
title="Zeit"
|
||||||
>
|
>
|
||||||
<display-running-time/>
|
<display-running-time/>
|
||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
|
|||||||
Reference in New Issue
Block a user