Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New Vue Web UI #1933

Draft
wants to merge 84 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6b172e8
[WIP] Create a new web ui with vue
Tofandel Oct 7, 2019
230f627
Configured webpack compilation (outputs image in dist/index.html.gz)
Tofandel Oct 11, 2019
a8672f3
Move each tab to its own component
Tofandel Oct 11, 2019
e139e42
Add environment conditional compilation
Tofandel Oct 11, 2019
907b7c7
Make Form and Input components
Tofandel Oct 11, 2019
0e7335e
New favicon
Tofandel Oct 12, 2019
81cdc76
New favicon
Tofandel Oct 12, 2019
c14f03f
Added compile mode for dev +
Tofandel Oct 17, 2019
101c152
Harmonize ws api
Tofandel Oct 17, 2019
7e455b0
Merge branch 'dev' into dev
Tofandel Oct 17, 2019
8e57f4f
Continue template conversion + some styling
Tofandel Oct 17, 2019
3d7189c
Merge remote-tracking branch 'origin/dev' into dev
Tofandel Oct 17, 2019
99400a7
Convert OOP to schema arrays
Tofandel Oct 21, 2019
6e7f90f
Restore start parameter
Tofandel Oct 21, 2019
221bb37
First test unit
Tofandel Oct 21, 2019
bb822f7
Add test unit for input
Tofandel Oct 21, 2019
1a6878a
Form unit tests
Tofandel Oct 21, 2019
5c9a717
Designing menu + start grid conversion
Tofandel Oct 21, 2019
b15ba1e
Moving alexa integration to it's own tab + Add hint component
Tofandel Oct 22, 2019
15b1ef0
Populating websocket data
Tofandel Oct 23, 2019
4cdcc69
Implement module visibility
Tofandel Oct 25, 2019
15c2dc6
New switch styling + repeater improvements
Tofandel Oct 25, 2019
ae997d5
More ws schema refactor
Tofandel Oct 25, 2019
d28cb84
Merge branch 'dev' into dev
Tofandel Oct 25, 2019
2c90d11
Added multiselect support
Tofandel Oct 25, 2019
a8a0394
Finished all common tabs except sensor
Tofandel Oct 26, 2019
9e9521a
PWA initial setup
Tofandel Oct 26, 2019
5266284
PWA initial setup
Tofandel Oct 26, 2019
508af01
Fix pwa compilation (npm run build:pwa)
Tofandel Oct 30, 2019
066e527
Fix typos
Tofandel Oct 30, 2019
a4cadb6
Fix compile errors
Tofandel Oct 30, 2019
c5947a4
Fix compile errors
Tofandel Oct 30, 2019
88a29e1
Fix compile errors
Tofandel Oct 30, 2019
9263b1f
Add codeowners
Tofandel Oct 30, 2019
769be42
Add codeowners
Tofandel Oct 30, 2019
f3b6565
More ws refactor
Tofandel Oct 30, 2019
60cb976
More ws refactor
Tofandel Oct 30, 2019
6222903
Add favicons + generate pwa icons automatically
Tofandel Nov 5, 2019
3f6e9b3
Add favicons + generate pwa icons automatically
Tofandel Nov 5, 2019
b8d00e6
Add favicons + generate pwa icons automatically
Tofandel Nov 5, 2019
2cb0059
Fix conditional loading of pwa
Tofandel Nov 5, 2019
41a2ecf
Replace gif loader by css
Tofandel Nov 5, 2019
c4500a3
Add package info for pwa
Tofandel Nov 5, 2019
0e7a486
Refactor integrations
Tofandel Nov 10, 2019
bb54a26
Refactor integrations
Tofandel Nov 10, 2019
3f88649
Refactor features
Tofandel Nov 10, 2019
75849f9
Make a vue data table component and code diff analysis to send the data
Tofandel Nov 10, 2019
8e250b0
Multiple fixes + finish features refactor
Tofandel Nov 15, 2019
65e06b9
Merge branch 'dev' into dev
Tofandel Nov 19, 2019
e77d0bb
Merge branch 'dev' into dev
Tofandel Dec 3, 2019
7f5e3ea
Work on the PWA
Tofandel Dec 3, 2019
c875953
Merge remote-tracking branch 'origin/dev' into dev
Tofandel Dec 3, 2019
ae0172d
Move from webpack-conditional-loader to webpack-preprocessor-loader
Tofandel Dec 8, 2019
4045365
Working device scanner
Tofandel Dec 9, 2019
751d621
Style pwa with element-ui
Tofandel Dec 9, 2019
58e1ec5
Add authentication modal
Tofandel Dec 9, 2019
e68de35
Add wifi status + refresh info
Tofandel Dec 10, 2019
d38b5e8
Add uploader
Tofandel Dec 10, 2019
03f2b03
Add uploader
Tofandel Dec 10, 2019
d7f68e3
Add pwa mocking device for 127.0.0.1
Tofandel Dec 23, 2019
74022d8
Improve uploader
Tofandel Dec 25, 2019
3efd905
Update dependencies + optimizations
Tofandel Jan 27, 2020
830761c
Merge branch 'dev' into dev
Tofandel Feb 13, 2020
dc202a5
Implement changes of 13.6 to 14.2 in vue ui
Tofandel Feb 13, 2020
f7c62f3
Restore scheduler visible and fix rfm69 visible
Tofandel Feb 13, 2020
39ff17b
Fix wifi schema
Tofandel Feb 13, 2020
9dbf4be
Fix relay schema
Tofandel Feb 13, 2020
4af5993
Add ws disconnection dialog
Tofandel Feb 13, 2020
2708706
Various bug fixes
Tofandel Feb 13, 2020
2b1c8f1
Cleanup debug messages
Tofandel Feb 13, 2020
ddc7215
Cleanup debug logs
Tofandel Feb 13, 2020
7ac8ae8
Restore debug line break
Tofandel Feb 14, 2020
fa8e609
Restore debug line break
Tofandel Feb 14, 2020
4054100
Added hardcode check for wifi
Tofandel Feb 14, 2020
3694b16
New underscore notation for non settings in api
Tofandel Feb 16, 2020
7c16335
Improve schema + fixes
Tofandel Feb 16, 2020
b352284
Add options for button + fix build error
Tofandel Feb 18, 2020
17d0bc9
Move options to button + fixes
Tofandel Feb 18, 2020
7c0ac08
Add codacity lint rules + implements websocket callback
Tofandel Feb 19, 2020
cf0e786
WIP refactor json buffer alloc + ws action callback
Tofandel Feb 20, 2020
ecc04d3
More api and ui rework + test of better allocation
Tofandel Apr 22, 2020
0376955
Merge branch 'dev' of https://github.com/xoseperez/espurna into dev
Tofandel Apr 22, 2020
6e18585
Remove some useless diff
Tofandel Apr 22, 2020
9c9caf0
Fix some merge errors
Tofandel Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions code/espurna/wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,16 @@ void _wifiWebSocketOnConnected(JsonObject& root) {
root["max"] = WIFI_MAX_NETWORKS;
wifi["scan"] = getSetting("wifiScan", 1 == WIFI_SCAN_NETWORKS);

const char* keys[] = {
"ssid", "pass", "ip", "gw", "mask", "dns", "stored"
};

// TODO check schema
JsonArray& schema = wifi.createNestedArray("schema");
schema.copyFrom(keys, 7);

JsonArray& networks = wifi.createNestedArray("networks");
schema.add("ssid");
schema.add("pass");
schema.add("ip");
schema.add("gw");
schema.add("mask");
schema.add("dns");
Copy link
Collaborator

@mcspr mcspr Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I was kind of doing the same thing, hardcoded 7 can also be (sizeof(keys)/sizeof(keys[0]))
I changed the behaviour of wifi settings, getSetting() will return hardcoded default. stored flag is to avoid removing hard-coded entry accidentally, since on ui reload it will appear again anyway

Copy link
Author

@Tofandel Tofandel Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just didn't want to use copyFrom because it was removed from version 6 of the arduino Json lib (Using v5 but if ever we move away)
Also not sure but doesn't it double the ram usage for the array (define + clone, seems redundant)
Edit: Never mind, add also clones the value

I don't get the stored flag
Don't if (!getSetting({"ssid", index}, _wifiSSID(index)).length()) break; prevent it from ever being set to false anyway, by not sending wifis that are not set?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://arduinojson.org/v6/doc/upgrade/#copyarray

When we have WIFI1_SSID=something, getsetting is never empty

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I finally got it, so the WIFI can be hardcoded with defines and this flag tells us if it comes from the define or not

But can't they be overwritten? The defines acting just as a default value

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see code/espurna/wifi_config.h
They are hard-coded defaults, we can't erase them. It is still possible to "shadow" them, either by setting indexed setting to something else or setting "" empty value

Copy link
Author

@Tofandel Tofandel Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so I got it all but then there might be an issue, if you overwrite the settings the delete button will still be disabled, but it shouldn't (it wouldn't technically delete it, but would reset it to default)
So maybe just changing the name of the button to 'Reset to default' instead of 'Delete' but the API wouldn't know the default value and would need to retrieve it again

