mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-07-16 17:48:51 +02:00
feat:#4 updated for custom ical links
This commit is contained in:
@ -14,8 +14,8 @@
|
|||||||
//You should have received a copy of the GNU Affero General Public License
|
//You should have received a copy of the GNU Affero General Public License
|
||||||
//along with this program. If not, see <https://www.gnu.org/licenses/>.
|
//along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export async function fetchICalendarEvents() {
|
export async function fetchICalendarEvents(token: string): Promise<string> {
|
||||||
const response = await fetch("https://cal.htwk-leipzig.de/api/feed?token=rk47mvraeb43t3g");
|
const response = await fetch("/api/feed?token=" + token, { method: "GET" });
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Network response was not ok");
|
throw new Error("Network response was not ok");
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,22 @@ import { fetchICalendarEvents } from "@/api/loadICal.ts";
|
|||||||
|
|
||||||
const { t } = useI18n({ useScope: "global" });
|
const { t } = useI18n({ useScope: "global" });
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
token: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectedToken = computed(() => props.token);
|
||||||
|
|
||||||
const mobilePage = inject("mobilePage") as Ref<boolean>;
|
const mobilePage = inject("mobilePage") as Ref<boolean>;
|
||||||
const date: Ref<Date> = ref(new Date());
|
const date: Ref<Date> = ref(new Date());
|
||||||
|
|
||||||
tokenStore().setToken("3rz8vb3974tr2b")
|
|
||||||
|
|
||||||
|
|
||||||
const { data: calendar } = useQuery({
|
const { data: calendar } = useQuery({
|
||||||
queryKey: ["userCalendar", tokenStore().token],
|
queryKey: ["userCalendar", selectedToken],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
fetchICalendarEvents(),
|
fetchICalendarEvents(selectedToken.value),
|
||||||
select: (data) => {
|
select: (data) => {
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -2,8 +2,35 @@
|
|||||||
|
|
||||||
import CalendarViewer from "@/components/CalendarViewer.vue";
|
import CalendarViewer from "@/components/CalendarViewer.vue";
|
||||||
import DynamicPage from "@/view/DynamicPage.vue";
|
import DynamicPage from "@/view/DynamicPage.vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { extractToken } from "@/helpers/token.ts";
|
||||||
|
import { useToast } from "primevue/usetoast";
|
||||||
|
import moduleStore from "@/store/moduleStore.ts";
|
||||||
|
import tokenStore from "@/store/tokenStore.ts";
|
||||||
|
|
||||||
|
const { t } = useI18n({ useScope: "global" });
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
|
const token = ref("");
|
||||||
|
|
||||||
|
function loadCalendar() {
|
||||||
|
try {
|
||||||
|
token.value = extractToken(token.value);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
toast.add({
|
||||||
|
severity: "error",
|
||||||
|
summary: t("editCalendarView.error"),
|
||||||
|
detail: t("editCalendarView.invalidToken"),
|
||||||
|
life: 3000,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleStore().removeAllModules();
|
||||||
|
tokenStore().setToken(token.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -16,16 +43,20 @@ import DynamicPage from "@/view/DynamicPage.vue";
|
|||||||
>
|
>
|
||||||
<template #selection="{ flexSpecs }">
|
<template #selection="{ flexSpecs }">
|
||||||
<InputText
|
<InputText
|
||||||
|
v-model="token"
|
||||||
:placeholder="$t('userCalender.searchPlaceholder')"
|
:placeholder="$t('userCalender.searchPlaceholder')"
|
||||||
:class="flexSpecs"
|
:class="flexSpecs"
|
||||||
|
@keyup.enter="loadCalendar()"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
:label="$t('userCalender.searchButton')"
|
:label="$t('userCalender.searchButton')"
|
||||||
icon="pi pi-refresh"
|
icon="pi pi-refresh"
|
||||||
|
@click="loadCalendar()"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<CalendarViewer
|
<CalendarViewer
|
||||||
|
:token="tokenStore().token"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</DynamicPage>
|
</DynamicPage>
|
||||||
|
Reference in New Issue
Block a user