Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
47835df
1
Parent(s): 6705e53
backend stabilization
Browse files
frontend/apps/internal/src/App.tsx
CHANGED
|
@@ -168,6 +168,7 @@ function AuthenticatedPortal({ user, authLoading, logout, refreshUser, hasRole }
|
|
| 168 |
case 'queue':
|
| 169 |
return (
|
| 170 |
<TicketBoard
|
|
|
|
| 171 |
onSelect={(t) => {
|
| 172 |
setSelectedTicket(t);
|
| 173 |
setActiveTab('detail');
|
|
|
|
| 168 |
case 'queue':
|
| 169 |
return (
|
| 170 |
<TicketBoard
|
| 171 |
+
workspaceId={selectedWorkspaceId}
|
| 172 |
onSelect={(t) => {
|
| 173 |
setSelectedTicket(t);
|
| 174 |
setActiveTab('detail');
|
frontend/apps/internal/src/components/ForensicsView.module.css
CHANGED
|
@@ -322,3 +322,36 @@
|
|
| 322 |
.spinning {
|
| 323 |
animation: spinning 1s linear infinite;
|
| 324 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
.spinning {
|
| 323 |
animation: spinning 1s linear infinite;
|
| 324 |
}
|
| 325 |
+
|
| 326 |
+
.paginationFooter {
|
| 327 |
+
padding: 20px 0;
|
| 328 |
+
display: flex;
|
| 329 |
+
justify-content: center;
|
| 330 |
+
border-top: 1px solid var(--border);
|
| 331 |
+
background: var(--bg3);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.loadMoreBtn {
|
| 335 |
+
background: var(--bg1);
|
| 336 |
+
border: 1px solid var(--border);
|
| 337 |
+
color: var(--text2);
|
| 338 |
+
padding: 10px 24px;
|
| 339 |
+
border-radius: 8px;
|
| 340 |
+
font-size: 11px;
|
| 341 |
+
font-weight: 700;
|
| 342 |
+
letter-spacing: 0.5px;
|
| 343 |
+
cursor: pointer;
|
| 344 |
+
transition: all 0.2s;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
.loadMoreBtn:hover:not(:disabled) {
|
| 348 |
+
background: var(--bg2);
|
| 349 |
+
color: var(--accent);
|
| 350 |
+
border-color: var(--accent);
|
| 351 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
.loadMoreBtn:disabled {
|
| 355 |
+
opacity: 0.5;
|
| 356 |
+
cursor: not-allowed;
|
| 357 |
+
}
|
frontend/apps/internal/src/components/ForensicsView.tsx
CHANGED
|
@@ -38,28 +38,46 @@ export const ForensicsView: React.FC<ForensicsViewProps> = ({ workspaceId }) =>
|
|
| 38 |
const [logs, setLogs] = useState<AuditLog[]>([]);
|
| 39 |
const [loading, setLoading] = useState(true);
|
| 40 |
const [filterType, setFilterType] = useState<string>('');
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
const fetchAuditLogs = useCallback(async () => {
|
| 43 |
setLoading(true);
|
| 44 |
try {
|
| 45 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
if (filterType) params.entity_type = filterType;
|
| 47 |
if (workspaceId) params.workspace_id = workspaceId;
|
| 48 |
|
| 49 |
const res = await api.get('system/audit/', { params });
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
} catch (err) {
|
| 52 |
console.error('Forensics fetch failed', err);
|
| 53 |
} finally {
|
| 54 |
setLoading(false);
|
| 55 |
}
|
| 56 |
-
}, [filterType, workspaceId]);
|
| 57 |
|
| 58 |
useEffect(() => {
|
| 59 |
if (activeTab === 'security') {
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
}
|
| 62 |
-
}, [activeTab,
|
| 63 |
|
| 64 |
const renderSecurityAudit = () => (
|
| 65 |
<div className={styles.auditContainer}>
|
|
@@ -74,8 +92,8 @@ export const ForensicsView: React.FC<ForensicsViewProps> = ({ workspaceId }) =>
|
|
| 74 |
<option value="workspace">WORKSPACE CONFIG</option>
|
| 75 |
</select>
|
| 76 |
</div>
|
| 77 |
-
<button className={styles.refreshBtn} onClick={fetchAuditLogs} disabled={loading}>
|
| 78 |
-
<RefreshCcw size={14} className={loading ? 'spinning' : ''} />
|
| 79 |
</button>
|
| 80 |
</div>
|
| 81 |
<div className={styles.auditBadge}>
|
|
@@ -147,6 +165,18 @@ export const ForensicsView: React.FC<ForensicsViewProps> = ({ workspaceId }) =>
|
|
| 147 |
))}
|
| 148 |
</AnimatePresence>
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
{logs.length === 0 && !loading && (
|
| 151 |
<div className={styles.emptyState}>
|
| 152 |
<Fingerprint size={48} opacity={0.2} />
|
|
|
|
| 38 |
const [logs, setLogs] = useState<AuditLog[]>([]);
|
| 39 |
const [loading, setLoading] = useState(true);
|
| 40 |
const [filterType, setFilterType] = useState<string>('');
|
| 41 |
+
const [offset, setOffset] = useState(0);
|
| 42 |
+
const [hasMore, setHasMore] = useState(true);
|
| 43 |
+
const LIMIT = 50;
|
| 44 |
|
| 45 |
+
const fetchAuditLogs = useCallback(async (isLoadMore = false) => {
|
| 46 |
setLoading(true);
|
| 47 |
try {
|
| 48 |
+
const currentOffset = isLoadMore ? offset + LIMIT : 0;
|
| 49 |
+
const params: any = {
|
| 50 |
+
limit: LIMIT,
|
| 51 |
+
offset: currentOffset
|
| 52 |
+
};
|
| 53 |
if (filterType) params.entity_type = filterType;
|
| 54 |
if (workspaceId) params.workspace_id = workspaceId;
|
| 55 |
|
| 56 |
const res = await api.get('system/audit/', { params });
|
| 57 |
+
const newLogs = res.data || [];
|
| 58 |
+
|
| 59 |
+
if (isLoadMore) {
|
| 60 |
+
setLogs(prev => [...prev, ...newLogs]);
|
| 61 |
+
} else {
|
| 62 |
+
setLogs(newLogs);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
setOffset(currentOffset);
|
| 66 |
+
setHasMore(newLogs.length === LIMIT);
|
| 67 |
} catch (err) {
|
| 68 |
console.error('Forensics fetch failed', err);
|
| 69 |
} finally {
|
| 70 |
setLoading(false);
|
| 71 |
}
|
| 72 |
+
}, [filterType, workspaceId, offset]);
|
| 73 |
|
| 74 |
useEffect(() => {
|
| 75 |
if (activeTab === 'security') {
|
| 76 |
+
setOffset(0);
|
| 77 |
+
setHasMore(true);
|
| 78 |
+
fetchAuditLogs(false);
|
| 79 |
}
|
| 80 |
+
}, [activeTab, filterType, workspaceId]);
|
| 81 |
|
| 82 |
const renderSecurityAudit = () => (
|
| 83 |
<div className={styles.auditContainer}>
|
|
|
|
| 92 |
<option value="workspace">WORKSPACE CONFIG</option>
|
| 93 |
</select>
|
| 94 |
</div>
|
| 95 |
+
<button className={styles.refreshBtn} onClick={() => fetchAuditLogs(false)} disabled={loading}>
|
| 96 |
+
<RefreshCcw size={14} className={loading && logs.length === 0 ? 'spinning' : ''} />
|
| 97 |
</button>
|
| 98 |
</div>
|
| 99 |
<div className={styles.auditBadge}>
|
|
|
|
| 165 |
))}
|
| 166 |
</AnimatePresence>
|
| 167 |
|
| 168 |
+
{hasMore && logs.length > 0 && (
|
| 169 |
+
<div className={styles.paginationFooter}>
|
| 170 |
+
<button
|
| 171 |
+
className={styles.loadMoreBtn}
|
| 172 |
+
onClick={() => fetchAuditLogs(true)}
|
| 173 |
+
disabled={loading}
|
| 174 |
+
>
|
| 175 |
+
{loading ? 'SYNCHRONIZING...' : 'LOAD MORE AUDIT ENTRIES'}
|
| 176 |
+
</button>
|
| 177 |
+
</div>
|
| 178 |
+
)}
|
| 179 |
+
|
| 180 |
{logs.length === 0 && !loading && (
|
| 181 |
<div className={styles.emptyState}>
|
| 182 |
<Fingerprint size={48} opacity={0.2} />
|
tasks/system.py
CHANGED
|
@@ -154,10 +154,11 @@ async def enqueue_task(task_or_pool: Any, *args, **kwargs):
|
|
| 154 |
"enqueued_at": datetime.utcnow().isoformat(),
|
| 155 |
"latch_key_override": task_name
|
| 156 |
}
|
| 157 |
-
if "
|
| 158 |
-
task_kwargs['metadata_json']["
|
| 159 |
-
|
| 160 |
-
|
|
|
|
| 161 |
|
| 162 |
await target_pool.enqueue_job(task_name, *final_args, _queue_name=queue_name, **task_kwargs)
|
| 163 |
logger.info(f"📤 Enqueued {task_name} to {queue_name} for {entity_id}")
|
|
|
|
| 154 |
"enqueued_at": datetime.utcnow().isoformat(),
|
| 155 |
"latch_key_override": task_name
|
| 156 |
}
|
| 157 |
+
if "workspace_id" in task_kwargs:
|
| 158 |
+
task_kwargs['metadata_json']["workspace_id"] = str(task_kwargs.pop("workspace_id"))
|
| 159 |
+
elif task_name in ["generate_workspace_insights", "refresh_active_workspace_insights", "generate_workspace_story_task"]:
|
| 160 |
+
# Heuristic for workspace-primary tasks where entity_id is the workspace
|
| 161 |
+
task_kwargs['metadata_json']["workspace_id"] = str(entity_id)
|
| 162 |
|
| 163 |
await target_pool.enqueue_job(task_name, *final_args, _queue_name=queue_name, **task_kwargs)
|
| 164 |
logger.info(f"📤 Enqueued {task_name} to {queue_name} for {entity_id}")
|