8}
9
10export function SettingsPanel({ settings, onSave, onCancel }: SettingsPanelProps) {
11 const [localSettings, setLocalSettings] = React.useState(settings);
12
14}
15
16export function ResultsDisplay({
17 settings,
18 options,
47 tooltip: {
48 trigger: 'axis',
49 formatter: function(params: any) {
50 const point = params[0];
51 return `
89 show: true,
90 position: 'top',
91 formatter: function(params: any) {
92 const dataIndex = params.dataIndex;
93 const goalValue = sortedData[dataIndex].value;
17}
18
19export function ProbabilityInputForm({
20 settings,
21 options,
8}
9
10export function GoalBarChart({ pastGoals, settings, showTodayPlaceholder = false }: GoalBarChartProps) {
11 const extractGoalAmount = (title: string) => {
12 const match = title.match(/My goal is ([\d.]+)/);
12}
13
14export async function fetchPastGoals(apiKey: string): Promise<FatebookGoal[]> {
15 const response = await fetch('/api/fatebook-goals', {
16 method: 'POST',
27}
28
29export async function createFatebookGoal(
30 apiKey: string,
31 goalValue: number,
1import { Settings } from "./storage.ts";
2
3export function getOptions(settings: Settings): number[] {
4 const options = [];
5 for (let i = settings.minValue; i <= settings.maxValue; i += settings.increment) {
9}
10
11export function calculateExpectedValues(options: number[], probabilities: Record<number, number>) {
12 return options.map(value => ({
13 value,
17}
18
19export function getUnit(settings: Settings, value: number): string {
20 if (settings.usePomodoros) {
21 return value === 1 ? 'pomodoro' : 'pomodoros';
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
50}
51
52async function batch(
53 statements: InStatement[],
54 mode?: TransactionMode,
69}
70
71function createResError(body: string) {
72 try {
73 const e = zLibsqlError.parse(JSON.parse(body));
120 *
121 * The types are currently shown for types declared in a SQL table. For
122 * column types of function calls, for example, an empty string is
123 * returned.
124 */
1export async function emailValHandler(email: Email) {
2 console.log("Email received!", email.from, email.subject, email.text);
3 for (const file of email.attachments) {
1export default async function(req: Request): Promise<Response> {
2 const corsHeaders = {
3 "Access-Control-Allow-Origin": "*",
194}
195
196async function applyImageEffect(imageBlob: Blob, effect: string, intensity: number): Promise<ArrayBuffer> {
197 // For now, let's just return the original image with some metadata modification
198 // This ensures we return valid image data while we work on proper effects