Having a hardcoded flag sometimes complicates things more than it simpifies it :p

Copy link
Collaborator

@mcspr mcspr Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of like that. You can always hit reset-all button though, I guess there could be a specific 'reset wifi settings' one.
pre 1.14.2 versions read hardcoded settings on boot, overwriting runtime settings with those values, so it had the same problem only delayed until the next reset

Copy link
Collaborator

@mcspr mcspr Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, not to speculate on code improvements regarding arduinojson:
#1957 (comment)

you can use it as a local library and build program on host. you can repeat the code from above for yourself, array size does not change when we copyfrom() or add individually, it only stores pointers since it is array of pointers.

Copy link
Author

@Tofandel Tofandel Feb 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what I figured, so there is no difference between the two? It's a matter of personal preference then, taking into account that some schemas are variable with macros (defines), is it possible to create an array with macro conditional to copy from?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, effectively it would be the exact same code generated for v5:
https://github.com/bblanchon/ArduinoJson/blob/v5.13.4/src/ArduinoJson/JsonArray.hpp#L151
Slightly different for v6
https://github.com/bblanchon/ArduinoJson/blob/8f8c82d400a2e860e538eed8f92674330186f76f/src/ArduinoJson/Array/Utilities.hpp#L47
But [index] access is also available in v5 (not sure what empty values are though, nulls?)


