WIP: Frontend implementation #1
4 changed files with 62 additions and 27 deletions
frontend: Login-Redirect for unauth requests
commit
c8b6e4757f
|
|
@ -3,3 +3,16 @@
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.fade-enter-active,
|
||||||
|
.fade-leave-active {
|
||||||
|
transition: opacity .2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-enter-from,
|
||||||
|
.fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
export default defineNuxtRouteMiddleware((to) => {
|
export default defineNuxtRouteMiddleware((to, from) => {
|
||||||
if (import.meta.server) return // SSR ignorieren
|
if (import.meta.server) return // SSR ignorieren
|
||||||
// allow login-page
|
// allow login-page
|
||||||
|
|
||||||
|
if (to.meta.requiresAuth !== true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const { token, loadToken } = useAuth()
|
const { token, loadToken } = useAuth()
|
||||||
loadToken()
|
loadToken()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
requiresAuth: true
|
||||||
|
})
|
||||||
|
|
||||||
import { ref, onMounted } from "vue"
|
import { ref, onMounted } from "vue"
|
||||||
|
|
||||||
const { loadToken } = useAuth()
|
const { loadToken } = useAuth()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
requiresAuth: true
|
||||||
|
})
|
||||||
|
|
||||||
import { ref, onMounted } from "vue"
|
import { ref, onMounted } from "vue"
|
||||||
|
|
||||||
const { apiFetch } = useApi()
|
const { apiFetch } = useApi()
|
||||||
|
|
@ -12,7 +17,7 @@ const newServer = ref({
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const error = ref("")
|
const error = ref("")
|
||||||
|
const showCreateForm = ref(false)
|
||||||
const editingId = ref<number | null>(null)
|
const editingId = ref<number | null>(null)
|
||||||
|
|
||||||
const editServer = ref({
|
const editServer = ref({
|
||||||
|
|
@ -106,31 +111,6 @@ onMounted(() => {
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<h1 class="text-3xl font-bold">Server Verwaltung</h1>
|
<h1 class="text-3xl font-bold">Server Verwaltung</h1>
|
||||||
|
|
||||||
<!-- Neues Server-Formular -->
|
|
||||||
<div class="p-4 bg-white shadow rounded space-y-4">
|
|
||||||
<h2 class="text-xl font-semibold">Neuen Server anlegen</h2>
|
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<input v-model="newServer.hostname" type="text" placeholder="Server Name" class="border p-2 rounded" />
|
|
||||||
|
|
||||||
<textarea v-model="newServer.description" placeholder="Beschreibung (optional)"
|
|
||||||
class="border p-2 rounded" />
|
|
||||||
|
|
||||||
<select v-model="newServer.owner_id" class="border p-2 rounded">
|
|
||||||
<option :value="null">Kein Owner</option>
|
|
||||||
<option v-for="owner in owners" :key="owner.id" :value="owner.id">
|
|
||||||
{{ owner.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
<button @click="createServer"
|
|
||||||
class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 self-start">
|
|
||||||
Speichern
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Server-Liste -->
|
<!-- Server-Liste -->
|
||||||
<div class="p-4 bg-white shadow rounded">
|
<div class="p-4 bg-white shadow rounded">
|
||||||
<h2 class="text-xl font-semibold mb-4">Server Liste</h2>
|
<h2 class="text-xl font-semibold mb-4">Server Liste</h2>
|
||||||
|
|
@ -220,5 +200,38 @@ onMounted(() => {
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
@click="showCreateForm = !showCreateForm"
|
||||||
|
class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
{{ showCreateForm ? "Formular ausblenden" : "Neuen Server anlegen" }}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Neues Server-Formular -->
|
||||||
|
<Transition name="fade">
|
||||||
|
<div v-if="showCreateForm" class="p-4 bg-white shadow rounded space-y-4">
|
||||||
|
<h2 class="text-xl font-semibold">Neuen Server anlegen</h2>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<input v-model="newServer.hostname" type="text" placeholder="Server Name" class="border p-2 rounded" />
|
||||||
|
|
||||||
|
<textarea v-model="newServer.description" placeholder="Beschreibung (optional)"
|
||||||
|
class="border p-2 rounded" />
|
||||||
|
|
||||||
|
<select v-model="newServer.owner_id" class="border p-2 rounded">
|
||||||
|
<option :value="null">Kein Owner</option>
|
||||||
|
<option v-for="owner in owners" :key="owner.id" :value="owner.id">
|
||||||
|
{{ owner.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<button @click="createServer"
|
||||||
|
class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 self-start">
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue