<script lang="ts" setup>
import { computed } from 'vue'
import ServiceTabLayout from '@/Components/Panel/ServiceTabLayout.vue'
import WebConsole from '@/Components/Panel/WebConsole.vue'
import type { Service } from '@/types'

interface Props {
  service: Service
  consoleUrl: string | null
}

const props = defineProps<Props>()

const tabs = computed(() => [
  { label: 'Dashboard', icon: 'tabler-dashboard', to: `/services/${props.service.id}/dedicated-panel` },
  { label: 'Console', icon: 'tabler-terminal-2', to: `/services/${props.service.id}/dedicated-panel/console` },
  { label: 'Bandwidth', icon: 'tabler-chart-area-line', to: `/services/${props.service.id}/dedicated-panel/bandwidth` },
  { label: 'Network', icon: 'tabler-network', to: `/services/${props.service.id}/dedicated-panel/network` },
  { label: 'Reinstall', icon: 'tabler-reload', to: `/services/${props.service.id}/dedicated-panel/reinstall` },
  { label: 'Settings', icon: 'tabler-settings', to: `/services/${props.service.id}/dedicated-panel/settings` },
])
</script>

<template>
  <ServiceTabLayout
    :service="service"
    :tabs="tabs"
    :current-tab="`/services/${service.id}/dedicated-panel/console`"
  >
    <VCard elevation="0">
      <VCardTitle class="d-flex align-center gap-2">
        <VIcon icon="tabler-terminal-2" color="primary" />
        IPMI / KVM Console
      </VCardTitle>
      <VCardText>
        <VAlert v-if="!consoleUrl" type="info" variant="tonal" class="mb-4">
          <VAlertTitle>Console Not Available</VAlertTitle>
          The IPMI/KVM console requires SynergyCP API configuration. Ensure the panel is connected.
        </VAlert>
        <WebConsole v-if="consoleUrl" :url="consoleUrl" type="vnc" />
      </VCardText>
    </VCard>
  </ServiceTabLayout>
</template>
