Fix formatting
This commit is contained in:
parent
b9fa68673d
commit
3d7dbfa61c
@ -3,7 +3,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="typescript">
|
||||
import type { SvelteComnponent } from 'svelte/internal';
|
||||
import type { SvelteComnponent } from "svelte/internal";
|
||||
import type { I18n } from "anki/i18n";
|
||||
import type pb from "anki/backend_proto";
|
||||
import { getGraphData, RevlogRange } from "./graph-helpers";
|
||||
@ -24,31 +24,40 @@
|
||||
active = true;
|
||||
try {
|
||||
sourceData = await getGraphData(search, days);
|
||||
revlogRange = days > 365 || days === 0
|
||||
? RevlogRange.All
|
||||
: RevlogRange.Year;
|
||||
revlogRange = days > 365 || days === 0 ? RevlogRange.All : RevlogRange.Year;
|
||||
} catch (e) {
|
||||
sourceData = null;
|
||||
alert(i18n.tr(i18n.TR.STATISTICS_ERROR_FETCHING));
|
||||
}
|
||||
active = false;
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
{#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 sourceData}
|
||||
<div tabindex="-1" class="no-focus-outline">
|
||||
{#each graphs as graph}
|
||||
<svelte:component this={graph} {sourceData} {revlogRange} {i18n} {nightMode} />
|
||||
<svelte:component
|
||||
this={graph}
|
||||
{sourceData}
|
||||
{revlogRange}
|
||||
{i18n}
|
||||
{nightMode} />
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script lang="typescript">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import type { I18n } from "anki/i18n";
|
||||
import { RevlogRange } from "./graph-helpers";
|
||||
@ -18,20 +18,20 @@
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let revlogRange: RevlogRange = days > 365 || days === 0
|
||||
? RevlogRange.Year
|
||||
: RevlogRange.All;
|
||||
let revlogRange: RevlogRange =
|
||||
days > 365 || days === 0 ? RevlogRange.Year : RevlogRange.All;
|
||||
|
||||
let searchRange: SearchRange = search === "deck:current"
|
||||
? SearchRange.Deck
|
||||
: search === ""
|
||||
? SearchRange.Collection
|
||||
: SearchRange.Custom;
|
||||
let searchRange: SearchRange =
|
||||
search === "deck:current"
|
||||
? SearchRange.Deck
|
||||
: search === ""
|
||||
? SearchRange.Collection
|
||||
: SearchRange.Custom;
|
||||
|
||||
let displayedSearch = search;
|
||||
|
||||
const update = () => {
|
||||
dispatch('update', {
|
||||
dispatch("update", {
|
||||
days: days,
|
||||
search: search,
|
||||
searchRange: searchRange,
|
||||
@ -42,11 +42,11 @@
|
||||
switch (searchRange as SearchRange) {
|
||||
case SearchRange.Deck:
|
||||
search = displayedSearch = "deck:current";
|
||||
update()
|
||||
update();
|
||||
break;
|
||||
case SearchRange.Collection:
|
||||
search = displayedSearch = "";
|
||||
update()
|
||||
update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -55,11 +55,11 @@
|
||||
switch (revlogRange as RevlogRange) {
|
||||
case RevlogRange.Year:
|
||||
days = 365;
|
||||
update()
|
||||
update();
|
||||
break;
|
||||
case RevlogRange.All:
|
||||
days = 0;
|
||||
update()
|
||||
update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@
|
||||
// fetch data on enter
|
||||
if (e.key == "Enter") {
|
||||
search = displayedSearch;
|
||||
update()
|
||||
update();
|
||||
}
|
||||
};
|
||||
|
||||
@ -79,7 +79,6 @@
|
||||
const all = i18n.tr(i18n.TR.STATISTICS_RANGE_ALL_HISTORY);
|
||||
</script>
|
||||
|
||||
|
||||
<div class="range-box">
|
||||
<div class="spin" class:active>◐</div>
|
||||
|
||||
@ -101,7 +100,7 @@
|
||||
bind:value={displayedSearch}
|
||||
on:keyup={searchKeyUp}
|
||||
on:focus={() => {
|
||||
searchRange = SearchRange.Custom;
|
||||
searchRange = SearchRange.Custom;
|
||||
}}
|
||||
placeholder={searchLabel} />
|
||||
</div>
|
||||
|
@ -1,13 +1,13 @@
|
||||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// 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 GraphsPage from "./GraphsPage.svelte";
|
||||
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 EaseGraph } from "./EaseGraph.svelte";
|
||||
@ -23,11 +23,8 @@ export { RevlogRange } from "./graph-helpers";
|
||||
|
||||
export function graphs(
|
||||
target: HTMLDivElement,
|
||||
graphs: SvelteComponent[], {
|
||||
search = "deck:current",
|
||||
days = 365,
|
||||
controller = null,
|
||||
} = {},
|
||||
graphs: SvelteComponent[],
|
||||
{ search = "deck:current", days = 365, controller = null } = {}
|
||||
): void {
|
||||
const nightMode = checkNightMode();
|
||||
|
||||
|
@ -12,7 +12,8 @@
|
||||
<script src="graphs.js"></script>
|
||||
<script>
|
||||
anki.graphs(
|
||||
document.getElementById("main"), [
|
||||
document.getElementById("main"),
|
||||
[
|
||||
anki.TodayStats,
|
||||
anki.FutureDue,
|
||||
anki.CalendarGraph,
|
||||
@ -23,7 +24,8 @@
|
||||
anki.HourGraph,
|
||||
anki.ButtonsGraph,
|
||||
anki.AddedGraph,
|
||||
], {
|
||||
],
|
||||
{
|
||||
controller: anki.RangeBox,
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user