a8d4774cdb
* Add _bytes methods for all methods in the backend Expose get_note in qt/aqt/mediasrv.py * Satisfy formatter * Rename _bytes function to _raw and have them bytes as input * Fix backend generation * Use lib/proto/deckOptions in deck-options * Add exposed_backend to qt/aqt/mediasrv.py * Move some more backend methods to exposed_backend_list * Use protobufjs for congrats and i18n * Use protobufjs for completeTag * Use protobufjs services in change-notetype * Reorder post handlers in alphabetical manner * Satisfy tests * Remove unused collection methods * Rename access_backend to raw_backend_request * Use _vendor.stringcase instead of creating a new function * Remove SKIP_UNROLL_OUTPUT * Directly call _run_command in non _raw methods * Remove TranslateString, ChangeNotetype and CompleteTag from SKIP_UNROLL_INPUT * Remove UpdateDeckConfigs from SKIP_UNROLL_INPUT * Remove ChangeNotetype from SKIP_UNROLL_INPUT * Remove SKIP_UNROLL_INPUT * Fix typing issue with translate_string - Adds typing support for Protobuf maps in genbackend.py * Do not emit convenience method for protobuf TranslateString
65 lines
1.8 KiB
Svelte
65 lines
1.8 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script lang="ts">
|
|
import type { Writable } from "svelte/store";
|
|
import { Stats } from "../lib/proto";
|
|
import { stats, empty } from "../lib/proto";
|
|
import type { PreferenceRaw } from "../sveltelib/preferences";
|
|
import useAsync from "../sveltelib/async";
|
|
import useAsyncReactive from "../sveltelib/asyncReactive";
|
|
import { getPreferences } from "../sveltelib/preferences";
|
|
import { daysToRevlogRange } from "./graph-helpers";
|
|
|
|
export let search: Writable<string>;
|
|
export let days: Writable<number>;
|
|
|
|
const {
|
|
loading: graphLoading,
|
|
error: graphError,
|
|
value: graphValue,
|
|
} = useAsyncReactive(
|
|
() => stats.graphs({ search: $search, days: $days }),
|
|
[search, days],
|
|
);
|
|
|
|
const {
|
|
loading: prefsLoading,
|
|
error: prefsError,
|
|
value: prefsValue,
|
|
} = useAsync(() =>
|
|
getPreferences(
|
|
() => stats.getGraphPreferences(empty),
|
|
async (input: Stats.IGraphPreferences): Promise<void> => {
|
|
stats.setGraphPreferences(input);
|
|
},
|
|
Stats.GraphPreferences.toObject.bind(Stats.GraphPreferences) as (
|
|
preferences: Stats.GraphPreferences,
|
|
options: { defaults: boolean },
|
|
) => PreferenceRaw<Stats.GraphPreferences>,
|
|
),
|
|
);
|
|
|
|
$: revlogRange = daysToRevlogRange($days);
|
|
|
|
$: {
|
|
if ($graphError) {
|
|
alert($graphError);
|
|
}
|
|
}
|
|
|
|
$: {
|
|
if ($prefsError) {
|
|
alert($prefsError);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<slot
|
|
{revlogRange}
|
|
loading={$graphLoading || $prefsLoading}
|
|
sourceData={$graphValue}
|
|
preferences={$prefsValue}
|
|
/>
|