<template>
    <div class="content-m">
        <div class="left-center">
            <h3>{{ monitoring.configName }}</h3>
            <p v-if="monitoring.type === 'WORKLOAD'" class="label">CPU</p>
        </div>
        <div class="col-3">
          <CpuMonitoredPodComponent class="tile-l" v-for="pod in pods" :pod="pod" :period="period"></CpuMonitoredPodComponent>
        </div>
    </div>
</template>

<script setup lang="ts">
import type { Pod } from '~/classes/Pod';
import { MonitoredResource } from '../MonitoredResource';
import CpuMonitoredPodComponent from './CpuMonitoredPodComponent.vue';
import type { Period } from '../Period';
import { MonitoringConfig } from '~/classes/monitoring/MonitoringConfig';

const props = defineProps<{
    monitoring: MonitoringConfig,
    period: Period
}>();

const pods: Ref<MonitoredResource<Pod>[] | undefined> = ref(undefined);

onMounted(() => {
     MonitoredResource.getMonitorings(props.monitoring.id, props.period.from, props.period.to, (_pods: MonitoredResource<Pod>[]) => {
        pods.value = _pods;
    });
});
</script>