Skip to content

Commit 1814d10

Browse files
bubblesnetjvrodley
andauthored
1 feature firstapis (#5)
* starting activemq * units hitting activemq starting to work * working on receive from queue * queue read/write working a bit * lose async on non async calls * defense * starting websockets * used echo to see value of humidity changing on wss message receipt * switch control working solely through props, not state and only on reflected state from wss * server status changes ws to client working * more status change emulatin * some linting * UI status setting from API through to UI works with full state object, and fails gracefully with a bad state object * start separating into queue, ws and api servers * huh? * huh? * defense * defense * message all the way from API call to showing up on screen * tweak retries and interval * starting switch commands * split out display_settings * split out display_settings * defense * measurement messages being handled correctly in UI, added external conditions * external sun indicator * values flowing through from device sensors * values flowing through from device sensors * control tab all sensors working, plenty of UI cleanup still needed * added devicemap, tweaked controltab * sense-go grabs config from api server on startup * defense pre smuggs * defense * defense * direction * defense * regularized sensor and measurement names across system, split sensors between devices * fix direction reporting * adding github CI * defense * put github actions at top level * github CI twiddling * github CI twiddling * put github actions at top level * defense * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * adding github CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * installing activemq in CI * start daemon manually * find log * start daemon manually * install admin * run activemq from cli * activemq * activemq * activemq * activemq * activemq * pid * cleanup? * cleanup? * cleanup? * pid1 * pid2 * coverage fixed * coverage fixed1 * coverage fixed * coverage fixed * find log * coverage fixed * find log1 * coverage fixed * find log * coverage fixed * coverage fixed * coverage fixed1 * manual install of activemq * manual install of activemq * manual install of activemq * coverage fixed1 * coverage fixed * coverage fixed * CI of activemq functions works, trying more node versions * CI of activemq functions works, trying more activemq versions * CI of activemq functions works, trying more activemq versions * CI of activemq functions works, trying more node versions * coverage fixed * coverage fixed * coverage fixed1 * manual install of activemq * manual install of activemq * manual install of activemq * coverage fixed1 * manual install of activemq * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io * codecov.io badge * codecov.io * remove async from sub topic, add test for sub topic * more units * more units * more units * more units * more units * deleting stuff * deleting stuff * deleting stuff * add running servers to CI * add running servers to CI * add running servers to CI * add running servers to CI * add running servers to CI * add running servers to CI * add running servers to CI * take config out to file from js * start getting DB involved in CI * create db * create db * create db - sudo? * create db - sudo? * create db - sudo? * create db - sudo? * 13.1 * 13.1 * postgres is running in another container * postgres is running in another container * postgres is running in another container * postgres is running in another container * postgres is running in another container * postgres is running in another container * postgres is running in another container * postgres is running in another container * psql not createdb * psql not createdb * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * still farting around with service container comm * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * grrr reverting * retry the init * add retries to queue init * add retries to queue init * add retries to queue init * create database tables * reorganize ci.yml * reorganize ci.yml * reorganize ci.yml * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * badging * user password checking implemented, storage of auth credentials not there yet * add user object with some units * rollback the user tests - not cooked * fixed database access for user - added public. * happy path units for user * building out user model with units * happy path units for user * building out user model with units * building out user model with units * more units * more units * more units * more units * parameterized queries in user * parameterized queries in user * should be ~100% on user.js * should be ~100% on user.js * defense * authentication against database works in API and UI * change test messages on server to valid JSON * login auth works for admin user, and user edit/set password too * auth first pass working okay for single admin user * test error handling for readconfig * get config to 100% test * test error handling in readconfig * fix false negative locals error test * fix assertions in locals test, comment out some unused code * start implementing email notifications * debugging email testing from CI * more units for email function * more units for email function * add licensebat config file - let's see how this works Co-authored-by: John Rodley <[email protected]>
1 parent 00b6a20 commit 1814d10

File tree

253 files changed

+40887
-2267
lines changed

Some content is hidden

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

253 files changed

+40887
-2267
lines changed

.github/workflows/ci.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: BubblesNetCI
2+
on: push
3+
4+
jobs:
5+
# Label of the runner job
6+
runner-job:
7+
# You must use a Linux environment when using service containers or container jobs
8+
runs-on: ubuntu-latest
9+
10+
# Service containers to run with `runner-job`
11+
services:
12+
# Label used to access the service container
13+
postgres:
14+
# Docker Hub image
15+
image: postgres
16+
# Provide the password for postgres
17+
env:
18+
POSTGRES_PASSWORD: postgres
19+
# Set health checks to wait until postgres has started
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
ports:
26+
# Maps tcp port 5432 on service container to the host
27+
- 5432:5432
28+
strategy:
29+
matrix:
30+
node-version: [15.x, 10.x, 12.x, 14.x]
31+
activemq-version: [5.16.1, 5.15.14]
32+
33+
steps:
34+
# Downloads a copy of the code in your repository before running CI tests
35+
- name: Check out repository code
36+
uses: actions/checkout@v2
37+
38+
# Performs a clean installation of ActiveMQ
39+
- name: "Install ActiveMQ ${{matrix.activemq-version}}"
40+
run: |
41+
sudo apt update -y -q > /dev/null 2> /dev/null
42+
sudo apt-get install -y -q default-jre > /dev/null 2> /dev/null
43+
npm install >/dev/null 2> /dev/null
44+
wget https://downloads.apache.org/activemq/${{matrix.activemq-version}}/apache-activemq-${{matrix.activemq-version}}-bin.tar.gz >/dev/null 2> /dev/null
45+
tar zxf apache-activemq-${{matrix.activemq-version}}-bin.tar.gz
46+
rm ./apache-activemq-${{matrix.activemq-version}}-bin.tar.gz
47+
sudo ./apache-activemq-${{matrix.activemq-version}}/bin/activemq start
48+
working-directory: server
49+
50+
- name: Setup PostgreSQL
51+
# Creates the DB schema and loads initial table data
52+
run: |
53+
sudo psql -h localhost -p 5432 -c "CREATE DATABASE bubbles_dev" "user=postgres dbname=postgres password=postgres"
54+
sudo psql -h localhost -p 5432 -a -q -f migrations/20201105104957_bu.up.sql "user=postgres dbname=bubbles_dev password=postgres"
55+
sudo psql -h localhost -p 5432 -a -q -f migrations/20201105133628_bu.up.sql "user=postgres dbname=bubbles_dev password=postgres"
56+
env:
57+
# The hostname used to communicate with the PostgreSQL service container
58+
POSTGRES_HOST: localhost
59+
# The default PostgreSQL port
60+
POSTGRES_PORT: 5432
61+
ICEBREAKER_DB: icebreaker_dev
62+
working-directory: server
63+
64+
- name: Run tests with coverage
65+
# Runs a script that creates a PostgreSQL client, populates
66+
# the client with data, and retrieves data
67+
# run: node client.js
68+
run: |
69+
cp config_ci.json config.json
70+
node src/queue-server.js&
71+
node src/ws-server.js&
72+
node src/api-server.js&
73+
npm run coverage
74+
bash <(curl -s https://codecov.io/bash) -t 74df7017-8e3b-462c-bb26-f99316613466 -v
75+
# Environment variables used by the app script to create
76+
# a new PostgreSQL client.
77+
env:
78+
# The hostname used to communicate with the PostgreSQL service container
79+
POSTGRES_HOST: localhost
80+
# The default PostgreSQL port
81+
POSTGRES_PORT: 5432
82+
PORT: 3003
83+
ICEBREAKER_DB: icebreaker_dev
84+
NODE_ENV: DEV
85+
working-directory: server
86+

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ the "copyright" line and a pointer to where the full notice is found.
643643
GNU Affero General Public License for more details.
644644

645645
You should have received a copy of the GNU Affero General Public License
646-
along with this program. If not, see <https://www.gnu.org/licenses/>.
646+
along with this program. If not, see <https://www.js.gnu.org/licenses/>.
647647

648648
Also add information on how to contact you by electronic and paper mail.
649649

@@ -658,4 +658,4 @@ specific requirements.
658658
You should also get your employer (if you work as a programmer) or school,
659659
if any, to sign a "copyright disclaimer" for the program, if necessary.
660660
For more information on this, and how to apply and follow the GNU AGPL, see
661-
<https://www.gnu.org/licenses/>.
661+
<https://www.js.gnu.org/licenses/>.

README.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# controller
1+
# BubblesNet Controller
2+
3+
[![codecov](https://codecov.io/gh/bubblesnet/controller/branch/1-feature-firstapis/graph/badge.svg?token=4ETBIJSIKZ)](https://codecov.io/gh/bubblesnet/controller)
4+
![ci](https://github.com/bubblesnet/controller/workflows/BubblesNetCI/badge.svg)
5+
6+
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
7+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
8+
9+
[![GitHub stars](https://img.shields.io/github/stars/bubblesnet/controller.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/bubblesnet/controller/)
10+
[![GitHub pull-requests](https://img.shields.io/github/issues-pr/bubblesnet/controller.svg)](https://GitHub.com/bubblesnet/controller/pull/)
11+
[![Github all releases](https://img.shields.io/github/downloads/bubblesnet/controller/total.svg)](https://GitHub.com/bubblesnet/controller/releases/)
12+
13+
![Your Repository's Stats](https://github-readme-stats.vercel.app/api?username=bubblesnet&show_icons=true)
214

315
The controller is a control, and data collection and analysis service designed to
416
work with the bubblesnet edge-device. It consists of:
@@ -7,4 +19,18 @@ Client - a React application for controlling one or more edge devices
719
and viewing the data from those devices.
820

921
Server - an API server that serves both the controller React application AND
10-
the edge devices manipulating the physical environment and queueing data for storage.
22+
the edge devices manipulating the physical environment and queueing data for storage.
23+
24+
This open-source project is a port and integration of an existing set of unrelated private projects. This
25+
original set of projects included:
26+
* Server written in Java J2EE as APIs that write JSON files to filesystem
27+
* File processors written in Java that read/write ActiveMQ, move file data into databases and archive files
28+
* A MySQL database
29+
* An Android/Android Things edge device that itself was a rewrite of a RPi python edge device
30+
31+
Data structures
32+
33+
A sensor on a device is referred to by its unique name
34+
The measurement the sensor takes also has a unique name
35+
The sensor and the measurement are linked in configuration not hard wired, so
36+
for instance you 'could' link a sensor named "humidity_sensor" to "air_temp_middle".

client/.babelrc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"development": {
4+
"plugins": [
5+
"@babel/plugin-transform-modules-commonjs"
6+
]
7+
},
8+
"test": {
9+
"plugins": [
10+
"@babel/plugin-transform-modules-commonjs"
11+
]
12+
}
13+
},
14+
"presets": [
15+
"react-app"
16+
],
17+
"plugins": [
18+
[
19+
"react-intl",
20+
{
21+
"extractSourceLocation": true
22+
}
23+
]
24+
]
25+
}

client/babel.config.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"plugins": [
3+
[
4+
"react-intl",
5+
{
6+
"idInterpolationPattern": "[sha512:contenthash:base64:6]",
7+
"extractFromFormatMessageCall": true,
8+
"ast": true
9+
}
10+
]
11+
]
12+
}

client/jest.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//jest.config.js
2+
3+
module.exports = {
4+
moduleNameMapper: {
5+
"\\.(css|sass)$": "identity-obj-proxy",
6+
},
7+
verbose: true,
8+
modulePathIgnorePatterns: ["node_modules"],
9+
10+
};

client/package.json

+35-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
2-
"name": "reactweb",
2+
"name": "bubblesweb",
33
"version": "0.1.0",
44
"private": true,
5+
"jest": {
6+
"testPathIgnorePatterns": [
7+
"/node_modules/"
8+
]
9+
},
510
"dependencies": {
611
"@testing-library/jest-dom": "^4.2.4",
712
"@testing-library/react": "^9.5.0",
@@ -10,21 +15,46 @@
1015
"enzyme": "^3.11.0",
1116
"enzyme-adapter-react-16": "^1.15.4",
1217
"grommet": "^2.15.0",
18+
"grommet-icons": "^4.5.0",
1319
"jest-enzyme": "^7.1.2",
1420
"moment": "^2.27.0",
1521
"pg": "^8.3.0",
22+
"prop-types": "^15.7.2",
1623
"react": "^16.13.1",
24+
"react-d3-speedometer": "^1.0.1",
1725
"react-dom": "^16.13.1",
1826
"react-editable-table": "^1.12.32",
27+
"react-google-font-loader": "^1.1.0",
28+
"react-input-switch": "^2.2.2",
1929
"react-interval-rerender": "^1.0.1",
30+
"react-intl": "^5.10.6",
2031
"react-scripts": "3.4.1",
21-
"rendition": "^16.1.2"
32+
"rendition": "^16.1.2",
33+
"react-use-websocket": "^2.2.0",
34+
"sprintf-js": "^1.1.2",
35+
"stompit": "^1.0.0",
36+
"styled-components": "^5.2.1"
37+
},
38+
"devDependencies": {
39+
"@babel/cli": "^7.12.8",
40+
"@babel/core": "^7.12.9",
41+
"@babel/plugin-transform-react-jsx": "^7.12.7",
42+
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
43+
"babel-plugin-react-intl": "^8.2.25",
44+
"@babel/preset-env": "7.12.7",
45+
"@babel/preset-react": "^7.12.7",
46+
"babel-jest": "^24.9.0",
47+
"jest": "^24.9.0",
48+
"@testing-library/jest-dom": "^5.11.9",
49+
"@testing-library/dom": "^7.29.4",
50+
"react-test-renderer": "^17.0.1"
2251
},
2352
"scripts": {
24-
"start": "react-scripts start",
53+
"start": "set HOST=0.0.0.0&&set PORT=3005&&react-scripts start",
2554
"build": "react-scripts build",
26-
"test": "react-scripts test",
27-
"eject": "react-scripts eject"
55+
"test": "jest",
56+
"eject": "react-scripts eject",
57+
"extract-messages": "set NODE_ENV=production&& babel --plugins react-intl ./src >NUL"
2858
},
2959
"eslintConfig": {
3060
"extends": "react-app"

client/public/favicon16x16.ico

560 Bytes
Binary file not shown.

client/public/favicon32x32.ico

-1 KB
Binary file not shown.

client/public/favicon96x96.ico

-9 KB
Binary file not shown.

client/public/iceberg192x192.png

-14.1 KB
Binary file not shown.

client/public/iceberg512x512.png

-50.8 KB
Binary file not shown.

client/public/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<meta name="theme-color" content="#000000" />
1010
<meta
1111
name="description"
12-
content="Web site created using create-react-app"
12+
content="Web site created using create-react-apiServer"
1313
/>
1414
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
1515
<!--
16-
manifest.json provides metadata used when your web app is installed on a
17-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
manifest.json provides metadata used when your web apiServer is installed on a
17+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-apiServer-manifest/
1818
-->
1919
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
2020
<!--
@@ -32,10 +32,10 @@
3232
integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
3333
crossorigin="anonymous"
3434
/>
35-
<title>Icebreaker</title>
35+
<title>Bubbles</title>
3636
</head>
3737
<body>
38-
<noscript>You need to enable JavaScript to run this app.</noscript>
38+
<noscript>You need to enable JavaScript to run this apiServer.</noscript>
3939
<div id="root"></div>
4040
<!--
4141
This HTML file is a template.

client/public/manifest.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"short_name": "Icebreaker",
3-
"name": "Icebreaker Admin UI",
2+
"short_name": "Bubbles",
3+
"name": "Bubbles Controller",
44
"icons": [
55
{
66
"src": "favicon.ico",
77
"sizes": "64x64 32x32 24x24 16x16",
88
"type": "image/x-icon"
99
},
1010
{
11-
"src": "iceberg192x192.png",
11+
"src": "bubbles192x192.png",
1212
"type": "image/png",
1313
"sizes": "192x192"
1414
},
1515
{
16-
"src": "iceberg512x512.png",
16+
"src": "bubbles512x512.png",
1717
"type": "image/png",
1818
"sizes": "512x512"
1919
}

client/public/robots.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# https://www.robotstxt.org/robotstxt.html
1+
# https://www.js.robotstxt.org/robotstxt.html
22
User-agent: *
33
Disallow:

client/src/App.css

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import 'Palette.css';
2+
13
.App {
24
text-align: center;
35
}
@@ -14,7 +16,7 @@
1416
}
1517

1618
.App-header {
17-
background-color: #282c34;
19+
background-color: var(--color-primary-0);
1820
min-height: 10vh;
1921
display: flex;
2022
flex-direction: column;
@@ -24,10 +26,10 @@
2426
color: white;
2527
}
2628

27-
.IcebergApp-header {
28-
background: #22445e;
29-
flexDirection: row;
30-
flexWrap: nowrap;
29+
.BubblesApp-header {
30+
background: linear-gradient(90deg, var(--color-primary-0) 0%, var(--color-primary-1) 49%, rgba(255,255,255,1) 100%);
31+
flexDirection: row;
32+
flexWrap: nowrap;
3133
min-height: 5vh;
3234
display: flex;
3335
align-items: flex-start;
@@ -51,5 +53,16 @@ flexWrap: nowrap;
5153

5254
.RenderEnvironmentPickerFunctional {
5355
justify-content: center;
54-
background: #aaaaaa;
56+
background: var(--color-primary-1);
57+
}
58+
59+
.tabstyle {
60+
color: white;
5561
}
62+
#animated-gif-container {
63+
background-image:url(images/bubbles-gif.gif);
64+
background-repeat:no-repeat;
65+
width:200px;
66+
height:48px;
67+
float: right;
68+
}

0 commit comments

Comments
 (0)