2020-06-22 11:11:50 +02:00
|
|
|
<script context="module">
|
|
|
|
import style from "./graphs.css";
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="typescript">
|
|
|
|
import { assertUnreachable } from "../typing";
|
2020-06-27 11:24:49 +02:00
|
|
|
import { I18n } from "../i18n";
|
2020-06-22 11:11:50 +02:00
|
|
|
import pb from "../backend/proto";
|
2020-06-27 07:35:34 +02:00
|
|
|
import { getGraphData, RevlogRange } from "./graphs";
|
2020-06-22 11:11:50 +02:00
|
|
|
import IntervalsGraph from "./IntervalsGraph.svelte";
|
2020-06-23 12:43:19 +02:00
|
|
|
import EaseGraph from "./EaseGraph.svelte";
|
2020-06-24 01:41:07 +02:00
|
|
|
import AddedGraph from "./AddedGraph.svelte";
|
2020-06-26 02:42:10 +02:00
|
|
|
import TodayStats from "./TodayStats.svelte";
|
|
|
|
import ButtonsGraph from "./ButtonsGraph.svelte";
|
|
|
|
import CardCounts from "./CardCounts.svelte";
|
2020-06-26 06:05:58 +02:00
|
|
|
import HourGraph from "./HourGraph.svelte";
|
2020-06-26 11:25:02 +02:00
|
|
|
import FutureDue from "./FutureDue.svelte";
|
2020-06-27 04:35:13 +02:00
|
|
|
import ReviewsGraph from "./ReviewsGraph.svelte";
|
2020-06-22 11:11:50 +02:00
|
|
|
|
2020-06-27 11:24:49 +02:00
|
|
|
export let i18n: I18n;
|
|
|
|
|
2020-06-26 02:42:10 +02:00
|
|
|
let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-06-22 11:11:50 +02:00
|
|
|
|
2020-06-22 12:28:36 +02:00
|
|
|
enum SearchRange {
|
|
|
|
Deck = 1,
|
|
|
|
Collection = 2,
|
|
|
|
Custom = 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
let searchRange: SearchRange = SearchRange.Deck;
|
2020-06-27 07:35:34 +02:00
|
|
|
let revlogRange: RevlogRange = RevlogRange.Month;
|
2020-06-22 11:11:50 +02:00
|
|
|
let days: number = 31;
|
2020-06-26 07:34:21 +02:00
|
|
|
let refreshing = false;
|
2020-06-22 11:11:50 +02:00
|
|
|
|
2020-06-22 12:28:36 +02:00
|
|
|
let search = "deck:current";
|
2020-06-22 13:39:16 +02:00
|
|
|
let displayedSearch = search;
|
2020-06-22 12:28:36 +02:00
|
|
|
|
2020-06-22 11:11:50 +02:00
|
|
|
const refresh = async () => {
|
2020-06-26 07:34:21 +02:00
|
|
|
refreshing = true;
|
2020-06-26 02:42:10 +02:00
|
|
|
sourceData = await getGraphData(search, days);
|
2020-06-26 07:34:21 +02:00
|
|
|
refreshing = false;
|
2020-06-22 11:11:50 +02:00
|
|
|
};
|
|
|
|
|
2020-06-22 13:39:16 +02:00
|
|
|
$: {
|
|
|
|
// refresh if either of these change
|
|
|
|
search;
|
|
|
|
days;
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2020-06-22 12:28:36 +02:00
|
|
|
$: {
|
|
|
|
switch (searchRange as SearchRange) {
|
|
|
|
case SearchRange.Deck:
|
2020-06-22 13:39:16 +02:00
|
|
|
search = displayedSearch = "deck:current";
|
2020-06-22 12:28:36 +02:00
|
|
|
break;
|
|
|
|
case SearchRange.Collection:
|
2020-06-22 13:39:16 +02:00
|
|
|
search = displayedSearch = "";
|
2020-06-22 12:28:36 +02:00
|
|
|
break;
|
|
|
|
case SearchRange.Custom:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-22 11:11:50 +02:00
|
|
|
$: {
|
2020-06-27 07:35:34 +02:00
|
|
|
switch (revlogRange as RevlogRange) {
|
|
|
|
case RevlogRange.Month:
|
2020-06-22 11:11:50 +02:00
|
|
|
days = 31;
|
|
|
|
break;
|
2020-06-27 07:35:34 +02:00
|
|
|
case RevlogRange.Year:
|
2020-06-22 11:11:50 +02:00
|
|
|
days = 365;
|
|
|
|
break;
|
2020-06-27 07:35:34 +02:00
|
|
|
case RevlogRange.All:
|
2020-06-22 11:11:50 +02:00
|
|
|
days = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-22 13:39:16 +02:00
|
|
|
const searchKeyUp = (e: KeyboardEvent) => {
|
|
|
|
// fetch data on enter
|
|
|
|
if (e.keyCode == 13) {
|
|
|
|
search = displayedSearch;
|
|
|
|
}
|
|
|
|
};
|
2020-06-22 11:11:50 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="range-box">
|
2020-06-26 07:34:21 +02:00
|
|
|
<div class="spin {refreshing ? 'active' : ''}">◐</div>
|
|
|
|
|
|
|
|
<div class="range-box-inner">
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={searchRange} value={SearchRange.Deck} />
|
|
|
|
Deck
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
bind:group={searchRange}
|
|
|
|
value={SearchRange.Collection} />
|
|
|
|
Collection
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={searchRange} value={SearchRange.Custom} />
|
|
|
|
Custom
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<input type="text" bind:value={displayedSearch} on:keyup={searchKeyUp} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="range-box-inner">
|
|
|
|
Review history:
|
|
|
|
<label>
|
2020-06-27 07:35:34 +02:00
|
|
|
<input type="radio" bind:group={revlogRange} value={RevlogRange.Month} />
|
2020-06-26 07:34:21 +02:00
|
|
|
Month
|
|
|
|
</label>
|
|
|
|
<label>
|
2020-06-27 07:35:34 +02:00
|
|
|
<input type="radio" bind:group={revlogRange} value={RevlogRange.Year} />
|
2020-06-26 07:34:21 +02:00
|
|
|
Year
|
|
|
|
</label>
|
|
|
|
<label>
|
2020-06-27 07:35:34 +02:00
|
|
|
<input type="radio" bind:group={revlogRange} value={RevlogRange.All} />
|
2020-06-26 07:34:21 +02:00
|
|
|
All
|
|
|
|
</label>
|
|
|
|
</div>
|
2020-06-22 11:11:50 +02:00
|
|
|
</div>
|
2020-06-26 07:34:21 +02:00
|
|
|
<div class="range-box-pad" />
|
2020-06-22 11:11:50 +02:00
|
|
|
|
2020-06-27 11:24:49 +02:00
|
|
|
<TodayStats {sourceData} {i18n} />
|
2020-06-26 02:42:10 +02:00
|
|
|
<CardCounts {sourceData} />
|
2020-06-27 07:35:34 +02:00
|
|
|
<FutureDue {sourceData} />
|
|
|
|
<ReviewsGraph {sourceData} {revlogRange} />
|
2020-06-26 02:42:10 +02:00
|
|
|
<IntervalsGraph {sourceData} />
|
|
|
|
<EaseGraph {sourceData} />
|
|
|
|
<ButtonsGraph {sourceData} />
|
2020-06-26 06:05:58 +02:00
|
|
|
<HourGraph {sourceData} />
|
2020-06-26 11:25:02 +02:00
|
|
|
<AddedGraph {sourceData} />
|