Merge pull request 'feature/10-dashboard-stats' (#21) from feature/10-dashboard-stats into develop

Reviewed-on: #21closes #10
This commit is contained in:
Philipp Dormann 2020-12-31 16:58:16 +00:00
commit 6ed818ef2d
5 changed files with 162 additions and 90 deletions

View File

@ -273,6 +273,7 @@ import store from "../store";
<div class="shadow px-6 pt-4 pb-1"> <div class="shadow px-6 pt-4 pb-1">
<BreadcrumbNav /> <BreadcrumbNav />
</div> </div>
<StatCards />
<div class="mb-8"> <div class="mb-8">
<FileUpload /> <FileUpload />
</div> </div>
@ -291,7 +292,6 @@ import store from "../store";
<div class="mb-8"> <div class="mb-8">
<Avatars /> <Avatars />
</div> </div>
<StatCards />
<div class="mb-8"> <div class="mb-8">
<Tracks /> <Tracks />
</div> </div>

View File

@ -1,7 +1,22 @@
<script> <script>
import { _ } from "svelte-i18n"; import { _ } from "svelte-i18n";
import { TrackService, StatsService } from "@odit/lfk-client-js";
const stats_promise = StatsService.statsControllerGet();
stats_promise.then((res) => {
console.log(res);
});
</script> </script>
<!-- -->
<h1>Allgemeine Statistiken</h1>
{#await stats_promise}
<div
class="bg-teal-lightest border-t-4 border-teal rounded-b text-teal-darkest px-4 py-3 shadow-md my-2"
role="alert">
<p class="font-bold">stats are being loaded...</p>
<p class="text-sm">This might take a moment 👀</p>
</div>
{:then stats}
<div <div
class="flex flex-col lg:flex-row w-full lg:space-x-2 space-y-2 lg:space-y-0 mb-2 lg:mb-4"> class="flex flex-col lg:flex-row w-full lg:space-x-2 space-y-2 lg:space-y-0 mb-2 lg:mb-4">
<div class="w-full lg:w-1/4"> <div class="w-full lg:w-1/4">
@ -12,23 +27,15 @@
<div class="text-xs uppercase font-light text-grey-500"> <div class="text-xs uppercase font-light text-grey-500">
{$_('runners')} {$_('runners')}
</div> </div>
<div class="text-xl font-bold">69</div> <div class="text-xl font-bold">{stats.total_runners}</div>
</div><svg </div>
stroke="currentColor" <svg
fill="none"
stroke-width="2"
viewBox="0 0 24 24"
stroke-linecap="round"
stroke-linejoin="round"
size="24"
class="stroke-current text-grey-500"
height="24" height="24"
width="24" width="24"
xmlns="http://www.w3.org/2000/svg"><path xmlns="http://www.w3.org/2000/svg"
d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" /> viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none" />
<circle cx="9" cy="7" r="4" /> <path
<path d="M23 21v-2a4 4 0 0 0-3-3.87" /> d="M13.49 5.48c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm-3.6 13.9l1-4.4 2.1 2v6h2v-7.5l-2.1-2 .6-3c1.3 1.5 3.3 2.5 5.5 2.5v-2c-1.9 0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5.1-.8.1l-5.2 2.2v4.7h2v-3.4l1.8-.7-1.6 8.1-4.9-1-.4 2 7 1.4z" /></svg>
<path d="M16 3.13a4 4 0 0 1 0 7.75" /></svg>
</div> </div>
</div> </div>
</div> </div>
@ -40,7 +47,7 @@
<div class="text-xs uppercase font-light text-grey-500"> <div class="text-xs uppercase font-light text-grey-500">
{$_('total-scans')} {$_('total-scans')}
</div> </div>
<div class="text-xl font-bold">1500</div> <div class="text-xl font-bold">{stats.total_scans}</div>
</div><svg </div><svg
stroke="currentColor" stroke="currentColor"
fill="none" fill="none"
@ -65,7 +72,7 @@
<div class="text-xs uppercase font-light text-grey-500"> <div class="text-xs uppercase font-light text-grey-500">
{$_('total-donations')} {$_('total-donations')}
</div> </div>
<div class="text-xl font-bold">5000,00 €</div> <div class="text-xl font-bold">{stats.total_donation}</div>
</div><svg </div><svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
height="24" height="24"
@ -83,7 +90,10 @@
<div class="text-xs uppercase font-light text-grey-500"> <div class="text-xs uppercase font-light text-grey-500">
{$_('total-distance')} {$_('total-distance')}
</div> </div>
<div class="text-xl font-bold">100.0 km</div> <div class="text-xl font-bold">
{stats.total_distance / 1000}
km
</div>
</div> </div>
<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path <svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path
d="M0 0h24v24H0z" d="M0 0h24v24H0z"
@ -93,4 +103,61 @@
</div> </div>
</div> </div>
</div> </div>
<div class="w-full lg:w-1/4">
<div
class="widget w-full p-4 rounded-lg bg-white border border-grey-100 dark:bg-grey-895 dark:border-grey-890">
<div class="flex flex-row items-center justify-between">
<div class="flex flex-col">
<div class="text-xs uppercase font-light text-grey-500">
{$_('count_teams')}
</div> </div>
<div class="text-xl font-bold">{stats.total_teams}</div>
</div>
<svg
stroke="currentColor"
fill="none"
stroke-width="2"
viewBox="0 0 24 24"
stroke-linecap="round"
stroke-linejoin="round"
size="24"
class="stroke-current text-grey-500"
height="24"
width="24"
xmlns="http://www.w3.org/2000/svg"><path
d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
<circle cx="9" cy="7" r="4" />
<path d="M23 21v-2a4 4 0 0 0-3-3.87" />
<path d="M16 3.13a4 4 0 0 1 0 7.75" /></svg>
</div>
</div>
</div>
<div class="w-full lg:w-1/4">
<div
class="widget w-full p-4 rounded-lg bg-white border border-grey-100 dark:bg-grey-895 dark:border-grey-890">
<div class="flex flex-row items-center justify-between">
<div class="flex flex-col">
<div class="text-xs uppercase font-light text-grey-500">
{$_('count_organizations')}
</div>
<div class="text-xl font-bold">{stats.total_orgs}</div>
</div>
<svg
height="24"
width="24"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z" />
<path
d="M17 11V3H7v4H3v14h8v-4h2v4h8V11h-4zM7 19H5v-2h2v2zm0-4H5v-2h2v2zm0-4H5V9h2v2zm4 4H9v-2h2v2zm0-4H9V9h2v2zm0-4H9V5h2v2zm4 8h-2v-2h2v2zm0-4h-2V9h2v2zm0-4h-2V5h2v2zm4 12h-2v-2h2v2zm0-4h-2v-2h2v2z" /></svg>
</div>
</div>
</div>
</div>
{:catch error}
<div class="text-white px-6 py-4 border-0 rounded relative mb-4 bg-red-500">
<span class="inline-block align-middle mr-8">
<b class="capitalize">{$_('general_promise_error')}</b>
{error}
</span>
</div>
{/await}

View File

@ -27,7 +27,7 @@
{:catch error} {:catch error}
<div class="text-white px-6 py-4 border-0 rounded relative mb-4 bg-red-500"> <div class="text-white px-6 py-4 border-0 rounded relative mb-4 bg-red-500">
<span class="inline-block align-middle mr-8"> <span class="inline-block align-middle mr-8">
<b class="capitalize">😢 Error</b> <b class="capitalize">{$_('general_promise_error')}</b>
{error} {error}
</span> </span>
</div> </div>

View File

@ -37,5 +37,7 @@
"hallo": "hallo", "hallo": "hallo",
"total-scans": "gesamte Scans", "total-scans": "gesamte Scans",
"total-donations": "Spendensumme", "total-donations": "Spendensumme",
"credits": "" "credits": "",
"runners": "Läufer",
"total-distance": "gelaufene Strecke"
} }

View File

@ -48,5 +48,8 @@
"by": "by", "by": "by",
"lfk-is-os": "The \"Lauf für Kaya!\" Frontend is (like all other projects for the \"LfK!\" Also) an open source project.", "lfk-is-os": "The \"Lauf für Kaya!\" Frontend is (like all other projects for the \"LfK!\" Also) an open source project.",
"oss_credit_description": "We use a lot of open source software on these projects, and would like to thank the following projects and contributors who help make open source great!", "oss_credit_description": "We use a lot of open source software on these projects, and would like to thank the following projects and contributors who help make open source great!",
"credits": "Credits" "credits": "Credits",
"count_organizations": "# Organizations",
"count_teams": "# Teams",
"general_promise_error": "😢 Error"
} }