Skip to content

Commit f464f80

Browse files
committed
[Feature]: UI for offers #3004
1 parent 230b6bf commit f464f80

5 files changed

Lines changed: 40 additions & 33 deletions

File tree

frontend/src/locale/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,14 @@
453453
"backend": "Backend",
454454
"backend_plural": "Backends",
455455
"availability": "Availability",
456-
"groupBy": "Group By",
456+
"groupBy": "Group by",
457457
"region": "Region",
458458
"count": "Count",
459459
"price": "$/GPU",
460460
"memory_mib": "Memory",
461-
"spot": "Spot",
462-
"empty_message_title_select_project": "Need project name",
463-
"empty_message_text_select_project": "Please choose project name in property filter",
461+
"spot": "Spot policy",
462+
"empty_message_title_select_project": "Select a project",
463+
"empty_message_text_select_project": "Use the filter above to select a project",
464464
"empty_message_title": "No offers",
465465
"empty_message_text": "No offers to display.",
466466
"nomatch_message_title": "No matches",

frontend/src/pages/Offers/List/helpers.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { RequestParam } from '../../../libs/filters';
33
const rangeSeparator = '..';
44

55
export function convertMiBToGB(mib: number) {
6-
const bytes = mib * Math.pow(2, 20); // Convert MiB to bytes
7-
// Convert bytes to GB
8-
return bytes / Math.pow(10, 9);
6+
return mib / 1024;
97
}
108

119
export const getPropertyFilterOptions = (gpus: IGpu[]) => {

frontend/src/pages/Offers/List/hooks/useFilters.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const useFilters = ({ gpus }: Args) => {
9393
{
9494
key: filterKeys.GPU_NAME,
9595
operators: ['='],
96-
propertyLabel: 'GPU names',
96+
propertyLabel: 'GPU name',
9797
},
9898
{
9999
key: filterKeys.GPU_COUNT,
@@ -103,17 +103,17 @@ export const useFilters = ({ gpus }: Args) => {
103103
{
104104
key: filterKeys.GPU_MEMORY,
105105
operators: ['<=', '>='],
106-
propertyLabel: 'GPU Memory',
106+
propertyLabel: 'GPU memory',
107107
},
108108
{
109109
key: filterKeys.BACKEND,
110110
operators: ['='],
111-
propertyLabel: 'Backends',
111+
propertyLabel: 'Backend',
112112
},
113113
{
114114
key: filterKeys.SPOT_POLICY,
115115
operators: ['='],
116-
propertyLabel: 'Spot',
116+
propertyLabel: 'Spot policy',
117117
},
118118
];
119119

frontend/src/pages/Offers/List/index.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33

4-
import { Cards, Header, PropertyFilter, SelectCSD, StatusIndicator } from 'components';
4+
import { Cards, Header, Link, PropertyFilter, SelectCSD, StatusIndicator } from 'components';
55

66
import { useCollection } from 'hooks';
77
import { useGetGpusListQuery } from 'services/gpu';
@@ -12,7 +12,7 @@ import { convertMiBToGB, rangeToObject, renderRange, round } from './helpers';
1212

1313
import styles from './styles.module.scss';
1414

15-
const gpusFilterOption = { label: 'GPUs', value: 'gpu' };
15+
const gpusFilterOption = { label: 'GPU', value: 'gpu' };
1616

1717
const getRequestParams = ({
1818
project_name,
@@ -111,38 +111,38 @@ export const OfferList = () => {
111111
{...collectionProps}
112112
items={items}
113113
cardDefinition={{
114-
header: (gpu) => gpu.name,
114+
header: (gpu) => <Link>{gpu.name}</Link>,
115115
sections: [
116116
{
117-
id: 'backends',
118-
header: t('offer.backend_plural'),
119-
content: (gpu) => gpu.backends?.join(', ') ?? '-',
117+
id: 'memory_mib',
118+
header: t('offer.memory_mib'),
119+
content: (gpu) => `${round(convertMiBToGB(gpu.memory_mib))}GB`,
120120
width: 50,
121121
},
122-
// {
123-
// id: 'region',
124-
// header: t('offer.region'),
125-
// content: (gpu) => gpu.region ?? gpu.regions?.join(', ') ?? '-',
126-
// width: 50,
127-
// },
128122
{
129-
id: 'count',
130-
header: t('offer.count'),
131-
content: (gpu) => renderRange(gpu.count) ?? '-',
123+
id: 'price',
124+
header: t('offer.price'),
125+
content: (gpu) => <span className={styles.greenText}>{renderRange(gpu.price) ?? '-'}</span>,
132126
width: 50,
133127
},
134128
{
135-
id: 'price',
136-
header: t('offer.price'),
137-
content: (gpu) => renderRange(gpu.price) ?? '-',
129+
id: 'count',
130+
header: t('offer.count'),
131+
content: (gpu) => renderRange(gpu.count) ?? '-',
138132
width: 50,
139133
},
140134
{
141-
id: 'memory_mib',
142-
header: t('offer.memory_mib'),
143-
content: (gpu) => `${round(convertMiBToGB(gpu.memory_mib))}GB`,
135+
id: 'backends',
136+
header: t('offer.backend_plural'),
137+
content: (gpu) => gpu.backends?.join(', ') ?? '-',
144138
width: 50,
145139
},
140+
// {
141+
// id: 'region',
142+
// header: t('offer.region'),
143+
// content: (gpu) => gpu.region ?? gpu.regions?.join(', ') ?? '-',
144+
// width: 50,
145+
// },
146146
{
147147
id: 'spot',
148148
header: t('offer.spot'),
@@ -152,8 +152,10 @@ export const OfferList = () => {
152152
{
153153
id: 'availability',
154154
content: (gpu) => {
155+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
156+
// @ts-expect-error
155157
if (gpu.availability === 'not_available') {
156-
return <StatusIndicator type="error">Not Available</StatusIndicator>;
158+
return <StatusIndicator type="warning">Not Available</StatusIndicator>;
157159
}
158160
},
159161
width: 50,
@@ -164,6 +166,7 @@ export const OfferList = () => {
164166
loadingText={t('common.loading')}
165167
stickyHeader={true}
166168
header={<Header variant="awsui-h1-sticky">{t('offer.title')}</Header>}
169+
variant="full-page"
167170
filter={
168171
<div className={styles.selectFilters}>
169172
<div className={styles.propertyFilter}>

frontend/src/pages/Offers/List/styles.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use '@cloudscape-design/design-tokens/index' as awsui;
2+
13
.selectFilters {
24
display: flex;
35
flex-wrap: wrap;
@@ -14,4 +16,8 @@
1416
flex-grow: 1;
1517
min-width: 0;
1618
}
19+
}
20+
21+
.greenText {
22+
color: awsui.$color-text-status-success;
1723
}

0 commit comments

Comments
 (0)