push newest version
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useAuth } from '../contexts/AuthContext'
|
||||
|
||||
const SpaceDetail = () => {
|
||||
const { id } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const { authFetch } = useAuth()
|
||||
const [space, setSpace] = useState(null)
|
||||
const [fqdns, setFqdns] = useState([])
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
@@ -47,7 +49,7 @@ const SpaceDetail = () => {
|
||||
const fetchSpace = async () => {
|
||||
try {
|
||||
setLoadingSpace(true)
|
||||
const response = await fetch('/api/spaces')
|
||||
const response = await authFetch('/api/spaces')
|
||||
if (response.ok) {
|
||||
const spaces = await response.json()
|
||||
const foundSpace = spaces.find(s => s.id === id)
|
||||
@@ -70,7 +72,7 @@ const SpaceDetail = () => {
|
||||
const fetchFqdns = async () => {
|
||||
try {
|
||||
setFetchError('')
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns`)
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns`)
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
setFqdns(Array.isArray(data) ? data : [])
|
||||
@@ -108,7 +110,7 @@ const SpaceDetail = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns`, {
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -165,7 +167,7 @@ const SpaceDetail = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${fqdnToDelete.id}`, {
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${fqdnToDelete.id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
@@ -216,7 +218,7 @@ const SpaceDetail = () => {
|
||||
formData.append('fqdn', fqdn.fqdn)
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`, {
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
@@ -254,7 +256,7 @@ const SpaceDetail = () => {
|
||||
|
||||
const fetchCSR = async (fqdn) => {
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`)
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`)
|
||||
if (response.ok) {
|
||||
const csr = await response.json()
|
||||
if (csr) {
|
||||
@@ -278,7 +280,7 @@ const SpaceDetail = () => {
|
||||
// Lade neuesten CSR und alle CSRs für History
|
||||
try {
|
||||
// Lade neuesten CSR
|
||||
const latestResponse = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr?latest=true`)
|
||||
const latestResponse = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr?latest=true`)
|
||||
if (latestResponse.ok) {
|
||||
const csr = await latestResponse.json()
|
||||
setCsrData(csr || null)
|
||||
@@ -287,7 +289,7 @@ const SpaceDetail = () => {
|
||||
}
|
||||
|
||||
// Lade alle CSRs für History
|
||||
const historyResponse = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`)
|
||||
const historyResponse = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`)
|
||||
if (historyResponse.ok) {
|
||||
const history = await historyResponse.json()
|
||||
setCsrHistory(Array.isArray(history) ? history : [])
|
||||
@@ -330,7 +332,7 @@ const SpaceDetail = () => {
|
||||
|
||||
// Lade neuesten CSR
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr?latest=true`)
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr?latest=true`)
|
||||
if (response.ok) {
|
||||
const csr = await response.json()
|
||||
setCsrData(csr)
|
||||
@@ -341,7 +343,7 @@ const SpaceDetail = () => {
|
||||
|
||||
// Lade Provider
|
||||
try {
|
||||
const response = await fetch('/api/providers')
|
||||
const response = await authFetch('/api/providers')
|
||||
if (response.ok) {
|
||||
const providersData = await response.json()
|
||||
setProviders(providersData.filter(p => p.enabled))
|
||||
@@ -356,7 +358,7 @@ const SpaceDetail = () => {
|
||||
const handleTestProvider = async (providerId) => {
|
||||
setProviderTestResult(null)
|
||||
try {
|
||||
const response = await fetch(`/api/providers/${providerId}/test`, {
|
||||
const response = await authFetch(`/api/providers/${providerId}/test`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
@@ -375,7 +377,7 @@ const SpaceDetail = () => {
|
||||
setSignResult(null)
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${selectedFqdn.id}/csr/sign`, {
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${selectedFqdn.id}/csr/sign`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
@@ -389,7 +391,7 @@ const SpaceDetail = () => {
|
||||
if (result.success) {
|
||||
// Lade Zertifikate automatisch neu, um das neue Zertifikat anzuzeigen
|
||||
try {
|
||||
const certResponse = await fetch(`/api/spaces/${id}/fqdns/${selectedFqdn.id}/certificates`)
|
||||
const certResponse = await authFetch(`/api/spaces/${id}/fqdns/${selectedFqdn.id}/certificates`)
|
||||
if (certResponse.ok) {
|
||||
const certs = await certResponse.json()
|
||||
setCertificates(certs)
|
||||
@@ -420,7 +422,7 @@ const SpaceDetail = () => {
|
||||
setCertificates([])
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/certificates`)
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/certificates`)
|
||||
if (response.ok) {
|
||||
const certs = await response.json()
|
||||
setCertificates(certs)
|
||||
@@ -438,7 +440,7 @@ const SpaceDetail = () => {
|
||||
const handleRefreshCertificate = async (cert) => {
|
||||
setRefreshingCertificate(cert.id)
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${selectedFqdn.id}/certificates/${cert.id}/refresh`, {
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${selectedFqdn.id}/certificates/${cert.id}/refresh`, {
|
||||
method: 'POST'
|
||||
})
|
||||
if (response.ok) {
|
||||
@@ -766,7 +768,7 @@ const SpaceDetail = () => {
|
||||
if (!isOpen) {
|
||||
// Lade CSR-History wenn Bereich erweitert wird
|
||||
try {
|
||||
const response = await fetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`)
|
||||
const response = await authFetch(`/api/spaces/${id}/fqdns/${fqdn.id}/csr`)
|
||||
if (response.ok) {
|
||||
const history = await response.json()
|
||||
// Speichere History mit FQDN-ID als Key
|
||||
|
||||
Reference in New Issue
Block a user