Skip to content

Commit 4f1781e

Browse files
committed
[grid] Displaying an OS logo in the Grid UI
1 parent b143b96 commit 4f1781e

File tree

9 files changed

+175
-6
lines changed

9 files changed

+175
-6
lines changed

javascript/grid-ui/src/assets/operating-systems/linux.svg

+121
Loading
Loading
Loading

javascript/grid-ui/src/components/Node/Node.tsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import operaBlinkLogo from "../../assets/browsers/opera.svg";
66
import firefoxLogo from "../../assets/browsers/firefox.svg";
77
import safariLogo from "../../assets/browsers/safari.svg";
88
import safariTechnologyPreviewLogo from "../../assets/browsers/safari.svg";
9+
import macLogo from "../../assets/operating-systems/mac.svg";
10+
import windowsLogo from "../../assets/operating-systems/windows.svg";
11+
import linuxLogo from "../../assets/operating-systems/linux.svg";
912
import InfoIcon from '@material-ui/icons/Info';
1013
import NodeType from "../../models/node";
1114

@@ -50,6 +53,19 @@ const browserLogoPath = (browser: string): string => {
5053
}
5154
};
5255

56+
const osLogoPath = (os: string): string => {
57+
const osLowerCase: string = os.toLowerCase();
58+
if (osLowerCase.includes("win")) {
59+
return windowsLogo;
60+
}
61+
if (osLowerCase.includes("mac")) {
62+
return macLogo;
63+
}
64+
if (osLowerCase.includes("nix") || osLowerCase.includes("nux") || osLowerCase.includes("aix")) {
65+
return linuxLogo;
66+
}
67+
return "";
68+
};
5369

5470
export default function Node(props) {
5571
const classes = useStyles();
@@ -59,8 +75,7 @@ export default function Node(props) {
5975
// Assuming we will put 3 stereotypes per column.
6076
const stereotypeColumns = Math.round(nodeInfo.slotStereotypes.length / 3);
6177
// Then we need to know how many columns we will display.
62-
const columnWidth: GridSize = 6;
63-
// const columnWidth = 12 / 12;
78+
const columnWidth: GridSize = 12 / stereotypeColumns as any;
6479

6580
return (
6681
<Card
@@ -92,7 +107,7 @@ export default function Node(props) {
92107
>
93108
{/*TODO: User proper logos after getting OS info from backend*/}
94109
<img
95-
src={chromeLogo}
110+
src={osLogoPath(nodeInfo.osInfo.name)}
96111
className={classes.osLogo}
97112
alt="OS Logo"
98113
/>
@@ -122,7 +137,6 @@ export default function Node(props) {
122137
nodeInfo.slotStereotypes
123138
.slice(index * 3, Math.min((index * 3) + 3, nodeInfo.slotStereotypes.length))
124139
.map((slotStereotype: any, idx) => {
125-
console.log(slotStereotype)
126140
return (<Typography
127141
color="textPrimary"
128142
variant="h6"

javascript/grid-ui/src/graphql/grid.gql

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ query {
99
stereotypes
1010
version
1111
sessionCount
12+
osInfo {
13+
version
14+
name
15+
arch
16+
}
1217
}
1318
totalSlots
1419
usedSlots

javascript/grid-ui/src/models/node.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import OsInfoType from "./os-info";
12
import CapabilitiesType from "./capabilities";
23

34
interface NodeType {
@@ -15,6 +16,8 @@ interface NodeType {
1516
sessionCount: number;
1617
/** Grid Node version */
1718
version: string;
19+
/** Grid Node OS information */
20+
osInfo: OsInfoType;
1821
/** Node stereotypes.
1922
* Not an ideal type, but it simplifies the parsing.
2023
* There is room for improvement here. */
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface OsInfoType {
2+
name: string;
3+
version: string;
4+
arch: string;
5+
}
6+
7+
export default OsInfoType;

javascript/grid-ui/src/screens/Overview/Overview.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Node from "../../components/Node/Node";
2525
import {useQuery} from "@apollo/client";
2626
import NodeType from "../../models/node";
2727
import {Link} from "@material-ui/core";
28+
import OsInfoType from "../../models/os-info";
2829

2930
function Copyright() {
3031
return (
@@ -153,14 +154,20 @@ export default function Overview() {
153154

154155
const gridVersion = data.grid.version;
155156
const nodes = data.grid.nodes.map((node) => {
157+
const osInfo: OsInfoType = {
158+
name: node.osInfo.name,
159+
version: node.osInfo.version,
160+
arch: node.osInfo.arch,
161+
}
156162
const slotStereotypes = JSON.parse(node.stereotypes);
157163
const newNode: NodeType = {
158164
uri: node.uri,
159-
capabilities: [],
160165
id: node.id,
166+
capabilities: [],
161167
status: node.status,
162168
maxSession: node.maxSession,
163169
version: node.version,
170+
osInfo: osInfo,
164171
sessionCount: node.sessionCount ?? 0,
165172
slotStereotypes: slotStereotypes,
166173
};

javascript/grid-ui/src/theme/theme.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const theme = createMuiTheme({
1515
main: red.A400,
1616
},
1717
background: {
18-
default: '#fff',
18+
default: '#F7F8F8',
1919
},
2020
},
2121
typography

0 commit comments

Comments
 (0)