feat : add applications list page, replace old dashboard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,9 +39,9 @@
|
||||
</div>
|
||||
<nav class="flex-1 overflow-hidden" :class="sidebarIsCollapsed ? 'px-1 pb-6' : 'px-4 pb-6'">
|
||||
<SidebarLink
|
||||
to="/"
|
||||
icon="mdi:view-dashboard-outline"
|
||||
label="Tableau de bord"
|
||||
to="/applications"
|
||||
icon="mdi:apps"
|
||||
:label="$t('applications.title')"
|
||||
:collapsed="sidebarIsCollapsed"
|
||||
:class="sidebarIsCollapsed ? 'mt-4' : 'border-t border-secondary-500 pt-6'"
|
||||
@click="ui.closeMobileSidebar()"
|
||||
|
||||
144
frontend/pages/applications/index.vue
Normal file
144
frontend/pages/applications/index.vue
Normal file
@@ -0,0 +1,144 @@
|
||||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
const router = useRouter()
|
||||
|
||||
const applications = ref<Application[]>([])
|
||||
const loading = ref(true)
|
||||
const showCreateForm = ref(false)
|
||||
const createForm = ref<ApplicationWrite>({
|
||||
name: '',
|
||||
slug: '',
|
||||
registryImage: '',
|
||||
description: '',
|
||||
giteaUrl: '',
|
||||
})
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
async function loadApplications() {
|
||||
loading.value = true
|
||||
try {
|
||||
applications.value = await getApplications()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreate() {
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
const created = await createApplication(createForm.value)
|
||||
showCreateForm.value = false
|
||||
createForm.value = { name: '', slug: '', registryImage: '', description: '', giteaUrl: '' }
|
||||
router.push(`/applications/${created.slug}`)
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function generateSlug(name: string) {
|
||||
createForm.value.slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '')
|
||||
}
|
||||
|
||||
onMounted(loadApplications)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 max-w-6xl mx-auto">
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-m-text">{{ t('applications.title') }}</h1>
|
||||
<p class="text-m-muted mt-1">{{ t('applications.description') }}</p>
|
||||
</div>
|
||||
<MalioButton @click="showCreateForm = !showCreateForm">
|
||||
{{ t('applications.addButton') }}
|
||||
</MalioButton>
|
||||
</div>
|
||||
|
||||
<!-- Create form -->
|
||||
<div v-if="showCreateForm" class="bg-m-surface border border-m-border rounded-lg p-6 mb-6">
|
||||
<form @submit.prevent="handleCreate" class="space-y-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-m-text mb-1">{{ t('applications.form.name') }}</label>
|
||||
<MalioInputText
|
||||
v-model="createForm.name"
|
||||
@update:model-value="generateSlug"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-m-text mb-1">{{ t('applications.form.slug') }}</label>
|
||||
<MalioInputText v-model="createForm.slug" required />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-m-text mb-1">{{ t('applications.form.registryImage') }}</label>
|
||||
<MalioInputText v-model="createForm.registryImage" required />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-m-text mb-1">{{ t('applications.form.giteaUrl') }}</label>
|
||||
<MalioInputText v-model="createForm.giteaUrl" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-m-text mb-1">{{ t('applications.form.description') }}</label>
|
||||
<textarea
|
||||
v-model="createForm.description"
|
||||
class="w-full rounded border border-m-border bg-m-bg text-m-text p-2"
|
||||
rows="2"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<MalioButton variant="secondary" @click="showCreateForm = false">
|
||||
{{ t('applications.form.cancel') }}
|
||||
</MalioButton>
|
||||
<MalioButton type="submit" :loading="isSubmitting">
|
||||
{{ t('applications.form.save') }}
|
||||
</MalioButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Loading -->
|
||||
<div v-if="loading" class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
|
||||
<div v-for="i in 3" :key="i" class="bg-m-surface border border-m-border rounded-lg p-6 animate-pulse">
|
||||
<div class="h-5 bg-m-disabled rounded w-1/2 mb-3" />
|
||||
<div class="h-4 bg-m-disabled rounded w-3/4 mb-2" />
|
||||
<div class="h-4 bg-m-disabled rounded w-1/3" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty state -->
|
||||
<div v-else-if="applications.length === 0" class="text-center py-12">
|
||||
<h3 class="text-lg font-medium text-m-text">{{ t('applications.emptyTitle') }}</h3>
|
||||
<p class="text-m-muted mt-1">{{ t('applications.emptyDescription') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Application cards -->
|
||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
|
||||
<NuxtLink
|
||||
v-for="app in applications"
|
||||
:key="app.slug"
|
||||
:to="`/applications/${app.slug}`"
|
||||
class="bg-m-surface border border-m-border rounded-lg p-6 hover:border-primary-500 transition-colors"
|
||||
>
|
||||
<div class="flex items-start justify-between">
|
||||
<h3 class="text-lg font-semibold text-m-text">{{ app.name }}</h3>
|
||||
<a
|
||||
v-if="app.giteaUrl"
|
||||
:href="app.giteaUrl"
|
||||
target="_blank"
|
||||
class="text-m-muted hover:text-primary-500"
|
||||
@click.stop
|
||||
>
|
||||
<Icon name="mdi:open-in-new" size="18" />
|
||||
</a>
|
||||
</div>
|
||||
<p v-if="app.description" class="text-m-muted text-sm mt-2 line-clamp-2">{{ app.description }}</p>
|
||||
<p class="text-m-muted text-xs mt-3">
|
||||
<Icon name="mdi:server" size="14" class="mr-1" />
|
||||
{{ app.environments?.length ?? 0 }} {{ t('applications.card.environments', app.environments?.length ?? 0) }}
|
||||
</p>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,176 +0,0 @@
|
||||
<template>
|
||||
<div class="flex h-full flex-col gap-6 pb-10">
|
||||
<section class="flex flex-col gap-2">
|
||||
<h1 class="text-2xl font-bold text-neutral-900 sm:text-3xl">
|
||||
{{ t('applications.title') }}
|
||||
</h1>
|
||||
<p class="max-w-3xl text-sm leading-6 text-neutral-500 sm:text-base">
|
||||
{{ t('applications.description') }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="min-h-0 rounded-3xl border border-primary-500/15 bg-white shadow-sm">
|
||||
<header class="flex flex-col gap-4 border-b border-primary-500/10 px-6 py-5 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-primary-500">
|
||||
{{ t('applications.listTitle') }}
|
||||
</h2>
|
||||
<p class="mt-1 text-sm text-neutral-500">
|
||||
{{ t('applications.listDescription') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-xl border border-primary-500/20 px-4 py-2 text-sm font-semibold text-primary-500 transition-colors hover:bg-tertiary-500 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="loading"
|
||||
@click="loadApplications()"
|
||||
>
|
||||
<Icon
|
||||
name="mdi:refresh"
|
||||
size="18"
|
||||
class="mr-2"
|
||||
:class="loading ? 'animate-spin' : ''"
|
||||
/>
|
||||
{{ t('applications.actions.refresh') }}
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div v-if="loading" class="grid gap-4 p-6 xl:grid-cols-2">
|
||||
<div
|
||||
v-for="index in 4"
|
||||
:key="index"
|
||||
class="animate-pulse rounded-2xl border border-primary-500/10 p-5"
|
||||
>
|
||||
<div class="h-4 w-24 rounded bg-neutral-200" />
|
||||
<div class="mt-4 h-7 w-40 rounded bg-neutral-200" />
|
||||
<div class="mt-3 h-4 w-full rounded bg-neutral-100" />
|
||||
<div class="mt-6 h-11 w-44 rounded-xl bg-neutral-200" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="applications.length === 0" class="px-6 py-12 text-center">
|
||||
<div class="mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-tertiary-500 text-primary-500">
|
||||
<Icon name="mdi:server-off" size="28" />
|
||||
</div>
|
||||
<h3 class="mt-4 text-lg font-bold text-primary-500">
|
||||
{{ t('applications.emptyTitle') }}
|
||||
</h3>
|
||||
<p class="mt-2 text-sm text-neutral-500">
|
||||
{{ t('applications.emptyDescription') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="grid gap-4 p-6 xl:grid-cols-2">
|
||||
<article
|
||||
v-for="application in applications"
|
||||
:key="application.slug"
|
||||
class="flex h-full min-w-0 flex-col rounded-2xl border p-5 transition-colors"
|
||||
:class="application.maintenance ? 'border-red-200 bg-red-50/60' : 'border-emerald-200 bg-emerald-50/60'"
|
||||
>
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div class="min-w-0">
|
||||
<p class="text-xs font-semibold uppercase tracking-[0.18em] text-neutral-500">
|
||||
{{ application.slug }}
|
||||
</p>
|
||||
<h3 class="mt-2 break-words text-xl font-bold text-primary-500">
|
||||
{{ application.name }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<span
|
||||
class="inline-flex w-fit items-center rounded-full px-3 py-1 text-xs font-bold"
|
||||
:class="application.maintenance ? 'bg-red-100 text-red-700' : 'bg-emerald-100 text-emerald-700'"
|
||||
>
|
||||
<span
|
||||
class="mr-2 h-2.5 w-2.5 rounded-full"
|
||||
:class="application.maintenance ? 'bg-red-500' : 'bg-emerald-500'"
|
||||
/>
|
||||
{{ application.maintenance ? t('applications.status.active') : t('applications.status.inactive') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="mt-4 flex-1 text-sm leading-6 text-neutral-600">
|
||||
{{
|
||||
application.maintenance
|
||||
? t('applications.card.activeDescription')
|
||||
: t('applications.card.inactiveDescription')
|
||||
}}
|
||||
</p>
|
||||
|
||||
<div class="mt-6 flex flex-col gap-3 border-t border-black/5 pt-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<p class="text-xs font-medium uppercase tracking-[0.14em] text-neutral-400">
|
||||
{{ t('applications.card.triggerFile') }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
class="inline-flex w-full items-center justify-center rounded-xl px-4 py-3 text-sm font-semibold text-white transition-opacity disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto sm:min-w-[220px]"
|
||||
:class="application.maintenance ? 'bg-red-600 hover:bg-red-700' : 'bg-primary-500 hover:bg-primary-600'"
|
||||
:disabled="Boolean(pendingBySlug[application.slug])"
|
||||
@click="toggleMaintenance(application)"
|
||||
>
|
||||
<Icon
|
||||
:name="pendingBySlug[application.slug] ? 'mdi:loading' : (application.maintenance ? 'mdi:shield-check-outline' : 'mdi:alert-outline')"
|
||||
size="18"
|
||||
class="mr-2"
|
||||
:class="pendingBySlug[application.slug] ? 'animate-spin' : ''"
|
||||
/>
|
||||
{{
|
||||
pendingBySlug[application.slug]
|
||||
? t('applications.actions.pending')
|
||||
: application.maintenance
|
||||
? t('applications.actions.deactivate')
|
||||
: t('applications.actions.activate')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ManagedApplication } from '~/services/dto/managed-application'
|
||||
import { getManagedApplications, setApplicationMaintenance } from '~/services/managed-applications'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const applications = ref<ManagedApplication[]>([])
|
||||
const loading = ref(true)
|
||||
const pendingBySlug = ref<Record<string, boolean>>({})
|
||||
|
||||
async function loadApplications() {
|
||||
loading.value = true
|
||||
|
||||
try {
|
||||
applications.value = await getManagedApplications()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleMaintenance(application: ManagedApplication) {
|
||||
pendingBySlug.value = {
|
||||
...pendingBySlug.value,
|
||||
[application.slug]: true
|
||||
}
|
||||
|
||||
try {
|
||||
const updatedApplication = await setApplicationMaintenance(application.slug, !application.maintenance)
|
||||
applications.value = applications.value.map((item) => item.slug === updatedApplication.slug ? updatedApplication : item)
|
||||
} finally {
|
||||
pendingBySlug.value = {
|
||||
...pendingBySlug.value,
|
||||
[application.slug]: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadApplications()
|
||||
})
|
||||
|
||||
useHead({
|
||||
title: 'Applications'
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user