Skip to content

Commit

Permalink
Merge pull request #15 from jpedroh/release/v4.1.0
Browse files Browse the repository at this point in the history
release/v4.1.0
  • Loading branch information
jpedroh authored Sep 29, 2020
2 parents 53b2e97 + 655adf3 commit bb51157
Show file tree
Hide file tree
Showing 20 changed files with 645 additions and 541 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "root",
"version": "4.0.0",
"version": "4.1.0",
"license": "MIT",
"private": "true",
"devDependencies": {
"@mach/eslint-config": "*",
"@mach/prettier-config": "*",
"@types/jest": "^26.0.8",
"@types/node": "^14.0.27",
"jest": "^26.2.2",
"ts-jest": "^26.1.4",
"typescript": "^3.9.7",
"@mach/eslint-config": "*",
"@mach/prettier-config": "*"
"typescript": "^3.9.7"
},
"scripts": {
"build": "yarn lerna run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mach/common",
"version": "4.0.0",
"version": "4.1.0",
"description": "> TODO: description",
"author": "Joao Pedro Henrique <[email protected]>",
"homepage": "https://github.com/jpedroh/mach#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mach/database",
"version": "4.0.0",
"version": "4.1.0",
"description": "> TODO: description",
"author": "Joao Pedro Henrique <[email protected]>",
"homepage": "https://github.com/jpedroh/mach#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mach/eslint-config",
"version": "4.0.0",
"version": "4.1.0",
"main": ".eslintrc.js",
"license": "MIT",
"devDependencies": {
Expand Down
16 changes: 16 additions & 0 deletions packages/front/actions/get-icao-fpl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Flight from '@mach/common'
import formatEet from '../utils/format-eet'
import formatFlightRules from '../utils/format-flight-rules'

const getIcaoFpl = (flight: Flight): string => {
return [
`(FPL-${flight.callsign}-${formatFlightRules(flight.flightRules)}S`,
`-1/${flight.aircraft.icaoCode}/${flight.aircraft.wakeTurbulence}-${flight.aircraft.equipment}/L1B1`,
`-${flight.arrivalIcao}${flight.estimatedOffBlockTime}`,
`-${flight.cruisingSpeed}F${flight.cruisingLevel} ${flight.route}`,
`-${flight.arrivalIcao}${formatEet(flight.estimatedEnrouteMinutes)}`,
`-${flight.remarks})`
].join('\n')
}

export default getIcaoFpl
45 changes: 43 additions & 2 deletions packages/front/components/flight-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Flight from '@mach/common'
import React from 'react'
import Button from 'react-bootstrap/Button'
import Modal from 'react-bootstrap/Modal'
import Flight from '@mach/common'
import formatEet from '../utils/format-eet'
import IcaoFpl from './icao-fpl'
import IvaoButton from './ivao-button'
import SkyVectorButton from './sky-vector-button'
import VatsimButton from './vatsim-button'

Expand All @@ -27,7 +29,45 @@ const FlightModal: React.FC<FlightModalProps> = ({
</Modal.Header>

<Modal.Body>
<h6>ICAO FPL</h6>
<h5 className="mb-3">GENERAL INFORMATION</h5>
<div className="row">
<div className="col-6">
<p>
<b>EOBT </b> {flight.estimatedOffBlockTime}Z
</p>
</div>
<div className="col-6">
<p>
<b>FLIGHT TIME </b> {formatEet(flight.estimatedEnrouteMinutes)}
</p>
</div>
<div className="col-4">
<p>
<b>AIRCRAFT </b> {flight.aircraft.icaoCode}
</p>
</div>
<div className="col-4">
<p>
<b>CRUISING SPEED </b> {flight.cruisingSpeed}
</p>
</div>
<div className="col-4">
<p>
<b>FL </b> {flight.cruisingLevel}
</p>
</div>
<div className="col-12">
<p>
<b>ROUTE </b> {flight.route}
</p>
</div>
<div className="col-12">
<p>
<b>REMARKS </b> {flight.remarks}
</p>
</div>
</div>
<h5 className="my-3">ICAO FPL</h5>
<IcaoFpl flight={flight} />
</Modal.Body>
<Modal.Footer>
Expand All @@ -36,6 +76,7 @@ const FlightModal: React.FC<FlightModalProps> = ({
</Button>
<SkyVectorButton flight={flight} />
<VatsimButton flight={flight} />
<IvaoButton flight={flight} />
</Modal.Footer>
</Modal>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/front/components/footer-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const FooterNav: React.FC = () => {
</Nav.Item>
<Nav.Item>
<Nav.Link href="https://www.github.com/jpedroh/mach" target="_blank">
Mach v4.0.0
Mach v4.1.0
</Nav.Link>
</Nav.Item>
<Nav.Item>
Expand Down
26 changes: 3 additions & 23 deletions packages/front/components/icao-fpl.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import Flight, { FlightRules } from '@mach/common'
import getIcaoFpl from '../actions/get-icao-fpl'

type IcaoFplProps = {
flight: Flight
Expand All @@ -21,29 +22,8 @@ const formatEet = (eet: number) => {

const IcaoFpl: React.FC<IcaoFplProps> = ({ flight }) => {
return (
<pre
className="bg-light pt-3 px-2 border rounded"
style={{ lineHeight: '6px' }}
>
<p>
(FPL-{flight.callsign}-{flightRules(flight.flightRules)}S
</p>
<p>
-1/{flight.aircraft.icaoCode}/{flight.aircraft.wakeTurbulence}-
{flight.aircraft.equipment}/L1B1
</p>
<p>
-{flight.arrivalIcao}
{flight.estimatedOffBlockTime}
</p>
<p>
-{flight.cruisingSpeed}F{flight.cruisingLevel} {flight.route}
</p>
<p>
-{flight.arrivalIcao}
{formatEet(flight.estimatedEnrouteMinutes)}
</p>
<p>-{flight.remarks})</p>
<pre className="bg-light pt-2 px-2 border rounded">
<p>{getIcaoFpl(flight)}</p>
</pre>
)
}
Expand Down
65 changes: 65 additions & 0 deletions packages/front/components/ivao-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Flight from '@mach/common'
import React from 'react'
import Button from 'react-bootstrap/Button'
import formatEet from '../utils/format-eet'
import formatFlightRules from '../utils/format-flight-rules'

type IvaoButtonProps = {
flight: Flight
}

const IvaoButton: React.FC<IvaoButtonProps> = ({ flight }) => {
return (
<form
id="ivaoform"
action="https://fpl.ivao.aero/api/fp/load"
method="POST"
target="_blank"
>
<input type="hidden" name="CALLSIGN" value={flight.callsign} />
<input
type="hidden"
name="RULES"
value={formatFlightRules(flight.flightRules)}
/>
<input type="hidden" name="FLIGHTTYPE" value="S" />
<input type="hidden" name="NUMBER" value="1" />
<input type="hidden" name="ACTYPE" value={flight.aircraft.icaoCode} />
<input
type="hidden"
name="WAKECAT"
value={flight.aircraft.wakeTurbulence}
/>
<input type="hidden" name="EQUIPMENT" value={flight.aircraft.equipment} />
<input type="hidden" name="TRANSPONDER" value="LB1" />
<input type="hidden" name="DEPICAO" value={flight.departureIcao} />
<input
type="hidden"
name="DEPTIME"
value={flight.estimatedOffBlockTime}
/>
<input type="hidden" name="SPEEDTYPE" value="N" />
<input
type="hidden"
name="SPEED"
value={flight.cruisingSpeed.substr(1)}
/>
<input type="hidden" name="LEVELTYPE" value="F" />
<input type="hidden" name="LEVEL" value={flight.cruisingLevel} />
<input type="hidden" name="ROUTE" value={flight.route} />
<input type="hidden" name="DESTICAO" value={flight.arrivalIcao} />
<input
type="hidden"
name="EET"
value={formatEet(flight.estimatedEnrouteMinutes)}
/>
<input type="hidden" name="OTHER" value={flight.remarks} />

<Button type="submit" variant="primary">
File IVAO FP
</Button>
</form>
)
}

export default IvaoButton
4 changes: 2 additions & 2 deletions packages/front/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const isProd = process.env.NODE_ENV === 'production'

module.exports = {
basePath: '/mach',
assetPrefix: '/mach/',
basePath: isProd ? '/mach' : '',
assetPrefix: isProd ? '/mach/' : ''
}
2 changes: 1 addition & 1 deletion packages/front/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mach/front",
"version": "4.0.0",
"version": "4.1.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
3 changes: 2 additions & 1 deletion packages/front/pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FlightModal from '../components/flight-modal'
import ResultsLead from '../components/results-lead'
import SearchTable from '../components/search-table'
import BaseLayout from '../layouts/base-layout'
import makeBlankFlight from '../utils/make-blank-flight'

const buildParameters = query => {
const parameters: GetFlightsQuery = {
Expand All @@ -30,7 +31,7 @@ const Search: NextPage = () => {
const [loading, setLoading] = React.useState(true)
const [show, setShow] = React.useState(false)
const [apiResponse, setApiResponse] = React.useState({ count: 0, items: [] })
const [flight, setFlight] = React.useState<any>({})
const [flight, setFlight] = React.useState(makeBlankFlight())

const handleClose = () => setShow(false)
const handleShow = flight => {
Expand Down
7 changes: 7 additions & 0 deletions packages/front/utils/format-eet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const formatEet = (eet: number) => {
const hours = Math.floor(eet / 60)
const minutes = eet % 60
return `${hours}`.padStart(2, '0') + `${minutes}`.padStart(2, '0')
}

export default formatEet
11 changes: 11 additions & 0 deletions packages/front/utils/format-flight-rules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { FlightRules } from '@mach/common'

const formatFlightRules = (flightRule: FlightRules): string => {
const mappings = {}
mappings[FlightRules.IFR] = 'I'
mappings[FlightRules.Y] = 'Y'
mappings[FlightRules.Z] = 'Z'
return mappings[flightRule]
}

export default formatFlightRules
25 changes: 25 additions & 0 deletions packages/front/utils/make-blank-flight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Flight, { FlightRules, WakeTurbulence } from '@mach/common'

const makeBlankFlight = (): Flight => ({
callsign: '',
beginDate: new Date(),
company: '',
flightNumber: 0,
aircraft: {
icaoCode: '',
equipment: '',
wakeTurbulence: WakeTurbulence.LIGHT
},
departureIcao: '',
estimatedOffBlockTime: '0000',
cruisingSpeed: '',
weekdays: [],
cruisingLevel: 0,
route: '',
arrivalIcao: '',
estimatedEnrouteMinutes: 0,
remarks: '',
flightRules: FlightRules.IFR
})

export default makeBlankFlight
2 changes: 1 addition & 1 deletion packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mach/prettier-config",
"version": "4.0.0",
"version": "4.1.0",
"main": "prettier.config.js",
"license": "MIT",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"contact": {
"email": "[email protected]"
},
"version": "4.0.0"
"version": "4.1.0"
},
"servers": [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/rest-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mach/rest-api",
"private": true,
"version": "4.0.0",
"version": "4.1.0",
"description": "> TODO: description",
"author": "Joao Pedro Henrique <[email protected]>",
"homepage": "https://github.com/jpedroh/mach#readme",
Expand All @@ -21,9 +21,9 @@
"url": "https://github.com/jpedroh/mach/issues"
},
"dependencies": {
"express": "^4.17.1",
"@mach/common": "^4.0.0",
"@mach/database": "^4.0.0"
"@mach/database": "^4.0.0",
"express": "^4.17.1"
},
"devDependencies": {
"@types/express": "^4.17.7"
Expand Down
8 changes: 4 additions & 4 deletions packages/rpl-crawler/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mach/rpl-crawler",
"private": true,
"version": "4.0.0",
"version": "4.1.0",
"main": "dist/index.js",
"files": [
"dist"
Expand All @@ -13,10 +13,10 @@
"build": "tsc"
},
"dependencies": {
"adm-zip": "^0.4.16",
"axios": "^0.19.2",
"@mach/common": "^4.0.0",
"@mach/database": "^4.0.0"
"@mach/database": "^4.0.0",
"adm-zip": "^0.4.16",
"axios": "^0.19.2"
},
"devDependencies": {
"@types/adm-zip": "^0.4.33",
Expand Down
Loading

0 comments on commit bb51157

Please sign in to comment.