api-feature/import-per-csv #25

Merged
TorstenHettstedt merged 4 commits from api-feature/import-per-csv into master 2023-02-27 17:55:32 +01:00
6 changed files with 179 additions and 1 deletions
+1
View File
@@ -6,6 +6,7 @@
.idea/**/workspace.xml .idea/**/workspace.xml
.idea/**/tasks.xml .idea/**/tasks.xml
.idea/**/usage.statistics.xml .idea/**/usage.statistics.xml
.idea/**/markdown.xml
.idea/**/dictionaries .idea/**/dictionaries
.idea/**/shelf .idea/**/shelf
+16 -1
View File
@@ -1,5 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
create_css_files() {
cd ui/public || exit 2
lessc --source-map less/print.less print.css
lessc --source-map less/global.less global.css
cd ../..
}
install_ui_dependence() {
cd ui/ || exit 2
npm install
cd ..
}
install_api_dependence() { install_api_dependence() {
cd api/ || exit 2 cd api/ || exit 2
composer install composer install
@@ -29,4 +44,4 @@ composer_run() {
docker-compose up -d docker-compose up -d
} }
install_api_dependence && build_ui && test_unit && composer_run && test_api create_css_files && install_ui_dependence && install_api_dependence && build_ui && test_unit && composer_run && test_api
+62
View File
@@ -0,0 +1,62 @@
Aktivität;Dauer;Von;Bis;Kommentar
Arbeit;04:19;2021-07-30 13:01;2021-07-30 17:20;
Mittagspause ;00:45;2021-07-30 12:16;2021-07-30 13:01;
Arbeit;04:22;2021-07-30 07:54;2021-07-30 12:16;
Arbeit;03:25;2021-07-29 13:25;2021-07-29 16:50;
Mittagspause ;01:01;2021-07-29 12:23;2021-07-29 13:25;
Arbeit;04:44;2021-07-29 07:39;2021-07-29 12:23;
Arbeit;04:47;2021-07-28 12:49;2021-07-28 17:37;
Mittagspause ;00:58;2021-07-28 11:51;2021-07-28 12:49;
Arbeit;03:48;2021-07-28 08:02;2021-07-28 11:51;
Arbeit;03:49;2021-07-27 12:34;2021-07-27 16:24;
Mittagspause ;00:47;2021-07-27 11:47;2021-07-27 12:34;
Arbeit;03:20;2021-07-27 08:27;2021-07-27 11:47;
Arbeit;04:47;2021-07-26 12:59;2021-07-26 17:47;
Mittagspause ;00:52;2021-07-26 12:07;2021-07-26 12:59;
Arbeit;03:59;2021-07-26 08:08;2021-07-26 12:07;
Arbeit;05:53;2021-07-23 12:43;2021-07-23 18:37;
Mittagspause ;00:36;2021-07-23 12:07;2021-07-23 12:43;
Arbeit;04:10;2021-07-23 07:57;2021-07-23 12:07;
Arbeit;04:09;2021-07-22 12:54;2021-07-22 17:04;
Mittagspause ;00:42;2021-07-22 12:11;2021-07-22 12:54;
Arbeit;04:16;2021-07-22 07:55;2021-07-22 12:11;
Arbeit;03:11;2021-07-21 13:37;2021-07-21 16:48;
Mittagspause ;01:07;2021-07-21 12:29;2021-07-21 13:37;
Arbeit;04:58;2021-07-21 07:31;2021-07-21 12:29;
Arbeit;01:17;2021-07-20 18:44;2021-07-20 20:02;
Arbeit;03:50;2021-07-20 13:14;2021-07-20 17:04;
Mittagspause ;00:41;2021-07-20 12:32;2021-07-20 13:14;
Arbeit;04:55;2021-07-20 07:37;2021-07-20 12:32;
Arbeit;03:19;2021-07-19 13:12;2021-07-19 16:31;
Mittagspause ;00:52;2021-07-19 12:20;2021-07-19 13:12;
Arbeit;04:28;2021-07-19 07:51;2021-07-19 12:20;
Arbeit;02:48;2021-07-16 12:55;2021-07-16 15:43;
Mittagspause ;00:47;2021-07-16 12:07;2021-07-16 12:55;
Arbeit;04:01;2021-07-16 08:06;2021-07-16 12:07;
Arbeit;03:38;2021-07-15 13:05;2021-07-15 16:43;
Mittagspause ;01:05;2021-07-15 11:59;2021-07-15 13:05;
Arbeit;03:56;2021-07-15 08:02;2021-07-15 11:59;
Arbeit;03:38;2021-07-14 13:07;2021-07-14 16:45;
Mittagspause ;01:00;2021-07-14 12:07;2021-07-14 13:07;
Arbeit;04:00;2021-07-14 08:06;2021-07-14 12:07;
Arbeit;04:22;2021-07-13 12:53;2021-07-13 17:15;
Mittagspause ;01:03;2021-07-13 11:50;2021-07-13 12:53;
Arbeit;03:47;2021-07-13 08:02;2021-07-13 11:50;
Arbeit;03:26;2021-07-12 13:02;2021-07-12 16:28;
Mittagspause ;01:03;2021-07-12 11:58;2021-07-12 13:02;
Arbeit;04:14;2021-07-12 07:44;2021-07-12 11:58;
Arbeit;03:57;2021-07-09 13:09;2021-07-09 17:06;
Mittagspause ;01:06;2021-07-09 12:02;2021-07-09 13:09;
Arbeit;03:57;2021-07-09 08:04;2021-07-09 12:02;
Arbeit;03:17;2021-07-08 13:12;2021-07-08 16:29;
Mittagspause ;01:07;2021-07-08 12:04;2021-07-08 13:12;
Arbeit;04:00;2021-07-08 08:03;2021-07-08 12:04;
Arbeit;03:41;2021-07-07 13:08;2021-07-07 16:49;
Mittagspause ;01:00;2021-07-07 12:07;2021-07-07 13:08;
Arbeit;04:05;2021-07-07 08:02;2021-07-07 12:07;
Arbeit;02:50;2021-07-06 13:05;2021-07-06 15:55;
Mittagspause ;01:05;2021-07-06 11:59;2021-07-06 13:05;
Arbeit;03:49;2021-07-06 08:10;2021-07-06 11:59;
Arbeit;03:32;2021-07-05 13:00;2021-07-05 16:33;
Mittagspause ;00:59;2021-07-05 12:00;2021-07-05 13:00;
Arbeit;03:48;2021-07-05 08:12;2021-07-05 12:00;
1 Aktivität Dauer Von Bis Kommentar
2 Arbeit 04:19 2021-07-30 13:01 2021-07-30 17:20
3 Mittagspause 00:45 2021-07-30 12:16 2021-07-30 13:01
4 Arbeit 04:22 2021-07-30 07:54 2021-07-30 12:16
5 Arbeit 03:25 2021-07-29 13:25 2021-07-29 16:50
6 Mittagspause 01:01 2021-07-29 12:23 2021-07-29 13:25
7 Arbeit 04:44 2021-07-29 07:39 2021-07-29 12:23
8 Arbeit 04:47 2021-07-28 12:49 2021-07-28 17:37
9 Mittagspause 00:58 2021-07-28 11:51 2021-07-28 12:49
10 Arbeit 03:48 2021-07-28 08:02 2021-07-28 11:51
11 Arbeit 03:49 2021-07-27 12:34 2021-07-27 16:24
12 Mittagspause 00:47 2021-07-27 11:47 2021-07-27 12:34
13 Arbeit 03:20 2021-07-27 08:27 2021-07-27 11:47
14 Arbeit 04:47 2021-07-26 12:59 2021-07-26 17:47
15 Mittagspause 00:52 2021-07-26 12:07 2021-07-26 12:59
16 Arbeit 03:59 2021-07-26 08:08 2021-07-26 12:07
17 Arbeit 05:53 2021-07-23 12:43 2021-07-23 18:37
18 Mittagspause 00:36 2021-07-23 12:07 2021-07-23 12:43
19 Arbeit 04:10 2021-07-23 07:57 2021-07-23 12:07
20 Arbeit 04:09 2021-07-22 12:54 2021-07-22 17:04
21 Mittagspause 00:42 2021-07-22 12:11 2021-07-22 12:54
22 Arbeit 04:16 2021-07-22 07:55 2021-07-22 12:11
23 Arbeit 03:11 2021-07-21 13:37 2021-07-21 16:48
24 Mittagspause 01:07 2021-07-21 12:29 2021-07-21 13:37
25 Arbeit 04:58 2021-07-21 07:31 2021-07-21 12:29
26 Arbeit 01:17 2021-07-20 18:44 2021-07-20 20:02
27 Arbeit 03:50 2021-07-20 13:14 2021-07-20 17:04
28 Mittagspause 00:41 2021-07-20 12:32 2021-07-20 13:14
29 Arbeit 04:55 2021-07-20 07:37 2021-07-20 12:32
30 Arbeit 03:19 2021-07-19 13:12 2021-07-19 16:31
31 Mittagspause 00:52 2021-07-19 12:20 2021-07-19 13:12
32 Arbeit 04:28 2021-07-19 07:51 2021-07-19 12:20
33 Arbeit 02:48 2021-07-16 12:55 2021-07-16 15:43
34 Mittagspause 00:47 2021-07-16 12:07 2021-07-16 12:55
35 Arbeit 04:01 2021-07-16 08:06 2021-07-16 12:07
36 Arbeit 03:38 2021-07-15 13:05 2021-07-15 16:43
37 Mittagspause 01:05 2021-07-15 11:59 2021-07-15 13:05
38 Arbeit 03:56 2021-07-15 08:02 2021-07-15 11:59
39 Arbeit 03:38 2021-07-14 13:07 2021-07-14 16:45
40 Mittagspause 01:00 2021-07-14 12:07 2021-07-14 13:07
41 Arbeit 04:00 2021-07-14 08:06 2021-07-14 12:07
42 Arbeit 04:22 2021-07-13 12:53 2021-07-13 17:15
43 Mittagspause 01:03 2021-07-13 11:50 2021-07-13 12:53
44 Arbeit 03:47 2021-07-13 08:02 2021-07-13 11:50
45 Arbeit 03:26 2021-07-12 13:02 2021-07-12 16:28
46 Mittagspause 01:03 2021-07-12 11:58 2021-07-12 13:02
47 Arbeit 04:14 2021-07-12 07:44 2021-07-12 11:58
48 Arbeit 03:57 2021-07-09 13:09 2021-07-09 17:06
49 Mittagspause 01:06 2021-07-09 12:02 2021-07-09 13:09
50 Arbeit 03:57 2021-07-09 08:04 2021-07-09 12:02
51 Arbeit 03:17 2021-07-08 13:12 2021-07-08 16:29
52 Mittagspause 01:07 2021-07-08 12:04 2021-07-08 13:12
53 Arbeit 04:00 2021-07-08 08:03 2021-07-08 12:04
54 Arbeit 03:41 2021-07-07 13:08 2021-07-07 16:49
55 Mittagspause 01:00 2021-07-07 12:07 2021-07-07 13:08
56 Arbeit 04:05 2021-07-07 08:02 2021-07-07 12:07
57 Arbeit 02:50 2021-07-06 13:05 2021-07-06 15:55
58 Mittagspause 01:05 2021-07-06 11:59 2021-07-06 13:05
59 Arbeit 03:49 2021-07-06 08:10 2021-07-06 11:59
60 Arbeit 03:32 2021-07-05 13:00 2021-07-05 16:33
61 Mittagspause 00:59 2021-07-05 12:00 2021-07-05 13:00
62 Arbeit 03:48 2021-07-05 08:12 2021-07-05 12:00
+7
View File
File diff suppressed because one or more lines are too long
@@ -5,10 +5,12 @@
import xIcon from '@iconify-icons/oi/x' import xIcon from '@iconify-icons/oi/x'
import EditByDay from "./Formular/EditByDay.svelte"; import EditByDay from "./Formular/EditByDay.svelte";
import EditByWeek from "./Formular/EditByWeek.svelte"; import EditByWeek from "./Formular/EditByWeek.svelte";
import ImportCsv from "./Formular/ImportCsv.svelte";
import {TimekeepingDate} from "../../components/TimekeepingDate.svelte"; import {TimekeepingDate} from "../../components/TimekeepingDate.svelte";
const DAILY_EDIT = 0 const DAILY_EDIT = 0
const WEEKLY_EDIT = 1 const WEEKLY_EDIT = 1
const CSV_IMPORT = 2
const Controller = { const Controller = {
'saveRecord': () => { 'saveRecord': () => {
@@ -65,6 +67,11 @@
}) })
} }
} }
const CsvController = {
'makeTimekeepingList': () => {
MenuController.dailyEdit()
}
}
const MenuController = { const MenuController = {
'dailyEdit': () => { 'dailyEdit': () => {
period_of_edit = DAILY_EDIT period_of_edit = DAILY_EDIT
@@ -75,6 +82,11 @@
period_of_edit = WEEKLY_EDIT period_of_edit = WEEKLY_EDIT
makeTimekeepingList = WeekController.makeTimekeepingList makeTimekeepingList = WeekController.makeTimekeepingList
makeTimekeepingList() makeTimekeepingList()
},
'csvImport': () => {
period_of_edit = CSV_IMPORT
activeRecordList = []
makeTimekeepingList = CsvController.makeTimekeepingList
} }
} }
@@ -92,6 +104,7 @@
<nav class="menu"> <nav class="menu">
<span on:click={MenuController.dailyEdit} class:active={period_of_edit === DAILY_EDIT}>Täglich</span> <span on:click={MenuController.dailyEdit} class:active={period_of_edit === DAILY_EDIT}>Täglich</span>
<span on:click={MenuController.weeklyEdit} class:active={period_of_edit === WEEKLY_EDIT}>Wöchentlich</span> <span on:click={MenuController.weeklyEdit} class:active={period_of_edit === WEEKLY_EDIT}>Wöchentlich</span>
<span on:click={MenuController.csvImport} class:active={period_of_edit === CSV_IMPORT}>Import per CSV</span>
</nav> </nav>
{#if period_of_edit === DAILY_EDIT} {#if period_of_edit === DAILY_EDIT}
<EditByDay bind:activeRecordList bind:activeDate bind:makeTimekeepingList/> <EditByDay bind:activeRecordList bind:activeDate bind:makeTimekeepingList/>
@@ -99,6 +112,9 @@
{#if period_of_edit === WEEKLY_EDIT} {#if period_of_edit === WEEKLY_EDIT}
<EditByWeek bind:activeRecordList bind:activeDate bind:makeTimekeepingList/> <EditByWeek bind:activeRecordList bind:activeDate bind:makeTimekeepingList/>
{/if} {/if}
{#if period_of_edit === CSV_IMPORT}
<ImportCsv bind:activeRecordList bind:makeTimekeepingList/>
{/if}
<fieldset name="buttons"> <fieldset name="buttons">
<button on:click={Controller.saveRecord} type="button">Übernehmen und Weiter <button on:click={Controller.saveRecord} type="button">Übernehmen und Weiter
<IconifyIcon icon={checkIcon} color="green"/> <IconifyIcon icon={checkIcon} color="green"/>
@@ -0,0 +1,77 @@
<script>
import Papa from '../../../papaparse.min'
export let activeRecordList = []
let imported_data = []
let files = null
const VerarbeiteDateien = () => {
for (const file of files) {
VerarbeiteCsv(file)
}
}
const VerarbeiteCsv = file => {
Papa.parse(file, {
header: true,
skipEmptyLines: true,
complete: results => {
let cash_work_days = {}
results.data.forEach(item => {
// noinspection JSNonASCIINames
let activity = item['Aktivität']
if (activity.trim() === 'Mittagspause') {
return
}
let work_from = new Date(item['Von'])
let work_to = new Date(item['Bis'])
let actual_day = work_from.toISOString().substring(0, 10)
let actual_work_hours = (work_to - work_from)/(1000*60*60)
cash_work_days[actual_day] ??= 0
TorstenHettstedt marked this conversation as resolved Outdated
Outdated
Review
Nutze [Nullish coalescing assignment (??=)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_assignment)
cash_work_days[actual_day] += actual_work_hours
})
for (let day in cash_work_days) {
let hours = cash_work_days[day]
let hours_digits = Math.trunc(hours)
let minutes_digits = Math.round((hours-hours_digits)*60)
let working_time = String(hours_digits).padStart(2, '0') + ":"
+ String(minutes_digits).padStart(2, '0') + ':00'
activeRecordList.push({workingTime: working_time, workingDay: day})
}
imported_data = activeRecordList
},
})
}
</script>
<fieldset>
<legend>Download-Liste</legend>
<div class="zelle">
<label for="csv-file">Download der Zeiten von <i>aTimeLogger2</i></label>
<input type="file" accept="text/csv" id="csv-file" bind:files/>
<button type="button" on:click={VerarbeiteDateien}>Upload</button>
</div>
</fieldset>
<fieldset name="record-data-for-import">
<div>
{#if imported_data.length < 1}
<p>Loading...</p>
{:else}
<table>
<tbody>
{#each imported_data as item}
<tr>
<td>
{item.workingDay}
</td>
<td>
{item.workingTime}
</td>
</tr>
{/each}
</tbody>
</table>
{/if}
</div>
</fieldset>