Skip to content

Commit

Permalink
Merge branch 'main' into feat/glossary-toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
OLILHR authored Jan 12, 2025
2 parents 9035751 + c4a005b commit 13a77d1
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
output_location: "build" # Built app content directory - optional
skip_deploy_on_missing_secrets: true # dependabot related
###### End of Repository/Build Configurations ######
env:
VITE_AUTH0_CLIENT_ID: Hku0EniRjy4B2krnx1sCwTIOzAiVta1B

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
api_location: "build/server" # Api source code path - optional
output_location: "build" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env:
VITE_AUTH0_CLIENT_ID: VSkXGqlTD7Rf5Q4n9a0h00rInEyL2ZQj
4 changes: 3 additions & 1 deletion src/auth/auth_config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const isDev = import.meta.env.DEV || window.location.hostname === "localhost";

const config = {
domain: "auth.hochfrequenz.de",
clientId: "Hku0EniRjy4B2krnx1sCwTIOzAiVta1B", // shared "HF-stage-apps" auth0 client ID
clientId: isDev ? "" : import.meta.env.VITE_AUTH0_CLIENT_ID || "", // shared "HF-apps-stage/prod" tenant auth0 client IDs
};

export default config as {
Expand Down
55 changes: 16 additions & 39 deletions src/lib/components/features/calendar-table.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<script context="module" lang="ts">
type CacheData = Array<string>;
const dataCache: Record<string, CacheData> = {};
</script>

<script lang="ts">
import type { CalendarEntry } from "$lib/types/calendar-entry";
import type { MonthValue } from "$lib/types/calendar-month";
Expand All @@ -13,45 +8,31 @@
export let selectedType: TypeValue;
let entries: CalendarEntry[] = [];
let isLoading = false;
let isLoading = true;
// split <number> and <string> ("WT"/"LWT")
function formatWorkday(workday: string): string {
return workday.replace(/(\d+)([a-zA-Z]+)/g, "$1 $2");
}
async function fetchData(): Promise<CacheData> {
const cacheKey = `${selectedYear}-${selectedType}`;
if (dataCache[cacheKey]) {
return dataCache[cacheKey];
}
async function fetchData(): Promise<string[]> {
const requestUrl =
selectedType === "ALL"
? `https://fristenkalender.azurewebsites.net/api/GenerateAllFristen/${selectedYear}`
: `https://fristenkalender.azurewebsites.net/api/GenerateFristenForType/${selectedYear}/${selectedType}`;
try {
const response = await fetch(requestUrl, {
method: "GET",
mode: "cors",
});
const response = await fetch(requestUrl, {
method: "GET",
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
dataCache[cacheKey] = data;
return data;
} catch (error) {
console.error("Error fetching data:", error);
throw error;
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
}
function processData(data: CacheData): CalendarEntry[] {
function processData(data: string[]): CalendarEntry[] {
let yearSelected = selectedYear;
let monthSelected = parseInt(selectedMonth);
Expand Down Expand Up @@ -114,14 +95,12 @@
async function loadData(): Promise<void> {
if (!selectedYear || !selectedMonth || !selectedType) return;
isLoading = true;
try {
const data = await fetchData();
entries = processData(data);
} catch (error) {
console.error("Error in loadData:", error);
console.error("Error while attempting to load data", error);
entries = [];
} finally {
isLoading = false;
Expand All @@ -134,13 +113,11 @@
</script>

<div class="h-full w-full relative flex flex-col overflow-hidden">
{#if isLoading}
<div class="flex justify-center items-center p-4">
<span>Lade Fristenkalender ...</span>
</div>
{:else if entries.length === 0}
<span>Keine Fristen für den ausgewählten Zeitraum gefunden.</span>
{:else}
{#if !isLoading && entries.length === 0}
<span class="text-lg text-transform: uppercase"
>Keine Fristen für den ausgewählten Zeitraum gefunden.</span
>
{:else if !isLoading}
<div class="overflow-auto flex-1 min-h-0">
<table class="w-full text-left">
<thead class="text-sm bg-tint uppercase sticky top-0 z-10">
Expand Down
5 changes: 2 additions & 3 deletions src/lib/services/download-ics.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export async function downloadCalendar(year: number): Promise<void> {
try {
const apiEndpoint = `https://fristenkalender.azurewebsites.net/api/GenerateAndExportWholeCalendar/calendar/[email protected]/${year}`;
const proxyUrl = `https://api.allorigins.win/raw?url=${encodeURIComponent(apiEndpoint)}`;

const response = await fetch(proxyUrl);
const response = await fetch(apiEndpoint);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
Expand All @@ -14,7 +13,7 @@ export async function downloadCalendar(year: number): Promise<void> {

const link = document.createElement("a");
link.href = url;
link.download = `HFFristenkalender${year}.ics`;
link.download = `Hochfrequenz_Fristenkalender_${year}.ics`;

document.body.appendChild(link);
link.click();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 13a77d1

Please sign in to comment.