Fotoliste.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. <h5>{slice[0].Klasse}</h5>
  7. Stand: {datum(new Date())}
  8. <div class="grid">
  9. {#each slice as s}
  10. <div>
  11. <img src="data:image/jpg;base64,{s && buffer(s.schuelerfoto.Foto)}" alt="Foto" style="width: 120px">
  12. <br>
  13. {s.Name}, {s.Vorname}
  14. </div>
  15. {/each}
  16. </div>
  17. </div>
  18. </div>
  19. {/each}
  20. {:catch error}Fehler
  21. {/await}
  22. <script>
  23. import { beforeUpdate } from 'svelte'
  24. import { datum } from './helfer'
  25. export let schueler, knexConfig
  26. const SchuelerFoto = R('models').Schueler
  27. const _ = R('lodash')
  28. SchuelerFoto.knex(R('knex')(knexConfig))
  29. const buffer = (d) => Buffer.from(d, 'binary').toString('base64')
  30. $: promise = SchuelerFoto.query().whereIn('ID', schueler.map(s => s.ID)).eager('[schuelerfoto]')
  31. </script>
  32. <style>
  33. @import 'css/main.css';
  34. .grid {
  35. display: grid;
  36. grid-template-columns: repeat(5, 1fr);
  37. grid-gap: 10px;
  38. }
  39. </style>