<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>Alter</p>
                <p>Node</p>
                <p>Containers</p>
                <p>Status</p>
                <p>Aktionen</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/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 1fr 1fr 1fr 1fr auto auto;
}
</style>