Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curio web: node info page #11745

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions curiosrc/web/hapi/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ package hapi

magik6k marked this conversation as resolved.
Show resolved Hide resolved
import (
"embed"
"html/template"
"text/template"

"github.com/gorilla/mux"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/cmd/curio/deps"
)

//go:embed web/*
var templateFS embed.FS

func Routes(r *mux.Router, deps *deps.Deps) error {
t, err := template.ParseFS(templateFS, "web/*")
t, err := makeTemplate().ParseFS(templateFS, "web/*")
if err != nil {
return xerrors.Errorf("parse templates: %w", err)
}
Expand All @@ -28,15 +29,27 @@ func Routes(r *mux.Router, deps *deps.Deps) error {
go a.watchRpc()
go a.watchActor()

// index page (simple info)
r.HandleFunc("/simpleinfo/actorsummary", a.actorSummary)
r.HandleFunc("/simpleinfo/machines", a.indexMachines)
r.HandleFunc("/simpleinfo/tasks", a.indexTasks)
r.HandleFunc("/simpleinfo/taskhistory", a.indexTasksHistory)
r.HandleFunc("/simpleinfo/pipeline-porep", a.indexPipelinePorep)

// pipeline-porep page
r.HandleFunc("/simpleinfo/pipeline-porep/sectors", a.pipelinePorepSectors)
r.HandleFunc("/pipeline-porep/sectors", a.pipelinePorepSectors)

// node info page
r.HandleFunc("/node/{id}", a.nodeInfo)
return nil
}

func makeTemplate() *template.Template {
return template.New("").Funcs(template.FuncMap{
"toHumanBytes": func(b int64) string {
return types.SizeStr(types.NewInt(uint64(b)))
},
})
}

var log = logging.Logger("curio/web")
Loading