mirror of
https://git.cyberia.club/cyberia/matrix-synapse-diskspace-janitor
synced 2024-05-31 14:52:12 +02:00
delete form
This commit is contained in:
parent
a2eec17b5f
commit
5df399d4ce
17
frontend.go
17
frontend.go
|
@ -104,12 +104,16 @@ func initFrontend(config *Config) FrontendApp {
|
|||
|
||||
biggestRooms := roomsSlice[0:6]
|
||||
bigRoomsRowCount := 0
|
||||
for _, room := range biggestRooms {
|
||||
for i, room := range biggestRooms {
|
||||
name, err := matrixAdmin.GetRoomName(room.Id)
|
||||
if err != nil {
|
||||
log.Printf("error getting name for '%s': %s\n", room.Id, err)
|
||||
}
|
||||
room.Name = name
|
||||
biggestRooms[i] = MatrixRoom{
|
||||
Id: room.Id,
|
||||
Name: name,
|
||||
Rows: room.Rows,
|
||||
}
|
||||
bigRoomsRowCount += room.Rows
|
||||
}
|
||||
|
||||
|
@ -122,10 +126,11 @@ func initFrontend(config *Config) FrontendApp {
|
|||
log.Println(string(bigRoomsBytes))
|
||||
|
||||
panelTemplateData := struct {
|
||||
DiskUsage template.JS
|
||||
DBTableSizes template.JS
|
||||
BigRooms template.JS
|
||||
}{template.JS(diskUsage), template.JS(dbTableSizes), template.JS(bigRoomsBytes)}
|
||||
DiskUsage template.JS
|
||||
DBTableSizes template.JS
|
||||
BigRooms template.JS
|
||||
BigRoomsSlice []MatrixRoom
|
||||
}{template.JS(diskUsage), template.JS(dbTableSizes), template.JS(bigRoomsBytes), biggestRooms}
|
||||
|
||||
app.buildPageFromTemplate(responseWriter, request, session, "panel.html", panelTemplateData)
|
||||
} else {
|
||||
|
|
|
@ -18,6 +18,27 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div class="horizontal space-around">
|
||||
<form action="/" method="POST" class="box vertical">
|
||||
<h3>delete rooms</h3>
|
||||
|
||||
{{ range $i, $room := .BigRoomsSlice }}
|
||||
<label for="delete_{{ $i }}" class="horizontal">
|
||||
DELETE
|
||||
|
||||
<input type="checkbox" id="delete_{{ $i }}" name="delete_{{ $i }}"></input>
|
||||
<input type="text" disabled name="id_{{ $i }}" value="{{ $room.Id }}"></input>
|
||||
<input type="text" disabled value="{{ $room.Name }}"></input>
|
||||
<input type="text" disabled name="rows_{{ $i }}" value="{{ $room.Rows }}"></input>
|
||||
</label>
|
||||
{{ end }}
|
||||
|
||||
<input type="password" name="password" placeholder="password"></input>
|
||||
|
||||
<input type="submit" value="SUMBIT"></input>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="static/vendor/chart.js"></script>
|
||||
<script>
|
||||
|
||||
|
|
|
@ -251,7 +251,8 @@ func (admin *MatrixAdmin) GetRoomName(roomId string) (string, error) {
|
|||
return responseObject.CanonicalAlias, nil
|
||||
}
|
||||
if responseObject.Name != "" {
|
||||
return responseObject.Name, nil
|
||||
roomIdSplit := strings.Split(roomId, ":")
|
||||
return fmt.Sprintf("%s: %s", roomIdSplit[1], responseObject.Name), nil
|
||||
}
|
||||
return roomId, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue