Skip to content

Commit 49e4f47

Browse files
committed
project creation
1 parent 835a577 commit 49e4f47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1499
-0
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# dependencies
2+
/node_modules
3+
4+
# production
5+
/out
6+
/dist
7+
/build
8+
9+
# misc
10+
.DS_Store
11+
.env.local
12+
.env.development.local
13+
.env.test.local
14+
.env.production.local
15+
.webpack
16+
17+
npm-debug.log
18+
yarn-debug.log*
19+
yarn-error.log*
20+
.idea
21+
package-lock.json

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Awair-uploader
2+
This is a community based opensource tool that is capable of fetching data of Awair Element devices from Awair servers and send them to a custom endpoint.
3+
The idea behind this project is to send these data to PlanetWatch servers in order to be able to be still elibile for rewards.
4+
5+
## Installation
6+
Since the project is not yet approved by PlanetWatch Company, the software is basically only fetching data from Awair's servers. For the time being we discourage any usage of this project until PlanetWatch approves and shares the endpoints where to write our data.
7+
8+
If you still want to install this tool, just run clone the repository and run the following commands:
9+
```sh
10+
npm install
11+
npm start
12+
```
13+
14+
If you want to create a standalone version of Awair-uploader, run the following commands:
15+
```sh
16+
npm run make
17+
```
18+
19+
## Contributing
20+
21+
The project was developed on MacOS and the building section is only for MacOS. Feel free to contribute to the project by adding your distro building section (Windows/Linux) with a Pull Request.
22+
23+
We will appreciate any help to improve of the code.
24+
25+
Stay tuned for next updates coming in the next days!

package.json

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"name": "awair-uploader",
3+
"productName": "awair-uploader",
4+
"version": "0.0.1",
5+
"description": "An Awair Element data uploader",
6+
"main": ".webpack/main",
7+
"scripts": {
8+
"start": "electron-forge start",
9+
"package": "electron-forge package",
10+
"make": "electron-forge make",
11+
"publish": "electron-forge publish",
12+
"lint": "eslint --ext .ts,.tsx ."
13+
},
14+
"keywords": [],
15+
"license": "GNU GPL V3",
16+
"config": {
17+
"forge": {
18+
"packagerConfig": {},
19+
"makers": [
20+
{
21+
"name": "@electron-forge/maker-squirrel",
22+
"config": {
23+
"name": "awair-uploader"
24+
}
25+
},
26+
{
27+
"name": "@electron-forge/maker-zip",
28+
"platforms": [
29+
"darwin"
30+
]
31+
},
32+
{
33+
"name": "@electron-forge/maker-dmg"
34+
},
35+
{
36+
"name": "@electron-forge/maker-deb",
37+
"config": {}
38+
},
39+
{
40+
"name": "@electron-forge/maker-rpm",
41+
"config": {}
42+
}
43+
],
44+
"plugins": [
45+
[
46+
"@electron-forge/plugin-webpack",
47+
{
48+
"mainConfig": "./webpack.main.config.js",
49+
"devContentSecurityPolicy": "connect-src 'self' https://developer-apis.awair.is 'unsafe-eval'",
50+
"renderer": {
51+
"config": "./webpack.renderer.config.js",
52+
"entryPoints": [
53+
{
54+
"html": "./src/index.html",
55+
"js": "./src/renderer.ts",
56+
"name": "main_window"
57+
}
58+
]
59+
}
60+
}
61+
]
62+
]
63+
}
64+
},
65+
"devDependencies": {
66+
"@electron-forge/cli": "^6.0.0-beta.63",
67+
"@electron-forge/maker-deb": "^6.0.0-beta.63",
68+
"@electron-forge/maker-dmg": "6.0.0-beta.63",
69+
"@electron-forge/maker-rpm": "^6.0.0-beta.63",
70+
"@electron-forge/maker-squirrel": "^6.0.0-beta.63",
71+
"@electron-forge/maker-zip": "^6.0.0-beta.63",
72+
"@electron-forge/plugin-webpack": "^6.0.0-beta.63",
73+
"@types/javascript-time-ago": "^2.0.3",
74+
"@types/luxon": "^2.3.1",
75+
"@types/react": "^17.0.38",
76+
"@types/react-dom": "^17.0.11",
77+
"@typescript-eslint/eslint-plugin": "^5.15.0",
78+
"@typescript-eslint/parser": "^5.9.1",
79+
"@vercel/webpack-asset-relocator-loader": "^1.7.0",
80+
"css-loader": "^6.5.1",
81+
"electron": "16.0.7",
82+
"eslint": "^8.6.0",
83+
"eslint-config-airbnb-typescript": "^16.1.3",
84+
"eslint-config-react-app": "^7.0.0",
85+
"eslint-plugin-import": "^2.25.4",
86+
"fork-ts-checker-webpack-plugin": "^6.5.0",
87+
"node-loader": "^2.0.0",
88+
"style-loader": "^3.3.1",
89+
"ts-loader": "^9.2.6",
90+
"typescript": "~4.5.4"
91+
},
92+
"dependencies": {
93+
"@react-keycloak/web": "^3.4.0",
94+
"@reduxjs/toolkit": "^1.8.0",
95+
"@types/react-router-dom": "^5.3.3",
96+
"antd": "^4.19.3",
97+
"axios": "^0.26.1",
98+
"electron-squirrel-startup": "^1.0.0",
99+
"javascript-time-ago": "^2.3.13",
100+
"jwt-decode": "^3.1.2",
101+
"keycloak-js": "^17.0.0",
102+
"luxon": "^2.3.1",
103+
"react": "^17.0.2",
104+
"react-dom": "^17.0.2",
105+
"react-redux": "^7.2.6",
106+
"react-router-dom": "^6.2.2"
107+
}
108+
}

src/App.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.loading {
2+
margin: 0 auto;
3+
font-weight: bold;
4+
}

src/app.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React, { useEffect } from 'react';
2+
import { connect } from 'react-redux';
3+
4+
import RouteHelper from './components/appUtils/RouteHelper';
5+
import MainPage from './pages/MainPage';
6+
import { StoreType } from './store';
7+
import { authorization } from './utils/authorization';
8+
import Scheduler from './scheduler';
9+
import { Sensors } from './types/planetWatch/sensors';
10+
import './App.css';
11+
12+
interface HomePageProps {
13+
isReady: boolean
14+
}
15+
16+
const App = (props: HomePageProps) => {
17+
if (!props.isReady) {
18+
return <div className='loading'>Loading...</div>;
19+
}
20+
21+
if (authorization?.isAuthenticated() === false) {
22+
authorization?.login();
23+
return <><div className='loading'>Redirecting to Login</div></>;
24+
}
25+
26+
const onComplete = (response: Sensors) => {
27+
console.log(response);
28+
};
29+
30+
useEffect(() => {
31+
Scheduler.getInstance().loadPWSensorsList(onComplete);
32+
Scheduler.getInstance().start();
33+
}, []);
34+
35+
return (
36+
<>
37+
<RouteHelper privateRoute={false}>
38+
<MainPage />
39+
</RouteHelper>
40+
</>
41+
);
42+
};
43+
44+
export default connect(
45+
(state: StoreType) => ({
46+
isReady: state.auth.isReady,
47+
}),
48+
)(App);

src/components/AvailableSensors.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.titleAvailable {
2+
margin-top: 10px;
3+
background-color: black;
4+
color: white;
5+
height: 35px;
6+
margin-bottom: 0 !important;
7+
border-top-left-radius: 10px;
8+
border-top-right-radius: 10px;
9+
font-size: 20px;
10+
padding-left: 10px;
11+
}
12+
13+
.boxAvailable {
14+
height: 330px;
15+
margin-top: 0 !important;
16+
background-color: white;
17+
border-bottom-left-radius: 10px;
18+
border-bottom-right-radius: 10px ;
19+
scrollbar-width: thin;
20+
overflow: overlay;
21+
}
22+
23+
.list {
24+
padding: 5px;
25+
padding-left: 10px;
26+
}

src/components/AvailableSensors.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React, { useEffect, useState } from 'react';
2+
import Scheduler from '../scheduler';
3+
import { Sensors } from '../types/planetWatch/sensors';
4+
import './AvailableSensors.css';
5+
6+
const AvailableSensors = () => {
7+
const [sensors, setSensors] = useState<Sensors>([]);
8+
9+
useEffect(() => {
10+
Scheduler.getInstance().loadPWSensorsList(() => { }).then((res) => {
11+
console.log(res);
12+
setSensors(res);
13+
});
14+
}, []);
15+
16+
17+
return (
18+
<>
19+
<p className='titleAvailable'>
20+
Available PW Sensors
21+
</p>
22+
<div className='boxAvailable'>
23+
{
24+
sensors && sensors.map((sensor, index) => (
25+
<div className='list' style={{ backgroundColor: index % 2 ? 'rgba(211, 211, 211, 0.571)' : 'transparent' }}>
26+
Sensor name
27+
{
28+
// sensor.id??? Waiting for PW Specifications
29+
}
30+
</div>
31+
))
32+
}
33+
</div>
34+
</>
35+
);
36+
};
37+
38+
export default AvailableSensors;

src/components/Log.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.titleLog {
2+
background-color: black;
3+
color: white;
4+
height: 35px;
5+
margin-bottom: 0 !important;
6+
border-top-left-radius: 10px;
7+
border-top-right-radius: 10px;
8+
font-size: 20px;
9+
padding-left: 10px;
10+
}
11+
12+
.boxLog {
13+
height: 555px;
14+
background-color: white;
15+
border-bottom-left-radius: 10px;
16+
border-bottom-right-radius: 10px ;
17+
padding: 5px;
18+
padding-top: 0px;
19+
}
20+
21+
.scroll {
22+
scrollbar-width: thin;
23+
overflow: overlay;
24+
height: 550px;
25+
}

src/components/Log.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React, { useEffect, useState } from 'react';
2+
import Scheduler from '../scheduler';
3+
import './Log.css';
4+
5+
const Log = () => {
6+
const [data, setData] = useState<string[]>();
7+
8+
const printData = (info: string[]) => {
9+
setData(info);
10+
};
11+
12+
useEffect(() => {
13+
Scheduler.getInstance().addLogSubscriber(printData);
14+
}, []);
15+
16+
17+
return (
18+
<>
19+
<div className='titleLog'>
20+
Logs
21+
</div>
22+
<div className='boxLog'>
23+
{
24+
data &&
25+
<div className='scroll'>
26+
{
27+
data.map((log, index) => (
28+
<div style={{ backgroundColor: index % 2 ? 'white' : 'rgba(211, 211, 211, 0.571)', paddingLeft: 10 }}>
29+
{log}
30+
</div>
31+
))
32+
}
33+
</div>
34+
}
35+
</div>
36+
</>
37+
);
38+
};
39+
40+
export default Log;

0 commit comments

Comments
 (0)