📃 pdf generation in RunnersOverview

ref #62
This commit is contained in:
Philipp Dormann 2021-02-19 20:02:01 +01:00
parent 5e6ada140c
commit fa3dc870d3
3 changed files with 29 additions and 2 deletions

View File

@ -1,5 +1,6 @@
const config = { const config = {
baseurl: 'https://dev.lauf-fuer-kaya.de', baseurl: 'https://dev.lauf-fuer-kaya.de',
documentserver_key: 'NqZSYTy5AFQ7MppbLW5moqpTk7u7YrNUHKYhKYuThnnya2WpCOIU694hIZT1FzYe',
fallback_username: 'admin', fallback_username: 'admin',
fallback_password: '72fpTzsev4xUu78QPs2FCbwZ3', fallback_password: '72fpTzsev4xUu78QPs2FCbwZ3',
prefersHashRouting: true prefersHashRouting: true

View File

@ -1,5 +1,6 @@
const config = { const config = {
baseurl: 'http://localhost:4010', baseurl: 'http://localhost:4010',
documentserver_key: 'NqZSYTy5AFQ7MppbLW5moqpTk7u7YrNUHKYhKYuThnnya2WpCOIU694hIZT1FzYe'
// optional // optional
prefersHashRouting: true prefersHashRouting: true
}; };

View File

@ -1,5 +1,5 @@
<script> <script>
import { _ } from "svelte-i18n"; import { getLocaleFromNavigator, _ } from "svelte-i18n";
import { import {
RunnerService, RunnerService,
RunnerTeamService, RunnerTeamService,
@ -79,7 +79,32 @@
{#if current_runners.some((r) => r.is_selected === true)} {#if current_runners.some((r) => r.is_selected === true)}
<button <button
on:click={() => { on:click={() => {
// const locale = getLocaleFromNavigator();
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(
current_runners.filter((r) => r.is_selected === true)
),
}
)
.then((response) => response.blob())
.then((blob) => {
const url = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = url;
a.download = 'Sponsoring.pdf';
document.body.appendChild(a);
a.click();
a.remove();
})
.catch((err) => {
console.error(err);
});
}} }}
type="button" type="button"
class="w-full inline-flex 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:w-auto sm:text-sm"> class="w-full inline-flex 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:w-auto sm:text-sm">