PDF download from TeamDetail + TeamsOverview

ref #62
This commit is contained in:
2021-02-20 16:53:30 +01:00
parent 289a8c14d3
commit dbc0ab76af
3 changed files with 91 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
RunnerOrganizationService,
RunnerTeamService,
} from "@odit/lfk-client-js";
import { _ } from "svelte-i18n";
import { getLocaleFromNavigator, _ } from "svelte-i18n";
import Toastify from "toastify-js";
import store from "../../store";
import ImportRunnerModal from "../runners/ImportRunnerModal.svelte";
@@ -100,6 +100,34 @@
<div class="mb-8 text-3xl font-extrabold leading-tight">
{original.name}
<span data-id="org_actions_${teamdata.id}">
<button
on:click={async () => {
const locale = getLocaleFromNavigator();
const runners = await RunnerTeamService.runnerTeamControllerGetRunners(teamdata.id);
fetch(
`https://dev.lauf-fuer-kaya.de/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(runners),
}
)
.then((response) => response.blob())
.then((blob) => {
const url = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = url;
a.download = 'Sponsorings_' + teamdata.name + '.pdf';
document.body.appendChild(a);
a.click();
a.remove();
})
.catch((err) => {});
}}
type="button"
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:ml-3 sm:w-auto sm:text-sm">{$_('generate-sponsoring-contracts')}</button>
{#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')}
<button
on:click={() => {
@@ -255,7 +283,7 @@
</section>
{:else}
{#await promise}
team detail is being loaded...
{$_('team-detail-is-being-loaded')}
{:catch error}
<PromiseError />
{/await}