<template>
    <div class="content-l">
        <h2>{{ createLabel(monitoring.type) }} Monitoring: {{ monitoring.configName }}</h2>
        <div class="col-3">
          <MemoryMonitoredPodComponent class="tile-l" v-for="pod in pods" :pod="pod"></MemoryMonitoredPodComponent>
        </div>
    </div>
</template>

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

const props = defineProps<{
    monitoring: VolumeMonitoringConfig
}>();

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

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

function createLabel(input: string)
{
    return input.at(0)?.toUpperCase() + input.substring(1, input.length).toLowerCase();
}
</script>