From 25be032b1b8f2d897928b4360cf07b109a29af05 Mon Sep 17 00:00:00 2001 From: webofceco Date: Thu, 18 Apr 2024 06:11:31 -0400 Subject: [PATCH] app modified --- app/backend/app.jl | 8 +++++++- app/frontend/src/routes/index.tsx | 21 ++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/backend/app.jl b/app/backend/app.jl index b277a5d..7e21a47 100644 --- a/app/backend/app.jl +++ b/app/backend/app.jl @@ -50,4 +50,10 @@ for (endpoint, readability_function) in readability_endpoints post_request_handler(endpoint, readability_function) end -Oxygen.serve(host="0.0.0.0", port=5050, middleware=[CorsHandler]) \ No newline at end of file +Oxygen.serve( + host="0.0.0.0", + port=5050, + middleware=[CorsHandler], + docs=false, + metrics=false +) \ No newline at end of file diff --git a/app/frontend/src/routes/index.tsx b/app/frontend/src/routes/index.tsx index 14de79a..46c6e3b 100644 --- a/app/frontend/src/routes/index.tsx +++ b/app/frontend/src/routes/index.tsx @@ -71,12 +71,6 @@ function Metrics() { setSelectedMetrics(allMetrics); }; - /** - * Closes the dropdown if the click event target does not have a parent - * element with the class "dropdown". - * - * @param {MouseEvent} event - The click event. - */ const closeDropdownOnOutsideClick = (event: MouseEvent) => { if (!(event.target as Element).closest(".dropdown")) { setIsDropdownOpen(false); @@ -181,13 +175,6 @@ function Metrics() { "Words": 0, }); - /** - * Sends a POST request to the specified route with the provided text data. - * @param metricType The name of the metric to update in the metricResponses signal. - * @param route The API route to send the request to. - * @returns Promise - * @throws Error if the network response is not ok. - */ async function postData(metricType: string, route: string): Promise { const text: string = (document.querySelector("textarea") as HTMLTextAreaElement).value; const endpoint: string = `https://readability-jl-api.onrender.com/${route}`; @@ -261,13 +248,17 @@ function Metrics() { } function downloadMetrics() { - const data: { [key: string]: number } = metricResponses(); + const data = metricResponses(); const csvContent = "data:text/csv;charset=utf-8," + "metric,value\n" + Object.keys(data) .map((key) => { - return `${key},${data[key]}`; + let formattedValue: string | number = data[key]; + if (key === "Average Reading Time" || key === "Average Speaking Time") { + formattedValue = `${formattedValue} seconds`; + } + return `${key},${formattedValue}`; }) .join("\n"); const encodedUri = encodeURI(csvContent);