ui fix
This commit is contained in:
parent
8261e79d4f
commit
692e6fe237
@ -5,7 +5,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
|||||||
const { apiURL, apiKey } = locals;
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
const postData = { ticker: data?.ticker, timePeriod: data?.timePeriod };
|
const postData = { ticker: data?.ticker, timePeriod: data?.timePeriod };
|
||||||
const response = await fetch(apiURL + "/export-price-data", {
|
const response = await fetch(apiURL + "/historical-price", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -709,6 +709,48 @@
|
|||||||
|
|
||||||
async function exportData(timePeriod: string) {
|
async function exportData(timePeriod: string) {
|
||||||
let exportList = [];
|
let exportList = [];
|
||||||
|
|
||||||
|
const response = await fetch("/api/export-price-data", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ ticker: $stockTicker, timePeriod: timePeriod }),
|
||||||
|
});
|
||||||
|
|
||||||
|
exportList = await response.json();
|
||||||
|
|
||||||
|
exportList = exportList?.map(({ time, open, high, low, close, date }) => ({
|
||||||
|
date: timePeriod === "max" ? time : date, // Use 'time' if timePeriod is "max", otherwise use 'date'
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
close,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const csvRows = [];
|
||||||
|
|
||||||
|
// Add headers row
|
||||||
|
csvRows.push("time,open,high,low,close");
|
||||||
|
|
||||||
|
// Add data rows
|
||||||
|
for (const row of exportList) {
|
||||||
|
const csvRow = `${row.date},${row.open},${row.high},${row.low},${row.close}`;
|
||||||
|
csvRows.push(csvRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create CSV blob and trigger download
|
||||||
|
const csv = csvRows.join("\n");
|
||||||
|
const blob = new Blob([csv], { type: "text/csv" });
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.setAttribute("hidden", "");
|
||||||
|
a.setAttribute("href", url);
|
||||||
|
a.setAttribute("download", `${$stockTicker}_${timePeriod}.csv`);
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
/*
|
||||||
if (data?.user) {
|
if (data?.user) {
|
||||||
const response = await fetch("/api/historical-price", {
|
const response = await fetch("/api/historical-price", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -757,6 +799,7 @@
|
|||||||
style: "border-radius: 200px; background: #333; color: #fff;",
|
style: "border-radius: 200px; background: #333; color: #fff;",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateClosePrice(data, extendPriceChart) {
|
function updateClosePrice(data, extendPriceChart) {
|
||||||
@ -1097,6 +1140,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if !$stockTicker.includes(".")}
|
||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
<DropdownMenu.Trigger asChild let:builder>
|
<DropdownMenu.Trigger asChild let:builder>
|
||||||
<Button
|
<Button
|
||||||
@ -1187,6 +1231,7 @@
|
|||||||
</DropdownMenu.Group>
|
</DropdownMenu.Group>
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<!--End Time Interval-->
|
<!--End Time Interval-->
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user