fix : securite middle et execfile
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue"
|
||||
import BackupRun from "~/components/BackupRun.vue"
|
||||
import { downloadApiFile, useApiAuthHeader } from "~/composables/useApiAuth"
|
||||
|
||||
definePageMeta({ layout: false })
|
||||
|
||||
@@ -117,35 +118,30 @@ const emptyScriptResult = (): ScriptResult => ({
|
||||
|
||||
const selectedBackup = ref<string | null>(null)
|
||||
const scriptResult = ref<ScriptResult>(emptyScriptResult())
|
||||
const apiAuthHeader = useApiAuthHeader()
|
||||
|
||||
const fetchLatestBackup = async (folder: string) => {
|
||||
const files = await $fetch<string[]>(`/api/backups?folder=${encodeURIComponent(folder)}`)
|
||||
const files = await $fetch<string[]>(`/api/backups?folder=${encodeURIComponent(folder)}`, {
|
||||
headers: apiAuthHeader
|
||||
})
|
||||
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 triggerDownload = async (folder: string, file: string) => {
|
||||
const url = `/api/download?folder=${encodeURIComponent(folder)}&file=${encodeURIComponent(file)}`
|
||||
await downloadApiFile(url, file)
|
||||
}
|
||||
|
||||
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 triggerBatchDownload = async (folders: string[]) => {
|
||||
const url = `/api/download-latest?folders=${encodeURIComponent(folders.join(","))}`
|
||||
await downloadApiFile(url, "backup-latest.tar.gz")
|
||||
}
|
||||
|
||||
const downloadLatestBackup = async (folder: string) => {
|
||||
const latestFile = await fetchLatestBackup(folder)
|
||||
|
||||
if (latestFile) {
|
||||
triggerDownload(folder, latestFile)
|
||||
await triggerDownload(folder, latestFile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +153,7 @@ const handleScriptResult = async (payload: ScriptResult) => {
|
||||
}
|
||||
|
||||
if (payload.downloadFolders.length > 1) {
|
||||
triggerBatchDownload(payload.downloadFolders)
|
||||
await triggerBatchDownload(payload.downloadFolders)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<script setup lang="ts">
|
||||
definePageMeta({layout: false})
|
||||
import {computed, onMounted, ref} from "vue"
|
||||
import { useApiAuthHeader } from "~/composables/useApiAuth"
|
||||
|
||||
type DiskSourceResult = {
|
||||
key: string
|
||||
@@ -77,6 +78,7 @@ type DiagramItem = {
|
||||
const selectedBackup = ref<string | null>(null)
|
||||
const rawResults = ref<DiskSourceResult[]>([])
|
||||
const loading = ref(false)
|
||||
const apiAuthHeader = useApiAuthHeader()
|
||||
const chartRadius = 52
|
||||
const chartCircumference = 2 * Math.PI * chartRadius
|
||||
|
||||
@@ -151,7 +153,9 @@ const runScript = async () => {
|
||||
rawResults.value = []
|
||||
|
||||
try {
|
||||
const output = await $fetch<DiskApiResponse>("/api/disk")
|
||||
const output = await $fetch<DiskApiResponse>("/api/disk", {
|
||||
headers: apiAuthHeader
|
||||
})
|
||||
rawResults.value = output.results
|
||||
} catch (error) {
|
||||
const message = `Erreur: ${error instanceof Error ? error.message : String(error)}`
|
||||
|
||||
Reference in New Issue
Block a user