feat(research): download exact saved revisions (RP26)
This commit is contained in:
parent
6ce3b68b3d
commit
5434950263
7 changed files with 320 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ import { Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'rec
|
|||
import type { CanonicalRunResult } from '@stock-bot/stock-config/canonical-research';
|
||||
import type { CanonicalMetrics } from '@stock-bot/types';
|
||||
import { actionClass } from '@/features/strategies/components/StrategyParameterForm';
|
||||
import { downloadJsonText } from '../services/downloadJsonText';
|
||||
import { downloadJsonText } from '@/utils/downloadJsonText';
|
||||
import { DatasetDownload } from './DatasetDownload';
|
||||
|
||||
const tableClass = 'w-full text-sm text-left border-collapse';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useRef, useState } from 'react';
|
||||
import { actionClass } from '@/features/strategies/components/StrategyParameterForm';
|
||||
import { downloadJsonText } from '@/utils/downloadJsonText';
|
||||
import { backtestApiV2 } from '../services/backtestApiV2';
|
||||
import { downloadJsonText } from '../services/downloadJsonText';
|
||||
|
||||
/** Changing the dataset discards pending transport state before another download is possible. */
|
||||
export function DatasetDownload({ hash }: { hash: string }) {
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
/** Save inert JSON text and release the browser URL after it consumes the click. */
|
||||
export function downloadJsonText(text: string, filename: string): void {
|
||||
const url = URL.createObjectURL(new Blob([text], { type: 'application/json' }));
|
||||
let anchor: HTMLAnchorElement | undefined;
|
||||
try {
|
||||
anchor = document.createElement('a');
|
||||
anchor.href = url;
|
||||
anchor.download = filename;
|
||||
document.body.append(anchor);
|
||||
anchor.click();
|
||||
} finally {
|
||||
setTimeout(() => URL.revokeObjectURL(url), 0);
|
||||
anchor?.remove();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue