This commit is contained in:
forest 2023-01-07 21:19:05 -06:00
parent 61c646b66f
commit c1642f628d
3 changed files with 21 additions and 5 deletions

View file

@ -73,6 +73,15 @@ func initFrontend(config *Config) FrontendApp {
userIsLoggedIn := session.UserID != ""
if userIsLoggedIn {
if request.Method == "POST" {
for i := 0; i < 20; i++ {
roomId := request.PostFormValue(fmt.Sprintf("id_%d", i))
delete := request.PostFormValue(fmt.Sprintf("delete_%d", i))
ban := request.PostFormValue(fmt.Sprintf("ban_%d", i))
log.Printf("%s %s %s", roomId, delete, ban)
}
}
diskUsage, err := os.ReadFile("data/diskUsage.json")
if err != nil {
@ -103,7 +112,7 @@ func initFrontend(config *Config) FrontendApp {
return roomsSlice[i].Rows > roomsSlice[j].Rows
})
biggestRooms := roomsSlice[0:6]
biggestRooms := roomsSlice[0:10]
bigRoomsRowCount := 0
for i, room := range biggestRooms {
// TODO cache this ??

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>matrix-synapse diskspace janitor</title>
<title>diskspace janitor</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/static/favicon.png" />

View file

@ -20,7 +20,7 @@
<div class="horizontal space-around">
<form action="/" method="POST" class="box vertical">
<h3>delete rooms</h3>
<h3>🔨 delete rooms</h3>
{{ range $i, $room := .BigRoomsSlice }}
{{ if $room.Id }}
@ -100,15 +100,22 @@
// matrix room size chart
const top7Rooms = bigRooms.slice(0, 6);
const otherRooms = rooms.slice(6, bigRooms.length)
top7Rooms.push({
Name: "Others",
Rows: otherRooms.reduce((accumulator, room) => accumulator + room.Rows, 0)
})
const totalRows = bigRooms.reduce((accumulator, room) => accumulator + room.Rows, 0);
new Chart(document.getElementById('chart3'), {
type: 'doughnut',
data: {
labels: bigRooms.map(room => room.Name || room.Id),
labels: top7Rooms.map(room => room.Name || room.Id),
datasets: [{
label: '%',
data: bigRooms.map(room => Math.round((room.Rows/totalRows)*100)),
data: top7Rooms.map(room => Math.round((room.Rows/totalRows)*100)),
borderWidth: 2
}]
},