<script setup>

import EventlogList from '../EventlogList.vue';
import AppsModel from '../../models/AppsModel.js';
import { EVENTS } from '../../constants.js';

const appsModel = AppsModel.create();

const props = defineProps([ 'app' ]);

const availableActions = [
  { id: EVENTS.APP_BACKUP, label: 'Backup started' },
  { id: EVENTS.APP_BACKUP_FINISH, label: 'Backup finished' },
  { id: EVENTS.APP_CONFIGURE, label: 'Reconfigured' },
  { id: EVENTS.APP_INSTALL, label: 'Installed' },
  { id: EVENTS.APP_RESTORE, label: 'Restored' },
  { id: EVENTS.APP_UNINSTALL, label: 'Uninstalled' },
  { id: EVENTS.APP_UPDATE, label: 'Update started' },
  { id: EVENTS.APP_UPDATE_FINISH, label: 'Update finished' },
  { id: EVENTS.APP_LOGIN, label: 'Log in' },
  { id: EVENTS.APP_OOM, label: 'Out of memory' },
  { id: EVENTS.APP_DOWN, label: 'Down' },
  { id: EVENTS.APP_UP, label: 'Up' },
  { id: EVENTS.APP_START, label: 'Started' },
  { id: EVENTS.APP_STOP, label: 'Stopped' },
  { id: EVENTS.APP_RESTART, label: 'Restarted' },
];

async function fetchPage(filter, page, perPage) {
  return appsModel.getEvents(props.app.id, filter, page, perPage);
}

</script>

<template>
  <EventlogList :fetch-page="fetchPage" :app="app" :available-actions="availableActions" :show-toolbar="false" />
</template>
