mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 20:57:13 -05:00
Fix formatting
This commit is contained in:
parent
b9fa68673d
commit
3d7dbfa61c
4 changed files with 43 additions and 36 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import type { SvelteComnponent } from 'svelte/internal';
|
import type { SvelteComnponent } from "svelte/internal";
|
||||||
import type { I18n } from "anki/i18n";
|
import type { I18n } from "anki/i18n";
|
||||||
import type pb from "anki/backend_proto";
|
import type pb from "anki/backend_proto";
|
||||||
import { getGraphData, RevlogRange } from "./graph-helpers";
|
import { getGraphData, RevlogRange } from "./graph-helpers";
|
||||||
|
|
@ -24,31 +24,40 @@
|
||||||
active = true;
|
active = true;
|
||||||
try {
|
try {
|
||||||
sourceData = await getGraphData(search, days);
|
sourceData = await getGraphData(search, days);
|
||||||
revlogRange = days > 365 || days === 0
|
revlogRange = days > 365 || days === 0 ? RevlogRange.All : RevlogRange.Year;
|
||||||
? RevlogRange.All
|
|
||||||
: RevlogRange.Year;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sourceData = null;
|
sourceData = null;
|
||||||
alert(i18n.tr(i18n.TR.STATISTICS_ERROR_FETCHING));
|
alert(i18n.tr(i18n.TR.STATISTICS_ERROR_FETCHING));
|
||||||
}
|
}
|
||||||
active = false;
|
active = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
const refresh = (event: CustomEvent) => {
|
const refresh = (event: CustomEvent) => {
|
||||||
refreshWith(event.detail.search, event.detail.days)
|
refreshWith(event.detail.search, event.detail.days);
|
||||||
}
|
};
|
||||||
|
|
||||||
refreshWith(search, days)
|
refreshWith(search, days);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if controller}
|
{#if controller}
|
||||||
<svelte:component this={controller} {i18n} {search} {days} {active} on:update={refresh} />
|
<svelte:component
|
||||||
|
this={controller}
|
||||||
|
{i18n}
|
||||||
|
{search}
|
||||||
|
{days}
|
||||||
|
{active}
|
||||||
|
on:update={refresh} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if sourceData}
|
{#if sourceData}
|
||||||
<div tabindex="-1" class="no-focus-outline">
|
<div tabindex="-1" class="no-focus-outline">
|
||||||
{#each graphs as graph}
|
{#each graphs as graph}
|
||||||
<svelte:component this={graph} {sourceData} {revlogRange} {i18n} {nightMode} />
|
<svelte:component
|
||||||
|
this={graph}
|
||||||
|
{sourceData}
|
||||||
|
{revlogRange}
|
||||||
|
{i18n}
|
||||||
|
{nightMode} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from "svelte";
|
||||||
|
|
||||||
import type { I18n } from "anki/i18n";
|
import type { I18n } from "anki/i18n";
|
||||||
import { RevlogRange } from "./graph-helpers";
|
import { RevlogRange } from "./graph-helpers";
|
||||||
|
|
@ -18,20 +18,20 @@
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
let revlogRange: RevlogRange = days > 365 || days === 0
|
let revlogRange: RevlogRange =
|
||||||
? RevlogRange.Year
|
days > 365 || days === 0 ? RevlogRange.Year : RevlogRange.All;
|
||||||
: RevlogRange.All;
|
|
||||||
|
|
||||||
let searchRange: SearchRange = search === "deck:current"
|
let searchRange: SearchRange =
|
||||||
? SearchRange.Deck
|
search === "deck:current"
|
||||||
: search === ""
|
? SearchRange.Deck
|
||||||
? SearchRange.Collection
|
: search === ""
|
||||||
: SearchRange.Custom;
|
? SearchRange.Collection
|
||||||
|
: SearchRange.Custom;
|
||||||
|
|
||||||
let displayedSearch = search;
|
let displayedSearch = search;
|
||||||
|
|
||||||
const update = () => {
|
const update = () => {
|
||||||
dispatch('update', {
|
dispatch("update", {
|
||||||
days: days,
|
days: days,
|
||||||
search: search,
|
search: search,
|
||||||
searchRange: searchRange,
|
searchRange: searchRange,
|
||||||
|
|
@ -42,11 +42,11 @@
|
||||||
switch (searchRange as SearchRange) {
|
switch (searchRange as SearchRange) {
|
||||||
case SearchRange.Deck:
|
case SearchRange.Deck:
|
||||||
search = displayedSearch = "deck:current";
|
search = displayedSearch = "deck:current";
|
||||||
update()
|
update();
|
||||||
break;
|
break;
|
||||||
case SearchRange.Collection:
|
case SearchRange.Collection:
|
||||||
search = displayedSearch = "";
|
search = displayedSearch = "";
|
||||||
update()
|
update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,11 +55,11 @@
|
||||||
switch (revlogRange as RevlogRange) {
|
switch (revlogRange as RevlogRange) {
|
||||||
case RevlogRange.Year:
|
case RevlogRange.Year:
|
||||||
days = 365;
|
days = 365;
|
||||||
update()
|
update();
|
||||||
break;
|
break;
|
||||||
case RevlogRange.All:
|
case RevlogRange.All:
|
||||||
days = 0;
|
days = 0;
|
||||||
update()
|
update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
// fetch data on enter
|
// fetch data on enter
|
||||||
if (e.key == "Enter") {
|
if (e.key == "Enter") {
|
||||||
search = displayedSearch;
|
search = displayedSearch;
|
||||||
update()
|
update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -79,7 +79,6 @@
|
||||||
const all = i18n.tr(i18n.TR.STATISTICS_RANGE_ALL_HISTORY);
|
const all = i18n.tr(i18n.TR.STATISTICS_RANGE_ALL_HISTORY);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<div class="range-box">
|
<div class="range-box">
|
||||||
<div class="spin" class:active>◐</div>
|
<div class="spin" class:active>◐</div>
|
||||||
|
|
||||||
|
|
@ -101,7 +100,7 @@
|
||||||
bind:value={displayedSearch}
|
bind:value={displayedSearch}
|
||||||
on:keyup={searchKeyUp}
|
on:keyup={searchKeyUp}
|
||||||
on:focus={() => {
|
on:focus={() => {
|
||||||
searchRange = SearchRange.Custom;
|
searchRange = SearchRange.Custom;
|
||||||
}}
|
}}
|
||||||
placeholder={searchLabel} />
|
placeholder={searchLabel} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import type { SvelteComponent } from 'svelte/internal';
|
import type { SvelteComponent } from "svelte/internal";
|
||||||
|
|
||||||
import { setupI18n } from "anki/i18n";
|
import { setupI18n } from "anki/i18n";
|
||||||
import GraphsPage from "./GraphsPage.svelte";
|
import GraphsPage from "./GraphsPage.svelte";
|
||||||
import { checkNightMode } from "anki/nightmode";
|
import { checkNightMode } from "anki/nightmode";
|
||||||
|
|
||||||
export { default as RangeBox } from './RangeBox.svelte';
|
export { default as RangeBox } from "./RangeBox.svelte";
|
||||||
|
|
||||||
export { default as IntervalsGraph } from "./IntervalsGraph.svelte";
|
export { default as IntervalsGraph } from "./IntervalsGraph.svelte";
|
||||||
export { default as EaseGraph } from "./EaseGraph.svelte";
|
export { default as EaseGraph } from "./EaseGraph.svelte";
|
||||||
|
|
@ -23,11 +23,8 @@ export { RevlogRange } from "./graph-helpers";
|
||||||
|
|
||||||
export function graphs(
|
export function graphs(
|
||||||
target: HTMLDivElement,
|
target: HTMLDivElement,
|
||||||
graphs: SvelteComponent[], {
|
graphs: SvelteComponent[],
|
||||||
search = "deck:current",
|
{ search = "deck:current", days = 365, controller = null } = {}
|
||||||
days = 365,
|
|
||||||
controller = null,
|
|
||||||
} = {},
|
|
||||||
): void {
|
): void {
|
||||||
const nightMode = checkNightMode();
|
const nightMode = checkNightMode();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@
|
||||||
<script src="graphs.js"></script>
|
<script src="graphs.js"></script>
|
||||||
<script>
|
<script>
|
||||||
anki.graphs(
|
anki.graphs(
|
||||||
document.getElementById("main"), [
|
document.getElementById("main"),
|
||||||
|
[
|
||||||
anki.TodayStats,
|
anki.TodayStats,
|
||||||
anki.FutureDue,
|
anki.FutureDue,
|
||||||
anki.CalendarGraph,
|
anki.CalendarGraph,
|
||||||
|
|
@ -23,7 +24,8 @@
|
||||||
anki.HourGraph,
|
anki.HourGraph,
|
||||||
anki.ButtonsGraph,
|
anki.ButtonsGraph,
|
||||||
anki.AddedGraph,
|
anki.AddedGraph,
|
||||||
], {
|
],
|
||||||
|
{
|
||||||
controller: anki.RangeBox,
|
controller: anki.RangeBox,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue