teams.svelte 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <script>
  2. export let schueler, privat, einstellungen = {};
  3. let teams_anzeigen = einstellungen.teams_anzeigen;
  4. let schueler_verbergen;
  5. $: pool.query(`UPDATE einstellungen SET teams_anzeigen=$1`, [teams_anzeigen])
  6. const { Pool } = R("pg");
  7. const pool = new Pool({ connectionString: privat.mein_bk_db });
  8. async function hole_lehrer() {
  9. const query = `SELECT * from lehrer`;
  10. try {
  11. const res = await pool.query(query);
  12. console.log(res.rows);
  13. return res.rows;
  14. } catch (e) {
  15. console.log(e);
  16. return [];
  17. }
  18. }
  19. </script>
  20. <style>
  21. @import "./node_modules/bulma-tooltip/dist/css/bulma-tooltip.min.css";
  22. </style>
  23. <h3 class="title">Einverständniserklärungen Teams</h3>
  24. <div class="field">
  25. <label class="checkbox">
  26. <input type="checkbox" bind:checked={teams_anzeigen} />
  27. Teams-Seite für Schüler anzeigen
  28. </label>
  29. </div>
  30. <div class="field">
  31. <label class="checkbox">
  32. <input type="checkbox" bind:checked={schueler_verbergen} />
  33. Schüler verbergen
  34. </label>
  35. </div>
  36. {#if !schueler_verbergen}
  37. <div class="columns">
  38. <div class="column is-two-thirds">
  39. {#each Object.entries(schueler) as [klasse, schueler]}
  40. <h3 class="title">{klasse}</h3>
  41. <table class="table is-striped">
  42. <thead>
  43. <tr>
  44. <th>Name</th>
  45. <th>Vorname</th>
  46. <th>Auswahlstatus (Konto, Video, Audio)</th>
  47. </tr>
  48. </thead>
  49. <tbody>
  50. {#each schueler as s}
  51. <tr>
  52. <td>{s.Name}</td>
  53. <td>{s.Vorname}</td>
  54. <td>
  55. <span
  56. class="tag"
  57. class:is-warning={s.konto === undefined || s.konto === null}
  58. class:is-danger={s.konto === false}
  59. class:is-success={s.konto}>Konto</span>
  60. <span
  61. class="tag"
  62. class:is-warning={s.video === undefined || s.video === null}
  63. class:is-danger={s.video === false}
  64. class:is-success={s.video}>Video</span>
  65. <span
  66. class="tag"
  67. class:is-warning={s.video === undefined || s.audio === null}
  68. class:is-danger={s.audio === false}
  69. class:is-success={s.audio}>Audio</span>
  70. </td>
  71. </tr>
  72. {/each}
  73. </tbody>
  74. </table>
  75. {/each}
  76. </div>
  77. </div>
  78. {/if}
  79. {#await hole_lehrer()}
  80. Hole Lehrerdaten
  81. {:then lehrer}
  82. <div class="columns">
  83. <div class="column is-two-thirds">
  84. <h3 class="title">Lehrer</h3>
  85. <table class="table is-striped">
  86. <thead>
  87. <tr>
  88. <th>Name</th>
  89. <th>Auswahlstatus (Konto, Video, Audio)</th>
  90. </tr>
  91. </thead>
  92. <tbody>
  93. {#each lehrer as l}
  94. <tr>
  95. <td>{l.name}</td>
  96. <td>
  97. <span
  98. class="tag"
  99. class:is-warning={l.konto === undefined || l.konto === null}
  100. class:is-danger={l.konto === false}
  101. class:is-success={l.konto}>Konto</span>
  102. <span
  103. class="tag"
  104. class:is-warning={l.video === undefined || l.video === null}
  105. class:is-danger={l.video === false}
  106. class:is-success={l.video}>Video</span>
  107. <span
  108. class="tag"
  109. class:is-warning={l.audio === undefined || l.audio === null}
  110. class:is-danger={l.audio === false}
  111. class:is-success={l.audio}>Audio</span>
  112. </td>
  113. </tr>
  114. {/each}
  115. </tbody>
  116. </table>
  117. </div>
  118. </div>
  119. {/await}