Skip to content

Commit 7eb9d44

Browse files
authored
FV-59 CSV je Zählart mitsamt Dokumentation der CSV-Dateien (#159)
1 parent ce40bf7 commit 7eb9d44

File tree

8 files changed

+138
-8
lines changed

8 files changed

+138
-8
lines changed

frontend/src/App.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,18 @@
5252
</template>
5353

5454
<script setup lang="ts">
55+
import type ConfigurationDTO from "@/types/configuration/ConfigurationDTO";
56+
5557
import { ref } from "vue";
5658
import { useRoute } from "vue-router";
5759
60+
import ConfigurationService from "@/api/service/ConfigurationService";
5861
import SsoUserInfoService from "@/api/service/SsoUserInfoService";
5962
import VersionInfoService from "@/api/service/VersionInfoService";
6063
import TheSnackbar from "@/components/common/TheSnackbar.vue";
6164
import SsoUserInfoResponse from "@/domain/SsoUserInfoResponse";
6265
import VersionInfoResponse from "@/domain/VersionInfoResponse";
66+
import { useConfigurationStore } from "@/store/ConfigurationStore";
6367
import { useSnackbarStore } from "@/store/SnackbarStore";
6468
import { useUserStore } from "@/store/UserStore";
6569
@@ -74,6 +78,7 @@ const frontendVersion = ref<string>("");
7478
const userStore = useUserStore();
7579
const route = useRoute();
7680
const snackbarStore = useSnackbarStore();
81+
const configurationStore = useConfigurationStore();
7782
7883
created();
7984
@@ -102,6 +107,11 @@ function created() {
102107
.catch(() => {
103108
backendVersion.value = "error";
104109
});
110+
ConfigurationService.getConfiguration().then(
111+
(configuration: ConfigurationDTO) => {
112+
configurationStore.setConfiguration(configuration);
113+
}
114+
);
105115
}
106116
107117
function navigateToHandbuch() {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type ConfigurationDTO from "@/types/configuration/ConfigurationDTO";
2+
3+
import FetchService from "@/api/service/FetchService";
4+
5+
export default class ConfigurationService {
6+
private static readonly ENDPOINT: string =
7+
"api/dave-backend-service/configuration";
8+
9+
static getConfiguration(): Promise<ConfigurationDTO> {
10+
return FetchService.getData(
11+
`${this.ENDPOINT}`,
12+
"Beim Laden der Anwendungskonfiguration ist ein Fehler aufgetreten."
13+
);
14+
}
15+
}

frontend/src/components/zaehlung/ZaehlungCard.vue

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@
159159
/>
160160
</template>
161161
<v-list density="compact">
162+
<v-list-item density="compact">
163+
<v-btn
164+
v-tooltip:end="'Link zur Dokumentation der CSV-Datei'"
165+
class="ml-2 mr-2"
166+
icon="mdi-information"
167+
variant="text"
168+
color="secondary"
169+
@click="openCsvDokumentation"
170+
/>
171+
</v-list-item>
162172
<v-list-item density="compact">
163173
<v-btn
164174
v-tooltip:end="'CSV-Muster herunterladen'"
@@ -194,6 +204,7 @@ import ZaehlartIcon from "@/components/icons/ZaehlartIcon.vue";
194204
import ZaehldauerIcon from "@/components/icons/ZaehldauerIcon.vue";
195205
import ZaehlungCardMap from "@/components/map/ZaehlungCardMap.vue";
196206
import ZaehlungGeometrie from "@/components/zaehlung/ZaehlungGeometrie.vue";
207+
import { useConfigurationStore } from "@/store/ConfigurationStore";
197208
import { useSnackbarStore } from "@/store/SnackbarStore";
198209
import Status, { statusIcon } from "@/types/enum/Status";
199210
import Zaehlart from "@/types/enum/Zaehlart";
@@ -216,6 +227,7 @@ const ICON_COLOR = "black";
216227
const loading = ref<boolean>(false);
217228
218229
const snackbarStore = useSnackbarStore();
230+
const configurationStore = useConfigurationStore();
219231
const dateUtils = useDateUtils();
220232
221233
const coordsZaehlstelle = computed<LatLng>(() => {
@@ -343,20 +355,22 @@ function openZaehlungDialog() {
343355
function downloadDummyCsv(): void {
344356
// Beispiel: 62301Q_20210423_Knotenarm2.csv
345357
const zaehlstelleNummer: string = zaehlung.value.zaehlstelleNummer;
346-
const zaehlart: string =
358+
const zaehlartForFileContent: string =
347359
zaehlung.value.zaehlart === Zaehlart.N ? "" : zaehlung.value.zaehlart;
348-
const filename = `${zaehlstelleNummer}${zaehlart}_${zaehlung.value.datum.replace(
360+
const filename = `${zaehlstelleNummer}${zaehlartForFileContent}_${zaehlung.value.datum.replace(
349361
"-",
350362
""
351363
)}_Knotenarm_X.csv`;
352364
353-
const metaHeader = "Zählstellennummer;Zählart;Datum;Knotenarmnummer;;;;;\n";
354-
const metaData = `${zaehlstelleNummer};${zaehlart};${zaehlung.value.datum};<von-Knotenarmnr>;;;;;\n`;
355-
const zaehlungHeader = "Intervallnummer;nach;Pkw;Lkw;Lz;Bus;Krad;Rad;Fuss\n";
365+
const csvFileContent = getCsvContentForAllZaehlarten(
366+
zaehlstelleNummer,
367+
zaehlartForFileContent,
368+
zaehlung.value.datum
369+
);
370+
const csvContentWithFileMetadata =
371+
"data:text/csv;charset=utf-8," + csvFileContent;
356372
357-
const csvContent =
358-
"data:text/csv;charset=utf-8," + metaHeader + metaData + zaehlungHeader;
359-
const encodedUri = encodeURI(csvContent);
373+
const encodedUri = encodeURI(csvContentWithFileMetadata);
360374
const link = document.createElement("a");
361375
link.setAttribute("href", encodedUri);
362376
link.setAttribute("download", filename);
@@ -365,8 +379,29 @@ function downloadDummyCsv(): void {
365379
link.click();
366380
}
367381
382+
function getCsvContentForAllZaehlarten(
383+
zaehlstelleNummer: string,
384+
zaehlart: string,
385+
zaehlungDatum: string
386+
): string {
387+
const metaHeader = "Zählstellennummer;Zählart;Datum;Knotenarmnummer;;;;;\n";
388+
const metaData = `${zaehlstelleNummer};${zaehlart};${zaehlungDatum};<knotenarmnummer>;;;;;\n`;
389+
const zaehlungHeader =
390+
"Intervallnummer;nach;Strassenseite;Richtung;Pkw;Lkw;Lz;Bus;Krad;Rad;Fuss\n";
391+
return metaHeader + metaData + zaehlungHeader;
392+
}
393+
368394
function openChatDialog() {
369395
zaehlung.value.unreadMessagesDienstleister = false;
370396
emits("openChatDialog", zaehlung.value);
371397
}
398+
399+
function openCsvDokumentation(): void {
400+
const linkCsvFile =
401+
configurationStore.getZaehlstelleConfiguration
402+
.linkDocumentationCsvFileForUploadZaehlung;
403+
if (!isEmpty(linkCsvFile)) {
404+
window.open(linkCsvFile);
405+
}
406+
}
372407
</script>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type ConfigurationDTO from "@/types/configuration/ConfigurationDTO";
2+
3+
import { defineStore } from "pinia";
4+
import { computed, ref } from "vue";
5+
6+
import DefaultObjectCreator from "@/util/DefaultObjectCreator";
7+
8+
export const useConfigurationStore = defineStore("configurationStore", () => {
9+
const configuration = ref<ConfigurationDTO>(
10+
DefaultObjectCreator.createDefaultConfigurationDTO()
11+
);
12+
13+
const getMapConfiguration = computed(() => configuration.value.map);
14+
15+
const getZaehlstelleConfiguration = computed(
16+
() => configuration.value.zaehlstelle
17+
);
18+
19+
function setConfiguration(payload: ConfigurationDTO) {
20+
configuration.value = payload;
21+
}
22+
23+
return {
24+
getMapConfiguration,
25+
getZaehlstelleConfiguration,
26+
setConfiguration,
27+
};
28+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type MapConfigurationDTO from "@/types/configuration/MapConfigurationDTO";
2+
import type ZaehlstelleConfigurationDTO from "@/types/configuration/ZaehlstelleConfigurationDTO";
3+
4+
export default interface ConfigurationDTO {
5+
map: MapConfigurationDTO;
6+
zaehlstelle: ZaehlstelleConfigurationDTO;
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default interface MapConfigurationDTO {
2+
lat: string;
3+
lng: string;
4+
zoom: number;
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default interface ZaehlstelleConfigurationDTO {
2+
automaticNumberAssignment: boolean;
3+
linkDocumentationCsvFileForUploadZaehlung: string;
4+
}

frontend/src/util/DefaultObjectCreator.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import type ConfigurationDTO from "@/types/configuration/ConfigurationDTO";
2+
import type MapConfigurationDTO from "@/types/configuration/MapConfigurationDTO";
3+
import type ZaehlstelleConfigurationDTO from "@/types/configuration/ZaehlstelleConfigurationDTO";
14
import type ZaehlungDTO from "@/types/zaehlung/ZaehlungDTO";
25

36
import { LatLng } from "leaflet";
@@ -28,4 +31,27 @@ export default class DefaultObjectCreator {
2831
zaehlung.sonderzaehlung = false;
2932
return zaehlung;
3033
}
34+
35+
public static createDefaultConfigurationDTO(): ConfigurationDTO {
36+
return {
37+
map: this.createDefaultMapConfigurationDTO(),
38+
zaehlstelle: this.createDefaultZaehlstelleConfigurationDTO(),
39+
};
40+
}
41+
42+
public static createDefaultZaehlstelleConfigurationDTO(): ZaehlstelleConfigurationDTO {
43+
return {
44+
automaticNumberAssignment: true,
45+
linkDocumentationCsvFileForUploadZaehlung: "",
46+
};
47+
}
48+
49+
public static createDefaultMapConfigurationDTO(): MapConfigurationDTO {
50+
return {
51+
// München Zentrum
52+
lat: "48.137227",
53+
lng: "11.575517",
54+
zoom: 12,
55+
};
56+
}
3157
}

0 commit comments

Comments
 (0)