mirror of
https://github.com/DeNNiiInc/UltyScan.git
synced 2026-04-17 20:35:59 +00:00
Fix workspace View and Export with beautiful report viewer
This commit is contained in:
@@ -116,22 +116,25 @@ async function loadWorkspaces() {
|
||||
if (result.workspaces && result.workspaces.length > 0) {
|
||||
container.innerHTML = result.workspaces
|
||||
.map(
|
||||
(ws) => `
|
||||
(ws) => {
|
||||
const name = ws.name || ws;
|
||||
const size = ws.size || '';
|
||||
const modified = ws.modified || '';
|
||||
return `
|
||||
<div class="workspace-item">
|
||||
<span class="workspace-name">${escapeHtml(ws)}</span>
|
||||
<div style="flex: 1;">
|
||||
<span class="workspace-name">${escapeHtml(name)}</span>
|
||||
${size ? `<span style="color: var(--text-secondary); font-size: 0.8rem; margin-left: 1rem;">${size}</span>` : ''}
|
||||
${modified ? `<span style="color: var(--text-secondary); font-size: 0.8rem; margin-left: 0.5rem;">| ${modified}</span>` : ''}
|
||||
</div>
|
||||
<div class="workspace-actions">
|
||||
<button class="btn btn-secondary" onclick="viewWorkspace('${escapeHtml(
|
||||
ws
|
||||
)}')">View</button>
|
||||
<button class="btn btn-secondary" onclick="exportWorkspace('${escapeHtml(
|
||||
ws
|
||||
)}')">Export</button>
|
||||
<button class="btn btn-danger" onclick="deleteWorkspace('${escapeHtml(
|
||||
ws
|
||||
)}')">Delete</button>
|
||||
<button class="btn btn-secondary" onclick="viewWorkspace('${escapeHtml(name)}')">View</button>
|
||||
<button class="btn btn-secondary" onclick="exportWorkspace('${escapeHtml(name)}')">Export</button>
|
||||
<button class="btn btn-danger" onclick="deleteWorkspace('${escapeHtml(name)}')">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
`;
|
||||
}
|
||||
)
|
||||
.join("");
|
||||
} else {
|
||||
@@ -152,8 +155,10 @@ async function viewWorkspace(name) {
|
||||
);
|
||||
const result = await response.json();
|
||||
|
||||
if (result.reportPath) {
|
||||
window.open(result.reportPath, "_blank");
|
||||
if (result.reportUrl) {
|
||||
window.open(result.reportUrl, "_blank");
|
||||
} else if (result.error) {
|
||||
showNotification(result.error, "error");
|
||||
} else {
|
||||
showNotification("No report found for this workspace.", "warning");
|
||||
}
|
||||
@@ -163,7 +168,7 @@ async function viewWorkspace(name) {
|
||||
}
|
||||
|
||||
async function exportWorkspace(name) {
|
||||
showNotification("Exporting workspace: " + name, "info");
|
||||
showNotification("Creating export for: " + name + "...", "info");
|
||||
try {
|
||||
const response = await fetch("workspaces.php", {
|
||||
method: "POST",
|
||||
@@ -172,10 +177,12 @@ async function exportWorkspace(name) {
|
||||
});
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
showNotification("Workspace exported: " + result.path, "success");
|
||||
if (result.success && result.downloadUrl) {
|
||||
showNotification(`Export ready: ${result.filename} (${result.size})`, "success");
|
||||
// Trigger download
|
||||
window.open(result.downloadUrl, "_blank");
|
||||
} else {
|
||||
showNotification("Export failed: " + result.error, "error");
|
||||
showNotification("Export failed: " + (result.error || "Unknown error"), "error");
|
||||
}
|
||||
} catch (error) {
|
||||
showNotification("Export failed.", "error");
|
||||
|
||||
Reference in New Issue
Block a user