feat(central) : ajoute le pilotage de maintenance et le deploiement prod
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
"patch": "Impossible de mettre à jour la ressource.",
|
||||
"delete": "Impossible de supprimer la ressource."
|
||||
},
|
||||
"applications": {
|
||||
"activateMaintenance": "Impossible d'activer le mode maintenance.",
|
||||
"deactivateMaintenance": "Impossible de désactiver le mode maintenance."
|
||||
},
|
||||
"auth": {
|
||||
"login": "Identifiants invalides.",
|
||||
"logout": "Impossible de se déconnecter.",
|
||||
@@ -14,6 +18,10 @@
|
||||
}
|
||||
},
|
||||
"success": {
|
||||
"applications": {
|
||||
"activateMaintenance": "Le mode maintenance a été activé.",
|
||||
"deactivateMaintenance": "Le mode maintenance a été désactivé."
|
||||
},
|
||||
"auth": {
|
||||
"login": "Connexion réussie.",
|
||||
"logout": "Déconnexion réussie."
|
||||
@@ -21,5 +29,29 @@
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "Tableau de bord"
|
||||
},
|
||||
"applications": {
|
||||
"eyebrow": "Pilotage centralise",
|
||||
"title": "Supervision des applications",
|
||||
"description": "Active ou desactive le mode maintenance sans te connecter a chaque projet. Chaque action pilote le fichier de maintenance de l'application cible.",
|
||||
"listTitle": "Applications managees",
|
||||
"listDescription": "L'etat affiche correspond au trigger de maintenance present sur le serveur de production.",
|
||||
"emptyTitle": "Aucune application disponible",
|
||||
"emptyDescription": "La configuration backend ne retourne encore aucune application geree.",
|
||||
"status": {
|
||||
"active": "Maintenance active",
|
||||
"inactive": "En ligne"
|
||||
},
|
||||
"card": {
|
||||
"activeDescription": "Les utilisateurs voient actuellement la page de maintenance de cette application.",
|
||||
"inactiveDescription": "L'application repond normalement et le trigger de maintenance est absent.",
|
||||
"triggerFile": "Fichier trigger maintenance.on"
|
||||
},
|
||||
"actions": {
|
||||
"refresh": "Rafraichir",
|
||||
"activate": "Activer la maintenance",
|
||||
"deactivate": "Desactiver la maintenance",
|
||||
"pending": "Mise a jour en cours"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14830
frontend/package-lock.json
generated
Normal file
14830
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,176 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-neutral-900">Tableau de bord</h1>
|
||||
<p class="mt-4 text-neutral-600">Bienvenue sur Central.</p>
|
||||
<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: 'Tableau de bord'
|
||||
title: 'Applications'
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<template>
|
||||
<div class="mx-auto w-full max-w-lg">
|
||||
<span
|
||||
class="flex items-center justify-center bg-white text-xl font-bold uppercase text-primary-500 p-4"
|
||||
>
|
||||
<img src="/malio.png" alt="Logo" class="w-[150px]"/>
|
||||
</span>
|
||||
<div class="flex flex-col items-center justify-center">
|
||||
<span
|
||||
class="flex items-center justify-center bg-white text-xl font-bold uppercase text-primary-500 p-4"
|
||||
>
|
||||
<img src="/malio.png" alt="Logo" class="w-[150px]"/>
|
||||
</span>
|
||||
<h1 class="mt-2 text-3xl font-bold tracking-wide text-neutral-800">Central</h1>
|
||||
</div>
|
||||
<form
|
||||
class="mt-8 space-y-6 rounded-lg border border-neutral-200 bg-white p-6 shadow-sm"
|
||||
@submit.prevent="handleSubmit"
|
||||
|
||||
10
frontend/services/dto/managed-application.ts
Normal file
10
frontend/services/dto/managed-application.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export type ManagedApplication = {
|
||||
slug: string
|
||||
name: string
|
||||
maintenance: boolean
|
||||
}
|
||||
|
||||
export type ManagedApplicationCollection = {
|
||||
'hydra:member'?: ManagedApplication[]
|
||||
member?: ManagedApplication[]
|
||||
}
|
||||
33
frontend/services/managed-applications.ts
Normal file
33
frontend/services/managed-applications.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ManagedApplication, ManagedApplicationCollection } from './dto/managed-application'
|
||||
|
||||
function normalizeManagedApplications(response: ManagedApplication[] | ManagedApplicationCollection): ManagedApplication[] {
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
return response['hydra:member'] ?? response.member ?? []
|
||||
}
|
||||
|
||||
export async function getManagedApplications(): Promise<ManagedApplication[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<ManagedApplication[] | ManagedApplicationCollection>('/applications')
|
||||
|
||||
return normalizeManagedApplications(response)
|
||||
}
|
||||
|
||||
export function setApplicationMaintenance(slug: string, maintenance: boolean) {
|
||||
const api = useApi()
|
||||
|
||||
return api.post<ManagedApplication>(
|
||||
`/applications/${slug}/maintenance`,
|
||||
{ maintenance },
|
||||
{
|
||||
toastSuccessKey: maintenance
|
||||
? 'success.applications.activateMaintenance'
|
||||
: 'success.applications.deactivateMaintenance',
|
||||
toastErrorKey: maintenance
|
||||
? 'errors.applications.activateMaintenance'
|
||||
: 'errors.applications.deactivateMaintenance'
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user