Skip to content

Commit

Permalink
curio web: node info page (#11745)
Browse files Browse the repository at this point in the history
* curio web: node info page

* curioweb: add missing files

* curio web: Better hapi route prefixes
  • Loading branch information
magik6k authored Mar 25, 2024
1 parent e86d81b commit 099fc04
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 23 deletions.
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

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

0 comments on commit 099fc04

Please sign in to comment.