21 Commits

Author SHA1 Message Date
46e812d925 remove comments 2026-05-16 13:43:04 -07:00
5c2ce8b385 remove filter clearing logic 2026-05-16 13:37:49 -07:00
b36a63d6f9 remove redundant app button 2026-05-16 13:37:01 -07:00
9313fbb6f0 make cards square for box shadow effect 2026-05-16 13:36:08 -07:00
1b5907be78 fix filter toggles, fix bad color declarations 2026-05-16 12:18:51 -07:00
e6f159bbea first big style pass, consolidate to mixins 2026-05-15 20:00:29 -07:00
b7e8bab6d1 Add card mixins for consistent styling across server and app components 2026-05-14 22:19:15 -07:00
08017ad6be swap skull for microscope 2026-04-24 15:55:04 -07:00
27bc8de54b remove silly emoji xd 2026-04-24 15:50:48 -07:00
5f5f8305ec Merge pull request 'smaller stat cards' (#7) from recipes into dev
Reviewed-on: BornDeleuze/coop-cloud-front#7
2026-04-24 22:44:44 +00:00
a2efaf279d smaller stat cards 2026-04-24 15:43:18 -07:00
df61028185 Merge pull request 'recipes' (#6) from recipes into dev
Reviewed-on: BornDeleuze/coop-cloud-front#6
2026-04-17 20:10:14 +00:00
f85b453b55 basic functionality working 2026-04-17 13:06:15 -07:00
21825ee009 add recipe from jjsfunhouse 2026-04-17 12:34:40 -07:00
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
34 changed files with 2712 additions and 852 deletions

1
.env
View File

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

View File

@ -1,5 +1,5 @@
# API base URL for the backend that wraps the abra CLI
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

View File

@ -1,14 +0,0 @@
[build]
command = "npm run build"
publish = "dist"
# Environment variables for build
[build.environment]
VITE_MOCK_AUTH = "true"
VITE_API_URL = "http://localhost:3000/api"
# Redirect all requests to index.html for client-side routing
[[redirects]]
from = "/*"
to = "/index.html"
status = 200

View File

@ -1,37 +1,28 @@
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { AuthProvider } from './context/AuthContext';
import { LoginForm } from './routes/Login/LoginForm';
import { Authenticated } from './components/Authenticated';
import { Dashboard } from './routes/Authenticated/Dashboard/Dashboard';
import { Apps } from './routes/Authenticated/Apps/Apps';
import { AppDetail } from './routes/Authenticated/Apps/App';
import { Servers } from './routes/Authenticated/Servers/Servers';
import { Server } from './routes/Authenticated/Servers/Server';
import { Dashboard } from './routes/Dashboard/Dashboard';
import { Apps } from './routes/Apps/Apps';
import { AppDetail } from './routes/Apps/App';
import { Servers } from './routes/Servers/Servers';
import { Server } from './routes/Servers/Server';
import { Recipes } from './routes/Recipes/Recipes';
function App() {
return (
<BrowserRouter>
<AuthProvider>
<Routes>
{/* Public routes */}
<Route path="/login" element={<LoginForm />} />
{/* Protected routes */}
<Route element={<Authenticated />}>
<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>
<Routes>
<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 path="/recipes" element={<Recipes />} />
{/* 404 catch-all */}
<Route path="*" element={<Navigate to="/dashboard" replace />} />
</Routes>
</AuthProvider>
</BrowserRouter>
);
}
export default App;
export default App;

View File

@ -234,6 +234,15 @@ body {
color: $text-secondary;
}
// Ensure stat-chip shows primary-dark outline on hover and when active
.stat-chip {
&:hover:not(:disabled),
&.active {
border-color: $primary-dark;
box-shadow: 0 0 0 3px rgba($primary-dark, 0.08);
}
}
// Results count
.results-count {
text-align: center;

View File

@ -23,11 +23,98 @@
// Card style
@mixin card {
background: $bg-primary;
border-radius: $radius-lg;
box-shadow: $shadow-md;
padding: $spacing-xl;
}
// Ensure cards occupy consistent vertical space and can stretch horizontally
@mixin card-dimensions($min-width: 320px, $min-height: 180px) {
min-width: $min-width;
min-height: $min-height;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
/// Standard vertical stack for card-style list rows (dashboard recent apps, server detail apps, etc.)
@mixin card-list-vertical($gap: $spacing-md) {
display: flex;
flex-direction: column;
gap: $gap;
}
/// Hover lift used by dashboard list cards, server grid cards, and similar surfaces
@mixin card-hover-lift($translate-y: -2px, $hover-shadow: $shadow-lg) {
transition: transform $transition-base, box-shadow $transition-base;
&:hover {
transform: translateY($translate-y);
box-shadow: $hover-shadow;
}
}
/// Card shell with horizontal scroll (e.g. data tables)
@mixin scrollable-card {
@include card;
overflow-x: auto;
}
/// Header block inside a card: title area with a bottom rule (server cards, etc.)
@mixin card-header-rule {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: $spacing-lg;
padding-bottom: $spacing-md;
border-bottom: 2px solid $bg-secondary;
}
/// Primary title + muted monospace/meta line (server cards, resource headers)
@mixin card-title-stack(
$title-size: $font-size-xl,
$title-weight: $font-weight-bold,
$meta-size: $font-size-sm
) {
h3 {
margin: 0 0 $spacing-xs;
font-size: $title-size;
color: $text-primary;
font-weight: $title-weight;
}
.server-host {
font-size: $meta-size;
color: $text-muted;
font-family: monospace;
}
}
/// Label + value row inside a card body (server stats, etc.)
@mixin card-stat-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: $spacing-sm 0;
border-bottom: 1px solid $bg-secondary;
&:last-child {
border-bottom: none;
}
}
/// Full-width edge bleed for highlighted rows inside padded cards (matches card horizontal padding)
@mixin card-row-highlight-bleed($clear-bottom-border: true) {
padding: $spacing-sm $spacing-md;
margin: $spacing-sm (-$spacing-xl);
padding-left: calc($spacing-xl + $spacing-md);
padding-right: calc($spacing-xl + $spacing-md);
@if $clear-bottom-border {
border-bottom: none;
}
}
// Button base
@mixin button-base {
padding: $spacing-sm $spacing-lg;
@ -63,4 +150,63 @@
font-weight: $font-weight-semibold;
background-color: rgba($color, 0.1);
// color: darken($color, 20%);
}
// Compact chip used for stat chips and small interactive chips
@mixin chip(
$bg: white,
$border-color: $border-color,
$radius: $radius-md,
$padding: $spacing-md $spacing-lg,
$gap: $spacing-md,
$hover-translate: -2px,
$hover-shadow: $shadow-sm,
$font-size: $font-size-base
) {
display: flex;
align-items: center;
gap: $gap;
padding: $padding;
background: $bg;
border: 2px solid $border-color;
border-radius: $radius;
cursor: pointer;
transition: all $transition-base;
font-size: $font-size;
&:hover:not(:disabled) {
border-color: $primary;
transform: translateY($hover-translate);
box-shadow: $hover-shadow;
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
// Reusable action button styles; accepts border width and radius
@mixin action-btn($border-width: 1px, $radius: $radius-sm, $padding: $spacing-xs $spacing-md, $font-size: $font-size-sm) {
background: none;
border: $border-width solid $border-color;
padding: $padding;
border-radius: $radius;
cursor: pointer;
font-size: $font-size;
color: $text-primary;
font-weight: $font-weight-medium;
transition: all $transition-base;
&:hover {
background-color: rgba($primary, 0.05);
color: $text-primary;
transform: translateY(-1px);
border-color: $primary;
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}

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,6 +1,5 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '../../hooks/useAuth';
import './_Header.scss';
import logo from '../../assets/coopcloud_logo_grey.svg';
@ -10,13 +9,7 @@ interface HeaderProps {
}
export const Header: React.FC<HeaderProps> = ({ children }) => {
const { user, logout } = useAuth();
const navigate = useNavigate();
const handleLogout = async () => {
await logout();
navigate('/login');
};
return(
<header className="layout-header">
<div className="header-content">
@ -34,13 +27,6 @@ return(
Servers
</button>
</nav>
<div className="user-menu">
<span className="username">{user?.username}</span>
<button onClick={handleLogout} className="logout-button">
Logout
</button>
</div>
</div>
</header>
)}

View File

@ -78,50 +78,4 @@
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

@ -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;
};

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *;
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
.app-detail-page {
@extend .page-wrapper;
@ -47,25 +47,7 @@
// 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;
}
@include action-btn(2px, $radius-md, $spacing-sm $spacing-lg, $font-size-sm);
&.primary {
background: $primary;
@ -137,39 +119,39 @@
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;
.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;
color: $primary-dark;
text-decoration: none;
font-size: $font-size-base;
transition: color $transition-base;
@ -183,7 +165,7 @@
.server-link {
background: none;
border: none;
color: $primary;
color: $primary-dark;
cursor: pointer;
padding: 0;
font-size: $font-size-base;

View File

@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header';
import { Terminal } from '../../../components/Terminal/Terminal';
import { apiService } from '../../../services/api';
import type { AbraApp } from '../../../types';
import type { LogEntry } from '../../../services/mockApi';
import { Header } from '../../components/Header/Header';
import { Terminal } from '../../components/Terminal/Terminal';
import { apiService } from '../../services/api';
import type { AbraApp } from '../../types';
import type { LogEntry } from '../../services/mockApi';
import './App.scss';
export const AppDetail: React.FC = () => {
@ -26,7 +26,7 @@ export const AppDetail: React.FC = () => {
const fetchApp = async () => {
try {
if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi');
const { mockApiService } = await import('../../services/mockApi');
const appsData = await mockApiService.getAppsGrouped();
const serverApps = appsData[server || ''];
@ -67,22 +67,19 @@ export const AppDetail: React.FC = () => {
try {
if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi');
const { mockApiService } = await import('../../services/mockApi');
const onLog = (log: LogEntry) => {
setTerminalLogs(prev => [...prev, log]);
};
switch (action) {
case 'start':
await mockApiService.startApp(app.appName, onLog);
case 'deploy':
await mockApiService.deployApp(app.appName, onLog);
break;
case 'stop':
await mockApiService.stopApp(app.appName, onLog);
break;
case 'deploy':
await mockApiService.deployApp(app.appName, onLog);
break;
case 'upgrade':
if (version) {
await mockApiService.upgradeApp(app.appName, version, onLog);
@ -95,9 +92,6 @@ export const AppDetail: React.FC = () => {
} else {
// Real API calls
switch (action) {
case 'start':
await apiService.startApp(app.appName);
break;
case 'stop':
await apiService.stopApp(app.appName);
break;
@ -164,7 +158,7 @@ export const AppDetail: React.FC = () => {
<span className="recipe-badge">{app.recipe}</span>
<span className={`status-badge status-${app.status}`}>{app.status}</span>
{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>
@ -242,7 +236,7 @@ export const AppDetail: React.FC = () => {
<div className="info-item">
<label>Chaos Mode</label>
<span className={app.chaos === 'true' ? 'chaos-active' : ''}>
{app.chaos === 'true' ? '🔬 Enabled' : 'Disabled'}
{app.chaos === 'true' ? '☠️ Enabled' : 'Disabled'}
</span>
</div>
</div>
@ -302,12 +296,13 @@ export const AppDetail: React.FC = () => {
<h2>Quick Actions</h2>
<div className="action-list">
<button
className="action-list-item"
onClick={() => handleAction('start')}
onClick={() => handleAction('deploy')}
disabled={!!actionLoading}
>
<span className="action-text"> Start Application</span>
<span className="action-text">Deploy Application</span>
</button>
<button
@ -315,15 +310,7 @@ export const AppDetail: React.FC = () => {
onClick={() => handleAction('stop')}
disabled={!!actionLoading}
>
<span className="action-text"> Stop Application</span>
</button>
<button
className="action-list-item"
onClick={() => handleAction('deploy')}
disabled={!!actionLoading}
>
<span className="action-text">🚀 Deploy Application</span>
<span className="action-text">Stop Application</span>
</button>
<button
@ -335,7 +322,7 @@ export const AppDetail: React.FC = () => {
}}
disabled={!!actionLoading}
>
<span className="action-text">🗑 Remove Application</span>
<span className="action-text">Remove Application</span>
</button>
</div>
</section>

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *;
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
// Extend global page wrapper
.apps-page {
@ -11,10 +11,44 @@
@extend .page-content;
}
// Compact stats row
.stats-row {
display: flex;
align-items: center;
gap: $spacing-md;
margin-bottom: $spacing-xl;
flex-wrap: wrap;
}
.stat-chip {
@include chip();
&.active {
border-color: $primary-dark;
background: $bg-primary;
box-shadow: 0 0 0 3px rgba($primary-dark, 0.08);
}
.stat-label {
color: $text-secondary;
font-size: $font-size-sm;
font-weight: $font-weight-medium;
}
.stat-value {
color: $text-primary;
font-size: $font-size-xl;
font-weight: $font-weight-bold;
min-width: 24px;
text-align: center;
}
}
/* reset-filters-btn removed — outline on stat-chip indicates active filters */
// Apps table specific styles
.apps-table-container {
@include card;
overflow-x: auto;
@include scrollable-card;
margin-bottom: $spacing-lg;
}
@ -71,19 +105,19 @@
font-weight: $font-weight-medium;
color: $text-primary;
}
}
.domain-link {
color: $primary;
text-decoration: none;
transition: color $transition-base;
&:hover {
color: $primary-light;
text-decoration: underline;
.domain-link {
color: $primary-dark;
text-decoration: none;
transition: color $transition-base;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
}
.no-domain {
color: $text-muted;
font-style: italic;
@ -112,23 +146,22 @@
gap: $spacing-sm;
.action-btn {
background: none;
border: 1px solid $border-color;
padding: $spacing-xs $spacing-sm;
border-radius: $radius-sm;
cursor: pointer;
font-size: $font-size-base;
color: $text-primary;
transition: all $transition-base;
@include action-btn(1px, $radius-sm, $spacing-xs $spacing-md, $font-size-sm);
&:hover {
background-color: $bg-tertiary;
transform: scale(1.1);
background-color: $primary;
color: white;
border-color: $primary;
}
&.upgrade {
border-color: $warning;
color: $warning;
&:hover {
background-color: $warning;
color: white;
}
}
}
}
}

View File

@ -1,8 +1,13 @@
// TODOS:
// make the two filters non-exlusive
import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header';
import { apiService } from '../../../services/api';
import type { AbraApp, AppWithServer, ServerAppsResponse } from '../../../types';
import { Header } from '../../components/Header/Header';
import { apiService } from '../../services/api';
import type { AbraApp, AppWithServer, ServerAppsResponse } from '../../types';
import './Apps.scss';
export const Apps: React.FC = () => {
@ -12,16 +17,16 @@ export const Apps: React.FC = () => {
const [error, setError] = useState('');
const [searchTerm, setSearchTerm] = useState('');
const [filterServer, setFilterServer] = useState<string>('all');
const [filterStatus, setFilterStatus] = useState<string>('all');
const [showUpgradesOnly, setShowUpgradesOnly] = useState(false);
const [showChaosOnly, setShowChaosOnly] = useState(false);
const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true';
useEffect(() => {
const fetchData = async () => {
try {
if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi');
const { mockApiService } = await import('../../services/mockApi');
const data = await mockApiService.getAppsGrouped();
setAppsData(data);
} else {
@ -59,7 +64,7 @@ export const Apps: React.FC = () => {
return Object.keys(appsData);
}, [appsData]);
// Filter apps
// Filter apps (additive filters: upgrades AND chaos can be applied together)
const filteredApps = useMemo(() => {
return allApps.filter(app => {
const matchesSearch =
@ -68,14 +73,12 @@ export const Apps: React.FC = () => {
(app.domain || '').toLowerCase().includes(searchTerm.toLowerCase());
const matchesServer = filterServer === 'all' || app.server === filterServer;
const matchesChaos = filterStatus === 'all' ||
(filterStatus === 'chaos' && app.chaos === 'true') ||
(filterStatus === 'stable' && app.chaos === 'false');
const matchesChaos = !showChaosOnly || app.chaos === 'true';
const matchesUpgrade = !showUpgradesOnly || app.upgrade !== 'latest';
return matchesSearch && matchesServer && matchesChaos && matchesUpgrade;
});
}, [allApps, searchTerm, filterServer, filterStatus, showUpgradesOnly]);
}, [allApps, searchTerm, filterServer, showUpgradesOnly, showChaosOnly]);
const stats = useMemo(() => {
const total = allApps.length;
@ -86,6 +89,9 @@ export const Apps: React.FC = () => {
return { total, needsUpgrade, chaosApps, totalServers };
}, [allApps, servers]);
const toggleUpgrades = () => setShowUpgradesOnly(prev => !prev);
const toggleChaos = () => setShowChaosOnly(prev => !prev);
if (loading) {
return (
<div className="apps-page">
@ -117,32 +123,37 @@ export const Apps: React.FC = () => {
<p className="subtitle">{stats.total} apps across {stats.totalServers} servers</p>
</div>
{/* Stats Overview */}
<div className="stats-grid">
<div className="stat-card">
<div className="stat-info">
<p className="stat-number">{stats.total}</p>
<p className="stat-label">Total Apps</p>
</div>
</div>
<div className="stat-card upgrade">
<div className="stat-info">
<p className="stat-number">{stats.needsUpgrade}</p>
<p className="stat-label">Upgrades Available</p>
</div>
</div>
<div className="stat-card chaos">
<div className="stat-info">
<p className="stat-number">{stats.chaosApps}</p>
<p className="stat-label">Chaos Mode</p>
</div>
</div>
<div className="stat-card">
<div className="stat-info">
<p className="stat-number">{stats.totalServers}</p>
<p className="stat-label">Servers</p>
</div>
</div>
{/* Compact Stats Overview */}
<div className="stats-row">
<button
className="stat-chip"
onClick={() => navigate('/servers')}
title="View servers"
>
<span className="stat-label">Servers</span>
<span className="stat-value">{stats.totalServers}</span>
</button>
<button
className={`stat-chip ${showUpgradesOnly ? 'active' : ''}`}
onClick={toggleUpgrades}
title="Click to toggle apps with upgrades available"
disabled={stats.needsUpgrade === 0}
>
<span className="stat-label">Upgrades</span>
<span className="stat-value">{stats.needsUpgrade}</span>
</button>
<button
className={`stat-chip ${showChaosOnly ? 'active' : ''}`}
onClick={toggleChaos}
title="Click to toggle chaos mode apps"
disabled={stats.chaosApps === 0}
>
<span className="stat-label">Chaos</span>
<span className="stat-value">{stats.chaosApps}</span>
</button>
</div>
{/* Filters */}
@ -161,21 +172,6 @@ export const Apps: React.FC = () => {
<option key={server} value={server}>{server}</option>
))}
</select>
<select value={filterStatus} onChange={(e) => setFilterStatus(e.target.value)}>
<option value="all">All Status</option>
<option value="stable">Stable</option>
<option value="chaos">Chaos Mode</option>
</select>
<label className="checkbox-filter">
<input
type="checkbox"
checked={showUpgradesOnly}
onChange={(e) => setShowUpgradesOnly(e.target.checked)}
/>
<span>Show only apps with upgrades</span>
</label>
</div>
{/* Apps Table */}

View File

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

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *;
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
// Extend global page wrapper
.dashboard-page {
@ -23,29 +23,21 @@
}
.apps-list {
display: flex;
flex-direction: column;
gap: $spacing-md;
@include card-list-vertical;
}
.app-item {
@include card;
@include card-hover-lift(-2px, $shadow-lg);
display: flex;
justify-content: space-between;
align-items: center;
transition: transform $transition-base, box-shadow $transition-base;
cursor: pointer;
&:hover {
transform: translateY(-2px);
box-shadow: $shadow-lg;
}
.app-info {
flex: 1;
h4 {
margin: 0 0 $spacing-xs;
font-size: $font-size-lg;
color: $text-primary;
font-weight: $font-weight-semibold;

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

View File

View File

View File

@ -0,0 +1,112 @@
import { useState, useEffect } from "react";
import { apiService } from '../../services/api';
import type { AbraServer } from '../../types';
function RecipeForm({ recipe, onClose }) {
const [loading, setLoading] = useState(true);
const [servers, setServers] = useState<AbraServer[]>([]);
const [selectedServer, setSelectedServer] = useState(""); // ❌ only one value
const [chaos, setChaos] = useState(false);
const [secrets, setSecrets] = useState(false);
const [error, setError] = useState('');
useEffect(() => {
const fetchData = async () => {
try {
const [serversData] = await Promise.all([
apiService.getServers(),
]);
setServers(serversData);
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to load servers');
} finally {
setLoading(false);
}
};
fetchData();
});
const [formData, setFormData] = useState({
domain: "",
chaos: false,
secrets: true,
});
const handleChange = (e) => {
setFormData({
...formData,
[e.target.name]: e.target.value,
});
};
const handleSubmit = (e) => {
e.preventDefault();
console.log("Submitting:", formData);
onClose();
};
return (
<form onSubmit={handleSubmit}>
<h2>{recipe.name}</h2>
{ loading ? (<p> Loading servers...</p>
) : (
<div>
<label>
Choose a server to deploy to:
<select
value={selectedServer}
onChange={(e) => setSelectedServer(e.target.value)}
>
<option value="">None</option>
{servers.map((server) => (
<option key={server.name} value={server.name}>
{server.name}
</option>
))}
</select>
</label>
</div>
)}
<div>
<label>
Domain:
<input
name="Domain"
value={formData.name}
onChange={handleChange}
/>
</label>
</div>
<div>
<label>
Chaos Mode Enabled:
<input
type="checkbox"
name="chaos"
onChange={handleChange}
/>
</label>
</div>
<div>
<label>
Autogenerate Secrets:
<input
type="checkbox"
name="secrets"
onChange={handleChange}
/>
</label>
</div>
<button type="submit">Submit</button>
<button type="button" onClick={onClose}>Cancel</button>
</form>
);
}
export default RecipeForm;

View File

@ -0,0 +1,164 @@
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
// Extend global page wrapper
.recipes-page {
@extend .page-wrapper;
}
.recipes-content {
@extend .page-content;
}
// Servers grid
.recipes-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: $spacing-xl;
margin-bottom: $spacing-xl;
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
}
// Server card
.recipe-card {
@include card;
@include card-dimensions(320px, 180px);
display: grid;
grid-template-rows: 1fr 2fr auto 0.9fr;
transition: transform $transition-base, box-shadow $transition-base;
position: relative;
overflow: hidden;
&:hover {
transform: translateY(-4px);
box-shadow: $shadow-xl;
}
.recipe-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: $spacing-lg;
padding-bottom: $spacing-md;
border-bottom: 2px solid $bg-secondary;
.recipe-title {
h3 {
margin: 0 0 $spacing-xs;
font-size: $font-size-xl;
color: $text-primary;
font-weight: $font-weight-bold;
}
.recipe-host {
font-size: $font-size-sm;
color: $text-muted;
font-family: monospace;
}
}
img {
width: clamp(20px, 3vw, 32px);
height: clamp(20px, 3vw, 32px);
object-fit: contain;
}
}
.card-tags {
display: flex;
gap: 6px;
margin-top: $spacing-sm;
height: $spacing-md;
flex-wrap: wrap;
}
.tag-category {
font-size: 12px;
padding: 2px 8px;
border-radius: 5px;
color: rgb(255, 255, 255);
font-weight: 700;
background-color: rgb(111, 128, 255);
}
.tag-feature {
font-size: 12px;
padding: 2px 8px;
border-radius: 5px;
color: rgb(255, 255, 255);
font-weight: 700;
background-color: rgb(22, 180, 22);
}
.recipe-stats {
flex-grow: 1;
flex: 1;
margin-bottom: $spacing-lg;
.stat-row {
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
}
.recipe-actions {
display: flex;
gap: $spacing-sm;
.action-btn {
flex: 1;
@include action-btn(2px, $radius-md, $spacing-sm $spacing-md, $font-size-sm);
&.primary {
background-color: $primary;
color: white;
border-color: $primary;
&:hover {
background-color: $primary-light;
border-color: $primary-light;
}
}
}
}
.recipe-alert {
background-color: rgba($warning, 0.1);
border-left: 4px solid $warning;
padding: $spacing-sm $spacing-md;
margin: 0 (-$spacing-xl) (-$spacing-xl);
display: flex;
align-items: center;
gap: $spacing-sm;
.alert-icon {
font-size: $font-size-lg;
color: $warning;
}
.alert-text {
font-size: $font-size-sm;
color: $text-primary;
font-weight: $font-weight-medium;
}
}
}
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
display: flex;
justify-content: center;
align-items: center;
}
.modal {
background: white;
padding: 24px;
border-radius: 8px;
width: min(90%, 500px);
}

View File

@ -0,0 +1,192 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Header } from '../../components/Header/Header';
import { apiService } from '../../services/api';
import type { AbraApp, AppWithServer, AbraRecipe } from '../../types';
import RecipeForm from './RecipeForm.tsx'
import './Recipes.scss';
export const Recipes: React.FC = () => {
const navigate = useNavigate();
const [recipesData, setRecipesData] = useState<AbraRecipe[] | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState('');
const [searchTerm, setSearchTerm] = useState('');
const [filterServer, setFilterServer] = useState<string>('all');
const [filterStatus, setFilterStatus] = useState<string>('all');
const [selectedRecipe, setSelectedRecipe] = useState(null);
const [showForm, setShowForm] = useState(false);
const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true';
useEffect(() => {
const fetchData = async () => {
try {
if (isMockMode) {
const { mockApiService } = await import('../../services/mockApi');
const data = await mockApiService.getRecipes();
console.log(data)
setRecipesData(data);
} else {
const data = await apiService.getRecipes();
setRecipesData(data);
}
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to load apps');
} finally {
setLoading(false);
}
};
fetchData();
}, [isMockMode]);
// Flatten and enrich apps data
const allRecipes: AbraRecipe[] = useMemo(() => {
if (!recipesData) return [];
return recipesData;
}, [recipesData]);
// Filter apps
const filteredRecipes = useMemo(() => {
return allRecipes.filter(recipe => {
const matchesSearch =
recipe.name.toLowerCase().includes(searchTerm.toLowerCase());
return matchesSearch;
});
}, [allRecipes, searchTerm, filterServer, filterStatus]);
const stats = useMemo(() => {
const total = allRecipes.length;
return { total };
}, [allRecipes]);
if (loading) {
return (
<div className="apps-page">
<Header />
<main className="recipes-content">
<div className="loading">Loading applications...</div>
</main>
</div>
);
}
if (error) {
return (
<div className="recipes-page">
<Header />
<main className="recipes-content">
<div className="error">Error: {error}</div>
</main>
</div>
);
}
return (
<div className="recipes-page">
<Header />
<main className="recipes-content">
<div className="page-header">
<h1>Applications</h1>
<p className="subtitle">{stats.total} recipes</p>
</div>
{/* Stats Overview */}
<div className="stats-grid">
<div className="stat-card">
<div className="stat-info">
<p className="stat-number">{stats.total}</p>
<p className="stat-label">Total Recipes</p>
</div>
</div>
</div>
{/* Filters */}
<div className="filters">
<input
type="text"
placeholder="Search apps by name, recipe, or domain..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="search-input"
/>
<select value={filterStatus} onChange={(e) => setFilterStatus(e.target.value)}>
<option value="all">All Status</option>
<option value="stable">Stable</option>
<option value="chaos">Chaos Mode</option>
</select>
</div>
{/* Server Cards */}
<div className="recipes-grid">
{filteredRecipes.length === 0 ? (
<div className="no-results">No recipes found matching your search</div>
) : (
filteredRecipes.map((recipe) => (
<div
key={recipe.name}
className="recipe-card"
style={{ cursor: 'pointer' }}
>
<div className="recipe-header">
<div className="recipe-title">
<h3>{recipe.name}</h3>
</div>
<div>
{recipe.icon.length > 0 ? <img src={`${recipe.icon}`} /> : null }
</div>
</div>
<div className="recipe-stats">
<div className="stat-row">
<span className="stat-value">{recipe.description}</span>
</div>
</div>
<div className="recipe-actions">
<button
className="action-btn"
onClick={(e) => {
e.stopPropagation();
console.log('clicked');
setSelectedRecipe(recipe);
console.log('selectedRecipe:', selectedRecipe);
}}
>
Add Recipe
</button>
</div>
<div className="card-tags">
{recipe.features.backups.toLowerCase().includes("yes") ? <span className="tag-feature"> Backups </span> : null}
{recipe.features.healthcheck.toLowerCase().includes("yes") ? <span className="tag-feature"> Healthcheck </span> : null}
{recipe.category.length > 0 ? <span className="tag-category"> {recipe.category} </span> : null}
</div>
</div>
))
)}
</div>
{selectedRecipe && (
<div className="modal-overlay" onClick={() => setSelectedRecipe(null)}>
<div className="modal" onClick={(e) => e.stopPropagation()}>
{}
<RecipeForm recipe={selectedRecipe} onClose={() => setSelectedRecipe(null)} />
</div>
</div>
)}
<div className="results-count">
Showing {filteredRecipes.length} of {allRecipes.length} apps
</div>
</main>
</div>
);
};

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *;
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
.server-detail-page {
@extend .page-wrapper;
@ -47,25 +47,7 @@
// Action buttons (shared with App view, could be moved to global)
.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;
}
@include action-btn(2px, $radius-md, $spacing-sm $spacing-lg, $font-size-sm);
&.primary {
background: $primary;
@ -212,9 +194,7 @@
}
.apps-list {
display: flex;
flex-direction: column;
gap: $spacing-md;
@include card-list-vertical;
}
.app-item {

View File

@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header';
import { Terminal } from '../../../components/Terminal/Terminal';
import { apiService } from '../../../services/api';
import type { AbraServer, ServerAppsResponse } from '../../../types';
import type { LogEntry } from '../../../services/mockApi';
import { Header } from '../../components/Header/Header';
import { Terminal } from '../../components/Terminal/Terminal';
import { apiService } from '../../services/api';
import type { AbraServer, ServerAppsResponse } from '../../types';
import type { LogEntry } from '../../services/mockApi';
import './Server.scss';
interface ServerWithApps extends AbraServer {
@ -35,7 +35,7 @@ export const Server: React.FC = () => {
const fetchServer = async () => {
try {
if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi');
const { mockApiService } = await import('../../services/mockApi');
const appsData = await mockApiService.getAppsGrouped();
const serversData = await mockApiService.getServers();
@ -95,7 +95,7 @@ export const Server: React.FC = () => {
try {
if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi');
const { mockApiService } = await import('../../services/mockApi');
const onLog = (log: LogEntry) => {
setTerminalLogs(prev => [...prev, log]);
@ -175,7 +175,7 @@ export const Server: React.FC = () => {
<span className="host-badge">{server.host}</span>
{server.upgradeCount > 0 && (
<span className="upgrade-badge">
{server.upgradeCount} upgrade{server.upgradeCount !== 1 ? 's' : ''}
{server.upgradeCount} upgrade{server.upgradeCount !== 1 ? 's' : ''}
</span>
)}
</div>
@ -187,14 +187,14 @@ export const Server: React.FC = () => {
onClick={() => handleAction('refresh')}
disabled={!!actionLoading}
>
{actionLoading === 'refresh' ? 'Refreshing...' : '🔄 Refresh'}
{actionLoading === 'refresh' ? 'Refreshing...' : 'Refresh'}
</button>
<button
className="action-btn primary"
onClick={() => handleAction('deploy-all')}
disabled={!!actionLoading}
>
{actionLoading === 'deploy-all' ? 'Deploying...' : '🚀 Deploy All'}
{actionLoading === 'deploy-all' ? 'Deploying...' : 'Deploy All'}
</button>
</div>
</div>
@ -280,7 +280,7 @@ export const Server: React.FC = () => {
{app.status}
</span>
{app.chaos === 'true' && (
<span className="chaos-badge">🔬</span>
<span className="chaos-badge"></span>
)}
{app.upgrade !== 'latest' && (
<span className="upgrade-badge"></span>
@ -319,7 +319,7 @@ export const Server: React.FC = () => {
onClick={() => handleAction('refresh')}
disabled={!!actionLoading}
>
<span className="action-text">🔄 Refresh Server Info</span>
<span className="action-text">Refresh Server Info</span>
</button>
<button
@ -327,7 +327,7 @@ export const Server: React.FC = () => {
onClick={() => handleAction('deploy-all')}
disabled={!!actionLoading}
>
<span className="action-text">🚀 Deploy All Apps</span>
<span className="action-text">Deploy All Apps</span>
</button>
<button
@ -335,7 +335,7 @@ export const Server: React.FC = () => {
onClick={() => handleAction('upgrade-all')}
disabled={!!actionLoading || server.upgradeCount === 0}
>
<span className="action-text"> Upgrade All Apps</span>
<span className="action-text">Upgrade All Apps</span>
</button>
</div>
</section>

View File

@ -1,6 +1,6 @@
@use '../../../assets/scss/variables' as *;
@use '../../../assets/scss/mixins' as *;
@use '../../../assets/scss/global' as *;
@use '../../assets/scss/variables' as *;
@use '../../assets/scss/mixins' as *;
@use '../../assets/scss/global' as *;
// Extend global page wrapper
.servers-page {
@ -14,10 +14,12 @@
// Servers grid
.servers-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: $spacing-xl;
margin-bottom: $spacing-xl;
align-items: stretch;
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
@ -26,38 +28,18 @@
// Server card
.server-card {
@include card;
@include card-hover-lift(-4px, $shadow-xl);
@include card-dimensions(320px, 180px);
display: flex;
flex-direction: column;
transition: transform $transition-base, box-shadow $transition-base;
position: relative;
overflow: hidden;
&:hover {
transform: translateY(-4px);
box-shadow: $shadow-xl;
}
.server-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: $spacing-lg;
padding-bottom: $spacing-md;
border-bottom: 2px solid $bg-secondary;
@include card-header-rule;
.server-title {
h3 {
margin: 0 0 $spacing-xs;
font-size: $font-size-xl;
color: $text-primary;
font-weight: $font-weight-bold;
}
.server-host {
font-size: $font-size-sm;
color: $text-muted;
font-family: monospace;
}
@include card-title-stack;
}
.server-status {
@ -80,24 +62,12 @@
margin-bottom: $spacing-lg;
.stat-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: $spacing-sm 0;
border-bottom: 1px solid $bg-secondary;
&:last-child {
border-bottom: none;
}
@include card-stat-row;
// Highlighted rows
&.highlight {
@include card-row-highlight-bleed;
background-color: rgba($warning, 0.05);
padding: $spacing-sm $spacing-md;
margin: $spacing-sm (-$spacing-xl);
padding-left: calc($spacing-xl + $spacing-md);
padding-right: calc($spacing-xl + $spacing-md);
border-bottom: none;
.stat-label {
font-weight: $font-weight-semibold;
@ -109,11 +79,8 @@
}
&.chaos-row {
@include card-row-highlight-bleed(false);
background-color: rgba($info, 0.05);
padding: $spacing-sm $spacing-md;
margin: $spacing-sm (-$spacing-xl);
padding-left: calc($spacing-xl + $spacing-md);
padding-right: calc($spacing-xl + $spacing-md);
.stat-label {
font-weight: $font-weight-semibold;
@ -152,21 +119,7 @@
.action-btn {
flex: 1;
padding: $spacing-sm $spacing-md;
border: 2px solid $border-color;
background: none;
color: $text-primary;
border-radius: $radius-md;
font-size: $font-size-sm;
font-weight: $font-weight-medium;
cursor: pointer;
transition: all $transition-base;
&:hover {
background-color: rgba($primary, 0.1);
border-color: $primary;
transform: translateY(-1px);
}
@include action-btn(2px, $radius-md, $spacing-sm $spacing-md, $font-size-sm);
&.primary {
background-color: $primary;

View File

@ -1,8 +1,8 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Header } from '../../../components/Header/Header';
import { apiService } from '../../../services/api';
import type { AbraServer, ServerAppsResponse } from '../../../types';
import { Header } from '../../components/Header/Header';
import { apiService } from '../../services/api';
import type { AbraServer, ServerAppsResponse } from '../../types';
import './Servers.scss';
interface ServerWithStats extends AbraServer {
@ -20,59 +20,47 @@ export const Servers: React.FC = () => {
const [error, setError] = useState('');
const [searchTerm, setSearchTerm] = useState('');
const [sortBy, setSortBy] = useState<'name' | 'apps' | 'upgrades'>('name');
const [showUpgradesOnly, setShowUpgradesOnly] = useState(false);
const [showChaosOnly, setShowChaosOnly] = useState(false);
const isMockMode = import.meta.env.VITE_MOCK_AUTH === 'true';
useEffect(() => {
const fetchData = async () => {
try {
let serversData, appsData;
if (isMockMode) {
const { mockApiService } = await import('../../../services/mockApi');
const [serversData, appsData] = await Promise.all([
const { mockApiService } = await import('../../services/mockApi');
[serversData, appsData] = await Promise.all([
mockApiService.getServers(),
mockApiService.getAppsGrouped(),
]);
// Enrich servers with stats from apps data
const enrichedServers = serversData.map(server => {
const serverStats = appsData[server.name];
const chaosCount = serverStats?.apps.filter(app => app.chaos === 'true').length || 0;
return {
...server,
appCount: serverStats?.appCount || 0,
versionCount: serverStats?.versionCount || 0,
latestCount: serverStats?.latestCount || 0,
upgradeCount: serverStats?.upgradeCount || 0,
chaosCount,
};
});
setServers(enrichedServers);
} else {
const [serversData, appsData] = await Promise.all([
[serversData, appsData] = await Promise.all([
apiService.getServers(),
apiService.getAppsGrouped(),
]);
// Enrich servers with stats from apps data
const enrichedServers = serversData.map(server => {
const serverStats = appsData[server.name];
const chaosCount = serverStats?.apps.filter(app => app.chaos === 'true').length || 0;
return {
...server,
appCount: serverStats?.appCount || 0,
versionCount: serverStats?.versionCount || 0,
latestCount: serverStats?.latestCount || 0,
upgradeCount: serverStats?.upgradeCount || 0,
chaosCount,
};
});
setServers(enrichedServers);
}
// Enrich servers with stats from apps data
const enrichedServers = serversData.map(server => {
const serverStats = appsData[server.name];
const chaosCount = serverStats?.apps.filter(app => app.chaos === 'true').length || 0;
return {
...server,
appCount: serverStats?.appCount || 0,
versionCount: serverStats?.versionCount || 0,
latestCount: serverStats?.latestCount || 0,
upgradeCount: serverStats?.upgradeCount || 0,
chaosCount,
};
});
setServers(enrichedServers);
} catch (err) {
console.error('Error loading servers:', err);
setError(err instanceof Error ? err.message : 'Failed to load servers');
} finally {
setLoading(false);
@ -92,28 +80,29 @@ export const Servers: React.FC = () => {
return { totalServers, totalApps, totalUpgrades, totalChaos };
}, [servers]);
// Filter and sort servers
// Filter and sort servers (additive filters allowed)
const filteredServers = useMemo(() => {
const filtered = servers.filter(server =>
const filtered = servers.filter(server => {
const matchesSearch =
server.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
server.host.toLowerCase().includes(searchTerm.toLowerCase())
);
server.host.toLowerCase().includes(searchTerm.toLowerCase());
const matchesUpgrades = !showUpgradesOnly || server.upgradeCount > 0;
const matchesChaos = !showChaosOnly || server.chaosCount > 0;
return matchesSearch && matchesUpgrades && matchesChaos;
});
// Sort
filtered.sort((a, b) => {
switch (sortBy) {
case 'apps':
return b.appCount - a.appCount;
case 'upgrades':
return b.upgradeCount - a.upgradeCount;
case 'name':
default:
return a.name.localeCompare(b.name);
}
});
filtered.sort((a, b) => {
switch (sortBy) {
case 'apps':
return b.appCount - a.appCount;
case 'name':
default:
return a.name.localeCompare(b.name);
}
});
return filtered;
}, [servers, searchTerm, sortBy]);
return filtered;
}, [servers, searchTerm, sortBy, showUpgradesOnly]);
if (loading) {
return (
@ -146,36 +135,38 @@ export const Servers: React.FC = () => {
<p className="subtitle">Managing {stats.totalServers} servers with {stats.totalApps} applications</p>
</div>
{/* Stats Overview */}
<div className="stats-grid">
<div className="stat-card">
<div className="stat-icon"></div>
<div className="stat-info">
<p className="stat-number">{stats.totalServers}</p>
<p className="stat-label">Total Servers</p>
</div>
</div>
<div className="stat-card">
<div className="stat-icon"></div>
<div className="stat-info">
<p className="stat-number">{stats.totalApps}</p>
<p className="stat-label">Total Apps</p>
</div>
</div>
<div className="stat-card upgrade">
<div className="stat-icon"></div>
<div className="stat-info">
<p className="stat-number">{stats.totalUpgrades}</p>
<p className="stat-label">Apps Need Upgrade</p>
</div>
</div>
<div className="stat-card chaos">
<div className="stat-icon"></div>
<div className="stat-info">
<p className="stat-number">{stats.totalChaos}</p>
<p className="stat-label">Chaos Apps</p>
</div>
</div>
{/* Compact Stats Row */}
<div className="stats-row">
<button
className="stat-chip"
onClick={() => navigate('/apps')}
title="View all apps"
>
<span className="stat-label">Apps</span>
<span className="stat-value">{stats.totalApps}</span>
</button>
<button
className={`stat-chip ${showUpgradesOnly ? 'active' : ''}`}
onClick={() => setShowUpgradesOnly(prev => !prev)}
title="Click to filter by servers with upgrades"
disabled={stats.totalUpgrades === 0}
>
<span className="stat-label">Upgrades</span>
<span className="stat-value">{stats.totalUpgrades}</span>
</button>
<button
className={`stat-chip ${showChaosOnly ? 'active' : ''}`}
onClick={() => setShowChaosOnly(prev => !prev)}
title="Click to filter servers with chaos apps"
disabled={stats.totalChaos === 0}
>
<span className="stat-label">Chaos</span>
<span className="stat-value">{stats.totalChaos}</span>
</button>
{/* Clear filters button removed — use stat-chip outlines for active filters */}
</div>
{/* Filters */}
@ -187,12 +178,6 @@ export const Servers: React.FC = () => {
onChange={(e) => setSearchTerm(e.target.value)}
className="search-input"
/>
<select value={sortBy} onChange={(e) => setSortBy(e.target.value as any)}>
<option value="name">Sort by Name</option>
<option value="apps">Sort by App Count</option>
<option value="upgrades">Sort by Upgrades</option>
</select>
</div>
{/* Server Cards */}
@ -233,7 +218,7 @@ export const Servers: React.FC = () => {
{server.upgradeCount > 0 && (
<div className="stat-row highlight">
<span className="stat-label">
<span className="upgrade-icon"></span> Need Upgrade
Need Upgrade
</span>
<span className="stat-value">{server.upgradeCount}</span>
</div>
@ -241,7 +226,7 @@ export const Servers: React.FC = () => {
{server.chaosCount > 0 && (
<div className="stat-row chaos-row">
<span className="stat-label">
<span className="chaos-icon"></span> Chaos Mode
Chaos Mode
</span>
<span className="stat-value">{server.chaosCount}</span>
</div>
@ -271,7 +256,6 @@ export const Servers: React.FC = () => {
{server.upgradeCount > 0 && (
<div className="server-alert">
<span className="alert-icon"></span>
<span className="alert-text">
{server.upgradeCount} app{server.upgradeCount > 1 ? 's' : ''} can be upgraded
</span>
@ -288,4 +272,4 @@ export const Servers: React.FC = () => {
</main>
</div>
);
};
};

View File

@ -1,6 +1,6 @@
import type { AbraServer, ServerAppsResponse, AuthResponse, LoginCredentials, User } from '../types';
import type { AbraServer, AbraRecipe, ServerAppsResponse } from '../types';
// Log entry type - shared between mock and real API
// Log entry type
export type LogEntry = {
type: 'info' | 'success' | 'error' | 'warning' | 'command' | 'output';
text: string;
@ -19,12 +19,6 @@ const processLogResponse = (logData: any[]): LogEntry[] => {
};
class ApiService {
private token: string | null = null;
constructor() {
this.token = localStorage.getItem('auth_token');
}
private async request<T>(
endpoint: string,
options: RequestInit = {}
@ -34,10 +28,6 @@ class ApiService {
...options.headers,
};
if (this.token) {
headers['Authorization'] = `Bearer ${this.token}`;
}
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
...options,
headers,
@ -51,51 +41,19 @@ class ApiService {
return response.json();
}
// Auth methods
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
// Get all apps grouped by server
async getAppsGrouped(): Promise<ServerAppsResponse> {
return this.request<ServerAppsResponse>('/abra/apps');
return this.request<ServerAppsResponse>('/apps');
}
// Get all servers
async getServers(): Promise<AbraServer[]> {
return this.request<AbraServer[]>('/abra/servers');
return this.request<AbraServer[]>('/servers');
}
// App actions with log streaming
// App actions with log streaming (websocket future)
async deployApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/apps/${appName}/deploy`, {
method: 'POST',
});
// Process logs and stream to callback
if (onLog && response.logs) {
const logs = processLogResponse(response.logs);
logs.forEach(log => onLog(log));
}
}
async stopApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/apps/${appName}/stop`, {
const response = await this.request<{ logs: any[] }>(`/apps/${appName}/deploy`, {
method: 'POST',
});
@ -105,8 +63,8 @@ class ApiService {
}
}
async startApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/apps/${appName}/start`, {
async undeployApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/apps/${appName}/undeploy`, {
method: 'POST',
});
@ -117,7 +75,7 @@ class ApiService {
}
async upgradeApp(appName: string, version: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/apps/${appName}/upgrade`, {
const response = await this.request<{ logs: any[] }>(`/apps/${appName}/upgrade`, {
method: 'POST',
body: JSON.stringify({ version }),
});
@ -129,7 +87,7 @@ class ApiService {
}
async removeApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/apps/${appName}/remove`, {
const response = await this.request<{ logs: any[] }>(`/apps/${appName}/remove`, {
method: 'POST',
});
@ -141,7 +99,7 @@ class ApiService {
// Server actions with log streaming
async refreshServer(serverName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/servers/${serverName}/refresh`, {
const response = await this.request<{ logs: any[] }>(`/servers/${serverName}/refresh`, {
method: 'POST',
});
@ -152,7 +110,7 @@ class ApiService {
}
async deployAllApps(serverName: string, appCount: number, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/servers/${serverName}/deploy-all`, {
const response = await this.request<{ logs: any[] }>(`/servers/${serverName}/deploy-all`, {
method: 'POST',
});
@ -163,7 +121,7 @@ class ApiService {
}
async upgradeAllApps(serverName: string, upgradeCount: number, onLog?: (log: LogEntry) => void): Promise<void> {
const response = await this.request<{ logs: any[] }>(`/abra/servers/${serverName}/upgrade-all`, {
const response = await this.request<{ logs: any[] }>(`/servers/${serverName}/upgrade-all`, {
method: 'POST',
});
@ -172,6 +130,11 @@ class ApiService {
logs.forEach(log => onLog(log));
}
}
// recipe catalog imports
async getRecipes(): Promise<AbraRecipe[]> {
return this.request<AbraRecipe[]>('/abra/catalogue');
}
}
export const apiService = new ApiService();
export const apiService = new ApiService();

File diff suppressed because it is too large Load Diff

View File

@ -119,7 +119,7 @@
"logs": [
{
"type": "info",
"text": "⬆️ Upgrading {appName} to {version}..."
"text": "Upgrading {appName} to {version}..."
},
{
"type": "command",
@ -287,7 +287,7 @@
"logs": [
{
"type": "info",
"text": "⬆️ Upgrading all apps on {serverName}..."
"text": "Upgrading all apps on {serverName}..."
},
{
"type": "command",

View File

@ -1,7 +1,9 @@
import type { AbraServer, ServerAppsResponse } from '../types';
import type { AbraServer, AbraRecipe, ServerAppsResponse } from '../types';
import appsData from './mock-apps.json';
import serversData from './mock-servers.json';
import logsData from './mock-logs.json';
import catalogue from './mock-catalogue.json';
// Log entry type
export type LogEntry = {
@ -91,15 +93,6 @@ export const mockApiService = {
}
},
async startApp(appName: string, onLog?: (log: LogEntry) => void): Promise<void> {
const logs = processLogs('start', { appName });
for (const log of logs) {
await delay(150);
onLog?.(log);
}
},
async upgradeApp(appName: string, version: string, onLog?: (log: LogEntry) => void): Promise<void> {
const logs = processLogs('upgrade', { appName, version });
@ -144,4 +137,9 @@ export const mockApiService = {
onLog?.(log);
}
},
// recipe catalog imports
async getRecipes(): Promise<AbraRecipe[]> {
await delay(300);
return catalogue as AbraRecipe[];
}
};

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 {
message: string;
status: number;
@ -52,4 +36,36 @@ export interface AppWithServer extends AbraApp {
appCount: number;
upgradeCount: number;
};
}
export interface Image {
image: string;
rating: string
source: string
url: string
}
type RecipeVersions = Record<string, Record<string, ServiceMeta>>[];
export interface ServiceMeta {
image: string;
tag: string
}
export interface Features {
backups: string;
email: string;
healthcheck: string;
image: Image;
status: number;
tests: string;
sso: string;
}
export interface AbraRecipe {
category: string;
default_branch: string;
description: string;
features: Features;
icon: string;
name: string;
repository: string;
ssh_url: string;
versions: RecipeVersions;
website: string;
}