-
Notifications
You must be signed in to change notification settings - Fork 61
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
Bugfixes/fix provider gpus UI #143
Changes from 7 commits
2bc64ef
5dedae5
4565b84
d2dea92
9bd9fd0
38ac4a2
72040a3
a1ea942
c400d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,7 +62,7 @@ export const ProviderListRow: React.FunctionComponent<Props> = ({ provider }) => | |||||
const _totalStorage = provider.isOnline | ||||||
? bytesToShrink(provider.availableStats.storage + provider.pendingStats.storage + provider.activeStats.storage) | ||||||
: null; | ||||||
const gpuModels = provider.hardwareGpuModels.map(gpu => gpu.substring(gpu.lastIndexOf(" ") + 1, gpu.length)); | ||||||
const gpuModels = provider.gpuModels.map(x => x.model).filter((x, i, arr) => arr.indexOf(x) === i); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could also utilise that new filter function. What do you think?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I added it to the deploy-web project too. No unit tests for now, but we could add them once the big refactor is done (rebrand). |
||||||
|
||||||
const onStarClick = event => { | ||||||
event.preventDefault(); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,10 +1,8 @@ | ||||||
import { Box, Chip, Paper } from "@mui/material"; | ||||||
import { makeStyles } from "tss-react/mui"; | ||||||
import { useRouter } from "next/router"; | ||||||
import { ClientProviderDetailWithStatus } from "@src/types/provider"; | ||||||
import { LabelValue } from "../shared/LabelValue"; | ||||||
import CheckIcon from "@mui/icons-material/Check"; | ||||||
import { ProviderAttributesSchema } from "@src/types/providerAttributes"; | ||||||
|
||||||
const useStyles = makeStyles()(theme => ({ | ||||||
root: { | ||||||
|
@@ -20,12 +18,16 @@ const useStyles = makeStyles()(theme => ({ | |||||
|
||||||
type Props = { | ||||||
provider: Partial<ClientProviderDetailWithStatus>; | ||||||
providerAttributesSchema: ProviderAttributesSchema; | ||||||
}; | ||||||
|
||||||
export const ProviderSpecs: React.FunctionComponent<Props> = ({ provider, providerAttributesSchema }) => { | ||||||
export const ProviderSpecs: React.FunctionComponent<Props> = ({ provider }) => { | ||||||
const { classes } = useStyles(); | ||||||
const router = useRouter(); | ||||||
|
||||||
const gpuModels = | ||||||
provider?.gpuModels | ||||||
?.map(x => x.model + " " + x.ram) | ||||||
.filter((x, i, arr) => arr.indexOf(x) === i) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.sort((a, b) => a.localeCompare(b)) || []; | ||||||
|
||||||
return ( | ||||||
<Paper className={classes.root}> | ||||||
|
@@ -41,7 +43,7 @@ export const ProviderSpecs: React.FunctionComponent<Props> = ({ provider, provid | |||||
<Box> | ||||||
<LabelValue | ||||||
label="GPU Models" | ||||||
value={provider.hardwareGpuModels.map(x => ( | ||||||
value={gpuModels.map(x => ( | ||||||
<Chip key={x} label={x} size="small" sx={{ marginRight: ".5rem" }} /> | ||||||
))} | ||||||
/> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pls explain what this means?
I understand that
findIndex
matching same vendor, model, etc. Why should it also be of the same index?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I see, it's to remove duplicates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really hard to understand this. I'd suggest if we could add a dedicated function for this.
in this case the code above would be:
and example below would be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be tested here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to keep only the first occurence of each gpus since there are duplicates in the array. If the current index
i
matchesfindIndex
that means it's the first occurence so it's kept, otherwise it is filtered out as duplicate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I figured after asking the question :) check out a suggestion pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mb your other replies weren't showing when I answered. For sure that would be easier to understand, I'll add it! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the
createFilterUnique
helper with relevant unit tests