-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
205 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,30 @@ | ||
<script lang="ts"> | ||
import "bulma/css/bulma.css"; | ||
import parser from "fast-xml-parser"; | ||
import sha1 from "jssha/dist/sha1"; | ||
import { url, server, secret, interval, status } from "./store"; | ||
import Meeting from "./Meeting.svelte"; | ||
import type { meeting } from "./types"; | ||
import Banner from "./Banner.svelte"; | ||
import Settings from "./Settings.svelte"; | ||
let meetings: Array<meeting>; | ||
let json: { response: { meetings: { meeting: meeting | Array<meeting> } } }; | ||
function getHash(message: string) { | ||
const hash = new sha1("SHA-1", "TEXT"); | ||
hash.update(`getMeetings${message}`); | ||
return hash.getHash("HEX"); | ||
} | ||
async function get_stats() { | ||
if (!$url) { | ||
json = null; | ||
return; | ||
} | ||
try { | ||
$status = "laden"; | ||
const res = await fetch($url); | ||
if (!res.ok) throw "Fehler beim Laden der Seite"; | ||
const xml = await res.text(); | ||
$status = "ok"; | ||
json = parser.parse(xml); | ||
} catch (e) { | ||
console.log("Server nicht erreichbar: ", e); | ||
json = null; | ||
$status = `Fehler: ${e}`; | ||
} | ||
} | ||
console.info( | ||
`%cWillkommen in der Konsole des BBB-Exporters. Hier kannst Du Fehler | ||
nachschauen und die Ergebnisse der Api-Abfrage als JSON auslesen. Man kann | ||
in Firefox das gesamte Objekt kopieren, wenn man mit der rechten Maustaste | ||
auf den "response"-Teil des JSON klickt. Im Texteditor eingefügt, lässt sich | ||
alles besser betrachten.`, 'color: blue' | ||
); | ||
$: $url = | ||
$server && $secret | ||
? `${$server}/bigbluebutton/api/getMeetings?checksum=${getHash($secret)}` | ||
: undefined; | ||
$: console.log("JSON: ", json); | ||
$: $url && get_stats(); | ||
$: meetings = | ||
json && [json?.response.meetings?.meeting].flat().filter(Boolean); | ||
setInterval(get_stats, $interval * 1000); | ||
import Server from "./Server.svelte"; | ||
import { server_list, selected } from "./store"; | ||
</script> | ||
|
||
<div class="container"> | ||
<Settings /> | ||
<section class="section"> | ||
{#if meetings} | ||
<Banner {json} {meetings} /> | ||
{#each meetings.filter((m) => !m.isBreakout) as meeting} | ||
<Meeting {meeting}> | ||
{#each meetings.filter((b) => | ||
[meeting.breakoutRooms?.breakout].flat().includes(b.meetingID) | ||
) as breakout} | ||
<Meeting meeting={breakout} /> | ||
{/each} | ||
</Meeting> | ||
<div class="tabs"> | ||
<ul> | ||
{#each $server_list as s} | ||
<li class:is-active={$selected === s}> | ||
<!-- svelte-ignore a11y-missing-attribute --> | ||
<a on:click={(_) => ($selected = s)} | ||
>{s.name || "Namenloser Server"}</a | ||
> | ||
</li> | ||
{/each} | ||
{:else} | ||
<Banner /> | ||
{/if} | ||
</section> | ||
<li> | ||
<!-- svelte-ignore a11y-missing-attribute --> | ||
<a> | ||
<i | ||
class="material-icons is-clickable" | ||
on:click={server_list.add}>add</i | ||
> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<Server /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script lang="ts"> | ||
import { selected } from "./store"; | ||
import parser from "fast-xml-parser"; | ||
import sha1 from "jssha/dist/sha1"; | ||
import Meeting from "./Meeting.svelte"; | ||
import type { meeting } from "./types"; | ||
import Banner from "./Banner.svelte"; | ||
let status: string | undefined = undefined; | ||
let meetings: Array<meeting>; | ||
let json: { response: { meetings: { meeting: meeting | Array<meeting> } } }; | ||
function getHash(message: string) { | ||
const hash = new sha1("SHA-1", "TEXT"); | ||
hash.update(`getMeetings${message}`); | ||
return hash.getHash("HEX"); | ||
} | ||
async function get_stats() { | ||
if (!url) { | ||
json = null; | ||
status = undefined; | ||
return; | ||
} | ||
try { | ||
status = "laden"; | ||
const res = await fetch(url); | ||
if (!res.ok) throw "Fehler beim Laden der Seite"; | ||
const xml = await res.text(); | ||
status = "ok"; | ||
json = parser.parse(xml); | ||
} catch (e) { | ||
console.log("Server nicht erreichbar: ", e); | ||
json = null; | ||
status = `Fehler: ${e}`; | ||
} | ||
} | ||
$: url = | ||
$selected.host && $selected.secret | ||
? `${$selected.host}/bigbluebutton/api/getMeetings?checksum=${getHash( | ||
$selected.secret | ||
)}` | ||
: undefined; | ||
$: $selected && get_stats(); | ||
$: meetings = | ||
json && [json?.response.meetings?.meeting].flat().filter(Boolean); | ||
setInterval(get_stats, $selected.interval * 1000); | ||
</script> | ||
|
||
{#if meetings} | ||
<Banner {json} {meetings} {status} /> | ||
{#each meetings.filter((m) => !m.isBreakout) as meeting} | ||
<Meeting {meeting}> | ||
{#each meetings.filter((b) => | ||
[meeting.breakoutRooms?.breakout].flat().includes(b.meetingID) | ||
) as breakout} | ||
<Meeting meeting={breakout} /> | ||
{/each} | ||
</Meeting> | ||
{/each} | ||
{:else} | ||
<Banner {status} /> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,56 @@ | ||
import { Writable, writable } from "svelte/store"; | ||
import type { server, CustomStore } from "./types"; | ||
|
||
export const url: Writable<string> = writable(undefined); | ||
export const status: Writable<string> = writable(undefined); | ||
export const interval: Writable<number> = writable(parseInt(window.localStorage.getItem("interval")) || 15); | ||
export const server: Writable<string> = writable(window.localStorage.getItem("server") || ""); | ||
export const secret: Writable<string> = writable(window.localStorage.getItem("secret") || ""); | ||
export const settings: Writable<boolean> = writable(!!(secret && server)); | ||
let sel: server, list: server[] | ||
|
||
function server_create() { | ||
const { subscribe, update, set }: Writable<server[]> = writable(JSON.parse(window.localStorage.getItem("servers")) || [{ name: "", host: "", secret: "", interval: 15 }]); | ||
|
||
return { | ||
subscribe, set, update, | ||
add: () => update(server => { | ||
const new_list = [...server, | ||
{ | ||
name: "", | ||
host: "", | ||
secret: "", | ||
interval: 15 | ||
} | ||
] | ||
selected.set(new_list[list.length]) | ||
settings.set(true) | ||
return new_list | ||
}), | ||
remove: () => update(server => { | ||
if (server.length === 1) { | ||
server = [{ name: "", host: "", secret: "", interval: 15 }]; | ||
selected.set(server[0]) | ||
return | ||
} | ||
for (let i = 0; i < server.length; i++) { | ||
if (server[i] === sel) { | ||
server.splice(i, 1); | ||
selected.set(server[i] || server[i - 1]); | ||
} | ||
} | ||
settings.set(false) | ||
return server | ||
}), | ||
}; | ||
} | ||
|
||
export const server_list: CustomStore<server[]> = server_create() | ||
|
||
server_list.subscribe(value => { | ||
window.localStorage.setItem(`servers`, JSON.stringify(value)); | ||
list = value | ||
}) | ||
|
||
export const selected: Writable<server> = writable(list[JSON.parse(window.localStorage.getItem("selected")) || 0]); | ||
selected.subscribe(value => { | ||
window.localStorage.setItem(`selected`, JSON.stringify(list.findIndex(s=>s === value))); | ||
sel = value | ||
server_list.set(list) | ||
}) | ||
|
||
export const settings: Writable<boolean> = writable(undefined) |
Oops, something went wrong.