Fotoliste.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {#await fotos}
  2. {:then fotosFertig}
  3. {#each R.lodash.chunk(schueler, 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}
  8. <div class="grid">
  9. {#each slice as s}
  10. <div>
  11. <img src="data:image/jpg;base64,{fotosFertig[s.ID]}" 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. {/await}
  21. <style>
  22. @import 'css/main.css';
  23. .grid {
  24. display: grid;
  25. grid-template-columns: repeat(5, 1fr);
  26. grid-gap: 10px;
  27. }
  28. </style>
  29. <script>
  30. export default {
  31. computed: {
  32. fotos: async ({schueler, knex}) => {
  33. R.objection.Model.knex(R.knex({
  34. client: 'mysql',
  35. useNullAsDefault: true,
  36. connection: {
  37. host: knex.host,
  38. database: knex.name,
  39. user: knex.user,
  40. password: knex.password,
  41. charset: 'utf8'
  42. }
  43. }))
  44. let f = {}
  45. const schuelerfotos = await R.models.Schuelerfoto.query().whereIn('Schueler_ID', schueler.map(s => s.ID))
  46. schuelerfotos.forEach(element => {
  47. f[element.Schueler_ID] = Buffer.from(element.Foto, 'binary').toString('base64')
  48. })
  49. return f
  50. }
  51. },
  52. data () { return { datum: new Date().toLocaleDateString('de', {day: '2-digit', month: '2-digit', year: 'numeric'}) } },
  53. helpers: { R },
  54. }
  55. </script>