-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
480 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {BaseResource} from "../ResourceCard"; | ||
import {AdditionalS3StorageType} from "@galv/galv"; | ||
import useStyles from "../../styles/UseStyles"; | ||
import clsx from "clsx"; | ||
import Stack from "@mui/material/Stack"; | ||
import Alert from "@mui/material/Alert"; | ||
import {humanize_bytes} from "../misc"; | ||
import {ReactNode} from "react"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
export default function AdditionalStorageSummary({ resource } : { resource: BaseResource}) { | ||
const {classes} = useStyles(); | ||
const r = resource as unknown as AdditionalS3StorageType | ||
|
||
let usage: ReactNode | ||
const usage_text = `Used ${humanize_bytes(r.bytes_used)} of ${humanize_bytes(r.quota_bytes)}` | ||
if (r.bytes_used > r.quota_bytes) { | ||
usage = <Alert severity="error">{usage_text}</Alert> | ||
} else if (r.bytes_used > r.quota_bytes * 0.9) { | ||
usage = <Alert severity="warning">{usage_text}</Alert> | ||
} else { | ||
usage = <Typography>{usage_text}</Typography> | ||
} | ||
|
||
return <Stack className={clsx(classes.resourceSummary)} spacing={1}> | ||
{!r.enabled && <Alert severity="warning">This storage is disabled</Alert>} | ||
{usage} | ||
</Stack> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {BaseResource} from "../ResourceCard"; | ||
import {ArbitraryFile} from "@galv/galv"; | ||
import useStyles from "../../styles/UseStyles"; | ||
import clsx from "clsx"; | ||
import Stack from "@mui/material/Stack"; | ||
import Prettify from "../prettify/Prettify"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
export default function ArbitraryFileSummary({ resource } : { resource: BaseResource}) { | ||
const {classes} = useStyles(); | ||
const r = resource as unknown as ArbitraryFile | ||
return <Stack className={clsx(classes.resourceSummary)} spacing={1}> | ||
<Typography variant="body2">{r.description}</Typography> | ||
<Prettify target={{_type: "attachment", _value: r.file}} /> | ||
</Stack> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import useStyles from "../../styles/UseStyles"; | ||
import {get_url_components} from "../misc"; | ||
import Stack from "@mui/material/Stack"; | ||
import clsx from "clsx"; | ||
import {ResourceChip} from "../ResourceChip"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
export default function ChipList({chips, max}: { chips: string[], max?: number }) { | ||
const max_items = max ?? 5 | ||
|
||
const extra = chips.length - max_items | ||
|
||
const {classes} = useStyles(); | ||
const components = chips.map(p => get_url_components(p)) | ||
.filter((c, i) => i < max_items) | ||
.map((c) => | ||
c?.resource_id && c?.lookup_key && | ||
<ResourceChip key={c.resource_id} resource_id={c.resource_id} lookup_key={c.lookup_key}/>) | ||
|
||
return <Stack direction="row" className={clsx(classes.chipList)}> | ||
{components.length > 0? components : <em>None</em>} | ||
{extra > 0 && <Typography>... and {extra} more</Typography>} | ||
</Stack> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {BaseResource} from "../ResourceCard"; | ||
import {DataColumnType} from "@galv/galv"; | ||
import useStyles from "../../styles/UseStyles"; | ||
import clsx from "clsx"; | ||
import Stack from "@mui/material/Stack"; | ||
import {get_url_components} from "../misc"; | ||
import {ResourceChip} from "../ResourceChip"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
|
||
export default function UnitSummary({ resource } : { resource: BaseResource}) { | ||
const {classes} = useStyles(); | ||
const r = resource as unknown as DataColumnType | ||
|
||
const unit = r.unit? get_url_components(r.unit) : undefined | ||
|
||
return <Stack className={clsx(classes.resourceSummary)} spacing={1}> | ||
<Typography variant="body2">{r.description}</Typography> | ||
<Stack direction="row"> | ||
{r.data_type} {unit && <ResourceChip resource_id={unit.resource_id} lookup_key={unit.lookup_key}/>} | ||
</Stack> | ||
</Stack> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {BaseResource} from "../ResourceCard"; | ||
import {CyclerTest} from "@galv/galv"; | ||
import useStyles from "../../styles/UseStyles"; | ||
import clsx from "clsx"; | ||
import Stack from "@mui/material/Stack"; | ||
import ChipList from "./ChipList"; | ||
import {get_url_components} from "../misc"; | ||
import {ResourceChip} from "../ResourceChip"; | ||
|
||
|
||
export default function CyclerTestSummary({ resource } : { resource: BaseResource}) { | ||
const {classes} = useStyles(); | ||
const r = resource as unknown as CyclerTest | ||
|
||
const c = r.cell? get_url_components(r.cell) : undefined | ||
const s = r.schedule? get_url_components(r.schedule) : undefined | ||
|
||
return <Stack className={clsx(classes.resourceSummary)} spacing={1}> | ||
{c && <ResourceChip resource_id={c.resource_id} lookup_key={c.lookup_key} />} | ||
{s && <ResourceChip resource_id={s.resource_id} lookup_key={s.lookup_key} />} | ||
<Stack direction="row">Equipment: <ChipList chips={r.equipment as string[]} /></Stack> | ||
<Stack direction="row">Files: <ChipList chips={r.files as string[]} /></Stack> | ||
</Stack> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {BaseResource} from "../ResourceCard"; | ||
import {Experiment} from "@galv/galv"; | ||
import useStyles from "../../styles/UseStyles"; | ||
import clsx from "clsx"; | ||
import Stack from "@mui/material/Stack"; | ||
import ChipList from "./ChipList"; | ||
|
||
export default function CyclerTestSummary({ resource } : { resource: BaseResource}) { | ||
const {classes} = useStyles(); | ||
const r = resource as unknown as Experiment | ||
|
||
return <Stack className={clsx(classes.resourceSummary)} spacing={1}> | ||
<Stack direction="row">Cycler Tests: <ChipList chips={r.cycler_tests as string[]} /></Stack> | ||
</Stack> | ||
} |
Oops, something went wrong.