8 Commits
main ... dev

Author SHA1 Message Date
a9a3b0c4e6 add local websocket url 2026-03-24 21:36:22 -07:00
10acf1f0f2 style pass 2026-03-24 21:30:59 -07:00
b1863f8dcf remove duplicate start 2026-03-24 21:27:12 -07:00
a588a16b96 fix scss imports 2026-03-24 21:25:19 -07:00
9be82e9e95 remove user / auth 2026-03-24 21:22:39 -07:00
9cde325a02 remove duplicate function 2026-03-24 21:16:06 -07:00
a08f42b8af api changes 2026-03-22 14:15:59 -07:00
89da98e35c logs hooked up 2026-03-05 08:16:11 -08:00
28 changed files with 1397 additions and 1140 deletions

1
.env
View File

@ -1,2 +1,3 @@
VITE_API_URL=http://localhost:3000/api VITE_API_URL=http://localhost:3000/api
VITE_WS_URL=ws://localhost:3000
VITE_MOCK_AUTH=true VITE_MOCK_AUTH=true

View File

@ -1,5 +1,5 @@
# API base URL for the backend that wraps the abra CLI # API base URL for the backend that wraps the abra CLI
VITE_API_URL=http://localhost:3000/api VITE_API_URL=http://localhost:3000/api
# Set to 'true' to bypass authentication for development # Set to 'true' to use mock data
VITE_MOCK_AUTH=true VITE_MOCK_AUTH=true

View File

@ -1,37 +1,26 @@
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { AuthProvider } from './context/AuthContext'; import { Dashboard } from './routes/Dashboard/Dashboard';
import { LoginForm } from './routes/Login/LoginForm'; import { Apps } from './routes/Apps/Apps';
import { Authenticated } from './components/Authenticated'; import { AppDetail } from './routes/Apps/App';
import { Dashboard } from './routes/Authenticated/Dashboard/Dashboard'; import { Servers } from './routes/Servers/Servers';
import { Apps } from './routes/Authenticated/Apps/Apps'; import { Server } from './routes/Servers/Server';
import { AppDetail } from './routes/Authenticated/Apps/App';
import { Servers } from './routes/Authenticated/Servers/Servers';
import { Server } from './routes/Authenticated/Servers/Server';
function App() { function App() {
return ( return (
<BrowserRouter> <BrowserRouter>
<AuthProvider> <Routes>
<Routes> <Route path="/" element={<Navigate to="/dashboard" replace />} />
{/* Public routes */} <Route path="/dashboard" element={<Dashboard />} />
<Route path="/login" element={<LoginForm />} /> <Route path="/apps" element={<Apps />} />
<Route path="/apps/:server/:appName" element={<AppDetail />} />
{/* Protected routes */} <Route path="/servers" element={<Servers />} />
<Route element={<Authenticated />}> <Route path="/servers/:serverName" element={<Server />} />
<Route path="/" element={<Navigate to="/dashboard" replace />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/apps" element={<Apps />} />
<Route path="/apps/:server/:appName" element={<AppDetail />} />
<Route path="/servers" element={<Servers />} />
<Route path="/servers/:serverName" element={<Server />} />
</Route>
{/* 404 catch-all */} {/* 404 catch-all */}
<Route path="*" element={<Navigate to="/dashboard" replace />} /> <Route path="*" element={<Navigate to="/dashboard" replace />} />
</Routes> </Routes>
</AuthProvider>
</BrowserRouter> </BrowserRouter>
); );
} }
export default App; export default App;

View File

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 163 KiB

View File

@ -1,24 +0,0 @@
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
export const Authenticated: React.FC = () => {
const { isAuthenticated, loading } = useAuth();
console.log('🛡️ ProtectedRoute:', { isAuthenticated, loading });
if (loading) {
return (
<div style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh'
}}>
<p>Loading...</p>
</div>
);
}
return isAuthenticated ? <Outlet /> : <Navigate to="/login" replace />;
};

View File

@ -1,25 +1,20 @@
import React from 'react'; import React from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { useAuth } from '../../hooks/useAuth';
import './_Header.scss'; import './_Header.scss';
import logo from '../../assets/coopcloud_logo_grey.svg';
interface HeaderProps { interface HeaderProps {
children: React.ReactNode; children: React.ReactNode;
} }
export const Header: React.FC<HeaderProps> = ({ children }) => { export const Header: React.FC<HeaderProps> = ({ children }) => {
const { user, logout } = useAuth();
const navigate = useNavigate(); const navigate = useNavigate();
const handleLogout = async () => {
await logout();
navigate('/login');
};
return( return(
<header className="layout-header"> <header className="layout-header">
<div className="header-content"> <div className="header-content">
<h1 onClick={() => navigate('/dashboard')} className="logo"> <h1 onClick={() => navigate('/dashboard')} className="logo">
<img className="logo" src="/public/coopcloud_logo_grey.svg"/> <img className="logo" src={logo}/>
</h1> </h1>
<nav className="nav"> <nav className="nav">
<button onClick={() => navigate('/dashboard')} className="nav-link"> <button onClick={() => navigate('/dashboard')} className="nav-link">
@ -32,13 +27,6 @@ return(
Servers Servers
</button> </button>
</nav> </nav>
<div className="user-menu">
<span className="username">{user?.username}</span>
<button onClick={handleLogout} className="logout-button">
Logout
</button>
</div>
</div> </div>
</header> </header>
)} )}

View File

@ -78,50 +78,4 @@
font-size: $font-size-xl; font-size: $font-size-xl;
} }
} }
.user-menu {
display: flex;
align-items: center;
gap: $spacing-lg;
@media (max-width: 768px) {
width: 100%;
justify-content: space-between;
}
.username {
font-weight: $font-weight-medium;
font-size: $font-size-base;
@media (max-width: 480px) {
font-size: $font-size-sm;
}
}
.logout-button {
background: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.4);
color: $text-primary;
padding: $spacing-sm $spacing-lg;
border-radius: $radius-md;
cursor: pointer;
transition: all $transition-base;
font-weight: $font-weight-medium;
&:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
&:active {
transform: translateY(0);
}
@media (max-width: 480px) {
padding: $spacing-sm $spacing-md;
font-size: $font-size-sm;
}
}
}
} }

View File

