Skip to content

Commit

Permalink
feat: update local index directory ui
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc committed Jun 1, 2023
1 parent 5e511a8 commit 6c19399
Show file tree
Hide file tree
Showing 19 changed files with 1,003 additions and 386 deletions.
4 changes: 3 additions & 1 deletion gql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ type resolver struct {
publisher *storageadapter.DealPublisher
spApi sealingpipeline.API
fullNode v1api.FullNode
sectorsList *sealingpipeline.SectorsList
}

func NewResolver(ctx context.Context, cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, spApi sealingpipeline.API, provider *storagemarket.Provider, legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer, ps piecestore.PieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, publisher *storageadapter.DealPublisher, fullNode v1api.FullNode) *resolver {
func NewResolver(ctx context.Context, cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, spApi sealingpipeline.API, provider *storagemarket.Provider, legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer, ps piecestore.PieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, publisher *storageadapter.DealPublisher, fullNode v1api.FullNode, sectorsList *sealingpipeline.SectorsList) *resolver {
return &resolver{
ctx: ctx,
cfg: cfg,
Expand All @@ -91,6 +92,7 @@ func NewResolver(ctx context.Context, cfg *config.Boost, r lotus_repo.LockedRepo
publisher: publisher,
spApi: spApi,
fullNode: fullNode,
sectorsList: sectorsList,
}
}

Expand Down
77 changes: 77 additions & 0 deletions gql/resolver_sectors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package gql

import (
"context"
gqltypes "github.com/filecoin-project/boost/gql/types"
"github.com/graph-gophers/graphql-go"
)

type sectorStateResolver struct {
SectorNumber int32
Status string
Unsealed bool
DealCount int32
Active bool
DealWeight gqltypes.BigInt
VerifiedPower gqltypes.BigInt
Expiration gqltypes.Uint64
OnChain bool
}

type sectorsListResolver struct {
TotalCount int32
Sectors []*sectorStateResolver
More bool
At graphql.Time
}

type sectorsArgs struct {
Cursor graphql.NullInt // SectorNumber
Offset graphql.NullInt
Limit graphql.NullInt
}

// query: sectorsList(cursor, offset, limit) SectorsList
func (r *resolver) SectorsList(ctx context.Context, args sectorsArgs) (*sectorsListResolver, error) {
offset := 0
if args.Offset.Set && args.Offset.Value != nil && *args.Offset.Value > 0 {
offset = int(*args.Offset.Value)
}

limit := 10
if args.Limit.Set && args.Limit.Value != nil && *args.Limit.Value > 0 {
limit = int(*args.Limit.Value)
}

snapshot, err := r.sectorsList.Snapshot(ctx, offset, limit)
if err != nil {
return nil, err
}

resolvers := make([]*sectorStateResolver, 0, len(snapshot.List))
for _, sector := range snapshot.List {
resolvers = append(resolvers, &sectorStateResolver{
SectorNumber: int32(sector.SectorNumber),
Status: sector.State.String(),
Unsealed: sector.Unsealed,
DealCount: int32(len(sector.Deals)),
Active: sector.Active,
DealWeight: gqltypes.BigInt{Int: sector.DealWeight},
VerifiedPower: gqltypes.BigInt{Int: sector.VerifiedPower},
Expiration: gqltypes.Uint64(sector.Expiration),
OnChain: sector.OnChain,
})
}

return &sectorsListResolver{
TotalCount: int32(snapshot.TotalCount),
Sectors: resolvers,
More: snapshot.More,
At: graphql.Time{Time: snapshot.At},
}, nil
}

// mutation: sectorsListRefresh()
func (r *resolver) SectorsListRefresh(ctx context.Context) (bool, error) {
return true, r.sectorsList.Refresh(ctx)
}
25 changes: 25 additions & 0 deletions gql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,25 @@ type SealingPipeline {
Workers: [Worker]!
}

type SectorsList {
totalCount: Int!
sectors: [SectorStatus]!
more: Boolean!
at: Time!
}

type SectorStatus {
SectorNumber: Int!
Status: String!
Unsealed: Boolean!
DealCount: Int!
Active: Boolean!
DealWeight: BigInt!
VerifiedPower: BigInt!
Expiration: Uint64!
OnChain: Boolean!
}

type FundsEscrow {
Available: BigInt!
Locked: BigInt!
Expand Down Expand Up @@ -467,6 +486,9 @@ type RootQuery {
"""Get the indexes for a particular piece CID"""
pieceIndexes(pieceCid: String!): [String!]!

"""Get the status of sectors"""
sectorsList(cursor: Int, offset: Int, limit: Int): SectorsList!

"""Get storage space usage"""
storage: Storage!

Expand Down Expand Up @@ -522,6 +544,9 @@ type RootMutation {

"""Update the Storage Ask (price of doing a storage deal)"""
storageAskUpdate(update: StorageAskUpdate!): Boolean!

"""Synchonously refresh the state of the sectors list"""
sectorsListRefresh: Boolean!
}

type RootSubscription {
Expand Down
8 changes: 6 additions & 2 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,15 @@ func NewGraphqlServer(cfg *config.Boost) func(lc fx.Lifecycle, r repo.LockedRepo
ps dtypes.ProviderPieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, fullNode v1api.FullNode, bg gql.BlockGetter) *gql.Server {

resolverCtx, cancel := context.WithCancel(context.Background())
resolver := gql.NewResolver(resolverCtx, cfg, r, h, dealsDB, logsDB, retDB, plDB, fundsDB, fundMgr, storageMgr, spApi, prov, legacyProv, legacyDT, ps, sa, piecedirectory, publisher, fullNode)
sectorsList := sealingpipeline.NewSectorsList(fullNode, spApi)
resolver := gql.NewResolver(resolverCtx, cfg, r, h, dealsDB, logsDB, retDB, plDB, fundsDB, fundMgr, storageMgr, spApi, prov, legacyProv, legacyDT, ps, sa, piecedirectory, publisher, fullNode, sectorsList)
server := gql.NewServer(resolver, bg)

lc.Append(fx.Hook{
OnStart: server.Start,
OnStart: func(ctx context.Context) error {
go sectorsList.Run(resolverCtx)
return server.Start(ctx)
},
OnStop: func(ctx context.Context) error {
cancel()
return server.Stop(ctx)
Expand Down
14 changes: 8 additions & 6 deletions react/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {Epoch} from "./Epoch";
import {LegacyDealDetail} from "./LegacyDealDetail"
import {SettingsPage} from "./Settings";
import {Banner} from "./Banner";
import {PieceDirectoryDetail, PieceDirectoryPage} from "./PieceDirectory";
import {ProposalLogsPage} from "./ProposalLogs";
import {InspectPage, InspectPiecePage} from "./Inspect";
import {PieceDoctorPage, InspectPiecePage, LIDPage} from "./LID";
import {RetrievalLogsPage} from "./RetrievalLogs";
import {RetrievalLogDetail} from "./RetrievalLogDetail";
import {SectorsListPage} from "./SectorsList";

function App(props) {
return (
Expand Down Expand Up @@ -53,13 +53,15 @@ function App(props) {
<Route path="/deal-transfers" element={<DealTransfersPage />} />
<Route path="/mpool" element={<MpoolPage />} />
<Route path="/settings" element={<SettingsPage />} />
<Route path="/piece-directory" element={<PieceDirectoryPage />} />
<Route path="/deals/:dealID" element={<DealDetail />} />
<Route path="/legacy-deals/:dealID" element={<LegacyDealDetail />} />
<Route path="/inspect" element={<InspectPage />} />
<Route path="/lid" element={<LIDPage />} />
<Route path="/sectors-list" element={<SectorsListPage />} />
<Route path="/sectors-list/from/:cursor/page/:pageNum" element={<SectorsListPage />} />
<Route path="/piece-doctor" element={<PieceDoctorPage />} />
<Route path="/inspect/piece/:pieceCID" element={<InspectPiecePage />} />
<Route path="/inspect/from/:cursor/page/:pageNum" element={<InspectPage />} />
<Route path="/inspect/:query" element={<InspectPage />} />
<Route path="/inspect/from/:cursor/page/:pageNum" element={<PieceDoctorPage />} />
<Route path="/inspect/:query" element={<PieceDoctorPage />} />
<Route path="/" element={<StorageDealsPage />} />
</Routes>
</div>
Expand Down
8 changes: 6 additions & 2 deletions react/src/CumulativeBarChart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global BigInt */
import {humanFIL, humanFileSize} from "./util";
import {addCommas, humanFIL, humanFileSize, isInteger} from "./util";
import React from "react";
import './CumulativeBarChart.css'

Expand Down Expand Up @@ -72,7 +72,11 @@ function amountToString(unit, amount) {
case 'attoFIL':
return humanFIL(amount)
default:
return amount.toString()
const amtStr = amount.toString()
if (isInteger(amtStr)) {
return addCommas(amtStr)
}
return amtStr
}
}

1 change: 0 additions & 1 deletion react/src/DealTransfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {TransfersQuery, TransferStatsQuery} from "./gql";
import moment from "moment"
import {PageContainer} from "./Components";
import {Link} from "react-router-dom";
import {toFixed} from "./util";
import arrowLeftRightImg from './bootstrap-icons/icons/arrow-left-right.svg'
import './DealTransfers.css'

Expand Down
45 changes: 45 additions & 0 deletions react/src/LID.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.block-stats th {
text-align: left;
}

.block-stats td, .block-stats th {
padding: 0.5em 1em;
}

.lid-graphs {
margin-top: 2em;
width: 100%;
}

.lid-graphs td {
vertical-align: top;
}

.storage-chart {
padding: 1em;
}

.storage-chart .indexed, .storage-chart .unsealed, .storage-chart .active {
background-color: rgb(44, 123, 229);
}

.storage-chart .flagged {
background-color: rgb(166, 197, 247);
}

.storage-chart .sealed, .storage-chart .inactive {
background-color: #b3b3b3;
}

.storage-fields td {
padding: 0.5em 1em;
font-weight: normal;
}

.sectors-list-link p, .flagged-pieces-link p {
padding: 1em;
}

.sectors-list-link a, .flagged-pieces-link a {
margin-left: 1em;
}
Loading

0 comments on commit 6c19399

Please sign in to comment.