Die Daten für die Ansichten werden von einer API abgefragt.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<Views {params} />
|
||||
<Views />
|
||||
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
export let params;
|
||||
import Views from "./WeeklyViews.svelte";
|
||||
</script>
|
||||
@@ -0,0 +1,31 @@
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
export let params;
|
||||
params = {
|
||||
title: 'Monatsansicht',
|
||||
records: [],
|
||||
isLoading: true
|
||||
}
|
||||
const View = {
|
||||
'browse': () => {
|
||||
fetch(env.API_URL + '/views/working-hours/monthly')
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error('Fail!');
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
params.records = data;
|
||||
params.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
params.isLoading = false;
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
View.browse();
|
||||
</script>
|
||||
|
||||
<Views {params} />
|
||||
+23
-18
@@ -1,5 +1,6 @@
|
||||
<script>
|
||||
export let params;
|
||||
console.log(params)
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -11,25 +12,29 @@
|
||||
<h1>{params.title}</h1>
|
||||
</header>
|
||||
<article>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeitraum</th>
|
||||
<th>Arbeitstage</th>
|
||||
<th>Arbeitsstunden</th>
|
||||
<th>Über- / Unterstunden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each params.records as record}
|
||||
{#if params.isLoading === true}
|
||||
<p>Loading...</p>
|
||||
{:else}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{record.period}</td>
|
||||
<td>{record.workingDays}</td>
|
||||
<td>{record.totalHours}</td>
|
||||
<td>{record.overtime}</td>
|
||||
<th>Zeitraum</th>
|
||||
<th>Arbeitstage</th>
|
||||
<th>Arbeitsstunden</th>
|
||||
<th>Über- / Unterstunden</th>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each params.records as record}
|
||||
<tr>
|
||||
<td>{record.period}</td>
|
||||
<td>{record.workingDays}</td>
|
||||
<td>{record.totalHours}</td>
|
||||
<td>{record.overtime}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
</article>
|
||||
</section>
|
||||
@@ -0,0 +1,31 @@
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
export let params;
|
||||
params = {
|
||||
title: 'Wochenansicht',
|
||||
records: [],
|
||||
isLoading: true
|
||||
}
|
||||
const View = {
|
||||
'browse': () => {
|
||||
fetch(env.API_URL + '/views/working-hours/weekly')
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error('Fail!');
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
params.records = data;
|
||||
params.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
params.isLoading = false;
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
View.browse();
|
||||
</script>
|
||||
|
||||
<Views {params} />
|
||||
@@ -0,0 +1,31 @@
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
export let params;
|
||||
params = {
|
||||
title: 'Jahresansicht',
|
||||
records: [],
|
||||
isLoading: true
|
||||
}
|
||||
const View = {
|
||||
'browse': () => {
|
||||
fetch(env.API_URL + '/views/working-hours/yearly')
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error('Fail!');
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
params.records = data;
|
||||
params.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
params.isLoading = false;
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
View.browse();
|
||||
</script>
|
||||
|
||||
<Views {params} />
|
||||
Reference in New Issue
Block a user