mirror of
https://github.com/thomasnordquist/MQTT-Explorer.git
synced 2026-09-11 17:13:53 +00:00
Compare commits
818
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e12d0544e6 | ||
|
|
9e48b8613e | ||
|
|
6f8ad41ef5 | ||
|
|
1ec10bb007 | ||
|
|
70e75061b2 | ||
|
|
c0b2950ecb | ||
|
|
f946ae39d7 | ||
|
|
43ff3e81f0 | ||
|
|
79a8cdf1fd | ||
|
|
16c190818c | ||
|
|
de367e755f | ||
|
|
6e355decbf | ||
|
|
d4dbc36a8a | ||
|
|
0e82a8baad | ||
|
|
0016f2d364 | ||
|
|
e6ecb77d01 | ||
|
|
2afddb8d63 | ||
|
|
dfdf473b27 | ||
|
|
4fcdd47e65 | ||
|
|
b2a8e84479 | ||
|
|
8d665e0e52 | ||
|
|
9e1c229a5d | ||
|
|
0d34f86893 | ||
|
|
73c48f388b | ||
|
|
a36a630466 | ||
|
|
fe6ccc8e16 | ||
|
|
d91718cf80 | ||
|
|
66610bcb54 | ||
|
|
7437c796a0 | ||
|
|
bb1e52feae | ||
|
|
d69d5af2ae | ||
|
|
0c1d09a8a0 | ||
|
|
308b748d0e | ||
|
|
85475a9201 | ||
|
|
2c147a92ad | ||
|
|
a143c5fb45 | ||
|
|
eb605a884c | ||
|
|
9868ac67fc | ||
|
|
229414de28 | ||
|
|
6c041cba02 | ||
|
|
a7136bd572 | ||
|
|
a5629b8c77 | ||
|
|
da122e06f1 | ||
|
|
e0a79f61af | ||
|
|
26ed0aadd2 | ||
|
|
578bb510f9 | ||
|
|
e725b1d012 | ||
|
|
c55c3a8245 | ||
|
|
92aa2c9fa8 | ||
|
|
5a54ba4983 | ||
|
|
91df6de4d4 | ||
|
|
8285627c5f | ||
|
|
55f8b7d2b7 | ||
|
|
8f1eeedbaf | ||
|
|
4843b2ec18 | ||
|
|
803413a087 | ||
|
|
b457559b4a | ||
|
|
03ba43038c | ||
|
|
8975e7b641 | ||
|
|
efc9fb9736 | ||
|
|
61f2389c1c | ||
|
|
f539e03c7e | ||
|
|
724ea5acbf | ||
|
|
e009940530 | ||
|
|
e19178780f | ||
|
|
3229ef5643 | ||
|
|
b4a6199936 | ||
|
|
bd6a1a0d2d | ||
|
|
9d09ab2165 | ||
|
|
f17640c9db | ||
|
|
1ba0d07757 | ||
|
|
20a3202b5f | ||
|
|
28b99f5774 | ||
|
|
42565c8bdc | ||
|
|
8b43e20f2e | ||
|
|
a2a75588c9 | ||
|
|
c13b60cd18 | ||
|
|
18f8da9054 | ||
|
|
f6856d66cc | ||
|
|
79fbd34cfa | ||
|
|
3bc23e6d74 | ||
|
|
e9a56ac48d | ||
|
|
b4bdd01808 | ||
|
|
4406bf5de4 | ||
|
|
ae0ce79e26 | ||
|
|
bbe2ae3f29 | ||
|
|
a2c4388c78 | ||
|
|
c88978f0dd | ||
|
|
b3a37e4794 | ||
|
|
1ecb53b397 | ||
|
|
97fedcba08 | ||
|
|
1f23c65484 | ||
|
|
980072f680 | ||
|
|
c452b9f417 | ||
|
|
b04f5dee16 | ||
|
|
7617430a3f | ||
|
|
10aae59c92 | ||
|
|
f4bda3e242 | ||
|
|
a346c48d3e | ||
|
|
8a2c39ba8e | ||
|
|
65b86ac5f6 | ||
|
|
4ead740982 | ||
|
|
ddaf06b682 | ||
|
|
9e18c4db4e | ||
|
|
ee783f15c0 | ||
|
|
0c31843ed5 | ||
|
|
ffc93d20d8 | ||
|
|
3c62da7e19 | ||
|
|
6846dbbb28 | ||
|
|
270e3e3ead | ||
|
|
0d73b0f519 | ||
|
|
ee83022d19 | ||
|
|
f27467ed97 | ||
|
|
ddbf3d9f1f | ||
|
|
60bbbc54d7 | ||
|
|
538aa7dc29 | ||
|
|
b37af291cc | ||
|
|
333a1bcabe | ||
|
|
c2404a7eb6 | ||
|
|
bb602cd28e | ||
|
|
898fd3896c | ||
|
|
7fb0483889 | ||
|
|
7d77110c1f | ||
|
|
a7ce6b4419 | ||
|
|
204f6dbcde | ||
|
|
7fa997087f | ||
|
|
a96b08eaaa | ||
|
|
c9c997d13a | ||
|
|
6f3e0f62e1 | ||
|
|
824b39637c | ||
|
|
0100b2988a | ||
|
|
0e72329c77 | ||
|
|
9b7c3b8e9c | ||
|
|
b9a5a5f1d8 | ||
|
|
cc9cc411f0 | ||
|
|
5f75079f2f | ||
|
|
a6e16dcd17 | ||
|
|
f1b13a2919 | ||
|
|
737afb3c1b | ||
|
|
e21011fce1 | ||
|
|
613d0d7178 | ||
|
|
bb964aba20 | ||
|
|
6e5e2e0dd7 | ||
|
|
5afccac2ac | ||
|
|
4626df0bf7 | ||
|
|
252780a51a | ||
|
|
245e661159 | ||
|
|
659033e4eb | ||
|
|
82fbf91f8a | ||
|
|
4275060003 | ||
|
|
6fe74d49fd | ||
|
|
736145d9b4 | ||
|
|
d5ad716086 | ||
|
|
c3f1e7c5e8 | ||
|
|
e1b6c709b0 | ||
|
|
42de570a98 | ||
|
|
30469e63e5 | ||
|
|
899db30e3b | ||
|
|
51d0eaafcc | ||
|
|
cfd1333989 | ||
|
|
6c9d98a763 | ||
|
|
040549c40a | ||
|
|
0c6d777999 | ||
|
|
65c53fd670 | ||
|
|
1b7c9c52f6 | ||
|
|
a63b12b266 | ||
|
|
a8ff4adde7 | ||
|
|
3b8418ccfd | ||
|
|
b51b3065b0 | ||
|
|
1f0c6771e5 | ||
|
|
67277b4652 | ||
|
|
b0e30a896f | ||
|
|
93010dc06e | ||
|
|
302b8f3c21 | ||
|
|
62d087bb0e | ||
|
|
f25cab4682 | ||
|
|
626b9cab7d | ||
|
|
d1de0770f2 | ||
|
|
2a3f481a24 | ||
|
|
ed492ccbf4 | ||
|
|
ea7535b250 | ||
|
|
b17b54490e | ||
|
|
72400af679 | ||
|
|
f8f1ddfebb | ||
|
|
6e4d08e4b5 | ||
|
|
5da8fe0f90 | ||
|
|
df9eda4866 | ||
|
|
6b030ab5ee | ||
|
|
e1493db7c8 | ||
|
|
205ea00c41 | ||
|
|
d428428a6e | ||
|
|
24e9c4cd22 | ||
|
|
d253c6c764 | ||
|
|
13b8f8d5da | ||
|
|
e769ddece4 | ||
|
|
64e807beef | ||
|
|
531af31490 | ||
|
|
e708e1d0c7 | ||
|
|
8fcf8b2478 | ||
|
|
4fdd5b2063 | ||
|
|
e4add31793 | ||
|
|
0cab2169c2 | ||
|
|
86f5b94852 | ||
|
|
f60449c253 | ||
|
|
c1c8b9aa61 | ||
|
|
dcf692d193 | ||
|
|
7f757b9f8a | ||
|
|
23b46cd432 | ||
|
|
68ef9ac913 | ||
|
|
567f6d2d50 | ||
|
|
3fa47f0318 | ||
|
|
9cdfa2de7b | ||
|
|
355e9177fc | ||
|
|
dbb6ead7ba | ||
|
|
ad888f6f9a | ||
|
|
07458cd712 | ||
|
|
6fc0d3f28d | ||
|
|
7a91e4dee6 | ||
|
|
3c40be97b7 | ||
|
|
ff00f7a99e | ||
|
|
b72fc48bdb | ||
|
|
e87a7115c5 | ||
|
|
14dac22732 | ||
|
|
ccdaaa6ce2 | ||
|
|
487eee93cd | ||
|
|
59737edfb4 | ||
|
|
30af13f793 | ||
|
|
19e8bfdb37 | ||
|
|
a89d7cf62e | ||
|
|
65e9f2e074 | ||
|
|
ff66d10aaa | ||
|
|
5203d40a24 | ||
|
|
237c718a0a | ||
|
|
fbfbe94d19 | ||
|
|
e24e505cc0 | ||
|
|
28743ba646 | ||
|
|
f63e73ee0a | ||
|
|
fbad7afa79 | ||
|
|
34cc38ab3c | ||
|
|
8645789550 | ||
|
|
4db6e7b1d7 | ||
|
|
1fae61b1fa | ||
|
|
b26eac3edb | ||
|
|
6d1354bf07 | ||
|
|
7148e302f6 | ||
|
|
763a1aea69 | ||
|
|
94a92e9b29 | ||
|
|
922f90c4eb | ||
|
|
ff11973a9a | ||
|
|
29fc2eea4d | ||
|
|
577e1e6b10 | ||
|
|
d113fab279 | ||
|
|
a6c401ab6a | ||
|
|
6cc8c8810b | ||
|
|
040a29da30 | ||
|
|
45f31ad931 | ||
|
|
39ddb984ab | ||
|
|
197788eb79 | ||
|
|
c85bc0323c | ||
|
|
65c2a6eff1 | ||
|
|
5a4f3a0388 | ||
|
|
03f9c6a26e | ||
|
|
ae7ecd4bc9 | ||
|
|
25469936fa | ||
|
|
bc2d066bb9 | ||
|
|
71e376e0e4 | ||
|
|
354b014245 | ||
|
|
d69779c497 | ||
|
|
af1219cda8 | ||
|
|
c7ea6790c8 | ||
|
|
779f1e9769 | ||
|
|
f690b3f5a7 | ||
|
|
39d87d5a8e | ||
|
|
6781170b85 | ||
|
|
7829a27c69 | ||
|
|
285001d184 | ||
|
|
d5a4d1e4d3 | ||
|
|
c59c64b65f | ||
|
|
5badd19015 | ||
|
|
a7eacfac46 | ||
|
|
20dae2ea2b | ||
|
|
dc50fd40a3 | ||
|
|
3df4d18a71 | ||
|
|
3aeee31193 | ||
|
|
af4cfec451 | ||
|
|
ae915a158b | ||
|
|
eac522fe63 | ||
|
|
a2bdf71422 | ||
|
|
f2d632959b | ||
|
|
b33412504d | ||
|
|
c458f6c64d | ||
|
|
d6489563b2 | ||
|
|
d651fc7a6c | ||
|
|
c86659f61c | ||
|
|
8959bbdee7 | ||
|
|
9a8474e3d8 | ||
|
|
c5e0e652f3 | ||
|
|
f047f97e44 | ||
|
|
cda8e928ef | ||
|
|
ccbea4acc5 | ||
|
|
8ae1528064 | ||
|
|
1c52aced63 | ||
|
|
72020b02b8 | ||
|
|
aa340b2158 | ||
|
|
faf909654b | ||
|
|
33f3458e38 | ||
|
|
3737410563 | ||
|
|
28afc439ba | ||
|
|
04ba067775 | ||
|
|
0a5d010827 | ||
|
|
1cef529ac7 | ||
|
|
094831f037 | ||
|
|
5148e92651 | ||
|
|
13be7a6697 | ||
|
|
1bef73f356 | ||
|
|
88cc57b8b1 | ||
|
|
b5d9ff3067 | ||
|
|
7c63e871f0 | ||
|
|
fd2c78eea0 | ||
|
|
e8e8926757 | ||
|
|
0b6a1e42d6 | ||
|
|
ff148a8e3c | ||
|
|
ecdecd8626 | ||
|
|
843f2377f0 | ||
|
|
a9a5fdf9dd | ||
|
|
a9742ebf81 | ||
|
|
df3e0fc047 | ||
|
|
05867dab48 | ||
|
|
4f3150d0f3 | ||
|
|
175aeea468 | ||
|
|
167f0b39e0 | ||
|
|
7a9b7d7bf6 | ||
|
|
1a1596ad3d | ||
|
|
8e49d19fbe | ||
|
|
df42d75651 | ||
|
|
c1e2a4c625 | ||
|
|
901acf2bed | ||
|
|
4ec7c8ca75 | ||
|
|
75c3619898 | ||
|
|
38f8d2e6ee | ||
|
|
e3584add7c | ||
|
|
77dcbccd5c | ||
|
|
0ff6359a41 | ||
|
|
66bfcab256 | ||
|
|
195dcf37d4 | ||
|
|
5830d99d45 | ||
|
|
d50cef7bb3 | ||
|
|
b79725bdf0 | ||
|
|
6bead5b5a6 | ||
|
|
183ea9d8c0 | ||
|
|
282736d2f6 | ||
|
|
45b30e5997 | ||
|
|
3d45e8ce6e | ||
|
|
393cf76839 | ||
|
|
410bc6a39b | ||
|
|
a56c00aeb3 | ||
|
|
c3d7d653fb | ||
|
|
9d72ef0122 | ||
|
|
b5aa22a6d8 | ||
|
|
aa05c16651 | ||
|
|
c543d0fb85 | ||
|
|
de7fa2dd9c | ||
|
|
f9829c2d5c | ||
|
|
e02091f645 | ||
|
|
8d15018986 | ||
|
|
76c63d38cd | ||
|
|
188b5c6c16 | ||
|
|
fc5a5d2035 | ||
|
|
838d106b62 | ||
|
|
d59a1af5d4 | ||
|
|
1638080e85 | ||
|
|
f4051b4cdf | ||
|
|
d054e64568 | ||
|
|
759176c4fc | ||
|
|
c2a9b7b1c6 | ||
|
|
2536b9fff7 | ||
|
|
b714547928 | ||
|
|
005fba5ca3 | ||
|
|
b27df0c0d8 | ||
|
|
341ab44f9e | ||
|
|
e0d35548c5 | ||
|
|
ba91730f43 | ||
|
|
f691a7a0ae | ||
|
|
5a43ecd8d2 | ||
|
|
73f33c31bb | ||
|
|
ffdce6f825 | ||
|
|
38b16daf51 | ||
|
|
bed5c74150 | ||
|
|
261454986e | ||
|
|
03784601ea | ||
|
|
b060861657 | ||
|
|
34a117b74c | ||
|
|
9e341afdcc | ||
|
|
0d585eef8f | ||
|
|
7e99c18410 | ||
|
|
68118248c9 | ||
|
|
f1a2ae16c1 | ||
|
|
7904cb22cf | ||
|
|
0e0fbae8bb | ||
|
|
3b72048b67 | ||
|
|
caa54809b4 | ||
|
|
23f5846122 | ||
|
|
de7b461b4e | ||
|
|
d92ea0bad7 | ||
|
|
d7bb4bb55f | ||
|
|
9ed8a3b91e | ||
|
|
dd78b43058 | ||
|
|
cd68e966ab | ||
|
|
6baeafce39 | ||
|
|
1d8900d6eb | ||
|
|
e82c8c4eb0 | ||
|
|
449d046ce3 | ||
|
|
06ab52bb6b | ||
|
|
181575f71f | ||
|
|
3d5a4af705 | ||
|
|
4e982be613 | ||
|
|
8c1c6387c9 | ||
|
|
0f9c2cd36f | ||
|
|
2296143883 | ||
|
|
fcb61b563c | ||
|
|
90e5336c5c | ||
|
|
37d56e24ac | ||
|
|
57f979e1bb | ||
|
|
00cbb63181 | ||
|
|
eaafb68117 | ||
|
|
486a3568e9 | ||
|
|
acff7ea631 | ||
|
|
6829046d8c | ||
|
|
182285d8a5 | ||
|
|
1af799789d | ||
|
|
7036d6c8fe | ||
|
|
0b067bd964 | ||
|
|
9fe5133ef1 | ||
|
|
c9aae4287c | ||
|
|
97846e01a7 | ||
|
|
b4b6c214cb | ||
|
|
1d77af5e22 | ||
|
|
1884f3baae | ||
|
|
0ebb6f4424 | ||
|
|
209899c3b8 | ||
|
|
4ec8cdf0ff | ||
|
|
53326b6de4 | ||
|
|
8c13282a55 | ||
|
|
0e3d94bf06 | ||
|
|
af8613096d | ||
|
|
92e045297e | ||
|
|
6176859c7c | ||
|
|
3935b1d614 | ||
|
|
c9d3e552ae | ||
|
|
d62305303a | ||
|
|
34c81f7f69 | ||
|
|
bd1f6b6d82 | ||
|
|
e728a721aa | ||
|
|
15a0c8a5c5 | ||
|
|
173f662fa7 | ||
|
|
15c4dc2df3 | ||
|
|
b9dcc4a9a8 | ||
|
|
f8648b92a1 | ||
|
|
4f0b13bdc7 | ||
|
|
1f9215a19f | ||
|
|
9e15e28147 | ||
|
|
09151d14a9 | ||
|
|
e66f6d098a | ||
|
|
8cc3d416b8 | ||
|
|
348b72ea69 | ||
|
|
050ba81760 | ||
|
|
fe16eabb6b | ||
|
|
3c58164539 | ||
|
|
5a9d6aa4dd | ||
|
|
5c413a9ebb | ||
|
|
d0ddec746a | ||
|
|
6e4754f475 | ||
|
|
63f89d628e | ||
|
|
dfaae34cf5 | ||
|
|
77654c7136 | ||
|
|
3bfc59d89a | ||
|
|
6bf84055d9 | ||
|
|
12d7d3ab64 | ||
|
|
b2913c7e0e | ||
|
|
352948f212 | ||
|
|
9a4dbe92a0 | ||
|
|
397b95f9e5 | ||
|
|
a411d21133 | ||
|
|
4f624cc130 | ||
|
|
f10bfafa1d | ||
|
|
10e37624a5 | ||
|
|
ebdfac39eb | ||
|
|
7cc032cdf4 | ||
|
|
4bc9039386 | ||
|
|
43b997fb18 | ||
|
|
6c883aa226 | ||
|
|
20cde3e2a4 | ||
|
|
ae7440f8ab | ||
|
|
03e228e5a0 | ||
|
|
14f2f9ff1e | ||
|
|
86544c1334 | ||
|
|
9e71c3132e | ||
|
|
817202fc20 | ||
|
|
931ec0113c | ||
|
|
365ebc78ab | ||
|
|
2a541a80dc | ||
|
|
a1d3f32f73 | ||
|
|
e9e6ea618d | ||
|
|
6021df7150 | ||
|
|
070b72b304 | ||
|
|
1f65a0f316 | ||
|
|
0f21f10c0d | ||
|
|
af2ff0149d | ||
|
|
8cd11cde3b | ||
|
|
fdbe6344d9 | ||
|
|
a56b41635c | ||
|
|
2c5c218fd1 | ||
|
|
749df70d5c | ||
|
|
4c4e1543ec | ||
|
|
9320fa252e | ||
|
|
9062129114 | ||
|
|
fa3805460c | ||
|
|
c2885c4829 | ||
|
|
a901f2b90b | ||
|
|
349b664270 | ||
|
|
a28fc958d4 | ||
|
|
0ec539854c | ||
|
|
9c5d89e0aa | ||
|
|
c9c0a447ce | ||
|
|
38819b0e0a | ||
|
|
d24dc41024 | ||
|
|
62774fe9c2 | ||
|
|
4b15650290 | ||
|
|
64e974f6c7 | ||
|
|
fb137a703c | ||
|
|
c43d1fadb4 | ||
|
|
91a9ba7757 | ||
|
|
48e65947f7 | ||
|
|
7f29dadc42 | ||
|
|
47d1e74852 | ||
|
|
6d6b35d5f8 | ||
|
|
0d56ab49ea | ||
|
|
daac8cf949 | ||
|
|
fa54b9a9fa | ||
|
|
d339d6a1bb | ||
|
|
b6f16c347d | ||
|
|
46fa93edbd | ||
|
|
2de7840897 | ||
|
|
499dfd1b68 | ||
|
|
425bbb36e3 | ||
|
|
b8f510bd7e | ||
|
|
aae1381de5 | ||
|
|
266d337dae | ||
|
|
e6bcc00927 | ||
|
|
d1f4bc678c | ||
|
|
52c44327d0 | ||
|
|
50b2362a70 | ||
|
|
fb8a16e1d7 | ||
|
|
a929729e6a | ||
|
|
b12961cbc9 | ||
|
|
f0465a8ad7 | ||
|
|
869ad9eb37 | ||
|
|
dcff2ae336 | ||
|
|
b6d6575543 | ||
|
|
a2fae27919 | ||
|
|
14f0f32560 | ||
|
|
195c2db70d | ||
|
|
8773d73ead | ||
|
|
eab20bc614 | ||
|
|
ab8365b1f7 | ||
|
|
c7b0400e84 | ||
|
|
10bac1bcd6 | ||
|
|
8a5bd3526d | ||
|
|
2590a701bb | ||
|
|
36b9cc0bea | ||
|
|
5260343700 | ||
|
|
5be21475ce | ||
|
|
1e8a451a68 | ||
|
|
b7f914d936 | ||
|
|
cefd9e95db | ||
|
|
4dfeddbdae | ||
|
|
11382e3af6 | ||
|
|
1400540852 | ||
|
|
d005195cfe | ||
|
|
97a59ea691 | ||
|
|
2812baccf9 | ||
|
|
f5de7903e7 | ||
|
|
9a65e79fc4 | ||
|
|
4598977b61 | ||
|
|
c461121d6d | ||
|
|
fcc560ef3f | ||
|
|
f76ea848cd | ||
|
|
431d0c89fe | ||
|
|
083a39d6c6 | ||
|
|
7e5e6013ab | ||
|
|
acbe20070b | ||
|
|
e89ca2bfa4 | ||
|
|
96da5badd4 | ||
|
|
e9734bdfc5 | ||
|
|
f1d9a82057 | ||
|
|
550d7014fa | ||
|
|
db134dbc1c | ||
|
|
7e38d23475 | ||
|
|
c23099e254 | ||
|
|
e4cfa38139 | ||
|
|
e9ab3da6c2 | ||
|
|
a150da0254 | ||
|
|
8c5f708386 | ||
|
|
436b569e93 | ||
|
|
3e47b07ba7 | ||
|
|
da5e58a417 | ||
|
|
c993bd88e0 | ||
|
|
5c038461a6 | ||
|
|
e2c60cca64 | ||
|
|
16c72fa9be | ||
|
|
8571d97182 | ||
|
|
c7e20c26cb | ||
|
|
ab3e35520b | ||
|
|
7a78cffa13 | ||
|
|
09dcce97b7 | ||
|
|
c20c075bcf | ||
|
|
d175195dd5 | ||
|
|
094d795b39 | ||
|
|
8266a87417 | ||
|
|
f23f6c908f | ||
|
|
9e5d944df3 | ||
|
|
b5068ad3d5 | ||
|
|
6853066a19 | ||
|
|
acbaced1ec | ||
|
|
b9eb54dd20 | ||
|
|
6f86a8d471 | ||
|
|
84a92ad522 | ||
|
|
5caa3564d1 | ||
|
|
d3598d8417 | ||
|
|
27f5e8a7eb | ||
|
|
b97f97de99 | ||
|
|
0c124d8d19 | ||
|
|
f7e3fbc8f9 | ||
|
|
100bfdd560 | ||
|
|
01f42a1c32 | ||
|
|
2cb8c0dabc | ||
|
|
cceeb74d96 | ||
|
|
c1bc96da01 | ||
|
|
89d363fbaa | ||
|
|
62cbf6547e | ||
|
|
ea7994dad9 | ||
|
|
c09ea4ae62 | ||
|
|
8c23f1f27c | ||
|
|
aa8d066fe1 | ||
|
|
485e1cffae | ||
|
|
eb7d7e8955 | ||
|
|
6392959e22 | ||
|
|
581dba7c01 | ||
|
|
ea57c55116 | ||
|
|
d9fcf59ca4 | ||
|
|
d66ecc6f0f | ||
|
|
eb6aa998a9 | ||
|
|
ef4dfe3298 | ||
|
|
354a0cbf84 | ||
|
|
94558b9a6f | ||
|
|
517bb06fb2 | ||
|
|
cd7e5ed412 | ||
|
|
58a6b21bf3 | ||
|
|
1763dc7574 | ||
|
|
5adb2bb5c8 | ||
|
|
4665130820 | ||
|
|
c3efd45a7f | ||
|
|
ad0298f8a0 | ||
|
|
6545026796 | ||
|
|
a10a10bcd3 | ||
|
|
908cc50e60 | ||
|
|
1a8f64966c | ||
|
|
1f70c1ba3c | ||
|
|
197781a4d8 | ||
|
|
38803ccf59 | ||
|
|
2148b01ba0 | ||
|
|
b404a4dac1 | ||
|
|
4340515012 | ||
|
|
5205ed1094 | ||
|
|
7961a7dd3f | ||
|
|
f8a2af8554 | ||
|
|
d1fb0026b6 | ||
|
|
7e9932de0a | ||
|
|
0dea1f9d19 | ||
|
|
d7be46c78e | ||
|
|
e95fd5b37d | ||
|
|
dee1abb1da | ||
|
|
4c84a9b5f6 | ||
|
|
016bf5dfcd | ||
|
|
9c15e392d1 | ||
|
|
613c6d3aa7 | ||
|
|
f10cd89647 | ||
|
|
6000541c32 | ||
|
|
87a86b8c0c | ||
|
|
f81d64cc2f | ||
|
|
9b31aeccd8 | ||
|
|
692054c540 | ||
|
|
91486718d8 | ||
|
|
55dd79aebd | ||
|
|
7141dfa9fc | ||
|
|
f16d0cd271 | ||
|
|
838e2fa287 | ||
|
|
b9439c3244 | ||
|
|
410855e8a0 | ||
|
|
71d606d7cd | ||
|
|
a32810417d | ||
|
|
4fcf767079 | ||
|
|
1e6fa11f0f | ||
|
|
9644952d81 | ||
|
|
d1cd299132 | ||
|
|
e3539015f7 | ||
|
|
874cedb422 | ||
|
|
63530a41ac | ||
|
|
d3bf5e87e1 | ||
|
|
10c6c3cecd | ||
|
|
4d8fa72491 | ||
|
|
b9c0a66948 | ||
|
|
6b859d31e8 | ||
|
|
4fd328e716 | ||
|
|
b606f14836 | ||
|
|
ad49c5c819 | ||
|
|
749a591465 | ||
|
|
a1b1c92648 | ||
|
|
85c6c4ebbc | ||
|
|
de7c9479c9 | ||
|
|
138f51eb39 | ||
|
|
107ca83882 | ||
|
|
839ad531ba | ||
|
|
174eb0c767 | ||
|
|
953422dcd4 | ||
|
|
a4015141c3 | ||
|
|
ca3bd0b22b | ||
|
|
797d11d58d | ||
|
|
8281a852ab | ||
|
|
e5c3f207d9 | ||
|
|
2efc8f4dda | ||
|
|
60a06d8c82 | ||
|
|
857500f9c9 | ||
|
|
396e6985ce | ||
|
|
6d75f29f03 | ||
|
|
f8cdf0837e | ||
|
|
5bb96233d1 | ||
|
|
f3ff6cde7b | ||
|
|
ec88f9822d | ||
|
|
235e81826b | ||
|
|
615ec17b96 | ||
|
|
ddc801fe93 | ||
|
|
24c6b7e7b3 | ||
|
|
55ea381b3b | ||
|
|
55fbc642c4 | ||
|
|
4b5d023d19 | ||
|
|
e0708a5288 | ||
|
|
d44a6e3159 | ||
|
|
09afe2a30c | ||
|
|
160b0b5a04 | ||
|
|
590c24a3bd | ||
|
|
e0978ee64b | ||
|
|
09811eafb7 | ||
|
|
795c410a92 | ||
|
|
6c25b42a94 | ||
|
|
9207af0aaa | ||
|
|
0ad91872a1 | ||
|
|
8b64818b4c | ||
|
|
03462f7ec8 | ||
|
|
3f52944f18 | ||
|
|
1740df6218 | ||
|
|
aa32349727 | ||
|
|
6d81520ff9 | ||
|
|
7d165bb342 | ||
|
|
6f3a5beeaa | ||
|
|
804c96d041 | ||
|
|
9c863c8339 | ||
|
|
3cb89fe502 | ||
|
|
1339c1a292 | ||
|
|
4b8356632c | ||
|
|
e34a38c1f0 | ||
|
|
e6ecfde339 | ||
|
|
688abbd999 | ||
|
|
5d758c8e6d | ||
|
|
ef6946bdd4 | ||
|
|
93ea829987 | ||
|
|
f316d5699d | ||
|
|
a58049d678 | ||
|
|
873df765a0 | ||
|
|
8fdd4f1f0d | ||
|
|
b7d194a244 | ||
|
|
a2a24659de | ||
|
|
8a18cfd56c | ||
|
|
28d19875d5 | ||
|
|
d64e085247 | ||
|
|
0114d938bd | ||
|
|
598e0e64fa | ||
|
|
e32e5f57f3 | ||
|
|
d30aa7c645 | ||
|
|
509fa2e696 | ||
|
|
e813ff6c9f | ||
|
|
d11337fda2 | ||
|
|
2822f98103 | ||
|
|
f4d3be36b6 | ||
|
|
5776bab4e1 | ||
|
|
13cea217dd | ||
|
|
e0d7f45ab8 | ||
|
|
809dbcbd43 | ||
|
|
3f50120a9f | ||
|
|
da37b708b4 | ||
|
|
1dbe82df2d | ||
|
|
aedbdd3e45 | ||
|
|
26312445c8 | ||
|
|
cb26f08ffd | ||
|
|
d11c7ae066 | ||
|
|
4e336c91b6 | ||
|
|
b706d561aa | ||
|
|
904d3c77cd | ||
|
|
d072de06ed | ||
|
|
697b57a141 | ||
|
|
98369b278a | ||
|
|
033e4945d0 | ||
|
|
ac498a948e | ||
|
|
d286611825 | ||
|
|
763f301bfd | ||
|
|
d92dfde167 | ||
|
|
d8844aca89 | ||
|
|
55b5233ee4 |
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"import": [
|
||||
"@cspell/dict-typescript/cspell-ext.json"
|
||||
],
|
||||
"ignoreRegExpList": [
|
||||
"import(?:(?:(?:[ \\n\\t]+([^ *\\n\\t\\{\\},]+)[ \\n\\t]*(?:,|[ \\n\\t]+))?([ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t\"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)|[ \n\\n\\t]*\\*[ \\n\\t]*as[ \\n\\t]+([^ \\n\\t\\{\\}]+)[ \\n\\t]+)from[ \\n\\t]*(?:['\"])([^'\"\\n]+)(['\"])\n",
|
||||
"^import\\s+(['\"]).*\\1$"
|
||||
],
|
||||
"language": "en",
|
||||
"words": [
|
||||
"Bbreak",
|
||||
"nodered",
|
||||
"goog",
|
||||
"thomasnordquist",
|
||||
"nowrap",
|
||||
"subheader",
|
||||
"basepath",
|
||||
"repo",
|
||||
"hexagonalize",
|
||||
"pixelize",
|
||||
"Transistions",
|
||||
"provisionprofile",
|
||||
"Nsis",
|
||||
"webdriverio",
|
||||
"Appx",
|
||||
"Hashable",
|
||||
"clickaway",
|
||||
"Resizer",
|
||||
"Subnodes",
|
||||
"Unmount",
|
||||
"Monokai",
|
||||
"plottable",
|
||||
"snackbar",
|
||||
"Nordquist",
|
||||
"debounced",
|
||||
"mosquitto",
|
||||
"snapcraft",
|
||||
"unsquashfs",
|
||||
"armv",
|
||||
"livingroom",
|
||||
"selectall",
|
||||
"toggledevtools",
|
||||
"Octo",
|
||||
"zigbee",
|
||||
"memoization",
|
||||
"submenu",
|
||||
"AGPL",
|
||||
"Oooooops",
|
||||
"DEVTOOLS",
|
||||
"mixins",
|
||||
"Explorerdmg",
|
||||
"heapsnapshot",
|
||||
"noconflict",
|
||||
"sparkplugb",
|
||||
"protojson",
|
||||
"typesafe"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "MQTT Explorer Development",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspace/MQTT-Explorer",
|
||||
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"ms-vscode.vscode-typescript-next",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"eamodio.gitlens"
|
||||
],
|
||||
"settings": {
|
||||
"editor.formatOnSave": true,
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"forwardPorts": [3000, 8080, 1883, 5900, 6080],
|
||||
"portsAttributes": {
|
||||
"3000": {
|
||||
"label": "MQTT Explorer Server",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"8080": {
|
||||
"label": "Webpack Dev Server",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"1883": {
|
||||
"label": "MQTT Broker",
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"5900": {
|
||||
"label": "VNC Server",
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"6080": {
|
||||
"label": "noVNC Web Client",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
|
||||
"postCreateCommand": "yarn install",
|
||||
|
||||
"postStartCommand": "sudo apt-get update && sudo apt-get install -y mosquitto xvfb x11vnc ffmpeg tmux python3 python3-pip && sudo pip3 install --break-system-packages websockify",
|
||||
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils:2": {
|
||||
"installZsh": true,
|
||||
"installOhMyZsh": true,
|
||||
"upgradePackages": true
|
||||
}
|
||||
},
|
||||
|
||||
"remoteUser": "node"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: mcr.microsoft.com/devcontainers/javascript-node:24
|
||||
volumes:
|
||||
- ..:/workspaces/MQTT-Explorer:cached
|
||||
command: sleep infinity
|
||||
network_mode: service:mosquitto
|
||||
environment:
|
||||
- MQTT_EXPLORER_USERNAME=dev
|
||||
- MQTT_EXPLORER_PASSWORD=dev123
|
||||
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto:2
|
||||
ports:
|
||||
- '1883:1883'
|
||||
- '3000:3000'
|
||||
- '8080:8080'
|
||||
- '5900:5900'
|
||||
- '6080:6080'
|
||||
volumes:
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
@@ -0,0 +1,4 @@
|
||||
# Mosquitto configuration for development
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
persistence false
|
||||
@@ -0,0 +1,64 @@
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
|
||||
# Dependencies
|
||||
node_modules
|
||||
app/node_modules
|
||||
backend/node_modules
|
||||
|
||||
# Build artifacts
|
||||
build
|
||||
dist
|
||||
app/dist
|
||||
|
||||
# Testing
|
||||
coverage
|
||||
.nyc_output
|
||||
test-screenshot-*.png
|
||||
ui-test.mp4
|
||||
ui-test.gif
|
||||
|
||||
# Development
|
||||
.vscode
|
||||
.devcontainer
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# IDE
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.idea
|
||||
|
||||
# Documentation
|
||||
*.md
|
||||
!Readme.md
|
||||
LICENSE.md
|
||||
|
||||
# CI/CD files
|
||||
.releaserc
|
||||
appveyor.yml
|
||||
|
||||
# Misc
|
||||
res
|
||||
scripts
|
||||
docker
|
||||
icon.xcf
|
||||
greenkeeper.json
|
||||
prettier.config.js
|
||||
.prettierignore
|
||||
.eslintrc.json
|
||||
.cspell.json
|
||||
tslint.json
|
||||
mcp.json
|
||||
|
||||
# Data directory (will be created in container)
|
||||
data
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package.ts @thomasnordquist
|
||||
.github @thomasnordquist
|
||||
scripts @thomasnordquist
|
||||
@@ -0,0 +1,5 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
patreon: thomasnordquist
|
||||
custom: https://paypal.me/ThomasNordquist
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# copilot-instructions.md - Agent Long-Term Memory
|
||||
|
||||
## META-INSTRUCTIONS (IMMUTABLE)
|
||||
|
||||
1. **Long-term memory**: If you learn something during a session that would save time in future sessions, add it to `.github/copilot-instructions.md`
|
||||
2. **Paper knowledge must go**: If something is no longer true, update or remove it immediately
|
||||
3. **Evaluate after every session**: Consider whether the instructions need updates based on what you learned
|
||||
4. **Concise and useful**: All information must be actionable, current, and concise
|
||||
|
||||
## Test Commands
|
||||
|
||||
**Unit tests:**
|
||||
- `yarn test` - All unit tests (app + backend)
|
||||
- `yarn test:app` - Frontend tests only
|
||||
- `yarn test:backend` - Backend tests only
|
||||
|
||||
**Integration tests:**
|
||||
- `yarn test:ui` - Browser tests (requires `yarn build` first)
|
||||
- `yarn test:demo-video` - UI recording (requires Xvfb, mosquitto, tmux, ffmpeg)
|
||||
- `yarn test:mcp` - Model Context Protocol tests
|
||||
- `yarn test:all` - All tests (unit + demo-video)
|
||||
- `./scripts/runBrowserTests.sh` - Browser mode UI tests (requires mosquitto service)
|
||||
|
||||
**CI jobs:** `test`, `ui-tests`, `demo-video`, `test-browser`, `browser-ui-tests`
|
||||
|
||||
**Important:** Browser UI tests require MQTT broker. In CI, GitHub Actions health checks ensure the mosquitto service is ready before tests run.
|
||||
|
||||
## Browser Mode
|
||||
|
||||
**Prerequisites:** Node.js ≥24, Yarn, Mosquitto broker (for testing)
|
||||
|
||||
**Development (hot reload):**
|
||||
```bash
|
||||
export MQTT_EXPLORER_USERNAME=admin MQTT_EXPLORER_PASSWORD=yourpass
|
||||
yarn dev:server
|
||||
# Backend: http://localhost:3000, Frontend: http://localhost:8080 (use this one)
|
||||
```
|
||||
|
||||
**Production:**
|
||||
```bash
|
||||
yarn build:server
|
||||
export MQTT_EXPLORER_USERNAME=admin MQTT_EXPLORER_PASSWORD=yourpass
|
||||
yarn start:server # http://localhost:3000
|
||||
```
|
||||
|
||||
**Build artifacts:** `dist/src/server.js`, `app/build/*.js`, `app/build/index.html`
|
||||
|
||||
## Debugging Browser Mode
|
||||
|
||||
**DevTools checks:**
|
||||
- Console: JavaScript errors, CSP errors (security headers), WebSocket issues
|
||||
- Network: Static asset loading, WebSocket status, API auth
|
||||
|
||||
**Common issues:**
|
||||
- **Blank page/CSP errors:** Add `'unsafe-eval'` to `scriptSrc` in `src/server.ts` helmet config
|
||||
- **Auth loop:** WebSocket auth failing - check Network → WS → Messages and server logs
|
||||
- **Theme errors:** Verify both ThemeProvider and LegacyThemeProvider in `app/src/index.tsx`
|
||||
|
||||
**Expected warnings (non-fatal):**
|
||||
- React 18 + Material-UI v5 type warnings
|
||||
- IpcRendererEventBus errors (no Electron IPC in browser mode)
|
||||
- MUI locale, componentWillReceiveProps, ACE editor warnings
|
||||
|
||||
**WebSocket debugging:**
|
||||
```bash
|
||||
node dist/src/server.js 2>&1 | tee server.log
|
||||
# Check DevTools → Network → WS → Messages for handshake
|
||||
# CORS: check ALLOWED_ORIGINS env var
|
||||
```
|
||||
|
||||
**Security notes:**
|
||||
- `unsafe-eval` in CSP required for webpack (security tradeoff)
|
||||
- Never hardcode credentials (use env vars)
|
||||
- Production: use HTTPS with reverse proxy
|
||||
- Rate limit: 5 auth attempts/15min/IP
|
||||
- File upload limit: 16MB
|
||||
|
||||
**Key files:**
|
||||
- `src/server.ts` - Express server, security middleware
|
||||
- `app/webpack.browser.config.mjs` - Browser webpack config
|
||||
- `app/src/browserEventBus.ts` - Socket.io client
|
||||
- `app/src/components/BrowserAuthWrapper.tsx` - Auth dialog
|
||||
- `app/src/index.tsx` - React entry, theme providers
|
||||
@@ -0,0 +1,29 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release
|
||||
- beta
|
||||
paths:
|
||||
- Dockerfile
|
||||
- .github
|
||||
|
||||
jobs:
|
||||
create-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
||||
@@ -0,0 +1,52 @@
|
||||
name: 'Copilot Setup Steps'
|
||||
|
||||
# Automatically run the setup steps when they are changed to allow for easy validation, and
|
||||
# allow manual testing through the repository's "Actions" tab
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- .github/workflows/copilot-setup-steps.yml
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/copilot-setup-steps.yml
|
||||
|
||||
jobs:
|
||||
copilot-setup-steps:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TESTS_MQTT_BROKER_HOST: localhost
|
||||
TESTS_MQTT_BROKER_PORT: 1883
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xvfb mosquitto
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache yarn dependencies
|
||||
uses: actions/cache@v4
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: |
|
||||
${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
node_modules
|
||||
app/node_modules
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
@@ -0,0 +1,226 @@
|
||||
name: Docker Browser Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release
|
||||
- beta
|
||||
paths:
|
||||
- 'Dockerfile.browser'
|
||||
- 'src/server.ts'
|
||||
- 'src/AuthManager.ts'
|
||||
- 'app/**'
|
||||
- 'backend/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/docker-browser.yml'
|
||||
- 'tsconfig.json'
|
||||
- 'events/**'
|
||||
schedule:
|
||||
# Run every two weeks (1st and 15th of each month) at 2:00 AM UTC
|
||||
- cron: '0 2 1,15 * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
env:
|
||||
TESTS_MQTT_BROKER_HOST: localhost
|
||||
TESTS_MQTT_BROKER_PORT: 1883
|
||||
|
||||
services:
|
||||
# MQTT broker for testing
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto:2
|
||||
ports:
|
||||
- 1883:1883
|
||||
options: >-
|
||||
--health-cmd "mosquitto_sub -t '$SYS/#' -C 1"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
--entrypoint sh
|
||||
command: -c "mkdir -p /mosquitto/config && echo 'listener 1883' > /mosquitto/config/mosquitto.conf && echo 'allow_anonymous true' >> /mosquitto/config/mosquitto.conf && exec mosquitto -c /mosquitto/config/mosquitto.conf"
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix={{branch}}-
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.browser
|
||||
platforms: linux/amd64
|
||||
push: false
|
||||
load: true
|
||||
tags: mqtt-explorer:test
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Test Docker image - Basic startup
|
||||
run: |
|
||||
# Start container with test credentials
|
||||
docker run -d \
|
||||
--name mqtt-explorer-test \
|
||||
-p 3000:3000 \
|
||||
-e MQTT_EXPLORER_USERNAME=test \
|
||||
-e MQTT_EXPLORER_PASSWORD=test123 \
|
||||
-e PORT=3000 \
|
||||
mqtt-explorer:test
|
||||
|
||||
# Wait for server to be ready (max 60 seconds)
|
||||
echo "Waiting for server to start..."
|
||||
for i in {1..60}; do
|
||||
if curl -f http://localhost:3000 > /dev/null 2>&1; then
|
||||
echo "Server started successfully after $i seconds"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 60 ]; then
|
||||
echo "Server failed to start within 60 seconds"
|
||||
docker logs mqtt-explorer-test
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: Test Docker image - Health check
|
||||
run: |
|
||||
# Wait for health check to pass
|
||||
echo "Waiting for health check to pass..."
|
||||
for i in {1..30}; do
|
||||
health=$(docker inspect --format='{{.State.Health.Status}}' mqtt-explorer-test)
|
||||
if [ "$health" = "healthy" ]; then
|
||||
echo "Container is healthy"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 30 ]; then
|
||||
echo "Health check failed"
|
||||
docker logs mqtt-explorer-test
|
||||
exit 1
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
- name: Test Docker image - Verify response
|
||||
run: |
|
||||
# Test that the server responds with HTML
|
||||
response=$(curl -s http://localhost:3000)
|
||||
if echo "$response" | grep -q "MQTT Explorer"; then
|
||||
echo "Server is serving the application correctly"
|
||||
else
|
||||
echo "Server response does not contain expected content"
|
||||
echo "Response: $response"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Test Docker image - Verify data persistence
|
||||
run: |
|
||||
# Check that data directory was created
|
||||
docker exec mqtt-explorer-test sh -c '[ -d /app/data ] && echo "Data directory exists"'
|
||||
|
||||
- name: Clean up test container
|
||||
if: always()
|
||||
run: |
|
||||
docker stop mqtt-explorer-test || true
|
||||
docker rm mqtt-explorer-test || true
|
||||
|
||||
- name: Check Docker image size
|
||||
run: |
|
||||
echo "### Docker Image Size" >> $GITHUB_STEP_SUMMARY
|
||||
docker images mqtt-explorer:test --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# Get size in bytes for detailed reporting
|
||||
SIZE_BYTES=$(docker inspect mqtt-explorer:test --format='{{.Size}}')
|
||||
SIZE_MB=$((SIZE_BYTES / 1024 / 1024))
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Image size**: ${SIZE_MB} MB (${SIZE_BYTES} bytes)" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Image size: ${SIZE_MB} MB"
|
||||
|
||||
- name: Setup Node.js for browser tests
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
cache: 'yarn'
|
||||
|
||||
- name: Install dependencies for browser tests
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install --with-deps chromium
|
||||
|
||||
- name: Start Docker container for browser tests
|
||||
run: |
|
||||
docker run -d \
|
||||
--name mqtt-explorer-browser-test \
|
||||
--network host \
|
||||
-e MQTT_EXPLORER_USERNAME=test \
|
||||
-e MQTT_EXPLORER_PASSWORD=test123 \
|
||||
-e PORT=3000 \
|
||||
mqtt-explorer:test
|
||||
|
||||
# Wait for server to be ready
|
||||
echo "Waiting for Docker container to be ready..."
|
||||
timeout 60 bash -c 'until curl -f http://localhost:3000; do sleep 1; done'
|
||||
echo "Docker container is ready"
|
||||
|
||||
- name: Run browser test suite
|
||||
run: |
|
||||
yarn test:browser
|
||||
env:
|
||||
MQTT_EXPLORER_USERNAME: test
|
||||
MQTT_EXPLORER_PASSWORD: test123
|
||||
BROWSER_MODE_URL: http://localhost:3000
|
||||
|
||||
- name: Clean up browser test container
|
||||
if: always()
|
||||
run: |
|
||||
docker logs mqtt-explorer-browser-test || true
|
||||
docker stop mqtt-explorer-browser-test || true
|
||||
docker rm mqtt-explorer-browser-test || true
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.browser
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Generate artifact attestation
|
||||
uses: actions/attest-build-provenance@v1
|
||||
with:
|
||||
subject-name: ghcr.io/${{ github.repository }}
|
||||
subject-digest: ${{ steps.build.outputs.digest }}
|
||||
push-to-registry: true
|
||||
@@ -0,0 +1,56 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
- beta
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
build:
|
||||
- os: ubuntu-latest
|
||||
task: linux
|
||||
- os: windows-latest
|
||||
task: win
|
||||
- os: macos-latest
|
||||
task: mac
|
||||
runs-on: ${{ matrix.build.os }}
|
||||
steps:
|
||||
- if: matrix.build.os == 'ubuntu-latest'
|
||||
run: sudo snap install snapcraft --classic
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
- run: npm install -g yarn
|
||||
- run: yarn
|
||||
- id: create_token # get ReleaseBot access token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.RELEASE_BOT_APP_ID }}
|
||||
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
|
||||
- name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v4
|
||||
id: semantic # Need an `id` for output variables
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
|
||||
- run: yarn build
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
- run: yarn prepare-release
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
- run: yarn package ${{ matrix.build.task }}
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
on:
|
||||
pull_request_target: # Use pull_request_target
|
||||
branches: [master, beta, release]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
||||
volumes:
|
||||
- ./:/app
|
||||
options: --user root
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Install Packages
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Build
|
||||
run: yarn build
|
||||
- name: Test
|
||||
run: yarn test
|
||||
|
||||
browser-ui-tests:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
||||
volumes:
|
||||
- ./:/app
|
||||
options: --user root
|
||||
env:
|
||||
TESTS_MQTT_BROKER_HOST: mosquitto
|
||||
TESTS_MQTT_BROKER_PORT: 1883
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Start mosquitto
|
||||
run: mosquitto -c /etc/mosquitto/conf.d/default.conf -d
|
||||
- name: Install Packages
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Build Browser Mode
|
||||
run: yarn build:server
|
||||
- name: Run Browser UI Tests
|
||||
timeout-minutes: 10
|
||||
run: ./scripts/runBrowserTests.sh
|
||||
- name: Upload Test Screenshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: browser-test-screenshots
|
||||
path: |
|
||||
test-screenshot-*.png
|
||||
retention-days: 30
|
||||
|
||||
demo-video:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
||||
volumes:
|
||||
- ./:/app
|
||||
options: --user root
|
||||
env:
|
||||
TESTS_MQTT_BROKER_HOST: localhost
|
||||
TESTS_MQTT_BROKER_PORT: 1883
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Start mosquitto
|
||||
run: mosquitto -c /etc/mosquitto/conf.d/default.conf -d
|
||||
- name: Install Packages
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Build
|
||||
run: yarn build
|
||||
- name: Generate Demo Video
|
||||
run: yarn ui-test
|
||||
- name: Post-processing
|
||||
run: ./scripts/prepareVideo.sh
|
||||
- name: Generate unique base path
|
||||
id: basepath
|
||||
run: |
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
BASEPATH="pr-${{ github.event.pull_request.number }}-${TIMESTAMP}"
|
||||
echo "basepath=${BASEPATH}" >> $GITHUB_OUTPUT
|
||||
- name: Install AWS CLI v2
|
||||
run: |
|
||||
apt-get update && apt-get install -y unzip
|
||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
||||
unzip -q awscliv2.zip
|
||||
./aws/install
|
||||
rm -rf aws awscliv2.zip
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: ${{ vars.AWS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: 'eu-central-1'
|
||||
- name: Upload full video to S3
|
||||
env:
|
||||
AWS_BUCKET: ${{ vars.AWS_BUCKET }}
|
||||
BASEPATH: ${{ steps.basepath.outputs.basepath }}
|
||||
run: |
|
||||
# Upload GIF
|
||||
aws s3api put-object \
|
||||
--bucket ${AWS_BUCKET} \
|
||||
--key artifacts/${BASEPATH}/ui-test.gif \
|
||||
--body ./ui-test.gif \
|
||||
--content-type image/gif
|
||||
|
||||
# Upload MP4
|
||||
aws s3api put-object \
|
||||
--bucket ${AWS_BUCKET} \
|
||||
--key artifacts/${BASEPATH}/ui-test.mp4 \
|
||||
--body ./ui-test.mp4 \
|
||||
--content-type video/mp4
|
||||
- name: Upload video segments to S3
|
||||
env:
|
||||
AWS_BUCKET: ${{ vars.AWS_BUCKET }}
|
||||
BASEPATH: ${{ steps.basepath.outputs.basepath }}
|
||||
shell: bash
|
||||
run: |
|
||||
# Upload all GIF segment files if they exist
|
||||
shopt -s nullglob # Make glob return empty list if no matches
|
||||
for segment in segment-*.gif; do
|
||||
echo "Uploading $segment..."
|
||||
aws s3api put-object \
|
||||
--bucket ${AWS_BUCKET} \
|
||||
--key artifacts/${BASEPATH}/${segment} \
|
||||
--body ./${segment} \
|
||||
--content-type image/gif
|
||||
done
|
||||
shopt -u nullglob # Restore default behavior
|
||||
- name: Generate file URLs
|
||||
id: fileurl
|
||||
env:
|
||||
AWS_BUCKET: ${{ vars.AWS_BUCKET }}
|
||||
BASEPATH: ${{ steps.basepath.outputs.basepath }}
|
||||
run: |
|
||||
BASE_URL="https://${AWS_BUCKET}.s3.eu-central-1.amazonaws.com/artifacts/${BASEPATH}"
|
||||
echo "base-url=${BASE_URL}" >> $GITHUB_OUTPUT
|
||||
echo "Uploaded to: ${BASE_URL}"
|
||||
- name: Generate markdown summary
|
||||
id: markdown
|
||||
env:
|
||||
BASE_URL: ${{ steps.fileurl.outputs.base-url }}
|
||||
run: |
|
||||
MARKDOWN=$(node ./scripts/generateMarkdownSummary.js "${BASE_URL}")
|
||||
echo "markdown<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$MARKDOWN" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
- name: Add to workflow summary
|
||||
env:
|
||||
MARKDOWN: ${{ steps.markdown.outputs.markdown }}
|
||||
run: |
|
||||
echo "$MARKDOWN" >> $GITHUB_STEP_SUMMARY
|
||||
- name: Post video to PR
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
MARKDOWN: ${{ steps.markdown.outputs.markdown }}
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const markdown = process.env.MARKDOWN;
|
||||
github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: markdown
|
||||
});
|
||||
|
||||
test-browser:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TESTS_MQTT_BROKER_HOST: localhost
|
||||
TESTS_MQTT_BROKER_PORT: 1883
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto:2
|
||||
ports:
|
||||
- 1883:1883
|
||||
options: >-
|
||||
--health-cmd "mosquitto_sub -t '$SYS/#' -C 1"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
--entrypoint sh
|
||||
command: -c "mkdir -p /mosquitto/config && echo 'listener 1883' > /mosquitto/config/mosquitto.conf && echo 'allow_anonymous true' >> /mosquitto/config/mosquitto.conf && exec mosquitto -c /mosquitto/config/mosquitto.conf"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- name: Install Dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install --with-deps chromium
|
||||
- name: Build Browser Mode
|
||||
run: yarn build:server
|
||||
- name: Test App
|
||||
run: yarn test:app
|
||||
- name: Test Backend
|
||||
run: yarn test:backend
|
||||
- name: Start Server in Background
|
||||
run: |
|
||||
yarn start:server &
|
||||
echo $! > server.pid
|
||||
env:
|
||||
MQTT_EXPLORER_USERNAME: test
|
||||
MQTT_EXPLORER_PASSWORD: test123
|
||||
PORT: 3000
|
||||
- name: Wait for Server
|
||||
run: |
|
||||
timeout 30 bash -c 'until curl -f http://localhost:3000; do sleep 1; done'
|
||||
- name: Browser Smoke Test
|
||||
run: |
|
||||
# Test server is running
|
||||
curl -f http://localhost:3000 || exit 1
|
||||
echo "Browser mode server is running successfully"
|
||||
- name: Stop Server
|
||||
if: always()
|
||||
run: |
|
||||
if [ -f server.pid ]; then
|
||||
kill $(cat server.pid) || true
|
||||
rm server.pid
|
||||
fi
|
||||
@@ -0,0 +1,17 @@
|
||||
name: Update Website
|
||||
|
||||
on: [release, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
update-website:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: gh-pages
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- run: npm install
|
||||
- run: npm run readme
|
||||
- uses: stefanzweifel/git-auto-commit-action@v5
|
||||
+29
@@ -7,3 +7,32 @@ build
|
||||
test.dot
|
||||
test.png
|
||||
.awcache
|
||||
.scannerwork
|
||||
screen*.png
|
||||
|
||||
# MCP introspection artifacts
|
||||
mqtt-explorer-mcp-screenshot.png
|
||||
screenshot-mcp-*.png
|
||||
test-mcp-introspection.js
|
||||
|
||||
/data
|
||||
test-screenshot-*.png
|
||||
test-expand-*.png
|
||||
browser-debug-screenshot.png
|
||||
|
||||
app/.webpack-cache
|
||||
|
||||
# Temporary files
|
||||
/tmp
|
||||
|
||||
# Demo video artifacts
|
||||
scenes.json
|
||||
segment-*.mp4
|
||||
segment-*.gif
|
||||
ui-test.mp4
|
||||
ui-test.gif
|
||||
app.mp4
|
||||
app2.mp4
|
||||
app720.gif
|
||||
qrawvideorgb24.yuv
|
||||
intro.png
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
build
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"branches": [
|
||||
"release",
|
||||
{
|
||||
"name": "beta",
|
||||
"prerelease": true
|
||||
}
|
||||
],
|
||||
repositoryUrl: "git@github.com:thomasnordquist/MQTT-Explorer.git",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"semantic-release-export-data",
|
||||
"@semantic-release/changelog",
|
||||
[
|
||||
"@semantic-release/npm",
|
||||
{
|
||||
"npmPublish": false
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"package.json",
|
||||
"yarn.lock"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
language: node_js
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- $HOME/.cache/electron
|
||||
- $HOME/.cache/electron-builder
|
||||
- $HOME/.npm/_prebuilds
|
||||
|
||||
node_js:
|
||||
- "10"
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
install:
|
||||
- npm install
|
||||
|
||||
script:
|
||||
- npm run build
|
||||
- npm run test
|
||||
- if [[ "$TRAVIS_TAG" != "" ]]; then npm run prepare-release; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$TRAVIS_TAG" != "" ]]; then npm run package -- linux; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TRAVIS_TAG" != "" ]]; then npm run package -- mac; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TRAVIS_TAG" != "" ]]; then npm run package -- win; fi
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"files.exclude": {
|
||||
"**/node_modules": true,
|
||||
"build/": true
|
||||
}
|
||||
}
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
# Browser Mode Documentation
|
||||
|
||||
MQTT Explorer now supports running as a web application served by a Node.js server, in addition to the existing Electron desktop app.
|
||||
|
||||
## Running in Browser Mode
|
||||
|
||||
### Quick Start
|
||||
|
||||
1. Build the application for browser mode:
|
||||
```bash
|
||||
yarn build:server
|
||||
```
|
||||
|
||||
2. Start the server:
|
||||
```bash
|
||||
yarn start:server
|
||||
```
|
||||
|
||||
3. Open your browser and navigate to `http://localhost:3000`
|
||||
|
||||
4. You'll be prompted to log in with credentials that were generated on server startup.
|
||||
|
||||
### Development Mode
|
||||
|
||||
To run in development mode with hot reload:
|
||||
|
||||
```bash
|
||||
yarn dev:server
|
||||
```
|
||||
|
||||
This starts both the webpack dev server and the backend server.
|
||||
|
||||
## Authentication
|
||||
|
||||
### Environment Variables
|
||||
|
||||
You can set custom authentication credentials using environment variables:
|
||||
|
||||
```bash
|
||||
export MQTT_EXPLORER_USERNAME=admin
|
||||
export MQTT_EXPLORER_PASSWORD=secretpassword
|
||||
yarn start:server
|
||||
```
|
||||
|
||||
### Generated Credentials
|
||||
|
||||
If no environment variables are set, the server will generate credentials on first startup and save them to `data/credentials.json`. The generated credentials will be printed to the console:
|
||||
|
||||
```
|
||||
============================================================
|
||||
Generated new credentials:
|
||||
Username: user-abc123
|
||||
Password: 123e4567-e89b-12d3-a456-426614174000
|
||||
============================================================
|
||||
Please save these credentials. They will be persisted to:
|
||||
/path/to/data/credentials.json
|
||||
============================================================
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
### Certificate Upload
|
||||
|
||||
In browser mode, certificate files are uploaded directly through the browser using the HTML5 File API. The certificates are:
|
||||
- Read client-side as base64
|
||||
- Stored in the connection configuration
|
||||
- Used when establishing MQTT connections
|
||||
|
||||
### Data Storage
|
||||
|
||||
In browser mode, all data is stored on the server:
|
||||
- Credentials: `data/credentials.json`
|
||||
- Uploaded certificates: `data/certificates/`
|
||||
- File uploads: `data/uploads/`
|
||||
|
||||
### Port Configuration
|
||||
|
||||
The default port is 3000. You can change it using the `PORT` environment variable:
|
||||
|
||||
```bash
|
||||
PORT=8080 yarn start:server
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
### Client-Server Communication
|
||||
|
||||
- **Electron Mode**: Uses Electron IPC for communication between renderer and main process
|
||||
- **Browser Mode**: Uses Socket.io WebSockets for real-time communication between browser and server
|
||||
|
||||
The application automatically detects the environment and uses the appropriate transport layer.
|
||||
|
||||
### Event Bus Abstraction
|
||||
|
||||
Both Electron IPC and Socket.io implement the same `EventBusInterface`, allowing the application code to work seamlessly in both modes without modification.
|
||||
|
||||
## Differences from Electron Mode
|
||||
|
||||
### Browser Mode Limitations
|
||||
|
||||
1. **File System Access**: Limited to server-side operations
|
||||
2. **Native Dialogs**: File selection uses browser file input instead of native dialogs
|
||||
3. **Auto-Updates**: Not available in browser mode
|
||||
4. **Tray Icon**: Not available in browser mode
|
||||
|
||||
### Browser Mode Advantages
|
||||
|
||||
1. **No Installation**: Access from any browser
|
||||
2. **Cross-Platform**: Works on any device with a modern browser
|
||||
3. **Remote Access**: Can be deployed on a server for remote access
|
||||
4. **Multi-User**: Can support authentication for multiple users
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Production Deployment
|
||||
|
||||
**CRITICAL**: The following security measures must be implemented for production deployments:
|
||||
|
||||
#### 1. HTTPS/TLS Encryption
|
||||
Always use HTTPS in production to protect credentials and MQTT data in transit:
|
||||
|
||||
```bash
|
||||
# Use a reverse proxy like nginx or Apache with TLS
|
||||
# Example nginx configuration:
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name mqtt-explorer.example.com;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 2. Environment Variables for Credentials
|
||||
**NEVER** use generated credentials in production. Always set secure credentials via environment variables:
|
||||
|
||||
```bash
|
||||
export MQTT_EXPLORER_USERNAME=your_secure_username
|
||||
export MQTT_EXPLORER_PASSWORD=your_strong_password_min_12_chars
|
||||
export NODE_ENV=production
|
||||
yarn start:server
|
||||
```
|
||||
|
||||
#### 3. CORS Configuration
|
||||
Configure allowed origins instead of using the wildcard (`*`):
|
||||
|
||||
```bash
|
||||
# Single origin
|
||||
export ALLOWED_ORIGINS=https://mqtt-explorer.example.com
|
||||
|
||||
# Multiple origins (comma-separated)
|
||||
export ALLOWED_ORIGINS=https://app1.example.com,https://app2.example.com
|
||||
|
||||
yarn start:server
|
||||
```
|
||||
|
||||
In production with `NODE_ENV=production`, wildcard CORS is automatically disabled for security.
|
||||
|
||||
#### 4. Network Security
|
||||
- Deploy behind a firewall or VPN
|
||||
- Use IP whitelisting if possible
|
||||
- Implement network-level rate limiting
|
||||
- Monitor for suspicious connection patterns
|
||||
|
||||
#### 5. File Upload Security
|
||||
The server implements several protections against malicious file uploads:
|
||||
- Maximum file size: 16MB (configurable via `MAX_FILE_SIZE` constant)
|
||||
- Path traversal protection via filename sanitization
|
||||
- Files stored in isolated directories
|
||||
- Real path validation to prevent directory escapes
|
||||
|
||||
#### 6. Authentication Security
|
||||
The server implements multiple layers of authentication security:
|
||||
- **Password Hashing**: bcrypt with 10 rounds
|
||||
- **Timing Attack Protection**: Constant-time string comparison for usernames
|
||||
- **Rate Limiting**: Maximum 5 failed attempts per IP per 15 minutes
|
||||
- **Session Tracking**: Failed attempts are tracked per client IP
|
||||
- **No Credential Logging**: In production mode, credentials are not logged
|
||||
|
||||
#### 7. HTTP Security Headers
|
||||
The server uses helmet.js to set security headers:
|
||||
- Content Security Policy (CSP)
|
||||
- HTTP Strict Transport Security (HSTS) in production
|
||||
- X-Content-Type-Options: nosniff
|
||||
- X-Frame-Options: DENY
|
||||
- X-XSS-Protection
|
||||
|
||||
### Security Best Practices
|
||||
|
||||
1. **Rotate Credentials Regularly**: Change authentication credentials periodically
|
||||
2. **Monitor Logs**: Watch for authentication failures and unusual patterns
|
||||
3. **Keep Dependencies Updated**: Run `yarn audit` regularly
|
||||
4. **Limit Network Exposure**: Don't expose the server directly to the internet
|
||||
5. **Use Strong Passwords**: Minimum 12 characters with mixed case, numbers, and symbols
|
||||
6. **Enable Logging**: Monitor access logs and error logs
|
||||
7. **Regular Backups**: Back up configuration and certificate data
|
||||
8. **Principle of Least Privilege**: Run the server with minimal required permissions
|
||||
|
||||
### Vulnerability Reporting
|
||||
|
||||
If you discover a security vulnerability, please report it via:
|
||||
- GitHub Security Advisories
|
||||
- Email to the maintainer
|
||||
- Do NOT create public issues for security vulnerabilities
|
||||
|
||||
### Security Audit Log
|
||||
|
||||
- **2024-12**: Initial security review and hardening
|
||||
- Added helmet.js for HTTP security headers
|
||||
- Implemented rate limiting for authentication
|
||||
- Added path traversal protection
|
||||
- Implemented constant-time comparison for credentials
|
||||
- Added input validation and size limits
|
||||
- Removed credential logging in production
|
||||
- Added configurable CORS origins
|
||||
- Created comprehensive security test suite
|
||||
|
||||
## Security Considerations (Legacy)
|
||||
|
||||
1. **HTTPS**: For production, always use HTTPS to encrypt credentials and MQTT data
|
||||
2. **Authentication**: Keep credentials secure and rotate them regularly
|
||||
3. **Network**: Ensure the server is on a trusted network or behind a firewall
|
||||
4. **Environment Variables**: Use environment variables for production credentials, not the generated ones
|
||||
|
||||
## Deployment
|
||||
|
||||
For production deployment:
|
||||
|
||||
1. Build the application:
|
||||
```bash
|
||||
yarn build:server
|
||||
```
|
||||
|
||||
2. Set environment variables:
|
||||
```bash
|
||||
export MQTT_EXPLORER_USERNAME=your_username
|
||||
export MQTT_EXPLORER_PASSWORD=your_secure_password
|
||||
export PORT=3000
|
||||
```
|
||||
|
||||
3. Start the server:
|
||||
```bash
|
||||
yarn start:server
|
||||
```
|
||||
|
||||
4. Use a reverse proxy (nginx, Apache) to add HTTPS and additional security features
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Debugging
|
||||
|
||||
Enable detailed Socket.IO connection and lifecycle debugging:
|
||||
|
||||
```bash
|
||||
DEBUG=mqtt-explorer:socketio* yarn start:server
|
||||
```
|
||||
|
||||
Available debug namespaces:
|
||||
- `mqtt-explorer:socketio` - General Socket.IO events and metrics
|
||||
- `mqtt-explorer:socketio:connect` - Client connection events
|
||||
- `mqtt-explorer:socketio:disconnect` - Client disconnection and cleanup
|
||||
- `mqtt-explorer:socketio:subscriptions` - Subscription lifecycle tracking
|
||||
- `mqtt-explorer:socketio:connections` - MQTT connection ownership
|
||||
|
||||
This will log:
|
||||
- Client connect/disconnect events
|
||||
- Subscription counts per socket
|
||||
- MQTT connection ownership tracking
|
||||
- Memory leak detection metrics (subscriptions, handlers, connections)
|
||||
|
||||
Example output:
|
||||
```
|
||||
mqtt-explorer:socketio:connect Client connected: abc123de
|
||||
mqtt-explorer:socketio [connect] clients=1 subscriptions=8 mqttConns=0 | socket[abc123de]: subs=8 conns=0
|
||||
mqtt-explorer:socketio:connections Connection my-mqtt owned by socket abc123de (total: 1)
|
||||
mqtt-explorer:socketio:disconnect Client disconnected: abc123de
|
||||
mqtt-explorer:socketio:subscriptions Removed 8 subscriptions for socket abc123de
|
||||
mqtt-explorer:socketio [disconnect] clients=0 subscriptions=0 mqttConns=0 | socket[abc123de]: subs=0 conns=0
|
||||
```
|
||||
|
||||
### Authentication Fails
|
||||
|
||||
1. Check the console output for the generated credentials
|
||||
2. Clear browser session storage: `sessionStorage.clear()` in browser console
|
||||
3. Restart the server to regenerate credentials
|
||||
|
||||
### Connection Issues
|
||||
|
||||
1. Check that the server is running: `http://localhost:3000`
|
||||
2. Check browser console for Socket.io connection errors
|
||||
3. Verify firewall rules allow the port
|
||||
|
||||
### Certificate Upload Issues
|
||||
|
||||
In browser mode, certificates are handled differently:
|
||||
- Use the file upload button to select certificate files
|
||||
- Files are read and encoded client-side
|
||||
- Large certificate files (>16KB) will be rejected
|
||||
@@ -0,0 +1,328 @@
|
||||
# CI/CD Pipeline Documentation
|
||||
|
||||
## Overview
|
||||
|
||||
MQTT Explorer uses GitHub Actions for continuous integration and testing. The pipeline tests both Electron (desktop) and browser modes.
|
||||
|
||||
## Workflows
|
||||
|
||||
### Test Workflow (`.github/workflows/tests.yml`)
|
||||
|
||||
This workflow runs on pull requests to `master`, `beta`, and `release` branches.
|
||||
|
||||
### Docker Browser Build Workflow (`.github/workflows/docker-browser.yml`)
|
||||
|
||||
This workflow builds and publishes a Docker image for the browser mode.
|
||||
|
||||
**Triggers**:
|
||||
- Push to `master`, `beta`, or `release` branches (when relevant files change)
|
||||
- Schedule: Runs every two weeks (1st and 15th of each month at 2:00 AM UTC)
|
||||
- Manual trigger via workflow_dispatch
|
||||
|
||||
**Platforms**:
|
||||
- linux/amd64 (x86-64)
|
||||
- linux/arm64 (Raspberry Pi 3/4/5, Apple Silicon)
|
||||
- linux/arm/v7 (Raspberry Pi 2/3)
|
||||
|
||||
**Image Registry**: GitHub Container Registry (ghcr.io/thomasnordquist/mqtt-explorer)
|
||||
|
||||
**Tags**:
|
||||
- `latest` - Latest build from master branch
|
||||
- `master` - Latest build from master
|
||||
- `beta` - Latest build from beta branch
|
||||
- `release` - Latest build from release branch
|
||||
- `<branch>-<sha>` - Specific commit builds
|
||||
|
||||
**Steps**:
|
||||
1. Build Docker image with multi-stage build
|
||||
2. Test basic startup with test credentials
|
||||
3. Test health check
|
||||
4. Verify HTTP response
|
||||
5. Test data directory creation
|
||||
6. Check Docker image size
|
||||
7. Setup Node.js 24 for browser tests
|
||||
8. Install dependencies for browser tests
|
||||
9. Install Playwright browsers (`npx playwright install --with-deps chromium`)
|
||||
10. Start container for browser tests
|
||||
11. Run browser test suite with Playwright
|
||||
12. Push image to GitHub Container Registry
|
||||
13. Generate build attestation for supply chain security
|
||||
|
||||
**Image Features**:
|
||||
- Multi-stage build for minimal size
|
||||
- Alpine Linux base with Node.js 24 (~200MB final image)
|
||||
- Multi-platform support (amd64, arm64, arm/v7)
|
||||
- Non-root user (UID 1001)
|
||||
- Health check endpoint
|
||||
- Proper signal handling with dumb-init
|
||||
- Persistent data volume at `/app/data`
|
||||
|
||||
### Test Workflow (`.github/workflows/tests.yml`)
|
||||
|
||||
This workflow runs on pull requests to `master`, `beta`, and `release` branches.
|
||||
|
||||
#### Jobs
|
||||
|
||||
##### 1. `test` - Electron Mode Tests
|
||||
|
||||
Tests the traditional Electron desktop application:
|
||||
|
||||
- **Environment**: Custom Docker container (`ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest`)
|
||||
- Based on Node.js 24
|
||||
- Includes Xvfb for headless display
|
||||
- Includes FFmpeg for video recording
|
||||
- Includes Mosquitto MQTT broker
|
||||
- **Playwright browsers pre-installed** with system dependencies
|
||||
- **Steps**:
|
||||
1. Install dependencies with frozen lockfile
|
||||
2. Build the Electron application
|
||||
3. Run unit tests (app + backend)
|
||||
4. Run UI tests with video recording
|
||||
5. Upload test video to S3 with 90-day expiration tag
|
||||
6. Post demo video to PR as comment
|
||||
7. Display test results in GitHub summary
|
||||
|
||||
**Artifacts**:
|
||||
- UI test video (GIF format) uploaded to S3 using AWS CLI
|
||||
- Video is tagged with `expiration=90days` for automatic lifecycle deletion
|
||||
- Video is posted to the PR thread as an embedded image
|
||||
- Videos expire after 90 days via S3 lifecycle policy
|
||||
|
||||
##### 2. `test-browser` - Browser Mode Tests
|
||||
|
||||
Tests the new browser/server mode:
|
||||
|
||||
- **Environment**: Ubuntu latest with Node.js 24
|
||||
- **Services**:
|
||||
- **Mosquitto MQTT Broker**: Eclipse Mosquitto v2 on port 1883
|
||||
- Health checks enabled
|
||||
- Anonymous connections allowed
|
||||
- **Steps**:
|
||||
1. Setup Node.js 24
|
||||
2. Install dependencies
|
||||
3. Install Playwright browsers (`npx playwright install --with-deps chromium`)
|
||||
4. Build browser mode (`yarn build:server`)
|
||||
5. Run unit tests (app + backend)
|
||||
6. Start server in background with test credentials
|
||||
7. Wait for server to be ready
|
||||
8. Run browser smoke tests
|
||||
9. Clean up server process
|
||||
|
||||
**Environment Variables**:
|
||||
- `MQTT_EXPLORER_USERNAME=test`
|
||||
- `MQTT_EXPLORER_PASSWORD=test123`
|
||||
- `PORT=3000`
|
||||
|
||||
## Test Commands
|
||||
|
||||
The following npm scripts are used in CI/CD:
|
||||
|
||||
```bash
|
||||
# Unit tests
|
||||
yarn test # Run all tests (app + backend)
|
||||
yarn test:app # Frontend tests only
|
||||
yarn test:backend # Backend tests only
|
||||
|
||||
# Build
|
||||
yarn build # Build Electron mode
|
||||
yarn build:server # Build browser mode
|
||||
|
||||
# UI Tests (Electron only)
|
||||
yarn ui-test # Run UI tests with video recording
|
||||
```
|
||||
|
||||
## Adding New Tests
|
||||
|
||||
### For Electron Mode
|
||||
|
||||
Add tests to the `test` job. UI tests should be added to the test suite that `yarn ui-test` runs.
|
||||
|
||||
### For Browser Mode
|
||||
|
||||
Browser-specific tests should:
|
||||
1. Use the pre-configured Mosquitto service
|
||||
2. Connect to `mqtt://mosquitto:1883`
|
||||
3. Test server endpoints at `http://localhost:3000`
|
||||
|
||||
Example:
|
||||
```yaml
|
||||
- name: Browser Integration Test
|
||||
run: |
|
||||
# Test MQTT connection through server
|
||||
curl -X POST http://localhost:3000/api/test
|
||||
```
|
||||
|
||||
## Local Testing
|
||||
|
||||
### Docker Browser Mode
|
||||
|
||||
```bash
|
||||
# Build the image locally (for your platform)
|
||||
docker build -f Dockerfile.browser -t mqtt-explorer:local .
|
||||
|
||||
# Build for specific platform (e.g., Raspberry Pi)
|
||||
docker buildx build --platform linux/arm64 -f Dockerfile.browser -t mqtt-explorer:local-arm64 .
|
||||
|
||||
# Run the container
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e MQTT_EXPLORER_USERNAME=test \
|
||||
-e MQTT_EXPLORER_PASSWORD=test123 \
|
||||
mqtt-explorer:local
|
||||
|
||||
# Test the server
|
||||
curl http://localhost:3000
|
||||
|
||||
# Check logs
|
||||
docker logs <container-id>
|
||||
|
||||
# Stop and remove
|
||||
docker stop <container-id>
|
||||
docker rm <container-id>
|
||||
```
|
||||
|
||||
See [DOCKER.md](DOCKER.md) for complete documentation.
|
||||
|
||||
### Electron Mode
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
yarn test
|
||||
yarn ui-test
|
||||
```
|
||||
|
||||
### Browser Mode
|
||||
|
||||
```bash
|
||||
# Start Mosquitto in Docker
|
||||
docker run -d -p 1883:1883 eclipse-mosquitto:2
|
||||
|
||||
# Build and test
|
||||
yarn build:server
|
||||
yarn test
|
||||
|
||||
# Start server
|
||||
MQTT_EXPLORER_USERNAME=test MQTT_EXPLORER_PASSWORD=test123 yarn start:server
|
||||
|
||||
# Run manual tests
|
||||
curl http://localhost:3000
|
||||
```
|
||||
|
||||
## GitHub Codespaces / Devcontainer
|
||||
|
||||
The repository includes a devcontainer configuration that automatically sets up:
|
||||
- Node.js 20
|
||||
- MQTT broker (Mosquitto)
|
||||
- All development dependencies
|
||||
- Port forwarding for development
|
||||
|
||||
See [.devcontainer/README.md](.devcontainer/README.md) for details.
|
||||
|
||||
## S3 Configuration for Demo Videos
|
||||
|
||||
### Required S3 Lifecycle Policy
|
||||
|
||||
Demo videos uploaded from PRs are tagged with `expiration=90days` and require an S3 lifecycle policy to automatically delete them after 90 days.
|
||||
|
||||
**Important**: The `video.mp4` file in the gh-pages branch is NOT tagged and will NOT expire.
|
||||
|
||||
#### Setting up the Lifecycle Policy
|
||||
|
||||
1. Create a file named `s3-lifecycle-pr-videos.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"Rules": [
|
||||
{
|
||||
"ID": "ExpirePRDemoVideosAfter90Days",
|
||||
"Status": "Enabled",
|
||||
"Filter": {
|
||||
"Tag": {
|
||||
"Key": "expiration",
|
||||
"Value": "90days"
|
||||
}
|
||||
},
|
||||
"Expiration": {
|
||||
"Days": 90
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
2. Apply the policy to your S3 bucket:
|
||||
|
||||
```bash
|
||||
aws s3api put-bucket-lifecycle-configuration \
|
||||
--bucket YOUR_BUCKET_NAME \
|
||||
--lifecycle-configuration file://s3-lifecycle-pr-videos.json
|
||||
```
|
||||
|
||||
3. Verify the policy:
|
||||
|
||||
```bash
|
||||
aws s3api get-bucket-lifecycle-configuration --bucket YOUR_BUCKET_NAME
|
||||
```
|
||||
|
||||
#### How It Works
|
||||
|
||||
- **PR demo videos**: Uploaded with filename pattern `pr-{number}-{timestamp}.gif` and tagged with:
|
||||
- `expiration=90days` - Used by lifecycle policy for automatic deletion
|
||||
- `Source=github-actions` - Identifies source of upload
|
||||
- `Type=pr-demo-video` - Categorizes the object type
|
||||
- **S3 lifecycle rule**: Automatically deletes objects tagged with `expiration=90days` after 90 days
|
||||
- **Upload mechanism**: AWS CLI v2 is installed directly, authentication is configured via `aws-actions/configure-aws-credentials@v4` GitHub Action, then `aws s3api put-object` is used with object tagging support
|
||||
- **gh-pages video**: `video.mp4` in gh-pages branch is served from GitHub Pages, not S3, so it persists indefinitely
|
||||
|
||||
#### Required AWS Credentials
|
||||
|
||||
The workflow requires the following secrets/variables:
|
||||
- `vars.AWS_KEY_ID` - AWS access key ID (requires `s3:PutObject` and `s3:PutObjectTagging` permissions)
|
||||
- `secrets.AWS_SECRET_ACCESS_KEY` - AWS secret access key
|
||||
- `vars.AWS_BUCKET` - S3 bucket name
|
||||
- AWS region: `eu-central-1` (hardcoded in workflow)
|
||||
|
||||
The S3 bucket must have:
|
||||
- **Bucket policy for public read access**: Since ACLs are disabled (BucketOwnerEnforced), a bucket policy must grant public read access to uploaded objects
|
||||
- Object tagging enabled
|
||||
- Lifecycle policy configured as described above
|
||||
|
||||
**Example S3 Bucket Policy for Public Read Access**:
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "PublicReadGetObject",
|
||||
"Effect": "Allow",
|
||||
"Principal": "*",
|
||||
"Action": "s3:GetObject",
|
||||
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The workflow uses AWS CLI v2 installed directly and `aws-actions/configure-aws-credentials@v4` action for secure credential management.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Browser Tests Failing
|
||||
|
||||
1. **Server won't start**: Check if port 3000 is already in use
|
||||
2. **MQTT connection fails**: Ensure Mosquitto service is healthy
|
||||
3. **Timeout errors**: Increase timeout in "Wait for Server" step
|
||||
|
||||
### Electron Tests Failing
|
||||
|
||||
1. **UI tests timeout**: Check if the Docker container has display access
|
||||
2. **Build fails**: Verify all dependencies are in yarn.lock
|
||||
|
||||
## Future Improvements
|
||||
|
||||
- [x] Add Playwright browser installation to workflows (browser tests can now use Playwright)
|
||||
- [ ] Add E2E browser tests with Playwright
|
||||
- [ ] Test WebSocket connections in browser mode
|
||||
- [ ] Add performance benchmarks
|
||||
- [ ] Test with different MQTT broker versions
|
||||
- [ ] Add security scanning for browser mode
|
||||
@@ -0,0 +1,12 @@
|
||||
# 0.2.3
|
||||
|
||||
- Highlight differences in the last received message with a "diff" view
|
||||
- Magnify app content with "Ctrl +", "Ctrl -", "Ctrl 0"
|
||||
- Make user interactions more predictable by removing "select topic on mouse over"
|
||||
- Add "Quick Preview" setting, to enable topic selection on mouse over
|
||||
- Add JSON formatter
|
||||
- Show error when connection to the mqtt broker is lost
|
||||
- Fix bug where mqtt explorer resets the tree after a reconnect
|
||||
- Fix MQTT-Client id
|
||||
|
||||
# 0.2.0
|
||||
@@ -0,0 +1,250 @@
|
||||
# MQTT Explorer - Docker Browser Mode
|
||||
|
||||
Docker image for running MQTT Explorer in browser mode.
|
||||
|
||||
## Try It Now
|
||||
|
||||
[](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/thomasnordquist/MQTT-Explorer/master/docker-compose.yml)
|
||||
|
||||
Click the badge above to instantly try MQTT Explorer in your browser using Play with Docker (requires free Docker Hub account).
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Using Pre-built Image
|
||||
|
||||
Pull and run the latest image from GitHub Container Registry:
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/thomasnordquist/mqtt-explorer:latest
|
||||
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e MQTT_EXPLORER_USERNAME=admin \
|
||||
-e MQTT_EXPLORER_PASSWORD=your_secure_password \
|
||||
-v mqtt-explorer-data:/app/data \
|
||||
--name mqtt-explorer \
|
||||
ghcr.io/thomasnordquist/mqtt-explorer:latest
|
||||
```
|
||||
|
||||
Access the application at `http://localhost:3000`
|
||||
|
||||
### Using Docker Compose
|
||||
|
||||
Create a `docker-compose.yml` file:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
mqtt-explorer:
|
||||
image: ghcr.io/thomasnordquist/mqtt-explorer:latest
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- MQTT_EXPLORER_USERNAME=admin
|
||||
- MQTT_EXPLORER_PASSWORD=your_secure_password
|
||||
- PORT=3000
|
||||
volumes:
|
||||
- mqtt-explorer-data:/app/data
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
mqtt-explorer-data:
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Required | Default | Description |
|
||||
|----------|----------|---------|-------------|
|
||||
| `MQTT_EXPLORER_USERNAME` | No | Generated | Username for authentication |
|
||||
| `MQTT_EXPLORER_PASSWORD` | No | Generated | Password for authentication |
|
||||
| `MQTT_EXPLORER_SKIP_AUTH` | No | `false` | Set to `true` to disable authentication (use only behind a secure proxy!) |
|
||||
| `PORT` | No | `3000` | Port the server listens on |
|
||||
| `ALLOWED_ORIGINS` | No | `*` | Comma-separated list of allowed CORS origins |
|
||||
| `NODE_ENV` | No | - | Set to `production` for production deployments |
|
||||
|
||||
### Authentication Modes
|
||||
|
||||
**Standard Mode (Default):**
|
||||
- Requires username and password for access
|
||||
- Credentials can be set via environment variables or auto-generated
|
||||
- Auto-generated credentials are logged on first startup and saved to `/app/data/credentials.json`
|
||||
|
||||
**Skip Authentication Mode (Use with caution!):**
|
||||
```bash
|
||||
docker run -d -p 3000:3000 \
|
||||
-e MQTT_EXPLORER_SKIP_AUTH=true \
|
||||
ghcr.io/thomasnordquist/mqtt-explorer:latest
|
||||
```
|
||||
|
||||
⚠️ **WARNING**: When `MQTT_EXPLORER_SKIP_AUTH=true`, the application is **completely open** without any authentication. This should **only be used** when MQTT Explorer is deployed behind a secure authentication proxy (e.g., OAuth2 Proxy, Authelia, Nginx with auth_request) or in a trusted private network.
|
||||
|
||||
**Recommended use case**: Integration with enterprise SSO systems where authentication is handled by a reverse proxy.
|
||||
|
||||
**Note**: If credentials are not provided and auth is not skipped, they will be auto-generated and stored in `/app/data/credentials.json`. Check the container logs to see the generated credentials:
|
||||
|
||||
```bash
|
||||
docker logs mqtt-explorer
|
||||
```
|
||||
|
||||
## Data Persistence
|
||||
|
||||
The container stores data in `/app/data`, including:
|
||||
- User credentials (`credentials.json`)
|
||||
- Connection settings (`settings.json`)
|
||||
- Uploaded certificates (`certificates/`)
|
||||
- File uploads (`uploads/`)
|
||||
|
||||
Mount a volume to persist data across container restarts:
|
||||
|
||||
```bash
|
||||
docker run -v mqtt-explorer-data:/app/data ...
|
||||
```
|
||||
|
||||
## Building from Source
|
||||
|
||||
Build the Docker image locally:
|
||||
|
||||
```bash
|
||||
docker build -f Dockerfile.browser -t mqtt-explorer:local .
|
||||
```
|
||||
|
||||
Run the locally built image:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e MQTT_EXPLORER_USERNAME=admin \
|
||||
-e MQTT_EXPLORER_PASSWORD=secret \
|
||||
mqtt-explorer:local
|
||||
```
|
||||
|
||||
## Health Check
|
||||
|
||||
The container includes a health check that runs every 30 seconds. Check the health status:
|
||||
|
||||
```bash
|
||||
docker inspect --format='{{.State.Health.Status}}' mqtt-explorer
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
1. **Use HTTPS in Production**: Put the container behind a reverse proxy (nginx, Traefik) with HTTPS
|
||||
2. **Set Strong Credentials**: Always set custom credentials via environment variables
|
||||
3. **Network Isolation**: Run in a private network when possible
|
||||
4. **Update Regularly**: Pull the latest image regularly for security updates
|
||||
|
||||
### Example with Nginx Reverse Proxy
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name mqtt-explorer.example.com;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Container won't start
|
||||
|
||||
Check the logs:
|
||||
```bash
|
||||
docker logs mqtt-explorer
|
||||
```
|
||||
|
||||
### Can't access the application
|
||||
|
||||
1. Verify the container is running: `docker ps`
|
||||
2. Check the port mapping: `docker port mqtt-explorer`
|
||||
3. Test connectivity: `curl http://localhost:3000`
|
||||
|
||||
### Authentication issues
|
||||
|
||||
1. Check generated credentials in logs: `docker logs mqtt-explorer`
|
||||
2. Verify environment variables: `docker inspect mqtt-explorer`
|
||||
3. Reset credentials by removing the data volume and restarting
|
||||
|
||||
### Permission issues
|
||||
|
||||
The container runs as a non-root user (UID 1001). If mounting host directories, ensure they're writable:
|
||||
|
||||
```bash
|
||||
chown -R 1001:1001 /path/to/host/data
|
||||
docker run -v /path/to/host/data:/app/data ...
|
||||
```
|
||||
|
||||
## Available Tags
|
||||
|
||||
- `latest` - Latest stable version from the master branch
|
||||
- `master` - Latest build from master branch
|
||||
- `beta` - Latest beta version
|
||||
- `release` - Latest release version
|
||||
- `master-<sha>` - Specific commit from master
|
||||
- `beta-<sha>` - Specific commit from beta
|
||||
- `release-<sha>` - Specific commit from release
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
The Docker image is built for multiple architectures:
|
||||
- `linux/amd64` - x86-64 (standard PCs, servers)
|
||||
- `linux/arm64` - ARM 64-bit (Raspberry Pi 3/4/5, Apple Silicon)
|
||||
- `linux/arm/v7` - ARM 32-bit (Raspberry Pi 2/3)
|
||||
|
||||
## One-Click Deployment Options
|
||||
|
||||
### Play with Docker (Free)
|
||||
|
||||
Try MQTT Explorer instantly in your browser without installing anything:
|
||||
|
||||
[](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/thomasnordquist/MQTT-Explorer/master/docker-compose.yml)
|
||||
|
||||
- **No installation required** - Runs entirely in your browser
|
||||
- **Free to use** - Requires only a Docker Hub account
|
||||
- **Perfect for demos** - Great for testing and demonstrations
|
||||
- **4-hour sessions** - Sessions automatically expire after 4 hours
|
||||
|
||||
### Cloud Platforms
|
||||
|
||||
Deploy MQTT Explorer to various cloud platforms with one click:
|
||||
|
||||
#### DigitalOcean App Platform
|
||||
|
||||
[](https://cloud.digitalocean.com/apps/new?repo=https://github.com/thomasnordquist/MQTT-Explorer/tree/master&refcode=docker)
|
||||
|
||||
- Automatically detects Docker configuration
|
||||
- Managed platform with auto-scaling
|
||||
- Starting at $5/month
|
||||
|
||||
#### Koyeb
|
||||
|
||||
[](https://app.koyeb.com/deploy?type=docker&name=mqtt-explorer&image=ghcr.io/thomasnordquist/mqtt-explorer:latest&ports=3000;http;/)
|
||||
|
||||
- Deploy directly from Docker image
|
||||
- Global edge network
|
||||
- Free tier available
|
||||
|
||||
**Note:** Remember to set the environment variables `MQTT_EXPLORER_USERNAME` and `MQTT_EXPLORER_PASSWORD` when deploying to cloud platforms.
|
||||
|
||||
## License
|
||||
|
||||
See the main [LICENSE.md](LICENSE.md) file.
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
FROM node:24
|
||||
|
||||
RUN DEBIAN_FRONTEND="noninteractive" apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates nano ffmpeg xvfb git-core tmux locales mosquitto x11vnc
|
||||
RUN apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3
|
||||
|
||||
# Generate locales for TMUX
|
||||
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US:en
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
|
||||
# Configure mosquitto for anonymous access (required for tests)
|
||||
RUN mkdir -p /etc/mosquitto/conf.d && \
|
||||
echo "listener 1883" > /etc/mosquitto/conf.d/default.conf && \
|
||||
echo "allow_anonymous true" >> /etc/mosquitto/conf.d/default.conf && \
|
||||
echo "persistence false" >> /etc/mosquitto/conf.d/default.conf
|
||||
|
||||
# Install Playwright and browsers
|
||||
# This ensures Playwright browsers are pre-installed in the container
|
||||
RUN npm install -g playwright@1.57.0 && \
|
||||
npx playwright install --with-deps chromium
|
||||
|
||||
CMD /bin/bash
|
||||
|
||||
VOLUME /app
|
||||
EXPOSE 5900
|
||||
@@ -0,0 +1,69 @@
|
||||
# Multi-stage build for MQTT Explorer Browser Mode
|
||||
# Stage 1: Build and prepare production dependencies
|
||||
FROM node:24-alpine AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Copy all source files and dependencies
|
||||
COPY package.json yarn.lock ./
|
||||
COPY tsconfig.json ./
|
||||
COPY src ./src
|
||||
COPY backend ./backend
|
||||
COPY events ./events
|
||||
COPY app ./app
|
||||
|
||||
# Install ALL dependencies (needed for build)
|
||||
RUN yarn install --frozen-lockfile --network-timeout 100000
|
||||
|
||||
# Build the application (compiles TypeScript and webpack bundles)
|
||||
RUN yarn build:server
|
||||
|
||||
# Remove dev dependencies, keeping only production dependencies
|
||||
RUN yarn install --production --frozen-lockfile --network-timeout 100000 && \
|
||||
yarn cache clean && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
# Stage 2: Production
|
||||
FROM node:24-alpine
|
||||
|
||||
# Install dumb-init in a single layer
|
||||
RUN apk add --no-cache dumb-init
|
||||
|
||||
# Create app user in a single layer
|
||||
RUN addgroup -g 1001 -S mqttexplorer && \
|
||||
adduser -u 1001 -S mqttexplorer -G mqttexplorer
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy ONLY the compiled dist folder (contains compiled TypeScript)
|
||||
COPY --from=builder --chown=mqttexplorer:mqttexplorer /build/dist ./dist
|
||||
|
||||
# Copy ONLY the built frontend app
|
||||
COPY --from=builder --chown=mqttexplorer:mqttexplorer /build/app/build ./app/build
|
||||
COPY --from=builder --chown=mqttexplorer:mqttexplorer /build/app/index.html ./app/
|
||||
|
||||
# Copy runtime node_modules (production dependencies only)
|
||||
COPY --from=builder --chown=mqttexplorer:mqttexplorer /build/node_modules ./node_modules
|
||||
|
||||
# Copy package.json for version info (needed by server)
|
||||
COPY --from=builder --chown=mqttexplorer:mqttexplorer /build/package.json ./
|
||||
|
||||
# Create data directory for persistent storage
|
||||
RUN mkdir -p /app/data && \
|
||||
chown -R mqttexplorer:mqttexplorer /app/data
|
||||
|
||||
# Switch to non-root user
|
||||
USER mqttexplorer
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD node -e "const http = require('http'); const req = http.get('http://localhost:3000', (r) => process.exit(r.statusCode === 200 ? 0 : 1)); req.on('error', () => process.exit(1));"
|
||||
|
||||
# Use dumb-init to handle signals properly
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||
|
||||
# Start the server
|
||||
CMD ["node", "dist/src/server.js"]
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
When distributing, the attribution and donation page may not be altered or made less accessible without explicit approval.
|
||||
|
||||
# Creative Commons Attribution-ShareAlike 4.0 International
|
||||
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
|
||||
**Using Creative Commons Public Licenses**
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
|
||||
* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
|
||||
|
||||
* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
|
||||
|
||||
## Creative Commons Attribution-ShareAlike 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
### Section 1 – Definitions.
|
||||
|
||||
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
|
||||
b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. __BY-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
|
||||
e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
|
||||
f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
|
||||
g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
|
||||
|
||||
h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
|
||||
i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
|
||||
k. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
|
||||
l. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
|
||||
m. __You__ means the individual or entity exercising the Licensed Rights under this Public License. __Your__ has a corresponding meaning.
|
||||
|
||||
### Section 2 – Scope.
|
||||
|
||||
a. ___License grant.___
|
||||
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
A. reproduce and Share the Licensed Material, in whole or in part; and
|
||||
|
||||
B. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
|
||||
3. __Term.__ The term of this Public License is specified in Section 6(a).
|
||||
|
||||
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
|
||||
5. __Downstream recipients.__
|
||||
|
||||
A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
|
||||
B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
||||
|
||||
C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
|
||||
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. ___Other rights.___
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
|
||||
|
||||
### Section 3 – License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
a. ___Attribution.___
|
||||
|
||||
1. If You Share the Licensed Material (including in modified form), You must:
|
||||
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
|
||||
b. ___ShareAlike.___
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
||||
|
||||
### Section 4 – Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
### Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
|
||||
|
||||
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
### Section 6 – Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
### Section 7 – Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
### Section 8 – Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
>
|
||||
> Creative Commons may be contacted at creativecommons.org.
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
# macOS Notarization Setup
|
||||
|
||||
This document explains how to set up notarization for macOS builds of MQTT Explorer.
|
||||
|
||||
## Overview
|
||||
|
||||
macOS notarization is a security feature required by Apple for all software distributed outside the Mac App Store. Starting with macOS 10.15 (Catalina), all software must be notarized to run without warnings on macOS.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. An active Apple Developer account
|
||||
2. Xcode command line tools installed on the build machine
|
||||
3. An app-specific password for notarization
|
||||
|
||||
## Setup Steps
|
||||
|
||||
### 1. Create an App-Specific Password
|
||||
|
||||
1. Sign in to [appleid.apple.com](https://appleid.apple.com)
|
||||
2. Navigate to "Sign-In and Security" section
|
||||
3. Under "App-Specific Passwords", click "Generate an app-specific password"
|
||||
4. Enter a descriptive name (e.g., "MQTT Explorer Notarization")
|
||||
5. Copy the generated password (you won't be able to see it again)
|
||||
|
||||
### 2. Find Your Team ID
|
||||
|
||||
1. Sign in to [developer.apple.com](https://developer.apple.com/account)
|
||||
2. Navigate to "Membership Details"
|
||||
3. Copy your Team ID (a 10-character alphanumeric string)
|
||||
|
||||
### 3. Configure GitHub Secrets
|
||||
|
||||
Add the following secrets to your GitHub repository:
|
||||
|
||||
- `APPLE_ID`: Your Apple ID email address (e.g., `your.email@example.com`)
|
||||
- `APPLE_APP_SPECIFIC_PASSWORD`: The app-specific password created in step 1
|
||||
- `APPLE_TEAM_ID`: Your Team ID from step 2
|
||||
|
||||
To add secrets:
|
||||
1. Go to your repository on GitHub
|
||||
2. Navigate to Settings → Secrets and variables → Actions
|
||||
3. Click "New repository secret" for each of the above
|
||||
|
||||
## How It Works
|
||||
|
||||
### Build Configuration
|
||||
|
||||
The notarization process is configured in `package.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"build": {
|
||||
"mac": {
|
||||
"hardenedRuntime": true,
|
||||
"gatekeeperAssess": false,
|
||||
"entitlements": "res/entitlements.mac.plist",
|
||||
"entitlementsInherit": "res/entitlements.mac.inherit.plist"
|
||||
},
|
||||
"afterSign": "./dist/scripts/notarize.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Notarization Script
|
||||
|
||||
The `scripts/notarize.ts` script handles the notarization process:
|
||||
|
||||
1. Checks if the build is for macOS
|
||||
2. Verifies that required environment variables are set
|
||||
3. Submits the app to Apple's notarization service
|
||||
4. Waits for notarization to complete
|
||||
5. Staples the notarization ticket to the app
|
||||
|
||||
### Entitlements
|
||||
|
||||
Different entitlements are used for different build types:
|
||||
|
||||
- **DMG builds** (regular distribution):
|
||||
- `res/entitlements.mac.plist` - Main entitlements
|
||||
- `res/entitlements.mac.inherit.plist` - Inherited entitlements for child processes
|
||||
|
||||
- **MAS builds** (Mac App Store):
|
||||
- `res/entitlements.mas.plist` - App Store specific entitlements
|
||||
|
||||
### CI/CD Integration
|
||||
|
||||
The GitHub Actions workflow (`platform-builds.yml`) automatically:
|
||||
|
||||
1. Builds the macOS app when code is pushed to `release` or `beta` branches
|
||||
2. Signs the app with the developer certificate
|
||||
3. Notarizes the app using the configured secrets
|
||||
4. Publishes the notarized app to GitHub releases
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Notarization Fails
|
||||
|
||||
If notarization fails, check:
|
||||
|
||||
1. **Credentials**: Ensure all three secrets are correctly set in GitHub
|
||||
2. **App-specific password**: Verify it hasn't expired or been revoked
|
||||
3. **Team ID**: Confirm it matches your developer account
|
||||
4. **Entitlements**: Ensure the entitlements files are valid and appropriate for your app
|
||||
|
||||
### Checking Notarization Status
|
||||
|
||||
You can check the notarization status of a built app:
|
||||
|
||||
```bash
|
||||
# Check if an app is notarized
|
||||
spctl -a -vv /path/to/MQTT\ Explorer.app
|
||||
|
||||
# Check notarization history
|
||||
xcrun notarytool history --apple-id your.email@example.com --team-id YOUR_TEAM_ID
|
||||
```
|
||||
|
||||
### Local Testing
|
||||
|
||||
To test notarization locally:
|
||||
|
||||
```bash
|
||||
# Set environment variables
|
||||
export APPLE_ID="your.email@example.com"
|
||||
export APPLE_APP_SPECIFIC_PASSWORD="your-app-specific-password"
|
||||
export APPLE_TEAM_ID="YOUR_TEAM_ID"
|
||||
|
||||
# Build and notarize
|
||||
yarn build
|
||||
yarn package mac
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- Never commit Apple credentials to the repository
|
||||
- Use app-specific passwords, not your main Apple ID password
|
||||
- Rotate app-specific passwords periodically
|
||||
- Limit access to GitHub secrets to trusted maintainers only
|
||||
|
||||
## References
|
||||
|
||||
- [Apple Notarization Documentation](https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution)
|
||||
- [electron-builder Code Signing](https://www.electron.build/code-signing)
|
||||
- [@electron/notarize](https://github.com/electron/notarize)
|
||||
@@ -1,41 +1,231 @@
|
||||
# MQTT-Explorer
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer/releases)
|
||||
# [MQTT Explorer](https://mqtt-explorer.com)
|
||||
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer/releases)
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer/releases)
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer)
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer)
|
||||
[](https://ci.appveyor.com/project/thomasnordquist/mqtt-explorer/branch/master)
|
||||
[](https://app.codacy.com/app/thomasnordquist/MQTT-Explorer?utm_source=github.com&utm_medium=referral&utm_content=thomasnordquist/MQTT-Explorer&utm_campaign=Badge_Grade_Dashboard)
|
||||
|
||||
### Version 0.1.0
|
||||
See the whole picture of your message queue.
|
||||
The perfect tool to integrate new services, IoT devices in your network.
|
||||
This application subscribes to all topics on your MQTT-Server and displays your message queue hierarchy, allowing you to drill-down to the topics that are of interest.
|
||||
| | | |
|
||||
| :---------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------: |
|
||||
| [](https://mqtt-explorer.com/img/screen-composite.png) | [](https://mqtt-explorer.com/img/screen2.png) | [](https://mqtt-explorer.com/img/screen3.png) |
|
||||
|
||||
## Download
|
||||
The app is prebuilt for Windows ([portable](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-0.1.0.exe), [installer](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-Setup-0.1.0.exe)), Linux ([AppImage](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-0.1.0-x86_64.AppImage)) and Mac ([dmg](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-0.1.0.dmg)).
|
||||
# The App has moved to [mqtt-explorer.com](https://mqtt-explorer.com)
|
||||
|
||||
<center>
|
||||
MQTT Explorer is a comprehensive and easy-to-use MQTT Client.
|
||||
Downloads can be found at the link above.
|
||||
|
||||
| | | |
|
||||
|:----------|:-------------:|:------:|
|
||||
|  | Windows | [portable](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-0.1.0.exe), [installer](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-Setup-0.1.0.exe) |
|
||||
|  | Linux | [AppImage](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-0.1.0-x86_64.AppImage)<br>*Run AppImage:<br>Make it executable and double-click it.* |
|
||||
|  | Mac | [dmg](https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v0.1.0/MQTT-Explorer-0.1.0.dmg) |
|
||||
This page is dedicated to its development.
|
||||
Pull-Requests and error reports are welcome.
|
||||
|
||||
</center>
|
||||
## Quick Start with GitHub Codespaces
|
||||
|
||||
More architectures and package types: [Downloads](https://github.com/thomasnordquist/MQTT-Explorer/releases)
|
||||
The fastest way to start developing is with GitHub Codespaces:
|
||||
|
||||

|
||||
1. Click the green "Code" button above
|
||||
2. Select "Codespaces" tab
|
||||
3. Click "Create codespace on [branch]"
|
||||
4. Wait for the environment to set up (includes Node.js and MQTT broker)
|
||||
5. Run `yarn dev:server` to start development
|
||||
|
||||

|
||||
The devcontainer includes a pre-configured MQTT broker and all development tools. See [.devcontainer/README.md](.devcontainer/README.md) for details.
|
||||
|
||||
## Run from sources
|
||||
|
||||
### Desktop Application (Electron)
|
||||
|
||||
```bash
|
||||
npm install -g yarn
|
||||
yarn
|
||||
yarn build
|
||||
yarn start
|
||||
```
|
||||
|
||||
### Browser Mode (Web Application)
|
||||
|
||||
MQTT Explorer can also run as a web application served by a Node.js server:
|
||||
|
||||
```bash
|
||||
npm install -g yarn
|
||||
yarn
|
||||
yarn build:server
|
||||
yarn start:server
|
||||
```
|
||||
|
||||
Then open your browser to `http://localhost:3000`. For more details, see [BROWSER_MODE.md](BROWSER_MODE.md).
|
||||
|
||||
### Docker (Browser Mode)
|
||||
|
||||
[](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/thomasnordquist/MQTT-Explorer/master/docker-compose.yml)
|
||||
|
||||
Run MQTT Explorer in a Docker container:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e MQTT_EXPLORER_USERNAME=admin \
|
||||
-e MQTT_EXPLORER_PASSWORD=your_secure_password \
|
||||
-v mqtt-explorer-data:/app/data \
|
||||
ghcr.io/thomasnordquist/mqtt-explorer:latest
|
||||
```
|
||||
|
||||
**Supports multiple platforms**: amd64, arm64 (Raspberry Pi 3/4/5), arm/v7 (Raspberry Pi 2/3).
|
||||
|
||||
**Enterprise integration**: Set `MQTT_EXPLORER_SKIP_AUTH=true` to disable built-in authentication when deploying behind a secure authentication proxy (e.g., OAuth2 Proxy, SSO).
|
||||
|
||||
For complete Docker documentation including authentication options, deployment examples, and security best practices, see [DOCKER.md](DOCKER.md).
|
||||
|
||||
## Develop
|
||||
PRs and issues are welcome
|
||||
|
||||
Install with `npm run install`, build with `npm run build`
|
||||
### Desktop Application
|
||||
|
||||
Start with `npm run start`
|
||||
Launch Application
|
||||
|
||||
The `app` directory contains all the rendering logic, the `backend` directory currently contains the models, tests, connection management.
|
||||
```bash
|
||||
npm install -g yarn
|
||||
yarn
|
||||
yarn dev
|
||||
```
|
||||
|
||||
### Browser Mode
|
||||
|
||||
Launch in development mode with hot reload:
|
||||
|
||||
```bash
|
||||
npm install -g yarn
|
||||
yarn
|
||||
yarn dev:server
|
||||
```
|
||||
|
||||
The `app` directory contains all the rendering logic, the `backend` directory currently contains the models, tests, connection management, `src` contains all the electron bindings. [mqttjs](https://github.com/mqttjs/MQTT.js) is used to facilitate communication to MQTT brokers.
|
||||
|
||||
## Automated Tests
|
||||
|
||||
MQTT Explorer uses multiple test suites to ensure reliability and quality:
|
||||
|
||||
### Unit Tests
|
||||
|
||||
**App tests** - Frontend component and logic tests:
|
||||
```bash
|
||||
yarn test:app
|
||||
```
|
||||
|
||||
**Backend tests** - Data model and business logic tests:
|
||||
```bash
|
||||
yarn test:backend
|
||||
```
|
||||
|
||||
**Run all unit tests**:
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
### Integration & UI Tests
|
||||
|
||||
**UI test suite** - Independent, deterministic browser tests:
|
||||
```bash
|
||||
yarn build
|
||||
yarn test:ui
|
||||
```
|
||||
|
||||
**Demo video generation** - UI test recording for documentation:
|
||||
```bash
|
||||
yarn build
|
||||
yarn test:demo-video
|
||||
```
|
||||
Note: Requires Xvfb, mosquitto broker, tmux, and ffmpeg. For full video recording setup, use `./scripts/uiTests.sh`.
|
||||
|
||||
**MCP introspection tests** - Model Context Protocol validation:
|
||||
```bash
|
||||
yarn build
|
||||
yarn test:mcp
|
||||
```
|
||||
|
||||
**Run all tests** (unit tests + demo video):
|
||||
```bash
|
||||
yarn build
|
||||
yarn test:all
|
||||
```
|
||||
|
||||
### Run UI Test Suite
|
||||
|
||||
The UI test suite validates core functionality through automated browser tests. Each test is independent and deterministic.
|
||||
|
||||
```bash
|
||||
# Run with automated setup (recommended)
|
||||
./scripts/runUiTests.sh
|
||||
|
||||
# Or run directly (requires manual MQTT broker setup)
|
||||
yarn build
|
||||
yarn test:ui
|
||||
```
|
||||
|
||||
See [docs/UI-TEST-SUITE.md](docs/UI-TEST-SUITE.md) for more details.
|
||||
|
||||
### Run Demo Video Generation
|
||||
|
||||
The demo video is used for documentation and showcases key features. It requires additional dependencies:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
yarn test:demo-video
|
||||
```
|
||||
|
||||
**Requirements:**
|
||||
- mosquitto MQTT broker
|
||||
- Xvfb (virtual framebuffer)
|
||||
- tmux (terminal multiplexer)
|
||||
- ffmpeg (video encoding)
|
||||
|
||||
**For full video recording with post-processing:**
|
||||
```bash
|
||||
yarn build
|
||||
./scripts/uiTests.sh
|
||||
```
|
||||
|
||||
This script handles Xvfb setup, mosquitto startup, video recording, and cleanup.
|
||||
|
||||
## Create a release
|
||||
|
||||
Create a PR to `release` branch.
|
||||
There needs to be a "feat: some new feature" or "fix: some bugfix" commit for a new release to be created
|
||||
|
||||
### macOS Notarization
|
||||
|
||||
macOS builds are automatically notarized during the release process. To set up notarization credentials, see [NOTARIZATION.md](NOTARIZATION.md).
|
||||
|
||||
## Create a beta release
|
||||
|
||||
Create a PR to `beta` branch. A "feat" or "fix" commit is necessary to create a new version.
|
||||
|
||||
## Write docs
|
||||
|
||||
```
|
||||
git clone --single-branch -b gh-pages https://github.com/thomasnordquist/MQTT-Explorer.git mqtt-explorer-pages
|
||||
cd mqtt-explorer-pages
|
||||
bundle install
|
||||
bundle exec jekyll serve --incremental
|
||||
```
|
||||
|
||||
Readme file: `Readme.tpl.md`
|
||||
|
||||
Preview is available at
|
||||
http://localhost:4000/Readme.tpl
|
||||
|
||||
## Update docs
|
||||
|
||||
```
|
||||
npm install
|
||||
./updateReadme.ts
|
||||
```
|
||||
|
||||
The readme will be generated from the docs.
|
||||
|
||||
## License
|
||||
Not yet decided which license exactly, but the basic idea is: "You may do whatever you want with this tool, except sell it."
|
||||
|
||||

|
||||
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
|
||||
|
||||
**Special requirement:** When distributing, the attribution and donation page may not be altered or made less accessible without explicit approval.
|
||||
|
||||
The license allows for anyone to adapt, share, and redistribute the material, as long as they give appropriate credit and distribute any derivative works under the same license.
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# MQTT-Explorer
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer/releases)
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer/releases)
|
||||
[](https://travis-ci.org/thomasnordquist/MQTT-Explorer)
|
||||
|
||||
### Version {{ version }}
|
||||
See the whole picture of your message queue.
|
||||
The perfect tool to integrate new services, IoT devices in your network.
|
||||
This application subscribes to all topics on your MQTT-Server and displays your message queue hierarchy, allowing you to drill-down to the topics that are of interest.
|
||||
|
||||
## Download
|
||||
The app is prebuilt for Windows ({{windowsTargets}}), Linux ({{linuxTargets}}) and Mac ({{macTargets}}).
|
||||
|
||||
<center>
|
||||
|
||||
| | | |
|
||||
|:----------|:-------------:|:------:|
|
||||
|  | Windows | {{windowsTargets}} |
|
||||
|  | Linux | {{linuxTargets}}<br>*Run AppImage:<br>Make it executable and double-click it.* |
|
||||
|  | Mac | {{macTargets}} |
|
||||
|
||||
</center>
|
||||
|
||||
More architectures and package types: [Downloads](https://github.com/thomasnordquist/MQTT-Explorer/releases)
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
## Develop
|
||||
PRs and issues are welcome
|
||||
|
||||
Install with `npm run install`, build with `npm run build`
|
||||
|
||||
Start with `npm run start`
|
||||
|
||||
The `app` directory contains all the rendering logic, the `backend` directory currently contains the models, tests, connection management.
|
||||
|
||||
## License
|
||||
Not yet decided which license exactly, but the basic idea is: "You may do whatever you want with this tool, except sell it."
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Security updates are provided for the latest release of MQTT Explorer.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.4.x | :white_check_mark: |
|
||||
| < 0.4 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
We take security vulnerabilities seriously. If you discover a security issue, please follow these steps:
|
||||
|
||||
### How to Report
|
||||
|
||||
1. **DO NOT** create a public GitHub issue for security vulnerabilities
|
||||
2. Report via one of these channels:
|
||||
- GitHub Security Advisories (preferred): https://github.com/thomasnordquist/MQTT-Explorer/security/advisories/new
|
||||
- Email the maintainer directly
|
||||
3. Include the following information:
|
||||
- Description of the vulnerability
|
||||
- Steps to reproduce
|
||||
- Potential impact
|
||||
- Any suggested fixes (optional)
|
||||
|
||||
### What to Expect
|
||||
|
||||
- **Acknowledgment**: We will acknowledge receipt of your report within 48 hours
|
||||
- **Updates**: We will provide updates on the status of your report within 7 days
|
||||
- **Fix Timeline**: We aim to release security fixes within 30 days for critical issues
|
||||
- **Credit**: With your permission, we will credit you in the security advisory and release notes
|
||||
|
||||
## Security Features
|
||||
|
||||
### Browser Mode Security
|
||||
|
||||
MQTT Explorer's browser mode includes several security features:
|
||||
|
||||
#### Authentication
|
||||
- **bcrypt Password Hashing**: All passwords are hashed with bcrypt (10 rounds)
|
||||
- **Constant-Time Comparison**: Username comparison uses crypto.timingSafeEqual() to prevent timing attacks
|
||||
- **Environment Variable Configuration**: Credentials can be set via environment variables for production
|
||||
- **Automatic Credential Generation**: Secure random credentials generated if not provided
|
||||
|
||||
#### Rate Limiting
|
||||
- **Authentication Rate Limiting**: Maximum 5 failed authentication attempts per IP per 15 minutes
|
||||
- **Per-IP Tracking**: Failed attempts tracked separately for each client IP
|
||||
- **Automatic Reset**: Rate limit counters automatically reset after 15 minutes
|
||||
|
||||
#### HTTP Security Headers (helmet.js)
|
||||
- **Content Security Policy (CSP)**: Restricts resource loading to prevent XSS attacks
|
||||
- **HTTP Strict Transport Security (HSTS)**: Enforces HTTPS in production
|
||||
- **X-Content-Type-Options**: Prevents MIME type sniffing
|
||||
- **X-Frame-Options**: Prevents clickjacking attacks
|
||||
- **X-XSS-Protection**: Enables browser XSS protection
|
||||
|
||||
#### Input Validation
|
||||
- **File Size Limits**: Maximum 16MB for file uploads
|
||||
- **Path Traversal Protection**: All file paths validated and sanitized
|
||||
- **Filename Sanitization**: Removes path separators, null bytes, and validates against traversal patterns
|
||||
- **Real Path Validation**: Ensures resolved paths stay within allowed directories
|
||||
- **Base64 Validation**: All file data properly validated before processing
|
||||
|
||||
#### CORS Configuration
|
||||
- **Configurable Origins**: CORS origins configurable via ALLOWED_ORIGINS environment variable
|
||||
- **Production Restrictions**: Wildcard CORS automatically disabled in production
|
||||
- **Credential Support**: CORS configured with credentials: true for authenticated requests
|
||||
|
||||
#### Error Handling
|
||||
- **Generic Error Messages**: Detailed errors only shown in development mode
|
||||
- **No Information Leakage**: Error messages sanitized to prevent information disclosure
|
||||
- **Secure Logging**: Sensitive information not logged in production
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
### For Server Deployment
|
||||
|
||||
1. **Always Use HTTPS in Production**
|
||||
- Use a reverse proxy (nginx, Apache) with TLS certificates
|
||||
- Never expose the Node.js server directly to the internet
|
||||
- Use Let's Encrypt for free TLS certificates
|
||||
|
||||
2. **Set Strong Credentials**
|
||||
```bash
|
||||
export MQTT_EXPLORER_USERNAME=your_secure_username
|
||||
export MQTT_EXPLORER_PASSWORD=your_strong_password_min_12_chars
|
||||
export NODE_ENV=production
|
||||
```
|
||||
|
||||
3. **Configure CORS Properly**
|
||||
```bash
|
||||
# Single origin
|
||||
export ALLOWED_ORIGINS=https://mqtt-explorer.example.com
|
||||
|
||||
# Multiple origins
|
||||
export ALLOWED_ORIGINS=https://app1.example.com,https://app2.example.com
|
||||
```
|
||||
|
||||
4. **Network Security**
|
||||
- Deploy behind a firewall or VPN
|
||||
- Use IP whitelisting when possible
|
||||
- Implement network-level rate limiting
|
||||
- Monitor access logs regularly
|
||||
|
||||
5. **Keep Dependencies Updated**
|
||||
```bash
|
||||
yarn audit
|
||||
yarn upgrade-interactive
|
||||
```
|
||||
|
||||
6. **Regular Security Audits**
|
||||
- Run security tests: `yarn test:security`
|
||||
- Review access logs for suspicious activity
|
||||
- Monitor authentication failures
|
||||
- Check for outdated dependencies
|
||||
|
||||
### For MQTT Connections
|
||||
|
||||
1. **Use TLS/SSL**: Always connect to MQTT brokers using TLS encryption
|
||||
2. **Strong Credentials**: Use unique, strong passwords for MQTT authentication
|
||||
3. **Certificate Validation**: Verify broker certificates in production
|
||||
4. **Least Privilege**: Connect with minimal required permissions
|
||||
|
||||
## Security Testing
|
||||
|
||||
The project includes comprehensive security tests:
|
||||
|
||||
```bash
|
||||
# Run all tests including security tests
|
||||
yarn test
|
||||
|
||||
# Run only security tests
|
||||
npx mocha --require source-map-support/register dist/src/spec/security-tests.spec.js
|
||||
```
|
||||
|
||||
Security tests cover:
|
||||
- Path traversal attack prevention
|
||||
- Input validation and sanitization
|
||||
- Authentication security
|
||||
- CORS configuration
|
||||
- Rate limiting
|
||||
- Error handling
|
||||
- Data sanitization
|
||||
|
||||
## Security Audit History
|
||||
|
||||
### December 2024 - Initial Security Review
|
||||
- Added helmet.js for HTTP security headers
|
||||
- Implemented rate limiting for authentication
|
||||
- Added path traversal protection with sanitization
|
||||
- Implemented constant-time comparison for credentials
|
||||
- Added input validation and size limits
|
||||
- Removed credential logging in production
|
||||
- Added configurable CORS origins
|
||||
- Created comprehensive security test suite (19 tests)
|
||||
- Enhanced documentation with security best practices
|
||||
|
||||
## Known Limitations
|
||||
|
||||
### Browser Mode
|
||||
- File system access limited to server-side directories
|
||||
- No native OS dialogs (uses browser file input)
|
||||
- Session management is stateless (no persistent sessions)
|
||||
|
||||
### Desktop Mode (Electron)
|
||||
- Inherits security model from Electron framework
|
||||
- IPC communication between renderer and main process
|
||||
- No network exposure by default
|
||||
|
||||
## Recommended Security Tools
|
||||
|
||||
- **Dependency Scanning**: Dependabot, Snyk, or npm audit
|
||||
- **SAST**: SonarQube, ESLint security plugins
|
||||
- **Container Scanning**: If using Docker deployment
|
||||
- **TLS Testing**: SSL Labs, testssl.sh
|
||||
- **Penetration Testing**: OWASP ZAP, Burp Suite
|
||||
|
||||
## References
|
||||
|
||||
- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
|
||||
- [Node.js Security Best Practices](https://nodejs.org/en/docs/guides/security/)
|
||||
- [Express Security Best Practices](https://expressjs.com/en/advanced/best-practice-security.html)
|
||||
- [helmet.js Documentation](https://helmetjs.github.io/)
|
||||
- [MQTT Security](https://mqtt.org/mqtt-specification/)
|
||||
|
||||
## Contact
|
||||
|
||||
For security-related questions or concerns:
|
||||
- GitHub Security Advisories: https://github.com/thomasnordquist/MQTT-Explorer/security/advisories
|
||||
- Project Issues (for non-sensitive topics): https://github.com/thomasnordquist/MQTT-Explorer/issues
|
||||
|
||||
Thank you for helping keep MQTT Explorer secure!
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
# React Component Testing Guide
|
||||
|
||||
This guide explains how to write tests for React components in the MQTT-Explorer project using the generic testing utilities.
|
||||
|
||||
## Overview
|
||||
|
||||
We use the following testing stack:
|
||||
- **Mocha** - Test framework
|
||||
- **Chai** - Assertion library
|
||||
- **React Testing Library** - React component testing utilities
|
||||
- **JSDOM** - DOM implementation for Node.js
|
||||
- **Custom Test Utilities** - Located in `src/utils/spec/testUtils.tsx`
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Create a Test File
|
||||
|
||||
Test files should be placed next to the component they test with the `.spec.tsx` extension:
|
||||
|
||||
```
|
||||
src/components/MyComponent/
|
||||
├── MyComponent.tsx
|
||||
└── MyComponent.spec.tsx
|
||||
```
|
||||
|
||||
### 2. Basic Test Structure
|
||||
|
||||
```typescript
|
||||
import React from 'react'
|
||||
import { expect } from 'chai'
|
||||
import { describe, it } from 'mocha'
|
||||
import MyComponent from './MyComponent'
|
||||
import { renderWithProviders } from '../../utils/spec/testUtils'
|
||||
|
||||
describe('MyComponent', () => {
|
||||
it('should render correctly', () => {
|
||||
const { container } = renderWithProviders(<MyComponent />)
|
||||
expect(container).to.exist
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Using Test Utilities
|
||||
|
||||
### `renderWithProviders`
|
||||
|
||||
This function wraps your component with necessary providers (Theme, Redux).
|
||||
|
||||
```typescript
|
||||
import { renderWithProviders } from '../../utils/spec/testUtils'
|
||||
|
||||
// Render with theme only (default)
|
||||
const { container } = renderWithProviders(<MyComponent />, { withTheme: true })
|
||||
|
||||
// Render with both theme and Redux
|
||||
const { container } = renderWithProviders(<MyComponent />, {
|
||||
withTheme: true,
|
||||
withRedux: true
|
||||
})
|
||||
|
||||
// Render with custom theme
|
||||
import { createTheme } from '@mui/material/styles'
|
||||
const darkTheme = createTheme({ palette: { mode: 'dark' } })
|
||||
const { container } = renderWithProviders(<MyComponent />, {
|
||||
theme: darkTheme
|
||||
})
|
||||
|
||||
// Render with custom Redux store
|
||||
import { configureStore } from '@reduxjs/toolkit'
|
||||
const customStore = configureStore({ /* ... */ })
|
||||
const { container } = renderWithProviders(<MyComponent />, {
|
||||
store: customStore,
|
||||
withRedux: true
|
||||
})
|
||||
```
|
||||
|
||||
### `createMockChartData`
|
||||
|
||||
Helper function to generate mock chart data:
|
||||
|
||||
```typescript
|
||||
import { createMockChartData } from '../../utils/spec/testUtils'
|
||||
|
||||
// Create 10 data points (default)
|
||||
const data = createMockChartData()
|
||||
|
||||
// Create specific number of points
|
||||
const data = createMockChartData(50)
|
||||
```
|
||||
|
||||
### Global Mocks
|
||||
|
||||
The test utilities automatically set up global mocks:
|
||||
- **ResizeObserver** - Mocked for components using `react-resize-detector`
|
||||
|
||||
## Common Testing Patterns
|
||||
|
||||
### Testing Rendering
|
||||
|
||||
```typescript
|
||||
it('should render without crashing', () => {
|
||||
const { container } = renderWithProviders(<MyComponent />)
|
||||
expect(container).to.exist
|
||||
})
|
||||
|
||||
it('should render specific element', () => {
|
||||
const { container } = renderWithProviders(<MyComponent />)
|
||||
const element = container.querySelector('.my-class')
|
||||
expect(element).to.exist
|
||||
})
|
||||
```
|
||||
|
||||
### Testing Props
|
||||
|
||||
```typescript
|
||||
it('should accept all valid props', () => {
|
||||
const props = {
|
||||
title: 'Test',
|
||||
value: 123,
|
||||
onchange: () => {},
|
||||
}
|
||||
const { container } = renderWithProviders(<MyComponent {...props} />)
|
||||
expect(container).to.exist
|
||||
})
|
||||
```
|
||||
|
||||
### Testing User Interactions
|
||||
|
||||
```typescript
|
||||
import { userEvent } from '../../utils/spec/testUtils'
|
||||
|
||||
it('should handle click events', async () => {
|
||||
const { container } = renderWithProviders(<MyComponent />)
|
||||
const button = container.querySelector('button')
|
||||
|
||||
if (button) {
|
||||
await userEvent.click(button)
|
||||
// Assert expected behavior
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Testing Different States
|
||||
|
||||
```typescript
|
||||
it('should render empty state', () => {
|
||||
const { container } = renderWithProviders(<MyComponent data={[]} />)
|
||||
// Assert empty state
|
||||
})
|
||||
|
||||
it('should render with data', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<MyComponent data={data} />)
|
||||
// Assert data is rendered
|
||||
})
|
||||
```
|
||||
|
||||
### Testing SVG Components
|
||||
|
||||
```typescript
|
||||
it('should render SVG elements', () => {
|
||||
const { container } = renderWithProviders(<ChartComponent />)
|
||||
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
|
||||
const paths = container.querySelectorAll('path')
|
||||
expect(paths.length).to.be.greaterThan(0)
|
||||
|
||||
const circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.equal(5)
|
||||
})
|
||||
```
|
||||
|
||||
### Testing Edge Cases
|
||||
|
||||
```typescript
|
||||
describe('Edge Cases', () => {
|
||||
it('should handle negative values', () => {
|
||||
const data = [{ x: 1, y: -10 }, { x: 2, y: -20 }]
|
||||
const { container } = renderWithProviders(<MyComponent data={data} />)
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should handle empty arrays', () => {
|
||||
const { container } = renderWithProviders(<MyComponent data={[]} />)
|
||||
expect(container).to.exist
|
||||
})
|
||||
|
||||
it('should handle very large numbers', () => {
|
||||
const data = [{ x: 1, y: 1000000 }]
|
||||
const { container } = renderWithProviders(<MyComponent data={data} />)
|
||||
expect(container).to.exist
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Run all tests
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
### Run specific test file
|
||||
```bash
|
||||
npx mocha --require tsx --require source-map-support/register "src/components/MyComponent/MyComponent.spec.tsx"
|
||||
```
|
||||
|
||||
### Run tests in watch mode
|
||||
```bash
|
||||
npx mocha --require tsx --require source-map-support/register --watch "src/**/*.spec.{ts,tsx}"
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Test Behavior, Not Implementation**
|
||||
- Focus on what the component does, not how it does it
|
||||
- Test user-facing behavior and output
|
||||
|
||||
2. **Use Descriptive Test Names**
|
||||
```typescript
|
||||
// Good
|
||||
it('should render error message when validation fails')
|
||||
|
||||
// Bad
|
||||
it('test1')
|
||||
```
|
||||
|
||||
3. **Group Related Tests**
|
||||
```typescript
|
||||
describe('MyComponent', () => {
|
||||
describe('Rendering', () => {
|
||||
it('should render correctly')
|
||||
it('should render with props')
|
||||
})
|
||||
|
||||
describe('Interactions', () => {
|
||||
it('should handle clicks')
|
||||
it('should handle keyboard input')
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
4. **Keep Tests Independent**
|
||||
- Each test should be able to run in isolation
|
||||
- Don't rely on test execution order
|
||||
- Clean up after each test if needed
|
||||
|
||||
5. **Test Edge Cases**
|
||||
- Empty data
|
||||
- Null/undefined values
|
||||
- Very large/small numbers
|
||||
- Negative values
|
||||
- Single item arrays
|
||||
|
||||
6. **Use Chai Assertions**
|
||||
```typescript
|
||||
expect(value).to.exist
|
||||
expect(value).to.be.true
|
||||
expect(value).to.equal(expected)
|
||||
expect(array).to.have.length(5)
|
||||
expect(number).to.be.greaterThan(0)
|
||||
```
|
||||
|
||||
## Example: Complete Test Suite
|
||||
|
||||
See `src/components/Chart/Chart.spec.tsx` for a comprehensive example that demonstrates:
|
||||
- Multiple test groups (Rendering, Data Visualization, Edge Cases, etc.)
|
||||
- Testing with different props and configurations
|
||||
- Testing SVG elements
|
||||
- Testing theme integration
|
||||
- Performance testing
|
||||
- Edge case coverage
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "ResizeObserver is not defined"
|
||||
This is automatically mocked by the test utilities. Make sure you're importing from `testUtils.tsx`.
|
||||
|
||||
### "Cannot find module"
|
||||
Check your import paths. Remember to use relative paths from the test file.
|
||||
|
||||
### "Window is not defined"
|
||||
Make sure `jsdom-global/register` is imported in testUtils.tsx.
|
||||
|
||||
### Tests timing out
|
||||
Increase the timeout in your test:
|
||||
```typescript
|
||||
it('should complete async operation', function() {
|
||||
this.timeout(5000) // 5 seconds
|
||||
// test code
|
||||
})
|
||||
```
|
||||
|
||||
## Adding New Test Utilities
|
||||
|
||||
To add new helper functions, update `src/utils/spec/testUtils.tsx`:
|
||||
|
||||
```typescript
|
||||
export function myNewHelper() {
|
||||
// Helper implementation
|
||||
}
|
||||
```
|
||||
|
||||
Then use it in your tests:
|
||||
```typescript
|
||||
import { myNewHelper } from '../../utils/spec/testUtils'
|
||||
```
|
||||
+182
-119
@@ -1,134 +1,197 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>MQTT-Explorer</title>
|
||||
<script src="./build/bugtracking.bundle.js"></script>
|
||||
|
||||
<style>
|
||||
body, html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
|
||||
<title>MQTT Explorer</title>
|
||||
<script src="./bugtracking.bundle.js"></script>
|
||||
|
||||
@keyframes example {
|
||||
0% {background-color: none;}
|
||||
25% {background-color: #3f51b5;}
|
||||
50% {background-color: #3f51b5;}
|
||||
100% {background-color: none;}
|
||||
}
|
||||
<style>
|
||||
body,
|
||||
html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
[tabindex] {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
}
|
||||
@keyframes updateDark {
|
||||
0% {
|
||||
background-color: none;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
-webkit-box-shadow: inset 0 0 6px rgba(30,30,30,0.3);
|
||||
}
|
||||
25% {
|
||||
background-color: #595585;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(140,140,140,0.8);
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
#splash {
|
||||
z-index: 1000000;
|
||||
background-color: #303030;
|
||||
display: block;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
opacity: 1;
|
||||
}
|
||||
#splash1 {
|
||||
margin: 37vh auto 0 auto;
|
||||
height: 25vh;
|
||||
width: 25vh;
|
||||
/* background-image:url('../rings.svg'); */
|
||||
background-size: cover;
|
||||
}
|
||||
#splash2 {
|
||||
margin: 0 auto;
|
||||
}
|
||||
@keyframes unsplash {
|
||||
0% {opacity: 1;}
|
||||
100% {opacity: 0;}
|
||||
}
|
||||
50% {
|
||||
background-color: #595585;
|
||||
}
|
||||
|
||||
.Resizer {
|
||||
background: #eee;
|
||||
opacity: .2;
|
||||
z-index: 1;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
-moz-background-clip: padding;
|
||||
-webkit-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
100% {
|
||||
background-color: none;
|
||||
}
|
||||
}
|
||||
|
||||
.Resizer:hover {
|
||||
-webkit-transition: all 0.3s ease-out;
|
||||
transition: all 0.3s ease-out;
|
||||
}
|
||||
@keyframes updateLight {
|
||||
0% {
|
||||
background-color: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.Resizer.horizontal {
|
||||
height: 11px;
|
||||
margin: -5px 0;
|
||||
border-top: 5px solid rgba(255, 255, 255, 0);
|
||||
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: row-resize;
|
||||
width: 100%;
|
||||
}
|
||||
25% {
|
||||
background-color: #c0c8c0;
|
||||
}
|
||||
|
||||
.Resizer.horizontal:hover {
|
||||
border-top: 5px solid rgba(0, 0, 0, 0.5);
|
||||
border-bottom: 5px solid rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
50% {
|
||||
background-color: #c0c8c0;
|
||||
}
|
||||
|
||||
.Resizer.vertical {
|
||||
width: 11px;
|
||||
margin: 0 -5px;
|
||||
border-left: 5px solid rgba(255, 255, 255, 0);
|
||||
border-right: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: col-resize;
|
||||
}
|
||||
100% {
|
||||
background-color: none;
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.Resizer.vertical:hover {
|
||||
border-left: 5px solid rgba(255, 255, 255, 0.5);
|
||||
border-right: 5px solid rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
.Resizer.disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.Resizer.disabled:hover {
|
||||
border-color: transparent;
|
||||
}
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="http://localhost:35729/livereload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="splash"><div id="splash1"></div></div>
|
||||
<div id="app" style="font:-webkit-control"></div>
|
||||
<script>
|
||||
function loadScript(path) {
|
||||
var script = document.createElement("script");
|
||||
script.src = path
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', onLoad(), false);
|
||||
function onLoad() {
|
||||
// <% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>loadScript("<%- file %>");<% }); %>
|
||||
// loadScript("<%= JSON.stringify(htmlWebpackPlugin) %>")
|
||||
}
|
||||
</script>
|
||||
<% _.forEach(htmlWebpackPlugin.files.js, function(file) { %><script src="<%- file %>"></script><% }); %>
|
||||
</body>
|
||||
</html>
|
||||
::-webkit-scrollbar-corner {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
-webkit-box-shadow: inset 0 0 6px rgba(60, 60, 60, 0.5);
|
||||
background-color: rgba(140, 140, 140, 0.1);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(140, 140, 140, 0.8);
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.Resizer {
|
||||
background: rgba(200, 200, 200, 0);
|
||||
z-index: 10;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
-moz-background-clip: padding;
|
||||
-webkit-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
.Resizer:hover {
|
||||
-webkit-transition: all 0.3s ease-out;
|
||||
transition: all 0.3s ease-out;
|
||||
}
|
||||
|
||||
.Resizer.horizontal {
|
||||
height: 10px;
|
||||
margin: -10px 0 0 0;
|
||||
border-top: 5px solid rgba(255, 255, 255, 0);
|
||||
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: row-resize;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.Resizer.horizontal::before {
|
||||
content: '•••';
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
margin-top: -22px;
|
||||
color: #aaa;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.Resizer.horizontal:hover {
|
||||
border-top: 5px solid rgba(120, 120, 120, 0.3);
|
||||
border-bottom: 5px solid rgba(120, 120, 120, 0.3);
|
||||
}
|
||||
|
||||
.Resizer.vertical {
|
||||
width: 2px;
|
||||
margin: 0px -8px 0px 0px;
|
||||
border-left: 0px solid rgba(128, 128, 128, 0);
|
||||
border-right: 8px solid rgba(128, 128, 128, 0);
|
||||
cursor: col-resize;
|
||||
}
|
||||
|
||||
.Resizer.vertical::before {
|
||||
content: '•••';
|
||||
margin-left: -11px;
|
||||
height: 3em;
|
||||
margin-top: calc(50vh - 32px);
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
color: #aaa;
|
||||
opacity: 1;
|
||||
writing-mode: vertical-lr;
|
||||
text-orientation: sideways;
|
||||
}
|
||||
|
||||
.Resizer.vertical:hover {
|
||||
border-left: 0px solid rgba(130, 130, 130, 0.3);
|
||||
border-right: 8px solid rgba(140, 140, 140, 0.3);
|
||||
}
|
||||
|
||||
.Resizer.disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.Resizer.disabled:hover {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.example-enter {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.example-enter-active {
|
||||
opacity: 1;
|
||||
transition: opacity 300ms ease-in;
|
||||
}
|
||||
|
||||
.example-exit {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.example-exit-active {
|
||||
opacity: 0;
|
||||
transition: opacity 300ms ease-in;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
global = globalThis //<- this should be enough
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app" style="font: -webkit-control;"></div>
|
||||
<script>
|
||||
function loadScript(path) {
|
||||
var script = document.createElement('script')
|
||||
script.src = path
|
||||
document.head.appendChild(script)
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', onLoad(), false)
|
||||
function onLoad() {
|
||||
// <% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>loadScript("<%- file %>");<% }); %>
|
||||
// loadScript("<%= JSON.stringify(htmlWebpackPlugin) %>")
|
||||
}
|
||||
</script>
|
||||
<% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>
|
||||
<script src="<%- file %>"></script>
|
||||
<% }); %>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Generated
-8424
File diff suppressed because it is too large
Load Diff
+96
-43
@@ -4,54 +4,107 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "webpack --mode production"
|
||||
"build": "webpack --mode production",
|
||||
"dev": "node_modules/.bin/webpack-dev-server --mode development --progress",
|
||||
"test": "mocha --require tsx --require source-map-support/register --recursive 'src/*/**/*.spec.{ts,tsx}'",
|
||||
"mochatest": "mocha --require tsx --require source-map-support/register --recursive 'src/*/**/*.spec.{ts,tsx}'"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@material-ui/icons": "^3.0.1",
|
||||
"@types/react": "^16.7.18",
|
||||
"@types/react-dom": "^16.0.11",
|
||||
"@types/react-redux": "^6.0.12",
|
||||
"css-loader": "^2.1.0",
|
||||
"electron-nucleus": "^1.11.0",
|
||||
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git",
|
||||
"html-webpack-plugin": "^4.0.0-beta.5",
|
||||
"number-abbreviate": "^2.0.0",
|
||||
"react": "^16.8.0-alpha.1",
|
||||
"react-dom": "^16.7.0",
|
||||
"react-redux": "^6.0.0",
|
||||
"react-vis": "^1.11.6",
|
||||
"redux": "^4.0.1",
|
||||
"style-loader": "^0.23.1",
|
||||
"webpack-bundle-analyzer": "^3.0.3",
|
||||
"webpack-livereload-plugin": "^2.2.0"
|
||||
},
|
||||
"license": "CC-BY-SA-4.0",
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^3.9.0",
|
||||
"@material-ui/styles": "^3.0.0-alpha.8",
|
||||
"@types/node": "^10.12.18",
|
||||
"@types/react-resize-detector": "^3.1.0",
|
||||
"@types/react-split-pane": "^0.1.67",
|
||||
"@types/sha1": "^1.1.1",
|
||||
"@types/socket.io-client": "^1.4.32",
|
||||
"@types/vis": "^4.21.9",
|
||||
"awesome-typescript-loader": "^5.2.1",
|
||||
"copy-text-to-clipboard": "^1.0.4",
|
||||
"jquery": "^3.3.1",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@mui/icons-material": "^7.3.6",
|
||||
"@mui/lab": "^7.0.1-beta.20",
|
||||
"@mui/material": "^7.3.6",
|
||||
"@mui/styles": "^6.4.8",
|
||||
"@react-spring/web": "^9.7.5",
|
||||
"@types/react-transition-group": "^4.4.11",
|
||||
"@visx/axis": "^3.10.1",
|
||||
"@visx/grid": "^3.5.0",
|
||||
"@visx/tooltip": "^3.3.0",
|
||||
"@visx/xychart": "^3.10.2",
|
||||
"ace-builds": "^1.4.11",
|
||||
"axios": "^1.13.2",
|
||||
"compare-versions": "^6.1.1",
|
||||
"copy-text-to-clipboard": "^3.2.0",
|
||||
"d3": "^7.9.0",
|
||||
"d3-shape": "^3.2.0",
|
||||
"diff": "^7.0.0",
|
||||
"dot-prop": "^5.3.0",
|
||||
"events": "^3.3.0",
|
||||
"get-value": "^3.0.1",
|
||||
"immutable": "^4.3.7",
|
||||
"in-viewport": "^3.6.0",
|
||||
"js-base64": "^3.7.8",
|
||||
"json-to-ast": "^2.1.0",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"lodash.throttle": "^4.1.1",
|
||||
"moving-average": "^1.0.0",
|
||||
"react-ace": "^6.3.2",
|
||||
"react-json-view": "^1.19.1",
|
||||
"react-resize-detector": "^3.4.0",
|
||||
"react-split-pane": "^0.1.85",
|
||||
"redux-batched-actions": "^0.4.1",
|
||||
"number-abbreviate": "^2.0.0",
|
||||
"os-browserify": "^0.3.0",
|
||||
"parse-duration": "^0.1.1",
|
||||
"path-browserify": "^1.0.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"react": "^19.2.3",
|
||||
"react-ace": "^14.0.1",
|
||||
"react-dom": "^19.2.3",
|
||||
"react-redux": "^9.2.0",
|
||||
"react-resize-detector": "^11.0.1",
|
||||
"react-split-pane": "^0.1.92",
|
||||
"react-transition-group": "^4.4.5",
|
||||
"redux": "^5.0.1",
|
||||
"redux-batched-actions": "^0.5.0",
|
||||
"redux-thunk": "^3.1.0",
|
||||
"sha1": "^1.1.1",
|
||||
"socket.io-client": "^2.2.0",
|
||||
"source-map-loader": "^0.2.4",
|
||||
"typescript": "^3.2.2",
|
||||
"webpack": "^4.28.2",
|
||||
"webpack-cli": "^3.1.2",
|
||||
"webpack-dev-server": "^3.1.14"
|
||||
"socket.io-client": "^4.8.1",
|
||||
"url": "^0.11.4",
|
||||
"uuid": "^11.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/runtime": "^7.28.4",
|
||||
"@reduxjs/toolkit": "2.5.0",
|
||||
"@testing-library/dom": "10.4.0",
|
||||
"@testing-library/react": "16.1.0",
|
||||
"@testing-library/user-event": "14.5.2",
|
||||
"@types/d3": "^7.4.3",
|
||||
"@types/diff": "^7.0.0",
|
||||
"@types/get-value": "^3.0.5",
|
||||
"@types/lodash.debounce": "^4.0.9",
|
||||
"@types/node": "^25.0.3",
|
||||
"@types/prismjs": "^1.26.5",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/react-redux": "^7.1.34",
|
||||
"@types/react-resize-detector": "^4.0.3",
|
||||
"@types/sha1": "^1.1.1",
|
||||
"@types/socket.io-client": "^3.0.0",
|
||||
"@types/uuid": "^11.0.0",
|
||||
"@types/vis": "^4.21.24",
|
||||
"chai": "^4.5.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^7.1.2",
|
||||
"file-loader": "^6.2.0",
|
||||
"html-webpack-plugin": "^5.6.3",
|
||||
"jsdom": "25.0.1",
|
||||
"jsdom-global": "3.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"mocha": "^10.8.2",
|
||||
"moment": "^2.30.1",
|
||||
"node-loader": "^2.0.0",
|
||||
"source-map-loader": "^5.0.0",
|
||||
"style-loader": "^4.0.0",
|
||||
"ts-loader": "^9.5.1",
|
||||
"typescript": "^5.9.3",
|
||||
"webpack": "^5.98.0",
|
||||
"webpack-bundle-analyzer": "^4.10.2",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"webpack-dev-server": "^5.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"electron": "^39"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
|
||||
<svg width="45" height="45" viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#fff">
|
||||
<g fill="none" fill-rule="evenodd" transform="translate(1 1)" stroke-width="2">
|
||||
<circle cx="22" cy="22" r="6" stroke-opacity="0">
|
||||
<animate attributeName="r"
|
||||
begin="1.5s" dur="3s"
|
||||
values="6;22"
|
||||
calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-opacity"
|
||||
begin="1.5s" dur="3s"
|
||||
values="1;0" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-width"
|
||||
begin="1.5s" dur="3s"
|
||||
values="2;0" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle cx="22" cy="22" r="6" stroke-opacity="0">
|
||||
<animate attributeName="r"
|
||||
begin="3s" dur="3s"
|
||||
values="6;22"
|
||||
calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-opacity"
|
||||
begin="3s" dur="3s"
|
||||
values="1;0" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-width"
|
||||
begin="3s" dur="3s"
|
||||
values="2;0" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle cx="22" cy="22" r="8">
|
||||
<animate attributeName="r"
|
||||
begin="0s" dur="1.5s"
|
||||
values="6;1;2;3;4;5;6"
|
||||
calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.7 KiB |
-123
@@ -1,123 +0,0 @@
|
||||
import * as React from 'react'
|
||||
import * as q from '../../backend/src/Model'
|
||||
|
||||
import { Theme, withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import { AppState } from './reducers'
|
||||
import Connection from './components/ConnectionSetup/Connection'
|
||||
import CssBaseline from '@material-ui/core/CssBaseline'
|
||||
const Settings = React.lazy(() => import('./components/Settings'))
|
||||
import Sidebar from './components/Sidebar/Sidebar'
|
||||
import TitleBar from './components/TitleBar'
|
||||
import Tree from './components/Tree/Tree'
|
||||
import UpdateNotifier from './UpdateNotifier'
|
||||
import { connect } from 'react-redux'
|
||||
import ErrorBoundary from './ErrorBoundary'
|
||||
import { default as SplitPane } from 'react-split-pane'
|
||||
|
||||
interface Props {
|
||||
name: string
|
||||
connectionId: string
|
||||
classes: any
|
||||
settingsVisible: boolean
|
||||
}
|
||||
|
||||
class App extends React.PureComponent<Props, {}> {
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = { }
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { settingsVisible } = this.props
|
||||
const { content, contentShift, centerContent, paneDefaults, heightProperty } = this.props.classes
|
||||
|
||||
return (
|
||||
<div className={centerContent}>
|
||||
<CssBaseline />
|
||||
<ErrorBoundary>
|
||||
<React.Suspense fallback={<div>Loading...</div>}>
|
||||
<Settings />
|
||||
</React.Suspense>
|
||||
<div className={centerContent}>
|
||||
<div className={`${settingsVisible ? contentShift : content}`}>
|
||||
<TitleBar />
|
||||
</div>
|
||||
<div>
|
||||
<SplitPane
|
||||
step={48}
|
||||
primary="second"
|
||||
className={`${settingsVisible ? contentShift : content} ${heightProperty}`}
|
||||
split="vertical"
|
||||
minSize={250}
|
||||
defaultSize={500}
|
||||
allowResize={true}
|
||||
pane1Style={{ overflow: 'hidden' }}
|
||||
>
|
||||
<div className={paneDefaults}>
|
||||
<Tree />
|
||||
</div>
|
||||
<div className={paneDefaults}>
|
||||
<Sidebar connectionId={this.props.connectionId} />
|
||||
</div>
|
||||
</SplitPane>
|
||||
</div>
|
||||
</div>
|
||||
<UpdateNotifier />
|
||||
<Connection />
|
||||
</ErrorBoundary>
|
||||
</div >
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
settingsVisible: state.settings.visible,
|
||||
connectionId: state.connection.connectionId,
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => {
|
||||
const drawerWidth = 300
|
||||
return {
|
||||
heightProperty: {
|
||||
height: 'calc(100vh - 64px) !important',
|
||||
},
|
||||
paneDefaults: {
|
||||
backgroundColor: theme.palette.background.default,
|
||||
color: theme.palette.text.primary,
|
||||
overflowY: 'scroll' as 'scroll',
|
||||
overflowX: 'hidden' as 'hidden',
|
||||
display: 'block' as 'block',
|
||||
height: 'calc(100vh - 64px)',
|
||||
},
|
||||
centerContent: {
|
||||
width: '100vw',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
},
|
||||
content: {
|
||||
width: '100vw',
|
||||
overflowX: 'hidden',
|
||||
backgroundColor: theme.palette.background.default,
|
||||
transition: theme.transitions.create('transform', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
transform: 'translateX(0px)',
|
||||
},
|
||||
contentShift: {
|
||||
overflowX: 'hidden',
|
||||
width: '100vw',
|
||||
padding: 0,
|
||||
backgroundColor: theme.palette.background.default,
|
||||
transition: theme.transitions.create('transform', {
|
||||
easing: theme.transitions.easing.easeOut,
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
transform: `translateX(${drawerWidth}px)`,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(connect(mapStateToProps)(App))
|
||||
@@ -1,19 +0,0 @@
|
||||
import { EventDispatcher } from '../../events'
|
||||
|
||||
export class TopicViewModel {
|
||||
private selected: boolean
|
||||
public change = new EventDispatcher<void, TopicViewModel>(this)
|
||||
|
||||
public constructor() {
|
||||
this.selected = false
|
||||
}
|
||||
|
||||
public isSelected() {
|
||||
return this.selected
|
||||
}
|
||||
|
||||
public setSelected(selected: boolean) {
|
||||
this.selected = selected
|
||||
this.change.dispatch()
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
import * as React from 'react'
|
||||
|
||||
import {
|
||||
Button,
|
||||
IconButton,
|
||||
Modal,
|
||||
Paper,
|
||||
Snackbar,
|
||||
SnackbarContent,
|
||||
Typography,
|
||||
} from '@material-ui/core'
|
||||
import { Theme, withStyles } from '@material-ui/core/styles'
|
||||
import { UpdateInfo, checkForUpdates, rendererEvents, updateAvailable } from '../../events'
|
||||
import { green, red } from '@material-ui/core/colors'
|
||||
|
||||
import { AppState } from './reducers'
|
||||
import Close from '@material-ui/icons/Close'
|
||||
import CloudDownload from '@material-ui/icons/CloudDownload'
|
||||
import { UpdateFileInfo } from 'builder-util-runtime'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connect } from 'react-redux'
|
||||
import { updateNotifierActions } from './actions'
|
||||
|
||||
interface Props {
|
||||
showUpdateNotification: boolean
|
||||
showUpdateDetails: boolean
|
||||
classes: any
|
||||
actions: any
|
||||
}
|
||||
|
||||
class UpdateNotifier extends React.Component<Props, {}> {
|
||||
private updateInfo?: UpdateInfo
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = {
|
||||
selectedNode: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
rendererEvents.emit(checkForUpdates, undefined)
|
||||
rendererEvents.subscribe(updateAvailable, this.handleUpdate)
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
rendererEvents.unsubscribeAll(updateAvailable)
|
||||
}
|
||||
|
||||
private fixUrl(url: string, version: string) {
|
||||
if (!/^http/.test(url)) {
|
||||
return `https://github.com/thomasnordquist/MQTT-Explorer/releases/download/v${version}/${url}`
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
private handleUpdate = (updateInfo: UpdateInfo) => {
|
||||
this.updateInfo = updateInfo
|
||||
this.props.actions.showUpdateNotification(true)
|
||||
}
|
||||
|
||||
private onCloseNotification = (event: React.SyntheticEvent<any>, reason: string) => {
|
||||
if (reason === 'clickaway') {
|
||||
return
|
||||
}
|
||||
this.props.actions.showUpdateNotification(false)
|
||||
}
|
||||
|
||||
private closeNotification = () => {
|
||||
this.props.actions.showUpdateNotification(false)
|
||||
}
|
||||
|
||||
private showDetails = () => {
|
||||
this.props.actions.showUpdateNotification(false)
|
||||
this.props.actions.showUpdateDetails(true)
|
||||
}
|
||||
|
||||
private hideDetails = () => {
|
||||
this.props.actions.showUpdateDetails(false)
|
||||
}
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
{this.renderUpdateNotification()}
|
||||
{this.renderUpdateDetails()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private renderUpdateNotification() {
|
||||
const snackbarAnchor: any = {
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
}
|
||||
|
||||
return (
|
||||
<Snackbar
|
||||
anchorOrigin={snackbarAnchor}
|
||||
open={this.props.showUpdateNotification}
|
||||
autoHideDuration={7000}
|
||||
onClose={this.onCloseNotification}
|
||||
>
|
||||
<SnackbarContent
|
||||
className={this.props.classes.success}
|
||||
message="Update available"
|
||||
action={this.notificationActions()}
|
||||
/>
|
||||
</Snackbar>
|
||||
)
|
||||
}
|
||||
|
||||
private notificationActions() {
|
||||
return [(
|
||||
<Button key="undo" size="small" onClick={this.showDetails}>
|
||||
Download
|
||||
</Button>
|
||||
), (
|
||||
<IconButton
|
||||
key="close"
|
||||
aria-label="Close"
|
||||
color="inherit"
|
||||
className={this.props.classes.close}
|
||||
onClick={this.closeNotification}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
private renderUpdateDetails() {
|
||||
if (!this.updateInfo) {
|
||||
return null
|
||||
}
|
||||
const releaseNotes = (this.updateInfo.releaseNotes as string) || ''
|
||||
return (
|
||||
<Modal
|
||||
open={this.props.showUpdateDetails}
|
||||
disableAutoFocus={true}
|
||||
onClose={this.hideDetails}
|
||||
>
|
||||
<Paper className={this.props.classes.root}>
|
||||
<Typography variant="h6" className={this.props.classes.title}>Version {this.updateInfo.version}</Typography>
|
||||
<Typography className={this.props.classes.title}>Changelog</Typography>
|
||||
<div className={this.props.classes.releaseNotes} dangerouslySetInnerHTML={{ __html: releaseNotes }} />
|
||||
{this.renderDownloads(this.updateInfo)}
|
||||
<Button className={this.props.classes.closeButton} color="secondary" onClick={this.hideDetails}>Close</Button>
|
||||
</Paper>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
private urlToFilename(url: string) {
|
||||
const parts = url.split('/')
|
||||
|
||||
return parts[parts.length - 1]
|
||||
}
|
||||
|
||||
private renderDownloads(updateInfo: UpdateInfo) {
|
||||
return updateInfo.files
|
||||
.map((file: UpdateFileInfo, index: number) => (
|
||||
<div key={index}>
|
||||
<Button
|
||||
className={this.props.classes.download}
|
||||
href={this.fixUrl(file.url, updateInfo.version)}
|
||||
>
|
||||
<IconButton><CloudDownload /></IconButton>{this.urlToFilename(file.url)}
|
||||
</Button>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
success: {
|
||||
backgroundColor: green[600],
|
||||
color: theme.typography.button.color,
|
||||
},
|
||||
close: {
|
||||
padding: theme.spacing.unit / 2,
|
||||
},
|
||||
root: {
|
||||
minWidth: '350px',
|
||||
maxWidth: '500px',
|
||||
backgroundColor: theme.palette.background.default,
|
||||
margin: '20vh auto auto auto',
|
||||
padding: `${2 * theme.spacing.unit}px`,
|
||||
outline: 'none',
|
||||
},
|
||||
title: {
|
||||
color: theme.palette.text.primary,
|
||||
},
|
||||
releaseNotes: {
|
||||
overflow: 'auto scroll',
|
||||
color: theme.palette.text.secondary,
|
||||
backgroundColor: 'rgba(60, 60, 60, 0.6)',
|
||||
maxHeight: '28vh',
|
||||
},
|
||||
paper: {
|
||||
padding: `${theme.spacing.unit * 2}px`,
|
||||
color: theme.palette.text.secondary,
|
||||
},
|
||||
download: {
|
||||
width: '100%',
|
||||
},
|
||||
closeButton: {
|
||||
display: 'block',
|
||||
margin: '0 0 0 auto',
|
||||
},
|
||||
})
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
showUpdateNotification: state.tooBigReducer.showUpdateNotification,
|
||||
showUpdateDetails: state.tooBigReducer.showUpdateDetails,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: bindActionCreators(updateNotifierActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(UpdateNotifier))
|
||||
@@ -0,0 +1,118 @@
|
||||
import { Action, ActionTypes, ChartParameters } from '../reducers/Charts'
|
||||
import { AppState } from '../reducers'
|
||||
import { default as persistentStorage, StorageIdentifier } from '../utils/PersistentStorage'
|
||||
import { Dispatch } from 'redux'
|
||||
import { showError, showNotification } from './Global'
|
||||
|
||||
interface ConnectionViewState {
|
||||
charts: Array<ChartParameters>
|
||||
}
|
||||
|
||||
interface ConnectionViewStateDictionary {
|
||||
[s: string]: ConnectionViewState
|
||||
}
|
||||
const connectionViewStateIdentifier: StorageIdentifier<ConnectionViewStateDictionary> = {
|
||||
id: 'connection_view_state',
|
||||
}
|
||||
|
||||
export const loadCharts = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const connectionId = getState().connection.connectionId
|
||||
if (!connectionId) {
|
||||
return
|
||||
}
|
||||
|
||||
let viewStates: ConnectionViewStateDictionary | undefined
|
||||
try {
|
||||
viewStates = await persistentStorage.load(connectionViewStateIdentifier)
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
|
||||
if (!viewStates || !viewStates[connectionId]) {
|
||||
dispatch(setCharts([]))
|
||||
return
|
||||
}
|
||||
|
||||
const viewState = viewStates[connectionId]
|
||||
if (viewState) {
|
||||
dispatch(setCharts(viewState.charts))
|
||||
}
|
||||
}
|
||||
|
||||
export const saveCharts = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const connectionId = getState().connection.connectionId
|
||||
if (!connectionId) {
|
||||
return
|
||||
}
|
||||
|
||||
const charts = getState().charts.get('charts').toArray()
|
||||
|
||||
let viewStates: ConnectionViewStateDictionary | undefined
|
||||
try {
|
||||
viewStates = (await persistentStorage.load(connectionViewStateIdentifier)) || {}
|
||||
const state: ConnectionViewState = viewStates[connectionId] || { charts: [] }
|
||||
state.charts = charts
|
||||
|
||||
viewStates[connectionId] = state
|
||||
await persistentStorage.store(connectionViewStateIdentifier, viewStates)
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
}
|
||||
|
||||
export const addChart =
|
||||
(chartParameters: ChartParameters) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const chartExists = Boolean(
|
||||
getState()
|
||||
.charts.get('charts')
|
||||
.find(chart => chart.topic === chartParameters.topic && chart.dotPath === chartParameters.dotPath)
|
||||
)
|
||||
if (chartExists) {
|
||||
dispatch(showNotification('Already added'))
|
||||
return
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.CHARTS_ADD,
|
||||
chart: chartParameters,
|
||||
})
|
||||
dispatch(saveCharts())
|
||||
dispatch(showNotification('Added to chart panel'))
|
||||
}
|
||||
|
||||
export const updateChart =
|
||||
(chartParameters: ChartParameters) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
dispatch({
|
||||
type: ActionTypes.CHARTS_UPDATE,
|
||||
topic: chartParameters.topic,
|
||||
dotPath: chartParameters.dotPath,
|
||||
parameters: chartParameters,
|
||||
})
|
||||
dispatch(saveCharts())
|
||||
}
|
||||
|
||||
export const removeChart =
|
||||
(chartParameters: ChartParameters) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
dispatch({
|
||||
chart: chartParameters,
|
||||
type: ActionTypes.CHARTS_REMOVE,
|
||||
})
|
||||
dispatch(saveCharts())
|
||||
}
|
||||
|
||||
export const moveChartUp =
|
||||
(parameters: { topic: string; dotPath?: string }) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
dispatch({
|
||||
topic: parameters.topic,
|
||||
dotPath: parameters.dotPath,
|
||||
type: ActionTypes.CHARTS_MOVE_UP,
|
||||
})
|
||||
dispatch(saveCharts())
|
||||
}
|
||||
|
||||
export const setCharts = (charts: Array<ChartParameters>): Action => {
|
||||
return {
|
||||
charts,
|
||||
type: ActionTypes.CHARTS_SET,
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,92 @@
|
||||
import { ActionTypes, Action, ConnectionState } from '../reducers/Connection'
|
||||
import { MqttOptions } from '../../../backend/src/DataSource'
|
||||
import { Dispatch } from 'redux'
|
||||
import { rendererEvents, addMqttConnectionEvent, makeConnectionStateEvent, removeConnection } from '../../../events'
|
||||
import { AppState } from '../reducers'
|
||||
import * as q from '../../../backend/src/Model'
|
||||
import { showTree } from './Tree'
|
||||
import * as url from 'url'
|
||||
import { TopicViewModel } from '../TopicViewModel'
|
||||
import { Action, ActionTypes } from '../reducers/Connection'
|
||||
import { ActionTypes as SettingsActionTypes } from '../reducers/Settings'
|
||||
import { AppState } from '../reducers'
|
||||
import { DataSourceState, MqttOptions } from '../../../backend/src/DataSource'
|
||||
import { Dispatch } from 'redux'
|
||||
import { globalActions } from '.'
|
||||
import { resetStore as resetTreeStore, showTree } from './Tree'
|
||||
import { showError } from './Global'
|
||||
import { TopicViewModel } from '../model/TopicViewModel'
|
||||
import { addMqttConnectionEvent, makeConnectionStateEvent, removeConnection, rendererEvents } from '../../../events'
|
||||
|
||||
export const connect = (options: MqttOptions, connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
dispatch(connecting(connectionId))
|
||||
rendererEvents.emit(addMqttConnectionEvent, { options, id: connectionId })
|
||||
const event = makeConnectionStateEvent(connectionId)
|
||||
const host = url.parse(options.url).hostname
|
||||
export const connect =
|
||||
(options: MqttOptions, connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
dispatch(connecting(connectionId))
|
||||
rendererEvents.emit(addMqttConnectionEvent, { options, id: connectionId })
|
||||
const event = makeConnectionStateEvent(connectionId)
|
||||
const host = url.parse(options.url).hostname
|
||||
|
||||
rendererEvents.subscribe(event, (dataSourceState) => {
|
||||
if (dataSourceState.connected) {
|
||||
const tree = new q.Tree<TopicViewModel>()
|
||||
tree.updateWithConnection(rendererEvents, connectionId)
|
||||
dispatch(connected(tree, host!))
|
||||
dispatch(showTree(tree))
|
||||
} else if (dataSourceState.error) {
|
||||
dispatch(showError(dataSourceState.error))
|
||||
dispatch(disconnect())
|
||||
}
|
||||
rendererEvents.subscribe(event, dataSourceState => {
|
||||
if (dataSourceState.connected) {
|
||||
const didReconnect = Boolean(getState().connection.tree)
|
||||
if (!didReconnect) {
|
||||
const tree = new q.Tree<TopicViewModel>()
|
||||
tree.updateWithConnection(rendererEvents, connectionId)
|
||||
dispatch(showTree(tree))
|
||||
dispatch(connected(tree, host!))
|
||||
}
|
||||
} else if (dataSourceState.error) {
|
||||
dispatch(showError(dataSourceState.error))
|
||||
dispatch(disconnect())
|
||||
}
|
||||
dispatch(updateHealth(dataSourceState))
|
||||
})
|
||||
}
|
||||
|
||||
const updateHealth = (dataSourceState: DataSourceState) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
let state
|
||||
if (dataSourceState.connecting) {
|
||||
state = 'connecting'
|
||||
} else if (!dataSourceState.connected) {
|
||||
state = 'offline'
|
||||
dispatch(globalActions.showError('Disconnected from server'))
|
||||
} else if (dataSourceState.connected) {
|
||||
state = 'online'
|
||||
} else {
|
||||
state = undefined
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.CONNECTION_SET_HEALTH,
|
||||
health: state,
|
||||
})
|
||||
}
|
||||
|
||||
export const connected: (tree: q.Tree<TopicViewModel>, host: string) => Action = (tree: q.Tree<TopicViewModel>, host: string) => ({
|
||||
export const connected: (tree: q.Tree<TopicViewModel>, host: string) => Action = (
|
||||
tree: q.Tree<TopicViewModel>,
|
||||
host: string
|
||||
) => ({
|
||||
tree,
|
||||
host,
|
||||
type: ActionTypes.CONNECTION_SET_CONNECTED,
|
||||
})
|
||||
|
||||
export const connecting: (connectionId: string) => Action = (connectionId: string) => ({
|
||||
export const connecting: (connectionId: string) => Action = (connectionId: string) => ({
|
||||
connectionId,
|
||||
type: ActionTypes.CONNECTION_SET_CONNECTING,
|
||||
})
|
||||
|
||||
export const showError = (error?: string) => ({
|
||||
error,
|
||||
type: ActionTypes.CONNECTION_SET_SHOW_ERROR,
|
||||
})
|
||||
|
||||
export const disconnect = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
export const disconnect = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const { connectionId, tree } = getState().connection
|
||||
rendererEvents.emit(removeConnection, connectionId)
|
||||
tree && tree.stopUpdating()
|
||||
if (connectionId) {
|
||||
rendererEvents.emit(removeConnection, connectionId)
|
||||
rendererEvents.unsubscribeAll(makeConnectionStateEvent(connectionId))
|
||||
}
|
||||
|
||||
dispatch(showTree(undefined))
|
||||
tree && tree.stopUpdating()
|
||||
tree && tree.destroy()
|
||||
|
||||
// Clear topic filter
|
||||
dispatch({
|
||||
topicFilter: '',
|
||||
type: SettingsActionTypes.SETTINGS_FILTER_TOPICS,
|
||||
})
|
||||
|
||||
dispatch(resetTreeStore())
|
||||
dispatch({
|
||||
type: ActionTypes.CONNECTION_SET_DISCONNECTED,
|
||||
})
|
||||
dispatch(showTree(undefined))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
import { AppState } from '../reducers'
|
||||
import { clearLegacyConnectionOptions, loadLegacyConnectionOptions } from '../model/LegacyConnectionSettings'
|
||||
import {
|
||||
ConnectionOptions,
|
||||
createEmptyConnection,
|
||||
makeDefaultConnections,
|
||||
CertificateParameters,
|
||||
} from '../model/ConnectionOptions'
|
||||
import { default as persistentStorage, StorageIdentifier } from '../utils/PersistentStorage'
|
||||
import { Dispatch } from 'redux'
|
||||
import { showError } from './Global'
|
||||
import * as path from 'path'
|
||||
import { ActionTypes, Action } from '../reducers/ConnectionManager'
|
||||
import { Subscription } from '../../../backend/src/DataSource/MqttSource'
|
||||
import { connectionsMigrator } from './migrations/Connection'
|
||||
import { rendererRpc, readFromFile } from '../../../events'
|
||||
import { makeOpenDialogRpc } from '../../../events/OpenDialogRequest'
|
||||
|
||||
export interface ConnectionDictionary {
|
||||
[s: string]: ConnectionOptions
|
||||
}
|
||||
const storedConnectionsIdentifier: StorageIdentifier<ConnectionDictionary> = {
|
||||
id: 'ConnectionManager_connections',
|
||||
}
|
||||
|
||||
export const loadConnectionSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
let connections
|
||||
try {
|
||||
await ensureConnectionsHaveBeenInitialized()
|
||||
connections = await persistentStorage.load(storedConnectionsIdentifier)
|
||||
|
||||
// Apply migrations
|
||||
if (connections && connectionsMigrator.isMigrationNecessary(connections)) {
|
||||
connections = connectionsMigrator.applyMigrations(connections)
|
||||
await persistentStorage.store(storedConnectionsIdentifier, connections)
|
||||
}
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
|
||||
if (!connections) {
|
||||
return
|
||||
}
|
||||
|
||||
dispatch(setConnections(connections))
|
||||
const firstKey = Object.keys(connections)[0]
|
||||
if (firstKey) {
|
||||
dispatch(selectConnection(firstKey))
|
||||
}
|
||||
}
|
||||
|
||||
export type CertificateTypes = 'selfSignedCertificate' | 'clientCertificate' | 'clientKey'
|
||||
export const selectCertificate =
|
||||
(type: CertificateTypes, connectionId: string) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
try {
|
||||
const certificate = await openCertificate()
|
||||
dispatch(
|
||||
updateConnection(connectionId, {
|
||||
[type]: certificate,
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
}
|
||||
|
||||
async function openCertificate(): Promise<CertificateParameters> {
|
||||
const rejectReasons = {
|
||||
noCertificateSelected: 'No certificate selected',
|
||||
certificateSizeDoesNotMatch: 'Certificate size larger/smaller then expected.',
|
||||
}
|
||||
|
||||
const openDialogReturnValue = await rendererRpc.call(makeOpenDialogRpc(), {
|
||||
properties: ['openFile'],
|
||||
securityScopedBookmarks: true,
|
||||
})
|
||||
|
||||
const selectedFile = openDialogReturnValue.filePaths && openDialogReturnValue.filePaths[0]
|
||||
if (!selectedFile) {
|
||||
throw rejectReasons.noCertificateSelected
|
||||
}
|
||||
|
||||
const data = await rendererRpc.call(readFromFile, { filePath: selectedFile })
|
||||
if (data.length > 16_384 || data.length < 64) {
|
||||
throw rejectReasons.certificateSizeDoesNotMatch
|
||||
}
|
||||
|
||||
return {
|
||||
data: data.toString('base64'),
|
||||
name: path.basename(selectedFile),
|
||||
}
|
||||
}
|
||||
|
||||
export const saveConnectionSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
try {
|
||||
console.log('store settings')
|
||||
await persistentStorage.store(storedConnectionsIdentifier, getState().connectionManager.connections)
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
}
|
||||
|
||||
export const updateConnection = (connectionId: string, changeSet: Partial<ConnectionOptions>): Action => ({
|
||||
connectionId,
|
||||
changeSet,
|
||||
type: ActionTypes.CONNECTION_MANAGER_UPDATE_CONNECTION,
|
||||
})
|
||||
|
||||
export const addSubscription = (subscription: Subscription, connectionId: string): Action => ({
|
||||
connectionId,
|
||||
subscription,
|
||||
type: ActionTypes.CONNECTION_MANAGER_ADD_SUBSCRIPTION,
|
||||
})
|
||||
|
||||
export const deleteSubscription = (subscription: Subscription, connectionId: string): Action => ({
|
||||
connectionId,
|
||||
subscription,
|
||||
type: ActionTypes.CONNECTION_MANAGER_DELETE_SUBSCRIPTION,
|
||||
})
|
||||
|
||||
export const createConnection = () => (dispatch: Dispatch<any>) => {
|
||||
const newConnection = createEmptyConnection()
|
||||
dispatch(addConnection(newConnection))
|
||||
dispatch(selectConnection(newConnection.id))
|
||||
}
|
||||
|
||||
export const setConnections = (connections: { [s: string]: ConnectionOptions }): Action => ({
|
||||
connections,
|
||||
type: ActionTypes.CONNECTION_MANAGER_SET_CONNECTIONS,
|
||||
})
|
||||
|
||||
export const selectConnection = (connectionId: string): Action => ({
|
||||
selected: connectionId,
|
||||
type: ActionTypes.CONNECTION_MANAGER_SELECT_CONNECTION,
|
||||
})
|
||||
|
||||
export const addConnection = (connection: ConnectionOptions): Action => ({
|
||||
connection,
|
||||
type: ActionTypes.CONNECTION_MANAGER_ADD_CONNECTION,
|
||||
})
|
||||
|
||||
export const toggleAdvancedSettings = (): Action => ({
|
||||
type: ActionTypes.CONNECTION_MANAGER_TOGGLE_ADVANCED_SETTINGS,
|
||||
})
|
||||
|
||||
export const toggleCertificateSettings = (): Action => ({
|
||||
type: ActionTypes.CONNECTION_MANAGER_TOGGLE_CERTIFICATE_SETTINGS,
|
||||
})
|
||||
|
||||
export const deleteConnection = (connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const connectionIds = Object.keys(getState().connectionManager.connections)
|
||||
const connectionIdLocation = connectionIds.indexOf(connectionId)
|
||||
|
||||
const remainingIds = connectionIds.filter(id => id !== connectionId)
|
||||
const nextSelectedConnectionIndex = Math.min(remainingIds.length - 1, connectionIdLocation)
|
||||
const nextSelectedConnection = remainingIds[nextSelectedConnectionIndex]
|
||||
|
||||
dispatch({
|
||||
connectionId,
|
||||
type: ActionTypes.CONNECTION_MANAGER_DELETE_CONNECTION,
|
||||
})
|
||||
|
||||
if (nextSelectedConnection) {
|
||||
dispatch(selectConnection(nextSelectedConnection))
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureConnectionsHaveBeenInitialized() {
|
||||
let connections = await persistentStorage.load(storedConnectionsIdentifier)
|
||||
const requiresInitialization = !connections
|
||||
if (requiresInitialization) {
|
||||
const migratedConnection = loadLegacyConnectionOptions()
|
||||
const defaultConnections = makeDefaultConnections()
|
||||
connections = {
|
||||
...migratedConnection,
|
||||
...defaultConnections,
|
||||
}
|
||||
await persistentStorage.store(storedConnectionsIdentifier, connections)
|
||||
|
||||
clearLegacyConnectionOptions()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { ActionTypes, ConfirmationRequest } from '../reducers/Global'
|
||||
import { Dispatch } from 'redux'
|
||||
|
||||
export const showError = (error?: string | unknown) => ({
|
||||
error,
|
||||
type: ActionTypes.showError,
|
||||
})
|
||||
|
||||
export const showNotification = (notification?: string) => ({
|
||||
notification,
|
||||
type: ActionTypes.showNotification,
|
||||
})
|
||||
|
||||
export const didLaunch = () => ({
|
||||
type: ActionTypes.didLaunch,
|
||||
})
|
||||
|
||||
export const toggleSettingsVisibility = () => (dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
type: ActionTypes.toggleSettingsVisibility,
|
||||
})
|
||||
}
|
||||
|
||||
export const requestConfirmation = (title: string, inquiry: string) => (dispatch: Dispatch<any>) => {
|
||||
return new Promise(resolve => {
|
||||
const confirmationRequest = {
|
||||
title,
|
||||
inquiry,
|
||||
callback: (confirmed: boolean) => {
|
||||
resolve(confirmed)
|
||||
dispatch(removeConfirmationRequest(confirmationRequest))
|
||||
},
|
||||
}
|
||||
|
||||
dispatch({
|
||||
confirmationRequest,
|
||||
type: ActionTypes.requestConfirmation,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const removeConfirmationRequest = (confirmationRequest: ConfirmationRequest) => (dispatch: Dispatch<any>) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
confirmationRequest,
|
||||
type: ActionTypes.removeConfirmationRequest,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,15 +1,63 @@
|
||||
import { ActionTypes, Action } from '../reducers/Publish'
|
||||
import { Action, ActionTypes } from '../reducers/Publish'
|
||||
import { AppState } from '../reducers'
|
||||
import { Base64Message } from '../../../backend/src/Model/Base64Message'
|
||||
import { Dispatch } from 'redux'
|
||||
import { rendererEvents, makePublishEvent } from '../../../events'
|
||||
import { MqttMessage, makePublishEvent, rendererEvents, rendererRpc, readFromFile } from '../../../events'
|
||||
import { makeOpenDialogRpc } from '../../../events/OpenDialogRequest'
|
||||
import { showError } from './Global'
|
||||
import { Base64 } from 'js-base64'
|
||||
|
||||
export const setTopic = (topic?: string): Action => {
|
||||
export const setTopic = (topic?: string): Action => {
|
||||
return {
|
||||
topic,
|
||||
type: ActionTypes.PUBLISH_SET_TOPIC,
|
||||
}
|
||||
}
|
||||
|
||||
export const openFile =
|
||||
(encoding: BufferEncoding = 'utf8') =>
|
||||
async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
try {
|
||||
const file = await getFileContent(encoding)
|
||||
if (file) {
|
||||
dispatch(setPayload(file.data))
|
||||
}
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
}
|
||||
|
||||
type FileParameters = {
|
||||
name: string
|
||||
data: string
|
||||
}
|
||||
async function getFileContent(encoding: BufferEncoding): Promise<FileParameters | undefined> {
|
||||
const rejectReasons = {
|
||||
noFileSelected: 'No file selected',
|
||||
errorReadingFile: 'Error reading file',
|
||||
}
|
||||
|
||||
const { canceled, filePaths } = await rendererRpc.call(makeOpenDialogRpc(), {
|
||||
properties: ['openFile'],
|
||||
securityScopedBookmarks: true,
|
||||
})
|
||||
|
||||
if (canceled) {
|
||||
return
|
||||
}
|
||||
|
||||
const selectedFile = filePaths[0]
|
||||
if (!selectedFile) {
|
||||
throw rejectReasons.noFileSelected
|
||||
}
|
||||
try {
|
||||
const data = await rendererRpc.call(readFromFile, { filePath: selectedFile, encoding })
|
||||
return { name: selectedFile, data: data.toString(encoding) }
|
||||
} catch (error) {
|
||||
throw rejectReasons.errorReadingFile
|
||||
}
|
||||
}
|
||||
|
||||
export const setPayload = (payload?: string): Action => {
|
||||
return {
|
||||
payload,
|
||||
@@ -31,18 +79,18 @@ export const setEditorMode = (editorMode: string): Action => {
|
||||
}
|
||||
}
|
||||
|
||||
export const publish = (connectionId: string) => (dispatch: Dispatch<Action>, getState: () => AppState) => {
|
||||
export const publish = (connectionId: string) => (dispatch: Dispatch<Action>, getState: () => AppState) => {
|
||||
const state = getState()
|
||||
const topic = state.publish.topic
|
||||
const topic = state.publish.manualTopic ?? state.tree.get('selectedTopic')?.path()
|
||||
|
||||
if (!topic) {
|
||||
return
|
||||
}
|
||||
|
||||
const publishEvent = makePublishEvent(connectionId)
|
||||
const mqttMessage = {
|
||||
const mqttMessage: Partial<MqttMessage> = {
|
||||
topic,
|
||||
payload: state.publish.payload,
|
||||
payload: state.publish.payload ? Base64Message.fromString(state.publish.payload) : null,
|
||||
retain: state.publish.retain,
|
||||
qos: state.publish.qos,
|
||||
}
|
||||
|
||||
+109
-27
@@ -1,34 +1,100 @@
|
||||
import { Action, ActionTypes, TopicOrder } from '../reducers/Settings'
|
||||
import { ActionTypes as TreeActionTypes } from '../reducers/Tree'
|
||||
import { Dispatch } from 'redux'
|
||||
import { showTree } from './Tree'
|
||||
import { AppState } from '../reducers'
|
||||
import * as q from '../../../backend/src/Model'
|
||||
import { ActionTypes, SettingsStateModel, TopicOrder, ValueRendererDisplayMode } from '../reducers/Settings'
|
||||
import { AppState } from '../reducers'
|
||||
import { autoExpandLimitSet } from '../components/SettingsDrawer/Settings'
|
||||
import { Base64Message } from '../../../backend/src/Model/Base64Message'
|
||||
import { batchActions } from 'redux-batched-actions'
|
||||
import { autoExpandLimitSet } from '../components/Settings'
|
||||
import { TopicViewModel } from '../TopicViewModel'
|
||||
import { default as persistentStorage, StorageIdentifier } from '../utils/PersistentStorage'
|
||||
import { Dispatch } from 'redux'
|
||||
import { globalActions } from './'
|
||||
import { showError } from './Global'
|
||||
import { showTree } from './Tree'
|
||||
import { TopicViewModel } from '../model/TopicViewModel'
|
||||
|
||||
export const setAutoExpandLimit = (autoExpandLimit: number = 0): Action => {
|
||||
return {
|
||||
autoExpandLimit,
|
||||
type: ActionTypes.SETTINGS_SET_AUTO_EXPAND_LIMIT,
|
||||
const settingsIdentifier: StorageIdentifier<Partial<SettingsStateModel>> = {
|
||||
id: 'Settings',
|
||||
}
|
||||
|
||||
export const loadSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
try {
|
||||
const settings = (await persistentStorage.load(settingsIdentifier)) || {}
|
||||
dispatch({
|
||||
settings: getState().settings.merge(settings),
|
||||
type: ActionTypes.SETTINGS_DID_LOAD_SETTINGS,
|
||||
})
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
dispatch(globalActions.didLaunch())
|
||||
}
|
||||
|
||||
export const storeSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const settings = {
|
||||
...getState().settings.toJS(),
|
||||
autoExpandLimit: undefined,
|
||||
topicFilter: undefined,
|
||||
visible: undefined,
|
||||
}
|
||||
|
||||
try {
|
||||
await persistentStorage.store(settingsIdentifier, settings)
|
||||
} catch (error) {
|
||||
dispatch(showError(error))
|
||||
}
|
||||
}
|
||||
|
||||
export const toggleSettingsVisibility = (): Action => {
|
||||
return {
|
||||
type: ActionTypes.SETTINGS_TOGGLE_VISIBILITY,
|
||||
export const setAutoExpandLimit =
|
||||
(autoExpandLimit: number = 0) =>
|
||||
(dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
autoExpandLimit,
|
||||
type: ActionTypes.SETTINGS_SET_AUTO_EXPAND_LIMIT,
|
||||
})
|
||||
}
|
||||
|
||||
export const setTimeLocale = (timeLocale: string) => (dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
timeLocale,
|
||||
type: ActionTypes.SETTINGS_SET_TIME_LOCALE,
|
||||
})
|
||||
dispatch(storeSettings())
|
||||
}
|
||||
|
||||
export const setTopicOrder = (topicOrder: TopicOrder = TopicOrder.none): Action => {
|
||||
return {
|
||||
topicOrder,
|
||||
type: ActionTypes.SETTINGS_SET_TOPIC_ORDER,
|
||||
}
|
||||
export const selectTopicWithMouseOver = (doSelect: boolean) => (dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
selectTopicWithMouseOver: doSelect,
|
||||
type: ActionTypes.SETTINGS_SET_SELECT_TOPIC_WITH_MOUSE_OVER,
|
||||
})
|
||||
dispatch(storeSettings())
|
||||
}
|
||||
|
||||
export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
export const setValueDisplayMode =
|
||||
(valueRendererDisplayMode: ValueRendererDisplayMode) => (dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
valueRendererDisplayMode,
|
||||
type: ActionTypes.SETTINGS_SET_VALUE_RENDERER_DISPLAY_MODE,
|
||||
})
|
||||
dispatch(storeSettings())
|
||||
}
|
||||
|
||||
export const toggleHighlightTopicUpdates = () => (dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
type: ActionTypes.SETTINGS_TOGGLE_HIGHLIGHT_ACTIVITY,
|
||||
})
|
||||
dispatch(storeSettings())
|
||||
}
|
||||
|
||||
export const setTopicOrder =
|
||||
(topicOrder: TopicOrder = TopicOrder.none) =>
|
||||
(dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
topicOrder,
|
||||
type: ActionTypes.SETTINGS_SET_TOPIC_ORDER,
|
||||
})
|
||||
dispatch(storeSettings())
|
||||
}
|
||||
|
||||
export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const { tree } = getState().connection
|
||||
|
||||
dispatch({
|
||||
@@ -36,8 +102,8 @@ export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, get
|
||||
type: ActionTypes.SETTINGS_FILTER_TOPICS,
|
||||
})
|
||||
|
||||
if (!filterStr || !tree) {
|
||||
dispatch(batchActions([setAutoExpandLimit(0), (showTree(tree) as any)]))
|
||||
if (!filterStr || !tree) {
|
||||
dispatch(batchActions([setAutoExpandLimit(0), showTree(tree) as any]))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,11 +115,16 @@ export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, get
|
||||
return true
|
||||
}
|
||||
|
||||
const messageMatches = (node.message && typeof node.message.value === 'string' && node.message.value.toLowerCase().indexOf(filterStr) !== -1)
|
||||
const messageMatches =
|
||||
node.message &&
|
||||
node.message.payload &&
|
||||
node.message.payload.toUnicodeString().toLowerCase().indexOf(filterStr) !== -1
|
||||
|
||||
return Boolean(messageMatches)
|
||||
}
|
||||
|
||||
const resultTree = tree.childTopics()
|
||||
const resultTree = tree
|
||||
.childTopics()
|
||||
.filter(nodeFilter)
|
||||
.map((node: q.TreeNode<TopicViewModel>) => {
|
||||
const clone = node.unconnectedClone()
|
||||
@@ -70,16 +141,17 @@ export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, get
|
||||
nextTree.updateWithConnection(tree.updateSource, tree.connectionId, nodeFilter)
|
||||
}
|
||||
|
||||
dispatch(batchActions([setAutoExpandLimit(autoExpandLimitForTree(nextTree)), (showTree(nextTree) as any)]))
|
||||
dispatch(batchActions([setAutoExpandLimit(autoExpandLimitForTree(nextTree)), showTree(nextTree) as any]))
|
||||
}
|
||||
|
||||
function autoExpandLimitForTree(tree: q.Tree<TopicViewModel>) {
|
||||
if (!tree) {
|
||||
return 0
|
||||
}
|
||||
|
||||
function closestExistingLimit(i: number): number {
|
||||
const sorted = autoExpandLimitSet.sort((a, b) => Math.abs(a.limit - i) - Math.abs(b.limit - i))
|
||||
return sorted[0]!.limit
|
||||
const sorted = [...autoExpandLimitSet].sort((a, b) => Math.abs(a.limit - i) - Math.abs(b.limit - i))
|
||||
return sorted[0].limit
|
||||
}
|
||||
|
||||
const count = tree.childTopicCount()
|
||||
@@ -87,3 +159,13 @@ function autoExpandLimitForTree(tree: q.Tree<TopicViewModel>) {
|
||||
|
||||
return closestExistingLimit(calculatedLimit)
|
||||
}
|
||||
|
||||
export const toggleTheme = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
dispatch({
|
||||
type:
|
||||
getState().settings.get('theme') === 'light'
|
||||
? ActionTypes.SETTINGS_SET_THEME_DARK
|
||||
: ActionTypes.SETTINGS_SET_THEME_LIGHT,
|
||||
})
|
||||
dispatch(storeSettings())
|
||||
}
|
||||
|
||||
+16
-14
@@ -1,21 +1,23 @@
|
||||
import { Dispatch, Action } from 'redux'
|
||||
import * as q from '../../../backend/src/Model'
|
||||
import { ActionTypes } from '../reducers/Sidebar'
|
||||
import { AppState } from '../reducers'
|
||||
import { makePublishEvent, rendererEvents } from '../../../events'
|
||||
import { Dispatch } from 'redux'
|
||||
import { clearTopic } from './clearTopic'
|
||||
|
||||
export const clearRetainedTopic = () => (dispatch: Dispatch<Action>, getState: () => AppState) => {
|
||||
const { selectedTopic } = getState().tree
|
||||
const { connectionId } = getState().connection
|
||||
export { clearTopic } from './clearTopic'
|
||||
|
||||
if (!selectedTopic || !connectionId) {
|
||||
export const clearRetainedTopic = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const selectedTopic = getState().tree.get('selectedTopic')
|
||||
if (!selectedTopic) {
|
||||
return
|
||||
}
|
||||
|
||||
const publishEvent = makePublishEvent(connectionId)
|
||||
const mqttMessage = {
|
||||
topic: selectedTopic.path(),
|
||||
payload: null,
|
||||
retain: true,
|
||||
qos: 0 as 0,
|
||||
}
|
||||
rendererEvents.emit(publishEvent, mqttMessage)
|
||||
dispatch(clearTopic(selectedTopic, false))
|
||||
}
|
||||
|
||||
export const setCompareMessage = (message?: q.Message) => (dispatch: Dispatch<any>) => {
|
||||
dispatch({
|
||||
message,
|
||||
type: ActionTypes.SIDEBAR_SET_COMPARE_MESSAGE,
|
||||
})
|
||||
}
|
||||
|
||||
+97
-37
@@ -1,54 +1,114 @@
|
||||
import { AppState } from '../reducers'
|
||||
import { ActionTypes } from '../reducers/Tree'
|
||||
import * as q from '../../../backend/src/Model'
|
||||
import { Dispatch, AnyAction } from 'redux'
|
||||
import { setTopic } from './Publish'
|
||||
import { TopicViewModel } from '../TopicViewModel'
|
||||
import { ActionTypes } from '../reducers/Tree'
|
||||
import { ActionTypes as SidebarActionTypes } from '../reducers/Sidebar'
|
||||
import { AnyAction, Dispatch } from 'redux'
|
||||
import { AppState } from '../reducers'
|
||||
import { batchActions } from 'redux-batched-actions'
|
||||
import { globalActions } from './'
|
||||
import { setTopic } from './Publish'
|
||||
import { TopicViewModel } from '../model/TopicViewModel'
|
||||
import debounce from 'lodash.debounce'
|
||||
export { clearTopic } from './clearTopic'
|
||||
|
||||
export const selectTopic = (topic: q.TreeNode<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const { selectedTopic } = getState().tree
|
||||
if (selectedTopic === topic) {
|
||||
return
|
||||
export { moveSelectionUpOrDownwards, moveInward, moveOutward } from './visibleTreeTraversal'
|
||||
|
||||
export const selectTopic =
|
||||
(topic: q.TreeNode<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
debouncedSelectTopic(topic, dispatch, getState)
|
||||
}
|
||||
|
||||
// Update publish topic
|
||||
let setTopicDispatch: any | undefined
|
||||
if (selectedTopic && (selectedTopic.path() === getState().publish.topic || !getState().publish.topic)) {
|
||||
setTopicDispatch = setTopic(topic.path())
|
||||
}
|
||||
const debouncedSelectTopic = debounce(
|
||||
(topic: q.TreeNode<TopicViewModel>, dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const previouslySelectedTopic = getState().tree.get('selectedTopic')
|
||||
|
||||
if (selectedTopic && selectedTopic.viewModel) {
|
||||
selectedTopic.viewModel.setSelected(false)
|
||||
}
|
||||
if (previouslySelectedTopic === topic) {
|
||||
return
|
||||
}
|
||||
|
||||
if (topic.viewModel) {
|
||||
topic.viewModel.setSelected(true)
|
||||
}
|
||||
// Update publish topic
|
||||
let setTopicDispatch: any | undefined
|
||||
if (!getState().publish.manualTopic) {
|
||||
setTopicDispatch = setTopic(topic.path())
|
||||
} else if (previouslySelectedTopic && previouslySelectedTopic.path() === getState().publish.manualTopic) {
|
||||
setTopicDispatch = setTopic(topic.path())
|
||||
}
|
||||
|
||||
const selectTreeTopicDispatch = {
|
||||
selectedTopic: topic,
|
||||
type: ActionTypes.TREE_SELECT_TOPIC,
|
||||
}
|
||||
previouslySelectedTopic?.viewModel?.setSelected(false)
|
||||
topic.viewModel?.setSelected(true)
|
||||
|
||||
if (setTopicDispatch) {
|
||||
dispatch(batchActions([selectTreeTopicDispatch, setTopicDispatch]))
|
||||
} else {
|
||||
dispatch(selectTreeTopicDispatch)
|
||||
}
|
||||
}
|
||||
const selectTreeTopicDispatch = {
|
||||
selectedTopic: topic,
|
||||
type: ActionTypes.TREE_SELECT_TOPIC,
|
||||
}
|
||||
|
||||
export const showTree = (tree?: q.Tree<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState): AnyAction => {
|
||||
const visibleTree = getState().tree.tree
|
||||
const connectionTree = getState().connection.tree
|
||||
dispatch({
|
||||
type: SidebarActionTypes.SIDEBAR_SET_COMPARE_MESSAGE,
|
||||
message: undefined,
|
||||
})
|
||||
|
||||
if (setTopicDispatch) {
|
||||
dispatch(batchActions([selectTreeTopicDispatch, setTopicDispatch]))
|
||||
} else {
|
||||
dispatch(selectTreeTopicDispatch)
|
||||
}
|
||||
},
|
||||
70
|
||||
)
|
||||
|
||||
function destroyUnreferencedTree(state: AppState) {
|
||||
const visibleTree = state.tree.get('tree')
|
||||
const connectionTree = state.connection.tree
|
||||
|
||||
// Stop updates of old tree
|
||||
if (visibleTree !== connectionTree && visibleTree) {
|
||||
if (visibleTree && visibleTree !== connectionTree) {
|
||||
console.warn('destroy')
|
||||
visibleTree.stopUpdating()
|
||||
visibleTree.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
export const resetStore =
|
||||
() =>
|
||||
(dispatch: Dispatch<any>, getState: () => AppState): AnyAction => {
|
||||
destroyUnreferencedTree(getState())
|
||||
|
||||
return dispatch({
|
||||
type: ActionTypes.TREE_RESET_STORE,
|
||||
})
|
||||
}
|
||||
|
||||
return dispatch({
|
||||
tree,
|
||||
type: ActionTypes.TREE_SHOW_TREE,
|
||||
export const showTree =
|
||||
(tree: q.Tree<TopicViewModel> | undefined) =>
|
||||
(dispatch: Dispatch<any>, getState: () => AppState): AnyAction => {
|
||||
destroyUnreferencedTree(getState())
|
||||
|
||||
return dispatch({
|
||||
tree,
|
||||
type: ActionTypes.TREE_SHOW_TREE,
|
||||
})
|
||||
}
|
||||
|
||||
export const togglePause = (tree?: q.Tree<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const paused = getState().tree.get('paused')
|
||||
const tree = getState().tree.get('tree')
|
||||
const changes = tree ? tree.unmergedChanges().length : 0
|
||||
|
||||
if (tree) {
|
||||
paused ? tree.resume() : tree.pause()
|
||||
}
|
||||
|
||||
if (paused && changes > 0) {
|
||||
dispatch(globalActions.showNotification('Applying recorded changes.'))
|
||||
}
|
||||
|
||||
// Allow for notification to be displayed
|
||||
setTimeout(() => {
|
||||
if (paused && changes > 0) {
|
||||
dispatch(globalActions.showNotification(`Successfully applied ${changes} changes.`))
|
||||
}
|
||||
}, 50)
|
||||
|
||||
dispatch({
|
||||
type: paused ? ActionTypes.TREE_RESUME_UPDATES : ActionTypes.TREE_PAUSE_UPDATES,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { ActionTypes, CustomAction } from '../reducers'
|
||||
import { ActionTypes, GlobalAction } from '../reducers/Global'
|
||||
|
||||
export const showUpdateNotification = (show: boolean): CustomAction => {
|
||||
export const showUpdateNotification = (show: boolean): GlobalAction => {
|
||||
return {
|
||||
type: ActionTypes.showUpdateNotification,
|
||||
showUpdateNotification: show,
|
||||
}
|
||||
}
|
||||
|
||||
export const showUpdateDetails = (show: boolean): CustomAction => {
|
||||
export const showUpdateDetails = (show: boolean): GlobalAction => {
|
||||
return {
|
||||
type: ActionTypes.showUpdateDetails,
|
||||
showUpdateDetails: show,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import * as q from '../../../backend/src/Model'
|
||||
import { AppState } from '../reducers'
|
||||
import { Dispatch } from 'redux'
|
||||
import { makePublishEvent, rendererEvents } from '../../../events'
|
||||
import { moveSelectionUpOrDownwards } from './visibleTreeTraversal'
|
||||
import { globalActions } from '.'
|
||||
|
||||
export const clearTopic =
|
||||
(topic: q.TreeNode<any>, recursive: boolean) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||
const topicsForPurging = recursive ? [topic, ...topic.childTopics()] : [topic]
|
||||
|
||||
if (recursive) {
|
||||
const topicCount = topic.childTopicCount()
|
||||
|
||||
const topicDelta = topic.hasMessage() ? -1 : 0
|
||||
const childTopicsMessage =
|
||||
topicCount + topicDelta > 0
|
||||
? ` and ${topicCount + topicDelta} child ${topicCount + topicDelta === 1 ? 'topic' : 'topics'}`
|
||||
: ''
|
||||
|
||||
const confirmed = await dispatch(
|
||||
globalActions.requestConfirmation(
|
||||
'Confirm delete',
|
||||
`Do you want to clear "${topic.path()}"${childTopicsMessage}?\n\nThis function will send an empty payload (QoS 0, retain) to this and every subtopic, clearing retained topics in the process. Only use this function if you know what you are doing.`
|
||||
)
|
||||
)
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(moveSelectionUpOrDownwards('next'))
|
||||
|
||||
const { connectionId } = getState().connection
|
||||
if (!connectionId) {
|
||||
return
|
||||
}
|
||||
const publishEvent = makePublishEvent(connectionId)
|
||||
|
||||
topicsForPurging
|
||||
.filter(t => t.path() !== '' && t.hasMessage())
|
||||
.map(t => t.path())
|
||||
.forEach((path, idx) => {
|
||||
const mqttMessage = {
|
||||
topic: path,
|
||||
payload: null,
|
||||
retain: true,
|
||||
qos: 0 as 0,
|
||||
messageId: undefined,
|
||||
}
|
||||
// Rate limit deletion
|
||||
setTimeout(() => rendererEvents.emit(publishEvent, mqttMessage), 20 * idx)
|
||||
})
|
||||
}
|
||||
@@ -1,8 +1,21 @@
|
||||
import * as settingsActions from './Settings'
|
||||
import * as chartActions from './Charts'
|
||||
import * as connectionActions from './Connection'
|
||||
import * as connectionManagerActions from './ConnectionManager'
|
||||
import * as globalActions from './Global'
|
||||
import * as publishActions from './Publish'
|
||||
import * as settingsActions from './Settings'
|
||||
import * as sidebarActions from './Sidebar'
|
||||
import * as treeActions from './Tree'
|
||||
import * as updateNotifierActions from './UpdateNotifier'
|
||||
import * as connectionActions from './Connection'
|
||||
import * as sidebarActons from './Sidebar'
|
||||
|
||||
export { settingsActions, treeActions, publishActions, updateNotifierActions, connectionActions, sidebarActons }
|
||||
export {
|
||||
settingsActions,
|
||||
treeActions,
|
||||
chartActions,
|
||||
publishActions,
|
||||
updateNotifierActions,
|
||||
connectionActions,
|
||||
sidebarActions,
|
||||
connectionManagerActions,
|
||||
globalActions,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { ConfigMigrator, Migration } from '../../utils/ConfigMigrator'
|
||||
import { ConnectionDictionary } from '../ConnectionManager'
|
||||
import { ConnectionOptions } from '../../model/ConnectionOptions'
|
||||
|
||||
export interface ConnectionOptionsV0 {
|
||||
type: 'mqtt'
|
||||
id: string
|
||||
host: string
|
||||
protocol: 'mqtt' | 'ws'
|
||||
basePath?: string
|
||||
port: number
|
||||
name: string
|
||||
username?: string
|
||||
password?: string
|
||||
encryption: boolean
|
||||
certValidation: boolean
|
||||
// selfSignedCertificate?: CertificateParameters
|
||||
// clientCertificate?: CertificateParameters
|
||||
// clientKey?: CertificateParameters
|
||||
clientId?: string
|
||||
subscriptions: Array<string>
|
||||
}
|
||||
|
||||
let migrations: Migration[] = [
|
||||
// iot.eclipse.org ha moved to mqtt.eclipse.org
|
||||
{
|
||||
from: undefined,
|
||||
apply: (connection: ConnectionOptionsV0): ConnectionOptionsV0 => {
|
||||
if (connection.id == 'iot.eclipse.org' && connection.host == 'iot.eclipse.org' && connection.port == 1883) {
|
||||
return {
|
||||
...connection,
|
||||
id: 'mqtt.eclipse.org',
|
||||
host: 'mqtt.eclipse.org',
|
||||
name: 'mqtt.eclipse.org',
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...connection,
|
||||
}
|
||||
},
|
||||
},
|
||||
// Remove stored clientId if it is the default generated client id. This allows to connect multiple instances of mqtt explorer to the same broker.
|
||||
// A randomly generated clientId will be used if no clientId is set.
|
||||
{
|
||||
from: undefined,
|
||||
apply: (connection: ConnectionOptionsV0): ConnectionOptionsV0 => {
|
||||
if (connection.clientId && /mqtt-explorer-[0-9a-f]{8}/.test(connection.clientId)) {
|
||||
return {
|
||||
...connection,
|
||||
clientId: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...connection,
|
||||
}
|
||||
},
|
||||
},
|
||||
// Added QoS level to subscription options
|
||||
{
|
||||
from: undefined,
|
||||
apply: (connection: ConnectionOptionsV0): ConnectionOptions => {
|
||||
return {
|
||||
...connection,
|
||||
configVersion: 1,
|
||||
subscriptions: connection.subscriptions.map(topic => ({ topic, qos: 0 })),
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const connectionMigrator = new ConfigMigrator(migrations)
|
||||
|
||||
function isMigrationNecessary(connections: ConnectionDictionary): boolean {
|
||||
return Object.values(connections)
|
||||
.map(connection => connectionMigrator.isMigrationNecessary(connection))
|
||||
.reduce((a, b) => a || b, false)
|
||||
}
|
||||
|
||||
function applyMigrations(connections: ConnectionDictionary): ConnectionDictionary {
|
||||
let newConnectionDictionary: ConnectionDictionary = {}
|
||||
Object.keys(connections).forEach(key => {
|
||||
let newConnection = connectionMigrator.applyMigrations(connections[key]) as any
|
||||
newConnectionDictionary[newConnection.id] = newConnection
|
||||
})
|
||||
|
||||
return newConnectionDictionary
|
||||
}
|
||||
|
||||
export const connectionsMigrator = {
|
||||
isMigrationNecessary,
|
||||
applyMigrations,
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import * as q from '../../../backend/src/Model'
|
||||
import { AppState } from '../reducers'
|
||||
import { Dispatch } from 'redux'
|
||||
import { selectTopic } from './Tree'
|
||||
import { SettingsState } from '../reducers/Settings'
|
||||
import { sortedNodes } from '../sortedNodes'
|
||||
import { TopicViewModel } from '../model/TopicViewModel'
|
||||
|
||||
export const moveSelectionUpOrDownwards =
|
||||
(direction: 'next' | 'previous') =>
|
||||
(dispatch: Dispatch<any>, getState: () => AppState): any => {
|
||||
const state = getState()
|
||||
const selected = state.tree.get('selectedTopic')
|
||||
const tree = state.tree.get('tree')
|
||||
|
||||
if (!selected || !tree) {
|
||||
if (tree) {
|
||||
dispatch(selectTopic(tree))
|
||||
}
|
||||
return
|
||||
}
|
||||
const nextTreeNode = nextVisibleElementInTree(state.settings, tree, selected, direction)
|
||||
if (nextTreeNode && nextTreeNode.viewModel) {
|
||||
dispatch(selectTopic(nextTreeNode))
|
||||
}
|
||||
}
|
||||
|
||||
export const moveInward =
|
||||
() =>
|
||||
(dispatch: Dispatch<any>, getState: () => AppState): any => {
|
||||
const state = getState()
|
||||
const selected = state.tree.get('selectedTopic')
|
||||
if (!selected || !selected.viewModel) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!selected.viewModel.isExpanded() && selected.edgeCount() > 0) {
|
||||
selected.viewModel.setExpanded(true, true)
|
||||
} else {
|
||||
dispatch(moveSelectionUpOrDownwards('next'))
|
||||
}
|
||||
}
|
||||
|
||||
export const moveOutward =
|
||||
() =>
|
||||
(dispatch: Dispatch<any>, getState: () => AppState): any => {
|
||||
const state = getState()
|
||||
const selected = state.tree.get('selectedTopic')
|
||||
if (!selected || !selected.viewModel) {
|
||||
return
|
||||
}
|
||||
|
||||
if (selected.viewModel.isExpanded() && selected.edgeCount() > 0) {
|
||||
selected.viewModel.setExpanded(false, true)
|
||||
} else {
|
||||
dispatch(moveSelectionUpOrDownwards('previous'))
|
||||
}
|
||||
}
|
||||
|
||||
function isTreeNodeVisible(treeNode: q.TreeNode<any>) {
|
||||
return Boolean(treeNode.viewModel)
|
||||
}
|
||||
|
||||
function nextVisibleElementInTree(
|
||||
settings: SettingsState,
|
||||
tree: q.Tree<TopicViewModel>,
|
||||
node: q.TreeNode<TopicViewModel>,
|
||||
direction: 'next' | 'previous'
|
||||
): q.TreeNode<TopicViewModel> | undefined {
|
||||
if (direction === 'next') {
|
||||
return findNextNodeDownward(settings, node)
|
||||
} else {
|
||||
return findNextNodeUpward(settings, node)
|
||||
}
|
||||
}
|
||||
|
||||
/** Not very efficient but easy to implement, complexity should not be an issue here */
|
||||
function findNextNodeUpward(
|
||||
settings: SettingsState,
|
||||
treeNode: q.TreeNode<TopicViewModel>
|
||||
): q.TreeNode<TopicViewModel> | undefined {
|
||||
const parent = treeNode.sourceEdge && treeNode.sourceEdge.source
|
||||
if (!parent) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const neighborNodes = sortedNodes(settings, parent)
|
||||
const nodeIdx = neighborNodes.findIndex(n => n.path() === treeNode.path())
|
||||
if (nodeIdx === 0) {
|
||||
return parent
|
||||
}
|
||||
const upwardNeighbor = neighborNodes[nodeIdx - 1]
|
||||
if (upwardNeighbor) {
|
||||
return lastVisibleChild(settings, upwardNeighbor)
|
||||
} else {
|
||||
return findNextNodeUpward(settings, parent)
|
||||
}
|
||||
}
|
||||
|
||||
function lastVisibleChild(settings: SettingsState, treeNode: q.TreeNode<TopicViewModel>): q.TreeNode<TopicViewModel> {
|
||||
const nodes = sortedNodes(settings, treeNode).filter(isTreeNodeVisible)
|
||||
if (nodes.length === 0) {
|
||||
return treeNode
|
||||
}
|
||||
return lastVisibleChild(settings, nodes[nodes.length - 1])
|
||||
}
|
||||
|
||||
function findNextNodeDownward(
|
||||
settings: SettingsState,
|
||||
treeNode: q.TreeNode<TopicViewModel>
|
||||
): q.TreeNode<TopicViewModel> | undefined {
|
||||
const children = sortedNodes(settings, treeNode).filter(isTreeNodeVisible)
|
||||
const firstChild = children[0]
|
||||
if (firstChild) {
|
||||
return firstChild
|
||||
}
|
||||
|
||||
return findNextNodeDownwardNeighbor(settings, treeNode)
|
||||
}
|
||||
|
||||
function findNextNodeDownwardNeighbor(
|
||||
settings: SettingsState,
|
||||
treeNode: q.TreeNode<TopicViewModel>
|
||||
): q.TreeNode<TopicViewModel> | undefined {
|
||||
const parent = treeNode.sourceEdge && treeNode.sourceEdge.source
|
||||
if (!parent) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const neighborNodes = sortedNodes(settings, parent).filter(isTreeNodeVisible)
|
||||
const nodeIdx = neighborNodes.findIndex(n => n.path() === treeNode.path())
|
||||
const downwardNeighbor = neighborNodes[nodeIdx + 1]
|
||||
if (downwardNeighbor) {
|
||||
return downwardNeighbor
|
||||
} else {
|
||||
return findNextNodeDownwardNeighbor(settings, parent)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// Browser-specific EventBus implementation using Socket.io
|
||||
// This file contains the socket.io-client dependency which belongs in the app layer
|
||||
import io, { Socket } from 'socket.io-client'
|
||||
import { SocketIOClientEventBus } from '../../events/EventSystem/SocketIOClientEventBus'
|
||||
import { Rpc } from '../../events/EventSystem/Rpc'
|
||||
|
||||
// Get auth from sessionStorage or use empty (will show login dialog)
|
||||
let username = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem('mqtt-explorer-username') || '' : ''
|
||||
let password = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem('mqtt-explorer-password') || '' : ''
|
||||
|
||||
// Connect to the server (same origin in browser mode)
|
||||
const socket: Socket = io({
|
||||
auth: {
|
||||
username,
|
||||
password,
|
||||
},
|
||||
reconnection: true,
|
||||
reconnectionDelay: 1000,
|
||||
reconnectionDelayMax: 5000,
|
||||
reconnectionAttempts: Infinity,
|
||||
transports: ['websocket', 'polling'],
|
||||
autoConnect: false, // Don't auto-connect, we'll connect manually after checking credentials
|
||||
})
|
||||
|
||||
// Handle connection errors
|
||||
socket.on('connect_error', (error) => {
|
||||
console.error('Socket connection error:', error.message)
|
||||
|
||||
// Check if it's an authentication error
|
||||
if (error.message.includes('Invalid credentials') ||
|
||||
error.message.includes('Authentication required') ||
|
||||
error.message.includes('Too many')) {
|
||||
// Clear invalid credentials from sessionStorage
|
||||
if (typeof sessionStorage !== 'undefined') {
|
||||
sessionStorage.removeItem('mqtt-explorer-username')
|
||||
sessionStorage.removeItem('mqtt-explorer-password')
|
||||
}
|
||||
|
||||
// Dispatch custom event that BrowserAuthWrapper can listen to
|
||||
if (typeof window !== 'undefined') {
|
||||
window.dispatchEvent(new CustomEvent('mqtt-auth-error', {
|
||||
detail: { message: error.message }
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
socket.on('disconnect', (reason) => {
|
||||
console.log('Socket disconnected:', reason)
|
||||
})
|
||||
|
||||
socket.on('connect', () => {
|
||||
console.log('Socket connected successfully')
|
||||
|
||||
// Dispatch custom event that BrowserAuthWrapper can listen to
|
||||
if (typeof window !== 'undefined') {
|
||||
window.dispatchEvent(new CustomEvent('mqtt-auth-success', {
|
||||
detail: { message: 'Authentication successful' }
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
// Listen for auth-status from server (sent on connection)
|
||||
socket.on('auth-status', (data: { authDisabled: boolean }) => {
|
||||
console.log('Auth status received from server:', data)
|
||||
|
||||
// Dispatch custom event with auth status
|
||||
if (typeof window !== 'undefined') {
|
||||
window.dispatchEvent(new CustomEvent('mqtt-auth-status', {
|
||||
detail: { authDisabled: data.authDisabled }
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Update socket authentication credentials and attempt to reconnect
|
||||
* @param newUsername New username
|
||||
* @param newPassword New password
|
||||
*/
|
||||
export function updateSocketAuth(newUsername: string, newPassword: string) {
|
||||
username = newUsername
|
||||
password = newPassword
|
||||
|
||||
// Update socket auth
|
||||
socket.auth = {
|
||||
username: newUsername,
|
||||
password: newPassword,
|
||||
}
|
||||
|
||||
// Store in sessionStorage
|
||||
if (typeof sessionStorage !== 'undefined') {
|
||||
sessionStorage.setItem('mqtt-explorer-username', newUsername)
|
||||
sessionStorage.setItem('mqtt-explorer-password', newPassword)
|
||||
}
|
||||
|
||||
// Disconnect if connected, then reconnect with new credentials
|
||||
if (socket.connected) {
|
||||
socket.disconnect()
|
||||
}
|
||||
socket.connect()
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect the socket (used on initial page load)
|
||||
*/
|
||||
export function connectSocket() {
|
||||
if (!socket.connected) {
|
||||
socket.connect()
|
||||
}
|
||||
}
|
||||
|
||||
export const rendererEvents = new SocketIOClientEventBus(socket)
|
||||
export const rendererRpc = new Rpc(rendererEvents)
|
||||
|
||||
// Export socket instance for error monitoring
|
||||
export const browserSocket = socket
|
||||
|
||||
// In browser mode, the backend is on the server
|
||||
// For compatibility, export same instances (renderer communicates with server backend via socket)
|
||||
export const backendEvents = rendererEvents
|
||||
export const backendRpc = rendererRpc
|
||||
|
||||
// Re-export all events from the events module so imports work correctly
|
||||
export * from '../../events/Events'
|
||||
export * from '../../events/EventsV2'
|
||||
export * from '../../events/EventSystem/EventDispatcher'
|
||||
export * from '../../events/EventSystem/EventBusInterface'
|
||||
@@ -1,4 +0,0 @@
|
||||
import { electronRendererTelementry } from 'electron-telemetry'
|
||||
|
||||
const spareMeFromGc = electronRendererTelementry
|
||||
electronRendererTelementry.registerErrorHandler()
|
||||
@@ -0,0 +1,164 @@
|
||||
import ConfirmationDialog from './ConfirmationDialog'
|
||||
import ConnectionSetup from './ConnectionSetup/ConnectionSetup'
|
||||
import CssBaseline from '@mui/material/CssBaseline'
|
||||
import ErrorBoundary from './ErrorBoundary'
|
||||
import Notification from './Layout/Notification'
|
||||
import React from 'react'
|
||||
import TitleBar from './Layout/TitleBar'
|
||||
import UpdateNotifier from './UpdateNotifier'
|
||||
import { AppState } from '../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { ConfirmationRequest } from '../reducers/Global'
|
||||
import { connect } from 'react-redux'
|
||||
import { globalActions, settingsActions } from '../actions'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
;(window as any).global = window
|
||||
|
||||
const Settings = React.lazy(() => import('./SettingsDrawer/Settings'))
|
||||
const ContentView = React.lazy(() => import('./Layout/ContentView'))
|
||||
|
||||
interface Props {
|
||||
connectionId: string
|
||||
classes: any
|
||||
settingsVisible: boolean
|
||||
error?: string
|
||||
notification?: string
|
||||
actions: typeof globalActions
|
||||
settingsActions: typeof settingsActions
|
||||
launching: boolean
|
||||
confirmationRequests: Array<ConfirmationRequest>
|
||||
}
|
||||
|
||||
class App extends React.PureComponent<Props, {}> {
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = {}
|
||||
}
|
||||
|
||||
private renderNotification() {
|
||||
const message = this.props.error || this.props.notification
|
||||
const isError = message === this.props.error
|
||||
if (message) {
|
||||
// Guard in case someone ever calls showError with an error instead of a string
|
||||
const str = typeof message === 'string' ? message : JSON.stringify(message)
|
||||
return (
|
||||
<Notification
|
||||
message={str}
|
||||
type={isError ? 'error' : 'notification'}
|
||||
onClose={() => {
|
||||
isError ? this.props.actions.showError(undefined) : this.props.actions.showNotification(undefined)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
this.props.settingsActions.loadSettings()
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { settingsVisible } = this.props
|
||||
const { content, contentShift, centerContent, paneDefaults, heightProperty } = this.props.classes
|
||||
|
||||
if (this.props.launching) {
|
||||
return null
|
||||
}
|
||||
|
||||
const anyProps: any = {}
|
||||
|
||||
return (
|
||||
<div className={centerContent}>
|
||||
<CssBaseline />
|
||||
<ErrorBoundary>
|
||||
<ConfirmationDialog confirmationRequests={this.props.confirmationRequests} />
|
||||
{this.renderNotification()}
|
||||
<React.Suspense fallback={<div></div>}>
|
||||
<Settings {...anyProps} />
|
||||
</React.Suspense>
|
||||
<div className={centerContent}>
|
||||
<div className={`${settingsVisible ? contentShift : content}`}>
|
||||
<TitleBar />
|
||||
</div>
|
||||
<div className={settingsVisible ? contentShift : content}>
|
||||
<React.Suspense fallback={<div></div>}>
|
||||
<ContentView
|
||||
heightProperty={heightProperty}
|
||||
connectionId={this.props.connectionId}
|
||||
paneDefaults={paneDefaults}
|
||||
/>
|
||||
</React.Suspense>
|
||||
</div>
|
||||
</div>
|
||||
<UpdateNotifier />
|
||||
<ConnectionSetup />
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => {
|
||||
const drawerWidth = 300
|
||||
const contentBaseStyle = {
|
||||
width: '100vw',
|
||||
backgroundColor: theme.palette.background.default,
|
||||
}
|
||||
|
||||
return {
|
||||
heightProperty: {
|
||||
height: '100%', // 'calc(100vh - 64px) !important',
|
||||
},
|
||||
paneDefaults: {
|
||||
backgroundColor: theme.palette.background.default,
|
||||
color: theme.palette.text.primary,
|
||||
display: 'block' as 'block',
|
||||
height: 'calc(100vh - 64px)',
|
||||
},
|
||||
centerContent: {
|
||||
width: '100vw',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
},
|
||||
content: {
|
||||
...contentBaseStyle,
|
||||
transition: theme.transitions.create('transform', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
transform: 'translateX(0px)',
|
||||
},
|
||||
contentShift: {
|
||||
...contentBaseStyle,
|
||||
backgroundColor: theme.palette.background.default,
|
||||
transition: theme.transitions.create('transform', {
|
||||
easing: theme.transitions.easing.easeOut,
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
transform: `translateX(${drawerWidth}px)`,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: bindActionCreators(globalActions, dispatch),
|
||||
settingsActions: bindActionCreators(settingsActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
settingsVisible: state.globalState.get('settingsVisible'),
|
||||
connectionId: state.connection.connectionId,
|
||||
error: state.globalState.get('error'),
|
||||
notification: state.globalState.get('notification'),
|
||||
highlightTopicUpdates: state.settings.get('highlightTopicUpdates'),
|
||||
launching: state.globalState.get('launching'),
|
||||
confirmationRequests: state.globalState.get('confirmationRequests'),
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(App))
|
||||
@@ -1,132 +0,0 @@
|
||||
import * as React from 'react'
|
||||
import * as q from '../../../backend/src/Model'
|
||||
|
||||
import { AppState } from '../reducers'
|
||||
import { Typography } from '@material-ui/core'
|
||||
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import { connect } from 'react-redux'
|
||||
import { TopicViewModel } from '../TopicViewModel'
|
||||
const abbreviate = require('number-abbreviate')
|
||||
|
||||
interface Stats {
|
||||
topic: string
|
||||
title: string
|
||||
}
|
||||
|
||||
const styles: StyleRulesCallback = theme => ({
|
||||
flex: {
|
||||
display: 'flex',
|
||||
width: '100%',
|
||||
},
|
||||
container: {
|
||||
width: '100%',
|
||||
height: '224px',
|
||||
backgroundColor: 'rebeccapurple',
|
||||
marginBottom: 0,
|
||||
marginTop: 'auto',
|
||||
padding: '8px',
|
||||
},
|
||||
})
|
||||
|
||||
interface Props {
|
||||
classes: any
|
||||
tree?: q.Tree<TopicViewModel>
|
||||
}
|
||||
|
||||
class BrokerStatistics extends React.Component<Props, {}> {
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = {}
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { tree, classes } = this.props
|
||||
if (!tree) {
|
||||
return null
|
||||
}
|
||||
|
||||
const stats: any = {
|
||||
broker: {
|
||||
topic: '$SYS/broker/version',
|
||||
title: 'Broker',
|
||||
},
|
||||
clients: {
|
||||
topic: '$SYS/broker/clients/total',
|
||||
title: 'Clients',
|
||||
},
|
||||
subscriptions: {
|
||||
topic: '$SYS/broker/subscriptions/count',
|
||||
title: 'Subscriptions',
|
||||
},
|
||||
received: {
|
||||
topic: '$SYS/broker/messages/received',
|
||||
title: 'Received',
|
||||
},
|
||||
sent: {
|
||||
topic: '$SYS/broker/messages/sent',
|
||||
title: 'Sent',
|
||||
},
|
||||
received5m: {
|
||||
topic: '$SYS/broker/load/messages/received/5min',
|
||||
title: 'Received last 5min',
|
||||
},
|
||||
sent5m: {
|
||||
topic: '$SYS/broker/load/messages/sent/5min',
|
||||
title: 'Sent 5m',
|
||||
},
|
||||
heap: {
|
||||
topic: '$SYS/broker/heap/current',
|
||||
title: 'Memory',
|
||||
},
|
||||
heapMax: {
|
||||
topic: '$SYS/broker/heap/maximum',
|
||||
title: 'Memory (max)',
|
||||
},
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
{this.renderStat(tree, stats.broker)}
|
||||
{this.renderPair(tree, stats.sent, stats.received)}
|
||||
{this.renderPair(tree, stats.clients, stats.subscriptions)}
|
||||
{this.renderPair(tree, stats.sent5m, stats.received5m)}
|
||||
{this.renderPair(tree, stats.heap, stats.heapMax)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private renderPair(tree: q.Tree<TopicViewModel>, a: Stats, b: Stats) {
|
||||
return (
|
||||
<div className={this.props.classes.flex}>
|
||||
<div style={{ flex: 1 }}>{this.renderStat(tree, a)}</div>
|
||||
<div style={{ flex: 1 }}>{this.renderStat(tree, b)}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
public renderStat(tree: q.Tree<TopicViewModel>, stat: Stats) {
|
||||
const node = tree.findNode(stat.topic)
|
||||
if (!node) {
|
||||
return null
|
||||
}
|
||||
|
||||
let value = node.message && node.message.value
|
||||
value = !isNaN(value) ? abbreviate(value) : value
|
||||
|
||||
return (
|
||||
<div key={stat.title}>
|
||||
<Typography><b>{stat.title}</b></Typography>
|
||||
<Typography style={{ paddingLeft: '8px' }}><i>{value}</i></Typography>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
tree: state.connection.tree,
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(connect(mapStateToProps)(BrokerStatistics))
|
||||
@@ -0,0 +1,149 @@
|
||||
import * as React from 'react'
|
||||
import { LoginDialog } from './LoginDialog'
|
||||
import { updateSocketAuth, connectSocket } from '../browserEventBus'
|
||||
import { isBrowserMode } from '../utils/browserMode'
|
||||
import { AuthContext } from '../contexts/AuthContext'
|
||||
|
||||
interface BrowserAuthWrapperProps {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export function BrowserAuthWrapper(props: BrowserAuthWrapperProps) {
|
||||
const [isAuthenticated, setIsAuthenticated] = React.useState(false)
|
||||
const [loginError, setLoginError] = React.useState<string | undefined>()
|
||||
const [showLogin, setShowLogin] = React.useState(false)
|
||||
const [waitTimeSeconds, setWaitTimeSeconds] = React.useState<number | undefined>()
|
||||
const [isConnecting, setIsConnecting] = React.useState(false)
|
||||
const [authCheckComplete, setAuthCheckComplete] = React.useState(false)
|
||||
const [authDisabled, setAuthDisabled] = React.useState(false)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isBrowserMode) {
|
||||
// Not in browser mode, skip authentication
|
||||
setIsAuthenticated(true)
|
||||
setAuthCheckComplete(true)
|
||||
return
|
||||
}
|
||||
|
||||
// Listen for auth status from socket connection
|
||||
const handleAuthStatus = (event: CustomEvent) => {
|
||||
const { authDisabled } = event.detail
|
||||
setAuthDisabled(authDisabled)
|
||||
|
||||
if (authDisabled) {
|
||||
// Authentication is disabled on server
|
||||
console.log('Authentication is disabled on server, skipping login')
|
||||
setIsAuthenticated(true)
|
||||
setShowLogin(false)
|
||||
setAuthCheckComplete(true)
|
||||
} else {
|
||||
// Authentication is enabled, check if we have credentials
|
||||
setAuthCheckComplete(true)
|
||||
|
||||
const username = sessionStorage.getItem('mqtt-explorer-username')
|
||||
const password = sessionStorage.getItem('mqtt-explorer-password')
|
||||
|
||||
if (username && password) {
|
||||
// Credentials exist, connection will authenticate automatically
|
||||
setIsConnecting(true)
|
||||
} else {
|
||||
// No credentials, show login dialog
|
||||
setShowLogin(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for successful authentication from socket
|
||||
const handleAuthSuccess = (event: CustomEvent) => {
|
||||
console.log('Authentication successful')
|
||||
setIsAuthenticated(true)
|
||||
setShowLogin(false)
|
||||
setLoginError(undefined)
|
||||
setWaitTimeSeconds(undefined)
|
||||
setIsConnecting(false)
|
||||
}
|
||||
|
||||
// Listen for authentication errors from socket
|
||||
const handleAuthError = (event: CustomEvent) => {
|
||||
const errorMessage = event.detail?.message || 'Authentication failed'
|
||||
console.error('Authentication error:', errorMessage)
|
||||
|
||||
// Mark auth check as complete - we now know auth is required
|
||||
setAuthCheckComplete(true)
|
||||
|
||||
// Clear authentication state
|
||||
setIsAuthenticated(false)
|
||||
setShowLogin(true)
|
||||
setIsConnecting(false)
|
||||
|
||||
// Extract wait time from error message (e.g., "Please wait 30 seconds")
|
||||
const waitTimeMatch = errorMessage.match(/(\d+)\s+seconds?/)
|
||||
if (waitTimeMatch) {
|
||||
const seconds = parseInt(waitTimeMatch[1], 10)
|
||||
// Add a few seconds margin to the countdown
|
||||
setWaitTimeSeconds(seconds + 3)
|
||||
} else {
|
||||
setWaitTimeSeconds(undefined)
|
||||
}
|
||||
|
||||
// Set user-friendly error message based on error type
|
||||
// Error messages from server already include wait times
|
||||
if (errorMessage.includes('Too many failed authentication attempts')) {
|
||||
setLoginError(errorMessage)
|
||||
} else if (errorMessage.includes('Invalid credentials')) {
|
||||
setLoginError(errorMessage)
|
||||
} else if (errorMessage.includes('Authentication required')) {
|
||||
setLoginError('Please enter your username and password.')
|
||||
setWaitTimeSeconds(undefined)
|
||||
} else {
|
||||
setLoginError('Authentication failed. Please try again.')
|
||||
setWaitTimeSeconds(undefined)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect socket to trigger auth-status event
|
||||
connectSocket()
|
||||
|
||||
window.addEventListener('mqtt-auth-status', handleAuthStatus as EventListener)
|
||||
window.addEventListener('mqtt-auth-success', handleAuthSuccess as EventListener)
|
||||
window.addEventListener('mqtt-auth-error', handleAuthError as EventListener)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('mqtt-auth-status', handleAuthStatus as EventListener)
|
||||
window.removeEventListener('mqtt-auth-success', handleAuthSuccess as EventListener)
|
||||
window.removeEventListener('mqtt-auth-error', handleAuthError as EventListener)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleLogin = (username: string, password: string) => {
|
||||
try {
|
||||
// Clear any previous error
|
||||
setLoginError(undefined)
|
||||
setWaitTimeSeconds(undefined)
|
||||
setIsConnecting(true)
|
||||
|
||||
// Update socket auth and reconnect (no page reload needed)
|
||||
updateSocketAuth(username, password)
|
||||
} catch (error) {
|
||||
console.error('Failed to update socket auth:', error)
|
||||
setLoginError('Failed to connect. Please try again.')
|
||||
setIsConnecting(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isBrowserMode) {
|
||||
// Not in browser mode, render children directly
|
||||
return <>{props.children}</>
|
||||
}
|
||||
|
||||
// Show nothing while checking auth status to avoid flash
|
||||
if (!authCheckComplete) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <LoginDialog open={showLogin} onLogin={handleLogin} error={loginError} waitTimeSeconds={waitTimeSeconds} />
|
||||
}
|
||||
|
||||
return <AuthContext.Provider value={{ authDisabled }}>{props.children}</AuthContext.Provider>
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { expect } from 'chai'
|
||||
import { renderWithProviders } from '../../utils/spec/testUtils'
|
||||
import Chart from './Chart'
|
||||
|
||||
describe('Chart X-Axis Domain Investigation', () => {
|
||||
it('should spread points across X-axis with sequential timestamps', () => {
|
||||
// Create 5 data points, 1 second (1000ms) apart
|
||||
const now = Date.now()
|
||||
const data = [
|
||||
{ x: now - 4000, y: 20 },
|
||||
{ x: now - 3000, y: 21 },
|
||||
{ x: now - 2000, y: 22 },
|
||||
{ x: now - 1000, y: 23 },
|
||||
{ x: now, y: 24 }
|
||||
]
|
||||
|
||||
const { container } = renderWithProviders(<Chart data={data} />)
|
||||
|
||||
// Find all circle elements (data points)
|
||||
const circles = container.querySelectorAll('svg circle')
|
||||
expect(circles).to.have.length(5)
|
||||
|
||||
// Extract cx (X-position) values
|
||||
const cxValues: number[] = []
|
||||
circles.forEach(circle => {
|
||||
const cx = circle.getAttribute('cx')
|
||||
if (cx) {
|
||||
cxValues.push(parseFloat(cx))
|
||||
}
|
||||
})
|
||||
|
||||
// Log for debugging
|
||||
console.log('\n========== X-AXIS DOMAIN INVESTIGATION ==========')
|
||||
console.log('Data X values (timestamps):')
|
||||
data.forEach((d, i) => console.log(` Point ${i}: ${d.x} (${new Date(d.x).toISOString()})`))
|
||||
console.log(`\nData X range: ${data[data.length - 1].x - data[0].x}ms (${(data[data.length - 1].x - data[0].x) / 1000}s)`)
|
||||
|
||||
console.log('\nRendered circle CX positions:')
|
||||
cxValues.forEach((cx, i) => console.log(` Circle ${i}: cx=${cx.toFixed(2)}px`))
|
||||
|
||||
const minCx = Math.min(...cxValues)
|
||||
const maxCx = Math.max(...cxValues)
|
||||
const cxRange = maxCx - minCx
|
||||
|
||||
console.log(`\nCX position range: ${cxRange.toFixed(2)}px (from ${minCx.toFixed(2)} to ${maxCx.toFixed(2)})`)
|
||||
console.log(`Points per pixel: ${(cxValues.length / cxRange).toFixed(4)}`)
|
||||
|
||||
// Calculate spacing between consecutive points
|
||||
const spacings: number[] = []
|
||||
for (let i = 1; i < cxValues.length; i++) {
|
||||
spacings.push(cxValues[i] - cxValues[i - 1])
|
||||
}
|
||||
console.log('\nSpacing between consecutive points:')
|
||||
spacings.forEach((s, i) => console.log(` ${i} to ${i+1}: ${s.toFixed(2)}px`))
|
||||
|
||||
const avgSpacing = spacings.reduce((a, b) => a + b, 0) / spacings.length
|
||||
console.log(`Average spacing: ${avgSpacing.toFixed(2)}px`)
|
||||
console.log('=================================================\n')
|
||||
|
||||
// Assertions:
|
||||
// 1. Points should be spread out (CX range should be significant, not bunched)
|
||||
expect(cxRange).to.be.greaterThan(50, 'Points should be spread across at least 50px')
|
||||
|
||||
// 2. Points should be in ascending order (left to right)
|
||||
for (let i = 1; i < cxValues.length; i++) {
|
||||
expect(cxValues[i]).to.be.greaterThan(cxValues[i - 1],
|
||||
`Point ${i} (cx=${cxValues[i]}) should be to the right of point ${i-1} (cx=${cxValues[i-1]})`)
|
||||
}
|
||||
|
||||
// 3. Spacing should be relatively uniform (since data points are equally spaced in time)
|
||||
const spacingVariance = spacings.map(s => Math.abs(s - avgSpacing))
|
||||
const maxVariance = Math.max(...spacingVariance)
|
||||
expect(maxVariance).to.be.lessThan(avgSpacing * 0.5,
|
||||
'Spacing between points should be relatively uniform')
|
||||
})
|
||||
|
||||
it('should handle points bunched at far right correctly', () => {
|
||||
// Simulate the "bunched up" scenario with very large timestamps
|
||||
const largeTimestamp = 1703347200000 // Dec 23, 2023
|
||||
const data = [
|
||||
{ x: largeTimestamp, y: 20 },
|
||||
{ x: largeTimestamp + 1000, y: 21 },
|
||||
{ x: largeTimestamp + 2000, y: 22 },
|
||||
{ x: largeTimestamp + 3000, y: 23 },
|
||||
{ x: largeTimestamp + 4000, y: 24 }
|
||||
]
|
||||
|
||||
const { container } = renderWithProviders(<Chart data={data} />)
|
||||
|
||||
const circles = container.querySelectorAll('svg circle')
|
||||
const cxValues: number[] = []
|
||||
circles.forEach(circle => {
|
||||
const cx = circle.getAttribute('cx')
|
||||
if (cx) {
|
||||
cxValues.push(parseFloat(cx))
|
||||
}
|
||||
})
|
||||
|
||||
console.log('\n========== LARGE TIMESTAMP TEST ==========')
|
||||
console.log('Data X values:', data.map(d => d.x))
|
||||
console.log('Rendered CX values:', cxValues.map(v => v.toFixed(2)))
|
||||
|
||||
const minCx = Math.min(...cxValues)
|
||||
const maxCx = Math.max(...cxValues)
|
||||
console.log(`CX range: ${(maxCx - minCx).toFixed(2)}px`)
|
||||
console.log('==========================================\n')
|
||||
|
||||
// Points should still be spread out even with large timestamps
|
||||
expect(maxCx - minCx).to.be.greaterThan(50,
|
||||
'Points with large timestamps should still be spread across the chart')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,514 @@
|
||||
/**
|
||||
* Chart Component Tests
|
||||
*
|
||||
* These tests verify the Chart component functionality including:
|
||||
* - Rendering with various data configurations
|
||||
* - Theme integration
|
||||
* - Interactive features (tooltips, hover states)
|
||||
* - Different curve interpolation types
|
||||
* - Custom domains and ranges
|
||||
* - Responsive behavior
|
||||
*/
|
||||
|
||||
import React from 'react'
|
||||
import { expect } from 'chai'
|
||||
import { describe, it } from 'mocha'
|
||||
import Chart, { Props as ChartProps } from './Chart'
|
||||
import { renderWithProviders, createMockChartData, screen } from '../../utils/spec/testUtils'
|
||||
import { PlotCurveTypes } from '../../reducers/Charts'
|
||||
|
||||
describe('Chart Component', () => {
|
||||
describe('Basic Rendering', () => {
|
||||
it('should render without crashing with valid data', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container).to.exist
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should render NoData component when data is empty', () => {
|
||||
const { container } = renderWithProviders(<Chart data={[]} />, { withTheme: true })
|
||||
|
||||
expect(container).to.exist
|
||||
// NoData component should be rendered
|
||||
const noDataElement = container.querySelector('div')
|
||||
expect(noDataElement).to.exist
|
||||
})
|
||||
|
||||
it('should render chart with correct height', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
const chartContainer = container.querySelector('[style*="height"]') as HTMLElement
|
||||
expect(chartContainer).to.exist
|
||||
expect(chartContainer.style.height).to.equal('150px')
|
||||
})
|
||||
|
||||
it('should render SVG chart elements', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Check for SVG element
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
|
||||
// Check for chart elements (paths for line series)
|
||||
const paths = container.querySelectorAll('path')
|
||||
expect(paths.length).to.be.greaterThan(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Data Visualization', () => {
|
||||
it('should render data points as glyphs', () => {
|
||||
const data = createMockChartData(3)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Check for circles (glyphs representing data points)
|
||||
const circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.be.greaterThan(0)
|
||||
})
|
||||
|
||||
it('should render exact number of data points matching data length', () => {
|
||||
const dataLength = 5
|
||||
const data = createMockChartData(dataLength)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Each data point should render as a circle
|
||||
const circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.equal(dataLength, `Expected ${dataLength} circles for ${dataLength} data points`)
|
||||
|
||||
// Verify each circle has proper attributes
|
||||
circles.forEach((circle, index) => {
|
||||
expect(circle.getAttribute('cx')).to.exist
|
||||
expect(circle.getAttribute('cy')).to.exist
|
||||
expect(circle.getAttribute('r')).to.equal('3')
|
||||
expect(circle.getAttribute('fill')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
it('should position data points with valid coordinates', () => {
|
||||
const data = createMockChartData(3)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
const circles = container.querySelectorAll('circle')
|
||||
circles.forEach((circle) => {
|
||||
const cx = parseFloat(circle.getAttribute('cx') || '0')
|
||||
const cy = parseFloat(circle.getAttribute('cy') || '0')
|
||||
|
||||
// Coordinates should be valid numbers
|
||||
expect(cx).to.be.a('number')
|
||||
expect(cy).to.be.a('number')
|
||||
expect(isNaN(cx)).to.be.false
|
||||
expect(isNaN(cy)).to.be.false
|
||||
|
||||
// Coordinates should be within chart bounds (positive values)
|
||||
expect(cx).to.be.greaterThan(0)
|
||||
expect(cy).to.be.greaterThan(0)
|
||||
})
|
||||
})
|
||||
|
||||
it('should render line connecting data points', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Line series should create a path element
|
||||
const paths = container.querySelectorAll('path')
|
||||
expect(paths.length).to.be.greaterThan(0)
|
||||
})
|
||||
|
||||
it('should handle single data point', () => {
|
||||
const data = [{ x: Date.now(), y: 50 }]
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
const circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.equal(1, 'Single data point should render as one circle')
|
||||
})
|
||||
|
||||
it('should handle large datasets', () => {
|
||||
const data = createMockChartData(100)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
const circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.equal(100, '100 data points should render as 100 circles')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Curve Interpolation', () => {
|
||||
const curveTypes: PlotCurveTypes[] = ['curve', 'linear', 'cubic_basis_spline', 'step_after', 'step_before']
|
||||
|
||||
curveTypes.forEach((interpolation) => {
|
||||
it(`should render with ${interpolation} interpolation`, () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(
|
||||
<Chart data={data} interpolation={interpolation} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
const paths = container.querySelectorAll('path')
|
||||
expect(paths.length).to.be.greaterThan(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Custom Styling', () => {
|
||||
it('should apply custom color', () => {
|
||||
const data = createMockChartData(5)
|
||||
const customColor = '#ff0000'
|
||||
const { container } = renderWithProviders(
|
||||
<Chart data={data} color={customColor} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
// Check if custom color is applied to line or glyphs
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
})
|
||||
|
||||
it('should use theme colors when no custom color provided', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
describe('Custom Domains and Ranges', () => {
|
||||
it('should render with custom Y range', () => {
|
||||
const data = createMockChartData(5)
|
||||
const range: [number, number] = [0, 100]
|
||||
const { container } = renderWithProviders(
|
||||
<Chart data={data} range={range} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should render with custom time range', () => {
|
||||
const data = createMockChartData(5)
|
||||
const timeRangeStart = 60000 // 1 minute
|
||||
const { container } = renderWithProviders(
|
||||
<Chart data={data} timeRangeStart={timeRangeStart} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should render with partial Y range (only min)', () => {
|
||||
const data = createMockChartData(5)
|
||||
const range: [number?, number?] = [0, undefined]
|
||||
const { container } = renderWithProviders(
|
||||
<Chart data={data} range={range} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should render with partial Y range (only max)', () => {
|
||||
const data = createMockChartData(5)
|
||||
const range: [number?, number?] = [undefined, 100]
|
||||
const { container } = renderWithProviders(
|
||||
<Chart data={data} range={range} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
describe('Chart Components', () => {
|
||||
it('should render Y-axis', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Y-axis should be present (look for axis group or tick marks)
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
|
||||
// Axis typically contains text elements for labels
|
||||
const texts = container.querySelectorAll('text')
|
||||
expect(texts.length).to.be.greaterThan(0)
|
||||
})
|
||||
|
||||
it('should render X-axis with time labels', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// X-axis should be present with text labels
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
|
||||
// X-axis has text labels for timestamps
|
||||
const texts = container.querySelectorAll('text')
|
||||
expect(texts.length).to.be.greaterThan(0, 'X-axis and Y-axis should have text labels')
|
||||
|
||||
// At least one text element should contain time format (e.g., contains ":")
|
||||
let hasTimeFormat = false
|
||||
texts.forEach((text) => {
|
||||
if (text.textContent && text.textContent.includes(':')) {
|
||||
hasTimeFormat = true
|
||||
}
|
||||
})
|
||||
expect(hasTimeFormat).to.be.true
|
||||
})
|
||||
|
||||
it('should render both X and Y axes', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
|
||||
// Both axes should render tick marks (lines)
|
||||
const lines = container.querySelectorAll('line')
|
||||
expect(lines.length).to.be.greaterThan(0, 'Axes should render tick marks')
|
||||
|
||||
// Both axes should have labels (text)
|
||||
const texts = container.querySelectorAll('text')
|
||||
expect(texts.length).to.be.greaterThan(2, 'Both axes should have multiple labels')
|
||||
})
|
||||
|
||||
it('should render grid lines', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Grid lines are rendered as line elements
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
})
|
||||
|
||||
it('should have proper chart margins', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
const svg = container.querySelector('svg')
|
||||
expect(svg).to.exist
|
||||
|
||||
// SVG should have proper dimensions
|
||||
expect(svg?.getAttribute('width')).to.exist
|
||||
expect(svg?.getAttribute('height')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
describe('Edge Cases', () => {
|
||||
it('should handle negative values', () => {
|
||||
const data = [
|
||||
{ x: Date.now() - 2000, y: -50 },
|
||||
{ x: Date.now() - 1000, y: -25 },
|
||||
{ x: Date.now(), y: -75 },
|
||||
]
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should handle zero values', () => {
|
||||
const data = [
|
||||
{ x: Date.now() - 2000, y: 0 },
|
||||
{ x: Date.now() - 1000, y: 0 },
|
||||
{ x: Date.now(), y: 0 },
|
||||
]
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should handle very large numbers', () => {
|
||||
const data = [
|
||||
{ x: Date.now() - 2000, y: 1000000 },
|
||||
{ x: Date.now() - 1000, y: 2000000 },
|
||||
{ x: Date.now(), y: 3000000 },
|
||||
]
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
// Y-axis should abbreviate large numbers
|
||||
const texts = container.querySelectorAll('text')
|
||||
expect(texts.length).to.be.greaterThan(0)
|
||||
})
|
||||
|
||||
it('should handle identical values', () => {
|
||||
const data = [
|
||||
{ x: Date.now() - 2000, y: 50 },
|
||||
{ x: Date.now() - 1000, y: 50 },
|
||||
{ x: Date.now(), y: 50 },
|
||||
]
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
describe('Component Props', () => {
|
||||
it('should accept all valid props without errors', () => {
|
||||
const data = createMockChartData(5)
|
||||
const props: ChartProps = {
|
||||
data,
|
||||
interpolation: 'curve',
|
||||
range: [0, 100],
|
||||
timeRangeStart: 60000,
|
||||
color: '#00ff00',
|
||||
}
|
||||
|
||||
const { container } = renderWithProviders(<Chart {...props} />, { withTheme: true })
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
it('should work with minimal props', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
describe('Theme Integration', () => {
|
||||
it('should render in light theme', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { container } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
|
||||
// Note: Testing dark theme would require a custom theme provider
|
||||
// This demonstrates how the test structure supports theme variations
|
||||
})
|
||||
|
||||
describe('Performance', () => {
|
||||
it('should memoize component with same props', () => {
|
||||
const data = createMockChartData(5)
|
||||
const { rerender } = renderWithProviders(<Chart data={data} />, { withTheme: true })
|
||||
|
||||
// Component should not re-render with same props due to React.memo
|
||||
expect(() => {
|
||||
rerender(<Chart data={data} />)
|
||||
}).to.not.throw()
|
||||
})
|
||||
|
||||
it('should handle rapid data updates', () => {
|
||||
const { rerender, container } = renderWithProviders(
|
||||
<Chart data={createMockChartData(5)} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
// Simulate rapid updates
|
||||
for (let i = 0; i < 10; i++) {
|
||||
rerender(<Chart data={createMockChartData(5)} />)
|
||||
}
|
||||
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
})
|
||||
})
|
||||
|
||||
describe('Interactive Data Updates', () => {
|
||||
it('should dynamically update when data points are added', () => {
|
||||
// Start with 3 data points
|
||||
const initialData = createMockChartData(3)
|
||||
const { rerender, container } = renderWithProviders(
|
||||
<Chart data={initialData} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
// Verify initial state: should have 3 data points
|
||||
const initialCircles = container.querySelectorAll('circle')
|
||||
expect(initialCircles.length).to.equal(3, 'Should initially render 3 data points')
|
||||
|
||||
// Verify each initial circle has valid attributes
|
||||
initialCircles.forEach((circle, index) => {
|
||||
const cx = circle.getAttribute('cx')
|
||||
const cy = circle.getAttribute('cy')
|
||||
const r = circle.getAttribute('r')
|
||||
|
||||
expect(cx).to.exist
|
||||
expect(cy).to.exist
|
||||
expect(r).to.equal('3')
|
||||
expect(parseFloat(cx!)).to.be.a('number').and.not.NaN
|
||||
expect(parseFloat(cy!)).to.be.a('number').and.not.NaN
|
||||
})
|
||||
|
||||
// Update state: add 2 more data points (total 5)
|
||||
const updatedData = createMockChartData(5)
|
||||
rerender(<Chart data={updatedData} />)
|
||||
|
||||
// Verify updated state: should now have 5 data points
|
||||
const updatedCircles = container.querySelectorAll('circle')
|
||||
expect(updatedCircles.length).to.equal(5, 'Should render 5 data points after update')
|
||||
|
||||
// Verify each updated circle has valid attributes
|
||||
updatedCircles.forEach((circle, index) => {
|
||||
const cx = circle.getAttribute('cx')
|
||||
const cy = circle.getAttribute('cy')
|
||||
const r = circle.getAttribute('r')
|
||||
const fill = circle.getAttribute('fill')
|
||||
|
||||
expect(cx).to.exist
|
||||
expect(cy).to.exist
|
||||
expect(r).to.equal('3')
|
||||
expect(fill).to.exist
|
||||
expect(parseFloat(cx!)).to.be.a('number').and.not.NaN
|
||||
expect(parseFloat(cy!)).to.be.a('number').and.not.NaN
|
||||
expect(parseFloat(cy!)).to.be.greaterThan(0, 'Y coordinate should be positive')
|
||||
})
|
||||
|
||||
// Verify the line path is updated to connect all 5 points
|
||||
const linePath = container.querySelector('path[stroke]')
|
||||
expect(linePath).to.exist
|
||||
expect(linePath!.getAttribute('d')).to.exist
|
||||
|
||||
// The path should start with MoveTo (M) command and contain curve/line commands
|
||||
const pathData = linePath!.getAttribute('d')
|
||||
expect(pathData).to.include('M') // MoveTo command for first point
|
||||
// Path may contain 'L' (line) or 'C' (curve) commands depending on interpolation
|
||||
expect(pathData!.length).to.be.greaterThan(10, 'Path should have substantial data for 5 points')
|
||||
})
|
||||
|
||||
it('should handle data point removal', () => {
|
||||
// Start with 5 data points
|
||||
const initialData = createMockChartData(5)
|
||||
const { rerender, container } = renderWithProviders(
|
||||
<Chart data={initialData} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
// Verify initial state
|
||||
let circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.equal(5, 'Should initially render 5 data points')
|
||||
|
||||
// Remove 2 data points (now 3)
|
||||
const reducedData = createMockChartData(3)
|
||||
rerender(<Chart data={reducedData} />)
|
||||
|
||||
// Verify reduced state
|
||||
circles = container.querySelectorAll('circle')
|
||||
expect(circles.length).to.equal(3, 'Should render 3 data points after removal')
|
||||
})
|
||||
|
||||
it('should maintain chart structure during data updates', () => {
|
||||
const initialData = createMockChartData(3)
|
||||
const { rerender, container } = renderWithProviders(
|
||||
<Chart data={initialData} />,
|
||||
{ withTheme: true }
|
||||
)
|
||||
|
||||
// Verify chart structure exists initially
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
expect(container.querySelectorAll('line').length).to.be.greaterThan(0, 'Should have axis/grid lines')
|
||||
expect(container.querySelectorAll('text').length).to.be.greaterThan(0, 'Should have axis labels')
|
||||
|
||||
// Update data
|
||||
const updatedData = createMockChartData(5)
|
||||
rerender(<Chart data={updatedData} />)
|
||||
|
||||
// Verify chart structure is maintained after update
|
||||
expect(container.querySelector('svg')).to.exist
|
||||
expect(container.querySelectorAll('line').length).to.be.greaterThan(0, 'Should still have axis/grid lines')
|
||||
expect(container.querySelectorAll('text').length).to.be.greaterThan(0, 'Should still have axis labels')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,166 @@
|
||||
import DateFormatter from '../helper/DateFormatter'
|
||||
import NoData from './NoData'
|
||||
import NumberFormatter from '../helper/NumberFormatter'
|
||||
import React, { memo, useCallback, useMemo } from 'react'
|
||||
import TooltipComponent from './TooltipComponent'
|
||||
import { useResizeDetector } from 'react-resize-detector'
|
||||
import { emphasize, useTheme } from '@mui/material/styles'
|
||||
import { mapCurveType } from './mapCurveType'
|
||||
import { PlotCurveTypes } from '../../reducers/Charts'
|
||||
import { Point, Tooltip } from './Model'
|
||||
import { useCustomXDomain } from './effects/useCustomXDomain'
|
||||
import { useCustomYDomain } from './effects/useCustomYDomain'
|
||||
import { XYChart, Axis, Grid, LineSeries, GlyphSeries } from '@visx/xychart'
|
||||
const abbreviate = require('number-abbreviate')
|
||||
|
||||
export interface Props {
|
||||
data: Array<{ x: number; y: number }>
|
||||
interpolation?: PlotCurveTypes
|
||||
range?: [number?, number?]
|
||||
timeRangeStart?: number
|
||||
color?: string
|
||||
}
|
||||
|
||||
const CHART_HEIGHT = 150
|
||||
|
||||
export default memo((props: Props) => {
|
||||
const theme = useTheme()
|
||||
const [tooltip, setTooltip] = React.useState<Tooltip | undefined>()
|
||||
const [hoveredPoint, setHoveredPoint] = React.useState<Point | undefined>()
|
||||
const { width = 300, ref } = useResizeDetector()
|
||||
const chartContainerRef = React.useRef<HTMLDivElement>(null)
|
||||
|
||||
const hintFormatter = React.useCallback(
|
||||
(point: any) => [
|
||||
{ title: <b>Time</b>, value: <DateFormatter timeFirst={true} date={new Date(point.x)} /> },
|
||||
{ title: <b>Value</b>, value: <NumberFormatter value={point.y} /> },
|
||||
{ title: <b>Raw</b>, value: <span>{point.y}</span> },
|
||||
],
|
||||
[]
|
||||
)
|
||||
|
||||
const onMouseLeave = React.useCallback(() => {
|
||||
setTooltip(undefined)
|
||||
setHoveredPoint(undefined)
|
||||
}, [])
|
||||
|
||||
const showTooltip = React.useCallback(
|
||||
(point: Point) => {
|
||||
if (!chartContainerRef.current) {
|
||||
return
|
||||
}
|
||||
setHoveredPoint(point)
|
||||
setTooltip({ point, value: hintFormatter(point), element: chartContainerRef.current })
|
||||
},
|
||||
[hintFormatter]
|
||||
)
|
||||
|
||||
const paletteColor =
|
||||
theme.palette.mode === 'light' ? theme.palette.secondary.dark : theme.palette.primary.light
|
||||
const color = props.color ? props.color : paletteColor
|
||||
|
||||
const highlightSelectedPoint = useCallback(
|
||||
(point: Point) => {
|
||||
const highlight = hoveredPoint && hoveredPoint.x === point.x && hoveredPoint.y === point.y
|
||||
return highlight ? emphasize(color, 0.8) : color
|
||||
},
|
||||
[hoveredPoint, color]
|
||||
)
|
||||
|
||||
const formatYAxis = useCallback((num: number) => abbreviate(num), [])
|
||||
|
||||
const formatXAxis = useCallback((timestamp: number) => {
|
||||
const date = new Date(timestamp)
|
||||
const hours = date.getHours().toString().padStart(2, '0')
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0')
|
||||
const seconds = date.getSeconds().toString().padStart(2, '0')
|
||||
return `${hours}:${minutes}:${seconds}`
|
||||
}, [])
|
||||
|
||||
const xDomain = useCustomXDomain(props)
|
||||
const yDomain = useCustomYDomain(props)
|
||||
|
||||
const data = props.data
|
||||
const hasData = data.length > 0
|
||||
const dummyDomain: [number, number] = [-1, 1]
|
||||
const dummyData = [{ x: -2, y: -2 }]
|
||||
|
||||
const accessors = useMemo(
|
||||
() => ({
|
||||
xAccessor: (d: Point) => d.x,
|
||||
yAccessor: (d: Point) => d.y,
|
||||
}),
|
||||
[]
|
||||
)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div ref={ref} style={{ height: `${CHART_HEIGHT}px`, width: '100%', position: 'relative' }}>
|
||||
{data.length === 0 ? <NoData /> : null}
|
||||
<div ref={chartContainerRef}>
|
||||
<XYChart
|
||||
width={width || 300}
|
||||
height={CHART_HEIGHT}
|
||||
margin={{ top: 10, right: 10, bottom: 30, left: 50 }}
|
||||
xScale={{ type: 'time', domain: xDomain || dummyDomain }}
|
||||
yScale={{ type: 'linear', domain: hasData ? yDomain : dummyDomain }}
|
||||
onPointerOut={onMouseLeave}
|
||||
>
|
||||
<Grid rows={true} columns={false} stroke={theme.palette.divider} strokeOpacity={0.3} />
|
||||
<Axis
|
||||
orientation="left"
|
||||
numTicks={5}
|
||||
tickFormat={formatYAxis}
|
||||
stroke={theme.palette.text.secondary}
|
||||
tickStroke={theme.palette.text.secondary}
|
||||
tickLabelProps={() => ({ fontSize: 11, fill: theme.palette.text.secondary })}
|
||||
/>
|
||||
<Axis
|
||||
orientation="bottom"
|
||||
numTicks={4}
|
||||
tickFormat={formatXAxis}
|
||||
stroke={theme.palette.text.secondary}
|
||||
tickStroke={theme.palette.text.secondary}
|
||||
tickLabelProps={() => ({ fontSize: 10, fill: theme.palette.text.secondary, textAnchor: 'middle' })}
|
||||
/>
|
||||
<LineSeries
|
||||
dataKey="line"
|
||||
data={hasData ? data : dummyData}
|
||||
xAccessor={accessors.xAccessor}
|
||||
yAccessor={accessors.yAccessor}
|
||||
stroke={color}
|
||||
strokeWidth={2}
|
||||
curve={mapCurveType(props.interpolation)}
|
||||
onPointerMove={(datum) => {
|
||||
if (datum && datum.datum) {
|
||||
const point = datum.datum as Point
|
||||
showTooltip(point)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<GlyphSeries
|
||||
dataKey="points"
|
||||
data={hasData ? data : dummyData}
|
||||
xAccessor={accessors.xAccessor}
|
||||
yAccessor={accessors.yAccessor}
|
||||
renderGlyph={(glyphProps) => {
|
||||
const point = glyphProps.datum as Point
|
||||
const pointColor = highlightSelectedPoint(point)
|
||||
return (
|
||||
<circle
|
||||
cx={glyphProps.x}
|
||||
cy={glyphProps.y}
|
||||
r={3}
|
||||
fill={pointColor}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</XYChart>
|
||||
</div>
|
||||
{/* Custom tooltip outside of visx to maintain exact same appearance */}
|
||||
<TooltipComponent tooltip={tooltip} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface Point {
|
||||
x: number
|
||||
y: number
|
||||
}
|
||||
|
||||
export interface Tooltip {
|
||||
value: Array<TooltipRows>
|
||||
point: Point
|
||||
element: Element | null
|
||||
}
|
||||
|
||||
export interface TooltipRows {
|
||||
title: React.ReactElement
|
||||
value: React.ReactElement
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import React, { memo } from 'react'
|
||||
import { Typography } from '@mui/material'
|
||||
|
||||
function NoData() {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height: '100%',
|
||||
position: 'absolute',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
width: '100%',
|
||||
color: '#ccc',
|
||||
verticalAlign: 'middle',
|
||||
paddingLeft: '30px',
|
||||
zIndex: 10,
|
||||
}}
|
||||
>
|
||||
<Typography style={{ fontWeight: 'bold' }} variant="h5">
|
||||
No Data
|
||||
</Typography>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(NoData)
|
||||
@@ -0,0 +1,60 @@
|
||||
import React, { memo } from 'react'
|
||||
import { alpha as fade, useTheme } from '@mui/material/styles'
|
||||
import { Fade, Grow, Paper, Popper, Typography } from '@mui/material'
|
||||
import { Tooltip } from './Model'
|
||||
|
||||
function TooltipComponent(props: { tooltip?: Tooltip }) {
|
||||
const theme = useTheme()
|
||||
const { tooltip } = props
|
||||
return (
|
||||
<Popper
|
||||
style={Boolean(tooltip) ? { transition: 'all 0.1s ease-out' } : undefined}
|
||||
open={Boolean(tooltip)}
|
||||
transition={true}
|
||||
placement="top"
|
||||
anchorEl={tooltip && tooltip.element}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
paddingBottom: '8px',
|
||||
transition: 'all 0.5s ease',
|
||||
}}
|
||||
>
|
||||
<Fade in={Boolean(tooltip)} timeout={300}>
|
||||
<Grow in={Boolean(tooltip)} timeout={300}>
|
||||
<Paper
|
||||
style={{
|
||||
padding: '4px',
|
||||
marginTop: '-12px',
|
||||
backgroundColor: fade(
|
||||
theme.palette.mode === 'light'
|
||||
? theme.palette.background.paper
|
||||
: theme.palette.background.default,
|
||||
0.7
|
||||
),
|
||||
}}
|
||||
>
|
||||
<table style={{ lineHeight: '1.25em' }}>
|
||||
<tbody>
|
||||
{tooltip &&
|
||||
tooltip.value.map((v: any, idx: number) => (
|
||||
<tr key={idx}>
|
||||
<td>
|
||||
<Typography style={{ lineHeight: '1.2' }}>{v.title}</Typography>
|
||||
</td>
|
||||
<td>
|
||||
<Typography style={{ lineHeight: '1.2' }}>{v.value}</Typography>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</Paper>
|
||||
</Grow>
|
||||
</Fade>
|
||||
</div>
|
||||
</Popper>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(TooltipComponent)
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Props } from '../Chart'
|
||||
|
||||
export function useCustomXDomain(props: Props): [number, number] | undefined {
|
||||
return useMemo(() => {
|
||||
if (props.data.length === 0) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const lastDataPoint = [...props.data].sort((a, b) => b.x - a.x)[0]
|
||||
const lastDataDate = lastDataPoint ? lastDataPoint.x : Date.now()
|
||||
|
||||
if (props.timeRangeStart) {
|
||||
// Custom time range mode
|
||||
return [Date.now() - props.timeRangeStart, lastDataDate]
|
||||
} else {
|
||||
// Auto-calculate from data (like react-vis did)
|
||||
const xValues = props.data.map(d => d.x)
|
||||
const minX = Math.min(...xValues)
|
||||
const maxX = Math.max(...xValues)
|
||||
return [minX, maxX]
|
||||
}
|
||||
}, [props.data, props.timeRangeStart])
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Props } from '../Chart'
|
||||
import { useMemo } from 'react'
|
||||
import { Point } from '../Model'
|
||||
|
||||
function defaultFor(a: number | undefined, b: number) {
|
||||
return a === undefined ? b : a
|
||||
}
|
||||
|
||||
export function useCustomYDomain(props: Props) {
|
||||
return useMemo(() => {
|
||||
const data = props.data
|
||||
const calculatedDomain = domainForData(data)
|
||||
const yDomain: [number, number] = props.range
|
||||
? [defaultFor(props.range[0], calculatedDomain[0]), defaultFor(props.range[1], calculatedDomain[1])]
|
||||
: calculatedDomain
|
||||
|
||||
return yDomain
|
||||
}, [props.data, props.range])
|
||||
}
|
||||
|
||||
function domainForData(data: Array<Point>): [number, number] {
|
||||
if (!data[0]) {
|
||||
const defaultDomain: [number, number] = [-1, 1]
|
||||
return defaultDomain
|
||||
}
|
||||
|
||||
let max = data[0].y
|
||||
let min = data[0].y
|
||||
|
||||
data.forEach(d => {
|
||||
if (max < d.y) {
|
||||
max = d.y
|
||||
}
|
||||
if (min > d.y) {
|
||||
min = d.y
|
||||
}
|
||||
})
|
||||
if ((max === 1 || max === 0) && (min === 1 || min === 0)) {
|
||||
return [0, 1]
|
||||
}
|
||||
if (min === max) {
|
||||
return [min - 0.5 * min, min + 0.5 * min]
|
||||
}
|
||||
return [min, max]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { PlotCurveTypes } from '../../reducers/Charts'
|
||||
import * as d3Shape from 'd3-shape'
|
||||
|
||||
export function mapCurveType(type: PlotCurveTypes | undefined) {
|
||||
switch (type) {
|
||||
case 'curve':
|
||||
return d3Shape.curveMonotoneX
|
||||
case 'linear':
|
||||
return d3Shape.curveLinear
|
||||
case 'cubic_basis_spline':
|
||||
return d3Shape.curveBasis
|
||||
case 'step_after':
|
||||
return d3Shape.curveStepAfter
|
||||
case 'step_before':
|
||||
return d3Shape.curveStepBefore
|
||||
default:
|
||||
return d3Shape.curveMonotoneX
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import React, { useRef } from 'react'
|
||||
import Play from '@mui/icons-material/PlayArrow'
|
||||
import Pause from '@mui/icons-material/PauseCircleFilled'
|
||||
import Clear from '@mui/icons-material/Clear'
|
||||
import CustomIconButton from '../helper/CustomIconButton'
|
||||
import { ChartParameters } from '../../reducers/Charts'
|
||||
import { SettingsButton } from './ChartSettings/SettingsButton'
|
||||
|
||||
export function ChartActions(props: {
|
||||
paused: boolean
|
||||
togglePause: () => void
|
||||
parameters: ChartParameters
|
||||
onRemove: () => void
|
||||
resetDataAction: () => void
|
||||
}) {
|
||||
const menuAnchor = useRef()
|
||||
return (
|
||||
<div style={{ display: 'flex' }}>
|
||||
<CustomIconButton tooltip={props.paused ? 'Resume chart' : 'Pause chart'} onClick={props.togglePause}>
|
||||
{props.paused ? <Play /> : <Pause />}
|
||||
</CustomIconButton>
|
||||
<SettingsButton menuAnchor={menuAnchor} parameters={props.parameters} resetDataAction={props.resetDataAction} />
|
||||
<CustomIconButton tooltip="Remove chart" onClick={props.onRemove}>
|
||||
<Clear data-test-type="RemoveChart" data-test={`${props.parameters.topic}-${props.parameters.dotPath || ''}`} />
|
||||
</CustomIconButton>
|
||||
<div style={{ width: 0, overflow: 'hidden' }}>
|
||||
{/* Helper element to provide an anchor element for the menu,
|
||||
* so the menu prefers not to overlap with the chart
|
||||
*/}
|
||||
<div style={{ marginLeft: '11px' }} ref={menuAnchor as any} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import React, { memo } from 'react'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { chartActions } from '../../../actions'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
import { connect } from 'react-redux'
|
||||
import { Menu, MenuItem } from '@mui/material'
|
||||
import { colors as createColors } from './colors'
|
||||
|
||||
function chartParametersForColor(chart: ChartParameters, color?: string) {
|
||||
return {
|
||||
color,
|
||||
topic: chart.topic,
|
||||
dotPath: chart.dotPath,
|
||||
}
|
||||
}
|
||||
|
||||
const colors: Array<string> = createColors()
|
||||
|
||||
function ColorSettings(props: {
|
||||
chart: ChartParameters
|
||||
actions: {
|
||||
chart: typeof chartActions
|
||||
}
|
||||
anchorEl?: Element
|
||||
open: boolean
|
||||
close: () => void
|
||||
}) {
|
||||
const setColor = React.useCallback(
|
||||
(color?: string) => props.actions.chart.updateChart(chartParametersForColor(props.chart, color)),
|
||||
[props.chart]
|
||||
)
|
||||
|
||||
const menuItems = React.useMemo(() => {
|
||||
return colors.map(color => (
|
||||
<MenuItem
|
||||
style={{ minWidth: '8em', minHeight: '36px', backgroundColor: color, textAlign: 'center' }}
|
||||
key={color}
|
||||
onClick={() => setColor(color)}
|
||||
>
|
||||
{props.chart.color === color ? 'X' : ''}
|
||||
</MenuItem>
|
||||
))
|
||||
}, [colors, props.chart])
|
||||
|
||||
return (
|
||||
<Menu anchorEl={props.anchorEl} open={props.open} onClose={props.close}>
|
||||
<MenuItem
|
||||
style={{ minWidth: '8em', minHeight: '36px', textAlign: 'center' }}
|
||||
key="none"
|
||||
onClick={() => setColor()}
|
||||
selected={props.chart.color === undefined}
|
||||
>
|
||||
default
|
||||
</MenuItem>
|
||||
{menuItems}
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(memo(ColorSettings))
|
||||
@@ -0,0 +1,68 @@
|
||||
import * as React from 'react'
|
||||
import { AppState } from '../../../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { chartActions } from '../../../actions'
|
||||
import { ChartParameters, PlotCurveTypes } from '../../../reducers/Charts'
|
||||
import { connect } from 'react-redux'
|
||||
import { Menu, MenuItem, Typography } from '@mui/material'
|
||||
|
||||
function chartParametersForAction(chart: ChartParameters, action: string) {
|
||||
return {
|
||||
topic: chart.topic,
|
||||
dotPath: chart.dotPath,
|
||||
interpolation: action as any,
|
||||
}
|
||||
}
|
||||
|
||||
const curves: Array<PlotCurveTypes> = ['curve', 'linear', 'step_after', 'step_before', 'cubic_basis_spline']
|
||||
|
||||
function InterpolationSettings(props: {
|
||||
chart: ChartParameters
|
||||
actions: {
|
||||
chart: typeof chartActions
|
||||
}
|
||||
anchorEl?: Element
|
||||
open: boolean
|
||||
close: () => void
|
||||
}) {
|
||||
const callbacks = React.useMemo(() => {
|
||||
const createCurveCallback = (curve: PlotCurveTypes) => () => {
|
||||
props.actions.chart.updateChart(chartParametersForAction(props.chart, curve))
|
||||
}
|
||||
|
||||
const callbacks: { [key: string]: () => void } = {}
|
||||
for (const curve of curves) {
|
||||
callbacks[curve] = createCurveCallback(curve)
|
||||
}
|
||||
return callbacks
|
||||
}, [curves])
|
||||
|
||||
const menuItems = React.useMemo(() => {
|
||||
return curves.map(curve => (
|
||||
<MenuItem
|
||||
key={curve}
|
||||
onClick={callbacks[curve]}
|
||||
selected={props.chart.interpolation === curve}
|
||||
data-menu-item={curve.replace(/_/g, ' ')}
|
||||
>
|
||||
<Typography variant="inherit">{curve.replace(/_/g, ' ')}</Typography>
|
||||
</MenuItem>
|
||||
))
|
||||
}, [curves, props.chart])
|
||||
|
||||
return (
|
||||
<Menu anchorEl={props.anchorEl} open={props.open} onClose={props.close}>
|
||||
{menuItems}
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(InterpolationSettings)
|
||||
@@ -0,0 +1,36 @@
|
||||
import * as React from 'react'
|
||||
import ArrowUpward from '@mui/icons-material/ArrowUpward'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { chartActions } from '../../../actions'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
import { connect } from 'react-redux'
|
||||
import { MenuItem, Typography, ListItemIcon } from '@mui/material'
|
||||
|
||||
function MoveUp(props: { actions: { chart: typeof chartActions }; chart: ChartParameters; close: () => void }) {
|
||||
const moveUp = React.useCallback(() => {
|
||||
props.actions.chart.moveChartUp({
|
||||
topic: props.chart.topic,
|
||||
dotPath: props.chart.dotPath,
|
||||
})
|
||||
props.close()
|
||||
}, [props.chart])
|
||||
|
||||
return (
|
||||
<MenuItem key="size" onClick={moveUp}>
|
||||
<ListItemIcon>
|
||||
<ArrowUpward />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">Move up</Typography>
|
||||
</MenuItem>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(MoveUp)
|
||||
@@ -0,0 +1,117 @@
|
||||
import React, { useCallback, useState, ChangeEvent, MouseEvent, useRef, useEffect, useMemo } from 'react'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
import { Menu, TextField, Typography } from '@mui/material'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { chartActions } from '../../../actions'
|
||||
import { KeyCodes } from '../../../utils/KeyCodes'
|
||||
|
||||
interface Props {
|
||||
actions: { chart: typeof chartActions }
|
||||
chart: ChartParameters
|
||||
anchorEl?: Element
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
function RangeSettings(props: Props) {
|
||||
const dismissClick = useCallback((e: MouseEvent) => e.stopPropagation(), [])
|
||||
const [rangeFrom, setRangeFrom] = useState<string | number | undefined>(props.chart.range && props.chart.range.from)
|
||||
const [rangeTo, setRangeTo] = useState<string | number | undefined>(props.chart.range && props.chart.range.to)
|
||||
useRangeStateToFireUpdateAction(rangeFrom, rangeTo, props)
|
||||
const rangeFromRef = useRef<HTMLInputElement>()
|
||||
const rangeToRef = useRef<HTMLInputElement>()
|
||||
|
||||
useEffect(() => {
|
||||
rangeFromRef.current && rangeFromRef.current.focus()
|
||||
}, [props.open])
|
||||
|
||||
const handleKeyEvents = (e: React.KeyboardEvent<any>) => {
|
||||
if (e.keyCode === KeyCodes.tab) {
|
||||
// Switch focus between those two
|
||||
if (document.activeElement === rangeFromRef.current) {
|
||||
rangeToRef.current && rangeToRef.current.focus()
|
||||
} else {
|
||||
rangeFromRef.current && rangeFromRef.current.focus()
|
||||
}
|
||||
|
||||
// Prevent closing the menu
|
||||
e.stopPropagation()
|
||||
// Prevent default tab behavior (focus/blur)
|
||||
e.preventDefault()
|
||||
} else if (e.keyCode === KeyCodes.enter) {
|
||||
props.onClose()
|
||||
}
|
||||
}
|
||||
|
||||
const setFromHandler = useCallback((e: ChangeEvent<HTMLInputElement>) => setRangeFrom(e.target.value), [])
|
||||
const setToHandler = useCallback((e: ChangeEvent<HTMLInputElement>) => setRangeTo(e.target.value), [])
|
||||
return useMemo(
|
||||
() => (
|
||||
<Menu
|
||||
style={{ textAlign: 'center' }}
|
||||
keepMounted={true}
|
||||
anchorEl={props.anchorEl}
|
||||
open={props.open}
|
||||
onClose={props.onClose}
|
||||
onKeyDownCapture={handleKeyEvents}
|
||||
>
|
||||
<div style={{ padding: '0 16px', width: '275px' }}>
|
||||
<Typography>Define custom ranges for the Y-Axis</Typography>
|
||||
<TextField
|
||||
inputProps={{
|
||||
ref: rangeFromRef,
|
||||
}}
|
||||
autoFocus={true}
|
||||
style={{ marginTop: '0' }}
|
||||
label="from"
|
||||
value={rangeFrom}
|
||||
onChange={setFromHandler}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextField
|
||||
inputProps={{
|
||||
ref: rangeToRef,
|
||||
}}
|
||||
style={{ marginLeft: '8px', marginTop: '0' }}
|
||||
onClick={dismissClick}
|
||||
label="to"
|
||||
value={rangeTo}
|
||||
onChange={setToHandler}
|
||||
margin="normal"
|
||||
/>
|
||||
</div>
|
||||
</Menu>
|
||||
),
|
||||
[rangeFrom, rangeTo, props.open]
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(RangeSettings)
|
||||
|
||||
function useRangeStateToFireUpdateAction(
|
||||
rangeFrom: string | number | undefined,
|
||||
rangeTo: string | number | undefined,
|
||||
props: Props
|
||||
) {
|
||||
React.useEffect(() => {
|
||||
const from = parseFloat(rangeFrom as any)
|
||||
const to = parseFloat(rangeTo as any)
|
||||
props.actions.chart.updateChart({
|
||||
topic: props.chart.topic,
|
||||
dotPath: props.chart.dotPath,
|
||||
range: {
|
||||
from: isNaN(from) ? undefined : from,
|
||||
to: isNaN(to) ? undefined : to,
|
||||
},
|
||||
})
|
||||
}, [rangeFrom, rangeTo])
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as React from 'react'
|
||||
import ChartSettings from '.'
|
||||
import CustomIconButton from '../../helper/CustomIconButton'
|
||||
import MoreVertIcon from '@mui/icons-material/Settings'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
|
||||
export function SettingsButton(props: {
|
||||
parameters: ChartParameters
|
||||
resetDataAction: () => void
|
||||
menuAnchor: React.MutableRefObject<undefined>
|
||||
}) {
|
||||
const [visible, setVisible] = React.useState(false)
|
||||
const toggleSettings = React.useCallback(() => {
|
||||
setVisible(!visible)
|
||||
}, [visible])
|
||||
|
||||
const close = React.useCallback(() => {
|
||||
setVisible(false)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<span>
|
||||
<ChartSettings
|
||||
open={visible}
|
||||
close={close}
|
||||
anchorEl={props.menuAnchor}
|
||||
chart={props.parameters}
|
||||
resetDataAction={props.resetDataAction}
|
||||
/>
|
||||
<CustomIconButton tooltip="Chart settings" onClick={toggleSettings}>
|
||||
<MoreVertIcon
|
||||
data-test-type="ChartSettings"
|
||||
data-test={`${props.parameters.topic}-${props.parameters.dotPath || ''}`}
|
||||
/>
|
||||
</CustomIconButton>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import React, { memo } from 'react'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
import { Menu, MenuItem, TextField, Typography } from '@mui/material'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { chartActions } from '../../../actions'
|
||||
|
||||
function Size(props: {
|
||||
actions: { chart: typeof chartActions }
|
||||
chart: ChartParameters
|
||||
anchorEl?: Element
|
||||
open: boolean
|
||||
close: () => void
|
||||
}) {
|
||||
const setChartWidth = (width?: 'big' | 'medium' | 'small') => () => {
|
||||
props.actions.chart.updateChart({
|
||||
width,
|
||||
topic: props.chart.topic,
|
||||
dotPath: props.chart.dotPath,
|
||||
})
|
||||
props.close()
|
||||
}
|
||||
|
||||
return (
|
||||
<Menu anchorEl={props.anchorEl} open={props.open} onClose={props.close}>
|
||||
<MenuItem selected={props.chart.width === undefined} onClick={setChartWidth()}>
|
||||
<Typography variant="inherit">auto</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem selected={props.chart.width === 'big'} onClick={setChartWidth('big')}>
|
||||
<Typography variant="inherit">100% width</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem selected={props.chart.width === 'medium'} onClick={setChartWidth('medium')}>
|
||||
<Typography variant="inherit">50% width</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem selected={props.chart.width === 'small'} onClick={setChartWidth('small')}>
|
||||
<Typography variant="inherit">33% width</Typography>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(memo(Size))
|
||||
@@ -0,0 +1,99 @@
|
||||
import React, { ChangeEvent, MouseEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Button, Menu, TextField, Typography } from '@mui/material'
|
||||
import { chartActions } from '../../../actions'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
import { connect } from 'react-redux'
|
||||
const parseDuration = require('parse-duration')
|
||||
|
||||
interface Props {
|
||||
actions: { chart: typeof chartActions }
|
||||
chart: ChartParameters
|
||||
anchorEl?: Element
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
function TimeRangeSettings(props: Props) {
|
||||
const dismissClick = useCallback((e: MouseEvent) => e.stopPropagation(), [])
|
||||
const [value, setValue] = useState<string | undefined>(
|
||||
props.chart.timeRange ? props.chart.timeRange.until : undefined
|
||||
)
|
||||
const ranges = ['all', '10s', '30s', '1m', '5m', '15m', '1h', '6h', '1d']
|
||||
|
||||
const manuallySetIntervalHandler = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setValue(e.target.value)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!value) {
|
||||
props.actions.chart.updateChart({
|
||||
...props.chart,
|
||||
timeRange: undefined,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const canBeParsed = Boolean(parseDuration(value))
|
||||
if (canBeParsed) {
|
||||
props.actions.chart.updateChart({
|
||||
...props.chart,
|
||||
timeRange: {
|
||||
until: value,
|
||||
},
|
||||
})
|
||||
}
|
||||
}, [value])
|
||||
|
||||
return useMemo(() => {
|
||||
const createRangeHandler = (range: string) => (e: React.MouseEvent) => setValue(range === 'all' ? undefined : range)
|
||||
|
||||
return (
|
||||
<Menu
|
||||
style={{ textAlign: 'center' }}
|
||||
keepMounted={true}
|
||||
anchorEl={props.anchorEl}
|
||||
open={props.open}
|
||||
onClose={props.onClose}
|
||||
>
|
||||
<Typography>Chart data within a time interval</Typography>
|
||||
<div style={{ padding: '0 16px', width: '275px', textAlign: 'center' }}>
|
||||
{ranges.map(r => {
|
||||
return (
|
||||
<Button
|
||||
style={{ margin: '4px', textTransform: 'none' }}
|
||||
variant="contained"
|
||||
key={r}
|
||||
onClick={createRangeHandler(r)}
|
||||
>
|
||||
{r}
|
||||
</Button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<Typography style={{ fontSize: '0.75em' }}>
|
||||
<i>Limited to 500 data points</i>
|
||||
</Typography>
|
||||
<br />
|
||||
<TextField
|
||||
style={{ marginLeft: '8px', marginTop: '0' }}
|
||||
onClick={dismissClick}
|
||||
label="custom interval"
|
||||
value={value || ''}
|
||||
onChange={manuallySetIntervalHandler}
|
||||
margin="normal"
|
||||
/>
|
||||
</Menu>
|
||||
)
|
||||
}, [value, props.open])
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(TimeRangeSettings)
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
amber,
|
||||
orange,
|
||||
pink,
|
||||
purple,
|
||||
deepPurple,
|
||||
teal,
|
||||
red,
|
||||
green,
|
||||
lime,
|
||||
indigo,
|
||||
yellow,
|
||||
brown,
|
||||
blueGrey,
|
||||
} from '@mui/material/colors'
|
||||
|
||||
export function colors() {
|
||||
function colorToInt(color: string): [number, number, number] {
|
||||
const str = color.replace('#', '')
|
||||
return [parseInt(str.slice(0, 2), 16), parseInt(str.slice(2, 4), 16), parseInt(str.slice(4, 6), 16)]
|
||||
}
|
||||
function colorCompare(colorA: string, colorB: string) {
|
||||
const a = colorToInt(colorA)
|
||||
const b = colorToInt(colorB)
|
||||
return Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1] - b[1], 2) + Math.pow(a[2] - b[2], 2))
|
||||
}
|
||||
const colors: Array<string> = [
|
||||
brown,
|
||||
blueGrey,
|
||||
amber,
|
||||
orange,
|
||||
pink,
|
||||
purple,
|
||||
deepPurple,
|
||||
teal,
|
||||
red,
|
||||
green,
|
||||
lime,
|
||||
indigo,
|
||||
yellow,
|
||||
]
|
||||
.map(color => [color[200], color[500], color[700]])
|
||||
.reduce((a, b) => a.concat(b), [])
|
||||
.sort((a, b) => colorCompare(a, b))
|
||||
return colors
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import BarChart from '@mui/icons-material/BarChart'
|
||||
import Clear from '@mui/icons-material/Refresh'
|
||||
import ColorLens from '@mui/icons-material/ColorLens'
|
||||
import ColorSettings from './ColorSettings'
|
||||
import InterpolationSettings from './InterpolationSettings'
|
||||
import MoveUp from './MoveUp'
|
||||
import MultilineChart from '@mui/icons-material/MultilineChart'
|
||||
import RangeSettings from './RangeSettings'
|
||||
import React, { memo } from 'react'
|
||||
import Size from './Size'
|
||||
import Sort from '@mui/icons-material/Sort'
|
||||
import TimeRangeSettings from './TimeRangeSettings'
|
||||
import { ChartParameters } from '../../../reducers/Charts'
|
||||
import { Menu, MenuItem, ListItemIcon, Typography } from '@mui/material'
|
||||
|
||||
function ChartSettings(props: {
|
||||
open: boolean
|
||||
close: () => void
|
||||
resetDataAction: () => void
|
||||
chart: ChartParameters
|
||||
anchorEl: React.MutableRefObject<undefined>
|
||||
}) {
|
||||
const [rangeVisible, setRangeVisible] = React.useState(false)
|
||||
const [timeRangeVisible, setTimeRangeVisible] = React.useState(false)
|
||||
const [interpolationVisible, setInterpolationVisible] = React.useState(false)
|
||||
const [sizeVisible, setSizeVisible] = React.useState(false)
|
||||
const [colorVisible, setColorVisible] = React.useState(false)
|
||||
const open = props.open
|
||||
|
||||
const toggleRange = React.useCallback(() => {
|
||||
if (open) {
|
||||
props.close()
|
||||
}
|
||||
setRangeVisible(!rangeVisible)
|
||||
}, [rangeVisible, open])
|
||||
|
||||
const toggleTimeRange = React.useCallback(() => {
|
||||
if (open) {
|
||||
props.close()
|
||||
}
|
||||
setTimeRangeVisible(!timeRangeVisible)
|
||||
}, [timeRangeVisible, open])
|
||||
|
||||
const toggleInterpolation = React.useCallback(() => {
|
||||
if (open) {
|
||||
props.close()
|
||||
}
|
||||
setInterpolationVisible(!interpolationVisible)
|
||||
}, [interpolationVisible, open])
|
||||
|
||||
const toggleSize = React.useCallback(() => {
|
||||
if (open) {
|
||||
props.close()
|
||||
}
|
||||
setSizeVisible(!sizeVisible)
|
||||
}, [sizeVisible, open])
|
||||
|
||||
const toggleColor = React.useCallback(() => {
|
||||
if (open) {
|
||||
props.close()
|
||||
}
|
||||
setColorVisible(!colorVisible)
|
||||
}, [colorVisible, open])
|
||||
|
||||
return (
|
||||
<span>
|
||||
<Menu id="long-menu" anchorEl={props.anchorEl.current} open={props.open} onClose={props.close}>
|
||||
<MenuItem key="range" onClick={toggleRange} data-menu-item="Y-Axis range (Values)">
|
||||
<ListItemIcon>
|
||||
<BarChart />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">Y-Axis range (Values)</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem key="timeRange" onClick={toggleTimeRange} data-menu-item="X-Axis range (Time)">
|
||||
<ListItemIcon>
|
||||
<BarChart />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">X-Axis range (Time)</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem key="interpolation" onClick={toggleInterpolation} data-menu-item="Curve interpolation">
|
||||
<ListItemIcon>
|
||||
<MultilineChart />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">Curve interpolation</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem key="size" onClick={toggleSize} data-menu-item="Size">
|
||||
<ListItemIcon>
|
||||
<Sort />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">Size</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem key="color" onClick={toggleColor} data-menu-item="Color">
|
||||
<ListItemIcon>
|
||||
<ColorLens />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">Color</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem key="clear" onClick={props.resetDataAction} data-menu-item="Clear data">
|
||||
<ListItemIcon>
|
||||
<Clear />
|
||||
</ListItemIcon>
|
||||
<Typography variant="inherit">Clear data</Typography>
|
||||
</MenuItem>
|
||||
<MoveUp chart={props.chart} close={props.close} />
|
||||
</Menu>
|
||||
<RangeSettings chart={props.chart} anchorEl={props.anchorEl.current} open={rangeVisible} onClose={toggleRange} />
|
||||
<TimeRangeSettings
|
||||
chart={props.chart}
|
||||
anchorEl={props.anchorEl.current}
|
||||
open={timeRangeVisible}
|
||||
onClose={toggleTimeRange}
|
||||
/>
|
||||
<InterpolationSettings
|
||||
chart={props.chart}
|
||||
anchorEl={props.anchorEl.current}
|
||||
open={interpolationVisible}
|
||||
close={toggleInterpolation}
|
||||
/>
|
||||
<Size chart={props.chart} anchorEl={props.anchorEl.current} open={sizeVisible} close={toggleSize} />
|
||||
<ColorSettings chart={props.chart} anchorEl={props.anchorEl.current} open={colorVisible} close={toggleColor} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(ChartSettings)
|
||||
@@ -0,0 +1,31 @@
|
||||
import * as React from 'react'
|
||||
import { ChartParameters } from '../../reducers/Charts'
|
||||
import { Typography } from '@mui/material'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
|
||||
function ChartTitle(props: { parameters: ChartParameters; classes: any }) {
|
||||
const { classes, parameters } = props
|
||||
return (
|
||||
<div style={{ flexGrow: 1, overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
<Typography variant="caption" className={classes.topic}>
|
||||
{parameters.dotPath ? parameters.dotPath : parameters.topic}
|
||||
</Typography>
|
||||
<br />
|
||||
<Typography variant="caption" className={classes.topic}>
|
||||
{parameters.dotPath ? parameters.topic : <span dangerouslySetInnerHTML={{ __html: ' ' }}></span>}
|
||||
</Typography>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
topic: {
|
||||
wordBreak: 'break-all' as 'break-all',
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
textOverflow: 'ellipsis' as 'ellipsis',
|
||||
},
|
||||
})
|
||||
|
||||
export default withStyles(styles)(ChartTitle)
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as q from '../../../../backend/src/Model'
|
||||
import React from 'react'
|
||||
import TopicChart from './TopicChart'
|
||||
import { ChartParameters } from '../../reducers/Charts'
|
||||
import { usePollingToFetchTreeNode } from '../helper/usePollingToFetchTreeNode'
|
||||
|
||||
interface Props {
|
||||
tree?: q.Tree<any>
|
||||
parameters: ChartParameters
|
||||
}
|
||||
|
||||
export function ChartWithTreeNode(props: Props) {
|
||||
const { tree, parameters } = props
|
||||
if (!tree) {
|
||||
return null
|
||||
}
|
||||
|
||||
const treeNode = usePollingToFetchTreeNode(tree, parameters.topic)
|
||||
return <TopicChart treeNode={treeNode} parameters={parameters} />
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import * as q from '../../../../backend/src/Model'
|
||||
import ChartTitle from './ChartTitle'
|
||||
import React, { useState, useCallback, memo, useRef } from 'react'
|
||||
import TopicPlot from '../TopicPlot'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { ChartActions } from './ChartActions'
|
||||
import { chartActions } from '../../actions'
|
||||
import { ChartParameters } from '../../reducers/Charts'
|
||||
import { connect } from 'react-redux'
|
||||
import { Paper } from '@mui/material'
|
||||
const throttle = require('lodash.throttle')
|
||||
|
||||
class ClearableMessageBuffer extends q.RingBuffer<q.Message> {
|
||||
public clear() {
|
||||
this.items = []
|
||||
this.start = 0
|
||||
this.end = 0
|
||||
}
|
||||
|
||||
public static fromMessageBuffer(buffer: q.RingBuffer<q.Message>): ClearableMessageBuffer {
|
||||
return new ClearableMessageBuffer(buffer.capacity, buffer.maxItems, buffer.compactionFactor, buffer)
|
||||
}
|
||||
|
||||
public clone(): ClearableMessageBuffer {
|
||||
return ClearableMessageBuffer.fromMessageBuffer(this)
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
parameters: ChartParameters
|
||||
treeNode?: q.TreeNode<any>
|
||||
actions: {
|
||||
chart: typeof chartActions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to onMessages, stores more data points then the default
|
||||
*/
|
||||
function useMessageSubscriptionToUpdate(treeNode?: q.TreeNode<any>) {
|
||||
const [lastUpdated, setLastUpdate] = useState(0)
|
||||
const [messageHistory, setMessageHistory] = useState<ClearableMessageBuffer | undefined>()
|
||||
let amendMessageCallback: any
|
||||
|
||||
function subscribeToMessageUpdates() {
|
||||
const throttledUpdate = throttle(() => setLastUpdate(treeNode ? treeNode.lastUpdate : 0), 300)
|
||||
|
||||
if (treeNode) {
|
||||
const newMessageHistory = ClearableMessageBuffer.fromMessageBuffer(treeNode.messageHistory)
|
||||
newMessageHistory.setCapacity(500, 2 * 500 * 10000)
|
||||
|
||||
amendMessageCallback = (message: q.Message) => {
|
||||
newMessageHistory.add(message)
|
||||
throttledUpdate()
|
||||
}
|
||||
treeNode.onMessage.subscribe(amendMessageCallback)
|
||||
setMessageHistory(newMessageHistory)
|
||||
}
|
||||
|
||||
return function cleanup() {
|
||||
treeNode && treeNode.onMessage.unsubscribe(amendMessageCallback)
|
||||
setMessageHistory(undefined)
|
||||
}
|
||||
}
|
||||
React.useEffect(subscribeToMessageUpdates, [treeNode])
|
||||
|
||||
return messageHistory
|
||||
}
|
||||
|
||||
function useResetDataCallback(messageHistory: ClearableMessageBuffer | undefined) {
|
||||
const [lastUpdated, setLastUpdate] = useState(0)
|
||||
|
||||
return React.useCallback(() => {
|
||||
messageHistory && messageHistory.clear()
|
||||
setLastUpdate(Date.now())
|
||||
}, [messageHistory])
|
||||
}
|
||||
|
||||
function TopicChart(props: Props) {
|
||||
const { parameters, treeNode } = props
|
||||
const [frozenHistory, setFrozenHistory] = useState<q.MessageHistory | undefined>()
|
||||
const messageHistory = useMessageSubscriptionToUpdate(treeNode)
|
||||
|
||||
const togglePause = useCallback(() => {
|
||||
if (!treeNode) {
|
||||
return
|
||||
}
|
||||
|
||||
setFrozenHistory(frozenHistory ? undefined : messageHistory && messageHistory.clone())
|
||||
}, [props.treeNode, frozenHistory, messageHistory])
|
||||
|
||||
const onRemove = React.useCallback(() => {
|
||||
props.actions.chart.removeChart(props.parameters)
|
||||
}, [props.parameters])
|
||||
|
||||
const resetData = useResetDataCallback(messageHistory)
|
||||
|
||||
return (
|
||||
<Paper
|
||||
style={{ padding: '8px' }}
|
||||
data-test-type="ChartPaper"
|
||||
data-test={`${props.parameters.topic}-${props.parameters.dotPath || ''}`}
|
||||
>
|
||||
<div style={{ display: 'flex' }}>
|
||||
<div style={{ display: 'flex', flexGrow: 1, overflow: 'hidden' }}>
|
||||
<ChartTitle parameters={parameters} />
|
||||
<ChartActions
|
||||
resetDataAction={resetData}
|
||||
parameters={parameters}
|
||||
onRemove={onRemove}
|
||||
paused={Boolean(frozenHistory)}
|
||||
togglePause={togglePause}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<TopicPlot
|
||||
node={props.treeNode ? props.treeNode : undefined}
|
||||
color={props.parameters.color}
|
||||
interpolation={props.parameters.interpolation}
|
||||
timeInterval={props.parameters.timeRange ? props.parameters.timeRange.until : undefined}
|
||||
range={props.parameters.range ? [props.parameters.range.from, props.parameters.range.to] : undefined}
|
||||
history={frozenHistory || messageHistory || new ClearableMessageBuffer(1)}
|
||||
dotPath={parameters.dotPath}
|
||||
/>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(memo(TopicChart))
|
||||
@@ -0,0 +1,161 @@
|
||||
import * as q from '../../../../backend/src/Model'
|
||||
import * as React from 'react'
|
||||
import ShowChart from '@mui/icons-material/ShowChart'
|
||||
import { AppState } from '../../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { chartActions } from '../../actions'
|
||||
import { ChartParameters } from '../../reducers/Charts'
|
||||
import { ChartWithTreeNode } from './ChartWithTreeNode'
|
||||
import { connect } from 'react-redux'
|
||||
import { Grid, Typography } from '@mui/material'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { List } from 'immutable'
|
||||
const { TransitionGroup, CSSTransition } = require('react-transition-group/esm')
|
||||
|
||||
interface Props {
|
||||
charts: List<ChartParameters>
|
||||
connectionId?: string
|
||||
tree?: q.Tree<any>
|
||||
actions: {
|
||||
chart: typeof chartActions
|
||||
}
|
||||
classes: any
|
||||
}
|
||||
|
||||
function spacingForChartCount(count: number): 4 | 6 | 12 {
|
||||
if (count >= 5) {
|
||||
return 4
|
||||
} else if (count >= 2) {
|
||||
return 6
|
||||
} else {
|
||||
return 12
|
||||
}
|
||||
}
|
||||
|
||||
function mapWidth(width: 'big' | 'medium' | 'small' | undefined, calculatedSpacing: 4 | 6 | 12): 4 | 6 | 12 {
|
||||
switch (width) {
|
||||
case 'big':
|
||||
return 12
|
||||
case 'medium':
|
||||
return 6
|
||||
case 'small':
|
||||
return 4
|
||||
default:
|
||||
return calculatedSpacing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Helper function to generate unique keys for charts
|
||||
const getChartKey = (chart: ChartParameters) => `${chart.topic}-${chart.dotPath || ''}`
|
||||
|
||||
function ChartPanel(props: Props) {
|
||||
const chartsInView = props.charts.count()
|
||||
|
||||
const [spacing, setSpacing] = React.useState(spacingForChartCount(chartsInView))
|
||||
const nodeRefsMap = React.useRef<Map<string, React.RefObject<HTMLDivElement>>>(new Map())
|
||||
|
||||
React.useEffect(() => {
|
||||
props.actions.chart.loadCharts()
|
||||
}, [props.connectionId])
|
||||
|
||||
// Update spacing after animations have completed
|
||||
React.useEffect(() => {
|
||||
const newSpacing = spacingForChartCount(chartsInView)
|
||||
if (newSpacing > spacing) {
|
||||
setTimeout(() => setSpacing(newSpacing), 500)
|
||||
} else {
|
||||
setSpacing(newSpacing)
|
||||
}
|
||||
}, [chartsInView])
|
||||
|
||||
// Clean up refs for removed charts
|
||||
React.useEffect(() => {
|
||||
const currentKeys = new Set(props.charts.map(getChartKey).toArray())
|
||||
const refsToDelete: string[] = []
|
||||
|
||||
nodeRefsMap.current.forEach((_, key) => {
|
||||
if (!currentKeys.has(key)) {
|
||||
refsToDelete.push(key)
|
||||
}
|
||||
})
|
||||
|
||||
refsToDelete.forEach(key => nodeRefsMap.current.delete(key))
|
||||
}, [props.charts])
|
||||
|
||||
const charts = props.charts.map(chartParameters => {
|
||||
const key = getChartKey(chartParameters)
|
||||
|
||||
// Get or create a ref for this specific chart
|
||||
if (!nodeRefsMap.current.has(key)) {
|
||||
nodeRefsMap.current.set(key, React.createRef<HTMLDivElement>())
|
||||
}
|
||||
const nodeRef = nodeRefsMap.current.get(key)!
|
||||
|
||||
return (
|
||||
<CSSTransition
|
||||
key={key}
|
||||
timeout={{ enter: 500, exit: 500 }}
|
||||
classNames="example"
|
||||
nodeRef={nodeRef}
|
||||
>
|
||||
<Grid item xs={mapWidth(chartParameters.width, spacing)} ref={nodeRef}>
|
||||
<ChartWithTreeNode tree={props.tree} parameters={chartParameters} />
|
||||
</Grid>
|
||||
</CSSTransition>
|
||||
)
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={props.classes.container}>
|
||||
<Grid container spacing={1}>
|
||||
<TransitionGroup component={null} className="example">
|
||||
{charts}
|
||||
</TransitionGroup>
|
||||
{chartsInView === 0 ? <NoCharts key="noCharts" /> : null}
|
||||
</Grid>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function NoCharts() {
|
||||
return (
|
||||
<div style={{ width: '100%', textAlign: 'center' }}>
|
||||
<Typography variant="h2">No charts selected</Typography>
|
||||
<Typography>Select a numeric values from the value preview.</Typography>
|
||||
<Typography>
|
||||
Click on <ShowChart /> to add a topic / value to this panel.
|
||||
</Typography>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
charts: state.charts.get('charts'),
|
||||
connectionId: state.connection.connectionId,
|
||||
tree: state.connection.tree,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
chart: bindActionCreators(chartActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
container: {
|
||||
backgroundColor: theme.palette.background.default,
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
padding: '8px',
|
||||
flex: 1,
|
||||
overflow: 'hidden scroll',
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ChartPanel) as any)
|
||||
@@ -0,0 +1,61 @@
|
||||
import React, { useRef, useCallback, memo } from 'react'
|
||||
import { ConfirmationRequest } from '../reducers/Global'
|
||||
import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material'
|
||||
import { KeyCodes } from '../utils/KeyCodes'
|
||||
|
||||
function ConfirmationDialog(props: { confirmationRequests: Array<ConfirmationRequest> }) {
|
||||
const request = props.confirmationRequests[0]
|
||||
const yesRef = useRef<HTMLButtonElement>()
|
||||
const noRef = useRef<HTMLButtonElement>()
|
||||
const arrowKeyHandler = useCallback((event: React.KeyboardEvent) => {
|
||||
const isArrowKey = event.keyCode === KeyCodes.arrow_left || event.keyCode === KeyCodes.arrow_right
|
||||
if (!isArrowKey) {
|
||||
return
|
||||
}
|
||||
|
||||
event.stopPropagation()
|
||||
if (document.activeElement === noRef.current) {
|
||||
yesRef.current && yesRef.current.focus()
|
||||
} else {
|
||||
noRef.current && noRef.current.focus()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const confirm = React.useCallback(() => {
|
||||
request && request.callback(true)
|
||||
}, [request])
|
||||
const reject = React.useCallback(() => {
|
||||
request && request.callback(false)
|
||||
}, [request])
|
||||
|
||||
if (!request) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={true}
|
||||
onClose={reject}
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
onKeyDown={arrowKeyHandler}
|
||||
>
|
||||
<DialogTitle id="alert-dialog-title">{request.title}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description" style={{ whiteSpace: 'pre-wrap' }}>
|
||||
{request.inquiry}
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button ref={yesRef as any} variant="contained" onClick={confirm} color="primary" autoFocus>
|
||||
Yes
|
||||
</Button>
|
||||
<Button ref={noRef as any} variant="contained" onClick={reject} color="secondary" style={{ marginLeft: '8px' }}>
|
||||
No
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(ConfirmationDialog)
|
||||
@@ -0,0 +1,136 @@
|
||||
import * as React from 'react'
|
||||
import { useState, useCallback, memo } from 'react'
|
||||
import Add from '@mui/icons-material/Add'
|
||||
import Lock from '@mui/icons-material/Lock'
|
||||
import Undo from '@mui/icons-material/Undo'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionManagerActions } from '../../actions'
|
||||
import { ConnectionOptions } from '../../model/ConnectionOptions'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { Button, Grid, TextField, Tooltip } from '@mui/material'
|
||||
import { QosSelect } from '../QosSelect'
|
||||
import { QoS } from '../../../../backend/src/DataSource/MqttSource'
|
||||
import Subscriptions from './Subscriptions'
|
||||
const SubscriptionsAny = Subscriptions as any
|
||||
|
||||
interface Props {
|
||||
connection: ConnectionOptions
|
||||
classes: any
|
||||
managerActions: typeof connectionManagerActions
|
||||
}
|
||||
|
||||
const ConnectionSettings = memo(function ConnectionSettings(props: Props) {
|
||||
const [qos, setQos] = useState<QoS>(0)
|
||||
const [topic, setTopic] = useState('')
|
||||
const { classes } = props
|
||||
|
||||
const updateSubscription = useCallback(
|
||||
(event: React.ChangeEvent<HTMLInputElement>) => setTopic(event.target.value),
|
||||
[]
|
||||
)
|
||||
|
||||
const handleChange = useCallback(
|
||||
(name: string) => (event: any) => {
|
||||
props.managerActions.updateConnection(props.connection.id, {
|
||||
[name]: event.target.value,
|
||||
})
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<form className={classes.container} noValidate={true} autoComplete="off">
|
||||
<Grid container={true} spacing={3}>
|
||||
<Grid item={true} xs={8} className={classes.gridPadding}>
|
||||
<TextField
|
||||
className={`${classes.fullWidth} advanced-connection-settings-topic-input`}
|
||||
label="Topic"
|
||||
placeholder="example/topic"
|
||||
margin="normal"
|
||||
value={topic}
|
||||
onChange={updateSubscription}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={2} className={classes.gridPadding}>
|
||||
<div className={classes.qos}>
|
||||
<QosSelect label="QoS" selected={qos} onChange={setQos} />
|
||||
</div>
|
||||
</Grid>
|
||||
<Grid item={true} xs={2} className={classes.gridPadding}>
|
||||
<Button
|
||||
className={classes.button}
|
||||
color="secondary"
|
||||
onClick={() => props.managerActions.addSubscription({ topic, qos }, props.connection.id)}
|
||||
variant="contained"
|
||||
data-testid="add-subscription-button"
|
||||
>
|
||||
<Add /> Add
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item={true} xs={12} style={{ padding: 0 }}>
|
||||
<SubscriptionsAny connection={props.connection} />
|
||||
</Grid>
|
||||
<Grid item={true} xs={7} className={classes.gridPadding}>
|
||||
<TextField
|
||||
className={classes.fullWidth}
|
||||
label="MQTT Client ID"
|
||||
margin="normal"
|
||||
value={props.connection.clientId}
|
||||
onChange={handleChange('clientId')}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={3} className={classes.gridPadding}>
|
||||
<div>
|
||||
<Tooltip title="Manage tls connection certificates" placement="top">
|
||||
<Button
|
||||
variant="contained"
|
||||
className={classes.button}
|
||||
onClick={() => props.managerActions.toggleCertificateSettings()}
|
||||
>
|
||||
<Lock /> Certificates
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</Grid>
|
||||
<Grid item={true} xs={2} className={classes.gridPadding}>
|
||||
<Button
|
||||
variant="contained"
|
||||
className={classes.button}
|
||||
onClick={props.managerActions.toggleAdvancedSettings}
|
||||
data-testid="back-button"
|
||||
>
|
||||
<Undo /> Back
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
managerActions: bindActionCreators(connectionManagerActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
fullWidth: {
|
||||
width: '100%',
|
||||
},
|
||||
gridPadding: {
|
||||
padding: '0 12px !important',
|
||||
},
|
||||
button: {
|
||||
marginTop: theme.spacing(3),
|
||||
float: 'right' as 'right',
|
||||
},
|
||||
qos: {
|
||||
marginTop: theme.spacing(1),
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(withStyles(styles)(ConnectionSettings) as any)
|
||||
@@ -0,0 +1,140 @@
|
||||
import * as React from 'react'
|
||||
import ClearAdornment from '../helper/ClearAdornment'
|
||||
import Lock from '@mui/icons-material/Lock'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Button, Theme, Tooltip, Typography } from '@mui/material'
|
||||
import { CertificateParameters, ConnectionOptions } from '../../model/ConnectionOptions'
|
||||
import { CertificateTypes } from '../../actions/ConnectionManager'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionManagerActions } from '../../actions'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { rendererRpc } from '../../../../events'
|
||||
import { RpcEvents } from '../../../../events/EventsV2'
|
||||
|
||||
function BrowserCertificateFileSelection(props: {
|
||||
certificateType: CertificateTypes
|
||||
title: string
|
||||
certificate?: CertificateParameters
|
||||
classes: any
|
||||
actions: {
|
||||
connectionManager: typeof connectionManagerActions
|
||||
}
|
||||
connection: ConnectionOptions
|
||||
}) {
|
||||
const fileInputRef = React.useRef<HTMLInputElement>(null)
|
||||
|
||||
const clearCertificate = React.useCallback(() => {
|
||||
props.actions.connectionManager.updateConnection(props.connection.id, {
|
||||
[props.certificateType]: undefined,
|
||||
})
|
||||
}, [props.connection, props.certificateType])
|
||||
|
||||
const handleFileSelect = React.useCallback(
|
||||
async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = event.target.files?.[0]
|
||||
if (!file) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// Read file content
|
||||
const reader = new FileReader()
|
||||
reader.onload = async e => {
|
||||
const content = e.target?.result
|
||||
if (typeof content === 'string') {
|
||||
// Convert to base64
|
||||
const base64Data = content.split(',')[1] || content
|
||||
|
||||
// Upload via IPC instead of HTTP POST
|
||||
const result = await rendererRpc.call(RpcEvents.uploadCertificate, {
|
||||
filename: file.name,
|
||||
data: base64Data,
|
||||
})
|
||||
|
||||
// Create certificate parameters
|
||||
const certificate: CertificateParameters = {
|
||||
name: result.name,
|
||||
data: result.data,
|
||||
}
|
||||
|
||||
// Update connection
|
||||
props.actions.connectionManager.updateConnection(props.connection.id, {
|
||||
[props.certificateType]: certificate,
|
||||
})
|
||||
}
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
} catch (error) {
|
||||
console.error('Error uploading certificate:', error)
|
||||
}
|
||||
|
||||
// Reset input
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.value = ''
|
||||
}
|
||||
},
|
||||
[props.connection.id, props.certificateType, props.actions.connectionManager]
|
||||
)
|
||||
|
||||
const handleButtonClick = () => {
|
||||
fileInputRef.current?.click()
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept=".pem,.crt,.cer,.key"
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleFileSelect}
|
||||
/>
|
||||
<Tooltip title="Select certificate" placement="top">
|
||||
<Button variant="contained" className={props.classes.button} onClick={handleButtonClick}>
|
||||
<Lock /> {props.title}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<ClearCertificate classes={props.classes} certificate={props.certificate} action={clearCertificate} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function ClearCertificate(props: { classes: any; certificate?: CertificateParameters; action: () => void }) {
|
||||
if (!props.certificate) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip title={props.certificate.name}>
|
||||
<Typography className={props.classes.certificateName}>
|
||||
<ClearAdornment action={props.action} value={props.certificate.name} />
|
||||
{props.certificate.name}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
connectionManager: bindActionCreators(connectionManagerActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
certificateName: {
|
||||
width: '100%',
|
||||
height: 'calc(1em + 4px)',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
textOverflow: 'ellipsis' as 'ellipsis',
|
||||
color: theme.palette.text.secondary,
|
||||
},
|
||||
button: {
|
||||
marginTop: theme.spacing(3),
|
||||
marginRight: theme.spacing(2),
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(withStyles(styles)(BrowserCertificateFileSelection) as any)
|
||||
@@ -0,0 +1,82 @@
|
||||
import * as React from 'react'
|
||||
import ClearAdornment from '../helper/ClearAdornment'
|
||||
import Lock from '@mui/icons-material/Lock'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Button, Theme, Tooltip, Typography } from '@mui/material'
|
||||
import { CertificateParameters, ConnectionOptions } from '../../model/ConnectionOptions'
|
||||
import { CertificateTypes } from '../../actions/ConnectionManager'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionManagerActions } from '../../actions'
|
||||
import { withStyles } from '@mui/styles'
|
||||
|
||||
function CertificateFileSelection(props: {
|
||||
certificateType: CertificateTypes
|
||||
title: string
|
||||
certificate?: CertificateParameters
|
||||
classes: any
|
||||
actions: {
|
||||
connectionManager: typeof connectionManagerActions
|
||||
}
|
||||
connection: ConnectionOptions
|
||||
}) {
|
||||
const clearCertificate = React.useCallback(() => {
|
||||
props.actions.connectionManager.updateConnection(props.connection.id, {
|
||||
[props.certificateType]: undefined,
|
||||
})
|
||||
}, [props.connection, props.certificateType])
|
||||
|
||||
return (
|
||||
<span>
|
||||
<Tooltip title="Select certificate" placement="top">
|
||||
<Button
|
||||
variant="contained"
|
||||
className={props.classes.button}
|
||||
onClick={() => props.actions.connectionManager.selectCertificate(props.certificateType, props.connection.id)}
|
||||
>
|
||||
<Lock /> {props.title}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<ClearCertificate classes={props.classes} certificate={props.certificate} action={clearCertificate} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function ClearCertificate(props: { classes: any; certificate?: CertificateParameters; action: () => void }) {
|
||||
if (!props.certificate) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip title={props.certificate.name}>
|
||||
<Typography className={props.classes.certificateName}>
|
||||
<ClearAdornment action={props.action} value={props.certificate.name} />
|
||||
{props.certificate.name}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
connectionManager: bindActionCreators(connectionManagerActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
certificateName: {
|
||||
width: '100%',
|
||||
height: 'calc(1em + 4px)',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
textOverflow: 'ellipsis' as 'ellipsis',
|
||||
color: theme.palette.text.secondary,
|
||||
},
|
||||
button: {
|
||||
marginTop: theme.spacing(3),
|
||||
marginRight: theme.spacing(2),
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(withStyles(styles)(CertificateFileSelection) as any)
|
||||
@@ -0,0 +1,113 @@
|
||||
import * as React from 'react'
|
||||
import CertificateFileSelection from './CertificateFileSelection'
|
||||
import BrowserCertificateFileSelection from './BrowserCertificateFileSelection'
|
||||
import Undo from '@mui/icons-material/Undo'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Button, Grid } from '@mui/material'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionManagerActions } from '../../actions'
|
||||
import { ConnectionOptions } from '../../model/ConnectionOptions'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { isBrowserMode } from '../../utils/browserMode'
|
||||
|
||||
// Use browser or desktop file selection based on mode
|
||||
const CertSelector: any = isBrowserMode ? BrowserCertificateFileSelection : CertificateFileSelection
|
||||
|
||||
interface Props {
|
||||
connection: ConnectionOptions
|
||||
classes: any
|
||||
managerActions: typeof connectionManagerActions
|
||||
}
|
||||
|
||||
interface State {
|
||||
subscription: string
|
||||
}
|
||||
|
||||
class Certificates extends React.PureComponent<Props, State> {
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = { subscription: '' }
|
||||
}
|
||||
|
||||
private handleChange = (name: string) => (event: any) => {
|
||||
this.props.managerActions.updateConnection(this.props.connection.id, {
|
||||
[name]: event.target.value,
|
||||
})
|
||||
}
|
||||
|
||||
private renderCertificateInfo() {
|
||||
if (!this.props.connection.selfSignedCertificate) {
|
||||
return null
|
||||
}
|
||||
|
||||
return <span />
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { classes } = this.props
|
||||
return (
|
||||
<div>
|
||||
<form noValidate={true} autoComplete="off">
|
||||
<Grid container={true} spacing={3}>
|
||||
<Grid item={true} xs={12} className={classes.gridPadding}>
|
||||
<CertSelector
|
||||
connection={this.props.connection}
|
||||
certificate={this.props.connection.selfSignedCertificate}
|
||||
title="Server Certificate (CA)"
|
||||
certificateType="selfSignedCertificate"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={12} className={classes.gridPadding}>
|
||||
<CertSelector
|
||||
connection={this.props.connection}
|
||||
certificate={this.props.connection.clientCertificate}
|
||||
title="Client Certificate"
|
||||
certificateType="clientCertificate"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={12} className={classes.gridPadding}>
|
||||
<CertSelector
|
||||
connection={this.props.connection}
|
||||
certificate={this.props.connection.clientKey}
|
||||
title="Client Key"
|
||||
certificateType="clientKey"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={2} className={classes.gridPadding}>
|
||||
<br />
|
||||
<Button
|
||||
variant="contained"
|
||||
className={classes.button}
|
||||
onClick={this.props.managerActions.toggleCertificateSettings}
|
||||
>
|
||||
<Undo /> Back
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
managerActions: bindActionCreators(connectionManagerActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
fullWidth: {
|
||||
width: '100%',
|
||||
},
|
||||
gridPadding: {
|
||||
padding: '0 12px !important',
|
||||
},
|
||||
button: {
|
||||
marginTop: theme.spacing(3),
|
||||
marginRight: theme.spacing(2),
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(withStyles(styles)(Certificates) as any)
|
||||
@@ -0,0 +1,25 @@
|
||||
import ConnectionHealthIndicator from '../helper/ConnectionHealthIndicator'
|
||||
import PowerSettingsNew from '@mui/icons-material/PowerSettingsNew'
|
||||
import React from 'react'
|
||||
import { Button } from '@mui/material'
|
||||
|
||||
function ConnectButton(props: { connecting: boolean; classes: any; toggle: () => void }) {
|
||||
const { classes, toggle, connecting } = props
|
||||
|
||||
if (connecting) {
|
||||
return (
|
||||
<Button variant="contained" color="primary" className={classes.button} onClick={toggle} data-testid="abort-button">
|
||||
<ConnectionHealthIndicator />
|
||||
Abort
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Button variant="contained" color="primary" className={classes.button} onClick={toggle} data-testid="connect-button">
|
||||
<PowerSettingsNew /> Connect
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConnectButton
|
||||
@@ -1,395 +0,0 @@
|
||||
import * as React from 'react'
|
||||
|
||||
import {
|
||||
Button,
|
||||
CircularProgress,
|
||||
FormControl,
|
||||
FormControlLabel,
|
||||
Grid,
|
||||
IconButton,
|
||||
Input,
|
||||
InputAdornment,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
Modal,
|
||||
Paper,
|
||||
Switch,
|
||||
TextField,
|
||||
Toolbar,
|
||||
Typography,
|
||||
} from '@material-ui/core'
|
||||
import { connect } from 'react-redux'
|
||||
import { MqttOptions } from '../../../../backend/src/DataSource'
|
||||
import { StyleRulesCallback, Theme, withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import Notification from './Notification'
|
||||
import Visibility from '@material-ui/icons/Visibility'
|
||||
import VisibilityOff from '@material-ui/icons/VisibilityOff'
|
||||
|
||||
const sha1 = require('sha1')
|
||||
import { AppState } from '../../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connectionActions } from '../../actions'
|
||||
|
||||
interface Props {
|
||||
classes: {[s: string]: string}
|
||||
actions: typeof connectionActions,
|
||||
visible: boolean
|
||||
connected: boolean
|
||||
connecting: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
const protocols = [
|
||||
'mqtt://',
|
||||
'ws://',
|
||||
]
|
||||
|
||||
interface State {
|
||||
showPassword: boolean
|
||||
connectionSettings: ConnectionSettings
|
||||
}
|
||||
|
||||
interface ConnectionSettings {
|
||||
host: string
|
||||
protocol: string
|
||||
port: number
|
||||
tls: boolean
|
||||
certValidation: boolean
|
||||
clientId: string
|
||||
connectionId?: string
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
|
||||
declare var window: any
|
||||
|
||||
class Connection extends React.Component<Props, State> {
|
||||
private randomClientId: string
|
||||
private defaultConnectionSettings: ConnectionSettings = {
|
||||
host: 'iot.eclipse.org',
|
||||
protocol: protocols[0],
|
||||
port: 1883,
|
||||
tls: false,
|
||||
certValidation: true,
|
||||
clientId: '',
|
||||
username: '',
|
||||
password: '',
|
||||
connectionId: undefined,
|
||||
}
|
||||
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
|
||||
const clientIdSha = sha1(`${Math.random()}`).slice(0, 8)
|
||||
this.randomClientId = `mqtt-explorer-${clientIdSha}`
|
||||
this.state = {
|
||||
connectionSettings: this.loadConnectionSettings(),
|
||||
showPassword: false,
|
||||
}
|
||||
}
|
||||
|
||||
private loadConnectionSettings(): ConnectionSettings {
|
||||
let storedSettings: ConnectionSettings | undefined
|
||||
|
||||
const storedSettingsString = window.localStorage.getItem('connectionSettings')
|
||||
try {
|
||||
storedSettings = storedSettingsString ? JSON.parse(storedSettingsString) : undefined
|
||||
} catch {
|
||||
window.localStorage.setItem('connectionSettings', undefined)
|
||||
}
|
||||
|
||||
return storedSettings || this.defaultConnectionSettings
|
||||
}
|
||||
|
||||
private saveConnectionSettings() {
|
||||
window.localStorage.setItem('connectionSettings', JSON.stringify(this.state.connectionSettings))
|
||||
}
|
||||
|
||||
private handleClickShowPassword = () => {
|
||||
this.setState({ showPassword: !this.state.showPassword })
|
||||
}
|
||||
|
||||
private optionsFromState(): MqttOptions {
|
||||
const protocol = this.state.connectionSettings.protocol === 'tcp://' ? 'mqtt://' : this.state.connectionSettings.protocol
|
||||
const url = `${protocol}${this.state.connectionSettings.host}:${this.state.connectionSettings.port}`
|
||||
|
||||
return {
|
||||
url,
|
||||
username: this.state.connectionSettings.username || undefined,
|
||||
password: this.state.connectionSettings.password || undefined,
|
||||
clientId: this.state.connectionSettings.clientId || this.randomClientId,
|
||||
tls: this.state.connectionSettings.tls,
|
||||
certValidation: this.state.connectionSettings.certValidation,
|
||||
}
|
||||
}
|
||||
|
||||
public static styles: StyleRulesCallback<string> = (theme: Theme) => {
|
||||
return {
|
||||
root: {
|
||||
minWidth: 550,
|
||||
maxWidth: 650,
|
||||
backgroundColor: theme.palette.background.default,
|
||||
margin: '14vh auto auto auto',
|
||||
padding: `${2 * theme.spacing.unit}px`,
|
||||
outline: 'none',
|
||||
},
|
||||
title: {
|
||||
color: theme.palette.text.primary,
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing.unit * 2,
|
||||
textAlign: 'center',
|
||||
color: theme.palette.text.secondary,
|
||||
},
|
||||
textField: {
|
||||
width: '100%',
|
||||
},
|
||||
switch: {
|
||||
marginTop: `${1 * theme.spacing.unit}px`,
|
||||
},
|
||||
button: {
|
||||
margin: theme.spacing.unit,
|
||||
},
|
||||
inputFormControl: {
|
||||
marginTop: '16px',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
private handleChange = (name: string) => (event: any) => {
|
||||
this.setState({
|
||||
connectionSettings: {
|
||||
...this.state.connectionSettings,
|
||||
[name]: event.target.value,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { classes } = this.props
|
||||
|
||||
const passwordVisibilityButton = (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
aria-label="Toggle password visibility"
|
||||
onClick={this.handleClickShowPassword}
|
||||
>
|
||||
{this.state.showPassword ? <Visibility /> : <VisibilityOff />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
)
|
||||
|
||||
let renderError = null
|
||||
if (this.props.error) {
|
||||
renderError = (
|
||||
<Notification
|
||||
message={this.props.error}
|
||||
onClose={() => { this.props.actions.showError(undefined) }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{renderError}
|
||||
<Modal open={this.props.visible} disableAutoFocus={true}>
|
||||
<Paper className={classes.root}>
|
||||
<Toolbar>
|
||||
<Typography className={classes.title} variant="h6" color="inherit">MQTT Connection</Typography>
|
||||
</Toolbar>
|
||||
<form className={classes.container} noValidate={true} autoComplete="off">
|
||||
<Grid container={true} spacing={24}>
|
||||
<Grid item={true} xs={2}>
|
||||
{this.renderProtocols()}
|
||||
</Grid>
|
||||
<Grid item={true} xs={7}>
|
||||
<TextField
|
||||
label="Host"
|
||||
className={classes.textField}
|
||||
value={this.state.connectionSettings.host}
|
||||
onChange={this.handleChange('host')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={3}>
|
||||
<TextField
|
||||
label="Port"
|
||||
className={classes.textField}
|
||||
value={this.state.connectionSettings.port}
|
||||
onChange={this.handleChange('port')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={5}>
|
||||
<TextField
|
||||
label="Username"
|
||||
className={classes.textField}
|
||||
value={this.state.connectionSettings.username}
|
||||
onChange={this.handleChange('username')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={5}>
|
||||
<FormControl className={`${classes.textField} ${classes.inputFormControl}`}>
|
||||
<InputLabel htmlFor="adornment-password">Password</InputLabel>
|
||||
<Input
|
||||
id="adornment-password"
|
||||
type={this.state.showPassword ? 'text' : 'password'}
|
||||
value={this.state.connectionSettings.password}
|
||||
onChange={this.handleChange('password')}
|
||||
endAdornment={passwordVisibilityButton}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item={true} xs={5}>
|
||||
<FormControl className={`${classes.textField} ${classes.inputFormControl}`}>
|
||||
<InputLabel htmlFor="client-id">Client ID</InputLabel>
|
||||
<Input
|
||||
placeholder={this.randomClientId}
|
||||
className={classes.textField}
|
||||
value={this.state.connectionSettings.clientId || ''}
|
||||
onChange={this.handleChange('clientId')}
|
||||
startAdornment={<span />}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item={true} xs={4}>
|
||||
{this.renderCertValidationSwitch()}
|
||||
</Grid>
|
||||
<Grid item={true} xs={3}>
|
||||
{this.renderTlsSwitch()}
|
||||
</Grid>
|
||||
</Grid>
|
||||
<br />
|
||||
<div style={{ textAlign: 'right' }}>
|
||||
<Button variant="contained" color="secondary" className={classes.button} onClick={() => this.saveConnectionSettings()}>
|
||||
Save
|
||||
</Button>
|
||||
{this.renderConnectButton()}
|
||||
</div>
|
||||
</form>
|
||||
</Paper>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private renderProtocols() {
|
||||
const { classes } = this.props
|
||||
const protocolItems = protocols.map((value: string) => (
|
||||
<MenuItem key={value} value={value}>
|
||||
{value}
|
||||
</MenuItem>
|
||||
))
|
||||
|
||||
return (
|
||||
<TextField
|
||||
select={true}
|
||||
label="Protocol"
|
||||
className={classes.textField}
|
||||
value={this.state.connectionSettings.protocol}
|
||||
onChange={this.handleChange('protocol')}
|
||||
margin="normal"
|
||||
>
|
||||
{protocolItems}
|
||||
</TextField>
|
||||
)
|
||||
}
|
||||
|
||||
private renderCertValidationSwitch() {
|
||||
const { classes } = this.props
|
||||
const certSwitch = (
|
||||
<Switch
|
||||
checked={this.state.connectionSettings.certValidation}
|
||||
onChange={this.toggleCertValidation}
|
||||
color="primary"
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={classes.switch}>
|
||||
<FormControlLabel
|
||||
control={certSwitch}
|
||||
label="Validate certificate"
|
||||
labelPlacement="bottom"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private toggleCertValidation = () => this.setState({
|
||||
connectionSettings: {
|
||||
...this.state.connectionSettings,
|
||||
certValidation: !this.state.connectionSettings.certValidation,
|
||||
},
|
||||
})
|
||||
|
||||
private renderTlsSwitch() {
|
||||
const { classes } = this.props
|
||||
const tlsSwitch = (
|
||||
<Switch
|
||||
checked={this.state.connectionSettings.tls}
|
||||
onChange={this.toggleTls}
|
||||
color="primary"
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={classes.switch}>
|
||||
<FormControlLabel
|
||||
control={tlsSwitch}
|
||||
label="Encryption (tls)"
|
||||
labelPlacement="bottom"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private toggleTls = () => this.setState({
|
||||
connectionSettings: {
|
||||
...this.state.connectionSettings,
|
||||
tls: !this.state.connectionSettings.tls,
|
||||
},
|
||||
})
|
||||
|
||||
private renderConnectButton() {
|
||||
const { classes, actions } = this.props
|
||||
|
||||
if (this.props.connecting) {
|
||||
return (
|
||||
<Button variant="contained" color="primary" className={classes.button} onClick={actions.disconnect}>
|
||||
<CircularProgress size={22} style={{ marginRight: '10px' }} color="secondary" /> Abort
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button variant="contained" color="primary" className={classes.button} onClick={this.onClickConnect}>
|
||||
Connect
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
private onClickConnect = () => {
|
||||
const connectionId = String(sha1(String(Math.random())).slice(0, 8))
|
||||
const options = this.optionsFromState()
|
||||
this.props.actions.connect(options, connectionId)
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
visible: !state.connection.connected,
|
||||
connected: state.connection.connected,
|
||||
connecting: state.connection.connecting,
|
||||
error: state.connection.error,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: bindActionCreators(connectionActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(Connection.styles)(Connection))
|
||||
@@ -0,0 +1,290 @@
|
||||
import ConnectButton from './ConnectButton'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import Save from '@mui/icons-material/Save'
|
||||
import Delete from '@mui/icons-material/Delete'
|
||||
import Settings from '@mui/icons-material/Settings'
|
||||
import Visibility from '@mui/icons-material/Visibility'
|
||||
import VisibilityOff from '@mui/icons-material/VisibilityOff'
|
||||
import { AppState } from '../../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionActions, connectionManagerActions } from '../../actions'
|
||||
import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions'
|
||||
import { KeyCodes } from '../../utils/KeyCodes'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { ToggleSwitch } from './ToggleSwitch'
|
||||
import { useGlobalKeyEventHandler } from '../../effects/useGlobalKeyEventHandler'
|
||||
import {
|
||||
Button,
|
||||
FormControl,
|
||||
Grid,
|
||||
IconButton,
|
||||
Input,
|
||||
InputAdornment,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
TextField,
|
||||
} from '@mui/material'
|
||||
|
||||
interface Props {
|
||||
connection: ConnectionOptions
|
||||
classes: { [s: string]: string }
|
||||
actions: typeof connectionActions
|
||||
managerActions: typeof connectionManagerActions
|
||||
connected: boolean
|
||||
connecting: boolean
|
||||
}
|
||||
|
||||
const protocols = ['mqtt', 'ws']
|
||||
|
||||
function ConnectionSettings(props: Props) {
|
||||
const [showPassword, setShowPassword] = useState(false)
|
||||
|
||||
const toggleConnect = useCallback(() => {
|
||||
if (props.connecting) {
|
||||
props.actions.disconnect()
|
||||
return
|
||||
}
|
||||
|
||||
if (!props.connection) {
|
||||
return
|
||||
}
|
||||
|
||||
const mqttOptions = toMqttConnection(props.connection)
|
||||
if (mqttOptions) {
|
||||
props.actions.connect(mqttOptions, props.connection.id)
|
||||
}
|
||||
}, [props.connection, props.connecting])
|
||||
|
||||
useGlobalKeyEventHandler(KeyCodes.escape, props.actions.disconnect)
|
||||
useGlobalKeyEventHandler(KeyCodes.enter, toggleConnect, [props.connecting])
|
||||
|
||||
const handleClickShowPassword = useCallback(() => {
|
||||
setShowPassword(!showPassword)
|
||||
}, [showPassword])
|
||||
|
||||
function requiresBasePath() {
|
||||
return props.connection.protocol !== 'mqtt'
|
||||
}
|
||||
|
||||
function renderBasePathInput() {
|
||||
return (
|
||||
<Grid item={true} xs={4}>
|
||||
<TextField
|
||||
label="Basepath"
|
||||
className={props.classes.textField}
|
||||
value={props.connection.basePath}
|
||||
onChange={handleChange('basePath')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
|
||||
const handleChange = (name: string) => (event: any) => {
|
||||
if (!props.connection) {
|
||||
return
|
||||
}
|
||||
|
||||
updateConnection(name, event.target.value)
|
||||
}
|
||||
|
||||
const updateConnection = (name: string, value: any) => {
|
||||
props.managerActions.updateConnection(props.connection.id, {
|
||||
[name]: value,
|
||||
})
|
||||
}
|
||||
|
||||
const renderProtocols = () => {
|
||||
const { classes, connection } = props
|
||||
|
||||
const protocolItems = protocols.map((value: string) => (
|
||||
<MenuItem key={value} value={value}>
|
||||
{value}://
|
||||
</MenuItem>
|
||||
))
|
||||
|
||||
return (
|
||||
<TextField
|
||||
select={true}
|
||||
label="Protocol"
|
||||
className={classes.textField}
|
||||
value={connection.protocol}
|
||||
onChange={updateProtocol}
|
||||
margin="normal"
|
||||
>
|
||||
{protocolItems}
|
||||
</TextField>
|
||||
)
|
||||
}
|
||||
|
||||
const updateProtocol = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.target.value
|
||||
updateConnection('protocol', value)
|
||||
if (event.target.value === 'mqtt') {
|
||||
updateConnection('basePath', undefined)
|
||||
} else {
|
||||
updateConnection('basePath', 'ws')
|
||||
}
|
||||
}
|
||||
|
||||
const toggleCertValidation = () => {
|
||||
props.managerActions.updateConnection(props.connection.id, {
|
||||
certValidation: !props.connection.certValidation,
|
||||
})
|
||||
}
|
||||
|
||||
const toggleTls = () => {
|
||||
props.managerActions.updateConnection(props.connection.id, {
|
||||
encryption: !props.connection.encryption,
|
||||
})
|
||||
}
|
||||
|
||||
function PasswordVisibilityButton(props: { showPassword: boolean; toggle: () => void }) {
|
||||
return (
|
||||
<InputAdornment position="end">
|
||||
<IconButton aria-label="Toggle password visibility" onClick={props.toggle}>
|
||||
{props.showPassword ? <Visibility /> : <VisibilityOff />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
)
|
||||
}
|
||||
|
||||
const { classes, connection } = props
|
||||
|
||||
return (
|
||||
<div>
|
||||
<form className={classes.container} noValidate={true} autoComplete="off">
|
||||
<Grid container={true} spacing={3}>
|
||||
<Grid item={true} xs={5}>
|
||||
<TextField
|
||||
autoFocus={true}
|
||||
label="Name"
|
||||
className={classes.textField}
|
||||
value={connection.name}
|
||||
onChange={handleChange('name')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={4}>
|
||||
<ToggleSwitch
|
||||
label="Validate certificate"
|
||||
classes={classes}
|
||||
value={connection.certValidation}
|
||||
toggle={toggleCertValidation}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={3}>
|
||||
<ToggleSwitch label="Encryption (tls)" classes={classes} value={connection.encryption} toggle={toggleTls} />
|
||||
</Grid>
|
||||
<Grid item={true} xs={2}>
|
||||
{renderProtocols()}
|
||||
</Grid>
|
||||
<Grid item={true} xs={7}>
|
||||
<TextField
|
||||
label="Host"
|
||||
className={classes.textField}
|
||||
value={connection.host}
|
||||
onChange={handleChange('host')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={3}>
|
||||
<TextField
|
||||
label="Port"
|
||||
className={classes.textField}
|
||||
value={connection.port}
|
||||
onChange={handleChange('port')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
{requiresBasePath() ? renderBasePathInput() : null}
|
||||
<Grid item={true} xs={requiresBasePath() ? 4 : 6}>
|
||||
<TextField
|
||||
label="Username"
|
||||
className={classes.textField}
|
||||
value={connection.username}
|
||||
onChange={handleChange('username')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item={true} xs={requiresBasePath() ? 4 : 6}>
|
||||
<FormControl className={`${classes.textField} ${classes.inputFormControl}`}>
|
||||
<InputLabel htmlFor="adornment-password">Password</InputLabel>
|
||||
<Input
|
||||
id="adornment-password"
|
||||
type={showPassword ? 'text' : 'password'}
|
||||
value={connection.password}
|
||||
onChange={handleChange('password')}
|
||||
endAdornment={<PasswordVisibilityButton showPassword={showPassword} toggle={handleClickShowPassword} />}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<br />
|
||||
<div>
|
||||
<div style={{ float: 'left' }}>
|
||||
<Button
|
||||
variant="contained"
|
||||
className={classes.button}
|
||||
onClick={() => props.managerActions.deleteConnection(props.connection.id)}
|
||||
>
|
||||
Delete <Delete />
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
className={classes.button}
|
||||
onClick={props.managerActions.toggleAdvancedSettings}
|
||||
data-testid="advanced-button"
|
||||
>
|
||||
<Settings /> Advanced
|
||||
</Button>
|
||||
</div>
|
||||
<div style={{ float: 'right' }}>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
className={classes.button}
|
||||
onClick={props.managerActions.saveConnectionSettings}
|
||||
>
|
||||
<Save /> Save
|
||||
</Button>
|
||||
<ConnectButton toggle={toggleConnect} connecting={props.connecting} classes={classes} />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
connected: state.connection.connected,
|
||||
connecting: state.connection.connecting,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: bindActionCreators(connectionActions, dispatch),
|
||||
managerActions: bindActionCreators(connectionManagerActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
textField: {
|
||||
width: '100%',
|
||||
},
|
||||
switch: {
|
||||
marginTop: 0,
|
||||
},
|
||||
button: {
|
||||
margin: theme.spacing(1),
|
||||
},
|
||||
inputFormControl: {
|
||||
marginTop: '16px',
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ConnectionSettings) as any)
|
||||
@@ -0,0 +1,141 @@
|
||||
import * as React from 'react'
|
||||
import ConnectionSettings from './ConnectionSettings'
|
||||
const ConnectionSettingsAny = ConnectionSettings as any
|
||||
import ProfileList from './ProfileList'
|
||||
import { AppState } from '../../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionManagerActions } from '../../actions'
|
||||
import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { Modal, Paper, Toolbar, Typography, Collapse } from '@mui/material'
|
||||
import AdvancedConnectionSettings from './AdvancedConnectionSettings'
|
||||
const AdvancedConnectionSettingsAny = AdvancedConnectionSettings as any
|
||||
import Certificates from './Certificates'
|
||||
const CertificatesAny = Certificates as any
|
||||
|
||||
interface Props {
|
||||
actions: any
|
||||
classes: any
|
||||
connection?: ConnectionOptions
|
||||
visible: boolean
|
||||
showAdvancedSettings: boolean
|
||||
showCertificateSettings: boolean
|
||||
}
|
||||
|
||||
class ConnectionSetup extends React.PureComponent<Props, {}> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
private renderSettings() {
|
||||
const { connection, showAdvancedSettings, showCertificateSettings } = this.props
|
||||
if (!connection) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Collapse in={!showAdvancedSettings && !showCertificateSettings}>
|
||||
<ConnectionSettingsAny connection={connection} />
|
||||
</Collapse>
|
||||
<Collapse in={showAdvancedSettings && !showCertificateSettings}>
|
||||
<AdvancedConnectionSettingsAny connection={connection} />
|
||||
</Collapse>
|
||||
<Collapse in={showCertificateSettings}>
|
||||
<CertificatesAny connection={connection} />
|
||||
</Collapse>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
this.props.actions.loadConnectionSettings()
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { classes, visible, connection } = this.props
|
||||
const mqttConnection = connection && toMqttConnection(connection)
|
||||
return (
|
||||
<div>
|
||||
<Modal open={visible} disableAutoFocus={true}>
|
||||
<Paper className={classes.root}>
|
||||
<div className={classes.left}>
|
||||
<ProfileList />
|
||||
</div>
|
||||
<div className={classes.right} key={connection && connection.id}>
|
||||
<Toolbar>
|
||||
<Typography className={classes.title} variant="h6" color="inherit">
|
||||
MQTT Connection
|
||||
</Typography>
|
||||
<Typography className={classes.connectionUri}>{mqttConnection && mqttConnection.url}</Typography>
|
||||
</Toolbar>
|
||||
{this.renderSettings()}
|
||||
</div>
|
||||
</Paper>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const connectionHeight = '440px'
|
||||
const styles = (theme: Theme) => ({
|
||||
title: {
|
||||
color: theme.palette.text.primary,
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
},
|
||||
root: {
|
||||
margin: `calc((100vh - ${connectionHeight}) / 2) auto 0 auto`,
|
||||
minWidth: '800px',
|
||||
maxWidth: '850px',
|
||||
height: connectionHeight,
|
||||
outline: 'none' as 'none',
|
||||
display: 'flex' as 'flex',
|
||||
},
|
||||
left: {
|
||||
borderRightStyle: 'dotted' as 'dotted',
|
||||
borderRadius: `${theme.shape.borderRadius}px 0 0 ${theme.shape.borderRadius}px`,
|
||||
paddingTop: theme.spacing(2),
|
||||
flex: 3,
|
||||
overflow: 'hidden' as 'hidden',
|
||||
backgroundColor: theme.palette.background.default,
|
||||
color: theme.palette.text.primary,
|
||||
overflowY: 'auto' as 'auto',
|
||||
},
|
||||
right: {
|
||||
borderRadius: `0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px 0`,
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
padding: theme.spacing(2),
|
||||
flex: 10,
|
||||
},
|
||||
connectionUri: {
|
||||
width: '27em',
|
||||
textOverflow: 'ellipsis' as 'ellipsis',
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
color: theme.palette.text.secondary,
|
||||
fontSize: '0.9em',
|
||||
marginLeft: theme.spacing(4),
|
||||
},
|
||||
})
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
visible: !state.connection.connected,
|
||||
showAdvancedSettings: state.connectionManager.showAdvancedSettings,
|
||||
showCertificateSettings: state.connectionManager.showCertificateSettings,
|
||||
connection: state.connectionManager.selected
|
||||
? state.connectionManager.connections[state.connectionManager.selected]
|
||||
: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: bindActionCreators(connectionManagerActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ConnectionSetup) as any)
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as React from 'react'
|
||||
import Add from '@mui/icons-material/Add'
|
||||
import { Fab } from '@mui/material'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
addButton: {
|
||||
height: theme.spacing(4),
|
||||
width: theme.spacing(4),
|
||||
minHeight: '0',
|
||||
},
|
||||
addIcon: {
|
||||
height: theme.spacing(2),
|
||||
},
|
||||
})
|
||||
|
||||
export const AddButton = withStyles(styles)((props: { classes: any; action: any }) => {
|
||||
return (
|
||||
<span id="addProfileButton" style={{ marginRight: '12px' }}>
|
||||
<Fab size="small" color="secondary" aria-label="Add" className={props.classes.addButton} onClick={props.action}>
|
||||
<Add className={props.classes.addIcon} />
|
||||
</Fab>
|
||||
</span>
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,71 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { ListItem, Typography } from '@mui/material'
|
||||
import { toMqttConnection, ConnectionOptions } from '../../../model/ConnectionOptions'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connectionActions, connectionManagerActions } from '../../../actions'
|
||||
|
||||
export interface Props {
|
||||
connection: ConnectionOptions
|
||||
actions: {
|
||||
connection: any
|
||||
connectionManager: any
|
||||
}
|
||||
selected: boolean
|
||||
classes: any
|
||||
}
|
||||
|
||||
const ConnectionItem = (props: Props) => {
|
||||
const connect = useCallback(() => {
|
||||
const mqttOptions = toMqttConnection(props.connection)
|
||||
if (mqttOptions) {
|
||||
props.actions.connection.connect(mqttOptions, props.connection.id)
|
||||
}
|
||||
}, [props.connection, props])
|
||||
|
||||
const connection = props.connection.host && toMqttConnection(props.connection)
|
||||
return (
|
||||
<ListItem
|
||||
button={true}
|
||||
selected={props.selected}
|
||||
style={{ display: 'block' }}
|
||||
onClick={() => props.actions.connectionManager.selectConnection(props.connection.id)}
|
||||
onDoubleClick={() => {
|
||||
props.actions.connectionManager.selectConnection(props.connection.id)
|
||||
connect()
|
||||
}}
|
||||
>
|
||||
<Typography className={props.classes.name}>{props.connection.name || 'mqtt broker'}</Typography>
|
||||
<Typography className={props.classes.details}>{connection && connection.url}</Typography>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
|
||||
export const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: {
|
||||
connection: bindActionCreators(connectionActions, dispatch),
|
||||
connectionManager: bindActionCreators(connectionManagerActions, dispatch),
|
||||
},
|
||||
}
|
||||
}
|
||||
export const connectionItemStyle = (theme: Theme) => ({
|
||||
name: {
|
||||
width: '100%',
|
||||
textOverflow: 'ellipsis' as 'ellipsis',
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
},
|
||||
details: {
|
||||
width: '100%',
|
||||
textOverflow: 'ellipsis' as 'ellipsis',
|
||||
whiteSpace: 'nowrap' as 'nowrap',
|
||||
overflow: 'hidden' as 'hidden',
|
||||
color: theme.palette.text.secondary,
|
||||
fontSize: '0.7em',
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(null, mapDispatchToProps)(withStyles(connectionItemStyle)(ConnectionItem) as any)
|
||||
@@ -0,0 +1,82 @@
|
||||
import ConnectionItem from './ConnectionItem'
|
||||
const ConnectionItemAny = ConnectionItem as any
|
||||
import React from 'react'
|
||||
import { AddButton } from './AddButton'
|
||||
import { AppState } from '../../../reducers'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { connect } from 'react-redux'
|
||||
import { connectionManagerActions } from '../../../actions'
|
||||
import { ConnectionOptions } from '../../../model/ConnectionOptions'
|
||||
import { KeyCodes } from '../../../utils/KeyCodes'
|
||||
import { List } from '@mui/material'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { useGlobalKeyEventHandler } from '../../../effects/useGlobalKeyEventHandler'
|
||||
|
||||
interface Props {
|
||||
classes: any
|
||||
selected?: string
|
||||
connections: { [s: string]: ConnectionOptions }
|
||||
actions: typeof connectionManagerActions
|
||||
}
|
||||
|
||||
function ProfileList(props: Props) {
|
||||
const { actions, classes, connections, selected } = props
|
||||
|
||||
const selectConnection = (dir: 'next' | 'previous') => (event: KeyboardEvent) => {
|
||||
if (!selected) {
|
||||
return
|
||||
}
|
||||
const indexDirection = dir === 'next' ? 1 : -1
|
||||
const connectionArray = Object.values(connections)
|
||||
const selectedIndex = connectionArray.map(connection => connection.id).indexOf(selected)
|
||||
const nextConnection = connectionArray[selectedIndex + indexDirection]
|
||||
if (nextConnection) {
|
||||
actions.selectConnection(nextConnection.id)
|
||||
}
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
useGlobalKeyEventHandler(KeyCodes.arrow_down, selectConnection('next'))
|
||||
useGlobalKeyEventHandler(KeyCodes.arrow_up, selectConnection('previous'))
|
||||
|
||||
const createConnectionButton = (
|
||||
<div style={{ padding: '8px 16px' }}>
|
||||
<AddButton action={actions.createConnection} />
|
||||
Connections
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<List style={{ height: '100%' }} component="nav" subheader={createConnectionButton}>
|
||||
<div className={classes.list}>
|
||||
{Object.values(connections).map(connection => (
|
||||
<ConnectionItemAny connection={connection} key={connection.id} selected={selected === connection.id} />
|
||||
))}
|
||||
</div>
|
||||
</List>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
list: {
|
||||
marginTop: theme.spacing(1),
|
||||
height: `calc(100% - ${theme.spacing(6)})`,
|
||||
overflowY: 'auto' as 'auto',
|
||||
},
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
actions: bindActionCreators(connectionManagerActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
connections: state.connectionManager.connections,
|
||||
selected: state.connectionManager.selected,
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ProfileList) as any)
|
||||
@@ -0,0 +1,90 @@
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import Delete from '@mui/icons-material/Delete'
|
||||
import { connectionManagerActions } from '../../actions'
|
||||
import { ConnectionOptions } from '../../model/ConnectionOptions'
|
||||
import {
|
||||
IconButton,
|
||||
TableContainer,
|
||||
Table,
|
||||
TableHead,
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableBody,
|
||||
Paper,
|
||||
Theme,
|
||||
} from '@mui/material'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
function Subscriptions(props: {
|
||||
classes: any
|
||||
connection: ConnectionOptions
|
||||
managerActions: typeof connectionManagerActions
|
||||
}) {
|
||||
const { classes, connection, managerActions } = props
|
||||
|
||||
return (
|
||||
<TableContainer component={Paper} className={`${classes.topicList} advanced-connection-settings-topic-list`}>
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell align="left" padding="checkbox" className={classes.tableTitleCell}></TableCell>
|
||||
<TableCell className={classes.tableTitleCell}>Topic</TableCell>
|
||||
<TableCell align="right" className={classes.tableTitleCell}>
|
||||
QoS
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{connection.subscriptions.map(subscription => (
|
||||
<TableRow key={subscription.topic + '_qos_' + subscription.qos}>
|
||||
<TableCell align="right" className={classes.tableCell}>
|
||||
<IconButton
|
||||
onClick={() => managerActions.deleteSubscription(subscription, connection.id)}
|
||||
style={{ padding: '6px' }}
|
||||
>
|
||||
<Delete />
|
||||
</IconButton>
|
||||
</TableCell>
|
||||
|
||||
<TableCell component="th" scope="row" className={classes.tableCell}>
|
||||
{subscription.topic}
|
||||
</TableCell>
|
||||
<TableCell align="right" className={classes.tableCell}>
|
||||
{subscription.qos}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
)
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
managerActions: bindActionCreators(connectionManagerActions, dispatch),
|
||||
}
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
tableCell: {
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0,
|
||||
wordBbreak: 'break-word',
|
||||
},
|
||||
tableTitleCell: {
|
||||
paddingTop: `${theme.spacing(0.5)}px`,
|
||||
paddingBottom: `${theme.spacing(0.5)}px`,
|
||||
},
|
||||
topicList: {
|
||||
height: '196px',
|
||||
overflowY: 'scroll' as 'scroll',
|
||||
margin: `${theme.spacing(1)}px ${theme.spacing(1)}px 0 ${theme.spacing(1)}px`,
|
||||
backgroundColor: theme.palette.background.default,
|
||||
width: 'auto',
|
||||
},
|
||||
})
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(withStyles(styles)(Subscriptions) as any)
|
||||
@@ -0,0 +1,12 @@
|
||||
import React from 'react'
|
||||
import { FormControlLabel, Switch } from '@mui/material'
|
||||
|
||||
export function ToggleSwitch(props: { value: boolean; classes: any; toggle: () => void; label: string }) {
|
||||
const { classes, value, toggle, label } = props
|
||||
const toggleSwitch = <Switch checked={value} onChange={toggle} color="primary" />
|
||||
return (
|
||||
<div className={classes.switch}>
|
||||
<FormControlLabel control={toggleSwitch} label={label} labelPlacement="bottom" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import * as React from 'react'
|
||||
import { Snackbar, SnackbarContent } from '@material-ui/core'
|
||||
import FileCopy from '@material-ui/icons/FileCopy'
|
||||
import Check from '@material-ui/icons/Check'
|
||||
import green from '@material-ui/core/colors/green'
|
||||
import { withStyles, Theme } from '@material-ui/core/styles'
|
||||
|
||||
const copy = require('copy-text-to-clipboard')
|
||||
|
||||
interface Props {
|
||||
value: string
|
||||
classes: any
|
||||
}
|
||||
|
||||
interface State {
|
||||
didCopy: boolean
|
||||
snackBarOpen: boolean
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) => ({
|
||||
snackbar: {
|
||||
backgroundColor: green[600],
|
||||
color: theme.typography.button.color,
|
||||
},
|
||||
})
|
||||
|
||||
class Copy extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
this.state = { didCopy: false, snackBarOpen: false }
|
||||
}
|
||||
|
||||
public render() {
|
||||
const icon = !this.state.didCopy
|
||||
? <FileCopy fontSize="inherit" style={{ cursor: 'pointer' }} onClick={this.handleClick} />
|
||||
: <Check fontSize="inherit" style={{ cursor: 'default' }} />
|
||||
|
||||
return <span>
|
||||
<span style={{ fontSize: '16px' }}>{icon}</span>
|
||||
<span>
|
||||
<Snackbar
|
||||
anchorOrigin={{
|
||||
vertical: 'bottom',
|
||||
horizontal: 'left',
|
||||
}}
|
||||
open={this.state.snackBarOpen}
|
||||
autoHideDuration={2000}
|
||||
onClose={() => { this.setState({ snackBarOpen: false }) }}
|
||||
>
|
||||
<SnackbarContent
|
||||
className={this.props.classes.snackbar}
|
||||
message="Copied to clipboard"
|
||||
/>
|
||||
</Snackbar>
|
||||
</span>
|
||||
</span>
|
||||
}
|
||||
|
||||
private handleClick = (event: React.MouseEvent) => {
|
||||
event.stopPropagation()
|
||||
|
||||
copy(this.props.value)
|
||||
this.setState({ didCopy: true, snackBarOpen: true })
|
||||
setTimeout(() => {
|
||||
this.setState({ didCopy: false })
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(Copy)
|
||||
@@ -0,0 +1,44 @@
|
||||
import * as React from 'react'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
|
||||
interface Props {
|
||||
keyboardKey: string
|
||||
classes: any
|
||||
}
|
||||
|
||||
class Key extends React.Component<Props, {}> {
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = { location: 'bottom' }
|
||||
}
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div className={this.props.classes.keyStyle}>
|
||||
<div className={this.props.classes.keyTextStyle}>{this.props.keyboardKey}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const style = (theme: Theme) => ({
|
||||
keyStyle: {
|
||||
display: 'inline-block' as 'inline-block',
|
||||
width: '1em',
|
||||
height: '1em',
|
||||
backgroundColor: '#bbb',
|
||||
borderRadius: '10%',
|
||||
verticalAlign: 'middle' as 'middle',
|
||||
textAlign: 'center' as 'center',
|
||||
textShadow: '1px 1px rgba(255,255,255,0.45)',
|
||||
boxShadow: '0.08em 0.15em 0.01em 0px rgba(100,100,100,0.75)',
|
||||
},
|
||||
keyTextStyle: {
|
||||
marginTop: '0.65em',
|
||||
fontSize: '0.4em',
|
||||
fontWeight: 'bold' as 'bold',
|
||||
},
|
||||
})
|
||||
|
||||
export default withStyles(style)(Key)
|
||||
@@ -0,0 +1,83 @@
|
||||
import * as React from 'react'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
const cursor = require('./cursor.png')
|
||||
|
||||
interface State {
|
||||
enabled: boolean
|
||||
target: { x: number; y: number }
|
||||
position: { x: number; y: number }
|
||||
stepSizeX: number
|
||||
stepSizeY: number
|
||||
}
|
||||
|
||||
class Demo extends React.Component<{ classes: any }, State> {
|
||||
private timer: any
|
||||
private frameInterval = 20
|
||||
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = { enabled: false, target: { x: 0, y: 0 }, position: { x: 0, y: 0 }, stepSizeX: 1, stepSizeY: 1 }
|
||||
}
|
||||
|
||||
private moveCloser(steps: number = 0) {
|
||||
const steSizeX = Math.min(this.state.stepSizeX, Math.abs(this.state.position.x - this.state.target.x))
|
||||
const steSizeY = Math.min(this.state.stepSizeY, Math.abs(this.state.position.y - this.state.target.y))
|
||||
const dirX = this.state.position.x > this.state.target.x ? -1 : 1
|
||||
const dirY = this.state.position.y > this.state.target.y ? -1 : 1
|
||||
|
||||
if (steSizeX <= 0.1 && steSizeY <= 0.1) {
|
||||
this.timer && clearTimeout(this.timer)
|
||||
return
|
||||
}
|
||||
|
||||
this.setState({
|
||||
position: {
|
||||
x: this.state.position.x + dirX * steSizeX,
|
||||
y: this.state.position.y + dirY * steSizeY,
|
||||
},
|
||||
})
|
||||
|
||||
this.timer = setTimeout(() => {
|
||||
this.moveCloser(steps + 1)
|
||||
}, this.frameInterval)
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
;(window as any).demo.enableMouse = () => {
|
||||
this.setState({ enabled: true })
|
||||
}
|
||||
;(window as any).demo.moveMouse = (x: number, y: number, animationTime: number) => {
|
||||
const stepSizeX = Math.abs(this.state.position.x - x) / (animationTime / this.frameInterval)
|
||||
const stepSizeY = Math.abs(this.state.position.y - y) / (animationTime / this.frameInterval)
|
||||
this.setState({ stepSizeX, stepSizeY, enabled: true, target: { x, y } })
|
||||
this.moveCloser()
|
||||
}
|
||||
}
|
||||
|
||||
public render() {
|
||||
if (!this.state.enabled) {
|
||||
return null
|
||||
}
|
||||
|
||||
const cursorStyle = {
|
||||
left: this.state.position.x + 2,
|
||||
top: this.state.position.y + 2,
|
||||
}
|
||||
|
||||
return <img src={cursor} style={cursorStyle} className={this.props.classes.cursor} />
|
||||
}
|
||||
}
|
||||
|
||||
const style = (theme: Theme) => ({
|
||||
cursor: {
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
position: 'fixed' as 'fixed',
|
||||
zIndex: 1000000,
|
||||
filter: theme.palette.mode === 'light' ? undefined : 'invert(100%)',
|
||||
pointerEvents: 'none' as 'none',
|
||||
},
|
||||
})
|
||||
|
||||
export default withStyles(style)(Demo)
|
||||
@@ -0,0 +1,94 @@
|
||||
import * as React from 'react'
|
||||
import { Theme } from '@mui/material/styles'
|
||||
import { withStyles } from '@mui/styles'
|
||||
import Key from './Key'
|
||||
|
||||
interface State {
|
||||
message?: string
|
||||
keys: Array<string>
|
||||
location: string
|
||||
}
|
||||
|
||||
class Demo extends React.Component<{ classes: any }, State> {
|
||||
private timer: any
|
||||
constructor(props: any) {
|
||||
super(props)
|
||||
this.state = { location: 'bottom', keys: [] }
|
||||
}
|
||||
|
||||
private clearTimer() {
|
||||
this.timer && clearTimeout(this.timer)
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
;(window as any).demo.showMessage = (
|
||||
message: string,
|
||||
location: string,
|
||||
duration: number,
|
||||
keys: Array<string> = []
|
||||
) => {
|
||||
this.clearTimer()
|
||||
this.setState({ message, location, keys })
|
||||
this.timer = setTimeout(() => this.setState({ message: undefined }), duration)
|
||||
}
|
||||
;(window as any).demo.hideMessage = () => {
|
||||
this.clearTimer()
|
||||
this.setState({ message: undefined })
|
||||
}
|
||||
}
|
||||
|
||||
public render() {
|
||||
const positions: { [s: string]: number } = {
|
||||
top: 0,
|
||||
bottom: -65,
|
||||
middle: -32,
|
||||
}
|
||||
const style = {
|
||||
position: 'fixed' as 'fixed',
|
||||
left: '5vw',
|
||||
zIndex: 1000000,
|
||||
margin: '30vw auto 50vw',
|
||||
right: '5vw',
|
||||
bottom: `${positions[this.state.location]}vh`,
|
||||
}
|
||||
const style2 = {
|
||||
textAlign: 'center' as 'center',
|
||||
fontSize: '4em',
|
||||
color: 'white',
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
||||
borderRadius: '16px',
|
||||
}
|
||||
|
||||
if (!this.state.message) {
|
||||
return null
|
||||
}
|
||||
|
||||
let keys: Array<any> = []
|
||||
if (this.state.keys.length > 0) {
|
||||
keys = this.state.keys
|
||||
.map(key => [<Key key={key} keyboardKey={key} />])
|
||||
.reduce((prev, current) => {
|
||||
return [prev, '+' as any, current]
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={style}>
|
||||
<div style={style2}>
|
||||
<span>{this.state.message}</span>
|
||||
{keys.length > 0 ? <div className={this.props.classes.keysStyle}>{keys}</div> : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const style = (theme: Theme) => ({
|
||||
keysStyle: {
|
||||
fontSize: '1em',
|
||||
display: 'inline-block' as 'inline-block',
|
||||
transform: 'translateY(0.3em) translateX(0.8em)',
|
||||
},
|
||||
})
|
||||
|
||||
export default withStyles(style)(Demo)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,26 @@
|
||||
import * as React from 'react'
|
||||
import ShowText from './ShowText'
|
||||
import Mouse from './Mouse'
|
||||
let heapdump: any
|
||||
|
||||
function writeHeapdump(path?: string) {
|
||||
if (!heapdump) {
|
||||
//<heapdump = require('heapdump')
|
||||
}
|
||||
|
||||
heapdump.writeSnapshot(path || `${Date.now()}.heapsnapshot`)
|
||||
return path
|
||||
}
|
||||
|
||||
;(window as any).demo = {
|
||||
writeHeapdump,
|
||||
}
|
||||
|
||||
export default function render(props: any) {
|
||||
return (
|
||||
<span>
|
||||
<ShowText />
|
||||
<Mouse />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user