mirror of
https://git.cyberia.club/cyberia/matrix-synapse-diskspace-janitor
synced 2024-06-12 04:32:14 +02:00
blah
This commit is contained in:
parent
61c646b66f
commit
c1642f628d
11
frontend.go
11
frontend.go
|
@ -73,6 +73,15 @@ func initFrontend(config *Config) FrontendApp {
|
||||||
|
|
||||||
userIsLoggedIn := session.UserID != ""
|
userIsLoggedIn := session.UserID != ""
|
||||||
if userIsLoggedIn {
|
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")
|
diskUsage, err := os.ReadFile("data/diskUsage.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -103,7 +112,7 @@ func initFrontend(config *Config) FrontendApp {
|
||||||
return roomsSlice[i].Rows > roomsSlice[j].Rows
|
return roomsSlice[i].Rows > roomsSlice[j].Rows
|
||||||
})
|
})
|
||||||
|
|
||||||
biggestRooms := roomsSlice[0:6]
|
biggestRooms := roomsSlice[0:10]
|
||||||
bigRoomsRowCount := 0
|
bigRoomsRowCount := 0
|
||||||
for i, room := range biggestRooms {
|
for i, room := range biggestRooms {
|
||||||
// TODO cache this ??
|
// TODO cache this ??
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>matrix-synapse diskspace janitor</title>
|
<title>diskspace janitor</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<link rel="shortcut icon" href="/static/favicon.png" />
|
<link rel="shortcut icon" href="/static/favicon.png" />
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<div class="horizontal space-around">
|
<div class="horizontal space-around">
|
||||||
<form action="/" method="POST" class="box vertical">
|
<form action="/" method="POST" class="box vertical">
|
||||||
<h3>delete rooms</h3>
|
<h3>🔨 delete rooms</h3>
|
||||||
|
|
||||||
{{ range $i, $room := .BigRoomsSlice }}
|
{{ range $i, $room := .BigRoomsSlice }}
|
||||||
{{ if $room.Id }}
|
{{ if $room.Id }}
|
||||||
|
@ -100,15 +100,22 @@
|
||||||
|
|
||||||
|
|
||||||
// matrix room size chart
|
// 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);
|
const totalRows = bigRooms.reduce((accumulator, room) => accumulator + room.Rows, 0);
|
||||||
|
|
||||||
new Chart(document.getElementById('chart3'), {
|
new Chart(document.getElementById('chart3'), {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: bigRooms.map(room => room.Name || room.Id),
|
labels: top7Rooms.map(room => room.Name || room.Id),
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: '%',
|
label: '%',
|
||||||
data: bigRooms.map(room => Math.round((room.Rows/totalRows)*100)),
|
data: top7Rooms.map(room => Math.round((room.Rows/totalRows)*100)),
|
||||||
borderWidth: 2
|
borderWidth: 2
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue