← back to Designer Wallcoverings
DW-Agents/dw-agents/agent-executive-coo/coo-dashboard-agent.ts.backup-oauth-20251112
171 lines
import cookieParser from "cookie-parser";
/**
* COO Dashboard - Port 7124
* Daily operations, workflow optimization, team coordination
*/
import express from 'express';
import session from 'express-session';
import { chatMiddleware } from '../shared-chat-integration';
const app = express();
// Global Authentication
const PORT = 7124;
// Global Authentication - MUST come before any other middleware
app.use(cookieParser());
// Add inter-agent chat widget (after auth)
app.use(chatMiddleware({
agentId: 'agent-executive-coo',
agentName: 'Executive Coo',
port: 7124,
category: 'agent'
}));
const AUTH_USERNAME = 'admin';
const AUTH_PASSWORD = '*exec2025*';
const COO_ACCESS = [
{ name: 'Task Orchestrator', port: 9900, url: 'http://45.61.58.125:9900/' },
{ name: 'Todays Highlights', port: 9885, url: 'http://45.61.58.125:9885/' },
{ name: 'Needs Attention', port: 9886, url: 'http://45.61.58.125:9886/' },
{ name: 'Completed Tasks', port: 9889, url: 'http://45.61.58.125:9889/' },
{ name: 'Marketing', port: 9881, url: 'http://45.61.58.125:9881/' },
{ name: 'New Client Signup', port: 9890, url: 'http://45.61.58.125:9890/' },
{ name: 'Zendesk Chat', port: 9884, url: 'http://45.61.58.125:9884/' },
{ name: 'Digital Samples', port: 9879, url: 'http://45.61.58.125:9879/' },
{ name: 'Skills Manager', port: 9894, url: 'http://45.61.58.125:9894/' }
];
const COO_SKILLS = [
{ name: '📋 Daily Reports', description: 'EOD report generator' },
{ name: '✉️ Email', description: 'Client and team communications' },
{ name: '📢 Company Updates', description: 'Internal communications' },
{ name: '📄 Documentation', description: 'Operations docs' },
{ name: '📊 Presentations', description: 'Team presentations' }
];
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
declare module 'express-session' {
interface SessionData { authenticated: boolean; }
}
app.use(session({
secret: 'dw-coo-dashboard-2025',
resave: false,
saveUninitialized: true,
cookie: { secure: false, httpOnly: true, maxAge: 7 * 24 * 60 * 60 * 1000 }
}));
const requireAuth = (req: any, res: any, next: any) => {
if (req.session.authenticated) return next();
res.redirect('/login');
};
app.get('/login', (req, res) => {
res.send(`<!DOCTYPE html><html><head><title>COO - Login</title><style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'DejaVu Sans, Segoe UI', sans-serif; background: linear-gradient(135deg, #e67e22 0%, #d35400 100%); display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-container { background: white; padding: 50px; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-width: 450px; width: 100%; }
.logo { text-align: center; font-size: 3em; margin-bottom: 10px; }
h1 { color: #e67e22; text-align: center; margin-bottom: 10px; font-size: 1.8em; }
.subtitle { text-align: center; color: #666; margin-bottom: 30px; font-size: 1.1em; }
input { width: 100%; padding: 15px; margin: 10px 0; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 1em; }
input:focus { border-color: #e67e22; outline: none; }
button { width: 100%; background: linear-gradient(135deg, #e67e22 0%, #d35400 100%); color: white; border: none; padding: 15px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 1.1em; margin-top: 10px; }
</style></head><body>
<div class="login-container">
<div class="logo">📊</div>
<h1>COO Dashboard</h1>
<div class="subtitle">Daily Operations Center</div>
${req.query.error ? '<div style="color:#dc3545;text-align:center;margin-bottom:15px;font-weight:600;">Invalid credentials</div>' : ''}
<form method="POST">
<input type="text" name="username" placeholder="Username" required autofocus>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Access Dashboard</button>
</form>
</div></body></html>`);
});
app.post('/login', (req, res) => {
const { username, password } = req.body;
if (username === AUTH_USERNAME && password === AUTH_PASSWORD) {
req.session.authenticated = true;
res.redirect('/');
} else {
res.redirect('/login?error=1');
}
});
app.get('/', requireAuth, (req, res) => {
res.send(`<!DOCTYPE html><html><head><title>COO Dashboard</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --primary: #36454f; --primary-light: #708090; --bg: #ffffff; --card-bg: #f8f9fa; --text: #36454f; }
body { font-family: 'DejaVu Sans, Segoe UI', sans-serif; background: var(--bg); padding: 0; min-height: 100vh; font-size: 18px; line-height: 1.8; }
.header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: white; padding: 25px 40px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 2.2em; display: flex; align-items: center; gap: 15px; }
.header-actions { display: flex; gap: 15px; align-items: center; }
.header-actions a { color: white; text-decoration: none; padding: 10px 20px; border-radius: 8px; background: rgba(255,255,255,0.2); }
.container { max-width: 1800px; margin: 0 auto; padding: 30px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; margin-bottom: 30px; }
.kpi-card { background: var(--card-bg); padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid var(--primary); }
.kpi-label { color: #708090; font-size: 1.1em; text-transform: uppercase; font-weight: 600; margin-bottom: 10px; }
.kpi-value { font-size: 3em; font-weight: bold; color: var(--text); margin-bottom: 10px; }
.section { background: var(--card-bg); padding: 30px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); margin-bottom: 25px; }
.section h2 { color: var(--primary); margin-bottom: 20px; font-size: 1.8em; border-bottom: 3px solid var(--primary); padding-bottom: 10px; }
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.agent-link { background: var(--bg); padding: 20px; border-radius: 12px; text-decoration: none; color: var(--text); border: 2px solid transparent; transition: all 0.3s; display: block; }
.agent-link:hover { border-color: var(--primary); transform: translateY(-3px); }
.agent-name { font-weight: 700; font-size: 1.3em; margin-bottom: 8px; color: var(--primary); }
.agent-port { color: #708090; font-size: 1em; font-family: monospace; }
</style></head><body>
<div class="header">
<h1><span>📊</span><span>COO Dashboard</span></h1>
<div class="header-actions"><span>Welcome, COO</span><a href="/logout">Logout</a></div>
</div>
<div class="container">
<div class="dashboard-grid">
<div class="kpi-card"><div class="kpi-label">Daily Tasks</div><div class="kpi-value">42</div></div>
<div class="kpi-card"><div class="kpi-label">Completed Today</div><div class="kpi-value">28</div></div>
<div class="kpi-card"><div class="kpi-label">Needs Attention</div><div class="kpi-value">3</div></div>
<div class="kpi-card"><div class="kpi-label">Team Efficiency</div><div class="kpi-value">94%</div></div>
</div>
<div class="section"><h2>📋 Operations Systems</h2>
<div class="agents-grid">
${COO_ACCESS.map(agent => `<a href="${agent.url}" target="_blank" class="agent-link"><div class="agent-name">${agent.name}</div><div class="agent-port">Port ${agent.port}</div></a>`).join('')}
</div></div>
<div class="section"><h2>🛠️ COO Skills & Tools</h2>
<div class="agents-grid">
${COO_SKILLS.map(skill => `<div class="agent-link" style="cursor: default; background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);"><div class="agent-name">${skill.name}</div><div class="agent-port" style="color: var(--text-light); font-size: 0.95em; margin-top: 8px;">${skill.description}</div></div>`).join('')}
</div></div>
</div></body></html>`);
});
app.get('/logout', (req, res) => {
req.session.destroy(() => res.redirect('/login'));
});
// Metrics endpoint for daily reporting
app.get("/api/metrics", (req: Request, res: Response) => {
res.json({
status: "online",
uptime: process.uptime(),
responseTime: 0,
tasksCompleted: 0,
errorsToday: 0,
lastActivity: new Date().toISOString(),
qnaReadiness: 100
});
});
app.listen(PORT, '0.0.0.0', () => {
console.log('📊 COO Dashboard');
console.log('🌍 http://45.61.58.125:' + PORT);
console.log('🔐 ' + AUTH_USERNAME + ' / ' + AUTH_PASSWORD);
});