24 Commits

Author SHA1 Message Date
semantic-release-bot
126d6b505a chore(release): 1.2.4 2026-03-10 14:05:53 +00:00
c758c4d904 Merge pull request 'fix: bundle latest backup downloads' (#10) from fix/backup-history into develop
All checks were successful
Release / release (push) Successful in 27s
Reviewed-on: #10
2026-03-10 14:05:29 +00:00
ffe463e130 fix: bundle latest backup downloads 2026-03-10 15:02:43 +01:00
semantic-release-bot
a8447d6ee1 chore(release): 1.2.3 2026-03-10 13:19:55 +00:00
91d429c4dd Merge pull request 'fix/backup-history' (#9) from fix/backup-history into develop
All checks were successful
Release / release (push) Successful in 25s
Reviewed-on: #9
2026-03-10 13:19:32 +00:00
505ebd9325 fix: add scroll to backup history 2026-03-10 14:18:14 +01:00
d0e39c92b2 fix: restore backup history listing 2026-03-10 14:16:44 +01:00
semantic-release-bot
8bd78a610f chore(release): 1.2.2 2026-03-10 12:52:57 +00:00
975b0f9718 Merge pull request 'fix/backup-ui-download' (#8) from fix/backup-ui-download into develop
All checks were successful
Release / release (push) Successful in 25s
Reviewed-on: #8
2026-03-10 12:52:33 +00:00
889d723e81 refactor: simplify backup result handling 2026-03-10 13:51:21 +01:00
4757c766f6 fix: align backup ui and downloads 2026-03-10 13:48:55 +01:00
acee6d471c fix: ssh connection correctif 2026-03-10 11:47:37 +01:00
semantic-release-bot
60c2fb2d7e chore(release): 1.2.1 2026-03-10 09:44:09 +00:00
e372505120 Merge pull request 'fix/style-loading-flash' (#7) from fix/style-loading-flash into develop
All checks were successful
Release / release (push) Successful in 29s
Reviewed-on: #7
2026-03-10 09:43:42 +00:00
4e393dd5e9 fix: reduce style loading flash 2026-03-10 10:40:46 +01:00
8fd4aba63e Merge branch 'develop' into feat/app-version 2026-03-10 10:14:46 +01:00
semantic-release-bot
d63b02fc4e chore(release): 1.2.0 2026-03-10 09:08:55 +00:00
7ed9382e73 Merge pull request 'feat: show git tag version' (#6) from feat/app-version into develop
All checks were successful
Release / release (push) Successful in 25s
Reviewed-on: #6
2026-03-10 09:08:32 +00:00
539cbdd2f1 feat: show git tag version 2026-03-10 10:06:55 +01:00
semantic-release-bot
0d985b62b1 chore(release): 1.1.0 2026-03-10 08:53:59 +00:00
4d76d2697b Merge pull request 'feat(backup): add backup scripts workflow' (#5) from feat/backup-release into develop
All checks were successful
Release / release (push) Successful in 37s
Reviewed-on: #5
2026-03-10 08:53:25 +00:00
0863dfad2e feat(backup): add backup scripts workflow 2026-03-10 09:51:26 +01:00
440fffc605 Merge pull request 'chore/configure-semantic-release' (#4) from chore/configure-semantic-release into develop
Reviewed-on: #4
2026-03-10 07:20:27 +00:00
aad7a0a928 Merge pull request 'feat : ajout download backup' (#2) from feat/387-affichage-download-backup into develop
Reviewed-on: #2
2026-03-09 09:51:57 +00:00
21 changed files with 2077 additions and 77 deletions

View File

@@ -1,25 +1,24 @@
name: Release
on: on:
push: push:
branches: branches:
- develop - develop
jobs: jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 22.x
cache: npm
- run: npm install - run: npm ci
- run: npx semantic-release - run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -6,7 +6,6 @@
"@semantic-release/commit-analyzer", "@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator", "@semantic-release/release-notes-generator",
"@semantic-release/changelog", "@semantic-release/changelog",
"@semantic-release/github",
[ [
"@semantic-release/git", "@semantic-release/git",
{ {
@@ -17,4 +16,4 @@
} }
] ]
] ]
} }

43
CHANGELOG.md Normal file
View File

@@ -0,0 +1,43 @@
## [1.2.4](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.2.3...v1.2.4) (2026-03-10)
### Bug Fixes
* bundle latest backup downloads ([ffe463e](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/ffe463e13034601843446514abbd7c69cbaee081))
## [1.2.3](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.2.2...v1.2.3) (2026-03-10)
### Bug Fixes
* add scroll to backup history ([505ebd9](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/505ebd9325c0aa54adb034c012c45c913bb36d73))
* restore backup history listing ([d0e39c9](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/d0e39c92b270993c99cde0eed8577c6dde817fdd))
## [1.2.2](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.2.1...v1.2.2) (2026-03-10)
### Bug Fixes
* align backup ui and downloads ([4757c76](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/4757c766f613a1888b62716a2c6852c8d92e3f6e))
* ssh connection correctif ([acee6d4](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/acee6d471c63671bfb9bdef62a3b6e2ebe40ba55))
## [1.2.1](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.2.0...v1.2.1) (2026-03-10)
### Bug Fixes
* reduce style loading flash ([4e393dd](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/4e393dd5e92a28d91e49affb9437687ac8de3817))
# [1.2.0](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.1.0...v1.2.0) (2026-03-10)
### Features
* show git tag version ([539cbdd](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/539cbdd2f1fa73eddab8adb6e2cc0683e6c424aa))
# [1.1.0](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.0.0...v1.1.0) (2026-03-10)
### Features
* **backup:** add backup scripts workflow ([0863dfa](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/0863dfad2e3c6272a012c30820381a2610e22d1b))

View File

@@ -20,14 +20,18 @@
--font-mono: "JetBrains Mono", "Fira Code", monospace; --font-mono: "JetBrains Mono", "Fira Code", monospace;
} }
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700;800;900&display=swap');
@layer base { @layer base {
html {
background: rgb(var(--m-bg));
color-scheme: dark;
}
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
body { body {
min-height: 100vh;
font-family: var(--font-display); font-family: var(--font-display);
background: rgb(var(--m-bg)); background: rgb(var(--m-bg));
color: rgb(var(--m-text)); color: rgb(var(--m-text));
@@ -35,6 +39,10 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
transition: background-color 0.4s ease, color 0.4s ease; transition: background-color 0.4s ease, color 0.4s ease;
} }
img {
display: block;
}
} }
@layer utilities { @layer utilities {

View File

@@ -1,7 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base { @layer base {
:root { :root {
--m-primary: 15 20 40; --m-primary: 15 20 40;

View File

@@ -82,8 +82,8 @@ watch(() => props.folder, async (folder) => {
loading.value = true loading.value = true
try { try {
const data = await $fetch<string[]>(`/api/backups?folder=${folder}`) const data = await $fetch<string[]>(`/api/backups?folder=${encodeURIComponent(folder)}`)
backups.value = data.slice(0, 6) backups.value = data
} catch (error) { } catch (error) {
console.error("Erreur récupération backups:", error) console.error("Erreur récupération backups:", error)
backups.value = [] backups.value = []
@@ -124,6 +124,9 @@ watch(() => props.folder, async (folder) => {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.375rem; gap: 0.375rem;
max-height: calc((2.875rem * 5) + (0.375rem * 4));
overflow-y: auto;
padding-right: 0.25rem;
} }
.file-row { .file-row {

283
components/BackupRun.vue Normal file
View File

@@ -0,0 +1,283 @@
<template>
<div
class="backup-card card-glow"
:class="{
'card-glow-success': message && !isError,
'card-glow-error': message && isError
}"
>
<div class="card-header">
<h2 class="card-title">Run Script</h2>
<span class="font-mono text-[10px] text-m-muted tracking-widest uppercase">Scripts</span>
</div>
<div
v-if="loading"
class="status-box"
role="status"
aria-live="polite"
aria-busy="true"
>
Chargement des scripts...
</div>
<div
v-else-if="scripts.length"
class="backup-list"
:aria-busy="runningKey !== null"
>
<button
v-for="item in scripts"
:key="item.key"
type="button"
class="backup-btn"
:class="{ 'backup-btn-active': active === item.key }"
:disabled="runningKey !== null"
:aria-pressed="active === item.key"
:aria-label="`Executer ${item.label}`"
@click="runScript(item.key)"
>
<div class="flex items-center gap-2.5">
<IconifyIcon :icon="item.icon" class="text-base text-m-accent" />
<span class="font-display text-sm font-semibold uppercase tracking-wide">
{{ item.label }}
</span>
</div>
<IconifyIcon
:icon="runningKey === item.key ? 'mdi:loading' : 'mdi:play'"
class="text-lg text-m-muted transition-transform duration-200"
:class="{
'translate-x-0.5 !text-m-accent': active === item.key,
'animate-spin': runningKey === item.key
}"
/>
</button>
</div>
<div
v-else
class="status-box status-empty"
role="status"
aria-live="polite"
>
Aucun script disponible.
</div>
<div
v-if="message"
class="status-box"
:class="statusClass"
role="status"
:aria-live="isError ? 'assertive' : 'polite'"
>
<p class="status-title">{{ message }}</p>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from "vue"
import { Icon as IconifyIcon } from "@iconify/vue"
type BackupScript = {
key: string
label: string
icon: string
downloadFolders?: string[]
}
type BackupScriptListResponse = {
scripts: BackupScript[]
}
type BackupScriptRunResponse = {
ok: boolean
key: string
label: string
downloadFolders?: string[]
output: string
}
type ScriptResult = {
key: string | null
label: string
output: string
isError: boolean
downloadFolders: string[]
}
const emit = defineEmits<{
result: [payload: ScriptResult]
}>()
const active = ref<string | null>(null)
const loading = ref(true)
const runningKey = ref<string | null>(null)
const scripts = ref<BackupScript[]>([])
const output = ref<string>("")
const message = ref<string>("")
const isError = ref(false)
const statusClass = computed(() => (isError.value ? "status-error" : "status-success"))
const loadScripts = async () => {
loading.value = true
message.value = ""
output.value = ""
isError.value = false
emit("result", {
key: null,
label: "",
output: "",
isError: false,
downloadFolders: []
})
try {
const data = await $fetch<BackupScriptListResponse>("/api/backup-script")
scripts.value = data.scripts
} catch (error) {
scripts.value = []
isError.value = true
message.value = `Erreur chargement scripts: ${error instanceof Error ? error.message : String(error)}`
emit("result", {
key: null,
label: "",
output: "",
isError: true,
downloadFolders: []
})
} finally {
loading.value = false
}
}
const runScript = async (key: string) => {
active.value = key
runningKey.value = key
output.value = ""
message.value = ""
isError.value = false
try {
const data = await $fetch<BackupScriptRunResponse>("/api/backup-script", {
method: "POST",
body: { key }
})
message.value = `${data.label} execute avec succes`
output.value = data.output || "Aucune sortie retournee."
emit("result", {
key: data.key,
label: data.label,
output: output.value,
isError: false,
downloadFolders: data.downloadFolders || []
})
} catch (error: any) {
isError.value = true
message.value = error?.data?.statusMessage || "Erreur execution script"
output.value = ""
emit("result", {
key,
label: scripts.value.find((item) => item.key === key)?.label || key,
output: "",
isError: true,
downloadFolders: []
})
} finally {
runningKey.value = null
}
}
onMounted(loadScripts)
</script>
<style scoped>
.backup-card {
background: rgb(var(--m-secondary));
border-radius: 12px;
padding: 1.25rem;
transition: background-color 0.4s ease;
}
.card-header {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 0.75rem;
}
.card-title {
font-family: var(--font-display);
font-size: 1.25rem;
font-weight: 700;
color: rgb(var(--m-text));
}
.backup-list {
display: flex;
flex-direction: column;
gap: 0.375rem;
}
.backup-btn {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.625rem 0.875rem;
border-radius: 8px;
background: rgb(var(--m-tertiary));
border: 1px solid transparent;
cursor: pointer;
transition: all 0.2s ease;
color: rgb(var(--m-text));
}
.backup-btn:focus-visible {
outline: 2px solid rgb(var(--m-accent) / 0.7);
outline-offset: 2px;
}
.backup-btn:disabled {
cursor: wait;
opacity: 0.7;
}
.backup-btn:hover {
border-color: rgb(var(--m-accent) / 0.15);
background: rgb(var(--m-accent) / 0.06);
}
.backup-btn-active {
border-color: rgb(var(--m-accent) / 0.25);
background: rgb(var(--m-accent) / 0.08);
box-shadow: 0 0 12px -4px rgb(var(--m-accent) / 0.15);
}
.status-box {
margin-top: 0.75rem;
border-radius: 8px;
padding: 0.875rem;
background: rgb(var(--m-tertiary));
color: rgb(var(--m-text));
font-family: var(--font-mono);
font-size: 0.75rem;
}
.status-success {
border: 1px solid rgb(var(--m-accent) / 0.18);
}
.status-error {
border: 1px solid rgb(255 99 99 / 0.3);
}
.status-empty {
color: rgb(var(--m-muted));
}
.status-title {
margin: 0;
line-height: 1.5;
}
</style>

View File

@@ -1,74 +1,166 @@
<template> <template>
<div class="page-layout"> <div class="page-layout">
<aside class="sidebar"> <aside class="sidebar" aria-label="Navigation principale">
<div class="sidebar-header"> <div class="sidebar-header">
<div class="logo-container"> <div class="logo-container">
<img <img
:src="logoSrc" :src="logoSrc"
alt="Logo Malio" alt="Logo Malio"
class="logo" class="logo"
/> />
</div> </div>
<div class="sidebar-divider" /> <div class="brand-copy">
<p class="brand-title">Supervisor</p>
</div>
<div class="sidebar-divider"/>
</div> </div>
<div class="sidebar-content"> <div class="sidebar-content">
<slot name="sidebar" /> <slot name="sidebar"/>
<nav class="sidebar-nav" aria-label="Sections">
<p class="nav-label">Navigation</p>
<div class="flex flex-col gap-2">
<div class="bg-m-tertiary rounded-lg border border-m-accent/6">
<NuxtLink
to="/"
class="flex items-center gap-3 px-4 py-2 rounded-lg text-white hover:bg-m-tertiary/80 transition-colors"
>
<IconifyIcon
icon="mdi:home"
class="text-lg"/>
<p>Home</p>
</NuxtLink>
</div>
<div class="bg-m-tertiary rounded-lg border border-m-accent/6">
<NuxtLink
to="/backup"
class="flex items-center gap-3 px-4 py-2 rounded-lg text-white hover:bg-m-tertiary/80 transition-colors"
>
<IconifyIcon
icon="mdi:data"
class="text-lg"/>
<p>Backup</p>
</NuxtLink>
</div>
</div>
</nav>
</div> </div>
<div class="sidebar-footer"> <div class="sidebar-footer">
<div class="sidebar-divider" /> <div class="sidebar-divider"/>
<div class="footer-row"> <div class="footer-row">
<p class="font-mono text-[10px] tracking-widest uppercase text-white/40"> <p class="font-mono text-[10px] tracking-widest uppercase text-white/40">
Supervisor v1.0 Supervisor {{ appVersion }}
</p> </p>
</div> </div>
</div> </div>
</aside> </aside>
<button class="mobile-menu-button" type="button" @click="isMenuOpen = true"> <button class="mobile-menu-button" type="button" @click="isMenuOpen = true">
<IconifyIcon icon="mdi:menu" class="text-2xl" /> <IconifyIcon icon="mdi:menu" class="text-2xl"/>
</button> </button>
<div v-if="isMenuOpen" class="mobile-menu-backdrop" @click="isMenuOpen = false" /> <div v-if="isMenuOpen" class="mobile-menu-backdrop" @click="isMenuOpen = false"/>
<aside v-if="isMenuOpen" class="mobile-sidebar"> <aside v-if="isMenuOpen" class="mobile-sidebar" aria-label="Navigation mobile">
<div class="sidebar-header"> <div class="sidebar-header">
<div class="logo-container"> <div class="logo-container">
<img <img
:src="logoSrc" :src="logoSrc"
alt="Logo Malio" alt="Logo Malio"
class="logo" class="logo"
/> />
</div> </div>
<div class="sidebar-divider" /> <div class="brand-copy">
<p class="brand-kicker">Control Center</p>
<p class="brand-title">Supervisor</p>
<p class="brand-description">
Tableau de bord interne pour le monitoring et les sauvegardes.
</p>
</div>
<div class="sidebar-divider"/>
</div> </div>
<div class="sidebar-content"> <div class="sidebar-content">
<slot name="sidebar" /> <slot name="sidebar"/>
<nav class="sidebar-nav" aria-label="Sections mobiles">
<p class="nav-label">Navigation</p>
<NuxtLink
v-for="item in navItems"
:key="`mobile-${item.to}`"
v-slot="{ href, navigate, isExactActive }"
:to="item.to"
custom
>
<a
:href="href"
class="nav-link"
:class="{ 'nav-link-active': isExactActive }"
:aria-current="isExactActive ? 'page' : undefined"
@click="navigate(); isMenuOpen = false"
>
<span class="nav-link-main">
<span class="nav-icon">
<IconifyIcon :icon="item.icon" class="text-lg"/>
</span>
<span>
<span class="nav-title">{{ item.label }}</span>
<span class="nav-caption">{{ item.caption }}</span>
</span>
</span>
<span class="nav-pill">{{ item.short }}</span>
</a>
</NuxtLink>
</nav>
</div> </div>
<div class="sidebar-footer"> <div class="sidebar-footer">
<div class="sidebar-divider" /> <div class="sidebar-divider"/>
<div class="status-card">
<p class="status-label">Environnement</p>
<p class="status-value">Production</p>
<p class="status-description">
Navigation rapide vers les vues principales de supervision.
</p>
</div>
<div class="footer-row"> <div class="footer-row">
<p class="font-mono text-[10px] tracking-widest uppercase text-white/40"> <p class="font-mono text-[10px] tracking-widest uppercase text-white/40">
Supervisor v1.0 Supervisor {{ appVersion }}
</p> </p>
<button class="close-button" type="button" @click="isMenuOpen = false"> <button class="close-button" type="button" @click="isMenuOpen = false">
<IconifyIcon icon="mdi:close" class="text-xl" /> <IconifyIcon icon="mdi:close" class="text-xl"/>
</button> </button>
</div> </div>
</div> </div>
</aside> </aside>
<main class="content bg-noise"> <main class="content bg-noise">
<slot /> <slot/>
</main> </main>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue" import {ref} from "vue"
import { Icon as IconifyIcon } from "@iconify/vue" import {Icon as IconifyIcon} from "@iconify/vue"
import logoSrc from '~/assets/LOGO_CARRE_BLANC.png' import logoSrc from '~/assets/LOGO_CARRE_BLANC.png'
const {
public: {appVersion}
} = useRuntimeConfig()
const isMenuOpen = ref(false) const isMenuOpen = ref(false)
const navItems = [
{
to: "/",
label: "Monitoring",
caption: "Etat global et disponibilite",
short: "MON",
icon: "mdi:chart-box-outline"
},
{
to: "/backup",
label: "Backup",
caption: "Scripts et fichiers archives",
short: "BKP",
icon: "mdi:database-arrow-up-outline"
}
]
</script> </script>
<style scoped> <style scoped>
@@ -81,9 +173,9 @@ const isMenuOpen = ref(false)
.sidebar, .sidebar,
.mobile-sidebar { .mobile-sidebar {
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgb(var(--m-sidebar-from)) 0%, rgb(var(--m-sidebar-from)) 0%,
rgb(var(--m-sidebar-to)) 100% rgb(var(--m-sidebar-to)) 100%
); );
color: white; color: white;
display: flex; display: flex;
@@ -110,6 +202,35 @@ const isMenuOpen = ref(false)
padding: 0.5rem 0; padding: 0.5rem 0;
} }
.brand-copy {
padding: 0.5rem 0 0.75rem;
text-align: center;
}
.brand-kicker {
margin: 0;
font-family: var(--font-mono);
font-size: 0.68rem;
letter-spacing: 0.18em;
text-transform: uppercase;
color: rgb(var(--m-accent));
}
.brand-title {
margin: 0.45rem 0 0;
font-family: var(--font-display);
font-size: 1.45rem;
font-weight: 700;
letter-spacing: -0.02em;
}
.brand-description {
margin: 0.55rem 0 0;
color: rgb(255 255 255 / 0.58);
line-height: 1.6;
font-size: 0.92rem;
}
.logo { .logo {
height: 100px; height: 100px;
width: 100px; width: 100px;
@@ -124,21 +245,22 @@ const isMenuOpen = ref(false)
.sidebar-content { .sidebar-content {
flex: 1; flex: 1;
padding: 0.5rem 0; padding: 0.5rem 1rem 1rem;
} }
.sidebar-footer { .sidebar-footer {
flex-shrink: 0; flex-shrink: 0;
padding-bottom: 0.5rem;
} }
.sidebar-divider { .sidebar-divider {
height: 1px; height: 1px;
margin: 0.75rem 1.5rem; margin: 0.75rem 1.5rem;
background: linear-gradient( background: linear-gradient(
90deg, 90deg,
transparent, transparent,
var(--m-sidebar-divider), var(--m-sidebar-divider),
transparent transparent
); );
} }
@@ -149,6 +271,136 @@ const isMenuOpen = ref(false)
padding: 0.5rem 1.5rem 0.75rem; padding: 0.5rem 1.5rem 0.75rem;
} }
.sidebar-nav {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.nav-label {
margin: 0;
padding: 0 0.75rem 0.25rem;
font-family: var(--font-mono);
font-size: 0.68rem;
letter-spacing: 0.18em;
text-transform: uppercase;
color: rgb(255 255 255 / 0.38);
}
.nav-link {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
padding: 0.85rem 0.9rem;
border-radius: 14px;
border: 1px solid transparent;
color: white;
text-decoration: none;
transition: background-color 0.2s ease,
border-color 0.2s ease,
transform 0.2s ease,
box-shadow 0.2s ease;
}
.nav-link:hover {
background: rgb(255 255 255 / 0.06);
border-color: rgb(var(--m-accent) / 0.14);
transform: translateY(-1px);
}
.nav-link:focus-visible {
outline: 2px solid rgb(var(--m-accent));
outline-offset: 2px;
background: rgb(255 255 255 / 0.08);
}
.nav-link-active {
background: linear-gradient(135deg, rgb(var(--m-accent) / 0.16), rgb(255 255 255 / 0.04));
border-color: rgb(var(--m-accent) / 0.24);
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
}
.nav-link-main {
display: flex;
align-items: center;
gap: 0.8rem;
min-width: 0;
}
.nav-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 2.5rem;
height: 2.5rem;
border-radius: 12px;
background: rgb(255 255 255 / 0.06);
color: rgb(var(--m-accent));
flex-shrink: 0;
}
.nav-title,
.nav-caption {
display: block;
}
.nav-title {
font-size: 0.96rem;
font-weight: 600;
color: white;
}
.nav-caption {
margin-top: 0.2rem;
font-size: 0.78rem;
line-height: 1.45;
color: rgb(255 255 255 / 0.5);
}
.nav-pill {
flex-shrink: 0;
padding: 0.28rem 0.45rem;
border-radius: 999px;
font-family: var(--font-mono);
font-size: 0.68rem;
letter-spacing: 0.08em;
color: rgb(255 255 255 / 0.62);
background: rgb(255 255 255 / 0.06);
}
.status-card {
margin: 0 1rem;
padding: 1rem;
border-radius: 16px;
border: 1px solid rgb(var(--m-accent) / 0.14);
background: radial-gradient(circle at top right, rgb(var(--m-accent) / 0.14), transparent 30%),
rgb(255 255 255 / 0.04);
}
.status-label {
margin: 0;
font-family: var(--font-mono);
font-size: 0.68rem;
letter-spacing: 0.16em;
text-transform: uppercase;
color: rgb(255 255 255 / 0.42);
}
.status-value {
margin: 0.5rem 0 0;
font-size: 1rem;
font-weight: 700;
color: white;
}
.status-description {
margin: 0.45rem 0 0;
font-size: 0.82rem;
line-height: 1.55;
color: rgb(255 255 255 / 0.54);
}
.content { .content {
background: rgb(var(--m-bg)); background: rgb(var(--m-bg));
overflow-y: auto; overflow-y: auto;
@@ -208,6 +460,11 @@ const isMenuOpen = ref(false)
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
} }
.sidebar-content {
padding-right: 0.9rem;
padding-left: 0.9rem;
}
.close-button { .close-button {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -219,5 +476,9 @@ const isMenuOpen = ref(false)
background: rgba(255, 255, 255, 0.06); background: rgba(255, 255, 255, 0.06);
color: white; color: white;
} }
.nav-link {
padding: 0.8rem 0.85rem;
}
} }
</style> </style>

View File

@@ -1,10 +1,44 @@
import { execSync } from "node:child_process"
import tailwindcss from "@tailwindcss/vite" import tailwindcss from "@tailwindcss/vite"
const getRepoVersion = () => {
try {
const tags = execSync(
"git for-each-ref --sort=-version:refname --format='%(refname:short)' refs/tags",
{ encoding: "utf8" }
)
.split("\n")
.map((tag) => tag.trim())
.filter(Boolean)
return tags[0] || "dev"
} catch {
return "dev"
}
}
// https://nuxt.com/docs/api/configuration/nuxt-config // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({ export default defineNuxtConfig({
compatibilityDate: '2025-07-15', compatibilityDate: "2025-07-15",
devtools: { enabled: true }, devtools: { enabled: true },
css: ["~/assets/css/main.css"], css: ["~/assets/css/main.css"],
app: {
head: {
link: [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
{ rel: "preconnect", href: "https://fonts.gstatic.com", crossorigin: "" },
{
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700;800;900&display=swap"
}
]
}
},
runtimeConfig: {
public: {
appVersion: getRepoVersion()
}
},
vite: { vite: {
plugins: [tailwindcss()] plugins: [tailwindcss()]
} }

786
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@
}, },
"dependencies": { "dependencies": {
"@iconify/vue": "^5.0.0", "@iconify/vue": "^5.0.0",
"iconify": "^1.4.0",
"nuxt": "^4.3.1", "nuxt": "^4.3.1",
"vue": "^3.5.29", "vue": "^3.5.29",
"vue-router": "^4.6.4" "vue-router": "^4.6.4"

361
pages/backup.vue Normal file
View File

@@ -0,0 +1,361 @@
<template>
<NuxtLayout name="default">
<div class="dashboard-container">
<header class="dashboard-header">
<div class="header-copy">
<p class="section-kicker">Operations</p>
<h1 class="font-display text-3xl font-bold tracking-tight text-m-text">
Backup
</h1>
<p class="header-description">
Centralisez la selection des dossiers, l'execution des scripts et le telechargement
des fichiers depuis une seule vue.
</p>
</div>
</header>
<div class="dashboard-grid">
<section class="grid-left" aria-label="Commandes de sauvegarde">
<BackupButtonSee
class="animate-fade-in-up backup-selector"
style="animation-delay: 120ms"
@select="selectedBackup = $event"
/>
<BackupRun
class="animate-fade-in-up"
style="animation-delay: 180ms"
@result="handleScriptResult"
/>
</section>
<section class="grid-middle" aria-labelledby="backup-files-title">
<div class="files-panel animate-fade-in-up" style="animation-delay: 240ms">
<div class="files-panel-header">
<div>
<p class="section-kicker">Fichiers</p>
<h2 id="backup-files-title" class="files-panel-title">
Historique des sauvegardes
</h2>
</div>
<p class="files-panel-meta">
{{ selectedBackup ? `Source ${selectedBackup}` : "En attente de selection" }}
</p>
</div>
<BackupList
class="backup-list-mobile"
:folder="selectedBackup"
/>
</div>
<section
class="files-panel output-panel animate-fade-in-up"
style="animation-delay: 300ms"
aria-labelledby="backup-output-title"
>
<div class="files-panel-header">
<div>
<p class="section-kicker">Execution</p>
<h2 id="backup-output-title" class="files-panel-title">Resultat du script</h2>
</div>
<span
class="panel-badge"
:class="{
'panel-badge-idle': !scriptResult.label,
'panel-badge-success': scriptResult.label && !scriptResult.isError,
'panel-badge-error': scriptResult.isError
}"
>
{{ scriptResult.label || "Pret" }}
</span>
</div>
<div
v-if="!scriptResult.output"
class="output-empty"
role="status"
aria-live="polite"
>
<p class="output-empty-title">Aucune sortie disponible</p>
<p class="output-empty-text">
Lancez un script depuis le panneau de gauche pour afficher son retour ici.
</p>
</div>
<pre
v-else
class="output-console"
:class="{ 'output-console-error': scriptResult.isError }"
>{{ scriptResult.output }}</pre>
</section>
</section>
</div>
</div>
</NuxtLayout>
</template>
<script setup lang="ts">
import { ref } from "vue"
import BackupRun from "~/components/BackupRun.vue"
definePageMeta({ layout: false })
type ScriptResult = {
key: string | null
label: string
output: string
isError: boolean
downloadFolders: string[]
}
const emptyScriptResult = (): ScriptResult => ({
key: null,
label: "",
output: "",
isError: false,
downloadFolders: []
})
const selectedBackup = ref<string | null>(null)
const scriptResult = ref<ScriptResult>(emptyScriptResult())
const fetchLatestBackup = async (folder: string) => {
const files = await $fetch<string[]>(`/api/backups?folder=${encodeURIComponent(folder)}`)
return files[0] || null
}
const triggerDownload = (folder: string, file: string) => {
const link = document.createElement("a")
link.href = `/api/download?folder=${encodeURIComponent(folder)}&file=${encodeURIComponent(file)}`
link.style.display = "none"
document.body.appendChild(link)
link.click()
link.remove()
}
const triggerBatchDownload = (folders: string[]) => {
const link = document.createElement("a")
link.href = `/api/download-latest?folders=${encodeURIComponent(folders.join(","))}`
link.style.display = "none"
document.body.appendChild(link)
link.click()
link.remove()
}
const downloadLatestBackup = async (folder: string) => {
const latestFile = await fetchLatestBackup(folder)
if (latestFile) {
triggerDownload(folder, latestFile)
}
}
const handleScriptResult = async (payload: ScriptResult) => {
scriptResult.value = { ...emptyScriptResult(), ...payload }
if (payload.isError || payload.downloadFolders.length === 0) {
return
}
if (payload.downloadFolders.length > 1) {
triggerBatchDownload(payload.downloadFolders)
return
}
for (const folder of payload.downloadFolders) {
try {
await downloadLatestBackup(folder)
} catch (error) {
console.error(`Erreur telechargement automatique pour ${folder}:`, error)
}
}
}
</script>
<style scoped>
.dashboard-container {
padding: 2rem 2.5rem;
}
.dashboard-header {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
gap: 1.5rem;
align-items: end;
margin-bottom: 1.5rem;
}
.header-copy {
min-width: 0;
}
.section-kicker {
margin: 0 0 0.5rem;
font-family: var(--font-mono);
font-size: 0.7rem;
letter-spacing: 0.18em;
text-transform: uppercase;
color: rgb(var(--m-accent));
}
.header-description {
max-width: 62ch;
margin-top: 0.9rem;
color: rgb(var(--m-muted));
line-height: 1.65;
}
.dashboard-grid {
display: grid;
grid-template-columns: 300px minmax(0, 1fr);
gap: 1.5rem;
align-items: start;
}
.grid-left,
.grid-middle {
display: flex;
flex-direction: column;
gap: 1.5rem;
min-width: 0;
}
.files-panel {
padding: 1.25rem;
border-radius: 20px;
background: rgb(var(--m-secondary) / 0.4);
border: 1px solid rgb(var(--m-accent) / 0.08);
}
.output-panel {
min-height: 220px;
}
.files-panel-header {
display: flex;
align-items: end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
}
.files-panel-title {
margin: 0;
font-family: var(--font-display);
font-size: 1.4rem;
font-weight: 700;
color: rgb(var(--m-text));
}
.files-panel-meta {
margin: 0;
font-family: var(--font-mono);
font-size: 0.75rem;
letter-spacing: 0.08em;
text-transform: uppercase;
color: rgb(var(--m-muted));
text-align: right;
}
.panel-badge {
display: inline-flex;
align-items: center;
border-radius: 999px;
padding: 0.35rem 0.7rem;
font-family: var(--font-mono);
font-size: 0.68rem;
letter-spacing: 0.08em;
text-transform: uppercase;
border: 1px solid transparent;
}
.panel-badge-idle {
color: rgb(var(--m-muted));
background: rgb(var(--m-tertiary) / 0.45);
border-color: rgb(var(--m-border) / 0.25);
}
.panel-badge-success {
color: rgb(var(--m-success));
background: rgb(var(--m-success) / 0.08);
border-color: rgb(var(--m-success) / 0.18);
}
.panel-badge-error {
color: rgb(var(--m-error));
background: rgb(var(--m-error) / 0.08);
border-color: rgb(var(--m-error) / 0.18);
}
.output-empty {
display: flex;
min-height: 132px;
flex-direction: column;
justify-content: center;
border-radius: 14px;
border: 1px dashed rgb(var(--m-border) / 0.55);
background: rgb(var(--m-tertiary) / 0.38);
padding: 1.25rem;
}
.output-empty-title {
margin: 0;
font-family: var(--font-display);
font-size: 1rem;
font-weight: 700;
color: rgb(var(--m-text));
}
.output-empty-text {
margin: 0.5rem 0 0;
max-width: 52ch;
color: rgb(var(--m-muted));
line-height: 1.65;
}
.output-console {
margin: 0;
min-height: 132px;
overflow-x: auto;
border-radius: 14px;
border: 1px solid rgb(var(--m-border) / 0.3);
background:
linear-gradient(180deg, rgb(var(--m-bg) / 0.96), rgb(var(--m-secondary) / 0.92));
padding: 1rem 1.1rem;
font-family: var(--font-mono);
font-size: 0.78rem;
line-height: 1.7;
white-space: pre-wrap;
word-break: break-word;
color: rgb(var(--m-success));
}
.output-console-error {
color: rgb(var(--m-error));
}
@media (max-width: 1180px) {
.dashboard-header,
.dashboard-grid {
grid-template-columns: 1fr;
}
.files-panel-header {
align-items: flex-start;
flex-direction: column;
}
.files-panel-meta {
text-align: left;
}
}
@media (max-width: 820px) {
.dashboard-container {
padding: 4.5rem 1.25rem 1.25rem;
}
.files-panel {
padding: 1rem;
}
}
</style>

View File

@@ -30,20 +30,10 @@
<div class="dashboard-grid"> <div class="dashboard-grid">
<div class="grid-left"> <div class="grid-left">
<StatusSite class="animate-fade-in-up" style="animation-delay: 100ms" /> <StatusSite class="animate-fade-in-up" style="animation-delay: 100ms" />
<BackupButtonSee
class="animate-fade-in-up backup-selector"
style="animation-delay: 200ms"
@select="selectedBackup = $event"
/>
</div> </div>
<div class="grid-middle"> <div class="grid-middle">
<Speedtest class="animate-fade-in-up speedtest-card-mobile" style="animation-delay: 150ms" /> <Speedtest class="animate-fade-in-up speedtest-card-mobile" style="animation-delay: 150ms" />
<BackupList
class="animate-fade-in-up backup-list-mobile"
style="animation-delay: 250ms"
:folder="selectedBackup"
/>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,20 @@
import scripts from "../config/backup-script.json"
type BackupScript = {
key: string
label: string
icon?: string
downloadFolders?: string[]
command: string
}
export default defineEventHandler(() => {
return {
scripts: (scripts as BackupScript[]).map(({ key, label, icon, downloadFolders }) => ({
key,
label,
icon: icon || "mdi:play-circle-outline",
downloadFolders: downloadFolders || []
}))
}
})

View File

@@ -0,0 +1,57 @@
import { exec } from "node:child_process"
import scripts from "../config/backup-script.json"
type BackupScript = {
key: string
label: string
downloadFolders?: string[]
command: string
}
function runCommand(command: string): Promise<string> {
return new Promise((resolve, reject) => {
exec(command, { timeout: 10 * 60 * 1000 }, (error, stdout, stderr) => {
if (error) {
reject(stderr || error.message)
return
}
resolve(stdout || stderr)
})
})
}
export default defineEventHandler(async (event) => {
const body = await readBody<{ key?: string }>(event)
const key = typeof body?.key === "string" ? body.key : null
if (!key) {
throw createError({
statusCode: 400,
statusMessage: "Clé de script manquante"
})
}
const script = (scripts as BackupScript[]).find((item) => item.key === key)
if (!script) {
throw createError({
statusCode: 404,
statusMessage: "Script introuvable"
})
}
try {
const output = await runCommand(script.command)
return {
ok: true,
key: script.key,
label: script.label,
downloadFolders: script.downloadFolders || [],
output: output.trim()
}
} catch (error) {
throw createError({
statusCode: 500,
statusMessage: `Erreur execution script: ${String(error)}`
})
}
})

View File

@@ -1,7 +1,7 @@
import { execFile } from "node:child_process" import { execFile } from "node:child_process"
import folderMap from "../config/backup-folders.json" import folderMap from "../config/backup-folders.json"
const REMOTE_HOST = process.env.BACKUPS_REMOTE_HOST || "malio-b@192.168.0.179" const REMOTE_HOST = process.env.BACKUPS_REMOTE_HOST || "malio-b"
const REMOTE_ROOT = process.env.BACKUPS_REMOTE_ROOT || "/home/malio-b/backups" const REMOTE_ROOT = process.env.BACKUPS_REMOTE_ROOT || "/home/malio-b/backups"
const MAX_FILES_PER_FOLDER = Number(process.env.BACKUPS_MAX_FILES || "200") const MAX_FILES_PER_FOLDER = Number(process.env.BACKUPS_MAX_FILES || "200")
const isSafeFolder = (value: string) => /^[a-zA-Z0-9._-]+$/.test(value) const isSafeFolder = (value: string) => /^[a-zA-Z0-9._-]+$/.test(value)

View File

@@ -0,0 +1,139 @@
import { execFile, spawn } from "node:child_process"
import folderMap from "../config/backup-folders.json"
const REMOTE_HOST = process.env.BACKUPS_REMOTE_HOST || "malio-b"
const REMOTE_ROOT = process.env.BACKUPS_REMOTE_ROOT || "/home/malio-b/backups"
const FOLDER_MAP = folderMap as Record<string, string>
const isSafeFolder = (value: string) => /^[a-zA-Z0-9._-]+$/.test(value)
const shellQuote = (value: string) => `'${value.replace(/'/g, `'\\''`)}'`
function runSsh(command: string): Promise<string> {
return new Promise((resolve, reject) => {
execFile(
"ssh",
["-o", "BatchMode=yes", "-o", "ConnectTimeout=5", REMOTE_HOST, command],
{ maxBuffer: 10 * 1024 * 1024 },
(error, stdout, stderr) => {
if (error) {
reject(stderr || error.message)
return
}
resolve(stdout)
}
)
})
}
async function remoteDirExists(remoteDir: string): Promise<boolean> {
const output = await runSsh(`[ -d ${shellQuote(remoteDir)} ] && echo yes || echo no`)
return output.trim() === "yes"
}
async function resolveFolderRemoteDir(folderName: string): Promise<string | null> {
const mapped = FOLDER_MAP[folderName]
if (mapped) {
return `${REMOTE_ROOT}/${mapped}`
}
const direct = `${REMOTE_ROOT}/${folderName}`
if (await remoteDirExists(direct)) {
return direct
}
const nested = `${REMOTE_ROOT}/bdd_recette/${folderName}`
if (await remoteDirExists(nested)) {
return nested
}
return null
}
async function getLatestRemoteFile(remoteDir: string): Promise<string | null> {
const output = await runSsh(`cd ${shellQuote(remoteDir)} && ls -1A | sort -r | head -n 1`)
const fileName = output.trim()
return fileName || null
}
function buildContentDisposition(fileName: string) {
const asciiName = fileName.replace(/[^\x20-\x7E]/g, "_").replace(/["\\]/g, "_")
return `attachment; filename="${asciiName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`
}
export default defineEventHandler(async (event) => {
const { folders } = getQuery(event)
const folderParam = typeof folders === "string" ? folders : ""
const folderNames = folderParam
.split(",")
.map((folder) => folder.trim())
.filter(Boolean)
if (folderNames.length === 0) {
throw createError({ statusCode: 400, statusMessage: "Paramètre folders invalide" })
}
if (folderNames.some((folder) => !isSafeFolder(folder))) {
throw createError({ statusCode: 400, statusMessage: "Paramètre folders invalide" })
}
const uniqueFolders = [...new Set(folderNames)]
const archiveEntries: Array<{ remoteDir: string; fileName: string; archiveName: string }> = []
for (const folderName of uniqueFolders) {
const remoteDir = await resolveFolderRemoteDir(folderName)
if (!remoteDir) {
continue
}
const fileName = await getLatestRemoteFile(remoteDir)
if (!fileName) {
continue
}
archiveEntries.push({
remoteDir,
fileName,
archiveName: `${folderName}/${fileName}`
})
}
if (archiveEntries.length === 0) {
throw createError({ statusCode: 404, statusMessage: "Aucun fichier a telecharger" })
}
const dateLabel = new Date().toISOString().slice(0, 19).replace(/[:T]/g, "-")
const archiveName = `backup-latest-${dateLabel}.tar.gz`
const tarArgs = archiveEntries.flatMap(({ remoteDir, fileName, archiveName: entryName }) => [
"--transform",
shellQuote(`s|^${fileName}$|${entryName}|`),
"-C",
shellQuote(remoteDir),
shellQuote(fileName)
])
const remoteCommand = `tar -czf - ${tarArgs.join(" ")}`
setHeader(event, "Content-Type", "application/gzip")
setHeader(event, "Content-Disposition", buildContentDisposition(archiveName))
const child = spawn("ssh", [
"-o",
"BatchMode=yes",
"-o",
"ConnectTimeout=5",
REMOTE_HOST,
remoteCommand
])
let stderr = ""
child.stderr.on("data", (chunk) => {
stderr += chunk.toString()
})
child.on("close", (code) => {
if (code !== 0) {
console.error(`Erreur archive SSH (${code}): ${stderr}`)
}
})
return sendStream(event, child.stdout)
})

View File

@@ -2,7 +2,7 @@ import { execFile, spawn } from "node:child_process"
import { Readable } from "node:stream" import { Readable } from "node:stream"
import folderMap from "../config/backup-folders.json" import folderMap from "../config/backup-folders.json"
const REMOTE_HOST = process.env.BACKUPS_REMOTE_HOST || "malio-b@192.168.0.179" const REMOTE_HOST = process.env.BACKUPS_REMOTE_HOST || "malio-b"
const REMOTE_ROOT = process.env.BACKUPS_REMOTE_ROOT || "/home/malio-b/backups" const REMOTE_ROOT = process.env.BACKUPS_REMOTE_ROOT || "/home/malio-b/backups"
const FOLDER_MAP = folderMap as Record<string, string> const FOLDER_MAP = folderMap as Record<string, string>

View File

@@ -1,7 +1,7 @@
{ {
"ferme": "bdd_recette/ferme", "ferme": "bdd-recette/ferme",
"inventory": "bdd_recette/inventory", "inventory": "bdd-recette/inventory",
"sirh": "bdd_recette/sirh", "sirh": "bdd-recette/sirh",
"user": "bdd_recette/user", "user": "bdd-recette/user",
"bitwarden": "bitwarden" "bitwarden": "bitwarden"
} }

View File

@@ -0,0 +1,22 @@
[
{
"key": "backup-bdd-recette",
"label": "Backup BDD recette",
"icon": "mdi:database-export",
"downloadFolders": ["ferme", "inventory", "sirh", "user"],
"command": "ssh ferme 'cd /home/malio/Malio-ops/RecetteScripts && bash backup-bdd-recette.sh && exit'"
},
{
"key": "check-statut-recette",
"label": "Check statut recette",
"icon": "mdi:server-network",
"command": "ssh ferme 'cd /home/malio/Malio-ops/RecetteScripts && bash check-statut-recette.sh && exit'"
},
{
"key": "backup-vaultwarden",
"label": "Backup vaultwarden",
"icon": "mdi:data",
"downloadFolders": ["bitwarden"],
"command": "ssh bitwarden 'cd /home/matt/vaultwarden/Malio-ops/BackupVaultWarden && bash backup-vaultwarden.sh && exit'"
}
]

View File

@@ -2,7 +2,7 @@
{ {
"key": "remote", "key": "remote",
"label": "Serveur distant", "label": "Serveur distant",
"command": "ssh malio-b@192.168.0.179 'cd /home/malio-b/Scripts-Serveur && bash check_storage.sh && exit'" "command": "ssh malio-b 'cd /home/malio-b/Malio-ops/CheckStorage && bash check-storage.sh && exit'"
}, },
{ {
"key": "local", "key": "local",