feat:#16 added frontend button

This commit is contained in:
Elmar Kresse
2024-11-04 15:59:28 +01:00
parent 42172fb0a5
commit 3265c5515f
3 changed files with 62 additions and 3 deletions

View File

@ -30,6 +30,18 @@ defineProps<{
disabled: boolean;
onClick: () => void;
};
upperButton?: {
label: string;
icon: string;
disabled: boolean;
onClick: () => void;
};
lowerButton?: {
label: string;
icon: string;
disabled: boolean;
onClick: () => void;
};
}>();
const slots = useSlots();
@ -98,6 +110,23 @@ const hasContent = computed(() => {
@click="button.onClick()"
/>
</div>
<div
v-if="lowerButton"
class="flex flex-wrap my-3 gap-2 align-items-center justify-content-end"
>
<Button
:disabled="lowerButton.disabled"
class="col-12 md:col-4"
:icon="lowerButton.icon"
:label="lowerButton.label"
@click="lowerButton.onClick()"
/>
</div>
<div
v-if="button"
class="flex flex-wrap my-3 gap-2 align-items-center justify-content-end"
>
</div>
</div>
</div>
</template>

View File

@ -17,12 +17,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<script lang="ts" setup>
import { Ref, computed, ref, watch } from "vue";
import { Ref, computed, ref, watch, inject } from "vue";
import { fetchRoom } from "@/api/fetchRoom.ts";
import DynamicPage from "@/view/DynamicPage.vue";
import RoomOccupation from "@/components/RoomOccupation.vue";
import { computedAsync } from "@vueuse/core";
import { router } from "@/main";
import tokenStore from "@/store/tokenStore.ts";
type Room = {
name: string;
@ -80,6 +81,27 @@ watch(selectedRoom, (newRoom: Room) => {
});
}
});
const domain = import.meta.env.SSR
? inject<string>("domain")!
: window.location.hostname;
const getLink = (selectedRoom: string) =>
"https://" + domain + "/api/feed/room?id=" + selectedRoom;
const button = computed(() => {
return {
label: "Copy iCal Link for" + selectedRoom.value.name,
icon: "pi pi-calendar",
disabled: selectedRoom.value.name === "",
onClick: () => {
// Copy iCal link to clipboard
// localhost/api/feed/room?id=selectedRoom.value.name
navigator.clipboard.writeText(getLink(selectedRoom.value.name));
},
};
});
</script>
<template>
@ -88,6 +110,7 @@ watch(selectedRoom, (newRoom: Room) => {
:headline="$t('roomFinderPage.headline')"
:sub-title="$t('roomFinderPage.detail')"
icon="pi pi-search"
:lower-button="button"
>
<template #selection>
<Dropdown
@ -104,5 +127,12 @@ watch(selectedRoom, (newRoom: Room) => {
<template #content>
<RoomOccupation :room="selectedRoom.name" />
</template>
<template #footer>
<Button
class="col-12 md:col-4 mt-3"
:label="$t('roomFinderPage.reset')"
@click="selectedRoom.name = ''"
/>
</template>
</DynamicPage>
</template>

View File

@ -2,10 +2,10 @@ package grpc
import (
"context"
"fmt"
"github.com/pocketbase/pocketbase"
pb "htwkalender/common/genproto/modules"
"htwkalender/data-manager/service/db"
"log/slog"
)
type RoomServiceHandler struct {
@ -20,7 +20,7 @@ func (s *RoomServiceHandler) GetRoomEvents(ctx context.Context, in *pb.GetRoomRe
"room", in.Room,
)
fmt.Errorf("Getting events for room %s", in.Room)
slog.Error("GetRoomEvents", "room", in.Room)
// get events from database by room
events, err := db.GetRoomSchedule(s.app, in.Room)