teams.svelte 3.0 KB

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