2024-11-02 18:41:13 +00:00
|
|
|
<template>
|
2024-11-03 17:54:42 +00:00
|
|
|
<Loading class="container" :loading="loading">
|
2024-11-03 18:14:47 +00:00
|
|
|
<Message v-if="error" type="danger">{{ error }}</Message>
|
2024-11-03 17:54:42 +00:00
|
|
|
<ul v-if="!loading && !error">
|
2024-11-03 18:14:47 +00:00
|
|
|
<li v-for="container in containers" :key="container">
|
|
|
|
{{ container }}
|
2024-11-03 17:54:42 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</Loading>
|
2024-11-02 18:41:13 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2024-11-03 18:14:47 +00:00
|
|
|
import axios, { AxiosError } from 'axios'
|
2024-11-03 17:54:42 +00:00
|
|
|
import Loading from '@/components/Loading.vue'
|
|
|
|
import Message from '@/components/Message.vue'
|
|
|
|
|
2024-11-02 18:41:13 +00:00
|
|
|
export default {
|
2024-11-02 21:43:27 +00:00
|
|
|
name: 'Containers',
|
2024-11-03 17:54:42 +00:00
|
|
|
components: {
|
|
|
|
Loading,
|
|
|
|
Message,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-11-03 18:14:47 +00:00
|
|
|
containers: [] as string[],
|
|
|
|
error: '',
|
2024-11-03 17:54:42 +00:00
|
|
|
loading: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
try {
|
2024-11-03 18:14:47 +00:00
|
|
|
const response = await axios.get<string[]>('/api/containers')
|
|
|
|
this.containers = response.data
|
2024-11-03 17:54:42 +00:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
2024-11-03 18:14:47 +00:00
|
|
|
this.error =
|
|
|
|
error instanceof AxiosError ? error.message : 'Error loading containers'
|
2024-11-03 17:54:42 +00:00
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
}
|
|
|
|
},
|
2024-11-02 18:41:13 +00:00
|
|
|
}
|
|
|
|
</script>
|