JsonArray& networks = wifi.createNestedArray("list");

for (unsigned char index = 0; index < WIFI_MAX_NETWORKS; ++index) {
if (!getSetting({"ssid", index}, _wifiSSID(index)).length()) break;
Expand All @@ -472,7 +473,6 @@ void _wifiWebSocketOnConnected(JsonObject& root) {
network.add(getSetting({"gw", index}, _wifiGateway(index)));
network.add(getSetting({"mask", index}, _wifiNetmask(index)));
network.add(getSetting({"dns", index}, _wifiDNS(index)));
network.add(_wifiHasSSID(index));
}
}

Expand Down
4 changes: 2 additions & 2 deletions code/ui/src/common/mock-websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function () {
}, {
"wifi": {
"rssi": -86,
"maxNetworks": 5,
"max": 5,
"scan": true,
"schema": [
"ssid",
Expand Down Expand Up @@ -227,4 +227,4 @@ export default function () {
});

return new WebSocket("ws://localhost:8080");
}
}
2 changes: 1 addition & 1 deletion code/ui/src/tabs/common/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</Row>

<legend>Networks</legend>
<Repeater v-model="wifi.list" @created="({row})=>$set(row, 'more', false)">
<Repeater v-model="wifi.list" :max="wifi.max" @created="({row})=>$set(row, 'more', false)">
<template #default="tpl">
<Row>
<C><label :for="'ssid-'+tpl.row.key">Network SSID</label></C>
Expand Down