Files
Hermes-ui/packages/client/src/views/hermes/JobsView.vue
T

81 lines
1.9 KiB
Vue
Raw Normal View History

2026-04-11 15:59:14 +08:00
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { NButton, NSpin } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import JobsPanel from '@/components/hermes/jobs/JobsPanel.vue'
import JobFormModal from '@/components/hermes/jobs/JobFormModal.vue'
import { useJobsStore } from '@/stores/hermes/jobs'
2026-04-11 15:59:14 +08:00
const { t } = useI18n()
2026-04-11 15:59:14 +08:00
const jobsStore = useJobsStore()
const showModal = ref(false)
const editingJob = ref<string | null>(null)
onMounted(() => {
jobsStore.fetchJobs()
})
function openCreateModal() {
editingJob.value = null
showModal.value = true
}
function openEditModal(jobId: string) {
editingJob.value = jobId
showModal.value = true
}
function handleModalClose() {
showModal.value = false
editingJob.value = null
}
async function handleSave() {
await jobsStore.fetchJobs()
handleModalClose()
}
</script>
<template>
<div class="jobs-view">
<header class="page-header">
<h2 class="header-title">{{ t('jobs.title') }}</h2>
<NButton type="primary" size="small" @click="openCreateModal">
2026-04-11 15:59:14 +08:00
<template #icon>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
</template>
{{ t('jobs.createJob') }}
2026-04-11 15:59:14 +08:00
</NButton>
</header>
<div class="jobs-content">
<NSpin :show="jobsStore.loading && jobsStore.jobs.length === 0">
<JobsPanel @edit="openEditModal" />
</NSpin>
</div>
<JobFormModal
v-if="showModal"
:job-id="editingJob"
@close="handleModalClose"
@saved="handleSave"
/>
</div>
</template>
<style scoped lang="scss">
@use '@/styles/variables' as *;
.jobs-view {
height: calc(100 * var(--vh));
2026-04-11 15:59:14 +08:00
display: flex;
flex-direction: column;
}
.jobs-content {
flex: 1;
overflow-y: auto;
padding: 20px;
}
</style>