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

Main #11

Merged
merged 5 commits into from
May 16, 2024
Merged

Main #11

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
7 changes: 7 additions & 0 deletions src/lib/formatters/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ export function addressFormatter(val: string, shortify?: boolean) {
const address = getAddress(val);
return shortify ? `${address.substring(0, 6)}...${address?.slice(-4)}` : address;
}

export function urlFormatter(val: string) {
val = val.trim().toLowerCase();
return val.startsWith('http://') || val.startsWith('https://')
? val
: val.replace(/^(?!(?:\w+?:)?\/\/)/, 'https://');
}
6 changes: 3 additions & 3 deletions src/pages/DashboardPage/Workers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export function Workers() {
<TableRow>
<TableCell sx={{ minWidth: 275 }}>Worker</TableCell>
<TableCell>Status</TableCell>
<SortableHeaderCell sort={WorkerSortBy.Uptime24h} query={query} setQuery={setQuery}>
Uptime, 24h
<SortableHeaderCell sort={WorkerSortBy.Uptime90d} query={query} setQuery={setQuery}>
Uptime, 90d
</SortableHeaderCell>
<SortableHeaderCell sort={WorkerSortBy.WorkerAPR} query={query} setQuery={setQuery}>
Worker APR, 7d
Expand Down Expand Up @@ -137,7 +137,7 @@ export function Workers() {
<TableCell>
<WorkerStatus worker={worker} />
</TableCell>
<TableCell>{percentFormatter(worker.uptime24Hours)}</TableCell>
<TableCell>{percentFormatter(worker.uptime90Days)}</TableCell>
<TableCell>{worker.apr != null ? percentFormatter(worker.apr) : '-'}</TableCell>
<TableCell>
{worker.stakerApr != null ? percentFormatter(worker.stakerApr) : '-'}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/WorkersPage/WorkerStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
bytesFormatter,
numberWithSpacesFormatter,
percentFormatter,
urlFormatter,
} from '@lib/formatters/formatters.ts';
import { Box, Divider, Stack, styled } from '@mui/material';

Expand Down Expand Up @@ -78,7 +79,13 @@ export const WorkerStatistics = ({ worker }: { worker: BlockchainApiFullWorker }
<Stack direction="row">
<WorkerDescLabel>Website</WorkerDescLabel>
<WorkerDescValue>
{worker.website ? <a href={worker.website}>{worker.website}</a> : '-'}
{worker.website ? (
<a href={urlFormatter(worker.website)} target="_blank" rel="noreferrer">
{urlFormatter(worker.website)}
</a>
) : (
'-'
)}
</WorkerDescValue>
</Stack>
<Stack direction="row">
Expand Down
3 changes: 2 additions & 1 deletion src/pages/WorkersPage/WorkersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export function MyWorkers() {
<TableCell width={275}>Worker</TableCell>
<TableCell>Status</TableCell>
<TableCell>Uptime, 24h</TableCell>
<TableCell>Uptime, 90d</TableCell>
<TableCell>APR, 7d</TableCell>
<TableCell>Delegator APR, 7d</TableCell>
<TableCell>Total reward</TableCell>
<TableCell></TableCell>
</TableRow>
Expand All @@ -64,6 +64,7 @@ export function MyWorkers() {
<WorkerStatus worker={worker} />
</TableCell>
<TableCell>{percentFormatter(worker.uptime24Hours)}</TableCell>
<TableCell>{percentFormatter(worker.uptime90Days)}</TableCell>
<TableCell>{worker.apr != null ? percentFormatter(worker.apr) : '-'}</TableCell>
<TableCell>
{worker.stakerApr != null ? percentFormatter(worker.stakerApr) : '-'}
Expand Down
Loading