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
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)