Skip to content

Commit

Permalink
Add prettier formatter and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
vetlek committed Dec 14, 2021
1 parent cd1be3f commit 76533aa
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 227 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ Flotilla is the main point of access for operators to interact with multiple rob

## Setup

For development, please fork the repository. Then, clone the repository:
For development, please fork the repository. Then, clone the repository:

```
$ git clone https://github.com/equinor/flotilla
```

The app use TypeScript and React. For development, Node v17.x needs to be installed. Installation instructions can be found [here](https://github.com/nodesource/distributions/blob/master/README.md).


## Install

To install the application, navigate to the root folder and run the following command:
To install the application, navigate to the root folder and run the following command:

```
$ npm ci
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"typescript": "^4.5.2",
"web-vitals": "^1.1.2"
},
"devDependencies": {
"prettier": "^2.4.1"
},
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts build",
Expand Down
39 changes: 20 additions & 19 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -22,13 +24,13 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Flotilla</title>
</head>
<title>Flotilla</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -38,6 +40,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>

</body>
</html>
47 changes: 28 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
import { Icon, Typography } from '@equinor/eds-core-react';
import { platform } from '@equinor/eds-icons';
import { RobotOverview } from "./components/RobotOverview"
import { defaultRobots } from "./models/robot"
import './app.css'
import { Icon, Typography } from "@equinor/eds-core-react";
import { platform } from "@equinor/eds-icons";
import { RobotOverview } from "./components/RobotOverview";
import { defaultRobots } from "./models/robot";
import "./app.css";
Icon.add({ platform });

const robots = [defaultRobots["taurob"], defaultRobots["exRobotics"], defaultRobots["turtle"]]
const robots = [
defaultRobots["taurob"],
defaultRobots["exRobotics"],
defaultRobots["turtle"],
];

function App() {
return (
<div className='app-ui'>
<div className='header'>
<Typography color="primary" variant="h1" bold>Flotilla</Typography>
</div>
<div className='robot-overview'>
<RobotOverview robots={robots}></RobotOverview>
</div>
<div className='mission-overview'>
<Typography variant='h2' style={{ "marginTop": "20px" }}>Mission Overview</Typography>
</div>
</div>)
return (
<div className="app-ui">
<div className="header">
<Typography color="primary" variant="h1" bold>
Flotilla
</Typography>
</div>
<div className="robot-overview">
<RobotOverview robots={robots}></RobotOverview>
</div>
<div className="mission-overview">
<Typography variant="h2" style={{ marginTop: "20px" }}>
Mission Overview
</Typography>
</div>
</div>
);
}

export default App
export default App;
50 changes: 24 additions & 26 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
.app-ui {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(384px, 1fr));
grid-gap: 16px;
margin-left: 24px;
margin-top: 24px;
}

.header {
grid-column-start: 1;
grid-column-end: -1;
}

.robot-overview {
grid-column-end: span 2;
grid-row-end: span 2;
max-height: 500px;
}

.mission-overview{
grid-column-end: span 2;
grid-row-end: span 2;
overflow: auto;
max-height: 500px;
}


display: grid;
grid-template-columns: repeat(auto-fit, minmax(384px, 1fr));
grid-gap: 16px;
margin-left: 24px;
margin-top: 24px;
}

.header {
grid-column-start: 1;
grid-column-end: -1;
}

.robot-overview {
grid-column-end: span 2;
grid-row-end: span 2;
max-height: 500px;
}

.mission-overview {
grid-column-end: span 2;
grid-row-end: span 2;
overflow: auto;
max-height: 500px;
}
78 changes: 42 additions & 36 deletions src/components/RobotOverview/RobotOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
import { Icon, Typography, Table } from '@equinor/eds-core-react';
import { info_circle } from '@equinor/eds-icons';
import { Robot } from "../../models/robot"
import styles from './robotOverview.module.css'
import RobotOverviewHeader from './RobotOverviewHeader'
import { Icon, Typography, Table } from "@equinor/eds-core-react";
import { info_circle } from "@equinor/eds-icons";
import { Robot } from "../../models/robot";
import styles from "./robotOverview.module.css";
import RobotOverviewHeader from "./RobotOverviewHeader";

Icon.add({ info_circle });

interface RobotProps {
robot: Robot
robot: Robot;
}

const RobotStatus: React.FC<RobotProps> = ({ robot }: RobotProps) => {
const name = robot.robotInfo.name
const type = robot.robotInfo.type
const status = robot.status
const battery = robot.battery
return (
<Table.Row className={styles.tableRowWrapper}>
<Table.Cell className={styles.tableNameCell}>{name}</Table.Cell>
<Table.Cell className={styles.tableTypeCell}>{type}</Table.Cell>
<Table.Cell className={styles.tableStatusCell}>{status}</Table.Cell>
<Table.Cell className={styles.tableBatteryCell} variant="numeric">{battery}</Table.Cell>
<Table.Cell className={styles.tableInfoCell} variant="icon"><Icon name="info_circle" size={24} color="primary" /></Table.Cell>
</Table.Row>
);
const name = robot.robotInfo.name;
const type = robot.robotInfo.type;
const status = robot.status;
const battery = robot.battery;
return (
<Table.Row className={styles.tableRowWrapper}>
<Table.Cell className={styles.tableNameCell}>{name}</Table.Cell>
<Table.Cell className={styles.tableTypeCell}>{type}</Table.Cell>
<Table.Cell className={styles.tableStatusCell}>{status}</Table.Cell>
<Table.Cell className={styles.tableBatteryCell} variant="numeric">
{battery}
</Table.Cell>
<Table.Cell className={styles.tableInfoCell} variant="icon">
<Icon name="info_circle" size={24} color="primary" />
</Table.Cell>
</Table.Row>
);
};

interface RobotOverviewProps {
robots: Robot[]
robots: Robot[];
}

const RobotOverview: React.FC<RobotOverviewProps> = ({ robots }: RobotOverviewProps) => {
var robotComponnets = robots.map(function (robot) {
return <RobotStatus robot={robot} />
});
return (
<Table className={styles.tableWrapper}>
<Table.Caption captionSide className={styles.tableCaption}>
<Typography variant="h2">Robot Overview</Typography>
</Table.Caption>
<RobotOverviewHeader />
<Table.Body className={styles.tableBodyWrapper}>
{robotComponnets}
</Table.Body>
</Table>
);
const RobotOverview: React.FC<RobotOverviewProps> = ({
robots,
}: RobotOverviewProps) => {
var rows = robots.map(function (robot) {
return <RobotStatus robot={robot} />;
});
return (
<Table className={styles.tableWrapper}>
<Table.Caption captionSide className={styles.tableCaption}>
<Typography variant="h2">Robot Overview</Typography>
</Table.Caption>
<RobotOverviewHeader />
<Table.Body className={styles.tableBodyWrapper}>
{rows}
</Table.Body>
</Table>
);
};

export default RobotOverview
export default RobotOverview;
60 changes: 39 additions & 21 deletions src/components/RobotOverview/RobotOverviewHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
import { Table } from "@equinor/eds-core-react";
import React from "react";
import styles from "./robotOverview.module.css"
import styles from "./robotOverview.module.css";

interface RobotOverviewHeaderCellProps {
label: string,
overideClassName?: string
};
label: string;
overideClassName?: string;
}

const RobotOverviewHeaderCell: React.FC<RobotOverviewHeaderCellProps> = ({ label, overideClassName }: RobotOverviewHeaderCellProps) => {
return (
<Table.Cell className={overideClassName}>
<span className={styles.label}>{label}</span>
</Table.Cell>
)
const RobotOverviewHeaderCell: React.FC<RobotOverviewHeaderCellProps> = ({
label,
overideClassName,
}: RobotOverviewHeaderCellProps) => {
return (
<Table.Cell className={overideClassName}>
<span className={styles.label}>{label}</span>
</Table.Cell>
);
};

const RobotOverviewHeader = () => {
return (
<Table.Head className={styles.tableHeadWrapper}>
<Table.Row className={styles.tableRowWrapper}>
<RobotOverviewHeaderCell label="Name" overideClassName={styles.tableNameCell} />
<RobotOverviewHeaderCell label="Type" overideClassName={styles.tableTypeCell} />
<RobotOverviewHeaderCell label="Status" overideClassName={styles.tableStatusCell} />
<RobotOverviewHeaderCell label="Battery" overideClassName={styles.tableBatteryCell} />
<RobotOverviewHeaderCell label="Info" overideClassName={styles.tableInfoCell} />
</Table.Row>
</Table.Head>
);
return (
<Table.Head className={styles.tableHeadWrapper}>
<Table.Row className={styles.tableRowWrapper}>
<RobotOverviewHeaderCell
label="Name"
overideClassName={styles.tableNameCell}
/>
<RobotOverviewHeaderCell
label="Type"
overideClassName={styles.tableTypeCell}
/>
<RobotOverviewHeaderCell
label="Status"
overideClassName={styles.tableStatusCell}
/>
<RobotOverviewHeaderCell
label="Battery"
overideClassName={styles.tableBatteryCell}
/>
<RobotOverviewHeaderCell
label="Info"
overideClassName={styles.tableInfoCell}
/>
</Table.Row>
</Table.Head>
);
};

export default RobotOverviewHeader;
Loading

0 comments on commit 76533aa

Please sign in to comment.