Merge branch 'dev' of ssh://git.commumedia.org:2222/alex/headquarter into dev
This commit is contained in:
@@ -75,7 +75,12 @@ export function SessionCard({
|
|||||||
const isActive = ["running", "building", "starting", "probing", "pending", "unhealthy"].includes(session.status);
|
const isActive = ["running", "building", "starting", "probing", "pending", "unhealthy"].includes(session.status);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="card session-card">
|
<article className={`card session-card ${isBusy ? "busy" : ""}`}>
|
||||||
|
{isBusy && (
|
||||||
|
<div className="session-busy-overlay">
|
||||||
|
<Icon name="loading" size="md" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="session-card-content">
|
<div className="session-card-content">
|
||||||
<div className="session-card-header">
|
<div className="session-card-header">
|
||||||
<div className="session-card-title">
|
<div className="session-card-title">
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ export const HomePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleStop = async (session: SessionView) => {
|
const handleStop = async (session: SessionView) => {
|
||||||
|
if (actionBusy === session.id) return;
|
||||||
setActionBusy(session.id);
|
setActionBusy(session.id);
|
||||||
try {
|
try {
|
||||||
await stopInstance(session.project_id, session.repository_id, session.id);
|
await stopInstance(session.project_id, session.repository_id, session.id);
|
||||||
@@ -153,6 +154,7 @@ export const HomePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (session: SessionView) => {
|
const handleDelete = async (session: SessionView) => {
|
||||||
|
if (actionBusy === session.id) return;
|
||||||
setActionBusy(session.id);
|
setActionBusy(session.id);
|
||||||
try {
|
try {
|
||||||
await deleteInstance(session.project_id, session.repository_id, session.id);
|
await deleteInstance(session.project_id, session.repository_id, session.id);
|
||||||
@@ -165,6 +167,7 @@ export const HomePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRecreateTunnel = async (session: SessionView) => {
|
const handleRecreateTunnel = async (session: SessionView) => {
|
||||||
|
if (actionBusy === session.id) return;
|
||||||
setActionBusy(session.id);
|
setActionBusy(session.id);
|
||||||
try {
|
try {
|
||||||
await recreateInstanceTunnel(session.project_id, session.repository_id, session.id);
|
await recreateInstanceTunnel(session.project_id, session.repository_id, session.id);
|
||||||
@@ -175,6 +178,7 @@ export const HomePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleStart = async (session: SessionView) => {
|
const handleStart = async (session: SessionView) => {
|
||||||
|
if (actionBusy === session.id) return;
|
||||||
setActionBusy(session.id);
|
setActionBusy(session.id);
|
||||||
try {
|
try {
|
||||||
await startInstance(session.project_id, session.repository_id, session.id);
|
await startInstance(session.project_id, session.repository_id, session.id);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
type Session,
|
type Session,
|
||||||
deleteInstance,
|
deleteInstance,
|
||||||
stopInstance,
|
stopInstance,
|
||||||
|
startInstance,
|
||||||
checkInstanceHealth,
|
checkInstanceHealth,
|
||||||
recreateInstanceTunnel,
|
recreateInstanceTunnel,
|
||||||
} from "../api/sessions";
|
} from "../api/sessions";
|
||||||
@@ -38,7 +39,6 @@ export const SessionsPage = () => {
|
|||||||
|
|
||||||
const [tunnelHealth, setTunnelHealth] = useState<Record<string, InstanceHealth>>({});
|
const [tunnelHealth, setTunnelHealth] = useState<Record<string, InstanceHealth>>({});
|
||||||
const [loadingSessionId, setLoadingSessionId] = useState<string | null>(null);
|
const [loadingSessionId, setLoadingSessionId] = useState<string | null>(null);
|
||||||
const [loadingAction, setLoadingAction] = useState<string>("");
|
|
||||||
|
|
||||||
const loadSessions = useCallback(async () => {
|
const loadSessions = useCallback(async () => {
|
||||||
setStatus("loading");
|
setStatus("loading");
|
||||||
@@ -155,8 +155,8 @@ export const SessionsPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleStop = async (session: Session) => {
|
const handleStop = async (session: Session) => {
|
||||||
|
if (loadingSessionId === session.id) return;
|
||||||
setLoadingSessionId(session.id);
|
setLoadingSessionId(session.id);
|
||||||
setLoadingAction("Stopping...");
|
|
||||||
try {
|
try {
|
||||||
await stopInstance(session.project_id, session.repository_id, session.id);
|
await stopInstance(session.project_id, session.repository_id, session.id);
|
||||||
await loadSessions();
|
await loadSessions();
|
||||||
@@ -164,13 +164,12 @@ export const SessionsPage = () => {
|
|||||||
// ignore
|
// ignore
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingSessionId(null);
|
setLoadingSessionId(null);
|
||||||
setLoadingAction("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (session: Session) => {
|
const handleDelete = async (session: Session) => {
|
||||||
|
if (loadingSessionId === session.id) return;
|
||||||
setLoadingSessionId(session.id);
|
setLoadingSessionId(session.id);
|
||||||
setLoadingAction("Deleting...");
|
|
||||||
try {
|
try {
|
||||||
await deleteInstance(session.project_id, session.repository_id, session.id);
|
await deleteInstance(session.project_id, session.repository_id, session.id);
|
||||||
setDirtyDeleteSession(null);
|
setDirtyDeleteSession(null);
|
||||||
@@ -189,13 +188,12 @@ export const SessionsPage = () => {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingSessionId(null);
|
setLoadingSessionId(null);
|
||||||
setLoadingAction("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleForceDelete = async (session: Session) => {
|
const handleForceDelete = async (session: Session) => {
|
||||||
|
if (loadingSessionId === session.id) return;
|
||||||
setLoadingSessionId(session.id);
|
setLoadingSessionId(session.id);
|
||||||
setLoadingAction("Force deleting...");
|
|
||||||
try {
|
try {
|
||||||
await deleteInstance(session.project_id, session.repository_id, session.id, true);
|
await deleteInstance(session.project_id, session.repository_id, session.id, true);
|
||||||
setDirtyDeleteSession(null);
|
setDirtyDeleteSession(null);
|
||||||
@@ -205,13 +203,12 @@ export const SessionsPage = () => {
|
|||||||
// ignore
|
// ignore
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingSessionId(null);
|
setLoadingSessionId(null);
|
||||||
setLoadingAction("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRecreateTunnel = async (session: Session) => {
|
const handleRecreateTunnel = async (session: Session) => {
|
||||||
|
if (loadingSessionId === session.id) return;
|
||||||
setLoadingSessionId(session.id);
|
setLoadingSessionId(session.id);
|
||||||
setLoadingAction("Recreating tunnel...");
|
|
||||||
try {
|
try {
|
||||||
await recreateInstanceTunnel(
|
await recreateInstanceTunnel(
|
||||||
session.project_id,
|
session.project_id,
|
||||||
@@ -224,7 +221,19 @@ export const SessionsPage = () => {
|
|||||||
// ignore
|
// ignore
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingSessionId(null);
|
setLoadingSessionId(null);
|
||||||
setLoadingAction("");
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStart = async (session: Session) => {
|
||||||
|
if (loadingSessionId === session.id) return;
|
||||||
|
setLoadingSessionId(session.id);
|
||||||
|
try {
|
||||||
|
await startInstance(session.project_id, session.repository_id, session.id);
|
||||||
|
await loadSessions();
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
} finally {
|
||||||
|
setLoadingSessionId(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -273,18 +282,11 @@ export const SessionsPage = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Session List */}
|
{/* Session List */}
|
||||||
<div className={`sessions-list-wrapper ${loadingSessionId ? "dimmed" : ""}`}>
|
<div className="sessions-list-wrapper">
|
||||||
{loadingSessionId && (
|
|
||||||
<div className="loading-overlay">
|
|
||||||
<div className="loading-content">
|
|
||||||
<Icon name="loading" size="lg" />
|
|
||||||
<p>{loadingAction}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<SessionList
|
<SessionList
|
||||||
sessions={sessions}
|
sessions={sessions}
|
||||||
onOpen={handleOpen}
|
onOpen={handleOpen}
|
||||||
|
onStart={handleStart}
|
||||||
onStop={handleStop}
|
onStop={handleStop}
|
||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
onRecreateTunnel={handleRecreateTunnel}
|
onRecreateTunnel={handleRecreateTunnel}
|
||||||
|
|||||||
@@ -2500,6 +2500,25 @@ a.nav-item,
|
|||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.session-card {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-card.busy {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-busy-overlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(var(--bg-rgb, 255, 255, 255), 0.8);
|
||||||
|
border-radius: var(--space-2);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* ============================================
|
/* ============================================
|
||||||
Terminal Styles
|
Terminal Styles
|
||||||
============================================ */
|
============================================ */
|
||||||
|
|||||||
Reference in New Issue
Block a user