123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <div class="box">
- <h3 class="title">Projektwoche</h3>
- <div class="field">
- <label class="checkbox">
- <input type="checkbox" bind:checked={prowo_anzeigen}>
- Projektwochen-Seite anzeigen
- </label>
- </div>
- <div class="field is-horizontal">
- <div class="field-body">
- <div class="field">
- <p class="control is-expanded has-icons-left">
- <label class="label is-small">Beginn der Prowo-Wahl</label>
- <input type="datetime-local" bind:value={wahlbeginn_prowo} class="input is-small">
- </p>
- </div>
- <div class="field">
- <p class="control is-expanded has-icons-left">
- <label class="label is-small">Ende der Prowo-Wahl</label>
- <input type="datetime-local" bind:value={wahlende_prowo} class="input is-small">
- </p>
- </div>
- </div>
- </div>
- <div class="field">
- <p class="control is-expanded has-icons-left">
- <label class="label is-small">Thema der Prowo</label>
- <input type="text" bind:value={thema_prowo} class="input is-expanded is-small">
- </p>
- </div>
- <div class="field">
- <button class="is-small button is-default" on:click={changeDate_prowo}> Wahlzeitraum ändern </button>
- {#if check_prowo}<span class="tag is-success">✓</span>{/if}
- </div>
- </div>
- <div class="box">
- <h3 class="title">SV-Wahl</h3>
- <div class="field">
- <label class="checkbox">
- <input type="checkbox" bind:checked={sv_anzeigen}>
- SV-Seite anzeigen
- </label>
- </div>
- <div class="field is-horizontal">
- <div class="field-body">
- <div class="field">
- <p class="control is-expanded has-icons-left">
- <label class="label is-small">Beginn der SV-Wahl</label>
- <input type="datetime-local" bind:value={wahlbeginn_sv} class="input is-small">
- </p>
- </div>
- <div class="field">
- <p class="control is-expanded has-icons-left">
- <label class="label is-small">Ende der SV-Wahl</label>
- <input type="datetime-local" bind:value={wahlende_sv} class="input is-small">
- </p>
- </div>
- </div>
- </div>
- <div class="field">
- <p class="control is-expanded has-icons-left">
- <label class="label is-small">Datum der ersten Schulkonferenz</label>
- <input type="datetime-local" bind:value={erste_schuko} class="input is-small">
- </p>
- </div>
- <div class="field">
- <button class="is-small button is-default" on:click={changeDate_sv}> Wahlzeitraum ändern </button>
- {#if check_sv}<span class="tag is-success">✓</span>{/if}
- </div>
- </div>
- <div class="box">
- <h3 class="title">Datenbank zurücksetzen</h3>
- <div class="field">
- <button class="button is-danger" on:click={db_reset}>Die Datenbank vollständig zurücksetzen</button>
- {#if check_db}<span class="tag is-success">✓</span>{/if}
- </div>
- </div>
- <script>
- export let schueler, privat, einstellungen = {}
- let check_sv, check_prowo, check_db
- const { Pool } = R('pg')
- const pool = new Pool({ connectionString: privat.mein_bk_db})
- let sv_anzeigen = einstellungen.sv_anzeigen
- let prowo_anzeigen = einstellungen.prowo_anzeigen
- let wahlbeginn_prowo = setDateTime(einstellungen.wahlbeginn_prowo)
- let wahlende_prowo = setDateTime(einstellungen.wahlende_prowo)
- let thema_prowo = einstellungen.thema_prowo || ''
- let wahlbeginn_sv = setDateTime(einstellungen.wahlbeginn_sv)
- let wahlende_sv = setDateTime(einstellungen.wahlende_sv)
- let erste_schuko = setDateTime(einstellungen.erste_schuko)
- $: pool.query(`UPDATE einstellungen SET prowo_anzeigen=$1`, [prowo_anzeigen])
- $: pool.query(`UPDATE einstellungen SET sv_anzeigen=$1`, [sv_anzeigen])
- const changeDate_prowo = async _ => {
- const query = `UPDATE einstellungen
- SET wahlbeginn_prowo=$1, wahlende_prowo=$2, thema_prowo=$3
- RETURNING wahlbeginn_prowo, wahlende_prowo, thema_prowo`
- const values = [new Date(wahlbeginn_prowo), new Date(wahlende_prowo), thema_prowo]
- try {
- const res = await pool.query(query, values)
- const data = res.rows[0]
- console.log(res)
- einstellungen.wahlbeginn_prowo = data.wahlbeginn_prowo
- einstellungen.wahlende_prowo = data.wahlende_prowo
- einstellungen.thema_prowo = data.thema_prowo
- einstellungen = einstellungen
- check_prowo = true
- } catch(err) {
- console.log(err.stack)
- }
- }
- const changeDate_sv = async _ => {
- const query = `UPDATE einstellungen
- SET wahlbeginn_sv=$1, wahlende_sv=$2, erste_schuko=$3
- RETURNING wahlbeginn_sv, wahlende_sv, erste_schuko`
- const values=[new Date(wahlbeginn_sv), new Date(wahlende_sv), new Date(erste_schuko)]
- try {
- const res = await pool.query(query, values)
- const data = res.rows[0]
- einstellungen.wahlbeginn_sv = data.wahlbeginn_sv
- einstellungen.wahlende_sv = data.wahlende_sv
- einstellungen.erste_schuko = data.erste_schuko
- einstellungen = einstellungen
- check_sv = true
- } catch(err) {
- console.log(err.stack)
- }
- }
- const db_reset = async _ => {
- const query = `BEGIN;
- DELETE FROM schueler;
- DELETE FROM wahlen;
- DELETE FROM klassen;
- DELETE FROM lehrer;
- DELETE FROM sprecher;
- DELETE FROM schuko;
- DELETE FROM verbindungslehrer;
- DELETE FROM wlan;
- DELETE FROM infos;
- COMMIT;`
- // DELETE FROM projekte,
- // DELETE FROM einstellungen,
- try {
- const res = await pool.query(query)
- check_db = true
- } catch(err) {
- console.log(err.stack)
- }
- }
- function setDateTime (date) {
- if (!date) return
- const d = new Date(date)
- return d.toISOString().replace('Z','')
- };
- </script>
|