<script setup lang="ts">
definePageMeta({ middleware: ['role-admin'] })

const serverLogs = ref<string>('')

async function runJobs(job: string) {
  switch (job) {
    case 'fetch_cover':
      serverLogs.value = await $fetch('jobs/fetch-cover', { method: 'POST' })
      break
  }
}
</script>

<template>
  <div class="flex flex-col gap-4 md:flex-row">
    <UCard class="w-full md:w-1/2">
      <template #header>
        <h1 class="font-sans text-3xl font-bold">
          Server Jobs
        </h1>
        <UButton class="mt-4" @click="runJobs('fetch_cover')">
          Cover Bilder anfragen
        </UButton>
      </template>
    </UCard>
    <UCard class="w-full md:w-1/2">
      <template #header>
        <h1 class="font-sans text-3xl font-bold">
          Server Logs
        </h1>
        <UTextarea v-model="serverLogs" autoresize disabled class="mt-4" />
      </template>
    </UCard>
  </div>
</template>

<style scoped>

</style>
