Add 5-minute auto-reload and last-updated timestamp to admin UI
This commit is contained in:
parent
02b4ad06ca
commit
cf1b3f7786
@ -222,21 +222,31 @@ function App() {
|
|||||||
const [creating, setCreating] = useState(false);
|
const [creating, setCreating] = useState(false);
|
||||||
const [editKey, setEditKey] = useState(null);
|
const [editKey, setEditKey] = useState(null);
|
||||||
const [editForm, setEditForm] = useState({});
|
const [editForm, setEditForm] = useState({});
|
||||||
|
const [refreshKey, setRefreshKey] = useState(0);
|
||||||
useEffect(() => {
|
const [lastUpdated, setLastUpdated] = useState(null);
|
||||||
if (!password) { setLoading(false); return; }
|
|
||||||
fetchApiKeys().finally(() => setLoading(false));
|
|
||||||
}, [password]);
|
|
||||||
|
|
||||||
const fetchApiKeys = async () => {
|
const fetchApiKeys = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get('/api/api-keys', { headers: authHeaders(password) });
|
const res = await axios.get('/api/api-keys', { headers: authHeaders(password) });
|
||||||
setApiKeys(res.data);
|
setApiKeys(res.data);
|
||||||
|
setLastUpdated(new Date());
|
||||||
} catch {
|
} catch {
|
||||||
setError('API-Keys konnten nicht geladen werden.');
|
setError('API-Keys konnten nicht geladen werden.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!password) { setLoading(false); return; }
|
||||||
|
fetchApiKeys().finally(() => setLoading(false));
|
||||||
|
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
fetchApiKeys();
|
||||||
|
setRefreshKey(k => k + 1);
|
||||||
|
}, 5 * 60 * 1000);
|
||||||
|
|
||||||
|
return () => clearInterval(timer);
|
||||||
|
}, [password]);
|
||||||
|
|
||||||
const handleCreate = async (e) => {
|
const handleCreate = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setCreating(true);
|
setCreating(true);
|
||||||
@ -328,10 +338,17 @@ function App() {
|
|||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
<h1>Ollama Proxy Admin</h1>
|
<h1>Ollama Proxy Admin</h1>
|
||||||
|
<div className="header-right">
|
||||||
|
{lastUpdated && (
|
||||||
|
<span className="last-updated">
|
||||||
|
Aktualisiert: {lastUpdated.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<button onClick={logout}>Abmelden</button>
|
<button onClick={logout}>Abmelden</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<SettingsSection password={password} />
|
<SettingsSection password={password} refreshKey={refreshKey} />
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Neuer API-Key</h2>
|
<h2>Neuer API-Key</h2>
|
||||||
|
|||||||
@ -486,3 +486,14 @@ tr:hover {
|
|||||||
color: #f5a0a0;
|
color: #f5a0a0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.last-updated {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #95a5a6;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user