diff --git a/frontend/components/ui/AppModal.vue b/frontend/components/ui/AppModal.vue new file mode 100644 index 0000000..01f2d4f --- /dev/null +++ b/frontend/components/ui/AppModal.vue @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ cancelLabel }} + + + {{ submitLabel }} + + + + + + + + + + + + + diff --git a/frontend/pages/applications/[slug].vue b/frontend/pages/applications/[slug].vue index 0342a67..0d6cb3c 100644 --- a/frontend/pages/applications/[slug].vue +++ b/frontend/pages/applications/[slug].vue @@ -10,12 +10,15 @@ const slug = route.params.slug as string const application = ref(null) const loading = ref(true) -const editingApp = ref(false) -const editForm = ref({ name: '', slug: '', registryImage: '', description: '', giteaUrl: '' }) -const isSubmitting = ref(false) +const pendingMaintenanceByEnvId = ref>({}) -// Environment form -const showEnvForm = ref(false) +// App edit modal +const showAppModal = ref(false) +const editForm = ref({ name: '', slug: '', registryImage: '', description: '', giteaUrl: '' }) +const isSubmittingApp = ref(false) + +// Env modal +const showEnvModal = ref(false) const editingEnvId = ref(null) const envForm = ref({ name: '', @@ -26,7 +29,6 @@ const envForm = ref({ logFiles: [], }) const isSubmittingEnv = ref(false) -const pendingMaintenanceByEnvId = ref>({}) async function loadApplication() { loading.value = true @@ -38,7 +40,7 @@ async function loadApplication() { } // Application edit -function startEditApp() { +function openEditAppModal() { if (!application.value) return editForm.value = { name: application.value.name, @@ -47,19 +49,19 @@ function startEditApp() { description: application.value.description ?? '', giteaUrl: application.value.giteaUrl ?? '', } - editingApp.value = true + showAppModal.value = true } async function saveApp() { - isSubmitting.value = true + isSubmittingApp.value = true try { application.value = await updateApplication(slug, editForm.value) - editingApp.value = false + showAppModal.value = false if (editForm.value.slug !== slug) { router.replace(`/applications/${editForm.value.slug}`) } } finally { - isSubmitting.value = false + isSubmittingApp.value = false } } @@ -70,13 +72,13 @@ async function handleDeleteApp() { } // Environment CRUD -function startCreateEnv() { +function openCreateEnvModal() { editingEnvId.value = null envForm.value = { name: '', containerName: '', deployScriptPath: '', maintenanceFilePath: '', appUrl: '', logFiles: [] } - showEnvForm.value = true + showEnvModal.value = true } -function startEditEnv(env: Environment) { +function openEditEnvModal(env: Environment) { editingEnvId.value = env.id! envForm.value = { name: env.name, @@ -86,7 +88,7 @@ function startEditEnv(env: Environment) { appUrl: env.appUrl ?? '', logFiles: env.logFiles.map(lf => ({ label: lf.label, path: lf.path })), } - showEnvForm.value = true + showEnvModal.value = true } async function saveEnv() { @@ -97,7 +99,7 @@ async function saveEnv() { } else { await createEnvironment(slug, envForm.value) } - showEnvForm.value = false + showEnvModal.value = false await loadApplication() } finally { isSubmittingEnv.value = false @@ -129,6 +131,10 @@ function removeLogFile(index: number) { envForm.value.logFiles.splice(index, 1) } +const envModalTitle = computed(() => + editingEnvId.value ? t('environments.editButton') : t('environments.addButton') +) + onMounted(loadApplication) @@ -154,10 +160,10 @@ onMounted(loadApplication) {{ application.name }} {{ application.description }} - + {{ t('applications.detail.editButton') }} @@ -171,7 +177,7 @@ onMounted(loadApplication) - + {{ t('applications.detail.registryImage') }} : @@ -186,122 +192,20 @@ onMounted(loadApplication) - - - - - - {{ t('applications.form.name') }} - - - - {{ t('applications.form.slug') }} - - - - {{ t('applications.form.registryImage') }} - - - - {{ t('applications.form.giteaUrl') }} - - - - - {{ t('applications.form.description') }} - - - - - {{ t('applications.form.cancel') }} - - - {{ t('applications.form.save') }} - - - - - {{ t('environments.title') }} + {{ t('environments.addButton') }} - - - - - - {{ t('environments.form.name') }} - - - - {{ t('environments.form.containerName') }} - - - - {{ t('environments.form.deployScriptPath') }} - - - - {{ t('environments.form.maintenanceFilePath') }} - - - - {{ t('environments.form.appUrl') }} - - - - - - - - {{ t('environments.logFiles.title') }} - - + {{ t('environments.logFiles.addButton') }} - - - - - - - - - - - - - - {{ t('environments.form.cancel') }} - - - {{ t('environments.form.save') }} - - - - - - + {{ t('applications.card.noEnvironments') }} @@ -346,7 +250,7 @@ onMounted(loadApplication) {{ t('environments.editButton') }} @@ -370,5 +274,105 @@ onMounted(loadApplication) + + + + {{ t('applications.detail.editButton') }} + + + + + + + + + + {{ t('applications.form.description') }} + + + + + + + + {{ envModalTitle }} + + + + + + + + + + + + + + {{ t('environments.logFiles.title') }} + + + {{ t('environments.logFiles.addButton') }} + + + + + + + + + + + + diff --git a/frontend/pages/applications/index.vue b/frontend/pages/applications/index.vue index 36338be..6ffa504 100644 --- a/frontend/pages/applications/index.vue +++ b/frontend/pages/applications/index.vue @@ -7,7 +7,7 @@ const router = useRouter() const applications = ref([]) const loading = ref(true) -const showCreateForm = ref(false) +const showCreateModal = ref(false) const createForm = ref({ name: '', slug: '', @@ -26,12 +26,16 @@ async function loadApplications() { } } +function openCreateModal() { + createForm.value = { name: '', slug: '', registryImage: '', description: '', giteaUrl: '' } + showCreateModal.value = true +} + async function handleCreate() { isSubmitting.value = true try { const created = await createApplication(createForm.value) - showCreateForm.value = false - createForm.value = { name: '', slug: '', registryImage: '', description: '', giteaUrl: '' } + showCreateModal.value = false router.push(`/applications/${created.slug}`) } finally { isSubmitting.value = false @@ -51,60 +55,12 @@ onMounted(loadApplications) {{ t('applications.title') }} + {{ t('applications.addButton') }} - - - - - - {{ t('applications.form.name') }} - - - - {{ t('applications.form.slug') }} - - - - {{ t('applications.form.registryImage') }} - - - - {{ t('applications.form.giteaUrl') }} - - - - - {{ t('applications.form.description') }} - - - - - {{ t('applications.form.cancel') }} - - - {{ t('applications.form.save') }} - - - - - @@ -147,5 +103,49 @@ onMounted(loadApplications) + + + + {{ t('applications.addButton') }} + + + + + + + + + + {{ t('applications.form.description') }} + + + +
{{ application.description }}
{{ t('environments.logFiles.title') }}