diff --git a/src/App.svelte b/src/App.svelte index 3e30b8ad..9871981e 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -69,6 +69,9 @@ import Donations from "./components/donations/Donations.svelte"; import DonationDetail from "./components/donations/DonationDetail.svelte"; import GroupDetail from "./components/groups/GroupDetail.svelte"; +import ScanStationsOverview from "./components/scanstations/ScanStationsOverview.svelte"; +import ScanStations from "./components/scanstations/ScanStations.svelte"; +import ScanStationDetail from "./components/scanstations/ScanStationDetail.svelte"; store.init(); registerSW(); @@ -180,6 +183,14 @@ + + + + + + + + diff --git a/src/components/dashboard/Dashboard.svelte b/src/components/dashboard/Dashboard.svelte index 4c66b23c..f095e11c 100644 --- a/src/components/dashboard/Dashboard.svelte +++ b/src/components/dashboard/Dashboard.svelte @@ -187,6 +187,21 @@ d="M2 22a8 8 0 1 1 16 0H2zm8-9c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6zm10 4h4v2h-4v-2zm-3-5h7v2h-7v-2zm2-5h5v2h-5V7z" /> {$_('contacts')} + {#if store.state.jwtinfo.userdetails.permissions.includes('STATION:GET')} + + + {$_('scanstations')} + + {/if} + import { _ } from "svelte-i18n"; + import { clickOutside } from "../base/outsideclick"; + import { focusTrap } from "svelte-focus-trap"; + import { ScanStationService, TrackService } from "@odit/lfk-client-js"; + import Toastify from "toastify-js"; + export let modal_open; + export let new_station; + export let current_stations; + export let copy_modal_open; + let tracks = []; + TrackService.trackControllerGetAll().then((val) => { + tracks = val; + track = tracks[0].id; + }); + function focus(el) { + el.focus(); + } + $: description = ""; + $: track = null; + $: enabled = true; + $: createbtnenabled = track != null; + $: processed_last_submit = true; + (() => { + document.onkeydown = (e) => { + e = e || window.event; + if (e.key === "Escape") { + modal_open = false; + } + if (e.keyCode === 13) { + if (createbtnenabled === true) { + createbtnenabled = false; + submit(); + } + } + }; + })(); + function submit() { + if (processed_last_submit === true) { + processed_last_submit = false; + const toast = Toastify({ + text: $_('scanstation-is-being-added'), + duration: -1, + }).showToast(); + let postdata = { + description, + enabled, + track, + }; + ScanStationService.scanStationControllerPost(postdata) + .then((result) => { + description = ""; + track = tracks[0].id; + enabled = true; + modal_open = false; + // + Toastify({ + text: $_('scanstation-added'), + duration: 500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + current_stations.push(result); + current_stations = current_stations; + new_station=result; + copy_modal_open=true; + }) + .catch((err) => { + // + }) + .finally(() => { + processed_last_submit = true; + // + toast.hideToast(); + }); + } + } + + +{#if modal_open} +
{ + modal_open = false; + }}> +
+ +
+{/if} diff --git a/src/components/scanstations/ConfirmScanStationDeletion.svelte b/src/components/scanstations/ConfirmScanStationDeletion.svelte new file mode 100644 index 00000000..450ee494 --- /dev/null +++ b/src/components/scanstations/ConfirmScanStationDeletion.svelte @@ -0,0 +1,92 @@ + + +{#if modal_open} +
+
+ +
+{/if} diff --git a/src/components/scanstations/CopyScanStationTokenModal.svelte b/src/components/scanstations/CopyScanStationTokenModal.svelte new file mode 100644 index 00000000..2067b175 --- /dev/null +++ b/src/components/scanstations/CopyScanStationTokenModal.svelte @@ -0,0 +1,125 @@ + + +{#if copy_modal_open} + {#if valueCopy != null} + + {/if} +
+
+ +
+{/if} diff --git a/src/components/scanstations/ScanStationDetail.svelte b/src/components/scanstations/ScanStationDetail.svelte new file mode 100644 index 00000000..64df533f --- /dev/null +++ b/src/components/scanstations/ScanStationDetail.svelte @@ -0,0 +1,193 @@ + + + +{#await promise} + {$_('loading-station-details')} +{:then} +
+ +
+ #{original_data.id} + + {#if store.state.jwtinfo.userdetails.permissions.includes('STATION:DELETE')} + {#if delete_triggered} + + + {/if} + {#if !delete_triggered} + + {/if} + {/if} + {#if !delete_triggered} + + {/if} + +
+ +
+ + +
+
+ + +
+
+ +
+

+ { + editable.enabled = !editable.enabled; + }} + name="enabled" + type="checkbox" + checked={editable.enabled} + class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" /> + {$_('this-scanstation-is')} + {#if editable.enabled}{$_('enabled')}{:else}{$_('disabled')}{/if} +

+
+
+{:catch error} + +{/await} diff --git a/src/components/scanstations/ScanStations.svelte b/src/components/scanstations/ScanStations.svelte new file mode 100644 index 00000000..74b636af --- /dev/null +++ b/src/components/scanstations/ScanStations.svelte @@ -0,0 +1,33 @@ + + +
+ + {$_('scanstations')} + {#if store.state.jwtinfo.userdetails.permissions.includes('STATION:CREATE')} + + {/if} + + +
+ +{#if store.state.jwtinfo.userdetails.permissions.includes('STATION:CREATE')} + + +{/if} diff --git a/src/components/scanstations/ScanStationsEmptyState.svelte b/src/components/scanstations/ScanStationsEmptyState.svelte new file mode 100644 index 00000000..5a1baec6 --- /dev/null +++ b/src/components/scanstations/ScanStationsEmptyState.svelte @@ -0,0 +1,21 @@ + + +
+

+ + {$_('you-dont-have-any-scanstations-yet')}.
+ {$_('add-the-first-scanstation')} +

+
+ + + \ No newline at end of file diff --git a/src/components/scanstations/ScanStationsOverview.svelte b/src/components/scanstations/ScanStationsOverview.svelte new file mode 100644 index 00000000..72a64162 --- /dev/null +++ b/src/components/scanstations/ScanStationsOverview.svelte @@ -0,0 +1,169 @@ + + + { + modal_open = false; + active_deletes[event.detail.id] = false; + }} + bind:modal_open + bind:delete_station /> +{#if store.state.jwtinfo.userdetails.permissions.includes('STATION:GET')} + {#await promise} + + {:then} + {#if current_stations.length === 0} + + {:else} + +
+ + + + + + + + + + + {#each current_stations as s} + {#if Object.values(s) + .toString() + .toLowerCase() + .includes(searchvalue)} + + + + + {#if active_deletes[s.id] === true} + + {:else} + + {/if} + + {/if} + {/each} + +
+ {$_('track')} + + {$_('description')} + + {$_('status')} + + {$_('action')} +
+ + +
+
+
+ {s.description} +
+
+
+
+
+ {#if s.enabled} + {$_('active')} + {:else} + {$_('inactive')} + {/if} +
+
+ + + + {$_('details')} + {#if store.state.jwtinfo.userdetails.permissions.includes('STATION:DELETE')} + + {/if} +
+
+ {/if} + {:catch error} +
+ + {$_('general_promise_error')} + {error} + +
+ {/await} +{/if} diff --git a/src/components/scanstations/scanstations_empty.svg b/src/components/scanstations/scanstations_empty.svg new file mode 100644 index 00000000..e66691db --- /dev/null +++ b/src/components/scanstations/scanstations_empty.svg @@ -0,0 +1 @@ + \ No newline at end of file