<template>
    <TableComponent :loading="deployments == null" v-for="deployments in [repo.get().value]">
        <div class="resource-container deployment-container">
            <div class="header">
                <p>Name</p>
                <p>Namespace</p>
                <p>Age</p>
                <p>Replicas</p>
                <p>Aktionen</p>
            </div>
            <DeploymentComponent :deployment="deployment" v-for="(deployment, index) in deployments" class="resource" :class="{ even: index % 2 }"></DeploymentComponent>
        </div>
    </TableComponent>
</template>

<script setup lang="ts">
import type { Deployment } from '~/classes/Deployment';
import { ResourceRepo } from '~/classes/repo/ResourceRepo';
import DeploymentComponent from "~/components/deployment/DeploymentComponent.vue";

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

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