Add rebuild triplestore button to frontend
This commit is contained in:
parent
e5100a1f22
commit
95f09ab881
6 changed files with 121 additions and 10 deletions
|
|
@ -80,6 +80,7 @@ var (
|
||||||
menuSSH = component.DummyMenuItem()
|
menuSSH = component.DummyMenuItem()
|
||||||
menuStats = component.DummyMenuItem()
|
menuStats = component.DummyMenuItem()
|
||||||
menuData = component.DummyMenuItem()
|
menuData = component.DummyMenuItem()
|
||||||
|
menuTriplestore = component.DummyMenuItem()
|
||||||
menuDrupal = component.DummyMenuItem()
|
menuDrupal = component.DummyMenuItem()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -161,6 +162,11 @@ func (admin *Admin) HandleRoute(ctx context.Context, route string) (handler http
|
||||||
router.Handler(http.MethodGet, route+"instance/:slug/stats", stats)
|
router.Handler(http.MethodGet, route+"instance/:slug/stats", stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
triplestore := admin.instanceTS(ctx)
|
||||||
|
router.Handler(http.MethodGet, route+"instance/:slug/triplestore", triplestore)
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
data := admin.instanceData(ctx)
|
data := admin.instanceData(ctx)
|
||||||
router.Handler(http.MethodGet, route+"instance/:slug/data", data)
|
router.Handler(http.MethodGet, route+"instance/:slug/data", data)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
<div class="pure-u-1">
|
||||||
|
<h2 id="wisski">Triplestore</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-u-1 pure-u-xl-1-2">
|
||||||
|
<button class="remote-action pure-button pure-button-action" data-action="rebuild_triplestore" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>
|
||||||
|
Rebuild Triplestore
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
@ -79,6 +79,7 @@ func (admin *Admin) instanceTabs(slug string, active string) templating.FlagFunc
|
||||||
{Title: "Overview", Path: template.URL("/admin/instance/" + slug), Active: active == "overview"},
|
{Title: "Overview", Path: template.URL("/admin/instance/" + slug), Active: active == "overview"},
|
||||||
{Title: "Rebuild", Path: template.URL("/admin/instance/" + slug + "/rebuild"), Active: active == "rebuild"},
|
{Title: "Rebuild", Path: template.URL("/admin/instance/" + slug + "/rebuild"), Active: active == "rebuild"},
|
||||||
{Title: "Users & Grants", Path: template.URL("/admin/instance/" + slug + "/users"), Active: active == "users"},
|
{Title: "Users & Grants", Path: template.URL("/admin/instance/" + slug + "/users"), Active: active == "users"},
|
||||||
|
{Title: "Triplestore", Path: template.URL("/admin/instance/" + slug + "/triplestore"), Active: active == "triplestore"},
|
||||||
{Title: "Drupal", Path: template.URL("/admin/instance/" + slug + "/drupal"), Active: active == "drupal"},
|
{Title: "Drupal", Path: template.URL("/admin/instance/" + slug + "/drupal"), Active: active == "drupal"},
|
||||||
{Title: "WissKI Data", Path: template.URL("/admin/instance/" + slug + "/data"), Active: active == "data"},
|
{Title: "WissKI Data", Path: template.URL("/admin/instance/" + slug + "/data"), Active: active == "data"},
|
||||||
{Title: "WissKI Stats", Path: template.URL("/admin/instance/" + slug + "/stats"), Active: active == "stats"},
|
{Title: "WissKI Stats", Path: template.URL("/admin/instance/" + slug + "/stats"), Active: active == "stats"},
|
||||||
|
|
|
||||||
59
internal/dis/component/server/admin/instance_triplestore.go
Normal file
59
internal/dis/component/server/admin/instance_triplestore.go
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
_ "embed"
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
||||||
|
"github.com/tkw1536/pkglib/httpx"
|
||||||
|
|
||||||
|
"github.com/julienschmidt/httprouter"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed "html/instance_triplestore.html"
|
||||||
|
var instanceTriplestoreHTML []byte
|
||||||
|
var instanceTriplestoreTemplate = templating.Parse[instanceTriplestoreContext](
|
||||||
|
"instance_triplestore.html", instanceTriplestoreHTML, nil,
|
||||||
|
|
||||||
|
templating.Assets(assets.AssetsAdmin),
|
||||||
|
)
|
||||||
|
|
||||||
|
type instanceTriplestoreContext struct {
|
||||||
|
templating.RuntimeFlags
|
||||||
|
|
||||||
|
Instance *wisski.WissKI
|
||||||
|
}
|
||||||
|
|
||||||
|
func (admin *Admin) instanceTS(ctx context.Context) http.Handler {
|
||||||
|
tpl := instanceTriplestoreTemplate.Prepare(
|
||||||
|
admin.dependencies.Templating,
|
||||||
|
templating.Crumbs(
|
||||||
|
menuAdmin,
|
||||||
|
menuInstances,
|
||||||
|
menuInstance,
|
||||||
|
menuTriplestore,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
return tpl.HTMLHandlerWithFlags(admin.dependencies.Handling, func(r *http.Request) (ctx instanceTriplestoreContext, funcs []templating.FlagFunc, err error) {
|
||||||
|
slug := httprouter.ParamsFromContext(r.Context()).ByName("slug")
|
||||||
|
|
||||||
|
// setup the context with just the instance
|
||||||
|
ctx.Instance, err = admin.dependencies.Instances.WissKI(r.Context(), slug)
|
||||||
|
if err != nil {
|
||||||
|
return ctx, nil, httpx.ErrNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx, []templating.FlagFunc{
|
||||||
|
templating.ReplaceCrumb(menuInstance, component.MenuItem{Title: "Instance", Path: template.URL("/admin/instance/" + ctx.Instance.Slug)}),
|
||||||
|
templating.ReplaceCrumb(menuTriplestore, component.MenuItem{Title: "Triplestore", Path: template.URL("/admin/instance/" + ctx.Instance.Slug + "/triplestore")}),
|
||||||
|
templating.Title(ctx.Instance.Slug + " - Triplestore"),
|
||||||
|
admin.instanceTabs(slug, "triplestore"),
|
||||||
|
}, nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package actions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth/scopes"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RebuildTriplestore struct {
|
||||||
|
component.Base
|
||||||
|
dependencies struct {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ WebsocketInstanceAction = (*Snapshot)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func (wsa *RebuildTriplestore) Action() InstanceAction {
|
||||||
|
return InstanceAction{
|
||||||
|
Action: Action{
|
||||||
|
Name: "rebuild_triplestore",
|
||||||
|
Scope: scopes.ScopeUserAdmin,
|
||||||
|
NumParams: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wsa *RebuildTriplestore) Act(ctx context.Context, instance *wisski.WissKI, in io.Reader, out io.Writer, params ...string) error {
|
||||||
|
return instance.TRB().RebuildTriplestore(ctx, out, false)
|
||||||
|
}
|
||||||
|
|
@ -232,6 +232,7 @@ func (dis *Distillery) allComponents(context *lifetime.Registry[component.Compon
|
||||||
lifetime.Place[*actions.Start](context)
|
lifetime.Place[*actions.Start](context)
|
||||||
lifetime.Place[*actions.Stop](context)
|
lifetime.Place[*actions.Stop](context)
|
||||||
lifetime.Place[*actions.Purge](context)
|
lifetime.Place[*actions.Purge](context)
|
||||||
|
lifetime.Place[*actions.RebuildTriplestore](context)
|
||||||
|
|
||||||
// Cron
|
// Cron
|
||||||
lifetime.Place[*cron.Cron](context)
|
lifetime.Place[*cron.Cron](context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue