Skip to content

Commit

Permalink
reworked some parts of the app, added vehicles view
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaiblaga89 committed Dec 8, 2019
1 parent 6c542e8 commit f36d33e
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 475 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"warn",
180
],
"react/jsx-props-no-spreading": "off"
"react/jsx-props-no-spreading": "off",
"react/forbid-prop-types": "off"
},
"env": {
"node": true,
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/npmpublish.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Package

on:
push:
tags:
- '*'

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn
- run: yarn build
- name: Upload
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/bmw-status-${{ github.ref }}.dmg
asset_name: macos
tag: ${{ github.ref }}
overwrite: true
77 changes: 14 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,19 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
# WORK IN PROGRESS

## Available Scripts
App implementing BMW's Connected Drive API using Electron and React

In the project directory, you can run:
Features

### `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
- [x] Login
- [ ] Login with TouchID
- [x] View cars
- [ ] Access car details
- [ ] View PHEV/EV charging status
- [ ] Implement polling for charging status
- [ ] Add notifications for charging status
- [ ] Implement service execution for heating/horn/lights (note: Lock/Unlock **will never be implemented for security reasons**)
- [ ] Let's see whatever comes to mind

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

### Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

### Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

### Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

### Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

### `npm run build` fails to minify
### `npm start`

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
App will open but keep in mind it's a tray app.
9 changes: 9 additions & 0 deletions __tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from '../src/App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
4 changes: 1 addition & 3 deletions config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const ignoredFiles = require('react-dev-utils/ignoredFiles');
const paths = require('./paths');
const fs = require('fs');
const paths = require('./paths');

const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@mihaiblaga89/bmw-connecteddrive-api": "^0.4.1",
"@reach/router": "^1.2.1",
"electron": "^6.1.5",
"electron-is-dev": "^1.1.0",
"electron-store": "^5.1.0",
"keytar": "^5.0.0",
Expand Down Expand Up @@ -62,7 +63,6 @@
"css-loader": "2.1.1",
"dotenv": "6.2.0",
"dotenv-expand": "5.1.0",
"electron": "^6.1.5",
"electron-builder": "^21.2.0",
"eslint": "^6.7.2",
"eslint-config-airbnb": "^18.0.1",
Expand Down Expand Up @@ -102,7 +102,6 @@
"resolve-url-loader": "3.1.1",
"sass-loader": "7.3.1",
"semver": "6.3.0",
"spectron": "^9.0.0",
"style-loader": "1.0.1",
"terser-webpack-plugin": "1.4.2",
"ts-pnp": "1.1.5",
Expand Down
28 changes: 12 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,32 @@ import {
LocationProvider,
Router,
} from '@reach/router';
import styled from 'styled-components';

import './App.css';
import Login from './pages/login';
import Dashboard from './pages/dashboard';

const electron = window.require('electron').remote;
const notifier = window.require('node-notifier');
// const electron = window.require('electron').remote;
// const notifier = window.require('node-notifier');

const source = createMemorySource('/');
const history = createHistory(source);

const Wrapper = styled.div`
background-color: white;
height: 100%;
`;

const App = () => (
<div style={{ backgroundColor: 'white', height: '100%' }}>
<Wrapper>
<LocationProvider history={history}>
<Router style={{ height: '100%' }}>
<Login path="/" />
<Dashboard path="/dash" />
<Login default path="login" />
<Dashboard path="dash/*" />
</Router>
</LocationProvider>
</div>
</Wrapper>
);

// const App = () => {
// return (
// <div className="App">
// <header className="App-header">
// <img src={logo} className="App-logo" alt="logo" />
// </header>
// </div>
// );
// };

export default App;
9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

Binary file added src/assets/images/car-placeholder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 19 additions & 15 deletions src/components/Vehicle/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { Card, Image, Icon } from 'semantic-ui-react';
import { Card, Image, Placeholder } from 'semantic-ui-react';

const Vehicle = ({ vehicle }) => {
console.log('veh', vehicle, vehicle.vin);
import carPlaceholder from '../../assets/images/car-placeholder.jpg';

const Vehicle = ({ vehicle, onClick }) => {
const [image, setImage] = useState(null);

useEffect(() => {
vehicle.getImage().then(setImage);
vehicle
.getImage()
.then(setImage)
.catch(() => setImage(carPlaceholder));
}, []);

return (
<Card>
{image && <Image src={image} wrapped />}
<Card onClick={onClick}>
{image ? (
<Image src={image} wrapped />
) : (
<Placeholder>
<Placeholder.Image square />
</Placeholder>
)}
<Card.Content>
<Card.Header>{vehicle.vin}</Card.Header>
<Card.Header>{vehicle.name}</Card.Header>
<Card.Meta>
<span className="date">Joined in 2015</span>
<span>{vehicle.vin}</span>
</Card.Meta>
<Card.Description>
Matthew is a musician living in Nashville.
</Card.Description>
</Card.Content>
<Card.Content extra>
<Icon name="user" />
22 Friends
</Card.Content>
</Card>
);
};

Vehicle.propTypes = {
vehicle: PropTypes.object.isRequired,
onClick: PropTypes.func.isRequired,
};

export default Vehicle;
48 changes: 48 additions & 0 deletions src/components/tabs/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import { Segment, Header, Icon, Button } from 'semantic-ui-react';
import BMWApi from '@mihaiblaga89/bmw-connecteddrive-api';
import PropTypes from 'prop-types';

import { OPEN_ISSUE_URL } from '../../constants';
import Vehicle from '../Vehicle';

const { shell } = window.require('electron');

const HomeTab = ({ navigate }) => {
const { vehicles } = BMWApi;
if (!vehicles.length) {
return (
<Segment placeholder>
<Header icon>
<Icon name="car" />
You have no car registered in BMW's Connected Drive or the
API is not returning them. If you think this is an issue,
please open a new issue on GitHub
</Header>
<Button
onClick={() => shell.openExternal(OPEN_ISSUE_URL)}
primary
>
Open issue
</Button>
</Segment>
);
}
return (
<Segment>
{vehicles.map(vehicle => (
<Vehicle
onClick={() => navigate(`vehicle/${vehicle.vin}`)}
vehicle={vehicle}
key={vehicle.vin}
/>
))}
</Segment>
);
};

HomeTab.propTypes = {
navigate: PropTypes.func,
};

export default HomeTab;
13 changes: 13 additions & 0 deletions src/components/tabs/vehicle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { useEffect } from 'react';
import { Segment, Button } from 'semantic-ui-react';

const VehicleTab = (...args) => {
console.log('asd', args);
return (
<Segment>
<Button labelPosition="left" icon="left chevron" content="Back" />
</Segment>
);
};

export default VehicleTab;
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const CREDENTIALS_SERVICE = 'BMWStatusApp';
export const OPEN_ISSUE_URL =
'https://github.com/mihaiblaga89/bmw-status-app/issues/new';
export const REGION_SELECT_OPTIONS = [
{
key: 'eu',
Expand Down
Loading

0 comments on commit f36d33e

Please sign in to comment.