-
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.
feat: add encode operation details widget
- Loading branch information
1 parent
ac1b968
commit 3380b3a
Showing
6 changed files
with
135 additions
and
12 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { default as EncodeDialog } from '@/components/interfaces/encode/dialog/EncodeDialog' | ||
|
||
export { default as EncodeCommandWidget } from '@/components/interfaces/encode/widgets/EncodeCommandWidget' | ||
export { default as EncodeOperationWidget } from '@/components/interfaces/encode/widgets/EncodeOperationWidget' | ||
export { default as EncodeOutputWidget } from '@/components/interfaces/encode/widgets/EncodeOutputWidget' | ||
export { default as EncodeSizeWidget } from '@/components/interfaces/encode/widgets/EncodeSizeWidget' |
99 changes: 99 additions & 0 deletions
99
app/src/components/interfaces/encode/widgets/EncodeOperationWidget.tsx
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,99 @@ | ||
import type { EncodeOperationWidgetFragment$key } from '@/__generated__/EncodeOperationWidgetFragment.graphql' | ||
|
||
import { Chip, Table, Typography } from '@giantnodes/react' | ||
import dayjs from 'dayjs' | ||
import { filesize } from 'filesize' | ||
import { graphql, useFragment } from 'react-relay' | ||
|
||
import { percent } from '@/utilities/numbers' | ||
|
||
const FRAGMENT = graphql` | ||
fragment EncodeOperationWidgetFragment on Encode { | ||
percent | ||
updated_at | ||
machine { | ||
name | ||
user_name | ||
} | ||
speed { | ||
bitrate | ||
frames | ||
scale | ||
} | ||
} | ||
` | ||
|
||
type EncodeOperationWidgetProps = { | ||
$key: EncodeOperationWidgetFragment$key | ||
} | ||
|
||
const EncodeOperationWidget: React.FC<EncodeOperationWidgetProps> = ({ $key }) => { | ||
const data = useFragment(FRAGMENT, $key) | ||
|
||
return ( | ||
<Table headingless size="sm"> | ||
<Table.Head> | ||
<Table.Column key="name" isRowHeader> | ||
name | ||
</Table.Column> | ||
|
||
<Table.Column key="name">value</Table.Column> | ||
</Table.Head> | ||
|
||
<Table.Body> | ||
{data.percent != null && ( | ||
<Table.Row> | ||
<Table.Cell> | ||
<Typography.Text>Progress</Typography.Text> | ||
</Table.Cell> | ||
<Table.Cell className="text-right"> | ||
<Chip color="brand">{percent(data.percent)}</Chip> | ||
</Table.Cell> | ||
</Table.Row> | ||
)} | ||
|
||
<Table.Row> | ||
<Table.Cell> | ||
<Typography.Text>Machine</Typography.Text> | ||
</Table.Cell> | ||
<Table.Cell className="flex justify-end gap-1"> | ||
<Chip color="info">{data.machine?.name}</Chip> | ||
<Chip color="info">{data.machine?.user_name}</Chip> | ||
</Table.Cell> | ||
</Table.Row> | ||
|
||
{data.speed != null && ( | ||
<Table.Row> | ||
<Table.Cell> | ||
<Typography.Text>Speed</Typography.Text> | ||
</Table.Cell> | ||
<Table.Cell className="flex justify-end gap-1"> | ||
<Chip color="warning">{data.speed.frames} fps</Chip> | ||
|
||
<Chip color="warning">{filesize(data.speed.bitrate * 0.125, { bits: true }).toLowerCase()}/s</Chip> | ||
|
||
<Chip color="warning">{data.speed.scale.toFixed(2)}x</Chip> | ||
</Table.Cell> | ||
</Table.Row> | ||
)} | ||
|
||
{data.updated_at != null && ( | ||
<Table.Row> | ||
<Table.Cell> | ||
<Typography.Text>Heartbeat</Typography.Text> | ||
</Table.Cell> | ||
<Table.Cell className="text-right"> | ||
<Typography.Text> | ||
<Chip color="danger" title={dayjs(data.updated_at).format('L LT')}> | ||
{dayjs(data.updated_at).fromNow()} | ||
</Chip> | ||
</Typography.Text> | ||
</Table.Cell> | ||
</Table.Row> | ||
)} | ||
</Table.Body> | ||
</Table> | ||
) | ||
} | ||
|
||
export default EncodeOperationWidget |
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,5 @@ | ||
export const percent = (value: number): string => | ||
Intl.NumberFormat('en-US', { | ||
style: 'percent', | ||
maximumFractionDigits: 2, | ||
}).format(value) |