<template>
    <TableComponent :loading="pods == null" v-for="pods in [repo.get().value]">
        <div class="resource-container pod-container">
            <div class="header">
                <p>Pod</p>
                <p>Namespace</p>
                <p>Age</p>
                <p>Node</p>
                <p>Containers</p>
                <p>Restarts</p>
                <p>Status</p>
                <p>Actions</p>
            </div>
            <PodComponent v-for="(pod, index) in pods" :pod="pod" class="resource" :class="{ even: index % 2 }"></PodComponent>
        </div>
    </TableComponent>
</template>

<script setup lang="ts">
import type { Pod } from '~/classes/Pod';
import { ResourceRepo } from '~/classes/repo/ResourceRepo';
import PodComponent from '~/components/pod/PodComponent.vue';

const repo = ResourceRepo.init<Pod>();
onMounted(() => {
    repo.listen("pods");
});
onUnmounted(() => {
    repo.clear();
});
</script>

<style scoped>
.pod-container {
    display: grid;
    grid-template-columns: auto auto auto auto auto 1fr auto auto;
}
</style>