Compare commits
4 Commits
afbc630d48
...
c25d277abf
| Author | SHA1 | Date | |
|---|---|---|---|
| c25d277abf | |||
| 2715353d14 | |||
| 69ad5b657a | |||
| cdf7e40005 |
956
frontend/package-lock.json
generated
956
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,11 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@emotion/react": "^11.14.0",
|
||||||
|
"@emotion/styled": "^11.14.0",
|
||||||
|
"@mui/base": "^5.0.0-beta.70",
|
||||||
|
"@mui/icons-material": "^7.1.1",
|
||||||
|
"@mui/material": "^7.1.1",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0"
|
"react-dom": "^19.1.0"
|
||||||
|
|||||||
@ -1,42 +1,17 @@
|
|||||||
#root {
|
.app-wrapper {
|
||||||
max-width: 1280px;
|
display: flex;
|
||||||
margin: 0 auto;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-color: #121212;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
margin-bottom: 2rem;
|
||||||
|
|
||||||
.logo {
|
|
||||||
height: 6em;
|
|
||||||
padding: 1.5em;
|
|
||||||
will-change: filter;
|
|
||||||
transition: filter 300ms;
|
|
||||||
}
|
|
||||||
.logo:hover {
|
|
||||||
filter: drop-shadow(0 0 2em #646cffaa);
|
|
||||||
}
|
|
||||||
.logo.react:hover {
|
|
||||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes logo-spin {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
|
||||||
a:nth-of-type(2) .logo {
|
|
||||||
animation: logo-spin infinite 20s linear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
padding: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.read-the-docs {
|
|
||||||
color: #888;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
|
import './App.css';
|
||||||
|
import './style/global.css';
|
||||||
import BackupForm from './components/BackupForm';
|
import BackupForm from './components/BackupForm';
|
||||||
import RestoreForm from './components/RestoreForm';
|
import RestoreForm from './components/RestoreForm';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: "2rem" }}>
|
<div className="app-wrapper">
|
||||||
<h1>🚀 Snapix Dashboard</h1>
|
<h1 className="title">🚀 Snapix Dashboard</h1>
|
||||||
|
<div className="form-sections">
|
||||||
<BackupForm />
|
<BackupForm />
|
||||||
<hr />
|
|
||||||
<RestoreForm />
|
<RestoreForm />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
const api = axios.create({
|
|
||||||
baseURL: 'http://localhost:8000', // שנה לכתובת האמיתית שלך
|
|
||||||
});
|
|
||||||
|
|
||||||
export const getNamespaces = () => api.get('/namespaces');
|
|
||||||
export const getPVCs = (namespace) => api.get(`/pvcs/${namespace}`);
|
|
||||||
export const createBackup = (payload) => api.post('/backup', payload);
|
|
||||||
export const restoreBackup = (payload) => api.post('/restore', payload);
|
|
||||||
@ -1,67 +1,74 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { getNamespaces, getPVCs, createBackup } from '../api/snapix';
|
import { getNamespaces, getPVCs, createBackup } from '../service';
|
||||||
|
import '../style/BackupForm.css';
|
||||||
|
import { Button, Input, Select, Option } from '@mui/base';
|
||||||
|
|
||||||
export default function BackupForm() {
|
function BackupForm() {
|
||||||
const [namespaces, setNamespaces] = useState([]);
|
const [namespaces, setNamespaces] = useState([]);
|
||||||
const [pvcs, setPvcs] = useState([]);
|
const [pvcs, setPvcs] = useState([]);
|
||||||
const [selectedNs, setSelectedNs] = useState('');
|
const [namespace, setNamespace] = useState('');
|
||||||
const [selectedPvc, setSelectedPvc] = useState('');
|
const [pvc, setPvc] = useState('');
|
||||||
const [backupName, setBackupName] = useState('');
|
const [backupName, setBackupName] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getNamespaces().then(res => setNamespaces(res.data));
|
getNamespaces().then(setNamespaces);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedNs) {
|
if (namespace) {
|
||||||
getPVCs(selectedNs).then(res => setPvcs(res.data));
|
getPVCs(namespace).then(setPvcs);
|
||||||
} else {
|
} else {
|
||||||
setPvcs([]);
|
setPvcs([]);
|
||||||
}
|
}
|
||||||
}, [selectedNs]);
|
}, [namespace]);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = async () => {
|
||||||
if (selectedNs && selectedPvc && backupName) {
|
try {
|
||||||
createBackup({
|
await createBackup({ namespace, pvcName: pvc, backupName });
|
||||||
namespace: selectedNs,
|
alert('✅ Backup created successfully!');
|
||||||
pvc_name: selectedPvc,
|
} catch (error) {
|
||||||
backup_name: backupName,
|
console.error(error);
|
||||||
}).then(() => {
|
alert('❌ Backup failed');
|
||||||
alert("Backup started!");
|
|
||||||
setBackupName('');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="form-container BackupForm">
|
||||||
<h2>📦 Backup PVC</h2>
|
<h3>📦 Create Backup</h3>
|
||||||
|
<div className="form-group">
|
||||||
|
<label>Namespace</label>
|
||||||
|
<Select value={namespace} onChange={(e) => setNamespace(e.target.value)}>
|
||||||
|
<Option value="">-- Select Namespace --</Option>
|
||||||
|
{namespaces.map((ns) => (
|
||||||
|
<Option key={ns} value={ns}>{ns}</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label>Namespace:</label>
|
<div className="form-group">
|
||||||
<select onChange={e => setSelectedNs(e.target.value)} value={selectedNs}>
|
<label>PVC</label>
|
||||||
<option value="">-- Select Namespace --</option>
|
<Select value={pvc} onChange={(e) => setPvc(e.target.value)} disabled={!namespace}>
|
||||||
{namespaces.map(ns => <option key={ns}>{ns}</option>)}
|
<Option value="">-- Select PVC --</Option>
|
||||||
</select>
|
{pvcs.map((p) => (
|
||||||
|
<Option key={p} value={p}>{p}</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label>PVC:</label>
|
<div className="form-group">
|
||||||
<select
|
<label>Backup Name</label>
|
||||||
onChange={e => setSelectedPvc(e.target.value)}
|
<Input
|
||||||
value={selectedPvc}
|
|
||||||
disabled={!selectedNs}
|
|
||||||
>
|
|
||||||
<option value="">-- Select PVC --</option>
|
|
||||||
{pvcs.map(pvc => <option key={pvc}>{pvc}</option>)}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<label>Backup Name:</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
value={backupName}
|
value={backupName}
|
||||||
onChange={e => setBackupName(e.target.value)}
|
onChange={(e) => setBackupName(e.target.value)}
|
||||||
placeholder="e.g. git-bkp"
|
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button onClick={handleSubmit}>Create Backup</button>
|
<Button className="btn" onClick={handleSubmit} disabled={!namespace || !pvc || !backupName}>
|
||||||
|
Create Backup
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default BackupForm;
|
||||||
|
|||||||
@ -1,49 +1,58 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { restoreBackup } from '../api/snapix';
|
import { restoreBackup } from '../service';
|
||||||
|
import '../style/RestoreForm.css';
|
||||||
|
import { Button, Input } from '@mui/base';
|
||||||
|
|
||||||
export default function RestoreForm() {
|
function RestoreForm() {
|
||||||
|
const [namespace, setNamespace] = useState('');
|
||||||
|
const [targetPVC, setTargetPVC] = useState('');
|
||||||
const [backupName, setBackupName] = useState('');
|
const [backupName, setBackupName] = useState('');
|
||||||
const [targetNs, setTargetNs] = useState('');
|
|
||||||
const [targetPvc, setTargetPvc] = useState('');
|
|
||||||
|
|
||||||
const handleRestore = () => {
|
const handleSubmit = async () => {
|
||||||
if (backupName && targetNs && targetPvc) {
|
try {
|
||||||
restoreBackup({
|
await restoreBackup({ namespace, targetPVC, backupName });
|
||||||
backup_name: backupName,
|
alert('✅ Restore completed successfully!');
|
||||||
target_namespace: targetNs,
|
} catch (error) {
|
||||||
target_pvc: targetPvc,
|
console.error(error);
|
||||||
}).then(() => {
|
alert('❌ Restore failed');
|
||||||
alert("Restore started!");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="form-container RestoreForm">
|
||||||
<h2>🔁 Restore PVC</h2>
|
<h3>♻️ Restore from Backup</h3>
|
||||||
|
<div className="form-group">
|
||||||
<label>Backup Name:</label>
|
<label>Namespace</label>
|
||||||
<input
|
<input
|
||||||
|
type="text"
|
||||||
|
value={namespace}
|
||||||
|
onChange={(e) => setNamespace(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group">
|
||||||
|
<label>Target PVC</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={targetPVC}
|
||||||
|
onChange={(e) => setTargetPVC(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group">
|
||||||
|
<label>Backup Name</label>
|
||||||
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
value={backupName}
|
value={backupName}
|
||||||
onChange={e => setBackupName(e.target.value)}
|
onChange={(e) => setBackupName(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label>Target Namespace:</label>
|
<Button className="btn" onClick={handleSubmit} disabled={!namespace || !targetPVC || !backupName}>
|
||||||
<input
|
Restore
|
||||||
type="text"
|
</Button>
|
||||||
value={targetNs}
|
|
||||||
onChange={e => setTargetNs(e.target.value)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<label>Target PVC:</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={targetPvc}
|
|
||||||
onChange={e => setTargetPvc(e.target.value)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<button onClick={handleRestore}>Restore</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default RestoreForm;
|
||||||
|
|||||||
33
frontend/src/service.js
Normal file
33
frontend/src/service.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
const API_BASE = "http://localhost:8000";
|
||||||
|
|
||||||
|
export async function getNamespaces() {
|
||||||
|
const res = await fetch(`${API_BASE}/namespaces`);
|
||||||
|
if (!res.ok) throw new Error("Failed to fetch namespaces");
|
||||||
|
return await res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPVCs(namespace) {
|
||||||
|
const res = await fetch(`${API_BASE}/pvcs/${namespace}`);
|
||||||
|
if (!res.ok) throw new Error("Failed to fetch PVCs");
|
||||||
|
return await res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createBackup({ namespace, pvcName, backupName }) {
|
||||||
|
const res = await fetch(`${API_BASE}/backup`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ namespace, pvc_name: pvcName, backup_name: backupName }),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error("Failed to create backup");
|
||||||
|
return await res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function restoreBackup({ namespace, targetPVC, backupName }) {
|
||||||
|
const res = await fetch(`${API_BASE}/restore`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ namespace, target_pvc: targetPVC, backup_name: backupName }),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error("Failed to restore backup");
|
||||||
|
return await res.json();
|
||||||
|
}
|
||||||
7
frontend/src/style/BackupForm.css
Normal file
7
frontend/src/style/BackupForm.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.BackupForm {
|
||||||
|
background: #e3f2fd;
|
||||||
|
padding: 24px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
|
||||||
|
color: rgb(0, 0, 0);
|
||||||
|
}
|
||||||
7
frontend/src/style/RestoreForm.css
Normal file
7
frontend/src/style/RestoreForm.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.RestoreForm {
|
||||||
|
background: #f1f8e9;
|
||||||
|
padding: 24px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
|
||||||
|
color: rgb(0, 0, 0);
|
||||||
|
}
|
||||||
58
frontend/src/style/global.css
Normal file
58
frontend/src/style/global.css
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/* Global button style */
|
||||||
|
.btn {
|
||||||
|
padding: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
background: #1976d2;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:disabled {
|
||||||
|
background: #ccc;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inputs */
|
||||||
|
input, select {
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 1rem;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shared spacing for forms */
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group label {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-sections {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 480px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2rem;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .input {
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 1rem;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: transparent;
|
||||||
|
} */
|
||||||
Loading…
x
Reference in New Issue
Block a user