From f22e69234cd72c99cd28d419d8a974463ab39231 Mon Sep 17 00:00:00 2001 From: Kyle Heaton Date: Tue, 23 Nov 2021 15:46:05 -0500 Subject: [PATCH 1/5] Fix event_logs download functionality Functionality was previously listed but not working, as mentioned in issue @2329. This fix creates another function that calls the correct API endpoint. --- templates/operations.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/templates/operations.html b/templates/operations.html index 01849f3b4..580b4f48e 100644 --- a/templates/operations.html +++ b/templates/operations.html @@ -1392,7 +1392,7 @@

Decisions

} }, - downloadInfo(formatType) { + downloadReport(formatType) { apiV2('POST', `${this.ENDPOINT}/${this.selectedOperationID}/report`, { enable_agent_output: this.isAgentOutputSelected }) .then((res) => { this.createDownloadReport(res, `${this.selectedOperation.name}_${formatType}`); @@ -1400,6 +1400,14 @@

Decisions

.catch(() => toast('Error generating operation report.')); }, + downloadEventLogs(formatType) { + apiV2('POST', `${this.ENDPOINT}/${this.selectedOperationID}/event-logs`, { enable_agent_output: this.isAgentOutputSelected }) + .then((res) => { + this.createDownloadReport(res, `${this.selectedOperation.name}_${formatType}`); + }) + .catch(() => toast('Error generating operation report.')); + }, + downloadCSV() { const csv = []; const rows = document.querySelector('#operationsPage').querySelectorAll('table tr:not(.csv-exclude)'); @@ -1428,8 +1436,8 @@

Decisions

}, handleDownload() { - if (this.selectedReportType === 'full-report') this.downloadInfo('full-report'); - else if (this.selectedReportType === 'event-logs') this.downloadInfo('event-logs'); + if (this.selectedReportType === 'full-report') this.downloadReport('full-report'); + else if (this.selectedReportType === 'event-logs') this.downloadEventLogs('event-logs'); else if (this.selectedReportType === 'csv') this.downloadCSV(); }, From 9ab6413837dc2d8906aabb0345b45776e79c9896 Mon Sep 17 00:00:00 2001 From: Chris Jellen Date: Mon, 29 Nov 2021 16:53:46 -0800 Subject: [PATCH 2/5] Add API docs to the /operations and /operations/{id} endpoints. --- templates/operations.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/operations.html b/templates/operations.html index 580b4f48e..5e0e9c369 100644 --- a/templates/operations.html +++ b/templates/operations.html @@ -1405,7 +1405,7 @@

Decisions

.then((res) => { this.createDownloadReport(res, `${this.selectedOperation.name}_${formatType}`); }) - .catch(() => toast('Error generating operation report.')); + .catch(() => toast('Error generating event logs.')); }, downloadCSV() { From ecb9e3186f00bea1226c0b97a205fd88d43b32ad Mon Sep 17 00:00:00 2001 From: Chris Jellen Date: Tue, 30 Nov 2021 10:34:23 -0800 Subject: [PATCH 3/5] Add API docs to the /operations and /operations/{id} endpoints. --- templates/operations.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/operations.html b/templates/operations.html index 5e0e9c369..ea1bf41a8 100644 --- a/templates/operations.html +++ b/templates/operations.html @@ -1453,6 +1453,7 @@

Decisions

fileName += '.json'; } else { dataURL = window.URL.createObjectURL(data); + fileName += '.csv'; } const elem = document.createElement('a'); From bb52b55d1e5043571de3c497cc175c167c509f86 Mon Sep 17 00:00:00 2001 From: Kyle Heaton Date: Wed, 1 Dec 2021 09:54:42 -0500 Subject: [PATCH 4/5] Combine download functions --- templates/operations.html | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/templates/operations.html b/templates/operations.html index ea1bf41a8..cd88b43ec 100644 --- a/templates/operations.html +++ b/templates/operations.html @@ -1392,20 +1392,13 @@

Decisions

} }, - downloadReport(formatType) { - apiV2('POST', `${this.ENDPOINT}/${this.selectedOperationID}/report`, { enable_agent_output: this.isAgentOutputSelected }) - .then((res) => { - this.createDownloadReport(res, `${this.selectedOperation.name}_${formatType}`); - }) - .catch(() => toast('Error generating operation report.')); - }, - - downloadEventLogs(formatType) { - apiV2('POST', `${this.ENDPOINT}/${this.selectedOperationID}/event-logs`, { enable_agent_output: this.isAgentOutputSelected }) - .then((res) => { - this.createDownloadReport(res, `${this.selectedOperation.name}_${formatType}`); - }) - .catch(() => toast('Error generating event logs.')); + downloadInfo(formatType) { + const endpoint = formatType === 'full-report' ? 'report' : formatType; + apiV2('POST', `${this.ENDPOINT}/${this.selectedOperationID}/${endpoint}`, { enable_agent_output: this.isAgentOutputSelected }) + .then((res) => { + this.createDownloadReport(res, `${this.selectedOperation.name}_${formatType}`); + }) + .catch(() => toast(`Error generating operation ${formatType.replace('-', ' ')}`)); }, downloadCSV() { @@ -1436,8 +1429,8 @@

Decisions

}, handleDownload() { - if (this.selectedReportType === 'full-report') this.downloadReport('full-report'); - else if (this.selectedReportType === 'event-logs') this.downloadEventLogs('event-logs'); + if (this.selectedReportType === 'full-report') this.downloadInfo('full-report'); + else if (this.selectedReportType === 'event-logs') this.downloadInfo('event-logs'); else if (this.selectedReportType === 'csv') this.downloadCSV(); }, @@ -1453,7 +1446,6 @@

Decisions

fileName += '.json'; } else { dataURL = window.URL.createObjectURL(data); - fileName += '.csv'; } const elem = document.createElement('a'); From 4c68466d058e92195d79ad50e22b31a0a0c6a456 Mon Sep 17 00:00:00 2001 From: Kyle Heaton Date: Wed, 1 Dec 2021 09:56:34 -0500 Subject: [PATCH 5/5] Combine download functions --- templates/operations.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/operations.html b/templates/operations.html index cd88b43ec..d84469400 100644 --- a/templates/operations.html +++ b/templates/operations.html @@ -1446,6 +1446,7 @@

Decisions

fileName += '.json'; } else { dataURL = window.URL.createObjectURL(data); + fileName += '.csv'; } const elem = document.createElement('a');