Fotoliste.html 1.1 KB

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