{backup,snapshot}: Log and display in control

This commit is contained in:
Tom Wiesing 2022-10-03 11:22:45 +02:00
parent 3b112f1b8e
commit 630da9e12f
No known key found for this signature in database
17 changed files with 294 additions and 44 deletions

View file

@ -26,6 +26,32 @@
<b>GraphDB Database Prefix:</b> <code>{{.Config.GraphDBRepoPrefix}}</code><br />
<hr />
<b>Bookkeeping Database:</b> <code>{{.Config.DistilleryDatabase}}</code><br />
<hr />
<b>Backups:</b>
<table>
<thead>
<tr>
<th>Path</th>
<th>Created</th>
<th>Packed</th>
</tr>
</thead>
<tbody>
{{ range .Info.Backups }}
<tr>
<td>
<code class="path">{{ .Path }}</code>
</td>
<td>
<code class="date">{{ .Created.Format "2006-01-02T15:04:05Z07:00" }}</code>
</td>
<td>
{{ .Packed }}
</td>
</tr>
{{ end}}
</tbody>
</table>
</p>
<h2 id="instances">Instances</h2>

View file

@ -36,6 +36,33 @@
<hr />
<b>GraphDBRepository:</b> <code>{{ .Instance.GraphDBRepository }}</code> <br />
<b>GraphDBUsername:</b> <code>{{ .Instance.GraphDBUsername }}</code> <br />
<hr />
<b>Snapshots:</b>
<table>
<thead>
<tr>
<th>Path</th>
<th>Created</th>
<th>Packed</th>
</tr>
</thead>
<tbody>
{{ range .Info.Snapshots }}
<tr>
<td>
<code class="path">{{ .Path }}</code>
</td>
<td>
<code class="date">{{ .Created.Format "2006-01-02T15:04:05Z07:00" }}</code>
</td>
<td>
{{ .Packed }}
</td>
</tr>
{{ end }}
</tbody>
</table>
<hr />
</p>
<footer>

View file

@ -1,6 +1,10 @@
const types = {
"date": (element) => {
return (new Date(element.innerText)).toString()
return (new Date(element.innerText)).toISOString()
},
"path": (element) => {
const text = element.innerText.split("/");
return text[text.length - 1];
},
"pathbuilders": (element) => {
const pathbuilders = window.pathbuilders; // read from context!

View file

@ -62,28 +62,43 @@ type disIndex struct {
Config *config.Config
Instances []instances.WissKIInfo
Instances []instances.WissKIInfo
TotalCount int
RunningCount int
StoppedCount int
Backups []models.Snapshot
}
func (dis *Control) disIndex(r *http.Request) (idx disIndex, err error) {
// load instances
idx.Instances, err = dis.allinstances(r)
if err != nil {
return
}
var group errgroup.Group
// count how many are running and how many are stopped
for _, i := range idx.Instances {
if i.Running {
idx.RunningCount++
} else {
idx.StoppedCount++
group.Go(func() error {
// load instances
idx.Instances, err = dis.allinstances(r)
if err != nil {
return err
}
}
idx.TotalCount = len(idx.Instances)
// count how many are running and how many are stopped
for _, i := range idx.Instances {
if i.Running {
idx.RunningCount++
} else {
idx.StoppedCount++
}
}
idx.TotalCount = len(idx.Instances)
return nil
})
// get the log entries
group.Go(func() (err error) {
idx.Backups, err = dis.Instances.SnapshotLogFor("")
return
})
// get the static properties
idx.Config = dis.Config
@ -91,6 +106,9 @@ func (dis *Control) disIndex(r *http.Request) (idx disIndex, err error) {
// current time
idx.Time = time.Now().UTC()
// wait for everything!
group.Wait()
return
}