Skip to content

Commit

Permalink
app modified
Browse files Browse the repository at this point in the history
  • Loading branch information
cecoeco committed Apr 18, 2024
1 parent 4bece1d commit 25be032
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
8 changes: 7 additions & 1 deletion app/backend/app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Oxygen.serve(
host="0.0.0.0",
port=5050,
middleware=[CorsHandler],
docs=false,
metrics=false
)
21 changes: 6 additions & 15 deletions app/frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<void>
* @throws Error if the network response is not ok.
*/
async function postData(metricType: string, route: string): Promise<void> {
const text: string = (document.querySelector("textarea") as HTMLTextAreaElement).value;
const endpoint: string = `https://readability-jl-api.onrender.com/${route}`;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 25be032

Please sign in to comment.