Fotoliste.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. {#await promise}Fotos kommen…
  2. {:then fotos}
  3. {#each chunk(fotos, 25) as slice}
  4. <div class="page grid" orientation="portrait" size="A4">
  5. <div class="main">
  6. <b>{slice[0].Klasse}</b>
  7. Stand: {datum(new Date())}
  8. <div class="grid" style="font-size: 0.8rem">
  9. {#each slice as s}
  10. <div>
  11. {#if s.schuelerfoto}
  12. <img src="data:image/jpg;base64,{buffer(s.schuelerfoto.Foto)}" alt="Foto" style="width: 120px">
  13. {:else}
  14. Kein Foto
  15. {/if}
  16. <br>
  17. {s.Name}, {s.Vorname}
  18. </div>
  19. {/each}
  20. </div>
  21. </div>
  22. </div>
  23. {/each}
  24. {:catch error}Fehler
  25. {/await}
  26. <script>
  27. import { datum, chunk } from './helfer'
  28. export let schueler, knexConfig
  29. const SchuelerFoto = R('models').Schueler
  30. SchuelerFoto.knex(R('knex')(knexConfig))
  31. const buffer = (d) => Buffer.from(d, 'binary').toString('base64')
  32. $: promise = SchuelerFoto.query().whereIn('ID', schueler.map(s => s.ID)).eager('[schuelerfoto]').orderBy('Name')
  33. </script>
  34. <style>
  35. @import 'css/main.css';
  36. .grid {
  37. display: grid;
  38. grid-template-columns: repeat(5, 1fr);
  39. grid-gap: 10px;
  40. }
  41. </style>