Initial commit: unified dashboard suite state with Khira and Image Manipulator 3-file setup

This commit is contained in:
2026-10-26 11:17:13 +05:30
commit 6c60b4ecb8
148 changed files with 128149 additions and 0 deletions
+151
View File
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script>
window.onerror = function(msg, url, lineNo, columnNo, error) {
alert("Error: " + msg + "\nLine: " + lineNo + "\nCol: " + columnNo);
return false;
};
window.onunhandledrejection = function(event) { alert("Promise Error: " + event.reason); };
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Phoenix — Enterprise API Suite</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&family=JetBrains+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="/static/css/style.css?v=21">
<style>
/* Loading Screen */
@keyframes loaderSpin { to { transform: rotate(360deg); } }
@keyframes loaderPulse { 0%,100%{opacity:.45} 50%{opacity:1} }
@keyframes loaderGlow { 0%,100%{box-shadow:0 0 16px rgba(255,108,55,.2)} 50%{box-shadow:0 0 32px rgba(255,108,55,.45),0 0 60px rgba(255,108,55,.12)} }
@keyframes loaderFadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes dotWave { 0%,80%,100%{transform:scale(0);opacity:.3} 40%{transform:scale(1);opacity:1} }
#loading-overlay {
position: fixed; inset: 0;
background: radial-gradient(ellipse at 50% 38%, #0f0f22 0%, #07070d 68%);
display: flex; align-items: center; justify-content: center;
z-index: 10000;
transition: opacity 0.4s ease, visibility 0.4s ease;
}
.loader-wrap {
display: flex; flex-direction: column; align-items: center; gap: 28px;
animation: loaderFadeUp 0.5s ease both;
}
/* Concentric rings */
.loader-rings {
position: relative; width: 64px; height: 64px;
}
.loader-rings::before, .loader-rings::after {
content: '';
position: absolute; border-radius: 50%; border-style: solid;
}
.loader-rings::before {
inset: 0;
border-width: 2px;
border-color: transparent rgba(255,108,55,0.18) transparent rgba(255,108,55,0.9);
animation: loaderSpin 1.1s linear infinite, loaderGlow 2s ease-in-out infinite;
}
.loader-rings::after {
inset: 10px;
border-width: 1.5px;
border-color: rgba(255,108,55,0.35) transparent rgba(255,108,55,0.35) transparent;
animation: loaderSpin 1.7s linear infinite reverse;
}
.loader-icon {
position: absolute; inset: 0;
display: flex; align-items: center; justify-content: center;
font-size: 20px; color: #FF6C37;
filter: drop-shadow(0 0 8px rgba(255,108,55,0.6));
animation: loaderPulse 2s ease-in-out infinite;
}
/* Brand text */
.loader-brand {
display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.loader-brand-name {
font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
font-size: 24px; font-weight: 800;
letter-spacing: 0.18em; text-transform: uppercase;
background: linear-gradient(135deg, #fff 25%, #FF8C5A 65%, #FF6C37 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
background-clip: text;
}
.loader-brand-sub {
font-family: 'Inter', sans-serif;
font-size: 10px; font-weight: 600;
letter-spacing: 0.22em; text-transform: uppercase;
color: #444c5c;
}
/* Dot wave loader */
.loader-dots {
display: flex; gap: 6px; align-items: center;
}
.loader-dot {
width: 5px; height: 5px; border-radius: 50%;
background: rgba(255,108,55,0.55);
}
.loader-dot:nth-child(1) { animation: dotWave 1.4s ease-in-out 0.0s infinite; }
.loader-dot:nth-child(2) { animation: dotWave 1.4s ease-in-out 0.2s infinite; }
.loader-dot:nth-child(3) { animation: dotWave 1.4s ease-in-out 0.4s infinite; }
.loader-dot:nth-child(4) { animation: dotWave 1.4s ease-in-out 0.6s infinite; }
.loader-dot:nth-child(5) { animation: dotWave 1.4s ease-in-out 0.8s infinite; }
</style>
</head>
<body>
<!-- ── Error Display ─────────────────────────────────────── -->
<div id="error-display" style="display:none; position:fixed; top:0; left:0; right:0; background:rgba(255,69,105,0.92); color:white; padding:16px 20px; z-index:99999; font-family:'Inter',sans-serif; font-size:13px; box-shadow:0 4px 24px rgba(0,0,0,0.5);"></div>
<script>
window.onerror = function(msg, url, line) {
const el = document.getElementById('error-display');
el.style.display = 'block';
el.innerHTML += `<div style="margin-bottom:6px;"><strong>⚠ Error:</strong> ${msg} <span style="opacity:.7; font-size:11px;">(${url}:${line})</span></div>`;
};
window.onunhandledrejection = function(event) { alert("Promise Error: " + event.reason); };
</script>
<!-- ── Loading Overlay ───────────────────────────────────── -->
<div id="loading-overlay">
<div class="loader-wrap">
<div class="loader-rings">
<div class="loader-icon"><i class="fa-solid fa-fire"></i></div>
</div>
<div class="loader-brand">
<div class="loader-brand-name">PHOENIX</div>
<div class="loader-brand-sub">Enterprise API Suite</div>
</div>
<div class="loader-dots">
<div class="loader-dot"></div>
<div class="loader-dot"></div>
<div class="loader-dot"></div>
<div class="loader-dot"></div>
<div class="loader-dot"></div>
</div>
</div>
</div>
<!-- ── App Root ──────────────────────────────────────────── -->
<div id="app-root" class="workspace" style="visibility:hidden">
<div id="sidebar" class="sidebar"></div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
<div id="main-panel" class="main-panel"></div>
</div>
<!-- ── Toast Container ───────────────────────────────────── -->
<div id="toast-container"></div>
<!-- ── Scripts ───────────────────────────────────────────── -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js">
window.onunhandledrejection = function(event) { alert("Promise Error: " + event.reason); };
</script>
<script src="/static/js/app.js?v=30">
window.onunhandledrejection = function(event) { alert("Promise Error: " + event.reason); };
</script>
</body>
</html>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
import re
with open('app.js', 'r') as f:
code = f.read()
# 1. _buildShell
shell = """
_buildShell() {
if (!this.dom.mainPanel) return;
this.dom.mainPanel.innerHTML = `
<div id="content-area"></div>
<div id="collections-list"></div>
`;
},
"""
code = code.replace('async init() {', shell + '\n async init() {')
code = code.replace('this.cacheDOM();', 'this.cacheDOM();\n this._buildShell();')
# 2. Rename render() to _renderAll()
code = code.replace('render() {', '_renderAll() {')
# 3. Targeted updates
code = code.replace('this.render();', 'this._renderAll();')
# 4. Results: binaryData ALWAYS nulled after blobUrl created
code = re.sub(r'(resultItem\.blobUrl = res\.blobUrl;)', r'\1\n resultItem.binaryData = null;', code)
# 5. saveState skip during bulk
# Already in code: if (this.state.bulk && this.state.bulk.running) return;
with open('app.js', 'w') as f:
f.write(code)
print("Rewrite done via Python")
@@ -0,0 +1,22 @@
import re
with open('app.js', 'r') as f:
content = f.read()
for func in ['renderSidebar', 'renderMain', 'renderResponse']:
match = re.search(fr'{func}\(\)\s*\{{', content)
if match:
start = match.start()
brace_count = 0
started = False
for i in range(start, len(content)):
if content[i] == '{':
brace_count += 1
started = True
elif content[i] == '}':
brace_count -= 1
if started and brace_count == 0:
end = i + 1
break
with open(f'{func}.txt', 'w') as out:
out.write(content[start:end])
+24
View File
@@ -0,0 +1,24 @@
render() {
const root = document.getElementById('app-root');
if (root) {
// Reset base class first to prevent layout/theme clashing
root.className = 'workspace';
if (this.state.bulk.results.length > 0 || this.state.bulk.running) {
root.classList.add('bulk-active');
}
if (this.state.gridMaximized || !this.state.activeSpaceId) {
root.classList.add('grid-maximized');
}
// Add theme class for active space
if (this.state.activeSpaceId) {
const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId);
const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet';
root.classList.add(`theme-${theme}`);
}
}
this.renderSidebar();
this.renderMain();
this.renderResponse();
}
@@ -0,0 +1,107 @@
renderMain() {
if (!this.state.activeSpaceId) {
// Render Spaces Dashboard Grid View
const spacesCardsHTML = this.state.spaces.map(s => {
const count = s.collections ? s.collections.length : 0;
const notifCount = s.notifications ? s.notifications.length : 0;
const theme = s.theme || 'violet';
return `
<div class="space-card space-card-${theme}" onclick="App.openSpace('${s.id}')">
<div class="space-card-icon">
<i class="fa-solid fa-cubes"></i>
${notifCount > 0 ? `<span class="space-card-notif-badge">${notifCount}</span>` : ''}
</div>
<div class="space-card-info">
<h3>${this.escapeHTML(s.name)}</h3>
<span>${count} Collections</span>
</div>
<div class="space-card-actions" onclick="event.stopPropagation();">
<button class="btn btn-ghost" style="color:var(--text-muted); padding:4px;" onclick="App.renameSpace('${s.id}')" title="Rename Space">
<i class="fa-solid fa-pencil" style="font-size:12px;"></i>
</button>
${this.state.spaces.length > 1 ? `
<button class="btn btn-ghost" style="color:var(--danger); padding:4px;" onclick="App.deleteSpace('${s.id}')" title="Delete Space">
<i class="fa-solid fa-trash" style="font-size:12px;"></i>
</button>
` : ''}
</div>
</div>
`;
}).join('');
const dashboardHTML = `
<div class="spaces-dashboard">
<div class="spaces-dash-header">
<h2>Workspaces</h2>
<p>Select a workspace to access its collections, endpoints, and history.</p>
</div>
<div class="spaces-grid">
${spacesCardsHTML}
<div class="space-card create-space-card" onclick="App.createSpace()">
<div class="space-card-icon"><i class="fa-solid fa-circle-plus"></i></div>
<div class="space-card-info">
<h3>Create New Space</h3>
<span>Add a clean workspace</span>
</div>
</div>
</div>
</div>
`;
const headerHTML = `
<div class="app-header">
<div class="brand" style="cursor:pointer;" onclick="App.showSpacesDashboard()"><i class="fa-solid fa-fire"></i> PHOENIX</div>
<div style="font-size:13px; color:var(--text-muted); font-weight:600;">
Workspace Dashboard
</div>
<div></div>
</div>
`;
this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML;
return;
}
const isBulkStart = this.checkBulkStart();
const bulk = this.state.bulk;
const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId);
// Tab Strip (Postman-like)
const tabStripHTML = `
<div class="main-tab-strip">
${this.tabs.map((tab, i) => {
const isActive = i === this.activeTabIndex;
const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled');
const displayName = tabName.length > 20 ? tabName.substring(0, 20) + '…' : tabName;
const method = tab.method || 'GET';
const mc = { GET:'var(--m-get)', POST:'var(--m-post)', PUT:'var(--m-put)', DELETE:'var(--m-delete)', PATCH:'var(--m-patch)' }[method] || 'var(--text-3)';
return `
<div class="main-tab ${isActive ? 'active' : ''}"
onclick="App.switchTab(${i})"
title="${this.escapeHTML(tab.name || tab.url || 'Untitled')}"
style="
display:flex;align-items:center;gap:6px;
padding:0 12px;min-width:120px;max-width:190px;
height:100%;cursor:pointer;flex-shrink:0;
position:relative;overflow:hidden;
user-select:none;white-space:nowrap;
border-right:1px solid var(--border-2);
background:${isActive ? 'var(--bg-app)' : 'var(--bg-sidebar)'};
color:${isActive ? 'var(--text-1)' : 'var(--text-3)'};
border-bottom:2px solid ${isActive ? 'var(--ph)' : 'transparent'};
transition:background 0.12s,color 0.12s;
"
onmouseover="if(!this.classList.contains('active')){this.style.background='var(--bg-elevated)';this.style.color='var(--text-2)';}"
onmouseout="if(!this.classList.contains('active')){this.style.background='var(--bg-sidebar)';this.style.color='var(--text-3)';}">
<span style="font-size:9px;font-weight:800;color:${mc};letter-spacing:0.03em;flex-shrink:0;font-family:var(--font-ui);">${method}</span>
<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:12px;font-weight:${isActive ? '600' : '500'};">${this.escapeHTML(displayName)}</span>
<button onclick="event.stopPropagation();App.closeTab(${i})"
style="background:none;border:none;cursor:pointer;color:${isActive ? 'var(--text-2)' : 'var(--text-4)'};padding:2px 3px;border-radius:3px;line-height:1;font-size:14px;flex-shrink:0;transition:background 0.1s,color 0.1s;"
onmouseover="this.style.background='var(--danger-dim)';this.style.color='var(--danger)'"
onmouseout="this.style.background='none';this.style.color='${isActive ? 'var(--text-2)' : 'var(--text-4)'}}'"
title="Close tab">×</button>
</div>
`;
}).join('')}
@@ -0,0 +1,3 @@
renderResponse() {
// No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel.
}
@@ -0,0 +1,88 @@
renderSidebar() {
const collectionsHTML = this.getCollectionsHTML();
const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId);
let notificationsBannerHTML = '';
if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) {
notificationsBannerHTML = `
<div class="notifications-banner" onclick="App.openNotificationsModal()">
<i class="fa-solid fa-bell"></i>
<span>${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''}</span>
</div>
`;
}
const spaceOptionsHTML = `
<option value="" ${!this.state.activeSpaceId ? 'selected' : ''}>⌂ Workspaces Dashboard</option>
${this.state.spaces.map(s => `
<option value="${s.id}" ${s.id === this.state.activeSpaceId ? 'selected' : ''}>
${this.escapeHTML(s.name)}
</option>
`).join('')}
`;
this.dom.sidebar.innerHTML = `
<!-- Workspace Header -->
<div class="sidebar-header" style="position:relative;z-index:1;">
<div class="sidebar-ws-label-row">
<div class="sidebar-ws-label-text">
<i class="fa-solid fa-cube"></i> Workspace
</div>
<button class="btn btn-ghost" style="height:26px;padding:0 9px;font-size:10px;gap:4px;" onclick="App.createSpace()" title="New Workspace">
<i class="fa-solid fa-plus" style="font-size:9px;"></i> New
</button>
</div>
<div style="position:relative;">
<select class="space-switcher-select" onchange="this.value ? App.openSpace(this.value) : App.showSpacesDashboard()">
${spaceOptionsHTML}
</select>
<i class="fa-solid fa-chevron-down" style="position:absolute;right:11px;top:50%;transform:translateY(-50%);color:var(--text-3);pointer-events:none;font-size:9px;"></i>
</div>
</div>
${activeSpace ? `
${notificationsBannerHTML}
<!-- Collections Section -->
<div class="sidebar-collections-header">
<div class="sidebar-section-label">
<i class="fa-solid fa-layer-group" style="color:var(--warning);font-size:9px;"></i>
Collections
</div>
<button class="btn btn-ghost" style="height:24px;padding:0 8px;font-size:10px;" onclick="App.createCollection()" title="New Collection">
<i class="fa-solid fa-plus" style="font-size:9px;"></i>
</button>
</div>
<!-- Search -->
<div class="sidebar-search-container" style="padding:0 10px 8px;">
<div style="position:relative;display:flex;align-items:center;">
<i class="fa-solid fa-magnifying-glass" style="position:absolute;left:9px;color:var(--text-3);font-size:10px;pointer-events:none;z-index:1;"></i>
<input type="text" class="sidebar-search-input" placeholder="Search…" value="${this.state.searchQuery || ''}"
oninput="App.filterSidebarCollections(this.value)"
style="padding-left:28px;padding-right:${this.state.searchQuery ? '28px' : '10px'};">
${this.state.searchQuery ? `<i id="search-clear-btn" class="fa-solid fa-xmark" onclick="App.filterSidebarCollections(''); document.querySelector('.sidebar-search-input').value='';" style="position:absolute;right:9px;color:var(--text-3);font-size:10px;cursor:pointer;z-index:1;"></i>` : ''}
</div>
</div>
<!-- Collections List -->
<div class="history-list" id="sidebar-collections-list">
${collectionsHTML || `<div style="padding:20px 14px;font-size:11px;color:var(--text-3);text-align:center;line-height:1.6;">No requests yet.<br>Create a collection to get started.</div>`}
</div>
` : `
<div style="flex:1;display:flex;align-items:center;justify-content:center;padding:24px;text-align:center;">
<div>
<i class="fa-solid fa-cubes" style="font-size:24px;color:var(--text-4);display:block;margin-bottom:12px;"></i>
<div style="font-size:11.5px;color:var(--text-3);line-height:1.65;">Select a workspace<br>from the dashboard</div>
</div>
</div>
`}
<!-- Footer -->
<div style="padding:10px;border-top:1px solid var(--border-1);flex-shrink:0;">
<button class="btn btn-ghost" style="width:100%;font-size:11px;" onclick="localStorage.removeItem('phoenix-state-v2'); location.reload();">
<i class="fa-solid fa-rotate-right"></i> Reset App
</button>
</div>
`;
}
+40
View File
@@ -0,0 +1,40 @@
import re
import sys
with open('app.js', 'r') as f:
content = f.read()
# 1. Add _buildShell()
shell_html = """
_buildShell() {
const root = document.getElementById('app-root');
if (!root) return;
root.innerHTML = `
<div id="sidebar" class="sidebar"></div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
<div id="main-panel" class="main-panel"></div>
<div id="toast-container"></div>
`;
},
"""
# Find init() and insert _buildShell() call and definition
init_idx = content.find('async init() {')
if init_idx != -1:
content = content[:init_idx] + shell_html + content[init_idx:]
content = content.replace('this.loadState();', 'this.loadState();\n this._buildShell();')
# 2. _renderAll() instead of render()
content = content.replace('render() {', '_renderAll() {')
# 3. Surgical updates
# We can replace 'this.render();' with selective calls, but the prompt says:
# "6. Full _renderAll() called only on: tab switch, space switch, page init, bulk complete."
# "5. saveState() must skip during bulk run." (already in code: if (this.state.bulk && this.state.bulk.running) return;)
# "4. Results: binaryData ALWAYS nulled after blobUrl created"
# "7. No this.dom.mainPanel.innerHTML = ... after init, except for Spaces Dashboard view"
# "8. No this.dom.sidebar.innerHTML = ... after init."
with open('/tmp/app_new.js', 'w') as f:
f.write(content)