@ -0,0 +1,86 @@
import React, { useEffect, useRef, useState } from 'react';
import type { LogEntry } from '../../services/mockApi'; // Import from mockApi (or api for real)
import './_Terminal.scss';
interface TerminalProps {
logs: LogEntry[];
isActive: boolean;
onClose?: () => void;
}
export const Terminal: React.FC<TerminalProps> = ({ logs, isActive, onClose }) => {
const terminalRef = useRef<HTMLDivElement>(null);
const [displayedLogs, setDisplayedLogs] = useState<LogEntry[]>([]);
// Stream logs in with delays for realistic effect
useEffect(() => {
if (!isActive || logs.length === 0) {
setDisplayedLogs([]);
return;
}
setDisplayedLogs([]);
let currentIndex = 0;
const streamLogs = () => {
if (currentIndex < logs.length) {
setDisplayedLogs(prev => [...prev, logs[currentIndex]]);
currentIndex++;
// Variable delay based on log type
const delay = logs[currentIndex - 1]?.type === 'command' ? 200 :
logs[currentIndex - 1]?.type === 'output' ? 100 : 300;
setTimeout(streamLogs, delay);
}
};
streamLogs();
}, [logs, isActive]);
// Auto-scroll to bottom
useEffect(() => {
if (terminalRef.current) {
terminalRef.current.scrollTop = terminalRef.current.scrollHeight;
}
}, [displayedLogs]);
if (!isActive && displayedLogs.length === 0) {
return null;
}
const formatTime = (date: Date) => {
return date.toLocaleTimeString('en-US', {
hour12: false,
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
};
return (
<div className="terminal-container">
<div className="terminal-header">
<div className="terminal-controls">
<span className="terminal-control close" onClick={onClose}></span>
<span className="terminal-control minimize"></span>
<span className="terminal-control maximize"></span>
</div>
<div className="terminal-title">abra CLI</div>
<div className="terminal-spacer"></div>
</div>
<div className="terminal-content" ref={terminalRef}>
{displayedLogs.filter(log => log && log.type).map((log, index) => (
<div key={index} className={`terminal-line terminal-${log.type}`}>
<span className="terminal-timestamp">[{formatTime(log.timestamp)}]</span>
<span className="terminal-text">{log.text}</span>
</div>
))}
{isActive && displayedLogs.length > 0 && (
<div className="terminal-cursor"></div>
)}
</div>
</div>
);
};

View File

@ -0,0 +1,204 @@
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
.terminal-container {
background: #1e1e1e;
border-radius: $radius-md;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Source Code Pro', monospace;
margin-bottom: $spacing-xl;
animation: terminal-appear 0.3s ease-out;
}
@keyframes terminal-appear {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.terminal-header {
display: flex;
align-items: center;
padding: $spacing-sm $spacing-md;
background: #323232;
border-bottom: 1px solid #404040;
user-select: none;
.terminal-controls {
display: flex;
gap: $spacing-xs;
min-width: 60px;
}
.terminal-control {
width: 12px;
height: 12px;
border-radius: 50%;
cursor: pointer;
transition: opacity 0.2s;
&:hover {
opacity: 0.8;
}
&.close {
background: #ff5f56;
}
&.minimize {
background: #ffbd2e;
}
&.maximize {
background: #27c93f;
}
}
.terminal-title {
flex: 1;
text-align: center;
color: #a0a0a0;
font-size: $font-size-xs;
font-weight: $font-weight-medium;
}
.terminal-spacer {
min-width: 60px;
}
}
.terminal-content {
padding: $spacing-md;
background: #1e1e1e;
color: #d4d4d4;
font-size: 13px;
line-height: 1.6;
max-height: 400px;
overflow-y: auto;
overflow-x: hidden;
/* Custom scrollbar */
&::-webkit-scrollbar {
width: 8px;
}
&::-webkit-scrollbar-track {
background: #2d2d2d;
}
&::-webkit-scrollbar-thumb {
background: #4a4a4a;
border-radius: 4px;
&:hover {
background: #5a5a5a;
}
}
}
.terminal-line {
display: flex;
margin-bottom: 2px;
animation: terminal-line-appear 0.2s ease-out;
white-space: pre-wrap;
word-break: break-word;
@keyframes terminal-line-appear {
from {
opacity: 0;
transform: translateX(-4px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
.terminal-timestamp {
color: #6a6a6a;
margin-right: $spacing-sm;
flex-shrink: 0;
font-size: 11px;
}
.terminal-text {
flex: 1;
}
/* Line type styles */
&.terminal-info {
.terminal-text {
color: #4fc3f7;
}
}
&.terminal-success {
.terminal-text {
color: #81c784;
font-weight: $font-weight-medium;
}
}
&.terminal-error {
.terminal-text {
color: #e57373;
font-weight: $font-weight-medium;
}
}
&.terminal-warning {
.terminal-text {
color: #ffb74d;
}
}
&.terminal-command {
.terminal-text {
color: #ba68c8;
font-weight: $font-weight-semibold;
}
}
&.terminal-output {
.terminal-text {
color: #d4d4d4;
opacity: 0.9;
}
}
}
.terminal-cursor {
display: inline-block;
color: #81c784;
margin-left: 4px;
animation: terminal-cursor-blink 1s step-end infinite;
}
@keyframes terminal-cursor-blink {
0%, 50% {
opacity: 1;
}
51%, 100% {
opacity: 0;
}
}
/* Responsive */
@media (max-width: 768px) {
.terminal-content {
font-size: 12px;
padding: $spacing-sm;
}
.terminal-line {
.terminal-timestamp {
display: none;
}
}
}

View File

@ -1,89 +0,0 @@
import React, { createContext, ReactNode, useContext, useEffect, useState } from 'react';
import { apiService } from '../services/api';
import type { LoginCredentials, User } from '../types';
interface AuthContextType {
user: User | null;
loading: boolean;
login: (credentials: LoginCredentials) => Promise<void>;
logout: () => Promise<void>;
isAuthenticated: boolean;
}
export const AuthContext = createContext<AuthContextType | undefined>(undefined);
interface AuthProviderProps {
children: ReactNode;
}
export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
const [user, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);
const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true';
useEffect(() => {
const checkAuth = async () => {
console.log('🔍 checkAuth running, isMockMode:', isMockMode);
try {
if (isMockMode) {
console.log('✅ Mock mode - setting mock user');
setUser({
id: 'mock-user-1',
username: 'developer',
email: 'dev@coopcloud.tech',
});
setLoading(false);
console.log('✅ Mock user set, loading set to false');
return;
}
const token = localStorage.getItem('auth_token');
if (token) {
const currentUser = await apiService.getCurrentUser();
setUser(currentUser);
}
} catch (error) {
console.error('Auth check failed:', error);
localStorage.removeItem('auth_token');
} finally {
setLoading(false);
}
};
checkAuth();
}, [isMockMode]);
const login = async (credentials: LoginCredentials) => {
try {
const response = await apiService.login(credentials);
setUser(response.user);
} catch (error) {
throw error;
}
};
const logout = async () => {
await apiService.logout();
setUser(null);
};
const value: AuthContextType = {
user,
loading,
login,
logout,
isAuthenticated: !!user,
};
console.log('📊 AuthContext state:', { user, loading, isAuthenticated: !!user });
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
};
export function useAuth() {
const context = useContext(AuthContext);
if (context === undefined) {
throw new Error('useAuth must be used within an AuthProvider');
}
return context;
}

View File

@ -1,12 +0,0 @@
import { useContext } from 'react';
import { AuthContext } from '../context/AuthContext';
export const useAuth = () => {
const context = useContext(AuthContext);
if (context === undefined) {
throw new Error('useAuth must be used within an AuthProvider');
}
return context;
};

387
src/routes/Apps/App.scss Normal file
View File

@ -0,0 +1,387 @@
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
.app-detail-page {
@extend .page-wrapper;
}
.app-detail-content {
@extend .page-content;
}
// App header section
.app-header {
@include card;
display: flex;
justify-content: space-between;
align-items: flex-start;
flex-wrap: wrap;
gap: $spacing-xl;
margin-bottom: $spacing-xl;
.app-title-section {
flex: 1;
min-width: 300px;
h1 {
margin: 0 0 $spacing-md 0;
font-size: $font-size-3xl;
color: $text-primary;
font-weight: $font-weight-bold;
}
.app-meta {
display: flex;
gap: $spacing-sm;
flex-wrap: wrap;
}
}
.app-actions {
display: flex;
gap: $spacing-md;
flex-wrap: wrap;
}
}
// Action buttons
.action-btn {
padding: $spacing-sm $spacing-lg;
border: 2px solid $border-color;
border-radius: $radius-md;
font-size: $font-size-sm;
font-weight: $font-weight-medium;
cursor: pointer;
transition: all $transition-base;
background: white;
color: $text-primary;
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
&:hover:not(:disabled) {
transform: translateY(-1px);
box-shadow: $shadow-md;
}
&.primary {
background: $primary;
color: white;
border-color: $primary;
&:hover:not(:disabled) {
background: $primary-light;
border-color: $primary-light;
}
}
&.secondary {
background: $bg-secondary;
color: $text-primary;
border-color: $border-color;
&:hover:not(:disabled) {
background: darken($bg-secondary, 5%);
}
}
&.danger {
background: $error;
color: white;
border-color: $error;
&:hover:not(:disabled) {
background: darken($error, 10%);
}
}
}
.back-button {
@extend .action-btn;
@extend .secondary;
}
// Content grid layout
.content-grid {
display: grid;
grid-template-columns: 2fr 1fr;
gap: $spacing-xl;
@media (max-width: 1024px) {
grid-template-columns: 1fr;
}
}
// Info cards
.info-card {
@include card;
margin-bottom: $spacing-xl;
&:last-child {
margin-bottom: 0;
}
h2 {
margin: 0 0 $spacing-lg 0;
font-size: $font-size-xl;
color: $text-primary;
font-weight: $font-weight-bold;
}
}
// Info grid
.info-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: $spacing-lg;
}
.info-item {
display: flex;
flex-direction: column;
gap: $spacing-xs;
label {
font-size: $font-size-xs;
color: $text-secondary;
font-weight: $font-weight-medium;
text-transform: uppercase;
letter-spacing: 0.5px;
}
span {
font-size: $font-size-base;
color: $text-primary;
}
.no-value {
color: $text-muted;
font-style: italic;
}
.chaos-active {
color: darken($info, 10%);
font-weight: $font-weight-medium;
}
}
.domain-link {
color: $primary;
text-decoration: none;
font-size: $font-size-base;
transition: color $transition-base;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
.server-link {
background: none;
border: none;
color: $primary;
cursor: pointer;
padding: 0;
font-size: $font-size-base;
text-align: left;
transition: color $transition-base;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
// Version information
.version-info {
display: flex;
flex-direction: column;
gap: $spacing-lg;
.version-current {
label {
display: block;
font-size: $font-size-xs;
color: $text-secondary;
font-weight: $font-weight-medium;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: $spacing-sm;
}
code {
display: inline-block;
background: $bg-secondary;
padding: $spacing-sm $spacing-md;
border-radius: $radius-sm;
font-size: $font-size-sm;
color: $text-primary;
font-family: monospace;
}
}
.version-upgrades {
label {
display: flex;
align-items: center;
gap: $spacing-sm;
font-size: $font-size-xs;
color: $text-secondary;
font-weight: $font-weight-medium;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: $spacing-md;
.upgrade-count {
background: $warning;
color: white;
padding: 2px 8px;
border-radius: $radius-full;
font-size: $font-size-xs;
font-weight: $font-weight-bold;
}
}
.upgrade-list {
display: flex;
flex-direction: column;
gap: $spacing-sm;
}
.upgrade-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: $spacing-md;
padding: $spacing-md;
background: $bg-secondary;
border-radius: $radius-md;
border: 2px solid transparent;
transition: border-color $transition-base;
&:hover {
border-color: $warning;
}
code {
flex: 1;
font-size: $font-size-sm;
color: $text-primary;
font-family: monospace;
}
.upgrade-btn {
padding: $spacing-xs $spacing-md;
background: $warning;
color: white;
border: none;
border-radius: $radius-sm;
font-size: $font-size-sm;
font-weight: $font-weight-medium;
cursor: pointer;
transition: all $transition-base;
&:hover:not(:disabled) {
background: darken($warning, 10%);
transform: translateY(-1px);
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
}
}
.version-latest {
padding: $spacing-md;
background: rgba($success, 0.1);
color: darken($success, 10%);
border-radius: $radius-md;
text-align: center;
font-size: $font-size-base;
font-weight: $font-weight-medium;
}
}
// Quick actions list
.action-list {
display: flex;
flex-direction: column;
gap: $spacing-sm;
.action-list-item {
display: flex;
align-items: center;
gap: $spacing-md;
padding: $spacing-md;
background: $bg-secondary;
border: 2px solid transparent;
border-radius: $radius-md;
cursor: pointer;
transition: all $transition-base;
font-size: $font-size-sm;
color: $text-primary;
text-align: left;
width: 100%;
&:hover:not(:disabled) {
background: white;
border-color: $primary;
transform: translateX(2px);
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
&.danger {
&:hover:not(:disabled) {
border-color: $error;
background: rgba($error, 0.05);
}
}
.action-text {
flex: 1;
font-weight: $font-weight-medium;
}
}
}
// Health status
.health-status {
display: flex;
flex-direction: column;
gap: $spacing-md;
.health-item {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: $spacing-md;
border-bottom: 1px solid $border-color;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
.health-label {
font-size: $font-size-sm;
color: $text-secondary;
}
.health-value {
font-size: $font-size-base;
font-weight: $font-weight-semibold;
color: $text-primary;
}
}
}

View File

@ -1,8 +1,10 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom'; import { useParams, useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header'; import { Header } from '../../components/Header/Header';
import { apiService } from '../../../services/api'; import { Terminal } from '../../components/Terminal/Terminal';
import type { AbraApp } from '../../../types'; import { apiService } from '../../services/api';
import type { AbraApp } from '../../types';
import type { LogEntry } from '../../services/mockApi';
import './App.scss'; import './App.scss';
export const AppDetail: React.FC = () => { export const AppDetail: React.FC = () => {
@ -12,8 +14,11 @@ export const AppDetail: React.FC = () => {
const [app, setApp] = useState<AbraApp | null>(null); const [app, setApp] = useState<AbraApp | null>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState(''); const [error, setError] = useState('');
const [isEditing, setIsEditing] = useState(false);
const [actionLoading, setActionLoading] = useState<string | null>(null); const [actionLoading, setActionLoading] = useState<string | null>(null);
// Terminal state
const [terminalLogs, setTerminalLogs] = useState<LogEntry[]>([]);
const [terminalActive, setTerminalActive] = useState(false);
const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true'; const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true';
@ -21,10 +26,9 @@ export const AppDetail: React.FC = () => {
const fetchApp = async () => { const fetchApp = async () => {
try { try {
if (isMockMode) { if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi'); const { mockApiService } = await import('../../services/mockApi');
const appsData = await mockApiService.getAppsGrouped(); const appsData = await mockApiService.getAppsGrouped();
// Find the specific app
const serverApps = appsData[server || '']; const serverApps = appsData[server || ''];
const foundApp = serverApps?.apps.find(a => a.appName === appName); const foundApp = serverApps?.apps.find(a => a.appName === appName);
@ -34,7 +38,6 @@ export const AppDetail: React.FC = () => {
setError('App not found'); setError('App not found');
} }
} else { } else {
// Real API call would be here
const appsData = await apiService.getAppsGrouped(); const appsData = await apiService.getAppsGrouped();
const serverApps = appsData[server || '']; const serverApps = appsData[server || ''];
const foundApp = serverApps?.apps.find(a => a.appName === appName); const foundApp = serverApps?.apps.find(a => a.appName === appName);
@ -55,30 +58,55 @@ export const AppDetail: React.FC = () => {
fetchApp(); fetchApp();
}, [server, appName, isMockMode]); }, [server, appName, isMockMode]);
const handleAction = async (action: string) => { const handleAction = async (action: string, version?: string) => {
if (!app) return; if (!app) return;
setActionLoading(action); setActionLoading(action);
setTerminalActive(true);
setTerminalLogs([]);
try { try {
switch (action) { if (isMockMode) {
case 'start': const { mockApiService } = await import('../../services/mockApi');
await apiService.startApp(app.appName);
break; const onLog = (log: LogEntry) => {
case 'stop': setTerminalLogs(prev => [...prev, log]);
await apiService.stopApp(app.appName); };
break;
case 'deploy': switch (action) {
await apiService.deployApp(app.appName); case 'deploy':
break; await mockApiService.deployApp(app.appName, onLog);
case 'upgrade': break;
// Upgrade logic would go here case 'stop':
console.log('Upgrade app'); await mockApiService.stopApp(app.appName, onLog);
break; break;
case 'upgrade':
if (version) {
await mockApiService.upgradeApp(app.appName, version, onLog);
}
break;
case 'remove':
await mockApiService.removeApp(app.appName, onLog);
break;
}
} else {
// Real API calls
switch (action) {
case 'stop':
await apiService.stopApp(app.appName);
break;
case 'deploy':
await apiService.deployApp(app.appName);
break;
}
} }
// Refresh app data after action
// In real implementation, you'd refetch the app
} catch (err) { } catch (err) {
console.error('Action failed:', err); console.error('Action failed:', err);
setTerminalLogs(prev => [...prev, {
type: 'error',
text: `❌ Error: ${err instanceof Error ? err.message : 'Action failed'}`,
timestamp: new Date()
}]);
} finally { } finally {
setActionLoading(null); setActionLoading(null);
} }
@ -130,35 +158,36 @@ export const AppDetail: React.FC = () => {
<span className="recipe-badge">{app.recipe}</span> <span className="recipe-badge">{app.recipe}</span>
<span className={`status-badge status-${app.status}`}>{app.status}</span> <span className={`status-badge status-${app.status}`}>{app.status}</span>
{app.chaos === 'true' && ( {app.chaos === 'true' && (
<span className="chaos-badge" title="Chaos mode enabled">Chaos</span> <span className="chaos-badge" title="Chaos mode enabled">🔬 Chaos</span>
)} )}
</div> </div>
</div> </div>
<div className="app-actions"> <div className="app-actions">
<button
className="action-btn secondary"
onClick={() => setIsEditing(!isEditing)}
>
{isEditing ? 'Cancel' : 'Edit'}
</button>
<button <button
className="action-btn danger" className="action-btn danger"
onClick={() => handleAction('stop')} onClick={() => handleAction('stop')}
disabled={actionLoading === 'stop'} disabled={!!actionLoading}
> >
{actionLoading === 'stop' ? 'Stopping...' : 'Stop'} {actionLoading === 'stop' ? 'Stopping...' : 'Stop'}
</button> </button>
<button <button
className="action-btn primary" className="action-btn primary"
onClick={() => handleAction('deploy')} onClick={() => handleAction('deploy')}
disabled={actionLoading === 'deploy'} disabled={!!actionLoading}
> >
{actionLoading === 'deploy' ? 'Deploying...' : 'Deploy'} {actionLoading === 'deploy' ? 'Deploying...' : 'Deploy'}
</button> </button>
</div> </div>
</div> </div>
{/* Terminal Component */}
<Terminal
logs={terminalLogs}
isActive={terminalActive}
onClose={() => setTerminalActive(false)}
/>
<div className="content-grid"> <div className="content-grid">
{/* Left Column - Main Info */} {/* Left Column - Main Info */}
<div className="main-column"> <div className="main-column">
@ -241,8 +270,8 @@ export const AppDetail: React.FC = () => {
<code>{version}</code> <code>{version}</code>
<button <button
className="upgrade-btn" className="upgrade-btn"
onClick={() => handleAction('upgrade')} onClick={() => handleAction('upgrade', version)}
disabled={actionLoading === 'upgrade'} disabled={!!actionLoading}
> >
{actionLoading === 'upgrade' ? 'Upgrading...' : 'Upgrade'} {actionLoading === 'upgrade' ? 'Upgrading...' : 'Upgrade'}
</button> </button>
@ -254,49 +283,46 @@ export const AppDetail: React.FC = () => {
{app.upgrade === 'latest' && ( {app.upgrade === 'latest' && (
<div className="version-latest"> <div className="version-latest">
Running latest version Running latest version
</div> </div>
)} )}
</div> </div>
</section> </section>
</div> </div>
{/* Right Column - Actions & Logs */} {/* Right Column - Actions & Stats */}
<div className="sidebar-column"> <div className="sidebar-column">
<section className="info-card"> <section className="info-card">
<h2>Quick Actions</h2> <h2>Quick Actions</h2>
<div className="action-list"> <div className="action-list">
<button <button
className="action-list-item" className="action-list-item"
onClick={() => handleAction('start')} onClick={() => handleAction('deploy')}
disabled={actionLoading === 'start'} disabled={!!actionLoading}
> >
<span className="action-text">Start Application</span> <span className="action-text">Deploy Application</span>
</button> </button>
<button <button
className="action-list-item" className="action-list-item"
onClick={() => handleAction('stop')} onClick={() => handleAction('stop')}
disabled={actionLoading === 'stop'} disabled={!!actionLoading}
> >
<span className="action-text">Stop Application</span> <span className="action-text">Stop Application</span>
</button> </button>
<button className="action-list-item"> <button
<span className="action-text">Restart Application</span> className="action-list-item danger"
</button> onClick={() => {
if (confirm(`Are you sure you want to remove ${app.appName}?`)) {
<button className="action-list-item"> handleAction('remove');
<span className="action-text">View Logs</span> }
</button> }}
disabled={!!actionLoading}
<button className="action-list-item"> >
<span className="action-text">Edit Configuration</span> <span className="action-text">Remove Application</span>
</button>
<button className="action-list-item danger">
<span className="action-text">Delete Application</span>
</button> </button>
</div> </div>
</section> </section>
@ -323,4 +349,4 @@ export const AppDetail: React.FC = () => {
</main> </main>
</div> </div>
); );
}; };

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *; @use '../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *; @use '../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *; @use '../../assets/scss/global' as *;
// Extend global page wrapper // Extend global page wrapper
.apps-page { .apps-page {

View File

@ -1,8 +1,8 @@
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header'; import { Header } from '../../components/Header/Header';
import { apiService } from '../../../services/api'; import { apiService } from '../../services/api';
import type { AbraApp, AppWithServer, ServerAppsResponse } from '../../../types'; import type { AbraApp, AppWithServer, ServerAppsResponse } from '../../types';
import './Apps.scss'; import './Apps.scss';
export const Apps: React.FC = () => { export const Apps: React.FC = () => {
@ -21,7 +21,7 @@ export const Apps: React.FC = () => {
const fetchData = async () => { const fetchData = async () => {
try { try {
if (isMockMode) { if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi'); const { mockApiService } = await import('../../services/mockApi');
const data = await mockApiService.getAppsGrouped(); const data = await mockApiService.getAppsGrouped();
setAppsData(data); setAppsData(data);
} else { } else {

View File

@ -1,463 +0,0 @@
@use '../../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *;
.app-detail-page {
min-height: 100vh;
background: #f5f5f5;
}
.app-detail-content {
max-width: 1400px;
margin: 0 auto;
padding: 24px;
.loading,
.error {
text-align: center;
padding: 60px 20px;
font-size: 16px;
color: #666;
}
.error {
color: #dc3545;
}
}
// Breadcrumb navigation
.breadcrumb {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 24px;
font-size: 14px;
.breadcrumb-link {
background: none;
border: none;
color: #0066cc;
cursor: pointer;
padding: 0;
font-size: 14px;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.breadcrumb-separator {
color: #999;
}
.breadcrumb-current {
color: #333;
font-weight: 500;
}
}
// App header section
.app-header {
background: white;
border-radius: 12px;
padding: 24px;
margin-bottom: 24px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: space-between;
align-items: flex-start;
flex-wrap: wrap;
gap: 20px;
.app-title-section {
flex: 1;
min-width: 300px;
h1 {
margin: 0 0 12px 0;
font-size: 28px;
color: #1a1a1a;
}
.app-meta {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
}
.app-actions {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
}
// Action buttons
.action-btn {
padding: 10px 20px;
border: none;
border-radius: 6px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
&.primary {
background: #0066cc;
color: white;
&:hover:not(:disabled) {
background: #0052a3;
}
}
&.secondary {
background: #f0f0f0;
color: #333;
&:hover:not(:disabled) {
background: #e0e0e0;
}
}
&.danger {
background: #dc3545;
color: white;
&:hover:not(:disabled) {
background: #c82333;
}
}
}
.back-button {
@extend .action-btn;
@extend .secondary;
}
// Badges
.recipe-badge {
display: inline-block;
padding: 4px 12px;
background: #e7f3ff;
color: #0066cc;
border-radius: 4px;
font-size: 13px;
font-weight: 500;
}
.status-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 4px;
font-size: 13px;
font-weight: 500;
&.status-deployed,
&.status-running {
background: #d4edda;
color: #155724;
}
&.status-stopped {
background: #f8d7da;
color: #721c24;
}
&.status-unknown {
background: #e2e3e5;
color: #383d41;
}
}
.chaos-badge {
display: inline-block;
padding: 4px 12px;
background: #fff3cd;
color: #856404;
border-radius: 4px;
font-size: 13px;
font-weight: 500;
}
// Content grid layout
.content-grid {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 24px;
@media (max-width: 1024px) {
grid-template-columns: 1fr;
}
}
// Info cards
.info-card {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
margin-bottom: 24px;
&:last-child {
margin-bottom: 0;
}
h2 {
margin: 0 0 20px 0;
font-size: 18px;
color: #1a1a1a;
font-weight: 600;
}
}
// Info grid
.info-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
}
.info-item {
display: flex;
flex-direction: column;
gap: 6px;
label {
font-size: 12px;
color: #666;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.5px;
}
span {
font-size: 14px;
color: #1a1a1a;
}
.no-value {
color: #999;
font-style: italic;
}
.chaos-active {
color: #856404;
font-weight: 500;
}
}
.domain-link {
color: $primary-dark;
text-decoration: none;
font-size: 14px;
&:hover {
text-decoration: underline;
}
}
.server-link {
background: none;
border: none;
color: #0066cc;
cursor: pointer;
padding: 0;
font-size: 14px;
text-align: left;
&:hover {
text-decoration: underline;
}
}
// Version information
.version-info {
display: flex;
flex-direction: column;
gap: 20px;
.version-current {
label {
display: block;
font-size: 12px;
color: #666;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 8px;
}
code {
display: inline-block;
background: #f5f5f5;
padding: 8px 12px;
border-radius: 4px;
font-size: 13px;
color: #1a1a1a;
}
}
.version-upgrades {
label {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
color: #666;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 12px;
.upgrade-count {
background: #ffc107;
color: #856404;
padding: 2px 8px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
}
}
.upgrade-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.upgrade-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px;
background: #f8f9fa;
border-radius: 6px;
border: 1px solid #e9ecef;
code {
flex: 1;
font-size: 13px;
color: #1a1a1a;
}
.upgrade-btn {
padding: 6px 16px;
background: #ffc107;
color: #856404;
border: none;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
&:hover:not(:disabled) {
background: #e0a800;
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
}
}
.version-latest {
padding: 12px;
background: #d4edda;
color: #155724;
border-radius: 6px;
text-align: center;
font-size: 14px;
font-weight: 500;
}
}
// Quick actions list
.action-list {
display: flex;
flex-direction: column;
gap: 8px;
.action-list-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
background: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s;
font-size: 14px;
color: #1a1a1a;
text-align: left;
width: 100%;
&:hover:not(:disabled) {
background: #e9ecef;
border-color: #dee2e6;
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
&.danger {
color: #dc3545;
&:hover:not(:disabled) {
background: #f8d7da;
border-color: #f5c6cb;
}
}
.action-icon {
font-size: 18px;
}
.action-text {
flex: 1;
}
}
}
// Health status
.health-status {
display: flex;
flex-direction: column;
gap: 16px;
.health-item {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16px;
border-bottom: 1px solid #e9ecef;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
.health-label {
font-size: 14px;
color: #666;
}
.health-value {
font-size: 16px;
font-weight: 600;
color: #1a1a1a;
}
}
}

View File

@ -1,8 +1,8 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Header } from '../../../components/Header/Header'; import { Header } from '../../components/Header/Header';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { apiService } from '../../../services/api'; import { apiService } from '../../services/api';
import type { AbraApp, AbraServer } from '../../../types'; import type { AbraApp, AbraServer } from '../../types';
import './_Dashboard.scss'; import './_Dashboard.scss';
export const Dashboard: React.FC = () => { export const Dashboard: React.FC = () => {
@ -19,7 +19,7 @@ export const Dashboard: React.FC = () => {
try { try {
if (isMockMode) { if (isMockMode) {
// Use mock API in development // Use mock API in development
const { mockApiService } = await import('../../../services/mockApi'); const { mockApiService } = await import('../../services/mockApi');
const [appsData, serversData] = await Promise.all([ const [appsData, serversData] = await Promise.all([
mockApiService.getAppsGrouped(), mockApiService.getAppsGrouped(),
mockApiService.getServers(), mockApiService.getServers(),

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *; @use '../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *; @use '../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *; @use '../../assets/scss/global' as *;
// Extend global page wrapper // Extend global page wrapper
.dashboard-page { .dashboard-page {

View File

@ -1,94 +0,0 @@
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
.login-container {
@include flex-center;
min-height: 100vh;
width: 100%;
// @include gradient-primary;
background-color: $primary-light;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.login-card {
@include card;
width: 100%;
max-width: 400px;
h1 {
margin: 0 0 $spacing-sm;
font-size: $font-size-3xl;
color: $text-primary;
text-align: center;
}
.login-subtitle {
text-align: center;
color: $text-secondary;
margin: 0 0 $spacing-2xl;
font-size: $font-size-sm;
}
}
.form-group {
margin-bottom: $spacing-lg;
label {
display: block;
margin-bottom: $spacing-sm;
color: $text-primary;
font-weight: $font-weight-medium;
font-size: $font-size-sm;
}
input {
width: 100%;
padding: $spacing-md;
border: 2px solid $border-color;
border-radius: $radius-md;
font-size: $font-size-base;
transition: border-color $transition-base;
box-sizing: border-box;
&:focus {
outline: none;
border-color: $primary;
}
&:disabled {
background-color: $bg-secondary;
cursor: not-allowed;
}
}
}
.error-message {
// background-color: rgba($error, 0.1);
// color: darken($error, 10%);
padding: $spacing-md;
border-radius: $radius-md;
margin-bottom: $spacing-md;
font-size: $font-size-sm;
// border-left: 4px solid $error;
}
.login-button {
@include button-base;
@include gradient-primary;
width: 100%;
color: white;
font-size: $font-size-base;
&:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba($primary, 0.4);
}
&:active:not(:disabled) {
transform: translateY(0);
}
}

View File

@ -1,72 +0,0 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '../../hooks/useAuth';
import './LoginForm.scss';
export const LoginForm: React.FC = () => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const { login } = useAuth();
const navigate = useNavigate();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError('');
setLoading(true);
try {
await login({ username, password });
navigate('/dashboard');
} catch (err) {
setError(err instanceof Error ? err.message : 'Login failed');
} finally {
setLoading(false);
}
};
return (
<div className="login-container">
<div className="login-card">
<h1>Coop Cloud</h1>
<p className="login-subtitle">Sign in to manage your applications</p>
<form onSubmit={handleSubmit}>
{error && <div className="error-message">{error}</div>}
<div className="form-group">
<label htmlFor="username">Username</label>
<input
id="username"
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
required
autoComplete="username"
disabled={loading}
/>
</div>
<div className="form-group">
<label htmlFor="password">Password</label>
<input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
autoComplete="current-password"
disabled={loading}
/>
</div>
<button type="submit" disabled={loading} className="login-button">
{loading ? 'Signing in...' : 'Sign in'}
</button>
</form>
</div>
</div>
);
};

View File

@ -1,68 +1,13 @@
@use '../../../assets/scss/variables' as *; @use '../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *; @use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
.server-detail-page { .server-detail-page {
min-height: 100vh; @extend .page-wrapper;
background-color: $bg-secondary;
} }
.server-detail-content { .server-detail-content {
max-width: 1600px; @extend .page-content;
margin: 0 auto;
padding: $spacing-2xl $spacing-xl;
@media (max-width: 768px) {
padding: $spacing-xl $spacing-md;
}
.loading,
.error {
text-align: center;
padding: $spacing-3xl;
font-size: $font-size-lg;
}
.loading {
color: $text-secondary;
}
.error {
color: $error;
}
}
// Breadcrumb navigation
.breadcrumb {
display: flex;
align-items: center;
gap: $spacing-sm;
margin-bottom: $spacing-xl;
font-size: $font-size-sm;
.breadcrumb-link {
background: none;
border: none;
color: $primary;
cursor: pointer;
padding: 0;
font-size: $font-size-sm;
text-decoration: none;
transition: color $transition-base;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
.breadcrumb-separator {
color: $text-muted;
}
.breadcrumb-current {
color: $text-primary;
font-weight: $font-weight-semibold;
}
} }
// Server header section // Server header section
@ -100,7 +45,7 @@
} }
} }
// Action buttons // Action buttons (shared with App view, could be moved to global)
.action-btn { .action-btn {
padding: $spacing-sm $spacing-lg; padding: $spacing-sm $spacing-lg;
border: 2px solid $border-color; border: 2px solid $border-color;
@ -159,7 +104,7 @@
@extend .secondary; @extend .secondary;
} }
// Badges // Badges - host badge is specific to server view
.host-badge { .host-badge {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@ -185,50 +130,6 @@
font-weight: $font-weight-medium; font-weight: $font-weight-medium;
} }
.recipe-badge {
display: inline-block;
padding: $spacing-xs $spacing-sm;
background: rgba($primary, 0.1);
color: $primary-light;
border-radius: $radius-sm;
font-size: $font-size-xs;
font-weight: $font-weight-medium;
}
.status-badge {
display: inline-block;
padding: $spacing-xs $spacing-sm;
border-radius: $radius-sm;
font-size: $font-size-xs;
font-weight: $font-weight-medium;
&.status-deployed,
&.status-running {
background: rgba($success, 0.1);
color: darken($success, 10%);
}
&.status-stopped {
background: rgba($error, 0.1);
color: darken($error, 10%);
}
&.status-unknown {
background: $bg-secondary;
color: $text-muted;
}
}
.chaos-badge {
display: inline-block;
padding: $spacing-xs $spacing-sm;
background: rgba($info, 0.1);
color: darken($info, 10%);
border-radius: $radius-sm;
font-size: $font-size-xs;
font-weight: $font-weight-medium;
}
// Content grid layout // Content grid layout
.content-grid { .content-grid {
display: grid; display: grid;
@ -405,18 +306,12 @@
} }
&.danger { &.danger {
color: $error;
&:hover:not(:disabled) { &:hover:not(:disabled) {
border-color: $error; border-color: $error;
background: rgba($error, 0.05); background: rgba($error, 0.05);
} }
} }
.action-icon {
font-size: $font-size-lg;
}
.action-text { .action-text {
flex: 1; flex: 1;
font-weight: $font-weight-medium; font-weight: $font-weight-medium;
@ -461,4 +356,4 @@
} }
} }
} }
} }

View File

@ -1,8 +1,10 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom'; import { useParams, useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header'; import { Header } from '../../components/Header/Header';
import { apiService } from '../../../services/api'; import { Terminal } from '../../components/Terminal/Terminal';
import type { AbraServer, ServerAppsResponse } from '../../../types'; import { apiService } from '../../services/api';
import type { AbraServer, ServerAppsResponse } from '../../types';
import type { LogEntry } from '../../services/mockApi';
import './Server.scss'; import './Server.scss';
interface ServerWithApps extends AbraServer { interface ServerWithApps extends AbraServer {
@ -22,6 +24,10 @@ export const Server: React.FC = () => {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState(''); const [error, setError] = useState('');
const [actionLoading, setActionLoading] = useState<string | null>(null); const [actionLoading, setActionLoading] = useState<string | null>(null);
// Terminal state
const [terminalLogs, setTerminalLogs] = useState<LogEntry[]>([]);
const [terminalActive, setTerminalActive] = useState(false);
const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true'; const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true';
@ -29,11 +35,10 @@ export const Server: React.FC = () => {
const fetchServer = async () => { const fetchServer = async () => {
try { try {
if (isMockMode) { if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi'); const { mockApiService } = await import('../../services/mockApi');
const appsData = await mockApiService.getAppsGrouped(); const appsData = await mockApiService.getAppsGrouped();
const serversData = await mockApiService.getServers(); const serversData = await mockApiService.getServers();
// Find the server
const foundServer = serversData.find(s => s.name === serverName); const foundServer = serversData.find(s => s.name === serverName);
const serverApps = appsData[serverName || '']; const serverApps = appsData[serverName || ''];
@ -51,7 +56,6 @@ export const Server: React.FC = () => {
setError('Server not found'); setError('Server not found');
} }
} else { } else {
// Real API call
const appsData = await apiService.getAppsGrouped(); const appsData = await apiService.getAppsGrouped();
const serversData = await apiService.getServers(); const serversData = await apiService.getServers();
@ -86,11 +90,39 @@ export const Server: React.FC = () => {
if (!server) return; if (!server) return;
setActionLoading(action); setActionLoading(action);
setTerminalActive(true);
setTerminalLogs([]);
try { try {
console.log(`Action: ${action} on server ${server.name}`); if (isMockMode) {
// Add actual server actions here const { mockApiService } = await import('../../services/mockApi');
const onLog = (log: LogEntry) => {
setTerminalLogs(prev => [...prev, log]);
};
switch (action) {
case 'refresh':
await mockApiService.refreshServer(server.name, onLog);
break;
case 'deploy-all':
await mockApiService.deployAllApps(server.name, server.appCount, onLog);
break;
case 'upgrade-all':
await mockApiService.upgradeAllApps(server.name, server.upgradeCount, onLog);
break;
}
} else {
// Real API calls
console.log(`Action: ${action} on server ${server.name}`);
}
} catch (err) { } catch (err) {
console.error('Action failed:', err); console.error('Action failed:', err);
setTerminalLogs(prev => [...prev, {
type: 'error',
text: `❌ Error: ${err instanceof Error ? err.message : 'Action failed'}`,
timestamp: new Date()
}]);
} finally { } finally {
setActionLoading(null); setActionLoading(null);
} }
@ -143,7 +175,7 @@ export const Server: React.FC = () => {
<span className="host-badge">{server.host}</span> <span className="host-badge">{server.host}</span>
{server.upgradeCount > 0 && ( {server.upgradeCount > 0 && (
<span className="upgrade-badge"> <span className="upgrade-badge">
{server.upgradeCount} upgrade{server.upgradeCount !== 1 ? 's' : ''} {server.upgradeCount} upgrade{server.upgradeCount !== 1 ? 's' : ''}
</span> </span>
)} )}
</div> </div>
@ -153,20 +185,27 @@ export const Server: React.FC = () => {
<button <button
className="action-btn secondary" className="action-btn secondary"
onClick={() => handleAction('refresh')} onClick={() => handleAction('refresh')}
disabled={actionLoading === 'refresh'} disabled={!!actionLoading}
> >
{actionLoading === 'refresh' ? 'Refreshing...' : 'Refresh'} {actionLoading === 'refresh' ? 'Refreshing...' : '🔄 Refresh'}
</button> </button>
<button <button
className="action-btn primary" className="action-btn primary"
onClick={() => handleAction('deploy-all')} onClick={() => handleAction('deploy-all')}
disabled={actionLoading === 'deploy-all'} disabled={!!actionLoading}
> >
{actionLoading === 'deploy-all' ? 'Deploying...' : 'Deploy All'} {actionLoading === 'deploy-all' ? 'Deploying...' : '🚀 Deploy All'}
</button> </button>
</div> </div>
</div> </div>
{/* Terminal Component */}
<Terminal
logs={terminalLogs}
isActive={terminalActive}
onClose={() => setTerminalActive(false)}
/>
<div className="content-grid"> <div className="content-grid">
{/* Left Column - Main Info */} {/* Left Column - Main Info */}
<div className="main-column"> <div className="main-column">
@ -241,10 +280,10 @@ export const Server: React.FC = () => {
{app.status} {app.status}
</span> </span>
{app.chaos === 'true' && ( {app.chaos === 'true' && (
<span className="chaos-badge" title="Chaos mode"></span> <span className="chaos-badge">🔬</span>
)} )}
{app.upgrade !== 'latest' && ( {app.upgrade !== 'latest' && (
<span className="upgrade-badge" title="Upgrade available"></span> <span className="upgrade-badge"></span>
)} )}
</div> </div>
</div> </div>
@ -278,7 +317,7 @@ export const Server: React.FC = () => {
<button <button
className="action-list-item" className="action-list-item"
onClick={() => handleAction('refresh')} onClick={() => handleAction('refresh')}
disabled={actionLoading === 'refresh'} disabled={!!actionLoading}
> >
<span className="action-text">Refresh Server Info</span> <span className="action-text">Refresh Server Info</span>
</button> </button>
@ -286,7 +325,7 @@ export const Server: React.FC = () => {
<button <button
className="action-list-item" className="action-list-item"
onClick={() => handleAction('deploy-all')} onClick={() => handleAction('deploy-all')}
disabled={actionLoading === 'deploy-all'} disabled={!!actionLoading}
> >
<span className="action-text">Deploy All Apps</span> <span className="action-text">Deploy All Apps</span>
</button> </button>
@ -294,25 +333,9 @@ export const Server: React.FC = () => {
<button <button
className="action-list-item" className="action-list-item"
onClick={() => handleAction('upgrade-all')} onClick={() => handleAction('upgrade-all')}
disabled={actionLoading === 'upgrade-all' || server.upgradeCount === 0} disabled={!!actionLoading || server.upgradeCount === 0}
> >
<span className="action-text">Upgrade All Apps</span> <span className="action-text">Upgrade All Apps</span>
</button>
<button className="action-list-item">
<span className="action-text">View Metrics</span>
</button>
<button className="action-list-item">
<span className="action-text">View Logs</span>
</button>
<button className="action-list-item">
<span className="action-text">Server Settings</span>
</button>
<button className="action-list-item danger">
<span className="action-text">Remove Server</span>
</button> </button>
</div> </div>
</section> </section>
@ -322,7 +345,7 @@ export const Server: React.FC = () => {
<div className="health-status"> <div className="health-status">
<div className="health-item"> <div className="health-item">
<span className="health-label">Status</span> <span className="health-label">Status</span>
<span className="health-value status-online">Online</span> <span className="health-value status-online">🟢 Online</span>
</div> </div>
<div className="health-item"> <div className="health-item">
<span className="health-label">CPU Usage</span> <span className="health-label">CPU Usage</span>
@ -347,4 +370,4 @@ export const Server: React.FC = () => {
</main> </main>
</div> </div>
); );
}; };

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *; @use '../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *; @use '../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *; @use '../../assets/scss/global' as *;
// Extend global page wrapper // Extend global page wrapper
.servers-page { .servers-page {

View File

@ -1,8 +1,8 @@
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header'; import { Header } from '../../components/Header/Header';
import { apiService } from '../../../services/api'; import { apiService } from '../../services/api';
import type { AbraServer, ServerAppsResponse } from '../../../types'; import type { AbraServer, ServerAppsResponse } from '../../types';
import './Servers.scss'; import './Servers.scss';
interface ServerWithStats extends AbraServer { interface ServerWithStats extends AbraServer {
@ -27,7 +27,7 @@ export const Servers: React.FC = () => {
const fetchData = async () => { const fetchData = async () => {
try { try {
if (isMockMode) { if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi'); const { mockApiService } = await import('../../services/mockApi');
const [serversData, appsData] = await Promise.all([ const [serversData, appsData] = await Promise.all([
mockApiService.getServers(), mockApiService.getServers(),
mockApiService.getAppsGrouped(), mockApiService.getAppsGrouped(),
@ -232,17 +232,13 @@ export const Servers: React.FC = () => {
</div> </div>
{server.upgradeCount > 0 && ( {server.upgradeCount > 0 && (
<div className="stat-row highlight"> <div className="stat-row highlight">
<span className="stat-label"> <span className="stat-label">Need Upgrade</span>
<span className="upgrade-icon"></span> Need Upgrade
</span>
<span className="stat-value">{server.upgradeCount}</span> <span className="stat-value">{server.upgradeCount}</span>
</div> </div>
)} )}
{server.chaosCount > 0 && ( {server.chaosCount > 0 && (
<div className="stat-row chaos-row"> <div className="stat-row chaos-row">
<span className="stat-label"> <span className="stat-label">Chaos Mode</span>
<span className="chaos-icon"></span> Chaos Mode
</span>
<span className="stat-value">{server.chaosCount}</span> <span className="stat-value">{server.chaosCount}</span>
</div> </div>
)} )}

View File

@ -1,15 +1,24 @@
import type { AbraApp, AbraServer, AuthResponse, LoginCredentials, User } from '../types'; import type { AbraServer, ServerAppsResponse } from '../types';
// Log entry type
export type LogEntry = {
type: 'info' | 'success' | 'error' | 'warning' | 'command' | 'output';
text: string;
timestamp: Date;
};
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api'; const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api';
// Helper to process log JSON from API response
const processLogResponse = (logData: any[]): LogEntry[] => {
return logData.map(log => ({
type: log.type,
text: log.text,
timestamp: new Date(log.timestamp || Date.now()),
}));
};
class ApiService { class ApiService {
private token: string | null = null;
constructor() {
// Load token from localStorage on initialization
this.token = localStorage.getItem('auth_token');
}
private async request<T>( private async request<T>(
endpoint: string, endpoint: string,
options: RequestInit = {} options: RequestInit = {}
@ -19,10 +28,6 @@ class ApiService {
...options.headers, ...options.headers,
}; };
if (this.token) {
headers['Authorization'] = `Bearer ${this.token}`;
}
const response = await fetch(`${API_BASE_URL}${endpoint}`, { const response = await fetch(`${API_BASE_URL}${endpoint}`, {
...options, ...options,
headers, headers,
@ -36,52 +41,94 @@ class ApiService {
return response.json(); return response.json();
} }
// Auth methods // Get all apps grouped by server
async login(credentials: LoginCredentials): Promise<AuthResponse> {
const response = await this.request<AuthResponse>('/auth/login', {
method: 'POST',
body: JSON.stringify(credentials),
});
this.token = response.token;
localStorage.setItem('auth_token', response.token);
return response;
}
async logout(): Promise<void> {
this.token = null;
localStorage.removeItem('auth_token');
}
async getCurrentUser(): Promise<User> {
return this.request<User>('/auth/me');
}
// Abra CLI wrapper methods
async getAppsGrouped(): Promise<ServerAppsResponse> { async getAppsGrouped(): Promise<ServerAppsResponse> {
return this.request<ServerAppsResponse>('/abra/apps'); return this.request<ServerAppsResponse>('/apps');
} }
// Get all servers
async getServers(): Promise<AbraServer[]> { async getServers(): Promise<AbraServer[]> {
return this.request<AbraServer[]>('/abra/servers'); return this.request<AbraServer[]>('/servers');
} }
async deployApp(appName: string): Promise<void> { // App actions with log streaming (websocket future)
return this.request(`/abra/apps/${appName}/deploy`, { async deployApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/apps/${appName}/deploy`, {
method: 'POST', method: 'POST',
}); });
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
} }
async stopApp(appName: string): Promise<void> { async undeployApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
return this.request(`/abra/apps/${appName}/stop`, { const response = await this.request<{ logs: any[] }>(`/apps/${appName}/undeploy`, {
method: 'POST', method: 'POST',
}); });
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
} }
async startApp(appName: string): Promise<void> { async upgradeApp(appName: string, version: string, onLog?: (log: LogEntry) => void): Promise<void> {
return this.request(`/abra/apps/${appName}/start`, { const response = await this.request<{ logs: any[] }>(`/apps/${appName}/upgrade`, {
method: 'POST',
body: JSON.stringify({ version }),
});
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
}
async removeApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/apps/${appName}/remove`, {
method: 'POST', method: 'POST',
}); });
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
}
// Server actions with log streaming
async refreshServer(serverName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/servers/${serverName}/refresh`, {
method: 'POST',
});
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
}
async deployAllApps(serverName: string, appCount: number, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/servers/${serverName}/deploy-all`, {
method: 'POST',
});
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
}
async upgradeAllApps(serverName: string, upgradeCount: number, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/servers/${serverName}/upgrade-all`, {
method: 'POST',
});
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
} }
} }

326
src/services/mock-logs.json Normal file
View File

@ -0,0 +1,326 @@
{
"deploy": {
"logs": [
{
"type": "info",
"text": "📦 Deploying {appName}..."
},
{
"type": "command",
"text": "$ abra app deploy {appName}"
},
{
"type": "info",
"text": "Checking server connection..."
},
{
"type": "success",
"text": "✓ Connected to server"
},
{
"type": "info",
"text": "Pulling latest images..."
},
{
"type": "output",
"text": "latest: Pulling from library/traefik"
},
{
"type": "output",
"text": "a1b2c3d4: Pull complete"
},
{
"type": "output",
"text": "e5f6g7h8: Pull complete"
},
{
"type": "success",
"text": "✓ Images pulled successfully"
},
{
"type": "info",
"text": "Creating containers..."
},
{
"type": "output",
"text": "Creating {appName}_app_1 ... done"
},
{
"type": "output",
"text": "Creating {appName}_db_1 ... done"
},
{
"type": "info",
"text": "Starting services..."
},
{
"type": "output",
"text": "Starting {appName}_app_1 ... done"
},
{
"type": "output",
"text": "Starting {appName}_db_1 ... done"
},
{
"type": "success",
"text": "✓ {appName} deployed successfully!"
}
]
},
"stop": {
"logs": [
{
"type": "info",
"text": "🛑 Stopping {appName}..."
},
{
"type": "command",
"text": "$ abra app stop {appName}"
},
{
"type": "output",
"text": "Stopping {appName}_app_1 ... done"
},
{
"type": "output",
"text": "Stopping {appName}_db_1 ... done"
},
{
"type": "success",
"text": "✓ {appName} stopped"
}
]
},
"start": {
"logs": [
{
"type": "info",
"text": "▶️ Starting {appName}..."
},
{
"type": "command",
"text": "$ abra app start {appName}"
},
{
"type": "output",
"text": "Starting {appName}_app_1 ... done"
},
{
"type": "output",
"text": "Starting {appName}_db_1 ... done"
},
{
"type": "success",
"text": "✓ {appName} started"
}
]
},
"upgrade": {
"logs": [
{
"type": "info",
"text": "⬆️ Upgrading {appName} to {version}..."
},
{
"type": "command",
"text": "$ abra app upgrade {appName}"
},
{
"type": "info",
"text": "Pulling new version..."
},
{
"type": "output",
"text": "{version}: Pulling from library/app"
},
{
"type": "output",
"text": "x9y8z7w6: Pull complete"
},
{
"type": "success",
"text": "✓ New version pulled"
},
{
"type": "info",
"text": "Stopping old containers..."
},
{
"type": "output",
"text": "Stopping {appName}_app_1 ... done"
},
{
"type": "info",
"text": "Starting new containers..."
},
{
"type": "output",
"text": "Starting {appName}_app_1 ... done"
},
{
"type": "success",
"text": "✓ {appName} upgraded to {version}"
}
]
},
"remove": {
"logs": [
{
"type": "warning",
"text": "⚠️ Removing {appName}..."
},
{
"type": "command",
"text": "$ abra app remove {appName}"
},
{
"type": "output",
"text": "Stopping {appName}_app_1 ... done"
},
{
"type": "output",
"text": "Stopping {appName}_db_1 ... done"
},
{
"type": "output",
"text": "Removing {appName}_app_1 ... done"
},
{
"type": "output",
"text": "Removing {appName}_db_1 ... done"
},
{
"type": "output",
"text": "Removing network {appName}_default"
},
{
"type": "success",
"text": "✓ {appName} removed"
}
]
},
"serverRefresh": {
"logs": [
{
"type": "info",
"text": "🔄 Refreshing server {serverName}..."
},
{
"type": "command",
"text": "$ abra server ls"
},
{
"type": "info",
"text": "Fetching server status..."
},
{
"type": "output",
"text": "Checking connection..."
},
{
"type": "success",
"text": "✓ Connected"
},
{
"type": "output",
"text": "Fetching app list..."
},
{
"type": "success",
"text": "✓ Found apps on {serverName}"
},
{
"type": "success",
"text": "✓ Server refreshed"
}
]
},
"deployAll": {
"logs": [
{
"type": "info",
"text": "📦 Deploying all apps on {serverName}..."
},
{
"type": "command",
"text": "$ abra app deploy --all --server {serverName}"
},
{
"type": "info",
"text": "Found {appCount} apps to deploy"
},
{
"type": "output",
"text": "Deploying apps in parallel..."
},
{
"type": "info",
"text": "[1/{appCount}] Deploying app_1..."
},
{
"type": "success",
"text": "✓ app_1 deployed"
},
{
"type": "info",
"text": "[2/{appCount}] Deploying app_2..."
},
{
"type": "success",
"text": "✓ app_2 deployed"
},
{
"type": "info",
"text": "[3/{appCount}] Deploying app_3..."
},
{
"type": "success",
"text": "✓ app_3 deployed"
},
{
"type": "success",
"text": "✓ All apps deployed on {serverName}"
}
]
},
"upgradeAll": {
"logs": [
{
"type": "info",
"text": "⬆️ Upgrading all apps on {serverName}..."
},
{
"type": "command",
"text": "$ abra app upgrade --all --server {serverName}"
},
{
"type": "info",
"text": "Found {upgradeCount} apps with available upgrades"
},
{
"type": "output",
"text": "Upgrading apps sequentially..."
},
{
"type": "info",
"text": "[1/{upgradeCount}] Upgrading app_1..."
},
{
"type": "success",
"text": "✓ app_1 upgraded"
},
{
"type": "info",
"text": "[2/{upgradeCount}] Upgrading app_2..."
},
{
"type": "success",
"text": "✓ app_2 upgraded"
},
{
"type": "success",
"text": "✓ All apps upgraded on {serverName}"
}
]
}
}

View File

@ -1,10 +1,67 @@
import type { AbraServer, ServerAppsResponse } from '../types'; import type { AbraServer, ServerAppsResponse } from '../types';
import appsData from './mock-apps.json'; import appsData from './mock-apps.json';
import serversData from './mock-servers.json'; import serversData from './mock-servers.json';
import logsData from './mock-logs.json';
// Log entry type
export type LogEntry = {
type: 'info' | 'success' | 'error' | 'warning' | 'command' | 'output';
text: string;
timestamp: Date;
};
// Type for the imported JSON structure
type LogTemplate = {
type: 'info' | 'success' | 'error' | 'warning' | 'command' | 'output';
text: string;
};
type LogsDataStructure = {
[key: string]: {
logs: LogTemplate[];
};
};
// Simulate API delay // Simulate API delay
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
// Helper to replace template variables like {appName}, {version}
const replaceVars = (text: string, vars: Record<string, string | number>): string => {
let result = text;
Object.entries(vars).forEach(([key, value]) => {
result = result.replace(new RegExp(`\\{${key}\\}`, 'g'), String(value));
});
return result;
};
// Helper to process log templates into LogEntry objects
const processLogs = (
action: string,
vars: Record<string, string | number>
): LogEntry[] => {
console.log('Processing logs for action:', action);
console.log('Loaded logsData:', logsData);
const typedLogsData = logsData as LogsDataStructure;
const actionData = typedLogsData[action];
if (!actionData || !actionData.logs) {
console.error(`No logs found for action: ${action}`);
return [];
}
console.log('Found logs:', actionData.logs);
const templates = actionData.logs;
return templates
.filter(template => template && template.type && template.text) // Filter out any undefined/malformed entries
.map(template => ({
type: template.type,
text: replaceVars(template.text, vars),
timestamp: new Date(),
}));
};
export const mockApiService = { export const mockApiService = {
async getAppsGrouped(): Promise<ServerAppsResponse> { async getAppsGrouped(): Promise<ServerAppsResponse> {
await delay(500); await delay(500);
@ -16,18 +73,66 @@ export const mockApiService = {
return serversData as AbraServer[]; return serversData as AbraServer[];
}, },
async deployApp(appName: string): Promise<void> { async deployApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
await delay(1000); const logs = processLogs('deploy', { appName });
console.log(`Mock: Deploying app ${appName}`);
for (const log of logs) {
await delay(200);
onLog?.(log);
}
}, },
async stopApp(appName: string): Promise<void> { async stopApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
await delay(500); const logs = processLogs('stop', { appName });
console.log(`Mock: Stopping app ${appName}`);
for (const log of logs) {
await delay(150);
onLog?.(log);
}
}, },
async startApp(appName: string): Promise<void> { async upgradeApp(appName: string, version: string, onLog?: (log: LogEntry) => void): Promise<void> {
await delay(500); const logs = processLogs('upgrade', { appName, version });
console.log(`Mock: Starting app ${appName}`);
for (const log of logs) {
await delay(200);
onLog?.(log);
}
},
async removeApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const logs = processLogs('remove', { appName });
for (const log of logs) {
await delay(180);
onLog?.(log);
}
},
async refreshServer(serverName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const logs = processLogs('serverRefresh', { serverName });
for (const log of logs) {
await delay(200);
onLog?.(log);
}
},
async deployAllApps(serverName: string, appCount: number, onLog?: (log: LogEntry) => void): Promise<void> {
const logs = processLogs('deployAll', { serverName, appCount });
for (const log of logs) {
await delay(250);
onLog?.(log);
}
},
async upgradeAllApps(serverName: string, upgradeCount: number, onLog?: (log: LogEntry) => void): Promise<void> {
const logs = processLogs('upgradeAll', { serverName, upgradeCount });
for (const log of logs) {
await delay(250);
onLog?.(log);
}
}, },
}; };

View File

@ -1,19 +1,3 @@
export interface User {
id: string;
username: string;
email: string;
}
export interface AuthResponse {
user: User;
token: string;
}
export interface LoginCredentials {
username: string;
password: string;
}
export interface ApiError { export interface ApiError {
message: string; message: string;
status: number; status: number;