teams.svelte 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <script>
  2. export let schueler, privat;
  3. let 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-danger={!s.konto}
  58. class:is-success={s.konto}>Konto</span>
  59. <span
  60. class="tag"
  61. class:is-danger={!s.video}
  62. class:is-success={s.video}>Video</span>
  63. <span
  64. class="tag"
  65. class:is-danger={!s.audio}
  66. class:is-success={s.audio}>Audio</span>
  67. </td>
  68. </tr>
  69. {/each}
  70. </tbody>
  71. </table>
  72. {/each}
  73. </div>
  74. </div>
  75. {/if}
  76. {#await hole_lehrer()}
  77. Hole Lehrerdaten
  78. {:then lehrer}
  79. <div class="columns">
  80. <div class="column is-two-thirds">
  81. <h3 class="title">Lehrer</h3>
  82. <table class="table is-striped">
  83. <thead>
  84. <tr>
  85. <th>Name</th>
  86. <th>Auswahlstatus (Konto, Video, Audio)</th>
  87. </tr>
  88. </thead>
  89. <tbody>
  90. {#each lehrer as l}
  91. <tr>
  92. <td>{l.name}</td>
  93. <td>
  94. <span
  95. class="tag"
  96. class:is-danger={!l.konto}
  97. class:is-success={l.konto}>Konto</span>
  98. <span
  99. class="tag"
  100. class:is-danger={!l.video}
  101. class:is-success={l.video}>Video</span>
  102. <span
  103. class="tag"
  104. class:is-danger={!l.audio}
  105. class:is-success={l.audio}>Audio</span>
  106. </td>
  107. </tr>
  108. {/each}
  109. </tbody>
  110. </table>
  111. </div>
  112. </div>
  113. {/await}