@@ -298,6 +284,7 @@
versionList.addEventListener("change", () => {
const pid = pidList.value;
const version = versionList.value;
+ deletedLogs = [];
if (pid && version) {
// Set param pid, version to URL
const currentParams = new URLSearchParams(
@@ -354,27 +341,31 @@
section.className = "command-section";
section.id = `section-${cmd}`;
section.innerHTML = `
-
- ${"show " + cmd} (${data.length})
-
-
- Output 1/${data.length}
-
-
-
-
- ${
- currentVerUser
- ? ""
- : data[0].is_deleted
- ? ``
- : ``
- }
- ${data[0].filename}\n${data[0].output}
-
- `;
+
+ ${"show " + cmd} (${data.length})
+
+
+ Output 1/${data.length}
+
+
+
+
+ ${
+ currentVerUser
+ ? ""
+ : deletedLogs.some(
+ (item) => item.id === data[0].id,
+ )
+ ? ``
+ : ``
+ }
+ ${data[0].filename}
${data[0].output}
+
+ `;
logSections.appendChild(section);
@@ -382,29 +373,7 @@
const updateDisplay = () => {
const info = logsCache[`${pid}_${version}`][cmd];
const curr = info.logs[info.index];
-
- const logBlock = document.getElementById(`log-${cmd}`);
- logBlock.className = `log-block ${
- curr.is_deleted ? "soft-deleted" : ""
- }`;
-
- const currentVerUser = versionsUser.find(
- (verItem) => verItem.version === version,
- );
-
- if (!currentVerUser) {
- if (curr.is_deleted) {
- logBlock.innerHTML = `
-
-
${curr.filename}\n${curr.output}
- `;
- } else {
- logBlock.innerHTML = `
-
-
${curr.filename}\n${curr.output}
- `;
- }
- }
+ updateDisplayActionDelete(curr, cmd, version);
document.getElementById(
`page-info-${cmd}`,
@@ -437,6 +406,73 @@
loadPIDs(pidParam, versionParam);
+ // Handle delete and cancel
+ document.addEventListener("click", async (e) => {
+ const pid = pidList.value;
+ const version = versionList.value;
+
+ if (!pid || !version) return;
+
+ // Find command section
+ const section = e.target.closest(".command-section");
+ if (!section) return;
+
+ const command = section.id.replace("section-", "");
+ const info = logsCache[`${pid}_${version}`][command];
+ const index = info.index;
+ const log = info.logs[index];
+
+ const isDeleted = deletedLogs.some(
+ (item) => item.id === log.id,
+ );
+
+ // Add to delete
+ if (e.target.classList.contains("trash-btn")) {
+ if (!isDeleted) {
+ deletedLogs.push({
+ id: log.id,
+ command: command,
+ });
+ updateDisplayActionDelete(log, command, version);
+ }
+ }
+
+ // Cancel add to delete
+ if (e.target.classList.contains("cancel-trash-btn")) {
+ deletedLogs = deletedLogs.filter(
+ (item) => item.id !== log.id,
+ );
+ updateDisplayActionDelete(log, command, version);
+ }
+ });
+
+ // Update UI delete and cancel button
+ const updateDisplayActionDelete = (log, command, version) => {
+ const logBlock = document.getElementById(`log-${command}`);
+ const isDeleted = deletedLogs.some(
+ (item) => item.id === log.id,
+ );
+
+ logBlock.className = `log-block ${
+ isDeleted ? "soft-deleted" : ""
+ }`;
+
+ const currentVerUser = versionsUser.find(
+ (verItem) => verItem.version === version,
+ );
+
+ if (!currentVerUser) {
+ logBlock.innerHTML = `
+ ${
+ isDeleted
+ ? `
`
+ : `
`
+ }
+
${log.filename}\n${log.output}
+ `;
+ }
+ };
+
const copyBtn = document.getElementById("copyBtn");
const downloadBtn = document.getElementById("downloadBtn");
@@ -522,116 +558,6 @@ ${license}`.trim();
}
-
-
-