diff --git a/frontend/pages/applications/[slug].vue b/frontend/pages/applications/[slug].vue index 1ca25c8..5192fae 100644 --- a/frontend/pages/applications/[slug].vue +++ b/frontend/pages/applications/[slug].vue @@ -2,6 +2,8 @@ import type { Application, ApplicationWrite, Environment, EnvironmentWrite } from '~/services/dto/application' import { getApplication, updateApplication, deleteApplication } from '~/services/applications' import { createEnvironment, updateEnvironment, deleteEnvironment, toggleMaintenance } from '~/services/environments' +import type { DeployResult } from '~/services/dto/deploy' +import { getAvailableTags, deploy } from '~/services/deploy' const { t } = useI18n() const route = useRoute() @@ -12,6 +14,15 @@ const application = ref(null) const loading = ref(true) const pendingMaintenanceByEnvId = ref>({}) +// Deploy modal +const showDeployModal = ref(false) +const deployEnvId = ref(null) +const deployTags = ref([]) +const selectedTag = ref('') +const loadingTags = ref(false) +const isDeploying = ref(false) +const deployResult = ref(null) + // App edit modal const showAppModal = ref(false) const editForm = ref({ name: '', slug: '', registryImage: '', description: '', giteaUrl: '' }) @@ -131,6 +142,43 @@ function removeLogFile(index: number) { envForm.value.logFiles.splice(index, 1) } +async function openDeployModal(env: Environment) { + deployEnvId.value = env.id! + selectedTag.value = '' + deployResult.value = null + deployTags.value = [] + showDeployModal.value = true + loadingTags.value = true + try { + const response = await getAvailableTags(slug) + deployTags.value = response.tags ?? [] + if (deployTags.value.length > 0) { + selectedTag.value = deployTags.value[0] + } + } finally { + loadingTags.value = false + } +} + +async function handleDeploy() { + if (!deployEnvId.value || !selectedTag.value) return + isDeploying.value = true + deployResult.value = null + try { + deployResult.value = await deploy(deployEnvId.value, selectedTag.value) + if (deployResult.value.success) { + await loadApplication() + } + } finally { + isDeploying.value = false + } +} + +function closeDeployModal() { + showDeployModal.value = false + deployResult.value = null +} + const envModalTitle = computed(() => editingEnvId.value ? t('environments.editButton') : t('environments.addButton') ) @@ -236,6 +284,12 @@ onMounted(loadApplication)
+ + + + +
+
+ +

{{ t('environments.deploy.loadingTags') }}

+
+ +
+ +

{{ t('environments.deploy.noTags') }}

+
+ +
+ + +
+
+ + +
+
+ + + {{ deployResult.success + ? t('environments.deploy.success') + : t('environments.deploy.error') + }} + + {{ deployResult.tag }} +
+ +
+

+ {{ t('environments.deploy.output') }} +

+
{{ deployResult.output }}
+
+
+ + + +