fix : correctif mr
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
import {Icon as IconifyIcon} from "@iconify/vue"
|
||||
import CircleSkeleton from "~/components/skeleton/CircleSkeleton.vue"
|
||||
import TextSkeleton from "~/components/skeleton/TextSkeleton.vue"
|
||||
import { downloadApiFile, useApiAuthHeader } from "~/composables/useApiAuth"
|
||||
import { apiFetch, downloadApiFile } from "~/composables/useApiAuth"
|
||||
|
||||
const props = defineProps<{
|
||||
folder: string | null
|
||||
@@ -71,7 +71,6 @@ const props = defineProps<{
|
||||
const backups = ref<string[]>([])
|
||||
const loading = ref(false)
|
||||
const errorMessage = ref("")
|
||||
const apiAuthHeader = useApiAuthHeader()
|
||||
const title = computed(() => {
|
||||
if (!props.folder) return "Fichiers"
|
||||
return `Backup — ${props.folder.toUpperCase()}`
|
||||
@@ -101,10 +100,7 @@ watch(() => props.folder, async (folder) => {
|
||||
loading.value = true
|
||||
errorMessage.value = ""
|
||||
try {
|
||||
const data = await $fetch<string[]>(`/api/backups?folder=${encodeURIComponent(folder)}`, {
|
||||
headers: apiAuthHeader,
|
||||
server: false
|
||||
})
|
||||
const data = await apiFetch<string[]>(`/api/backups?folder=${encodeURIComponent(folder)}`)
|
||||
backups.value = data
|
||||
} catch (error) {
|
||||
console.error("Erreur récupération backups:", error)
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue"
|
||||
import { Icon as IconifyIcon } from "@iconify/vue"
|
||||
import { useApiAuthHeader } from "~/composables/useApiAuth"
|
||||
import { apiFetch } from "~/composables/useApiAuth"
|
||||
|
||||
type BackupScript = {
|
||||
key: string
|
||||
@@ -119,7 +119,6 @@ const scripts = ref<BackupScript[]>([])
|
||||
const output = ref<string>("")
|
||||
const message = ref<string>("")
|
||||
const isError = ref(false)
|
||||
const apiAuthHeader = useApiAuthHeader()
|
||||
|
||||
const statusClass = computed(() => (isError.value ? "status-error" : "status-success"))
|
||||
|
||||
@@ -136,9 +135,7 @@ const loadScripts = async () => {
|
||||
downloadFolders: []
|
||||
})
|
||||
try {
|
||||
const data = await $fetch<BackupScriptListResponse>("/api/backup-script", {
|
||||
headers: apiAuthHeader
|
||||
})
|
||||
const data = await apiFetch<BackupScriptListResponse>("/api/backup-script")
|
||||
scripts.value = data.scripts
|
||||
} catch (error) {
|
||||
scripts.value = []
|
||||
@@ -164,10 +161,9 @@ const runScript = async (key: string) => {
|
||||
isError.value = false
|
||||
|
||||
try {
|
||||
const data = await $fetch<BackupScriptRunResponse>("/api/backup-script", {
|
||||
const data = await apiFetch<BackupScriptRunResponse>("/api/backup-script", {
|
||||
method: "POST",
|
||||
body: { key },
|
||||
headers: apiAuthHeader
|
||||
body: { key }
|
||||
})
|
||||
message.value = `${data.label} execute avec succes`
|
||||
output.value = data.output || "Aucune sortie retournee."
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup>
|
||||
import {Icon as IconifyIcon} from "@iconify/vue"
|
||||
import { useApiAuthHeader } from "~/composables/useApiAuth"
|
||||
import { apiFetch } from "~/composables/useApiAuth"
|
||||
|
||||
const { data: messages, error } = await useFetch('/api/discord/messages', {
|
||||
headers: useApiAuthHeader(),
|
||||
$fetch: apiFetch,
|
||||
server: false
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -46,14 +46,13 @@
|
||||
<script setup lang="ts">
|
||||
import {computed, ref} from "vue"
|
||||
import {Icon as IconifyIcon} from "@iconify/vue"
|
||||
import { useApiAuthHeader, withApiAuth } from "~/composables/useApiAuth"
|
||||
import { apiRequest } from "~/composables/useApiAuth"
|
||||
|
||||
const ping = ref<number | null>(null)
|
||||
const download = ref<number | null>(null)
|
||||
const upload = ref<number | null>(null)
|
||||
const isTesting = ref(false)
|
||||
const errorMessage = ref("")
|
||||
const apiAuthHeader = useApiAuthHeader()
|
||||
|
||||
const metrics = computed(() => [
|
||||
{ label: "Download", icon: "mdi:arrow-down-bold", value: download.value, unit: "Mbps" },
|
||||
@@ -63,9 +62,7 @@ const metrics = computed(() => [
|
||||
|
||||
async function testDownload() {
|
||||
const start = performance.now()
|
||||
const res = await fetch('/api/download', {
|
||||
headers: apiAuthHeader
|
||||
})
|
||||
const res = await apiRequest('/api/download')
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`)
|
||||
}
|
||||
@@ -80,7 +77,7 @@ async function testUpload() {
|
||||
const size = 5 * 1024 * 1024
|
||||
const data = new Uint8Array(size)
|
||||
const start = performance.now()
|
||||
const response = await fetch('/api/upload', withApiAuth({ method: 'POST', body: data }))
|
||||
const response = await apiRequest('/api/upload', { method: 'POST', body: data })
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
import CircleSkeleton from "~/components/skeleton/CircleSkeleton.vue"
|
||||
import TextSkeleton from "~/components/skeleton/TextSkeleton.vue"
|
||||
import {onBeforeUnmount, onMounted, ref} from "vue"
|
||||
import { useApiAuthHeader } from "~/composables/useApiAuth"
|
||||
import { apiFetch } from "~/composables/useApiAuth"
|
||||
|
||||
interface StatusRow {
|
||||
label: string
|
||||
@@ -72,7 +72,6 @@ const props = withDefaults(
|
||||
const rows = ref<StatusRow[]>([])
|
||||
const loading = ref(true)
|
||||
const initialized = ref(false)
|
||||
const apiAuthHeader = useApiAuthHeader()
|
||||
let timer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
const statusLabel = (status: number) => {
|
||||
@@ -86,9 +85,7 @@ const checkStatus = async () => {
|
||||
loading.value = true
|
||||
}
|
||||
try {
|
||||
const data = await $fetch<StatusResponse>(props.endpoint, {
|
||||
headers: apiAuthHeader
|
||||
})
|
||||
const data = await apiFetch<StatusResponse>(props.endpoint)
|
||||
rows.value = data.results
|
||||
} catch (error) {
|
||||
rows.value = [
|
||||
|
||||
Reference in New Issue
Block a user