Compare commits

..
171 Commits
Author SHA1 Message Date
Thomas Nordquist 68118248c9 Improve ui-test video 2019-06-18 17:26:10 +02:00
Thomas Nordquist f1a2ae16c1 Fix plot theme switch 2019-06-18 17:05:22 +02:00
Thomas Nordquist 7904cb22cf Update @types/node 2019-06-18 16:25:17 +02:00
Thomas Nordquist 0e0fbae8bb Freeze electron package version in package.json 2019-06-18 15:48:50 +02:00
Thomas Nordquist 3b72048b67 Fix linting error 2019-06-18 15:13:44 +02:00
Thomas Nordquist caa54809b4 Show app name on windows tiles 2019-06-18 15:04:39 +02:00
Thomas Nordquist 23f5846122 Prepare release v0.3.0 2019-06-18 14:53:55 +02:00
Thomas Nordquist de7b461b4e Update ui-test video 2019-06-18 14:49:48 +02:00
Thomas Nordquist d92ea0bad7 Remove scene from ui-test video 2019-06-18 14:49:24 +02:00
Thomas Nordquist d7bb4bb55f Fix layout default sizes 2019-06-18 14:48:52 +02:00
Thomas Nordquist 9ed8a3b91e Add ui-test accessibility 2019-06-18 14:48:39 +02:00
Thomas Nordquist dd78b43058 Fix sidebar scroll behavior 2019-06-18 14:48:16 +02:00
Thomas Nordquist cd68e966ab Fix test text input 2019-06-18 10:27:58 +02:00
Thomas Nordquist 6baeafce39 Fix typo 2019-06-18 10:27:42 +02:00
Thomas Nordquist 1d8900d6eb Move chart panel below tree 2019-06-17 23:27:16 +02:00
Thomas Nordquist e82c8c4eb0 Refactor 2019-06-17 21:31:54 +02:00
Thomas Nordquist 449d046ce3 Avoid dotPath confusions 2019-06-17 19:11:58 +02:00
Thomas Nordquist 06ab52bb6b Fix chart panel auto-open 2019-06-17 19:08:40 +02:00
Thomas Nordquist 181575f71f Prepare release v0.3.0-alpha2 2019-06-17 18:29:46 +02:00
Thomas Nordquist 3d5a4af705 Tidy up ui 2019-06-17 18:27:19 +02:00
Thomas Nordquist 4e982be613 Show notification when adding charts 2019-06-17 18:19:26 +02:00
Thomas Nordquist 8c1c6387c9 Add colors and move capability to charts 2019-06-17 18:08:35 +02:00
Thomas Nordquist 0f9c2cd36f Allow custom options for charts 2019-06-17 16:37:13 +02:00
Thomas Nordquist 2296143883 Set fixed border for bottom panel 2019-06-17 16:36:40 +02:00
Thomas Nordquist fcb61b563c Refactor 2019-06-17 12:12:22 +02:00
Thomas Nordquist 90e5336c5c Filter tracking 2019-06-17 12:11:24 +02:00
Thomas Nordquist 37d56e24ac Fix chart tree source 2019-06-16 23:06:32 +02:00
Thomas Nordquist 57f979e1bb Prepare release v0.3.0-alpha 2019-06-16 22:43:37 +02:00
Thomas Nordquist 00cbb63181 Add ShowPlot icon/action to MessageHistory 2019-06-16 22:43:13 +02:00
Thomas Nordquist eaafb68117 Throttle chart updates 2019-06-16 22:42:17 +02:00
Thomas Nordquist 486a3568e9 Allow plotting edge-case values 2019-06-16 22:31:21 +02:00
Thomas Nordquist acff7ea631 Refactor 2019-06-16 22:30:56 +02:00
Thomas Nordquist 6829046d8c Disable reducer tracking 2019-06-16 22:30:38 +02:00
Thomas Nordquist 182285d8a5 Fix ui glitch in topic breadcrumbs 2019-06-16 21:56:30 +02:00
Thomas Nordquist 1af799789d Only migrate eclipse mqtt server when not using ssl 2019-06-16 21:29:37 +02:00
Thomas Nordquist 7036d6c8fe Migrate from iot.eclipse.org to mqtt.eclipse.org 2019-06-16 21:23:22 +02:00
Thomas Nordquist 0b067bd964 Update electron to 5.0.4 2019-06-16 21:01:08 +02:00
Thomas Nordquist 9fe5133ef1 Improve plot performance with memoization 2019-06-16 20:55:55 +02:00
Thomas Nordquist c9aae4287c Fix chart panel auto-open 2019-06-16 20:50:18 +02:00
Thomas Nordquist 97846e01a7 Use mui-theme to color plots 2019-06-16 20:18:48 +02:00
Thomas Nordquist b4b6c214cb Open/close chart panel automatically 2019-06-16 20:18:26 +02:00
Thomas Nordquist 1d77af5e22 Improve message receive time accuracy 2019-06-16 19:39:40 +02:00
Thomas Nordquist 1884f3baae Fix code style 2019-06-16 19:25:50 +02:00
Thomas Nordquist 0ebb6f4424 Round time intervals 2019-06-16 19:23:24 +02:00
Thomas Nordquist 209899c3b8 Add numeric chart panel 2019-06-16 19:10:37 +02:00
Thomas Nordquist 4ec8cdf0ff Fix linting on windows 2019-06-15 20:27:30 +02:00
Thomas Nordquist 53326b6de4 Fix linter error 2019-06-15 20:11:35 +02:00
Thomas Nordquist 8c13282a55 Fix axios dependecy 2019-06-15 17:23:14 +02:00
Thomas Nordquist 0e3d94bf06 Remove ffmpreg-concat from build 2019-06-15 16:37:24 +02:00
Thomas Nordquist af8613096d Add automatic linting 2019-06-15 15:04:15 +02:00
Thomas Nordquist 92e045297e Update code formatting 2019-06-15 14:56:57 +02:00
Thomas Nordquist 6176859c7c Update MaterialUI 2019-06-14 11:58:46 +02:00
Thomas Nordquist 3935b1d614 Fix flaky diagram 2019-06-14 10:41:52 +02:00
greenkeeper[bot] c9d3e552ae Update css-loader in group default to the latest version 🚀 (#125)
* chore(package): update css-loader to version 3.0.0

* chore(package): update lockfile app/yarn.lock
2019-06-12 18:34:49 +02:00
Thomas Nordquist d62305303a Refactor 2019-06-06 23:20:20 +02:00
Thomas Nordquist 34c81f7f69 Extract style 2019-06-06 23:16:40 +02:00
Thomas Nordquist bd1f6b6d82 Resolve error when trying to decode faulty json 2019-06-06 23:16:40 +02:00
Thomas Nordquist e728a721aa Prevent unneccessary re-renders 2019-06-06 23:16:40 +02:00
greenkeeper[bot] 15a0c8a5c5 Update file-loader in group default to the latest version 🚀 (#122)
* fix(package): update file-loader to version 4.0.0

* chore(package): update lockfile app/yarn.lock
2019-06-06 09:36:12 +02:00
Thomas Nordquist 173f662fa7 Fix readme 2019-06-05 13:49:35 +02:00
Thomas Nordquist 15c4dc2df3 Fix binary switches for settings drawer 2019-06-05 13:28:07 +02:00
Thomas Nordquist b9dcc4a9a8 Fix diagram mouse event handlers 2019-06-05 13:22:12 +02:00
greenkeeper[bot] f8648b92a1 Update dependencies to enable Greenkeeper 🌴 (#121)
* chore: add Greenkeeper config file

* chore(package): update dependencies

* chore(package): update dependencies

* docs(readme): add Greenkeeper badge

* chore(package): update lockfile app/yarn.lock

* chore(package): update lockfile yarn.lock

* Fix update specific issues

* Fix AceEditor
2019-06-05 11:48:15 +02:00
Thomas Nordquist 4f0b13bdc7 Clean up 2019-06-04 23:03:53 +02:00
Thomas Nordquist 1f9215a19f Fix ui-tests 2019-06-04 23:00:42 +02:00
Thomas Nordquist 9e15e28147 Add JSON based plots 2019-06-04 21:51:23 +02:00
Thomas Nordquist 09151d14a9 Handle invalid json
- fix style
2019-06-04 14:36:28 +02:00
Thomas Nordquist e66f6d098a Refactor CodeDiff 2019-06-04 11:32:59 +02:00
Thomas Nordquist 8cc3d416b8 Update axios 2019-06-04 10:48:13 +02:00
Thomas Nordquist 348b72ea69 Fix type error 2019-06-04 10:45:02 +02:00
Thomas Nordquist 050ba81760 Prepare json literal inpsection 2019-05-28 17:49:44 +02:00
Thomas Nordquist fe16eabb6b Adapt to newer webdriver api 2019-05-28 11:00:06 +02:00
Thomas Nordquist 3c58164539 Fix heapdump rebuild script 2019-05-28 10:57:57 +02:00
Thomas Nordquist 5a9d6aa4dd Remove depreacted lockfile 2019-05-28 10:57:35 +02:00
Thomas Nordquist 5c413a9ebb Update dependencies of web-app 2019-05-28 10:47:17 +02:00
Thomas Nordquist d0ddec746a Update dependecies 2019-05-28 10:42:33 +02:00
Thomas Nordquist 6e4754f475 Disable auto-updater for appx/snap/mas builds 2019-05-07 17:44:42 +02:00
Thomas Nordquist 63f89d628e Destroy view-models when destroying trees 2019-05-07 17:43:31 +02:00
Thomas Nordquist dfaae34cf5 Add bigger microsoft store icon 2019-05-07 13:16:19 +02:00
Thomas Nordquist 77654c7136 Bump version 2019-05-04 13:05:12 +02:00
Thomas Nordquist 3bfc59d89a Fix silent error in treenode 2019-05-04 13:03:36 +02:00
Thomas Nordquist 6bf84055d9 Update images in readme 2019-05-03 12:11:03 +02:00
Thomas Nordquist 12d7d3ab64 Fix download location 2019-05-03 12:07:58 +02:00
Thomas Nordquist b2913c7e0e Disable auto update for osx only 2019-05-03 12:07:58 +02:00
Thomas Nordquist 352948f212 Fix update notifier url 2019-05-03 12:07:58 +02:00
Thomas Nordquist 9a4dbe92a0 Fix connection health indicator in connection manager 2019-05-03 12:07:58 +02:00
Thomas Nordquist 397b95f9e5 Disable auto update
Auto update is buggy https://github.com/electron-userland/electron-builder/issues/3681
2019-05-03 12:07:58 +02:00
Thomas Nordquist a411d21133 Fix auto update 2019-05-03 12:07:58 +02:00
Thomas Nordquist 4f624cc130 Fix download url 2019-05-03 12:07:58 +02:00
Thomas Nordquist f10bfafa1d Delete me 2019-05-03 12:07:58 +02:00
Thomas Nordquist 10e37624a5 Improve demo video 2019-05-03 12:07:58 +02:00
Thomas Nordquist ebdfac39eb Fix copy to clipboard layout glitch 2019-05-03 12:07:58 +02:00
Thomas Nordquist 7cc032cdf4 Add afterPack script 2019-05-03 02:07:34 +02:00
Thomas Nordquist 4bc9039386 Fix sed command 2019-05-03 00:59:29 +02:00
Thomas Nordquist 43b997fb18 Add wrapper script to disable sandbox 2019-05-03 00:59:08 +02:00
Thomas Nordquist 6c883aa226 Disable sandbox for snap builds 2019-05-03 00:16:30 +02:00
Thomas Nordquist 20cde3e2a4 Merge branch 'master' of https://github.com/thomasnordquist/MQTT-Explorer 2019-05-01 02:46:06 +02:00
Thomas Nordquist ae7440f8ab Fix linux icon 2019-05-01 01:26:00 +02:00
Thomas Nordquist 03e228e5a0 Fix ci fullscreen flag 2019-05-01 00:58:04 +02:00
Thomas Nordquist 14f2f9ff1e Fix mac release artifact publish settings 2019-04-30 21:22:54 +02:00
Thomas Nordquist 86544c1334 Disable sandbox 2019-04-30 18:35:29 +02:00
Thomas Nordquist 9e71c3132e Use proper provisioning profile for OSX builds 2019-04-30 18:28:35 +02:00
Thomas Nordquist 817202fc20 Disable electron sandbox due to crashes 2019-04-30 17:44:53 +02:00
Thomas Nordquist 931ec0113c Fix ui glitch 2019-04-30 17:44:25 +02:00
Thomas Nordquist 365ebc78ab Fix ui tests 2019-04-30 16:25:37 +02:00
Thomas Nordquist 2a541a80dc Fix ui tests 2019-04-30 15:54:53 +02:00
Thomas Nordquist a1d3f32f73 Fix mouse-dummy pointer events for demo video 2019-04-27 10:32:45 +02:00
Thomas Nordquist e9e6ea618d Change leak acceptance level 2019-04-27 10:31:16 +02:00
Thomas Nordquist 6021df7150 Fix minor ui-bugs 2019-04-27 10:31:06 +02:00
Thomas Nordquist 070b72b304 Document license 2019-04-27 10:29:37 +02:00
Thomas Nordquist 1f65a0f316 Upgrade electron to v5.0.0 2019-04-26 17:45:35 +02:00
Thomas Nordquist 0f21f10c0d Fix backend tests 2019-04-26 14:57:12 +02:00
Thomas Nordquist af2ff0149d Add memory leak test-suite 2019-04-25 13:50:15 +02:00
Thomas Nordquist 8cd11cde3b Disable redux dev tools on default 2019-04-25 09:01:07 +02:00
Thomas Nordquist fdbe6344d9 Disable diff hover highlight 2019-04-25 09:00:44 +02:00
Thomas Nordquist a56b41635c Fix indentation 2019-04-25 00:28:48 +02:00
Thomas Nordquist 2c5c218fd1 Remove unsubscription since component would unount when node changes 2019-04-25 00:05:33 +02:00
Thomas Nordquist 749df70d5c Fix memory leaks 2019-04-24 23:40:28 +02:00
Thomas Nordquist 4c4e1543ec Prepare release 2019-04-17 19:32:43 +02:00
Thomas Nordquist 9320fa252e Add license 2019-04-17 19:32:29 +02:00
Thomas Nordquist 9062129114 Fix themes 2019-04-17 19:21:32 +02:00
Thomas Nordquist fa3805460c Fix ValueRenderer button / time positioning 2019-04-16 12:48:50 +02:00
Thomas Nordquist c2885c4829 Add time locale selection 2019-04-16 12:48:10 +02:00
Thomas Nordquist a901f2b90b Remove ffmpeg-concat to fix windows build 2019-04-16 08:55:23 +02:00
Thomas Nordquist 349b664270 Add auto-expand steps 2019-04-16 00:51:27 +02:00
Thomas Nordquist a28fc958d4 Fix IconButton shapes and positioning
Fixes #106
2019-04-15 22:40:16 +02:00
Thomas Nordquist 0ec539854c Add comprehendable description for auto-expand
Fixes #102
2019-04-15 22:37:30 +02:00
Thomas Nordquist 9c5d89e0aa Fix ui-glitch
Fixes #105
2019-04-15 17:07:02 +02:00
Thomas Nordquist c9c0a447ce Fix removal of empty topics
Fixes #104
2019-04-15 16:58:50 +02:00
Thomas Nordquist 38819b0e0a Deselect message history message when topic selection changes
Fixes #93
2019-04-15 16:45:58 +02:00
Thomas Nordquist d24dc41024 Increase buffer sizes 2019-04-15 16:19:38 +02:00
Thomas Nordquist 62774fe9c2 Fixx CodeDiff scroll behaviour 2019-04-15 16:17:41 +02:00
Thomas Nordquist 4b15650290 Use better source-map 2019-04-15 15:54:18 +02:00
Thomas Nordquist 64e974f6c7 Remove unused prop 2019-04-15 15:54:10 +02:00
Thomas Nordquist fb137a703c Fix CodeDiff scrolling 2019-04-15 15:53:51 +02:00
Thomas Nordquist c43d1fadb4 Fix initial topic selection for Publish component
Fixes #101
2019-04-15 15:52:43 +02:00
Thomas Nordquist 91a9ba7757 Refactor CustomIconButtons 2019-04-15 15:52:27 +02:00
Thomas Nordquist 48e65947f7 Load (my) redux dev tools in dev mode 2019-04-15 14:15:59 +02:00
Thomas Nordquist 7f29dadc42 Fix down-scale behavior 2019-04-15 14:15:06 +02:00
Thomas Nordquist 47d1e74852 Reset store after disconnect 2019-04-15 14:14:43 +02:00
Thomas Nordquist 6d6b35d5f8 Fix react warnings 2019-04-15 11:55:55 +02:00
Thomas Nordquist 0d56ab49ea Fix sidebar topic theme 2019-04-15 11:43:07 +02:00
Thomas Nordquist daac8cf949 Fix value preview update 2019-04-15 11:35:13 +02:00
Thomas Nordquist fa54b9a9fa Align value preview style with code editor 2019-04-15 11:34:40 +02:00
Thomas Nordquist d339d6a1bb Remove dead code 2019-04-15 11:05:38 +02:00
Thomas Nordquist b6f16c347d Reduce selectable elements 2019-04-15 11:03:58 +02:00
Thomas Nordquist 46fa93edbd Fix resizer highlight and scroll bar style 2019-04-15 11:00:28 +02:00
Thomas Nordquist 2de7840897 Script ui-test scenes 2019-04-15 10:15:06 +02:00
Thomas Nordquist 499dfd1b68 Fix history scroll behavior and text selection
Related to #92
2019-04-14 21:39:13 +02:00
Thomas Nordquist 425bbb36e3 Rename HistoryDrawer 2019-04-14 20:37:57 +02:00
Thomas Nordquist b8f510bd7e Select message content with Ctrl + A if message is in focus
Fixes #92
2019-04-14 20:24:51 +02:00
Thomas Nordquist aae1381de5 Removed outline from selected elements 2019-04-14 20:24:36 +02:00
Thomas Nordquist 266d337dae Upgrade electron 2019-04-13 12:50:31 +02:00
Thomas Nordquist e6bcc00927 Record tests as separate scenes 2019-04-13 12:49:47 +02:00
Thomas Nordquist d1f4bc678c Fix code-style 2019-04-11 20:41:08 +02:00
Thomas Nordquist 52c44327d0 Move UpdateNotifier 2019-04-11 11:49:28 +02:00
Thomas Nordquist 50b2362a70 Allow pre-releases if own version is a beta 2019-04-10 20:43:34 +02:00
Thomas Nordquist fb8a16e1d7 Fix update notification 2019-04-10 20:34:44 +02:00
Thomas Nordquist a929729e6a Use file loader to load demo cursor 2019-04-10 20:34:27 +02:00
Thomas Nordquist b12961cbc9 Fix codestyle 2019-04-10 20:25:52 +02:00
Thomas Nordquist f0465a8ad7 Document theme color proposals 2019-04-10 20:17:25 +02:00
Thomas Nordquist 869ad9eb37 Remove \”Loading...\” suspense fallback 2019-04-10 20:16:49 +02:00
Thomas Nordquist dcff2ae336 Move settings visibility to global state
Fixes #95
2019-04-10 20:16:22 +02:00
Thomas Nordquist b6d6575543 Refactor reducers 2019-04-10 19:47:55 +02:00
Thomas Nordquist a2fae27919 Refactor Settings component 2019-04-10 19:47:20 +02:00
Thomas Nordquist 14f0f32560 Fix setTheme action signature 2019-04-10 18:55:47 +02:00
Thomas Nordquist 195c2db70d Fix ClearAdonment for light theme 2019-04-10 18:55:25 +02:00
Thomas Nordquist 8773d73ead Don't save autoExpandLimit 2019-04-10 18:54:39 +02:00
Thomas Nordquist eab20bc614 Fix topicFilter record initialisation 2019-04-10 14:00:46 +02:00
Thomas Nordquist ab8365b1f7 Fix pause icon alignment 2019-04-10 14:00:02 +02:00
Thomas Nordquist c7b0400e84 Revert "Fix zoom key modifier for windows"
This reverts commit 2590a701bb.
Test failed
2019-04-10 12:05:27 +02:00
173 changed files with 8295 additions and 6349 deletions
+8
View File
@@ -0,0 +1,8 @@
{
"language": "en",
"words": [
"subheader",
"basepath",
"webdriverio"
]
}
+2
View File
@@ -0,0 +1,2 @@
node_modules
build
+1
View File
@@ -28,6 +28,7 @@ install:
script:
- yarn run build
- yarn lint
- yarn test
- export TRAVIS_BUILD_NUMBER="" # Override travis build number since it is uses for tagging the binary version https://github.com/electron-userland/electron-builder/issues/3730
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run -e GH_TOKEN=$GH_TOKEN -e GIT_TAG=$TRAVIS_TAG --rm -v `pwd`:/app thomasnordquist/ui-test-recording-env sh -c "cd app && docker/testMounted.sh"; fi
+7
View File
@@ -0,0 +1,7 @@
{
"editor.formatOnSave": true,
"files.exclude": {
"**/node_modules": true,
"build/": true
}
}
+158
View File
@@ -0,0 +1,158 @@
## creative commons
# Attribution-NoDerivatives 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 licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen 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-NoDerivatives 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-NoDerivatives 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. __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.
c. __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.
d. __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.
e. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
f. __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.
g. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
h. __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.
i. __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.
j. __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 and reproduce, but not 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. __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, 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.
For the avoidance of doubt, You do not have permission under this Public License to Share Adapted Material.
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.
### 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, provided You do not Share Adapted Material;
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; 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.” 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
+9 -2
View File
@@ -8,7 +8,7 @@
| | | |
|:---:|:---:|:---:|
|[![screen1_small](https://user-images.githubusercontent.com/7721625/53954800-84b34c00-40d7-11e9-842d-bf655c569600.jpg)](https://user-images.githubusercontent.com/7721625/53954364-52551f00-40d6-11e9-93cf-d5a9601897ea.png)|[![screen2_small](https://user-images.githubusercontent.com/7721625/53954801-84b34c00-40d7-11e9-913a-42572e675620.jpg)](https://user-images.githubusercontent.com/7721625/53954365-52551f00-40d6-11e9-823f-afd66f19ed01.png)|[![screen3_small](https://user-images.githubusercontent.com/7721625/53954802-854be280-40d7-11e9-973c-08f23c8dbf89.jpg)](https://user-images.githubusercontent.com/7721625/53954366-52551f00-40d6-11e9-9738-74db830d03ac.png)|
|[![screen_composite](https://mqtt-explorer.com/img/screen-composite_small.png)](https://mqtt-explorer.com/img/screen-composite.png)|[![screen2_small](https://mqtt-explorer.com/img/screen2_small.png)](https://mqtt-explorer.com/img/screen2.png)|[![screen3_small](https://mqtt-explorer.com/img/screen3_small.png)](https://mqtt-explorer.com/img/screen3.png)|
# The App has moved to [mqtt-explorer.com](https://mqtt-explorer.com)
MQTT Explorer is a comprehensive and easy-to-use MQTT Client.
@@ -56,4 +56,11 @@ Compile and execute tests
```bash
npm run build
node dist/src/spec/webdriverio.js
```
```
## License
![CC-BY-ND 4.0](https://img.shields.io/badge/License-CC%20BY--ND%204.0-blue.svg)
[CC-BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0/)
The license is a little restrictive to distributing derived work, this may change in the future if the interest arises or more people work on this project.
+164 -97
View File
@@ -1,115 +1,182 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>MQTT Explorer</title>
<script src="./bugtracking.bundle.js"></script>
<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>
<style>
body, html {
margin: 0;
padding: 0;
}
<style>
body,
html {
margin: 0;
padding: 0;
}
@keyframes updateDark {
0% {background-color: none;}
25% {background-color: #3f51b5;}
50% {background-color: #3f51b5;}
100% {background-color: none;}
}
[tabindex] {
outline: none;
}
@keyframes updateLight {
0% {background-color: none; color: inherit}
25% {background-color: #bfc9c8; color: #000}
50% {background-color: #bfc9c8; color: #000}
100% {background-color: none; color: inherit}
@keyframes updateDark {
0% {
background-color: none;
}
25% {
background-color: #3f51b5;
}
50% {
background-color: #3f51b5;
}
100% {
background-color: none;
}
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
@keyframes updateLight {
0% {
background-color: none;
color: inherit;
}
25% {
background-color: #bfc9c8;
color: #000;
}
50% {
background-color: #bfc9c8;
color: #000;
}
100% {
background-color: none;
color: inherit;
}
}
::-webkit-scrollbar-corner {
background-color: rgba(0, 0, 0, 0.0);
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(30,30,30,0.3);
}
::-webkit-scrollbar-corner {
background-color: rgba(0, 0, 0, 0);
}
::-webkit-scrollbar-thumb {
background-color: rgba(140,140,140,0.8);
}
</style>
<style>
.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;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(60, 60, 60, 0.5);
background-color: rgba(140, 140, 140, 0.1);
}
.Resizer:hover {
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
::-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.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%;
}
.Resizer:hover {
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
.Resizer.horizontal:hover {
border-top: 5px solid rgba(0, 0, 0, 0.5);
border-bottom: 5px solid rgba(0, 0, 0, 0.5);
}
.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.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;
}
.Resizer.horizontal::before {
content: '•••';
display: inline-block;
vertical-align: middle;
text-align: center;
width: 100%;
margin-top: -22px;
color: #aaa;
opacity: 1;
}
.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;
}
.Resizer.horizontal:hover {
border-top: 5px solid rgba(120, 120, 120, 0.3);
border-bottom: 5px solid rgba(120, 120, 120, 0.3);
}
</style>
</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>
.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>
</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>
+29 -15
View File
@@ -4,21 +4,28 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode production",
"dev": "node_modules/.bin/webpack-dev-server --mode development --progress"
"build": "yarn rebuild && webpack --mode production",
"dev": "node_modules/.bin/webpack-dev-server --mode development --progress",
"rebuild": "cd node_modules/heapdump && node-gyp rebuild --target=5.0.4 --arch=x64 --dist-url=https://atom.io/download/electron || echo Could not build heapdump; cd -"
},
"author": "",
"license": "ISC",
"license": "CC-BY-ND-4.0",
"dependencies": {
"@material-ui/core": "^4.0.0-alpha.6",
"@material-ui/icons": "^4.0.0-alpha.1",
"@material-ui/lab": "^4.0.0-alpha.6",
"@material-ui/styles": "^4.0.0-alpha.6",
"@material-ui/core": "^4",
"@material-ui/icons": "^4",
"@material-ui/lab": "^4.0.0-alpha",
"@material-ui/styles": "^4",
"@types/react-transition-group": "^2.9.2",
"axios": "^0.19.0",
"brace": "^0.11.1",
"compare-versions": "^3.4.0",
"copy-text-to-clipboard": "^1.0.4",
"copy-text-to-clipboard": "^2.1.0",
"d3": "^5.9.2",
"d3-shape": "^1.3.5",
"diff": "^4.0.1",
"dot-prop": "^5.0.0",
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git#dist",
"file-loader": "^4.0.0",
"get-value": "^3.0.1",
"immutable": "^4.0.0-rc.12",
"js-base64": "^2.5.1",
@@ -30,11 +37,12 @@
"number-abbreviate": "^2.0.0",
"prismjs": "^1.15.0",
"react": "16.8",
"react-ace": "^6.3.2",
"react-ace": "^7.0.1",
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-resize-detector": "^3.4.0",
"react-redux": "^7.0.3",
"react-resize-detector": "^4.1.4",
"react-split-pane": "^0.1.85",
"react-transition-group": "^4.1.1",
"react-vis": "^1.11.6",
"redux": "^4.0.1",
"redux-batched-actions": "^0.4.1",
@@ -44,22 +52,25 @@
"uuid": "^3.3.2"
},
"devDependencies": {
"@types/d3": "^5.7.2",
"@types/diff": "^4.0.1",
"@types/get-value": "^3.0.1",
"@types/node": "^10.12.18",
"@types/node": "^12.0.4",
"@types/prismjs": "^1.9.1",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",
"@types/react-redux": "^6.0.12",
"@types/react-resize-detector": "^3.1.0",
"@types/react-redux": "^7.0.9",
"@types/react-resize-detector": "^4.0.1",
"@types/sha1": "^1.1.1",
"@types/socket.io-client": "^1.4.32",
"@types/uuid": "^3.4.4",
"@types/vis": "^4.21.9",
"awesome-typescript-loader": "^5.2.1",
"css-loader": "^2.1.0",
"css-loader": "^3.0.0",
"hard-source-webpack-plugin": "^0.13.1",
"heapdump": "^0.3.12",
"html-webpack-plugin": "^4.0.0-beta.5",
"node-loader": "^0.6.0",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"typescript": "^3.2.2",
@@ -67,5 +78,8 @@
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
},
"peerDependencies": {
"electron": "^5.0.4"
}
}
+128
View File
@@ -0,0 +1,128 @@
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,
}
}
+21 -14
View File
@@ -1,28 +1,26 @@
import * as q from '../../../backend/src/Model'
import * as url from 'url'
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 { showTree } from './Tree'
import { TopicViewModel } from '../model/TopicViewModel'
import {
addMqttConnectionEvent,
makeConnectionStateEvent,
removeConnection,
rendererEvents,
} from '../../../events'
import { addMqttConnectionEvent, makeConnectionStateEvent, removeConnection, rendererEvents } from '../../../events'
export const connect = (options: MqttOptions, connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
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) => {
console.log(dataSourceState)
rendererEvents.subscribe(event, dataSourceState => {
if (dataSourceState.connected) {
const didReconnect = Boolean(getState().connection.tree)
if (!didReconnect) {
@@ -52,15 +50,16 @@ const updateHealth = (dataSourceState: DataSourceState) => (dispatch: Dispatch<a
state = undefined
}
console.log(state)
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,
@@ -79,9 +78,17 @@ export const disconnect = () => (dispatch: Dispatch<any>, getState: () => AppSta
}
tree && tree.stopUpdating()
tree && tree.destroy()
dispatch(showTree(undefined))
// Clear topic filter
dispatch({
topicFilter: '',
type: SettingsActionTypes.SETTINGS_FILTER_TOPICS,
})
dispatch(resetTreeStore())
dispatch({
type: ActionTypes.CONNECTION_SET_DISCONNECTED,
})
dispatch(showTree(undefined))
}
+75 -36
View File
@@ -1,6 +1,11 @@
import { AppState } from '../reducers'
import { clearLegacyConnectionOptions, loadLegacyConnectionOptions } from '../model/LegacyConnectionSettings'
import { ConnectionOptions, createEmptyConnection, makeDefaultConnections, CertificateParameters } from '../model/ConnectionOptions'
import {
ConnectionOptions,
createEmptyConnection,
makeDefaultConnections,
CertificateParameters,
} from '../model/ConnectionOptions'
import { default as persistentStorage, StorageIdentifier } from '../utils/PersistentStorage'
import { Dispatch } from 'redux'
import { showError } from './Global'
@@ -8,12 +13,12 @@ import { remote } from 'electron'
import * as fs from 'fs'
import * as path from 'path'
import {
ActionTypes,
Action,
} from '../reducers/ConnectionManager'
import { ActionTypes, Action } from '../reducers/ConnectionManager'
const storedConnectionsIdentifier: StorageIdentifier<{[s: string]: ConnectionOptions}> = {
interface ConnectionDictionary {
[s: string]: ConnectionOptions
}
const storedConnectionsIdentifier: StorageIdentifier<ConnectionDictionary> = {
id: 'ConnectionManager_connections',
}
@@ -37,15 +42,18 @@ export const loadConnectionSettings = () => async (dispatch: Dispatch<any>, getS
}
}
export const selectCertificate = (connectionId: string) => async (dispatch: Dispatch<any>, getState: () => AppState) => {
export const selectCertificate = (connectionId: string) => async (
dispatch: Dispatch<any>,
getState: () => AppState
) => {
try {
const certificate = await openCertificate()
console.log(certificate)
dispatch(updateConnection(connectionId, {
selfSignedCertificate: certificate,
}))
dispatch(
updateConnection(connectionId, {
selfSignedCertificate: certificate,
})
)
} catch (error) {
console.log(error)
dispatch(showError(error))
}
}
@@ -57,30 +65,33 @@ async function openCertificate(): Promise<CertificateParameters> {
}
return new Promise((resolve, reject) => {
remote.dialog.showOpenDialog({ properties: ['openFile'], securityScopedBookmarks: true }, (filePaths?: string[]) => {
const selectedFile = filePaths && filePaths[0]
if (!selectedFile) {
reject(rejectReasons.noCertificateSelected)
return
}
fs.readFile(selectedFile, (error, data) => {
if (error) {
reject(error)
remote.dialog.showOpenDialog(
{ properties: ['openFile'], securityScopedBookmarks: true },
(filePaths?: Array<string>) => {
const selectedFile = filePaths && filePaths[0]
if (!selectedFile) {
reject(rejectReasons.noCertificateSelected)
return
}
if (data.length > 16_384 || data.length < 128) {
reject(rejectReasons.certificateSizeDoesNotMatch)
return
}
fs.readFile(selectedFile, (error, data) => {
if (error) {
reject(error)
return
}
resolve({
data: data.toString('base64'),
name: path.basename(selectedFile),
if (data.length > 16_384 || data.length < 128) {
reject(rejectReasons.certificateSizeDoesNotMatch)
return
}
resolve({
data: data.toString('base64'),
name: path.basename(selectedFile),
})
})
})
})
}
)
})
}
@@ -117,7 +128,7 @@ export const createConnection = () => (dispatch: Dispatch<any>) => {
dispatch(selectConnection(newConnection.id))
}
export const setConnections = (connections: {[s: string]: ConnectionOptions}): Action => ({
export const setConnections = (connections: { [s: string]: ConnectionOptions }): Action => ({
connections,
type: ActionTypes.CONNECTION_MANAGER_SET_CONNECTIONS,
})
@@ -132,7 +143,7 @@ export const addConnection = (connection: ConnectionOptions): Action => ({
type: ActionTypes.CONNECTION_MANAGER_ADD_CONNECTION,
})
export const toggleAdvancedSettings = (): Action => ({
export const toggleAdvancedSettings = (): Action => ({
type: ActionTypes.CONNECTION_MANAGER_TOGGLE_ADVANCED_SETTINGS,
})
@@ -155,16 +166,44 @@ export const deleteConnection = (connectionId: string) => (dispatch: Dispatch<an
}
async function ensureConnectionsHaveBeenInitialized() {
const connections = await persistentStorage.load(storedConnectionsIdentifier)
let connections = await persistentStorage.load(storedConnectionsIdentifier)
const requiresInitialization = !connections
if (requiresInitialization) {
const migratedConnection = loadLegacyConnectionOptions()
const defaultConnections = makeDefaultConnections()
persistentStorage.store(storedConnectionsIdentifier, {
connections = {
...migratedConnection,
...defaultConnections,
})
}
await persistentStorage.store(storedConnectionsIdentifier, connections)
clearLegacyConnectionOptions()
}
// Migrate connections, rewrite dictionary to "keep" it "ordered" (dictionaries do not have a guaranteed order)
const mayNeedMigrations = connections && connections['iot.eclipse.org']
if (connections && mayNeedMigrations) {
let newConnections = {}
for (const connection of Object.values(connections)) {
addMigratedConnection(newConnections, connection)
}
await persistentStorage.store(storedConnectionsIdentifier, newConnections)
}
}
function addMigratedConnection(newConnections: { [key: string]: ConnectionOptions }, connection: ConnectionOptions) {
// The host has been renamed, only change the host if it has not been changed
// Also check for ssl since SSL is not yet working
if (
connection.id === 'iot.eclipse.org' &&
connection.host === 'iot.eclipse.org' &&
connection.port === 1883 &&
!connection.encryption
) {
connection.id = 'mqtt.eclipse.org'
connection.host = 'mqtt.eclipse.org'
connection.name = 'mqtt.eclipse.org'
}
newConnections[connection.id] = connection
}
+8 -1
View File
@@ -1,4 +1,5 @@
import { ActionTypes } from '../reducers'
import { ActionTypes } from '../reducers/Global'
import { Dispatch } from 'redux'
export const showError = (error?: string) => ({
error,
@@ -13,3 +14,9 @@ export const showNotification = (notification?: string) => ({
export const didLaunch = () => ({
type: ActionTypes.didLaunch,
})
export const toggleSettingsVisibility = () => (dispatch: Dispatch<any>) => {
dispatch({
type: ActionTypes.toggleSettingsVisibility,
})
}
+1 -1
View File
@@ -32,7 +32,7 @@ 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
+31 -23
View File
@@ -1,19 +1,15 @@
import * as q from '../../../backend/src/Model'
import { ActionTypes, SettingsState, TopicOrder } 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 { 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'
import {
ActionTypes,
SettingsState,
TopicOrder,
} from '../reducers/Settings'
import { Base64Message } from '../../../backend/src/Model/Base64Message'
import { globalActions } from '.'
const settingsIdentifier: StorageIdentifier<Partial<SettingsState>> = {
id: 'Settings',
@@ -21,7 +17,7 @@ const settingsIdentifier: StorageIdentifier<Partial<SettingsState>> = {
export const loadSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
try {
const settings = await persistentStorage.load(settingsIdentifier) || {}
const settings = (await persistentStorage.load(settingsIdentifier)) || {}
dispatch({
settings: getState().settings.merge(settings),
type: ActionTypes.SETTINGS_DID_LOAD_SETTINGS,
@@ -35,6 +31,7 @@ export const loadSettings = () => async (dispatch: Dispatch<any>, getState: () =
export const storeSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
const settings = {
...getState().settings.toJS(),
autoExpandLimit: undefined,
topicFilter: undefined,
visible: undefined,
}
@@ -51,6 +48,13 @@ export const setAutoExpandLimit = (autoExpandLimit: number = 0) => (dispatch: Di
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())
}
@@ -70,13 +74,6 @@ export const setValueDisplayMode = (valueRendererDisplayMode: 'diff' | 'raw') =>
dispatch(storeSettings())
}
export const toggleSettingsVisibility = () => (dispatch: Dispatch<any>) => {
dispatch({
type: ActionTypes.SETTINGS_TOGGLE_VISIBILITY,
})
dispatch(storeSettings())
}
export const toggleHighlightTopicUpdates = () => (dispatch: Dispatch<any>) => {
dispatch({
type: ActionTypes.SETTINGS_TOGGLE_HIGHLIGHT_ACTIVITY,
@@ -101,26 +98,34 @@ export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, get
})
if (!filterStr || !tree) {
dispatch(batchActions([setAutoExpandLimit(0), (showTree(tree) as any)]))
dispatch(batchActions([setAutoExpandLimit(0), showTree(tree) as any]))
return
}
const topicFilter = filterStr.toLowerCase()
const nodeFilter = (node: q.TreeNode<TopicViewModel>): boolean => {
const topicMatches = node.path().toLowerCase().indexOf(topicFilter) !== -1
const topicMatches =
node
.path()
.toLowerCase()
.indexOf(topicFilter) !== -1
if (topicMatches) {
return true
}
const messageMatches = node.message
&& node.message.value
&& Base64Message.toUnicodeString(node.message.value).toLowerCase().indexOf(filterStr) !== -1
const messageMatches =
node.message &&
node.message.value &&
Base64Message.toUnicodeString(node.message.value)
.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()
@@ -137,7 +142,7 @@ 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>) {
@@ -157,7 +162,10 @@ function autoExpandLimitForTree(tree: q.Tree<TopicViewModel>) {
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,
type:
getState().settings.get('theme') === 'light'
? ActionTypes.SETTINGS_SET_THEME_DARK
: ActionTypes.SETTINGS_SET_THEME_LIGHT,
})
dispatch(storeSettings())
}
+17 -7
View File
@@ -1,10 +1,11 @@
import * as q from '../../../backend/src/Model'
import { Dispatch } from 'redux'
import { ActionTypes } from '../reducers/Sidebar'
import { AppState } from '../reducers'
import { Dispatch } from 'redux'
import { makePublishEvent, rendererEvents } from '../../../events'
export const clearRetainedTopic = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
const { selectedTopic } = getState().tree
const selectedTopic = getState().tree.get('selectedTopic')
if (!selectedTopic) {
return
}
@@ -12,7 +13,17 @@ export const clearRetainedTopic = () => (dispatch: Dispatch<any>, getState: () =
dispatch(clearTopic(selectedTopic, false))
}
export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean, subtopicClearLimit = 50) => (dispatch: Dispatch<any>, getState: () => AppState) => {
export const setCompareMessage = (message?: q.Message) => (dispatch: Dispatch<any>) => {
dispatch({
message,
type: ActionTypes.SIDEBAR_SET_COMPARE_MESSAGE,
})
}
export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean, subtopicClearLimit = 50) => (
dispatch: Dispatch<any>,
getState: () => AppState
) => {
const { connectionId } = getState().connection
if (!connectionId) {
return
@@ -25,15 +36,14 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean, subtopicC
retain: true,
qos: 0 as 0,
}
console.log('deleting', topic.path())
rendererEvents.emit(publishEvent, mqttMessage)
if (recursive) {
topic.childTopics()
topic
.childTopics()
.filter(topic => Boolean(topic.message && topic.message.value))
.slice(0, subtopicClearLimit)
.forEach((topic) => {
console.log('deleting', topic.path())
.forEach(topic => {
const mqttMessage = {
topic: topic.path(),
payload: null,
+66 -36
View File
@@ -1,57 +1,89 @@
import * as q from '../../../backend/src/Model'
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 { setTopic } from './Publish'
import { TopicViewModel } from '../model/TopicViewModel'
import { globalActions } from '.';
import { globalActions } from '.'
const debounce = require('lodash.debounce')
export const selectTopic = (topic: q.TreeNode<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState) => {
export const selectTopic = (topic: q.TreeNode<TopicViewModel>) => (
dispatch: Dispatch<any>,
getState: () => AppState
) => {
debouncedSelectTopic(topic, dispatch, getState)
}
const debouncedSelectTopic = debounce((topic: q.TreeNode<TopicViewModel>, dispatch: Dispatch<any>, getState: () => AppState) => {
const { selectedTopic } = getState().tree
if (selectedTopic === topic) {
return
}
const debouncedSelectTopic = debounce(
(topic: q.TreeNode<TopicViewModel>, dispatch: Dispatch<any>, getState: () => AppState) => {
const previouslySelectedTopic = getState().tree.get('selectedTopic')
// Update publish topic
let setTopicDispatch: any | undefined
if (selectedTopic && (selectedTopic.path() === getState().publish.topic || !getState().publish.topic)) {
setTopicDispatch = setTopic(topic.path())
}
if (previouslySelectedTopic === topic) {
return
}
if (selectedTopic && selectedTopic.viewModel) {
selectedTopic.viewModel.setSelected(false)
}
// Update publish topic
let setTopicDispatch: any | undefined
if (!getState().publish.topic) {
setTopicDispatch = setTopic(topic.path())
} else if (previouslySelectedTopic && previouslySelectedTopic.path() === getState().publish.topic) {
setTopicDispatch = setTopic(topic.path())
}
if (topic.viewModel) {
topic.viewModel.setSelected(true)
}
if (previouslySelectedTopic && previouslySelectedTopic.viewModel) {
previouslySelectedTopic.viewModel.setSelected(false)
}
const selectTreeTopicDispatch = {
selectedTopic: topic,
type: ActionTypes.TREE_SELECT_TOPIC,
}
if (topic.viewModel) {
topic.viewModel.setSelected(true)
}
if (setTopicDispatch) {
dispatch(batchActions([selectTreeTopicDispatch, setTopicDispatch]))
} else {
dispatch(selectTreeTopicDispatch)
}
}, 70)
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,
})
}
export const showTree = (tree: q.Tree<TopicViewModel> | undefined) => (
dispatch: Dispatch<any>,
getState: () => AppState
): AnyAction => {
destroyUnreferencedTree(getState())
return dispatch({
tree,
@@ -60,8 +92,8 @@ export const showTree = (tree?: q.Tree<TopicViewModel>) => (dispatch: Dispatch<a
}
export const togglePause = (tree?: q.Tree<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState) => {
const paused = getState().tree.paused
const tree = getState().tree.tree
const paused = getState().tree.get('paused')
const tree = getState().tree.get('tree')
const changes = tree ? tree.unmergedChanges().length : 0
if (paused && changes > 0) {
@@ -79,6 +111,4 @@ export const togglePause = (tree?: q.Tree<TopicViewModel>) => (dispatch: Dispatc
dispatch({
type: paused ? ActionTypes.TREE_RESUME_UPDATES : ActionTypes.TREE_PAUSE_UPDATES,
})
}
+3 -3
View File
@@ -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,
+12 -1
View File
@@ -1,3 +1,4 @@
import * as chartActions from './Charts'
import * as connectionActions from './Connection'
import * as connectionManagerActions from './ConnectionManager'
import * as globalActions from './Global'
@@ -7,4 +8,14 @@ import * as sidebarActions from './Sidebar'
import * as treeActions from './Tree'
import * as updateNotifierActions from './UpdateNotifier'
export { settingsActions, treeActions, publishActions, updateNotifierActions, connectionActions, sidebarActions, connectionManagerActions, globalActions }
export {
settingsActions,
treeActions,
chartActions,
publishActions,
updateNotifierActions,
connectionActions,
sidebarActions,
connectionManagerActions,
globalActions,
}
+31 -21
View File
@@ -4,7 +4,7 @@ import CssBaseline from '@material-ui/core/CssBaseline'
import ErrorBoundary from './ErrorBoundary'
import Notification from './Layout/Notification'
import TitleBar from './Layout/TitleBar'
import UpdateNotifier from '../UpdateNotifier'
import UpdateNotifier from './UpdateNotifier'
import { AppState } from '../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
@@ -28,7 +28,7 @@ interface Props {
class App extends React.PureComponent<Props, {}> {
constructor(props: any) {
super(props)
this.state = { }
this.state = {}
}
private renderNotification() {
@@ -41,7 +41,9 @@ class App extends React.PureComponent<Props, {}> {
<Notification
message={str}
type={isError ? 'error' : 'notification'}
onClose={() => { isError ? this.props.actions.showError(undefined) : this.props.actions.showNotification(undefined) }}
onClose={() => {
isError ? this.props.actions.showError(undefined) : this.props.actions.showNotification(undefined)
}}
/>
)
}
@@ -65,8 +67,8 @@ class App extends React.PureComponent<Props, {}> {
<div className={centerContent}>
<CssBaseline />
<ErrorBoundary>
{this.renderNotification()}
<React.Suspense fallback={<div>Loading...</div>}>
{this.renderNotification()}
<React.Suspense fallback={<div></div>}>
<Settings />
</React.Suspense>
<div className={centerContent}>
@@ -74,8 +76,12 @@ class App extends React.PureComponent<Props, {}> {
<TitleBar />
</div>
<div className={settingsVisible ? contentShift : content}>
<React.Suspense fallback={<div>Loading...</div>}>
<ContentView heightProperty={heightProperty} connectionId={this.props.connectionId} paneDefaults={paneDefaults} />
<React.Suspense fallback={<div></div>}>
<ContentView
heightProperty={heightProperty}
connectionId={this.props.connectionId}
paneDefaults={paneDefaults}
/>
</React.Suspense>
</div>
</div>
@@ -89,15 +95,18 @@ class App extends React.PureComponent<Props, {}> {
const styles = (theme: Theme) => {
const drawerWidth = 300
const contentBaseStyle = {
width: '100vw',
backgroundColor: theme.palette.background.default,
}
return {
heightProperty: {
height: 'calc(100vh - 64px) !important',
height: '100%', // '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)',
},
@@ -106,9 +115,7 @@ const styles = (theme: Theme) => {
overflow: 'hidden' as 'hidden',
},
content: {
width: '100vw',
overflowX: 'hidden' as 'hidden',
backgroundColor: theme.palette.background.default,
...contentBaseStyle,
transition: theme.transitions.create('transform', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
@@ -116,9 +123,7 @@ const styles = (theme: Theme) => {
transform: 'translateX(0px)',
},
contentShift: {
overflowX: 'hidden' as 'hidden',
width: '100vw',
padding: 0,
...contentBaseStyle,
backgroundColor: theme.palette.background.default,
transition: theme.transitions.create('transform', {
easing: theme.transitions.easing.easeOut,
@@ -138,13 +143,18 @@ const mapDispatchToProps = (dispatch: any) => {
const mapStateToProps = (state: AppState) => {
return {
settingsVisible: state.settings.get('visible'),
settingsVisible: state.globalState.get('settingsVisible'),
connectionId: state.connection.connectionId,
error: state.globalState.error,
notification: state.globalState.notification,
error: state.globalState.get('error'),
notification: state.globalState.get('notification'),
highlightTopicUpdates: state.settings.get('highlightTopicUpdates'),
launching: state.globalState.launching,
launching: state.globalState.get('launching'),
}
}
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(App))
export default withStyles(styles)(
connect(
mapStateToProps,
mapDispatchToProps
)(App)
)
+97
View File
@@ -0,0 +1,97 @@
import * as q from '../../../../backend/src/Model'
import * as React from 'react'
import TopicPlot from '../TopicPlot'
import { AppState } from '../../reducers'
import { bindActionCreators } from 'redux'
import { chartActions } from '../../actions'
import { ChartParameters } from '../../reducers/Charts'
import { connect } from 'react-redux'
import { Paper } from '@material-ui/core'
import ChartTitle from './ChartTitle'
import { ChartActions } from './ChartActions'
const throttle = require('lodash.throttle')
interface Props {
parameters: ChartParameters
treeNode?: q.TreeNode<any>
actions: {
chart: typeof chartActions
}
}
/**
* Subscribes to onMessage of treeNode
*/
function useMessageSubscriptionToUpdate(treeNode?: q.TreeNode<any>) {
const [lastUpdated, setLastUpdate] = React.useState(0)
function subscribeToMessageUpdates() {
const onUpdateCallback = throttle(() => setLastUpdate(treeNode ? treeNode.lastUpdate : 0), 300)
treeNode && treeNode.onMessage.subscribe(onUpdateCallback)
return function cleanup() {
treeNode && treeNode.onMessage.unsubscribe(onUpdateCallback)
}
}
React.useEffect(subscribeToMessageUpdates, [treeNode])
}
function Chart(props: Props) {
const { parameters, treeNode } = props
const [freezedHistory, setHistory] = React.useState<q.MessageHistory | undefined>()
useMessageSubscriptionToUpdate(treeNode)
const togglePause = React.useCallback(() => {
if (!props.treeNode) {
return
}
setHistory(freezedHistory ? undefined : props.treeNode.messageHistory.clone())
}, [props.treeNode, freezedHistory])
const onRemove = React.useCallback(() => {
props.actions.chart.removeChart(props.parameters)
}, [props.parameters])
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
parameters={parameters}
onRemove={onRemove}
paused={Boolean(freezedHistory)}
togglePause={togglePause}
/>
</div>
</div>
{props.treeNode ? (
<TopicPlot
color={props.parameters.color}
interpolation={props.parameters.interpolation}
range={props.parameters.range ? [props.parameters.range.from, props.parameters.range.to] : undefined}
history={freezedHistory ? freezedHistory : props.treeNode.messageHistory}
dotPath={parameters.dotPath}
/>
) : (
<span>No data</span>
)}
</Paper>
)
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
chart: bindActionCreators(chartActions, dispatch),
},
}
}
export default connect(
undefined,
mapDispatchToProps
)(Chart)
@@ -0,0 +1,26 @@
import * as React from 'react'
import Play from '@material-ui/icons/PlayArrow'
import Pause from '@material-ui/icons/PauseCircleFilled'
import Clear from '@material-ui/icons/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
}) {
return (
<div style={{ display: 'flex' }}>
<CustomIconButton tooltip={props.paused ? 'Resume chart' : 'Pause chart'} onClick={props.togglePause}>
{props.paused ? <Play /> : <Pause />}
</CustomIconButton>
<SettingsButton parameters={props.parameters} />
<CustomIconButton tooltip="Remove chart" onClick={props.onRemove}>
<Clear data-test-type="RemoveChart" data-test={`${props.parameters.topic}-${props.parameters.dotPath || ''}`} />
</CustomIconButton>
</div>
)
}
@@ -0,0 +1,71 @@
import * as React from 'react'
import { bindActionCreators } from 'redux'
import { chartActions } from '../../../actions'
import { ChartParameters } from '../../../reducers/Charts'
import { connect } from 'react-redux'
import { Menu, MenuItem } from '@material-ui/core'
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
)(ColorSettings)
@@ -0,0 +1,66 @@
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 } from '@material-ui/core'
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}>
{curve.replace(/_/g, ' ')}
</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,35 @@
import * as React from 'react'
import { ChartParameters } from '../../../reducers/Charts'
import { Menu, MenuItem, TextField, Typography } from '@material-ui/core'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { chartActions } from '../../../actions'
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}>
Move up
</MenuItem>
)
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
chart: bindActionCreators(chartActions, dispatch),
},
}
}
export default connect(
undefined,
mapDispatchToProps
)(MoveUp)
@@ -0,0 +1,72 @@
import * as React from 'react'
import { ChartParameters } from '../../../reducers/Charts'
import { Menu, MenuItem, TextField, Typography } from '@material-ui/core'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { chartActions } from '../../../actions'
function RangeSettings(props: {
actions: { chart: typeof chartActions }
chart: ChartParameters
anchorEl?: Element
open: boolean
onClose: () => void
}) {
const dismissClick = React.useCallback((e: React.MouseEvent) => e.stopPropagation(), [])
const [rangeFrom, setRangeFrom] = React.useState<string | number | undefined>(
props.chart.range && props.chart.range.from
)
const [rangeTo, setRangeTo] = React.useState<string | number | undefined>(props.chart.range && props.chart.range.to)
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])
const setFromHandler = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => setRangeFrom(e.target.value), [])
const setToHandler = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => setRangeTo(e.target.value), [])
return (
<Menu style={{ textAlign: 'center' }} anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
<Typography>Define custom ranges for the Y-Axis</Typography>
<div style={{ padding: '0 16px' }}>
<TextField
style={{ marginTop: '0' }}
onClick={dismissClick}
label="from"
value={rangeFrom}
onChange={setFromHandler}
margin="normal"
/>
<TextField
style={{ marginLeft: '8px', marginTop: '0' }}
onClick={dismissClick}
label="to"
value={rangeTo}
onChange={setToHandler}
margin="normal"
/>
</div>
</Menu>
)
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
chart: bindActionCreators(chartActions, dispatch),
},
}
}
export default connect(
undefined,
mapDispatchToProps
)(RangeSettings)
@@ -0,0 +1,30 @@
import * as React from 'react'
import ChartSettings from '.'
import CustomIconButton from '../../helper/CustomIconButton'
import MoreVertIcon from '@material-ui/icons/Settings'
import { ChartParameters } from '../../../reducers/Charts'
export function SettingsButton(props: { parameters: ChartParameters }) {
const [visible, setVisible] = React.useState(false)
const settingsRef = React.useRef()
const toggleSettings = React.useCallback(() => {
setVisible(!visible)
}, [visible])
const close = React.useCallback(() => {
setVisible(false)
}, [])
return (
<span>
<ChartSettings open={visible} close={close} anchorEl={settingsRef} chart={props.parameters} />
<CustomIconButton tooltip="Chart settings" onClick={toggleSettings}>
<MoreVertIcon
ref={settingsRef as any}
data-test-type="ChartSettings"
data-test={`${props.parameters.topic}-${props.parameters.dotPath || ''}`}
/>
</CustomIconButton>
</span>
)
}
@@ -0,0 +1,53 @@
import * as React from 'react'
import { ChartParameters } from '../../../reducers/Charts'
import { Menu, MenuItem, TextField, Typography } from '@material-ui/core'
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()}>
auto
</MenuItem>
<MenuItem selected={props.chart.width === 'big'} onClick={setChartWidth('big')}>
100% width
</MenuItem>
<MenuItem selected={props.chart.width === 'medium'} onClick={setChartWidth('medium')}>
50% width
</MenuItem>
<MenuItem selected={props.chart.width === 'small'} onClick={setChartWidth('small')}>
33% width
</MenuItem>
</Menu>
)
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
chart: bindActionCreators(chartActions, dispatch),
},
}
}
export default connect(
undefined,
mapDispatchToProps
)(Size)
@@ -0,0 +1,46 @@
import {
amber,
orange,
pink,
purple,
deepPurple,
teal,
red,
green,
lime,
indigo,
yellow,
brown,
blueGrey,
} from '@material-ui/core/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,79 @@
import * as React from 'react'
import InterpolationSettings from './InterpolationSettings'
import { ChartParameters } from '../../../reducers/Charts'
import { Menu, MenuItem } from '@material-ui/core'
import RangeSettings from './RangeSettings'
import Size from './Size'
import MoveUp from './MoveUp'
import ColorSettings from './ColorSettings'
function ChartSettings(props: {
open: boolean
close: () => void
chart: ChartParameters
anchorEl: React.MutableRefObject<undefined>
}) {
const [rangeVisible, setRangeVisible] = React.useState(false)
const [interpolationVisible, setInterpolationVisible] = React.useState(false)
const [sizeVisible, setSizeVisible] = React.useState(false)
const [colorVisible, setColorVisible] = React.useState(false)
const toggleRange = React.useCallback(() => {
if (open) {
props.close()
}
setRangeVisible(!rangeVisible)
}, [rangeVisible, 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}>
Set range
</MenuItem>
<MenuItem key="interpolation" onClick={toggleInterpolation}>
Curve interpolation
</MenuItem>
<MenuItem key="size" onClick={toggleSize}>
Size
</MenuItem>
<MenuItem key="color" onClick={toggleColor}>
Color
</MenuItem>
<MoveUp chart={props.chart} close={props.close} />
</Menu>
<RangeSettings chart={props.chart} anchorEl={props.anchorEl.current} open={rangeVisible} onClose={toggleRange} />
<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 ChartSettings
@@ -0,0 +1,29 @@
import * as React from 'react'
import { ChartParameters } from '../../reducers/Charts'
import { Typography, Theme, withStyles } from '@material-ui/core'
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: '&nbsp;' }}></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,50 @@
import * as q from '../../../../backend/src/Model'
import * as React from 'react'
import Chart from './Chart'
import { ChartParameters } from '../../reducers/Charts'
interface Props {
tree?: q.Tree<any>
parameters: ChartParameters
}
export function ChartWithTreeNode(props: Props) {
const { tree, parameters } = props
if (!tree) {
return null
}
const initialTreeNode = tree.findNode(parameters.topic)
const [treeNode, setTreeNode] = React.useState<q.TreeNode<any> | undefined>(initialTreeNode)
usePollingToFetchTreeNode(treeNode, tree, parameters.topic, setTreeNode)
return <Chart treeNode={treeNode} parameters={parameters} />
}
/**
* If a node is not available when the plot is shown, keep polling until it has been created
*/
function usePollingToFetchTreeNode(
treeNode: q.TreeNode<any> | undefined,
tree: q.Tree<any>,
path: string,
setTreeNode: React.Dispatch<React.SetStateAction<q.TreeNode<any> | undefined>>
) {
function pollUntilTreeNodeHasBeenFound() {
let intervalTimer: any
if (!treeNode) {
intervalTimer = setInterval(() => {
const node = tree.findNode(path)
if (node) {
setTreeNode(node)
clearInterval(intervalTimer)
}
}, 500)
}
return function cleanup() {
intervalTimer && clearInterval(intervalTimer)
}
}
React.useEffect(pollUntilTreeNodeHasBeenFound, [])
}
+132
View File
@@ -0,0 +1,132 @@
import * as q from '../../../../backend/src/Model'
import * as React from 'react'
import ShowChart from '@material-ui/icons/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, Theme, Typography, withStyles } from '@material-ui/core'
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
}
}
function ChartPanel(props: Props) {
const chartsInView = props.charts.count()
const [spacing, setSpacing] = React.useState(spacingForChartCount(chartsInView))
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])
const charts = props.charts.map(chartParameters => (
<CSSTransition
key={`${chartParameters.topic}-${chartParameters.dotPath || ''}`}
timeout={{ enter: 500, exit: 500 }}
classNames="example"
>
<Grid item xs={mapWidth(chartParameters.width, spacing)}>
<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))
@@ -14,18 +14,9 @@ const styles = (theme: Theme) => ({
},
})
export const AddButton = withStyles(styles)((props: {
classes: any,
action: any,
}) => {
export const AddButton = withStyles(styles)((props: { classes: any; action: any }) => {
return (
<Fab
size="small"
color="secondary"
aria-label="Add"
className={props.classes.addButton}
onClick={props.action}
>
<Fab size="small" color="secondary" aria-label="Add" className={props.classes.addButton} onClick={props.action}>
<Add className={props.classes.addIcon} />
</Fab>
)
@@ -8,7 +8,7 @@ import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { connectionManagerActions } from '../../actions'
import { ConnectionOptions } from '../../model/ConnectionOptions'
import { StyleRulesCallback, Theme, withStyles } from '@material-ui/core/styles'
import { Theme, withStyles } from '@material-ui/core/styles'
import {
Button,
@@ -56,8 +56,8 @@ class ConnectionSettings extends React.Component<Props, State> {
<ClearAdornment action={this.clearCertificate} value={this.props.connection.selfSignedCertificate.name} />
{this.props.connection.selfSignedCertificate.name}
</Typography>
</Tooltip>
</span>
</Tooltip>
</span>
)
}
@@ -89,27 +89,26 @@ class ConnectionSettings extends React.Component<Props, State> {
className={classes.fullWidth}
label="Subscription"
margin="normal"
onChange={(event: React.ChangeEvent<HTMLInputElement>) => this.setState({ subscription: event.target.value })}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
this.setState({ subscription: event.target.value })
}
/>
</Grid>
<Grid item={true} xs={2} className={classes.gridPadding}>
<Button
className={classes.button}
color="secondary"
onClick={() => this.props.managerActions.addSubscription(this.state.subscription, this.props.connection.id)}
onClick={() =>
this.props.managerActions.addSubscription(this.state.subscription, this.props.connection.id)
}
variant="contained"
>
<Add /> Add
</Button>
</Grid>
<Grid item={true} xs={12} style={{ padding: 0 }}>
<List
className={`${classes.topicList} advanced-connection-settings-topic-list`}
component="nav"
>
<div className={classes.list}>
{this.renderSubscriptions()}
</div>
<List className={`${classes.topicList} advanced-connection-settings-topic-list`} component="nav">
<div className={classes.list}>{this.renderSubscriptions()}</div>
</List>
</Grid>
<Grid item={true} xs={7} className={classes.gridPadding}>
@@ -151,17 +150,15 @@ class ConnectionSettings extends React.Component<Props, State> {
}
}
const Subscription = (props: {
subscription: string,
deleteAction: any,
}) => {
const Subscription = (props: { subscription: string; deleteAction: any }) => {
return (
<ListItem style={{ padding: '0 0 0 8px' }}>
<ListItemText>
<IconButton onClick={props.deleteAction} style={{ padding: '6px' }}>
<Delete />
</IconButton>
{props.subscription}</ListItemText>
{props.subscription}
</ListItemText>
</ListItem>
)
}
@@ -172,33 +169,34 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
const styles: StyleRulesCallback<string> = (theme: Theme) => {
return {
fullWidth: {
width: '100%',
},
gridPadding: {
padding: '0 12px !important',
},
topicList: {
height: '180px',
overflowY: 'scroll' as 'scroll',
margin: '8px 16px',
backgroundColor: theme.palette.background.default,
},
button: {
marginTop: theme.spacing(3),
float: 'right',
},
certificateName: {
width: '100%',
height: 'calc(1em + 4px)',
overflow: 'hidden' as 'hidden',
whiteSpace: 'nowrap' as 'nowrap',
textOverflow: 'ellipsis' as 'ellipsis',
color: theme.palette.text.hint,
},
}
}
const styles = (theme: Theme) => ({
fullWidth: {
width: '100%',
},
gridPadding: {
padding: '0 12px !important',
},
topicList: {
height: '180px',
overflowY: 'scroll' as 'scroll',
margin: '8px 16px',
backgroundColor: theme.palette.background.default,
},
button: {
marginTop: theme.spacing(3),
float: 'right' as 'right',
},
certificateName: {
width: '100%',
height: 'calc(1em + 4px)',
overflow: 'hidden' as 'hidden',
whiteSpace: 'nowrap' as 'nowrap',
textOverflow: 'ellipsis' as 'ellipsis',
color: theme.palette.text.hint,
},
})
export default connect(undefined, mapDispatchToProps)(withStyles(styles)(ConnectionSettings))
export default connect(
undefined,
mapDispatchToProps
)(withStyles(styles)(ConnectionSettings))
@@ -10,7 +10,7 @@ import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { connectionActions, connectionManagerActions } from '../../actions'
import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions'
import { StyleRulesCallback, Theme, withStyles } from '@material-ui/core/styles'
import { Theme, withStyles } from '@material-ui/core/styles'
import {
Button,
@@ -29,17 +29,14 @@ import ConnectionHealthIndicator from '../helper/ConnectionHealthIndicator'
interface Props {
connection: ConnectionOptions
classes: {[s: string]: string}
actions: typeof connectionActions,
classes: { [s: string]: string }
actions: typeof connectionActions
managerActions: typeof connectionManagerActions
connected: boolean
connecting: boolean
}
const protocols = [
'mqtt',
'ws',
]
const protocols = ['mqtt', 'ws']
interface State {
showPassword: boolean
@@ -127,20 +124,12 @@ class ConnectionSettings extends React.Component<Props, State> {
const { classes, connection } = this.props
const certSwitch = (
<Switch
checked={connection.certValidation}
onChange={this.toggleCertValidation}
color="primary"
/>
<Switch checked={connection.certValidation} onChange={this.toggleCertValidation} color="primary" />
)
return (
<div className={classes.switch}>
<FormControlLabel
control={certSwitch}
label="Validate certificate"
labelPlacement="bottom"
/>
<FormControlLabel control={certSwitch} label="Validate certificate" labelPlacement="bottom" />
</div>
)
}
@@ -154,21 +143,11 @@ class ConnectionSettings extends React.Component<Props, State> {
private renderTlsSwitch() {
const { classes, connection } = this.props
const tlsSwitch = (
<Switch
checked={connection.encryption}
onChange={this.toggleTls}
color="primary"
/>
)
const tlsSwitch = <Switch checked={connection.encryption} onChange={this.toggleTls} color="primary" />
return (
<div className={classes.switch}>
<FormControlLabel
control={tlsSwitch}
label="Encryption (tls)"
labelPlacement="bottom"
/>
<FormControlLabel control={tlsSwitch} label="Encryption (tls)" labelPlacement="bottom" />
</div>
)
}
@@ -185,12 +164,13 @@ class ConnectionSettings extends React.Component<Props, State> {
if (this.props.connecting) {
return (
<Button variant="contained" color="primary" className={classes.button} onClick={actions.disconnect}>
<ConnectionHealthIndicator />&nbsp;&nbsp;Abort
<ConnectionHealthIndicator />
&nbsp;&nbsp;Abort
</Button>
)
}
return (
<Button variant="contained" color="primary" className={classes.button} onClick={this.onClickConnect}>
<Button variant="contained" color="primary" className={classes.button} onClick={this.onClickConnect}>
<PowerSettingsNew /> Connect
</Button>
)
@@ -212,10 +192,7 @@ class ConnectionSettings extends React.Component<Props, State> {
const passwordVisibilityButton = (
<InputAdornment position="end">
<IconButton
aria-label="Toggle password visibility"
onClick={this.handleClickShowPassword}
>
<IconButton aria-label="Toggle password visibility" onClick={this.handleClickShowPassword}>
{this.state.showPassword ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>
@@ -287,15 +264,28 @@ class ConnectionSettings extends React.Component<Props, State> {
<br />
<div>
<div style={{ float: 'left' }}>
<Button variant="contained" className={classes.button} onClick={() => this.props.managerActions.deleteConnection(this.props.connection.id)}>
<Button
variant="contained"
className={classes.button}
onClick={() => this.props.managerActions.deleteConnection(this.props.connection.id)}
>
Delete <Delete />
</Button>
<Button variant="contained" className={classes.button} onClick={this.props.managerActions.toggleAdvancedSettings}>
<Button
variant="contained"
className={classes.button}
onClick={this.props.managerActions.toggleAdvancedSettings}
>
<Settings /> Advanced
</Button>
</div>
<div style={{ float : 'right' }}>
<Button variant="contained" color="secondary" className={classes.button} onClick={this.props.managerActions.saveConnectionSettings}>
<div style={{ float: 'right' }}>
<Button
variant="contained"
color="secondary"
className={classes.button}
onClick={this.props.managerActions.saveConnectionSettings}
>
<Save /> Save
</Button>
{this.renderConnectButton()}
@@ -321,21 +311,22 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
const styles: StyleRulesCallback<string> = (theme: Theme) => {
return {
textField: {
width: '100%',
},
switch: {
marginTop: 0,
},
button: {
margin: theme.spacing(1),
},
inputFormControl: {
marginTop: '16px',
},
}
}
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))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(ConnectionSettings))
@@ -7,13 +7,7 @@ import { connect } from 'react-redux'
import { connectionManagerActions } from '../../actions'
import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions'
import { Theme, withStyles } from '@material-ui/core/styles'
import {
Modal,
Paper,
Toolbar,
Typography,
Collapse,
} from '@material-ui/core'
import { Modal, Paper, Toolbar, Typography, Collapse } from '@material-ui/core'
import AdvancedConnectionSettings from './AdvancedConnectionSettings'
interface Props {
@@ -37,8 +31,12 @@ class ConnectionSetup extends React.Component<Props, {}> {
return (
<div>
<Collapse in={!showAdvancedSettings}><ConnectionSettings connection={connection} /></Collapse>
<Collapse in={showAdvancedSettings}><AdvancedConnectionSettings connection={connection} /></Collapse>
<Collapse in={!showAdvancedSettings}>
<ConnectionSettings connection={connection} />
</Collapse>
<Collapse in={showAdvancedSettings}>
<AdvancedConnectionSettings connection={connection} />
</Collapse>
</div>
)
}
@@ -54,13 +52,15 @@ class ConnectionSetup extends React.Component<Props, {}> {
<div>
<Modal open={visible} disableAutoFocus={true}>
<Paper className={classes.root}>
<div className={classes.left}><ProfileList /></div>
<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 className={classes.title} variant="h6" color="inherit">
MQTT Connection
</Typography>
<Typography className={classes.connectionUri}>{mqttConnection && mqttConnection.url}</Typography>
</Toolbar>
{this.renderSettings()}
</div>
@@ -115,7 +115,9 @@ const mapStateToProps = (state: AppState) => {
return {
visible: !state.connection.connected,
showAdvancedSettings: state.connectionManager.showAdvancedSettings,
connection: state.connectionManager.selected ? state.connectionManager.connections[state.connectionManager.selected] : undefined,
connection: state.connectionManager.selected
? state.connectionManager.connections[state.connectionManager.selected]
: undefined,
}
}
@@ -125,4 +127,7 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ConnectionSetup))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(ConnectionSetup))
@@ -6,17 +6,12 @@ import { connect } from 'react-redux'
import { connectionManagerActions } from '../../actions'
import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions'
import { Theme, withStyles } from '@material-ui/core/styles'
import {
List,
ListItem,
ListSubheader,
Typography,
} from '@material-ui/core'
import { List, ListItem, ListSubheader, Typography } from '@material-ui/core'
interface Props {
classes: any
selected?: string
connections: {[s: string]: ConnectionOptions}
connections: { [s: string]: ConnectionOptions }
actions: any
}
@@ -26,7 +21,11 @@ class ProfileList extends React.Component<Props, {}> {
}
private addConnectionButton() {
return <span id="addProfileButton" style={{ marginRight: '12px' }}><AddButton action={this.props.actions.createConnection} /></span>
return (
<span id="addProfileButton" style={{ marginRight: '12px' }}>
<AddButton action={this.props.actions.createConnection} />
</span>
)
}
public render() {
@@ -37,7 +36,13 @@ class ProfileList extends React.Component<Props, {}> {
subheader={<ListSubheader component="div">{this.addConnectionButton()}Connections</ListSubheader>}
>
<div className={this.props.classes.list}>
{Object.values(this.props.connections).map(connection => <ConnectionItem connection={connection} key={connection.id} selected={this.props.selected === connection.id} />)}
{Object.values(this.props.connections).map(connection => (
<ConnectionItem
connection={connection}
key={connection.id}
selected={this.props.selected === connection.id}
/>
))}
</div>
</List>
)
@@ -59,9 +64,9 @@ const mapDispatchToProps = (dispatch: any) => {
}
interface ConnectionItemProps {
connection: ConnectionOptions,
actions: any,
selected: boolean,
connection: ConnectionOptions
actions: any
selected: boolean
classes: any
}
@@ -91,17 +96,16 @@ const connectionItemRenderer = withStyles(connectionItemStyle)((props: Connectio
style={{ display: 'block' }}
onClick={() => props.actions.selectConnection(props.connection.id)}
>
<Typography className={props.classes.name}>
{props.connection.name || 'mqtt broker'}
</Typography>
<Typography className={props.classes.details}>
{connection && connection.url}
</Typography>
<Typography className={props.classes.name}>{props.connection.name || 'mqtt broker'}</Typography>
<Typography className={props.classes.details}>{connection && connection.url}</Typography>
</ListItem>
)
})
const ConnectionItem = connect(null, mapDispatchToProps)(connectionItemRenderer)
const ConnectionItem = connect(
null,
mapDispatchToProps
)(connectionItemRenderer)
const mapStateToProps = (state: AppState) => {
return {
@@ -110,4 +114,7 @@ const mapStateToProps = (state: AppState) => {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ProfileList))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(ProfileList))
-1
View File
@@ -13,7 +13,6 @@ class Key extends React.Component<Props, {}> {
}
public render() {
return (
<div className={this.props.classes.keyStyle}>
<div className={this.props.classes.keyTextStyle}>{this.props.keyboardKey}</div>
+14 -14
View File
@@ -1,15 +1,16 @@
import * as React from 'react'
import { Theme, withStyles } from '@material-ui/core'
const cursor = require('./cursor.png')
interface State {
enabled: boolean
target: {x: number, y: number}
position: {x: number, y: number}
stepSizeX: number,
stepSizeY: number,
target: { x: number; y: number }
position: { x: number; y: number }
stepSizeX: number
stepSizeY: number
}
class Demo extends React.Component<{classes: any}, State> {
class Demo extends React.Component<{ classes: any }, State> {
private timer: any
private frameInterval = 20
@@ -31,8 +32,8 @@ class Demo extends React.Component<{classes: any}, State> {
this.setState({
position: {
x: this.state.position.x + (dirX * steSizeX),
y: this.state.position.y + (dirY * steSizeY),
x: this.state.position.x + dirX * steSizeX,
y: this.state.position.y + dirY * steSizeY,
},
})
@@ -42,10 +43,10 @@ class Demo extends React.Component<{classes: any}, State> {
}
public componentDidMount() {
(window as any).demo.enableMouse = () => {
;(window as any).demo.enableMouse = () => {
this.setState({ enabled: true })
}
(window as any).demo.moveMouse = (x: number, y: number, animationTime: number) => {
;(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 } })
@@ -58,14 +59,12 @@ class Demo extends React.Component<{classes: any}, State> {
return null
}
const style = {
const cursorStyle = {
left: this.state.position.x + 2,
top: this.state.position.y + 2,
}
return (
<img src="../cursor.png" style={style} className={this.props.classes.cursor} />
)
return <img src={cursor} style={cursorStyle} className={this.props.classes.cursor} />
}
}
@@ -76,7 +75,8 @@ const style = (theme: Theme) => ({
position: 'fixed' as 'fixed',
zIndex: 1000000,
filter: theme.palette.type === 'light' ? undefined : 'invert(100%)',
}
pointerEvents: 'none' as 'none',
},
})
export default withStyles(style)(Demo)
+13 -9
View File
@@ -4,11 +4,11 @@ import Key from './Key'
interface State {
message?: string
keys: string[]
keys: Array<string>
location: string
}
class Demo extends React.Component<{classes: any}, State> {
class Demo extends React.Component<{ classes: any }, State> {
private timer: any
constructor(props: any) {
super(props)
@@ -20,20 +20,24 @@ class Demo extends React.Component<{classes: any}, State> {
}
public componentDidMount() {
(window as any).demo.showMessage = (message: string, location: string, duration: number, keys: string[] = []) => {
;(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 = () => {
;(window as any).demo.hideMessage = () => {
this.clearTimer()
this.setState({ message: undefined })
}
}
public render() {
const positions: {[s: string]: number} = {
const positions: { [s: string]: number } = {
top: 0,
bottom: -65,
middle: -32,
@@ -52,16 +56,16 @@ class Demo extends React.Component<{classes: any}, State> {
color: 'white',
backgroundColor: 'rgba(0, 0, 0, 0.8)',
borderRadius: '16px',
}
if (!this.state.message) {
return null
}
let keys: any[] = []
let keys: Array<any> = []
if (this.state.keys.length > 0) {
keys = this.state.keys.map(key => [<Key key={key} keyboardKey={key} />])
keys = this.state.keys
.map(key => [<Key key={key} keyboardKey={key} />])
.reduce((prev, current) => {
return [prev, '+' as any, current]
})

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

+13 -1
View File
@@ -1,8 +1,20 @@
import * as React from 'react'
import ShowText from './ShowText'
import Mouse from './Mouse'
let heapdump: any
(window as any).demo = {}
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 (
+24 -17
View File
@@ -4,13 +4,7 @@ import SentimentDissatisfied from '@material-ui/icons/SentimentDissatisfied'
import Warning from '@material-ui/icons/Warning'
import { electronRendererTelementry } from 'electron-telemetry'
import { Theme, withStyles } from '@material-ui/core/styles'
import {
Button,
Modal,
Paper,
Toolbar,
Typography,
} from '@material-ui/core'
import { Button, Modal, Paper, Toolbar, Typography } from '@material-ui/core'
interface State {
error?: Error
@@ -21,7 +15,6 @@ interface Props {
}
class ErrorBoundary extends React.Component<Props, State> {
public static getDerivedStateFromError(error: Error) {
return { error }
}
@@ -54,23 +47,36 @@ class ErrorBoundary extends React.Component<Props, State> {
<Modal open={true} disableAutoFocus={true}>
<Paper className={classes.root}>
<Toolbar style={{ padding: '0' }}>
<Typography className={classes.title} variant="h6" color="inherit"><Warning /> Oooooops!</Typography>
<Typography className={classes.title} variant="h6" color="inherit">
<Warning /> Oooooops!
</Typography>
</Toolbar>
<Typography className={classes.centered}>I hoped that you would never see this window, but MQTT-Explorer had an unexpected error.</Typography>
<Typography className={classes.centered}><SentimentDissatisfied /></Typography>
<Typography className={classes.centered}>
I hoped that you would never see this window, but MQTT-Explorer had an unexpected error.
</Typography>
<Typography className={classes.centered}>
<SentimentDissatisfied />
</Typography>
<pre className={classes.textColor} style={{ maxHeight: '35vh', overflow: 'scroll' }}>
<code className={classes.textColor}>
{this.state.error.stack}
</code>
<code className={classes.textColor}>{this.state.error.stack}</code>
</pre>
<Typography>
Please report this issue with a short description of what happened to
<span> <a className={classes.textColor} href="https://github.com/thomasnordquist/MQTT-Explorer/issues">https://github.com/thomasnordquist/MQTT-Explorer/issues</a></span>
<span>
{' '}
<a className={classes.textColor} href="https://github.com/thomasnordquist/MQTT-Explorer/issues">
https://github.com/thomasnordquist/MQTT-Explorer/issues
</a>
</span>
</Typography>
<div>
<div className={classes.buttonPositioning}>
<Button className={classes.button} variant="contained" color="secondary" onClick={this.clearStorage}>Start Fresh</Button>
<Button className={classes.button} variant="contained" color="primary" onClick={this.restart}>Restart</Button>
<Button className={classes.button} variant="contained" color="secondary" onClick={this.clearStorage}>
Start Fresh
</Button>
<Button className={classes.button} variant="contained" color="primary" onClick={this.restart}>
Restart
</Button>
</div>
</div>
</Paper>
@@ -98,6 +104,7 @@ const styles = (theme: Theme) => ({
},
textColor: {
color: theme.palette.text.primary,
userSelect: 'all' as 'all',
},
centered: {
textAlign: 'center' as 'center',
+109 -21
View File
@@ -1,28 +1,116 @@
import * as React from 'react'
import ChartPanel from '../ChartPanel'
import ReactSplitPane from 'react-split-pane'
import { Sidebar } from '../Sidebar'
import Tree from '../Tree/Tree'
import { AppState } from '../../reducers'
import { ChartParameters } from '../../reducers/Charts'
import { connect } from 'react-redux'
import { List } from 'immutable'
import { Sidebar } from '../Sidebar'
import ReactResizeDetector from 'react-resize-detector'
interface Props {
heightProperty: any
paneDefaults: any
connectionId?: string
chartPanelItems: List<ChartParameters>
}
function ContentView(props: Props) {
const [height, setHeight] = React.useState<string | number>('100%')
const [sidebarWidth, setSidebarWidth] = React.useState<string | number>('40%')
const [detectedHeight, setDetectedHeight] = React.useState(0)
const [detectedSidebarWidth, setDetectedSidebarWidth] = React.useState(0)
const detectSize = React.useCallback((width, newHeight) => {
setDetectedHeight(newHeight)
}, [])
const detectSidebarSize = React.useCallback(width => {
setDetectedSidebarWidth(width)
}, [])
const closeDrawerCompletelyIfItSitsOnTheEdge = React.useCallback(() => {
if (detectedHeight < 30) {
setHeight('100%')
}
}, [detectedHeight])
const closeSidebarCompletelyIfItSitsOnTheEdge = React.useCallback(() => {
if (detectedSidebarWidth < 30) {
setSidebarWidth('0%')
}
}, [detectedSidebarWidth])
// Open chart panel on start and when a new chart is added but the panel is closed
React.useEffect(() => {
const almostClosed = !isNaN(height as any) && detectedHeight < 30
if ((!height || height === '100%' || almostClosed) && props.chartPanelItems.count() > 0) {
setHeight('calc(100% - 250px)')
}
if (props.chartPanelItems.count() === 0) {
setHeight('100%')
}
}, [props.chartPanelItems])
export default function ContentView(props: {heightProperty: any, paneDefaults: any, connectionId: any}) {
return (
<ReactSplitPane
step={20}
primary="second"
className={props.heightProperty}
split="vertical"
minSize={250}
defaultSize={500}
resizerStyle={{ width: '2px', margin: '0 -10px 0 0px' }}
allowResize={true}
style={{ position: 'relative' }}
pane1Style={{ overflow: 'hidden' }}
>
<div className={props.paneDefaults}>
<Tree />
</div>
<div className={props.paneDefaults}>
<Sidebar connectionId={props.connectionId} />
</div>
</ReactSplitPane>
<div className={props.paneDefaults}>
<span>
<ReactSplitPane
step={20}
primary="second"
className={props.heightProperty}
split="vertical"
minSize={0}
size={sidebarWidth}
onChange={setSidebarWidth}
onDragFinished={closeSidebarCompletelyIfItSitsOnTheEdge}
allowResize={true}
style={{ height: '100%' }}
pane1Style={{ overflowX: 'hidden' }}
resizerStyle={{ height: '100%' }}
>
<span>
<ReactSplitPane
step={10}
split="horizontal"
minSize={0}
size={height}
allowResize={true}
style={{ height: 'calc(100vh - 64px)' }}
pane1Style={{ maxHeight: '100%' }}
pane2Style={{ borderTop: '1px solid #999', display: 'flex' }}
onChange={setHeight}
onDragFinished={closeDrawerCompletelyIfItSitsOnTheEdge}
>
<Tree />
{/** Passing height constraints via flex options down */}
<div style={{ flex: 1, display: 'flex', height: '100%', width: '100%' }}>
{/** Resize detector must not be in the scroll zone, it needs to detect actual available size */}
<ReactResizeDetector handleHeight={true} onResize={detectSize} />
<ChartPanel />
</div>
</ReactSplitPane>
</span>
<div style={{ height: '100%' }}>
<ReactResizeDetector handleWidth={true} onResize={detectSidebarSize} />
<div
className={props.paneDefaults}
style={{ minWidth: '250px', height: '100%', overflowY: 'auto', overflowX: 'hidden' }}
>
<Sidebar connectionId={props.connectionId} />
</div>
</div>
</ReactSplitPane>
</span>
</div>
)
}
const mapStateToProps = (state: AppState) => {
return {
chartPanelItems: state.charts.get('charts'),
}
}
export default connect(mapStateToProps)(ContentView)
+1 -1
View File
@@ -37,7 +37,7 @@ class Notification extends React.Component<Props, {}> {
<Snackbar
anchorOrigin={snackbarAnchor}
open={Boolean(this.props.message)}
autoHideDuration={this.props.type === 'error' ? 10000 : 3000}
autoHideDuration={this.props.type === 'error' ? 10000 : 2000}
onClose={this.props.onClose}
>
<SnackbarContent
+31 -18
View File
@@ -2,26 +2,33 @@ import * as React from 'react'
import * as q from '../../../../backend/src/Model'
import CustomIconButton from '../helper/CustomIconButton'
import Pause from '@material-ui/icons/PauseCircleFilled'
import Resume from '@material-ui/icons/PlayCircleFilled'
import Resume from '@material-ui/icons/PlayArrow'
import { AppState } from '../../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { treeActions } from '../../actions'
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
import { Tooltip } from '@material-ui/core'
import { withStyles, Theme } from '@material-ui/core/styles'
const styles: StyleRulesCallback = theme => ({ })
const styles = (theme: Theme) => ({
icon: {
color: theme.palette.primary.contrastText,
verticalAlign: 'middle' as 'middle',
},
bufferStats: {
minWidth: '8em',
},
})
interface Props {
classes: any
actions: {
tree: typeof treeActions,
tree: typeof treeActions
}
paused: boolean
tree?: q.Tree<any>
}
class PauseButton extends React.Component<Props, {changes: number}> {
class PauseButton extends React.Component<Props, { changes: number }> {
private timer?: any
constructor(props: Props) {
super(props)
@@ -34,8 +41,9 @@ class PauseButton extends React.Component<Props, {changes: number}> {
}
return (
<span>
{this.state.changes} changes<br />
<span className={this.props.classes.bufferStats}>
{this.state.changes} changes
<br />
buffer at {Math.round(this.props.tree.unmergedChanges().fillState() * 10000) / 100}%
</span>
)
@@ -59,16 +67,18 @@ class PauseButton extends React.Component<Props, {changes: number}> {
}
public render() {
const message = this.props.paused ? 'Resumes updating the tree, after applying all recorded changes' : 'Stops all updates, records changes until the buffer is full.'
const message = this.props.paused
? 'Resumes updating the tree, after applying all recorded changes'
: 'Stops all updates, records changes until the buffer is full.'
return (
<div style={{ display: 'inline-flex' }}>
<span>
<CustomIconButton onClick={this.props.actions.tree.togglePause} >
<Tooltip title={message}>
<div /* Required so tooltip does not loose the anchor when the icon changes */>
{this.props.paused ? <Resume /> : <Pause />}
</div>
</Tooltip>
<CustomIconButton onClick={this.props.actions.tree.togglePause} tooltip={message}>
{this.props.paused ? (
<Resume className={this.props.classes.icon} />
) : (
<Pause className={this.props.classes.icon} />
)}
</CustomIconButton>
</span>
{this.props.paused ? this.renderBufferStats() : null}
@@ -79,8 +89,8 @@ class PauseButton extends React.Component<Props, {changes: number}> {
const mapStateToProps = (state: AppState) => {
return {
paused: state.tree.paused,
tree: state.tree.tree,
paused: state.tree.get('paused'),
tree: state.tree.get('tree'),
}
}
@@ -92,4 +102,7 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(PauseButton))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(PauseButton))
+61 -39
View File
@@ -3,32 +3,26 @@ import ClearAdornment from '../helper/ClearAdornment'
import CloudOff from '@material-ui/icons/CloudOff'
import ConnectionHealthIndicator from '../helper/ConnectionHealthIndicator'
import Menu from '@material-ui/icons/Menu'
import PauseButton from './PauseButton'
import Search from '@material-ui/icons/Search'
import { AppState } from '../../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { connectionActions, settingsActions, treeActions } from '../../actions'
import { connectionActions, globalActions, settingsActions } from '../../actions'
import { fade } from '@material-ui/core/styles/colorManipulator'
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
import {
AppBar,
Button,
IconButton,
InputBase,
Toolbar,
Typography,
} from '@material-ui/core'
import PauseButton from './PauseButton'
import { Theme, withStyles } from '@material-ui/core/styles'
import { AppBar, Button, IconButton, InputBase, Toolbar, Typography } from '@material-ui/core'
const styles: StyleRulesCallback = theme => ({
const styles = (theme: Theme) => ({
title: {
display: 'none',
[theme.breakpoints.up('sm')]: {
display: 'block',
display: 'none' as 'none',
[theme.breakpoints.up(750)]: {
display: 'block' as 'block',
},
whiteSpace: 'nowrap' as 'nowrap',
},
search: {
position: 'relative',
position: 'relative' as 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
'&:hover': {
@@ -36,35 +30,47 @@ const styles: StyleRulesCallback = theme => ({
},
marginRight: theme.spacing(2),
marginLeft: 0,
width: '100%',
[theme.breakpoints.up('sm')]: {
marginLeft: theme.spacing(3),
width: 'auto',
flexGrow: 1,
maxWidth: '60%',
[theme.breakpoints.up('md')]: {
maxWidth: '30%',
marginLeft: theme.spacing(4),
width: 'auto' as 'auto',
},
[theme.breakpoints.up(750)]: {
marginLeft: theme.spacing(4),
width: 'auto' as 'auto',
},
},
disconnectIcon: {
[theme.breakpoints.down('xs')]: {
display: 'none' as 'none',
},
marginRight: '8px',
paddingLeft: '8px',
},
searchIcon: {
width: theme.spacing(8),
width: theme.spacing(6),
height: '100%',
position: 'absolute',
pointerEvents: 'none',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
position: 'absolute' as 'absolute',
pointerEvents: 'none' as 'none',
display: 'flex' as 'flex',
alignItems: 'center' as 'center',
justifyContent: 'center' as 'center',
},
inputRoot: {
color: 'inherit',
color: 'inherit' as 'inherit',
width: '100%',
},
inputInput: {
paddingTop: theme.spacing(1),
paddingRight: theme.spacing(1),
paddingBottom: theme.spacing(1),
paddingLeft: theme.spacing(10),
paddingLeft: theme.spacing(6),
transition: theme.transitions.create('width'),
width: '100%',
[theme.breakpoints.up('md')]: {
width: 200,
},
},
menuButton: {
marginLeft: -12,
@@ -79,8 +85,9 @@ const styles: StyleRulesCallback = theme => ({
interface Props {
classes: any
actions: {
settings: typeof settingsActions,
connection: typeof connectionActions,
settings: typeof settingsActions
connection: typeof connectionActions
global: typeof globalActions
}
topicFilter?: string
}
@@ -88,7 +95,7 @@ interface Props {
class TitleBar extends React.Component<Props, {}> {
constructor(props: any) {
super(props)
this.state = { }
this.state = {}
}
private renderSearch() {
@@ -103,7 +110,11 @@ class TitleBar extends React.Component<Props, {}> {
value={topicFilter}
onChange={this.onFilterChange}
placeholder="Search…"
endAdornment={<div style={{ width: '24px', paddingRight: '8px' }}><ClearAdornment action={this.clearFilter} value={topicFilter} /></div>}
endAdornment={
<div style={{ width: '24px', paddingRight: '8px' }}>
<ClearAdornment variant="primary" action={this.clearFilter} value={topicFilter} />
</div>
}
classes={{ root: classes.inputRoot, input: classes.inputInput }}
/>
</div>
@@ -124,14 +135,21 @@ class TitleBar extends React.Component<Props, {}> {
return (
<AppBar position="static">
<Toolbar>
<IconButton className={classes.menuButton} color="inherit" aria-label="Menu" onClick={actions.settings.toggleSettingsVisibility}>
<IconButton
className={classes.menuButton}
color="inherit"
aria-label="Menu"
onClick={actions.global.toggleSettingsVisibility}
>
<Menu />
</IconButton>
<Typography className={classes.title} variant="h6" color="inherit">MQTT Explorer</Typography>
<Typography className={classes.title} variant="h6" color="inherit">
MQTT Explorer
</Typography>
{this.renderSearch()}
<PauseButton />
<Button className={classes.disconnect} onClick={actions.connection.disconnect}>
Disconnect <CloudOff style={{ marginRight: '8px', paddingLeft: '8px' }}/>
Disconnect <CloudOff className={classes.disconnectIcon} />
</Button>
<ConnectionHealthIndicator withBackground={true} />
</Toolbar>
@@ -150,9 +168,13 @@ const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
settings: bindActionCreators(settingsActions, dispatch),
global: bindActionCreators(globalActions, dispatch),
connection: bindActionCreators(connectionActions, dispatch),
},
}
}
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(TitleBar))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(TitleBar))
@@ -0,0 +1,36 @@
import * as React from 'react'
import { InputLabel, Switch, Theme, Tooltip } from '@material-ui/core'
import { withStyles } from '@material-ui/styles'
const sha1 = require('sha1')
function BooleanSwitch(props: { title: string; value: boolean; tooltip: string; action: () => void; classes: any }) {
const { tooltip, value, action, title, classes } = props
const clickHandler = (e: React.MouseEvent) => {
e.stopPropagation()
e.preventDefault()
action()
}
return (
<div style={{ padding: '8px', display: 'flex' }}>
<Tooltip title={tooltip}>
<InputLabel htmlFor={`toggle-${sha1(title)}`} onClick={clickHandler} className={classes.label}>
{title}
</InputLabel>
</Tooltip>
<Tooltip title={tooltip}>
<Switch name={`toggle-${sha1(title)}`} checked={value} onChange={action} color="primary" />
</Tooltip>
</div>
)
}
const styles = (theme: Theme) => ({
label: {
flex: '1',
paddingTop: theme.spacing(1.5),
},
})
export default withStyles(styles)(BooleanSwitch)
@@ -2,7 +2,7 @@ import * as q from '../../../../backend/src/Model'
import * as React from 'react'
import { AppState } from '../../reducers'
import { connect } from 'react-redux'
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
import { StyleRulesCallback, withStyles, Theme } from '@material-ui/core/styles'
import { TopicViewModel } from '../../model/TopicViewModel'
import { Typography } from '@material-ui/core'
import { Base64Message } from '../../../../backend/src/Model/Base64Message'
@@ -15,7 +15,7 @@ interface Stats {
title: string
}
const styles: StyleRulesCallback = theme => ({
const styles = (theme: Theme) => ({
flex: {
display: 'flex',
width: '100%',
@@ -112,13 +112,17 @@ class BrokerStatistics extends React.Component<Props, {}> {
}
const str = node.message.value ? Base64Message.toUnicodeString(node.message.value) : ''
let value = (node.message && node.message.value) ? parseFloat(str) : NaN
let value = node.message && node.message.value ? parseFloat(str) : NaN
value = !isNaN(value) ? abbreviate(value) : str
return (
<div key={stat.title}>
<Typography><b>{stat.title}</b></Typography>
<Typography style={{ paddingLeft: '8px' }}><i>{value}</i></Typography>
<Typography>
<b>{stat.title}</b>
</Typography>
<Typography style={{ paddingLeft: '8px' }}>
<i>{value}</i>
</Typography>
</div>
)
}
+102 -93
View File
@@ -1,12 +1,14 @@
import * as React from 'react'
import BooleanSwitch from './BooleanSwitch'
import BrokerStatistics from './BrokerStatistics'
import ChevronRight from '@material-ui/icons/ChevronRight'
import TimeLocale from './TimeLocale'
import { AppState } from '../../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { settingsActions } from '../../actions'
import { globalActions, settingsActions } from '../../actions'
import { shell } from 'electron'
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
import { Theme, withStyles } from '@material-ui/core/styles'
import { TopicOrder } from '../../reducers/Settings'
import {
@@ -18,29 +20,37 @@ import {
MenuItem,
Select,
Typography,
Switch,
Tooltip,
} from '@material-ui/core'
const sha1 = require('sha1')
export const autoExpandLimitSet = [{
limit: 0,
name: 'Collapsed',
}, {
limit: 2,
name: 'Few',
}, {
limit: 3,
name: 'Some',
}, {
limit: 10,
name: 'Most',
}, {
limit: 1E6,
name: 'All',
}]
export const autoExpandLimitSet = [
{
limit: 0,
name: 'Collapsed',
},
{
limit: 2,
name: 'Few',
},
{
limit: 5,
name: 'Some',
},
{
limit: 15,
name: 'Most',
},
{
limit: 30,
name: 'Most',
},
{
limit: 1e6,
name: 'All',
},
]
const styles: StyleRulesCallback = theme => ({
const styles = (theme: Theme) => ({
drawer: {
backgroundColor: theme.palette.background.default,
flexShrink: 0,
@@ -63,13 +73,13 @@ const styles: StyleRulesCallback = theme => ({
color: theme.palette.text.hint,
cursor: 'pointer' as 'pointer',
},
switchBase: {
height: theme.spacing(4),
},
})
interface Props {
actions: typeof settingsActions
actions: {
settings: typeof settingsActions
global: typeof globalActions
}
autoExpandLimit: number
classes: any
highlightTopicUpdates: boolean
@@ -93,69 +103,63 @@ class Settings extends React.Component<Props, {}> {
private renderHighlightTopicUpdates() {
const { highlightTopicUpdates, actions } = this.props
return this.renderSwitch('Show Activity', highlightTopicUpdates, actions.toggleHighlightTopicUpdates, 'Topics blink when a new message arrives')
}
private renderSwitch(title: string, checked: boolean, action: any, tooltip: string) {
const { classes } = this.props
const clickHandler = (e: React.MouseEvent) => {
e.stopPropagation()
e.preventDefault()
action()
}
return (
<div style={{ padding: '8px', display: 'flex' }}>
<Tooltip title={tooltip}>
<InputLabel
htmlFor={`toggle-${sha1(title)}`}
onClick={clickHandler}
style={{ flex: '1', paddingTop: '8px' }}
>
{title}
</InputLabel>
</Tooltip>
<Tooltip title={tooltip}>
<Switch
name={`toggle-${sha1(title)}`}
checked={checked}
onChange={action}
color="primary"
classes={{ switchBase: classes.switchBase }}
/>
</Tooltip>
</div>
<BooleanSwitch
title="Show Activity"
tooltip="Topics blink when a new message arrives"
value={highlightTopicUpdates}
action={actions.settings.toggleHighlightTopicUpdates}
/>
)
}
private selectTopicsOnMouseOver() {
const { actions, selectTopicWithMouseOver } = this.props
const toggle = () => actions.selectTopicWithMouseOver(!selectTopicWithMouseOver)
const toggle = () => actions.settings.selectTopicWithMouseOver(!selectTopicWithMouseOver)
return this.renderSwitch('Quick Preview', selectTopicWithMouseOver, toggle, 'Select topics on mouse over')
return (
<BooleanSwitch
title="Quick Preview"
tooltip="Select topics on mouse over"
value={selectTopicWithMouseOver}
action={toggle}
/>
)
}
private toggleTheme() {
const { actions, theme } = this.props
return this.renderSwitch('Theme', theme === 'light', actions.toggleTheme, 'Select a theme')
return (
<BooleanSwitch
title="Dark Mode"
tooltip="Enable dark theme"
value={theme === 'dark'}
action={actions.settings.toggleTheme}
/>
)
}
private renderAutoExpand() {
const { classes, autoExpandLimit } = this.props
const limits = autoExpandLimitSet.map(limit => <MenuItem key={limit.limit} value={limit.limit}>{limit.name}</MenuItem>)
const limits = autoExpandLimitSet.map(limit => (
<MenuItem key={limit.limit} value={limit.limit}>
{limit.limit < 10000 && limit.limit > 0 ? `${limit.limit} topics` : limit.name}
</MenuItem>
))
return (
<div style={{ padding: '8px', display: 'flex' }}>
<InputLabel htmlFor="auto-expand" style={{ flex: '1', marginTop: '8px' }}>Auto Expand</InputLabel>
<InputLabel htmlFor="auto-expand" style={{ flex: '1', marginTop: '8px' }}>
Auto Expand
</InputLabel>
<Select
value={autoExpandLimit}
onChange={this.onChangeAutoExpand}
input={<Input name="auto-expand" id="auto-expand-label-placeholder" />}
name="auto-expand"
className={classes.input}
style={{ flex: '1' }}
value={autoExpandLimit}
onChange={this.onChangeAutoExpand}
input={<Input name="auto-expand" id="auto-expand-label-placeholder" />}
name="auto-expand"
className={classes.input}
style={{ flex: '1' }}
>
{limits}
</Select>
@@ -163,8 +167,8 @@ class Settings extends React.Component<Props, {}> {
)
}
private onChangeAutoExpand = (e: React.ChangeEvent<HTMLSelectElement>) => {
this.props.actions.setAutoExpandLimit(parseInt(e.target.value, 10))
private onChangeAutoExpand = (e: React.ChangeEvent<{ value: unknown }>) => {
this.props.actions.settings.setAutoExpandLimit(parseInt(String(e.target.value), 10))
}
private renderNodeOrder() {
@@ -172,7 +176,9 @@ class Settings extends React.Component<Props, {}> {
return (
<div style={{ padding: '8px', display: 'flex' }}>
<InputLabel htmlFor="auto-expand" style={{ flex: '1', marginTop: '8px' }}>Topic Order</InputLabel>
<InputLabel htmlFor="auto-expand" style={{ flex: '1', marginTop: '8px' }}>
Topic Order
</InputLabel>
<Select
value={topicOrder}
onChange={this.onChangeSorting}
@@ -182,43 +188,38 @@ class Settings extends React.Component<Props, {}> {
className={classes.input}
style={{ flex: '1' }}
>
<MenuItem value={TopicOrder.none}><em>default</em></MenuItem>
<MenuItem value={TopicOrder.none}>
<em>default</em>
</MenuItem>
<MenuItem value={TopicOrder.abc}>a-z</MenuItem>
<MenuItem value={TopicOrder.messages}>{TopicOrder.messages}</MenuItem>
<MenuItem value={TopicOrder.topics}>{TopicOrder.topics}</MenuItem>
</Select>
</div>)
</div>
)
}
private onChangeSorting = (e: React.ChangeEvent<HTMLSelectElement>) => {
this.props.actions.setTopicOrder(e.target.value as TopicOrder)
private onChangeSorting = (e: React.ChangeEvent<{ value: unknown }>) => {
this.props.actions.settings.setTopicOrder(e.target.value as TopicOrder)
}
public render() {
const { classes, actions, visible } = this.props
return (
<Drawer
anchor="left"
className={classes.drawer}
open={visible}
variant="persistent"
>
<div
className={classes.paper}
tabIndex={0}
role="button"
>
<Drawer anchor="left" className={classes.drawer} open={visible} variant="persistent">
<div className={classes.paper} tabIndex={0} role="button">
<Typography className={classes.title} variant="h6" color="inherit">
<IconButton onClick={actions.toggleSettingsVisibility}>
<IconButton onClick={actions.global.toggleSettingsVisibility}>
<ChevronRight />
</IconButton>
Settings
</Typography>
<Divider />
<Divider style={{ userSelect: 'none' }} />
</div>
<div>
{this.renderAutoExpand()}
{this.renderNodeOrder()}
<TimeLocale />
{this.renderHighlightTopicUpdates()}
{this.selectTopicsOnMouseOver()}
{this.toggleTheme()}
@@ -238,7 +239,7 @@ const mapStateToProps = (state: AppState) => {
return {
autoExpandLimit: state.settings.get('autoExpandLimit'),
topicOrder: state.settings.get('topicOrder'),
visible: state.settings.get('visible'),
visible: state.globalState.get('settingsVisible'),
highlightTopicUpdates: state.settings.get('highlightTopicUpdates'),
selectTopicWithMouseOver: state.settings.get('selectTopicWithMouseOver'),
theme: state.settings.get('theme'),
@@ -247,8 +248,16 @@ const mapStateToProps = (state: AppState) => {
const mapDispatchToProps = (dispatch: any) => {
return {
actions: bindActionCreators(settingsActions, dispatch),
actions: {
settings: bindActionCreators(settingsActions, dispatch),
global: bindActionCreators(globalActions, dispatch),
},
}
}
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(Settings))
export default withStyles(styles)(
connect(
mapStateToProps,
mapDispatchToProps
)(Settings)
)
@@ -0,0 +1,90 @@
import * as React from 'react'
import DateFormatter from '../helper/DateFormatter'
import { AppState } from '../../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Input, InputLabel, MenuItem, Select, StyleRulesCallback, Theme } from '@material-ui/core'
import { settingsActions } from '../../actions'
import { withStyles } from '@material-ui/styles'
const moment = require('moment/min/moment-with-locales')
interface Props {
actions: {
settings: typeof settingsActions
}
timeLocale: string
classes: any
}
function TimeLocaleSettings(props: Props) {
const { classes, timeLocale, actions } = props
const locales = moment.locales()
const date = new Date()
const localeMenuItems = locales.map((l: string) => (
<MenuItem key={l} value={l}>
<div>
Locale: <b>{l}</b>, Format:{' '}
<b>
<DateFormatter date={date} overrideLocale={l} />
</b>
</div>
</MenuItem>
))
function updateLocale(e: React.ChangeEvent<{ value: unknown }>) {
const locale = e.target.value ? String(e.target.value) : ''
actions.settings.setTimeLocale(locale)
}
return (
<div style={{ padding: '8px', display: 'flex' }}>
<InputLabel htmlFor="time-locale" style={{ flex: '1', marginTop: '8px' }}>
Time Locale
</InputLabel>
<Select
value={timeLocale}
onChange={updateLocale}
input={<Input name="time-locale" id="time-locale-label-placeholder" />}
name="time-locale"
className={classes.input}
renderValue={v => <span>{String(v)}</span>}
style={{ flex: '1' }}
>
{localeMenuItems}
</Select>
</div>
)
}
const mapStateToProps = (state: AppState) => {
return {
timeLocale: state.settings.get('timeLocale'),
}
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
settings: bindActionCreators(settingsActions, dispatch),
},
}
}
const styles = (theme: Theme) => ({
input: {
minWidth: '150px',
margin: `auto ${theme.spacing(1)} auto ${theme.spacing(2)}px`,
},
selected: {
'& div': {
display: 'none',
},
},
})
export default withStyles(styles)(
connect(
mapStateToProps,
mapDispatchToProps
)(TimeLocaleSettings)
)
@@ -16,4 +16,4 @@ export enum CodeBlockColorsBraceMonokai {
string = '#E6DB74',
variable = '#A6E22E',
gutters = '#2F3129',
}
}
-181
View File
@@ -1,181 +0,0 @@
import * as diff from 'diff'
import * as Prism from 'prismjs'
import * as React from 'react'
import { Theme, withStyles } from '@material-ui/core'
import 'prismjs/components/prism-json'
import 'prismjs/themes/prism-tomorrow.css'
import { CodeBlockColors, CodeBlockColorsBraceMonokai } from './CodeBlockColors'
interface Props {
previous: string
current: string
nameOfCompareMessage: string
language?: 'json'
classes: any
}
class CodeDiff extends React.Component<Props, {}> {
constructor(props: Props) {
super(props)
}
private renderChangeAmount(changes: Diff.Change[]) {
const additions = changes.map(change => (change.added === true) ? (change.count || 0) : 0).reduce((a, b) => a + b)
const deletions = changes.map(change => (change.removed === true) ? (change.count || 0) : 0).reduce((a, b) => a + b)
if (additions === 0 && deletions === 0) {
return null
}
return (
<span style={{ display: 'block', marginBottom: '8px', float: 'right' }}>
<span>
Comparing with <b>{this.props.nameOfCompareMessage}</b> message:&nbsp;
<span className={this.props.classes.additions}>+ {additions} line{additions === 1 ? '' : 's'}</span>
, <span className={this.props.classes.deletions}>- {deletions} line{deletions === 1 ? '' : 's'}</span>
</span>
</span>
)
}
private trimNewlineRight(str: string) {
if (str.slice(-1) === '\n') {
return str.slice(0, -1)
}
return str
}
private cssClassForChange(change: diff.Change) {
if (change.added === true) {
return this.props.classes.addition
}
if (change.removed === true) {
return this.props.classes.deletion
}
return this.props.classes.noChange
}
public render() {
const changes = diff.diffLines(this.props.previous, this.props.current)
const styledLines = Prism.highlight(this.props.current, Prism.languages.json, 'json').split('\n')
let lineNumber = 0
const code = changes.map((change, key) => {
const hasStyledCode = change.removed !== true
const changedLines = change.count || 0
if (hasStyledCode && this.props.language === 'json') {
const currentLines = styledLines.slice(lineNumber, lineNumber + changedLines)
const lines = currentLines.map((html: string, idx: number) => {
return <div key={`${key}-${idx}`} className={this.props.classes.line}><span className={this.cssClassForChange(change)} dangerouslySetInnerHTML={{ __html: html }} /></div>
})
lineNumber += changedLines
return <div key={key}>{lines}</div>
}
return this.trimNewlineRight(change.value)
.split('\n')
.map((line, idx) => {
return <div key={`${key}-${idx}`} className={this.props.classes.line}><span className={this.cssClassForChange(change)}>{line}</span></div>
})
})
return (
<div className={this.props.classes.gutters}>
<pre className={`language-json ${this.props.classes.codeBlock}`}>
{code}
</pre>
{this.renderChangeAmount(changes)}
</div>
)
}
}
const style = (theme: Theme) => {
const codeBlockColors = theme.palette.type === 'light' ? CodeBlockColors : CodeBlockColorsBraceMonokai
const baseStyle = {
width: '100%',
}
const before = {
margin: '0 2px 0 -9px',
color: codeBlockColors.text,
}
return {
additions: {
color: 'rgb(10, 255, 10)',
},
deletions: {
color: 'rgb(255, 10, 10)',
},
line: {
lineHeight: 'normal',
},
gutters: {
backgroundColor: codeBlockColors.gutters,
},
codeBlock: {
fontSize: '12px',
maxHeight: '200px',
marginLeft: '33px !important',
backgroundColor: `${codeBlockColors.background} !important`,
'& span': {
color: codeBlockColors.text,
},
'& .token.number': {
color: codeBlockColors.numeric,
},
'& .token.boolean': {
color: codeBlockColors.numeric,
},
'& .token.property': {
color: codeBlockColors.variable,
},
'& .token.string': {
color: codeBlockColors.string,
},
'& .token': {
color: codeBlockColors.text,
},
'& .token.operator': {
color: codeBlockColors.text,
},
'& .token.punctuation': {
color: codeBlockColors.text,
},
},
noChange: {
...baseStyle,
'&:before': {
...before,
},
},
deletion: {
...baseStyle,
backgroundColor: 'rgba(255, 10, 10, 0.3)',
'&:before': {
...before,
content: "'-'",
},
'&:hover': {
backgroundColor: 'rgba(255, 10, 10, 0.6)',
},
},
addition: {
...baseStyle,
backgroundColor: 'rgba(10, 255, 10, 0.3)',
'&:hover': {
backgroundColor: 'rgba(10, 255, 10, 0.5)',
},
'&:before': {
...before,
content: "'+'",
},
},
}
}
export default withStyles(style)(CodeDiff)
@@ -0,0 +1,91 @@
import * as q from '../../../../../backend/src/Model'
import * as React from 'react'
import ShowChart from '@material-ui/icons/ShowChart'
import TopicPlot from '../../TopicPlot'
import { bindActionCreators } from 'redux'
import { chartActions } from '../../../actions'
import { connect } from 'react-redux'
import { Fade, Paper, Popper, Tooltip } from '@material-ui/core'
import { JsonPropertyLocation } from '../../../../../backend/src/JsonAstParser'
interface Props {
treeNode: q.TreeNode<any>
classes: any
literal: JsonPropertyLocation
actions: {
chart: typeof chartActions
}
}
function ChartPreview(props: Props) {
const chartIconRef = React.useRef(null)
const [open, setOpen] = React.useState(false)
const onClick = React.useCallback(() => {
props.actions.chart.addChart({
topic: props.treeNode.path(),
dotPath: props.literal.path !== '' ? props.literal.path : undefined,
})
setOpen(false)
}, [props.literal.path, props.treeNode])
const mouseOver = React.useCallback(() => {
setOpen(true)
}, [])
const mouseOut = React.useCallback(() => {
setOpen(false)
}, [])
const hasEnoughDataToDisplayDiagrams = props.treeNode.messageHistory.count() > 1
const addChartToPanelButton = hasEnoughDataToDisplayDiagrams ? (
<Tooltip title="Add to chart panel">
<ShowChart
ref={chartIconRef}
className={props.classes.icon}
onMouseEnter={mouseOver}
onMouseLeave={mouseOut}
onClick={onClick}
data-test-type="ShowChart"
data-test={props.literal.path}
/>
</Tooltip>
) : (
<Tooltip title="Add to chart panel, not enough data for preview">
<ShowChart
onClick={onClick}
className={props.classes.icon}
style={{ color: '#aaa' }}
data-test-type="ShowChart"
data-test={props.literal.path}
/>
</Tooltip>
)
return (
<span>
{addChartToPanelButton}
<Popper open={open} anchorEl={chartIconRef.current} placement="left-end">
<Fade in={open} timeout={300}>
<Paper style={{ width: '300px' }}>
{open ? <TopicPlot history={props.treeNode.messageHistory} dotPath={props.literal.path} /> : <span />}
</Paper>
</Fade>
</Popper>
</span>
)
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
chart: bindActionCreators(chartActions, dispatch),
},
}
}
export default connect(
undefined,
mapDispatchToProps
)(ChartPreview)
@@ -0,0 +1,45 @@
import * as React from 'react'
import { Theme } from '@material-ui/core'
import { withStyles } from '@material-ui/styles'
interface Props {
changes: Array<Diff.Change>
classes: { [s: string]: any }
nameOfCompareMessage: string
}
function changeAmount(props: Props) {
const additions = props.changes.map(change => (change.added === true ? change.count || 0 : 0)).reduce((a, b) => a + b)
const deletions = props.changes
.map(change => (change.removed === true ? change.count || 0 : 0))
.reduce((a, b) => a + b)
if (additions === 0 && deletions === 0) {
return null
}
return (
<span style={{ display: 'block', marginBottom: '8px', float: 'right' }}>
<span>
Comparing with <b>{props.nameOfCompareMessage}</b> message:&nbsp;
<span className={props.classes.additions}>
+ {additions} line{additions === 1 ? '' : 's'}
</span>
,{' '}
<span className={props.classes.deletions}>
- {deletions} line{deletions === 1 ? '' : 's'}
</span>
</span>
</span>
)
}
const style = (theme: Theme) => ({
additions: {
color: 'rgb(10, 255, 10)',
},
deletions: {
color: 'rgb(255, 10, 10)',
},
})
export default withStyles(style)(changeAmount)
@@ -0,0 +1,104 @@
import * as diff from 'diff'
import * as q from '../../../../../backend/src/Model'
import * as React from 'react'
import Add from '@material-ui/icons/Add'
import ChartPreview from './ChartPreview'
import Remove from '@material-ui/icons/Remove'
import { JsonPropertyLocation } from '../../../../../backend/src/JsonAstParser'
import { lineChangeStyle, trimNewlineRight } from './util'
import { Theme } from '@material-ui/core'
import { withStyles } from '@material-ui/styles'
interface Props {
changes: Array<diff.Change>
literalPositions: Array<JsonPropertyLocation>
classes: any
className: string
treeNode: q.TreeNode<any>
}
const style = (theme: Theme) => {
const icon = {
verticalAlign: 'top',
width: '12px',
height: '12px',
marginTop: '2px',
borderRadius: '50%',
}
return {
icon,
iconButton: {
...icon,
marginTop: '0px',
width: '16px',
height: '16px',
padding: '2px',
'&:hover': {
color: theme.palette.primary.contrastText,
backgroundColor: theme.palette.primary.main,
},
},
gutterLine: {
textAlign: 'right' as 'right',
paddingRight: theme.spacing(0.5),
height: '16px',
width: '100%',
},
}
}
function tokensForLine(change: diff.Change, line: number, props: Props) {
const { classes, literalPositions } = props
const literal = literalPositions[line]
const chartPreview = Boolean(literal) ? (
<ChartPreview
key="chartPreview"
treeNode={props.treeNode}
classes={{ icon: props.classes.iconButton }}
literal={literal}
/>
) : null
if (change.added) {
return [chartPreview, <Add key="add" className={classes.icon} />]
} else if (change.removed) {
return [<Remove key="remove" className={classes.icon} />]
} else {
return [
chartPreview,
<div
key="placeholder"
style={{ width: '12px', display: 'inline-block' }}
dangerouslySetInnerHTML={{ __html: '&nbsp;' }}
/>,
]
}
}
function Gutters(props: Props) {
let currentLine = -1
const gutters = props.changes
.map((change, key) => {
return trimNewlineRight(change.value)
.split('\n')
.map((_, idx) => {
currentLine = !change.removed ? currentLine + 1 : currentLine
return (
<div key={`${key}-${idx}`} style={lineChangeStyle(change)} className={props.classes.gutterLine}>
{tokensForLine(change, currentLine, props)}
</div>
)
})
})
.reduce((a, b) => a.concat(b), [])
return (
<span>
<pre className={props.className}>{gutters}</pre>
</span>
)
}
export default withStyles(style)(Gutters)
@@ -0,0 +1,107 @@
import * as diff from 'diff'
import * as Prism from 'prismjs'
import * as q from '../../../../../backend/src/Model'
import * as React from 'react'
import DiffCount from './DiffCount'
import Gutters from './Gutters'
import { isPlottable, lineChangeStyle, trimNewlineRight } from './util'
import { JsonPropertyLocation, literalsMappedByLines } from '../../../../../backend/src/JsonAstParser'
import { selectTextWithCtrlA } from '../../../utils/handleTextSelectWithCtrlA'
import { style } from './style'
import { withStyles } from '@material-ui/core'
import 'prismjs/components/prism-json'
interface Props {
treeNode: q.TreeNode<any>
previous: string
current: string
nameOfCompareMessage: string
language?: 'json'
classes: any
}
interface State {}
class CodeDiff extends React.Component<Props, State> {
private handleCtrlA = selectTextWithCtrlA({ targetSelector: 'pre ~ pre' })
constructor(props: Props) {
super(props)
this.state = {}
}
private isValidJson(str: string) {
try {
JSON.parse(str)
return true
} catch (error) {
return false
}
}
private plottableLiteralsIndexedWithLineNumbers() {
const allLiterals = this.isValidJson(this.props.current) ? literalsMappedByLines(this.props.current) || [] : []
return allLiterals.map((l: JsonPropertyLocation) => (isPlottable(l.value) ? l : undefined)) as Array<
JsonPropertyLocation
>
}
private renderStyledCodeLines(changes: Array<Diff.Change>) {
const styledLines = Prism.highlight(this.props.current, Prism.languages.json, 'json').split('\n')
let lineNumber = 0
return changes
.map((change, key) => {
const hasStyledCode = change.removed !== true
const changedLines = change.count || 0
if (hasStyledCode && this.props.language === 'json') {
const currentLines = styledLines.slice(lineNumber, lineNumber + changedLines)
const lines = currentLines.map((html: string, idx: number) => {
return (
<div key={`${key}-${idx}`} style={lineChangeStyle(change)} className={this.props.classes.line}>
<span dangerouslySetInnerHTML={{ __html: html }} />
</div>
)
})
lineNumber += changedLines
return [<div key={key}>{lines}</div>]
}
return trimNewlineRight(change.value)
.split('\n')
.map((line, idx) => {
return (
<div key={`${key}-${idx}`} style={lineChangeStyle(change)} className={this.props.classes.line}>
<span>{line}</span>
</div>
)
})
})
.reduce((a, b) => a.concat(b), [])
}
public render() {
const changes = diff.diffLines(this.props.previous, this.props.current)
const literalPositions = this.plottableLiteralsIndexedWithLineNumbers()
const code = this.renderStyledCodeLines(changes)
return (
<div>
<div tabIndex={0} onKeyDown={this.handleCtrlA} className={this.props.classes.codeWrapper}>
<Gutters
className={this.props.classes.gutters}
changes={changes}
treeNode={this.props.treeNode}
literalPositions={literalPositions}
/>
<pre className={this.props.classes.codeBlock}>{code}</pre>
</div>
<DiffCount changes={changes} nameOfCompareMessage={this.props.nameOfCompareMessage} />
</div>
)
}
}
export default withStyles(style)(CodeDiff)
@@ -0,0 +1,63 @@
import { CodeBlockColors, CodeBlockColorsBraceMonokai } from '../CodeBlockColors'
import { Theme } from '@material-ui/core'
export const style = (theme: Theme) => {
const codeBlockColors = theme.palette.type === 'light' ? CodeBlockColors : CodeBlockColorsBraceMonokai
const codeBaseStyle = {
font: "12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace",
display: 'inline-grid' as 'inline-grid',
margin: '0',
padding: '1px 0 0 0',
}
return {
line: {
lineHeight: 'normal' as 'normal',
paddingLeft: '4px',
width: '100%',
height: '16px',
},
codeWrapper: {
display: 'flex',
maxHeight: '15em',
overflow: 'auto',
backgroundColor: `${codeBlockColors.background}`,
margin: '8px 0 0 0',
},
gutters: {
...codeBaseStyle,
width: '33px',
backgroundColor: codeBlockColors.gutters,
userSelect: 'none' as 'none',
},
codeBlock: {
...codeBaseStyle,
width: 'calc(100% - 33px)',
backgroundColor: 'inherit !important',
'& span': {
color: codeBlockColors.text,
},
'& .token.number': {
color: codeBlockColors.numeric,
},
'& .token.boolean': {
color: codeBlockColors.numeric,
},
'& .token.property': {
color: codeBlockColors.variable,
},
'& .token.string': {
color: codeBlockColors.string,
},
'& .token': {
color: codeBlockColors.text,
},
'& .token.operator': {
color: codeBlockColors.text,
},
'& .token.punctuation': {
color: codeBlockColors.text,
},
},
}
}
@@ -0,0 +1,69 @@
export function trimNewlineRight(str: string) {
if (str.slice(-1) === '\n') {
return str.slice(0, -1)
}
return str
}
const gutterBaseStyle = {}
const additionStyle = {
...gutterBaseStyle,
backgroundColor: 'rgba(10, 255, 10, 0.3)',
}
const deletionStyle = {
...gutterBaseStyle,
backgroundColor: 'rgba(255, 10, 10, 0.3)',
}
export function lineChangeStyle(change: Diff.Change) {
if (change.added === true) {
return additionStyle
}
if (change.removed === true) {
return deletionStyle
}
return gutterBaseStyle
}
export function toPlottableValue(value: any): number | undefined {
if (typeof value === 'number') {
return value
}
if (typeof value === 'boolean') {
return value ? 1 : 0
}
const isNumber = !isNaN(value)
const floatVal = parseFloat(value)
if (isNumber && !isNaN(floatVal)) {
return floatVal
}
const intVal = parseInt(value, undefined)
if (isNumber && !isNaN(intVal)) {
return intVal
}
// Convert "on" / "off" to int 1 / 0
if (typeof value === 'string') {
if (/^(on$)|(off$)/i.test(value)) {
return value.toLowerCase() === 'on' ? 1 : 0
}
if (/^[0-9]*,[0-9]+$/.test(value)) {
let parsedFloat = parseFloat(value.replace(',', '.'))
if (!isNaN(parsedFloat)) {
return parsedFloat
}
}
}
}
export function isPlottable(value: any) {
return !isNaN(toPlottableValue(value) as any)
}
@@ -1,16 +1,17 @@
import * as React from 'react'
import { Badge, Typography } from '@material-ui/core'
import { selectTextWithCtrlA } from '../../utils/handleTextSelectWithCtrlA'
import { Theme, withStyles } from '@material-ui/core/styles'
interface HistoryItem {
key: string
title: JSX.Element | string
value: string
selected?: boolean
}
interface Props {
items: HistoryItem[]
items: Array<HistoryItem>
onClick?: (index: number, element: EventTarget) => void
classes: any
contentTypeIndicator?: JSX.Element
@@ -21,7 +22,7 @@ interface State {
collapsed: boolean
}
class MessageHistory extends React.Component<Props, State> {
class HistoryDrawer extends React.Component<Props, State> {
constructor(props: any) {
super(props)
this.state = {
@@ -33,9 +34,13 @@ class MessageHistory extends React.Component<Props, State> {
this.setState({ collapsed: !this.state.collapsed })
}
private handleCtrlA = selectTextWithCtrlA({ targetSelector: 'pre' })
public renderHistory() {
const style = (element: HistoryItem) => ({
backgroundColor: element.selected ? this.props.theme.palette.action.selected : this.props.theme.palette.action.hover,
backgroundColor: element.selected
? this.props.theme.palette.action.selected
: this.props.theme.palette.action.hover,
margin: '8px',
padding: '8px 8px 0 8px',
cursor: this.props.onClick ? 'pointer' : 'inherit',
@@ -44,13 +49,19 @@ class MessageHistory extends React.Component<Props, State> {
const messageStyle: React.CSSProperties = { textOverflow: 'ellipsis', whiteSpace: 'nowrap', overflow: 'hidden' }
const elements = this.props.items.map((element, index) => (
<div
key={index}
key={element.key}
style={style(element)}
onClick={(event: React.MouseEvent) => this.props.onClick && this.props.onClick(index, event.target)}
tabIndex={0}
onKeyDown={this.handleCtrlA}
>
<div><i>{element.title}</i></div>
<div>
<i>{element.title}</i>
</div>
<div style={messageStyle}>
<span><pre>{element.value}</pre></span>
<span>
<pre>{element.value}</pre>
</span>
</div>
</div>
))
@@ -59,11 +70,7 @@ class MessageHistory extends React.Component<Props, State> {
return (
<div className={this.props.classes.main}>
<Typography
component={'span'}
onClick={this.toggle}
style={{ cursor: 'pointer' }}
>
<Typography component={'span'} onClick={this.toggle} style={{ cursor: 'pointer' }}>
<Badge
classes={{ badge: this.props.classes.badge }}
invisible={!visible}
@@ -74,7 +81,7 @@ class MessageHistory extends React.Component<Props, State> {
</Badge>
<div style={{ float: 'right' }}>{this.state.collapsed ? this.props.contentTypeIndicator : null}</div>
</Typography>
<div style={{ maxHeight: '230px', overflowY: 'scroll' }}>
<div style={{ maxHeight: '230px', overflowY: 'scroll' }}>
{this.state.collapsed ? null : this.props.children}
{this.state.collapsed ? null : elements}
</div>
@@ -83,13 +90,7 @@ class MessageHistory extends React.Component<Props, State> {
}
public render() {
return (
<div
style={{ display: 'block', width: '100%' }}
>
{this.renderHistory()}
</div>
)
return <div style={{ display: 'block', width: '100%' }}>{this.renderHistory()}</div>
}
}
@@ -101,4 +102,4 @@ const styles = (theme: Theme) => ({
badge: { right: '-25px' },
})
export default withStyles(styles, { withTheme: true })(MessageHistory)
export default withStyles(styles, { withTheme: true })(HistoryDrawer)
+111
View File
@@ -0,0 +1,111 @@
import * as React from 'react'
import DateFormatter from '../helper/DateFormatter'
import { default as ReactResizeDetector } from 'react-resize-detector'
import { PlotCurveTypes } from '../../reducers/Charts'
import { Theme, withTheme } from '@material-ui/core'
import 'react-vis/dist/style.css'
const { XYPlot, LineMarkSeries, Hint, XAxis, YAxis, HorizontalGridLines } = require('react-vis')
const abbreviate = require('number-abbreviate')
interface Props {
data: Array<{ x: number; y: number }>
theme: Theme
interpolation?: PlotCurveTypes
range?: [number?, number?]
color?: string
}
function mapCurveType(type: PlotCurveTypes | undefined) {
switch (type) {
case 'curve':
return 'curveMonotoneX'
case 'linear':
return 'curveLinear'
case 'cubic_basis_spline':
return 'curveBasis'
case 'step_after':
return 'curveStepAfter'
case 'step_before':
return 'curveStepBefore'
default:
return 'curveMonotoneX'
}
}
export default withTheme((props: Props) => {
const [width, setWidth] = React.useState(300)
const [tooltip, setTooltip] = React.useState({ value: undefined })
const detectResize = React.useCallback(newWidth => setWidth(newWidth), [])
const hintFormatter = React.useCallback((point: any) => {
return [
{ title: <b>Time</b>, value: <DateFormatter date={new Date(point.x)} /> },
{ title: <b>Value</b>, value: point.y },
]
}, [])
const hideTooltip = React.useCallback(() => {
setTooltip({ value: undefined })
}, [])
const showTooltip = React.useCallback((value: any) => {
setTooltip({ value })
}, [])
return React.useMemo(() => {
const data = props.data
const calculatedDomain = domainForData(data)
let yDomain: [number, number] = props.range
? [props.range[0] || calculatedDomain[0], props.range[1] || calculatedDomain[1]]
: calculatedDomain
let color: string =
props.theme.palette.type === 'light' ? props.theme.palette.secondary.dark : props.theme.palette.primary.light
if (props.color) {
color = props.color
}
return (
<div style={{ height: '150px', overflow: 'hidden' }}>
<XYPlot width={width} height={180} yDomain={yDomain}>
<HorizontalGridLines />
<XAxis />
<YAxis width={45} tickFormat={(num: number) => abbreviate(num)} />
<LineMarkSeries
color={color}
onValueMouseOver={showTooltip}
onValueMouseOut={hideTooltip}
size={3}
data={data}
curve={mapCurveType(props.interpolation)}
/>
{tooltip.value ? <Hint format={hintFormatter} value={tooltip.value} /> : null}
</XYPlot>
<ReactResizeDetector handleWidth={true} onResize={detectResize} />
</div>
)
}, [width, props.data, tooltip, props.interpolation, props.range, props.color, props.theme])
})
function domainForData(data: Array<{ x: number; y: number }>): [number, number] {
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,39 @@
import * as React from 'react'
import { default as AceEditor } from 'react-ace'
import { Theme, withTheme } from '@material-ui/core'
import 'brace/mode/json'
import 'brace/theme/dawn'
import 'brace/theme/monokai'
import 'brace/mode/xml'
import 'brace/mode/text'
import 'react-ace'
function Editor(props: {
editorMode: string
theme: Theme
value: string | undefined
onChange: (value: string) => void
}) {
const editorOptions = {
showLineNumbers: false,
tabSize: 2,
}
return (
<AceEditor
style={{}}
mode={props.editorMode}
theme={props.theme.palette.type === 'dark' ? 'monokai' : 'dawn'}
name="UNIQUE_ID_OF_DIV"
width="100%"
height="200px"
showGutter={true}
value={props.value}
onChange={props.onChange}
setOptions={editorOptions}
editorProps={{ $blockScrolling: true }}
/>
)
}
export default withTheme(Editor)
@@ -0,0 +1,40 @@
import * as React from 'react'
import { FormControlLabel, Radio, RadioGroup } from '@material-ui/core'
interface Props {
value: string
onChange: (event: React.ChangeEvent<{}>, value: string) => void
}
export function EditorModeSelect(props: Props) {
const labelStyle = { margin: '0 8px 0 8px' }
return (
<RadioGroup
style={{ display: 'inline-block', float: 'left' }}
value={props.value}
onChange={props.onChange}
row={true}
>
<FormControlLabel
value="text"
style={labelStyle}
control={<Radio color="primary" />}
label="raw"
labelPlacement="top"
/>
<FormControlLabel
value="xml"
style={labelStyle}
control={<Radio color="primary" />}
label="xml"
labelPlacement="top"
/>
<FormControlLabel
value="json"
style={labelStyle}
control={<Radio color="primary" />}
label="json"
labelPlacement="top"
/>
</RadioGroup>
)
}
+56 -161
View File
@@ -1,45 +1,34 @@
import 'react-ace'
import 'brace/mode/json'
import 'brace/mode/text'
import 'brace/mode/xml'
import 'brace/theme/monokai'
import 'brace/theme/dawn'
import * as React from 'react'
import * as q from '../../../../../backend/src/Model'
import * as React from 'react'
import ClearAdornment from '../../helper/ClearAdornment'
import FormatAlignLeft from '@material-ui/icons/FormatAlignLeft'
import History from '../HistoryDrawer'
import Message from './Model/Message'
import Navigation from '@material-ui/icons/Navigation'
import { AppState } from '../../../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { globalActions, publishActions } from '../../../actions'
import {
Button,
FormControlLabel,
Radio,
RadioGroup,
TextField,
FormControl,
InputLabel,
Input,
Checkbox,
MenuItem,
Tooltip,
Fab,
Theme,
withTheme,
} from '@material-ui/core'
import { EditorModeSelect } from './EditorModeSelect'
import QosSelect from './QosSelect'
import Editor from './Editor'
// tslint:disable-next-line
import { default as AceEditor } from 'react-ace'
import { AppState } from '../../../reducers'
import History from '../History'
import Message from './Model/Message'
import Navigation from '@material-ui/icons/Navigation'
import FormatAlignLeft from '@material-ui/icons/FormatAlignLeft'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { publishActions, globalActions } from '../../../actions'
import ClearAdornment from '../../helper/ClearAdornment'
import { TopicViewModel } from '../../../model/TopicViewModel'
const sha1 = require('sha1')
interface Props {
node?: q.TreeNode<TopicViewModel>
connectionId?: string
topic?: string
payload?: string
@@ -47,26 +36,20 @@ interface Props {
globalActions: typeof globalActions
retain: boolean
editorMode: string
qos: 0 | 1 | 2
theme: Theme
}
interface State {
history: Message[]
history: Array<Message>
}
class Publish extends React.Component<Props, State> {
private editorOptions = {
showLineNumbers: false,
tabSize: 2,
}
constructor(props: any) {
super(props)
this.state = { history: [] }
}
private updatePayload = (payload: string, event?: any) => {
private updatePayload = (payload: string) => {
this.props.actions.setPayload(payload)
}
@@ -97,7 +80,7 @@ class Publish extends React.Component<Props, State> {
// Remove duplicates
let filteredHistory = this.state.history.filter(e => e.payload !== payload || e.topic !== topic)
filteredHistory = filteredHistory.slice(-7)
const history: Message[] = [...filteredHistory, { topic, payload, sent: new Date() }]
const history: Array<Message> = [...filteredHistory, { topic, payload, sent: new Date() }]
this.setState({ history })
}
@@ -111,18 +94,18 @@ class Publish extends React.Component<Props, State> {
return (
<div>
<FormControl style={{ width: '100%' }}>
<InputLabel htmlFor="publish-topic">Topic</InputLabel>
<Input
id="publish-topic"
value={topicStr}
startAdornment={<span/>}
endAdornment={<ClearAdornment action={this.clearTopic} value={topicStr} />}
onBlur={this.onTopicBlur}
onChange={this.updateTopic}
multiline={true}
placeholder="example/topic"
/>
</FormControl>
<InputLabel htmlFor="publish-topic">Topic</InputLabel>
<Input
id="publish-topic"
value={topicStr}
startAdornment={<span />}
endAdornment={<ClearAdornment action={this.clearTopic} value={topicStr} />}
onBlur={this.onTopicBlur}
onChange={this.updateTopic}
multiline={true}
placeholder="example/topic"
/>
</FormControl>
</div>
)
}
@@ -135,13 +118,7 @@ class Publish extends React.Component<Props, State> {
private publishButton() {
return (
<Button
variant="contained"
size="small"
color="primary"
onClick={this.publish}
id="publish-button"
>
<Button variant="contained" size="small" color="primary" onClick={this.publish} id="publish-button">
<Navigation style={{ marginRight: '8px' }} /> Publish
</Button>
)
@@ -165,7 +142,11 @@ class Publish extends React.Component<Props, State> {
return (
<Tooltip title="Format JSON">
<Fab style={{ width: '36px', height: '36px', marginLeft: '8px' }} onClick={this.formatJson} id="sidebar-publish-format-json">
<Fab
style={{ width: '36px', height: '36px', marginLeft: '8px' }}
onClick={this.formatJson}
id="sidebar-publish-format-json"
>
<FormatAlignLeft style={{ fontSize: '20px' }} />
</Fab>
</Tooltip>
@@ -176,96 +157,31 @@ class Publish extends React.Component<Props, State> {
return (
<div style={{ marginTop: '16px' }}>
<div style={{ width: '100%', lineHeight: '64px' }}>
{this.renderEditorModeSelection()}
<EditorModeSelect value={this.props.editorMode} onChange={this.updateMode} />
{this.renderFormatJson()}
<div style={{ float: 'right', marginRight: '16px' }}>
{this.publishButton()}
</div>
<div style={{ float: 'right', marginRight: '16px' }}>{this.publishButton()}</div>
</div>
</div>
)
}
private renderEditorModeSelection() {
const labelStyle = { margin: '0 8px 0 8px' }
return (
<RadioGroup
style={{ display: 'inline-block', float: 'left' }}
value={this.props.editorMode}
onChange={this.updateMode}
row={true}
>
<FormControlLabel
value="text"
style={labelStyle}
control={<Radio color="primary" />}
label="raw"
labelPlacement="top"
/>
<FormControlLabel
value="xml"
style={labelStyle}
control={<Radio color="primary" />}
label="xml"
labelPlacement="top"
/>
<FormControlLabel
value="json"
style={labelStyle}
control={<Radio color="primary" />}
label="json"
labelPlacement="top"
/>
</RadioGroup>
)
}
private onChangeQoS = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = parseInt(event.target.value, 10)
if (value !== 0 && value !== 1 && value !== 2) {
return
}
this.props.actions.setQoS(value)
}
private publishMode() {
const labelStyle = { margin: '0 8px 0 8px' }
const itemStyle = { padding: '0' }
const tooltipStyle = { textAlign: 'center' as 'center', width: '100%' }
const qosSelect = (
<TextField
select={true}
value={this.props.qos}
margin="normal"
style={{ margin: '8px 0 8px 8px' }}
onChange={this.onChangeQoS}
>
<MenuItem key={0} value={0} style={itemStyle}>
<Tooltip title="At most once"><div style={tooltipStyle}>0</div></Tooltip>
</MenuItem>
<MenuItem key={1} value={1} style={itemStyle}>
<Tooltip title="At least once"><div style={tooltipStyle}>1</div></Tooltip>
</MenuItem>
<MenuItem key={2} value={2} style={itemStyle}>
<Tooltip title="Exactly once"><div style={tooltipStyle}>2</div></Tooltip>
</MenuItem>
</TextField>
)
return (
<div style={{ marginTop: '8px', clear: 'both' }}>
<div style={{ width: '100%', textAlign: 'right' }}>
<FormControlLabel
style={labelStyle}
control={qosSelect}
label="QoS"
labelPlacement="start"
/>
<Tooltip title="Retained messages only appear to be retained, when client subscribes after the initial publish." placement="top">
<FormControlLabel style={labelStyle} control={<QosSelect />} label="QoS" labelPlacement="start" />
<Tooltip
title="Retained messages only appear to be retained, when client subscribes after the initial publish."
placement="top"
>
<FormControlLabel
value="retain"
style={labelStyle}
control={<Checkbox color="primary" checked={this.props.retain} onChange={this.props.actions.toggleRetain} />}
control={
<Checkbox color="primary" checked={this.props.retain} onChange={this.props.actions.toggleRetain} />
}
label="retain"
labelPlacement="end"
/>
@@ -277,10 +193,10 @@ class Publish extends React.Component<Props, State> {
private history() {
const items = this.state.history.reverse().map(message => ({
key: sha1(message.topic + message.payload),
title: message.topic,
value: message.payload || '',
}))
return <History items={items} onClick={this.didSelectHistoryEntry} />
}
@@ -290,38 +206,15 @@ class Publish extends React.Component<Props, State> {
this.props.actions.setPayload(message.payload)
}
private editor() {
return (
<div style={{ width: '100%', display: 'block' }}>
{this.editorMode()}
{this.renderEditor()}
{this.publishMode()}
</div>
)
}
private renderEditor() {
return (
<AceEditor
mode={this.props.editorMode}
theme={this.props.theme.palette.type === 'dark' ? 'monokai' : 'dawn'}
name="UNIQUE_ID_OF_DIV"
width="100%"
height="200px"
showGutter={true}
value={this.props.payload}
onChange={this.updatePayload}
setOptions={this.editorOptions}
editorProps={{ $blockScrolling: true }}
/>
)
}
public render() {
return (
<div style={{ flexGrow: 1, marginLeft: '8px' }}>
{this.topic()}
{this.editor()}
<div style={{ width: '100%', display: 'block' }}>
{this.editorMode()}
<Editor value={this.props.payload} editorMode={this.props.editorMode} onChange={this.updatePayload} />
{this.publishMode()}
</div>
{this.history()}
</div>
)
@@ -341,8 +234,10 @@ const mapStateToProps = (state: AppState) => {
payload: state.publish.payload,
editorMode: state.publish.editorMode,
retain: state.publish.retain,
qos: state.publish.qos,
}
}
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(Publish))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withTheme(Publish))
@@ -0,0 +1,75 @@
import * as React from 'react'
import { TextField, MenuItem, Tooltip } from '@material-ui/core'
import { connect } from 'react-redux'
import { AppState } from '../../../reducers'
import { bindActionCreators } from 'redux'
import { publishActions } from '../../../actions'
interface Props {
qos: 0 | 1 | 2
actions: {
publish: typeof publishActions
}
}
function QosSelect(props: Props) {
const tooltipStyle = { textAlign: 'center' as 'center', width: '100%' }
const itemStyle = { padding: '0' }
const onChangeQos = React.useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
const value = parseInt(event.target.value, 10)
if (value !== 0 && value !== 1 && value !== 2) {
return
}
props.actions.publish.setQoS(value)
},
[props.actions.publish]
)
return (
<TextField
select={true}
value={props.qos}
margin="normal"
style={{ margin: '8px 0 8px 8px' }}
onChange={onChangeQos}
>
<MenuItem key={0} value={0} style={itemStyle}>
<Tooltip title="At most once">
<div style={tooltipStyle}>0</div>
</Tooltip>
</MenuItem>
<MenuItem key={1} value={1} style={itemStyle}>
<Tooltip title="At least once">
<div style={tooltipStyle}>1</div>
</Tooltip>
</MenuItem>
<MenuItem key={2} value={2} style={itemStyle}>
<Tooltip title="Exactly once">
<div style={tooltipStyle}>2</div>
</Tooltip>
</MenuItem>
</TextField>
)
}
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
publish: bindActionCreators(publishActions, dispatch),
},
}
}
const mapStateToProps = (state: AppState) => {
return {
qos: state.publish.qos,
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(QosSelect)
+46 -50
View File
@@ -8,21 +8,13 @@ import NodeStats from './NodeStats'
import Topic from './Topic'
import ValuePanel from './ValueRenderer/ValuePanel'
import { AppState } from '../../reducers'
import { Badge, ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary, Typography } from '@material-ui/core'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { settingsActions, sidebarActions } from '../../actions'
import { StyleRulesCallback, Theme, withStyles } from '@material-ui/core/styles'
import { Theme, withStyles } from '@material-ui/core/styles'
import { TopicViewModel } from '../../model/TopicViewModel'
import {
ExpansionPanel,
ExpansionPanelDetails,
ExpansionPanelSummary,
Typography,
Tooltip,
Badge,
} from '@material-ui/core'
const throttle = require('lodash.throttle')
const Publish = React.lazy(() => import('./Publish/Publish'))
@@ -36,7 +28,6 @@ interface Props {
}
interface State {
node: q.TreeNode<TopicViewModel>
compareMessage?: q.Message
valueRenderWidth: number
}
@@ -50,8 +41,7 @@ class Sidebar extends React.Component<Props, State> {
constructor(props: any) {
super(props)
console.error('Find and fix me #state')
this.state = { node: new q.Tree(), valueRenderWidth: 300 }
this.state = { valueRenderWidth: 300 }
}
private registerUpdateListener(node: q.TreeNode<TopicViewModel>) {
@@ -70,10 +60,8 @@ class Sidebar extends React.Component<Props, State> {
}
return (
<CustomIconButton onClick={() => this.deleteTopic(this.props.node)}>
<Tooltip title="Clear this topic">
<Delete />
</Tooltip>
<CustomIconButton onClick={() => this.deleteTopic(this.props.node)} tooltip="Clear this topic">
<Delete style={{ marginTop: '-3px' }} />
</CustomIconButton>
)
}
@@ -81,22 +69,23 @@ class Sidebar extends React.Component<Props, State> {
private renderRecursiveTopicDeleteButton() {
const deleteLimit = 50
const topicCount = this.props.node ? this.props.node.childTopicCount() : 0
if ((!this.props.node || topicCount === 0) || (this.props.node.message && topicCount === 1)) {
if (!this.props.node || topicCount === 0 || (this.props.node.message && topicCount === 1)) {
return null
}
return (
<CustomIconButton onClick={() => this.deleteTopic(this.props.node, true, deleteLimit)}>
<Tooltip title={`Deletes up to ${deleteLimit} sub-topics with a single click`}>
<Badge
classes={{ badge: this.props.classes.badge }}
badgeContent={<span style={{ whiteSpace: 'nowrap' }}>{topicCount >= deleteLimit ? '50+' : topicCount}</span>}
color="secondary"
>
<Delete color="action" />
</Badge>
</Tooltip>
</CustomIconButton>
<Badge
classes={{ badge: this.props.classes.badge }}
badgeContent={<span style={{ whiteSpace: 'nowrap' }}>{topicCount >= deleteLimit ? '50+' : topicCount}</span>}
color="secondary"
>
<CustomIconButton
onClick={() => this.deleteTopic(this.props.node, true, deleteLimit)}
tooltip={`Deletes up to ${deleteLimit} sub-topics with a single click`}
>
<Delete style={{ marginTop: '-3px' }} color="action" />
</CustomIconButton>
</Badge>
)
}
@@ -119,20 +108,22 @@ class Sidebar extends React.Component<Props, State> {
<div>
<ExpansionPanel key="topic" defaultExpanded={true} disabled={!Boolean(this.props.node)}>
<ExpansionPanelSummary expandIcon={<ExpandMore />} style={summaryStyle}>
<Typography className={classes.heading}>Topic {copyTopic} {deleteTopic} {deleteRecursiveTopic}</Typography>
<Typography className={classes.heading}>
Topic {copyTopic} {deleteTopic} {deleteRecursiveTopic}
</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails style={this.detailsStyle}>
<Topic node={this.props.node} didSelectNode={this.updateNode} />
</ExpansionPanelDetails>
</ExpansionPanel>
{<ValuePanel />}
<ValuePanel lastUpdate={this.props.node ? this.props.node.lastUpdate : 0} />
<ExpansionPanel defaultExpanded={true}>
<ExpansionPanelSummary expandIcon={<ExpandMore />} style={summaryStyle}>
<Typography className={classes.heading}>Publish</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails style={this.detailsStyle}>
<React.Suspense fallback={<div>Loading...</div>}>
<Publish node={this.props.node} connectionId={this.props.connectionId} />
<Publish connectionId={this.props.connectionId} />
</React.Suspense>
</ExpansionPanelDetails>
</ExpansionPanel>
@@ -161,7 +152,6 @@ class Sidebar extends React.Component<Props, State> {
public componentWillReceiveProps(nextProps: Props) {
this.props.node && this.removeUpdateListener(this.props.node)
nextProps.node && this.registerUpdateListener(nextProps.node)
this.props.node && this.setState({ node: this.props.node })
if (this.props.node !== nextProps.node) {
this.setState({ compareMessage: undefined })
@@ -183,7 +173,7 @@ class Sidebar extends React.Component<Props, State> {
const mapStateToProps = (state: AppState) => {
return {
node: state.tree.selectedTopic,
node: state.tree.get('selectedTopic'),
}
}
@@ -194,20 +184,26 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
const styles: StyleRulesCallback<string> = (theme: Theme) => {
return {
drawer: {
display: 'block',
height: '100%',
},
valuePaper: {
margin: theme.spacing(1),
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
}
}
const styles = (theme: Theme) => ({
drawer: {
display: 'block' as 'block',
},
badge: {
top: '3px',
right: '3px',
},
valuePaper: {
margin: theme.spacing(1),
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
})
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(Sidebar))
export default withStyles(styles)(
connect(
mapStateToProps,
mapDispatchToProps
)(Sidebar)
)
+23 -20
View File
@@ -1,7 +1,7 @@
import * as React from 'react'
import * as q from '../../../../backend/src/Model'
import Button from '@material-ui/core/Button'
import { withStyles, Theme, StyleRulesCallback } from '@material-ui/core/styles'
import { withStyles, Theme } from '@material-ui/core/styles'
import { treeActions } from '../../actions'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
@@ -16,9 +16,9 @@ interface Props {
didSelectNode: (node: q.TreeNode<TopicViewModel>) => void
}
const styles: StyleRulesCallback<string> = (theme: Theme) => ({
const styles = (theme: Theme) => ({
button: {
textTransform: 'none',
textTransform: 'none' as 'none',
padding: '3px 5px 3px 5px',
minWidth: '30px',
},
@@ -26,35 +26,35 @@ const styles: StyleRulesCallback<string> = (theme: Theme) => ({
class Topic extends React.Component<Props, {}> {
public render() {
const { node } = this.props
const { node, theme } = this.props
if (!node) {
return null
}
let key = 0
const breadCrumps = node.branch()
const breadCrumps = node
.branch()
.map(node => node.sourceEdge)
.filter(edge => Boolean(edge))
.map(edge =>
[(
<Button
onClick={() => this.props.actions.selectTopic(edge!.target)}
size="small"
color="secondary"
className={this.props.classes.button}
key={edge!.hash()}
>
{edge!.name}
</Button>
)]
)
.map(edge => [
<Button
onClick={() => this.props.actions.selectTopic(edge!.target)}
size="small"
variant={theme.palette.type === 'light' ? 'contained' : undefined}
color={theme.palette.type === 'light' ? 'primary' : 'secondary'}
className={this.props.classes.button}
key={edge!.hash()}
>
{edge!.name || <span dangerouslySetInnerHTML={{ __html: '&nbsp;' }} />}
</Button>,
])
if (breadCrumps.length === 0) {
return null
}
const joinedBreadCrumps = breadCrumps.reduce((prev, current) =>
prev.concat([<span key={key += 1}>/</span>]).concat(current)
prev.concat([<span key={(key += 1)}> / </span>]).concat(current)
)
return <span style={{ lineHeight: '2.2em' }}>{joinedBreadCrumps}</span>
@@ -67,4 +67,7 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
export default connect(null, mapDispatchToProps)(withStyles(styles, { withTheme: true })(Topic))
export default connect(
null,
mapDispatchToProps
)(withStyles(styles, { withTheme: true })(Topic))
@@ -1,12 +1,17 @@
import * as q from '../../../../../backend/src/Model'
import * as React from 'react'
import BarChart from '@material-ui/icons/BarChart'
import ShowChart from '@material-ui/icons/ShowChart'
import Copy from '../../helper/Copy'
import DateFormatter from '../../helper/DateFormatter'
import History from '../History'
import { TopicViewModel } from '../../../model/TopicViewModel'
import History from '../HistoryDrawer'
import TopicPlot from '../../TopicPlot'
import { Base64Message } from '../../../../../backend/src/Model/Base64Message'
const PlotHistory = React.lazy(() => import('./PlotHistory'))
import { isPlottable } from '../CodeDiff/util'
import { TopicViewModel } from '../../../model/TopicViewModel'
import { bindActionCreators } from 'redux'
import { chartActions } from '../../../actions'
import { connect } from 'react-redux'
import CustomIconButton from '../../helper/CustomIconButton'
const throttle = require('lodash.throttle')
@@ -14,21 +19,36 @@ interface Props {
node?: q.TreeNode<TopicViewModel>
selected?: q.Message
onSelect: (message: q.Message) => void
actions: {
charts: typeof chartActions
}
}
interface State {
displayMessage?: q.Message,
displayMessage?: q.Message
anchorEl?: HTMLElement
}
class MessageHistory extends React.Component<Props, State> {
private updateNode = throttle(() => {
this.setState(this.state)
}, 300)
constructor(props: any) {
super(props)
this.state = { }
this.state = {}
}
private addNodeToCharts = (event: React.MouseEvent) => {
event.preventDefault()
event.stopPropagation()
const { node } = this.props
if (!node) {
return null
}
this.props.actions.charts.addChart({ topic: node.path() })
}
private displayMessage = (index: number, eventTarget: EventTarget) => {
@@ -59,43 +79,66 @@ class MessageHistory extends React.Component<Props, State> {
const history = node.messageHistory.toArray()
let previousMessage: q.Message | undefined = node.message
const historyElements = history.reverse().map((message) => {
const historyElements = history.reverse().map((message, idx) => {
const value = message.value ? Base64Message.toUnicodeString(message.value) : ''
const element = {
title: <span><DateFormatter date={message.received} /> {previousMessage ? <i>(-<DateFormatter date={message.received} intervalSince={previousMessage.received} />)</i> : null}</span>,
value: message.value ? Base64Message.toUnicodeString(message.value) : '',
value,
key: `${message.messageNumber}-${message.received}`,
title: (
<span>
<DateFormatter date={message.received} />
{previousMessage && previousMessage !== message ? (
<i>
(-
<DateFormatter date={message.received} intervalSince={previousMessage.received} />)
</i>
) : null}
<div style={{ float: 'right' }}>
<Copy value={value} />
</div>
</span>
),
selected: message && message === this.props.selected,
}
previousMessage = message
return element
})
const numericMessages = history
.map((message: q.Message) => {
const value = message.value ? parseFloat(Base64Message.toUnicodeString(message.value)) : NaN
return { x: message.received.getTime(), y: value }
}).filter(data => !isNaN(data.y))
const showPlot = numericMessages.length >= 2
const isMessagePlottable =
node.message && node.message.value && isPlottable(Base64Message.toUnicodeString(node.message.value))
return (
<div>
<History
items={historyElements}
contentTypeIndicator={showPlot ? <BarChart /> : undefined}
contentTypeIndicator={
isMessagePlottable ? (
<CustomIconButton
style={{ height: '22px', width: '22px' }}
onClick={this.addNodeToCharts}
tooltip="Add to chart panel"
>
<ShowChart style={{ marginTop: '-5px' }} />
</CustomIconButton>
) : (
undefined
)
}
onClick={this.displayMessage}
>
{showPlot ? this.renderPlot(numericMessages) : null}
{isMessagePlottable ? <TopicPlot history={node.messageHistory} /> : null}
</History>
</div>
)
}
}
public renderPlot(data: Array<{x: number, y: number}>) {
return (
<React.Suspense fallback={<div>Loading...</div>}>
<PlotHistory data={data} />
</React.Suspense>
)
const mapDispatchToProps = (dispatch: any) => {
return {
actions: { charts: bindActionCreators(chartActions, dispatch) },
}
}
export default MessageHistory
export default connect(
null,
mapDispatchToProps
)(MessageHistory)
@@ -1,72 +0,0 @@
import * as q from '../../../../../backend/src/Model'
import * as React from 'react'
import DateFormatter from '../../helper/DateFormatter'
import { default as ReactResizeDetector } from 'react-resize-detector'
import 'react-vis/dist/style.css'
import { Base64Message } from '../../../../../backend/src/Model/Base64Message'
const { XYPlot, LineMarkSeries, Hint, YAxis, HorizontalGridLines } = require('react-vis')
const abbreviate = require('number-abbreviate')
interface Props {
data: Array<{x: number, y: number}>
}
interface Stats {
width: number
value?: any
}
class PlotHistory extends React.Component<Props, Stats> {
constructor(props: Props) {
super(props)
this.state = { width: 300 }
}
private resize = (width: number, height: number) => {
this.setState({ width: width - 12 })
}
private hintFormatter = (point: any) => {
return [
{ title: <b>Time</b>, value: <DateFormatter date={new Date(point.x)} /> },
{ title: <b>Value</b>, value: point.y },
]
}
private _forgetValue = () => {
this.setState({
value: undefined,
})
}
private _rememberValue = (value: any) => {
this.setState({ value })
}
public render() {
const data = this.props.data
return (
<div>
<XYPlot width={this.state.width} height={150}>
<HorizontalGridLines />
<YAxis
width={45}
tickFormat={(num: number) => abbreviate(num)}
/>
<LineMarkSeries
onValueMouseOver={this._rememberValue}
onValueMouseOut={this._forgetValue}
size={3}
data={data}
curve={data.length < 50 ? 'curveCardinal' : undefined}
/>
{this.state.value ? <Hint format={this.hintFormatter} value={this.state.value} /> : null}
</XYPlot>
<ReactResizeDetector handleWidth={true} onResize={this.resize} />
</div>
)
}
}
export default PlotHistory
@@ -35,16 +35,16 @@ interface Props {
sidebarActions: typeof sidebarActions
settingsActions: typeof settingsActions
classes: any
}
interface State {
lastUpdate: number
compareMessage?: q.Message
}
interface State {}
class ValuePanel extends React.Component<Props, State> {
constructor(props: Props) {
super(props)
this.state = { }
this.state = {}
}
private renderValue() {
@@ -53,13 +53,7 @@ class ValuePanel extends React.Component<Props, State> {
return null
}
return (
<ValueRenderer
message={node.message}
messageHistory={node.messageHistory}
compareWith={this.state.compareMessage}
/>
)
return <ValueRenderer treeNode={node} message={node.message} compareWith={this.props.compareMessage} />
}
private renderViewOptions() {
@@ -73,7 +67,7 @@ class ValuePanel extends React.Component<Props, State> {
size="small"
color="secondary"
variant="contained"
style={{ marginTop: '-3px', padding: '0px 4px', minHeight: '24px' }}
style={{ marginTop: '11px', padding: '0px 4px', minHeight: '24px' }}
onClick={this.props.sidebarActions.clearRetainedTopic}
>
retained <Clear style={{ fontSize: '16px', marginLeft: '2px' }} />
@@ -83,10 +77,8 @@ class ValuePanel extends React.Component<Props, State> {
return (
<div style={{ width: '100%', display: 'flex', paddingLeft: '8px' }}>
<span style={{ marginTop: '-8px', flexGrow: 1 }}>{this.renderActionButtons()}</span>
<div style={{ flex: 6, textAlign: 'right' }}>
{this.props.node.mqttMessage.retain ? retainedButton : null}
</div>
<span style={{ marginTop: '2px', flexGrow: 1 }}>{this.renderActionButtons()}</span>
<div style={{ flex: 6, textAlign: 'right' }}>{this.props.node.mqttMessage.retain ? retainedButton : null}</div>
{this.messageMetaInfo()}
</div>
)
@@ -98,9 +90,13 @@ class ValuePanel extends React.Component<Props, State> {
}
return (
<span style={{ width: '100%', paddingLeft: '8px', flex: 6, marginTop: '-14px' }}>
<span style={{ width: '100%', paddingLeft: '8px', flex: 6 }}>
<Typography style={{ textAlign: 'right' }}>QoS: {this.props.node.mqttMessage.qos}</Typography>
<Typography style={{ textAlign: 'right' }}><i><DateFormatter date={this.props.node.message.received} /></i></Typography>
<Typography style={{ textAlign: 'right' }}>
<i>
<DateFormatter date={this.props.node.message.received} />
</i>
</Typography>
</span>
)
}
@@ -114,15 +110,24 @@ class ValuePanel extends React.Component<Props, State> {
}
return (
<ToggleButtonGroup id="valueRendererDisplayMode" value={this.props.valueRendererDisplayMode} exclusive={true} onChange={handleValue}>
<ToggleButtonGroup
id="valueRendererDisplayMode"
value={this.props.valueRendererDisplayMode}
exclusive={true}
onChange={handleValue}
>
<ToggleButton className={this.props.classes.toggleButton} value="diff" id="valueRendererDisplayMode-diff">
<Tooltip title="Show difference between the current and the last message">
<Code />
<span>
<Code className={this.props.classes.toggleButtonIcon} />
</span>
</Tooltip>
</ToggleButton>
<ToggleButton className={this.props.classes.toggleButton} value="raw" id="valueRendererDisplayMode-raw">
<Tooltip title="Raw value">
<Reorder />
<span>
<Reorder className={this.props.classes.toggleButtonIcon} />
</span>
</Tooltip>
</ToggleButton>
</ToggleButtonGroup>
@@ -137,10 +142,10 @@ class ValuePanel extends React.Component<Props, State> {
}
private handleMessageHistorySelect = (message: q.Message) => {
if (message !== this.state.compareMessage) {
this.setState({ compareMessage: message })
if (message !== this.props.compareMessage) {
this.props.sidebarActions.setCompareMessage(message)
} else {
this.setState({ compareMessage: undefined })
this.props.sidebarActions.setCompareMessage(undefined)
}
}
@@ -148,7 +153,10 @@ class ValuePanel extends React.Component<Props, State> {
const { node, classes } = this.props
const { detailsStyle, summaryStyle } = this.panelStyle()
const copyValue = (node && node.message && node.message.value) ? <Copy value={Base64Message.toUnicodeString(node.message.value)} /> : null
const copyValue =
node && node.message && node.message.value ? (
<Copy value={Base64Message.toUnicodeString(node.message.value)} />
) : null
return (
<ExpansionPanel key="value" defaultExpanded={true}>
@@ -158,11 +166,15 @@ class ValuePanel extends React.Component<Props, State> {
<ExpansionPanelDetails style={detailsStyle}>
{this.renderViewOptions()}
<div>
<React.Suspense fallback={<div>Loading...</div>}>
{this.renderValue()}
</React.Suspense>
<React.Suspense fallback={<div>Loading...</div>}>{this.renderValue()}</React.Suspense>
</div>
<div>
<MessageHistory
onSelect={this.handleMessageHistorySelect}
selected={this.props.compareMessage}
node={this.props.node}
/>
</div>
<div><MessageHistory onSelect={this.handleMessageHistorySelect} selected={this.state.compareMessage} node={this.props.node} /></div>
</ExpansionPanelDetails>
</ExpansionPanel>
)
@@ -179,20 +191,25 @@ const mapDispatchToProps = (dispatch: any) => {
const mapStateToProps = (state: AppState) => {
return {
valueRendererDisplayMode: state.settings.get('valueRendererDisplayMode'),
node: state.tree.selectedTopic,
node: state.tree.get('selectedTopic'),
compareMessage: state.sidebar.get('compareMessage'),
}
}
const styles: StyleRulesCallback<string> = (theme: Theme) => {
return {
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
toggleButton: {
height: '36px',
}
}
}
const styles = (theme: Theme) => ({
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
toggleButton: {
height: '36px',
},
toggleButtonIcon: {
verticalAlign: 'middle',
},
})
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ValuePanel))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(ValuePanel))
@@ -9,7 +9,7 @@ import { ValueRendererDisplayMode } from '../../../reducers/Settings'
interface Props {
message: q.Message
messageHistory: q.RingBuffer<q.Message>
treeNode: q.TreeNode<any>
compareWith?: q.Message
renderMode: ValueRendererDisplayMode
}
@@ -27,6 +27,7 @@ class ValueRenderer extends React.Component<Props, State> {
private renderDiff(current: string = '', previous: string = '', language?: 'json') {
return (
<CodeDiff
treeNode={this.props.treeNode}
previous={previous}
current={current}
language={language}
@@ -64,9 +65,8 @@ class ValueRenderer extends React.Component<Props, State> {
}
public renderValue() {
const { message, messageHistory, compareWith, renderMode } = this.props
const previousMessages = messageHistory.toArray()
const { message, treeNode, compareWith, renderMode } = this.props
const previousMessages = treeNode.messageHistory.toArray()
const previousMessage = previousMessages[previousMessages.length - 2]
let compareMessage = compareWith || previousMessage || message
if (renderMode === 'raw') {
+48
View File
@@ -0,0 +1,48 @@
import * as dotProp from 'dot-prop'
import * as q from '../../../backend/src/Model'
import * as React from 'react'
import PlotHistory from './Sidebar/PlotHistory'
import { Base64Message } from '../../../backend/src/Model/Base64Message'
import { toPlottableValue } from './Sidebar/CodeDiff/util'
import { PlotCurveTypes } from '../reducers/Charts'
interface Props {
history: q.MessageHistory
dotPath?: string
interpolation?: PlotCurveTypes
range?: [number?, number?]
color?: string
}
function nodeToHistory(history: q.MessageHistory) {
return history
.toArray()
.map((message: q.Message) => {
const value = message.value ? toPlottableValue(Base64Message.toUnicodeString(message.value)) : NaN
return { x: message.received.getTime(), y: toPlottableValue(value) }
})
.filter(data => !isNaN(data.y as any)) as any
}
function nodeDotPathToHistory(history: q.MessageHistory, dotPath: string) {
return history
.toArray()
.map((message: q.Message) => {
let json = {}
try {
json = message.value ? JSON.parse(Base64Message.toUnicodeString(message.value)) : {}
} catch (ignore) {}
let value = dotProp.get(json, dotPath)
return { x: message.received.getTime(), y: toPlottableValue(value) }
})
.filter(data => !isNaN(data.y as any)) as any
}
function render(props: Props) {
const data = props.dotPath ? nodeDotPathToHistory(props.history, props.dotPath) : nodeToHistory(props.history)
return <PlotHistory color={props.color} range={props.range} interpolation={props.interpolation} data={data} />
}
export default render
+30 -16
View File
@@ -30,7 +30,7 @@ interface State {
lastUpdate: number
}
class Tree extends React.PureComponent<Props, State> {
class TreeComponent extends React.PureComponent<Props, State> {
private updateTimer?: any
private perf: number = 0
private renderTime = 0
@@ -77,18 +77,24 @@ class Tree extends React.PureComponent<Props, State> {
const timeUntilNextUpdate = updateInterval - (performance.now() - this.renderTime)
this.updateTimer = setTimeout(() => {
window.requestIdleCallback(() => {
this.updateTimer && clearTimeout(this.updateTimer)
this.updateTimer = undefined
this.renderTime = performance.now()
window.requestIdleCallback(
() => {
this.updateTimer && clearTimeout(this.updateTimer)
this.updateTimer = undefined
this.renderTime = performance.now()
if (!this.props.paused) {
this.props.tree && this.props.tree.applyUnmergedChanges()
}
window.requestIdleCallback(() => {
this.setState({ lastUpdate: this.renderTime })
}, { timeout: 100 })
}, { timeout: 500 })
if (!this.props.paused) {
this.props.tree && this.props.tree.applyUnmergedChanges()
}
window.requestIdleCallback(
() => {
this.setState({ lastUpdate: this.renderTime })
},
{ timeout: 100 }
)
},
{ timeout: 500 }
)
}, Math.max(0, timeUntilNextUpdate))
}
@@ -101,6 +107,11 @@ class Tree extends React.PureComponent<Props, State> {
const style: React.CSSProperties = {
lineHeight: '1.1',
cursor: 'default',
overflowY: 'scroll',
overflowX: 'hidden',
height: '100%',
width: '100%',
paddingBottom: '16px', // avoid conflict with chart panel Resizer
}
return (
@@ -123,9 +134,9 @@ class Tree extends React.PureComponent<Props, State> {
const mapStateToProps = (state: AppState) => {
return {
tree: state.tree.tree,
paused: state.tree.paused,
filter: state.tree.filter,
tree: state.tree.get('tree'),
paused: state.tree.get('paused'),
filter: state.tree.get('filter'),
host: state.connection.host,
settings: state.settings,
}
@@ -137,4 +148,7 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Tree)
export default connect(
mapStateToProps,
mapDispatchToProps
)(TreeComponent)
+32 -23
View File
@@ -70,7 +70,7 @@ interface State {
selected: boolean
}
class TreeNode extends React.Component<Props, State> {
class TreeNodeComponent extends React.Component<Props, State> {
private animationDirty: boolean = false
private cssAnimationWasSetAt?: number
@@ -97,8 +97,8 @@ class TreeNode extends React.Component<Props, State> {
treeNode.viewModel.change.subscribe(this.viewStateHasChanged)
}
private viewStateHasChanged = (msg: void, viewModel: TopicViewModel) => {
this.setState({ selected: viewModel.isSelected() })
private viewStateHasChanged = () => {
this.props.treeNode.viewModel && this.setState({ selected: this.props.treeNode.viewModel.isSelected() })
}
private removeSubscriber(treeNode: q.TreeNode<TopicViewModel>) {
@@ -107,9 +107,11 @@ class TreeNode extends React.Component<Props, State> {
}
private stateHasChanged(newState: State) {
return this.state.collapsedOverride !== newState.collapsedOverride
|| this.state.mouseOver !== newState.mouseOver
|| this.state.selected !== newState.selected
return (
this.state.collapsedOverride !== newState.collapsedOverride ||
this.state.mouseOver !== newState.mouseOver ||
this.state.selected !== newState.selected
)
}
private toggle() {
@@ -137,7 +139,12 @@ class TreeNode extends React.Component<Props, State> {
private mouseOver = (event: React.MouseEvent) => {
event.stopPropagation()
this.setHover(true)
if (this.props.settings.get('selectTopicWithMouseOver') && this.props.treeNode && this.props.treeNode.message && this.props.treeNode.message.value) {
if (
this.props.settings.get('selectTopicWithMouseOver') &&
this.props.treeNode &&
this.props.treeNode.message &&
this.props.treeNode.message.value
) {
this.props.didSelectTopic(this.props.treeNode)
}
}
@@ -173,13 +180,6 @@ class TreeNode extends React.Component<Props, State> {
this.addSubscriber(treeNode)
}
public componentWillReceiveProps(nextProps: Props) {
if (nextProps.treeNode !== this.props.treeNode) {
this.removeSubscriber(this.props.treeNode)
this.addSubscriber(nextProps.treeNode)
}
}
public componentWillUnmount() {
const { treeNode } = this.props
this.removeSubscriber(treeNode)
@@ -188,11 +188,13 @@ class TreeNode extends React.Component<Props, State> {
public shouldComponentUpdate(nextProps: Props, nextState: State) {
const shouldRenderToRemoveCssAnimation = this.cssAnimationWasSetAt !== undefined
return this.stateHasChanged(nextState)
|| this.props.settings !== nextProps.settings
|| (this.props.lastUpdate !== nextProps.lastUpdate)
|| this.animationDirty
|| shouldRenderToRemoveCssAnimation
return (
this.stateHasChanged(nextState) ||
this.props.settings !== nextProps.settings ||
this.props.lastUpdate !== nextProps.lastUpdate ||
this.animationDirty ||
shouldRenderToRemoveCssAnimation
)
}
public componentDidUpdate() {
@@ -211,12 +213,19 @@ class TreeNode extends React.Component<Props, State> {
public render() {
const { classes } = this.props
const shouldStartAnimation = (!this.animationDirty) && !this.props.isRoot && this.props.settings.get('highlightTopicUpdates')
const shouldStartAnimation =
!this.animationDirty && !this.props.isRoot && this.props.settings.get('highlightTopicUpdates')
const animationName = this.props.theme.palette.type === 'light' ? 'updateLight' : 'updateDark'
const animation = shouldStartAnimation ? { willChange: 'auto', translateZ: 0, animation: `${animationName} 0.5s` } : {}
const animation = shouldStartAnimation
? { willChange: 'auto', translateZ: 0, animation: `${animationName} 0.5s` }
: {}
this.animationDirty = shouldStartAnimation
const highlightClass = this.state.selected ? this.props.classes.selected : (this.state.mouseOver ? this.props.classes.hover : '')
const highlightClass = this.state.selected
? this.props.classes.selected
: this.state.mouseOver
? this.props.classes.hover
: ''
return (
<div>
@@ -243,4 +252,4 @@ class TreeNode extends React.Component<Props, State> {
}
}
export default withStyles(styles, { withTheme: true })(TreeNode)
export default withStyles(styles, { withTheme: true })(TreeNodeComponent)
+9 -10
View File
@@ -49,13 +49,16 @@ class TreeNodeSubnodes extends React.Component<Props, State> {
}
private renderMore() {
this.renderMoreAnimationFrame = (window as any).requestIdleCallback(() => {
this.setState({ ...this.state, alreadyAdded: this.state.alreadyAdded * 1.5 })
}, { timeout: 500 })
this.renderMoreAnimationFrame = (window as any).requestIdleCallback(
() => {
this.setState({ ...this.state, alreadyAdded: this.state.alreadyAdded * 1.5 })
},
{ timeout: 500 }
)
}
public componentWillUnmount() {
(window as any).cancelIdleCallback(this.renderMoreAnimationFrame)
;(window as any).cancelIdleCallback(this.renderMoreAnimationFrame)
}
public render() {
@@ -69,7 +72,7 @@ class TreeNodeSubnodes extends React.Component<Props, State> {
}
const nodes = this.sortedNodes().slice(0, this.state.alreadyAdded)
const listItems = nodes.map((node) => {
const listItems = nodes.map(node => {
return (
<TreeNode
key={`${node.hash()}-${this.props.filter}`}
@@ -82,11 +85,7 @@ class TreeNodeSubnodes extends React.Component<Props, State> {
)
})
return (
<span className={this.props.classes.list}>
{listItems}
</span>
)
return <span className={this.props.classes.list}>{listItems}</span>
}
}
+27 -13
View File
@@ -14,17 +14,25 @@ export interface TreeNodeProps extends React.HTMLAttributes<HTMLElement> {
}
class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
private renderSourceEdge() {
const name = this.props.name || (this.props.treeNode.sourceEdge && this.props.treeNode.sourceEdge.name)
return <span key="edge" className={this.props.classes.sourceEdge}>{name}</span>
return (
<span key="edge" className={this.props.classes.sourceEdge}>
{name}
</span>
)
}
private renderValue() {
return this.props.treeNode.message && this.props.treeNode.message.value && this.props.treeNode.message.length > 0
? <span key="value" className={this.props.classes.value}> = {Base64Message.toUnicodeString(this.props.treeNode.message.value).slice(0, 120)}</span>
: null
return this.props.treeNode.message &&
this.props.treeNode.message.value &&
this.props.treeNode.message.length > 0 ? (
<span key="value" className={this.props.classes.value}>
{' '}
= {Base64Message.toUnicodeString(this.props.treeNode.message.value).slice(0, 120)}
</span>
) : null
}
private renderExpander() {
@@ -32,7 +40,11 @@ class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
return null
}
return <span key="expander" className={this.props.classes.expander} onClick={this.props.toggleCollapsed}>{this.props.collapsed ? '▶' : '▼'}</span>
return (
<span key="expander" className={this.props.classes.expander} onClick={this.props.toggleCollapsed}>
{this.props.collapsed ? '▶' : '▼'}
</span>
)
}
private renderMetadata() {
@@ -41,16 +53,16 @@ class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
}
const messages = this.props.treeNode.leafMessageCount()
return <span key="metadata" className={this.props.classes.collapsedSubnodes}>{`(${this.props.treeNode.childTopicCount()} topics, ${messages} messages)`}</span>
return (
<span
key="metadata"
className={this.props.classes.collapsedSubnodes}
>{`(${this.props.treeNode.childTopicCount()} topics, ${messages} messages)`}</span>
)
}
public render() {
return ([
this.renderExpander(),
this.renderSourceEdge(),
this.renderMetadata(),
this.renderValue(),
])
return [this.renderExpander(), this.renderSourceEdge(), this.renderMetadata(), this.renderValue()]
}
}
@@ -69,9 +81,11 @@ const styles = (theme: Theme) => ({
color: theme.palette.type === 'light' ? '#222' : '#eee',
cursor: 'pointer' as 'pointer',
paddingRight: theme.spacing(0.25),
userSelect: 'none' as 'none',
},
collapsedSubnodes: {
color: theme.palette.text.secondary,
userSelect: 'none' as 'none',
},
})
@@ -1,27 +1,18 @@
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 { green } from '@material-ui/core/colors'
import { AppState } from './reducers'
import Close from '@material-ui/icons/Close'
import CloudDownload from '@material-ui/icons/CloudDownload'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { updateNotifierActions } from './actions'
import axios from 'axios'
import * as compareVersions from 'compare-versions'
import * as electron from 'electron'
import * as os from 'os'
import * as React from 'react'
import axios from 'axios'
import Close from '@material-ui/icons/Close'
import CloudDownload from '@material-ui/icons/CloudDownload'
import { AppState } from '../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { green } from '@material-ui/core/colors'
import { Theme, withStyles } from '@material-ui/core/styles'
import { updateNotifierActions } from '../actions'
import { Button, IconButton, Modal, Paper, Snackbar, SnackbarContent, Typography } from '@material-ui/core'
interface Props {
showUpdateNotification: boolean
@@ -31,25 +22,27 @@ interface Props {
}
interface GithubRelease {
url: string,
assets?: GithubAsset[]
url: string
assets?: Array<GithubAsset>
published_at: string // "2019-01-25T20:14:39Z"
body_html: string
body: string
body_text: string
tag_name: string
prerelease: boolean
}
interface GithubAsset {
id: number
node_id: string
url: string
browser_download_url: string
name: string
label: string
}
interface State {
newerVersions: GithubRelease[]
newerVersions: Array<GithubRelease>
}
class UpdateNotifier extends React.Component<Props, State> {
@@ -57,11 +50,10 @@ class UpdateNotifier extends React.Component<Props, State> {
super(props)
this.state = { newerVersions: [] }
// window.compare = compareVersions
const ownVersion = electron.remote.app.getVersion()
this.fetchReleases().then((releases) => {
this.fetchReleases().then(releases => {
const newerVersions = releases
.filter(release => !/alpha|beta/.test(release.tag_name))
.filter(release => this.allowPrereleaseIfOwnVersionIsBeta(release, ownVersion))
.filter(release => compareVersions(release.tag_name, ownVersion) > 0)
.sort((a, b) => compareVersions(b.tag_name, a.tag_name))
@@ -72,14 +64,20 @@ class UpdateNotifier extends React.Component<Props, State> {
})
}
private fetchReleases(): Promise<GithubRelease[]> {
return axios.get('https://api.github.com/repos/thomasnordquist/mqtt-explorer/releases', {
private allowPrereleaseIfOwnVersionIsBeta(release: GithubRelease, ownVersion: string) {
const ownVersionIsBeta = !/alpha|beta/.test(ownVersion)
return ownVersionIsBeta || !release.prerelease
}
private async fetchReleases(): Promise<Array<GithubRelease>> {
const res = await axios.get('https://api.github.com/repos/thomasnordquist/mqtt-explorer/releases', {
headers: {
accept: 'application/vnd.github.v3.full+json',
},
}).then((res) => {
return res.data
})
return res.data as Array<GithubRelease>
}
private onCloseNotification = (event: React.SyntheticEvent<any>, reason: string) => {
@@ -125,21 +123,19 @@ class UpdateNotifier extends React.Component<Props, State> {
}
private notificationActions() {
return [(
<Button key="undo" size="small" onClick={this.showDetails}>
Details
</Button>
), (
<IconButton
key="close"
aria-label="Close"
color="inherit"
className={this.props.classes.close}
onClick={this.closeNotification}
>
<Close />
</IconButton>
),
return [
<Button key="undo" size="small" onClick={this.showDetails}>
Details
</Button>,
<IconButton
key="close"
aria-label="Close"
color="inherit"
className={this.props.classes.close}
onClick={this.closeNotification}
>
<Close />
</IconButton>,
]
}
@@ -153,30 +149,27 @@ class UpdateNotifier extends React.Component<Props, State> {
.join('<hr />')
return (
<Modal
open={this.props.showUpdateDetails}
disableAutoFocus={true}
onClose={this.hideDetails}
>
<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 {latestUpdate.tag_name}</Typography>
<Typography variant="h6" className={this.props.classes.title}>
Version {latestUpdate.tag_name}
</Typography>
<Typography className={this.props.classes.title}>Changelog</Typography>
<div className={this.props.classes.releaseNotes} dangerouslySetInnerHTML={{ __html: releaseNotes }} />
{this.renderDownloads()}
<Button
className={this.props.classes.download}
onClick={this.openGithub}
>
<Button className={this.props.classes.download} onClick={this.openHomePage}>
Github Page
</Button>
<Button className={this.props.classes.closeButton} color="secondary" onClick={this.hideDetails}>Close</Button>
<Button className={this.props.classes.closeButton} color="secondary" onClick={this.hideDetails}>
Close
</Button>
</Paper>
</Modal>
)
}
private openGithub = () => {
this.openUrl('https://github.com/thomasnordquist/MQTT-Explorer')
private openHomePage = () => {
this.openUrl('https://mqtt-explorer.com')
}
private openUrl = (url: string) => {
@@ -202,18 +195,14 @@ class UpdateNotifier extends React.Component<Props, State> {
return null
}
return latestUpdate.assets
.filter(this.assetForCurrentPlatform)
.map(asset => (
<div>
<Button
className={this.props.classes.download}
onClick={() => this.openUrl(asset.url)}
>
<CloudDownload />&nbsp;{asset.name}
</Button>
</div>
))
return latestUpdate.assets.filter(this.assetForCurrentPlatform).map(asset => (
<div>
<Button className={this.props.classes.download} onClick={() => this.openUrl(asset.browser_download_url)}>
<CloudDownload />
&nbsp;{asset.name}
</Button>
</div>
))
}
public render() {
@@ -266,8 +255,8 @@ const styles = (theme: Theme) => ({
const mapStateToProps = (state: AppState) => {
return {
showUpdateNotification: state.globalState.showUpdateNotification,
showUpdateDetails: state.globalState.showUpdateDetails,
showUpdateNotification: state.globalState.get('showUpdateNotification'),
showUpdateDetails: state.globalState.get('showUpdateDetails'),
}
}
@@ -277,4 +266,9 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(UpdateNotifier))
export default withStyles(styles)(
connect(
mapStateToProps,
mapDispatchToProps
)(UpdateNotifier)
)
+14 -12
View File
@@ -1,28 +1,30 @@
import * as React from 'react'
import Clear from '@material-ui/icons/Clear'
import { IconButton } from '@material-ui/core'
import { IconButton, Theme } from '@material-ui/core'
import { withTheme } from '@material-ui/core/styles'
interface Props {
value?: string
action: any
style?: React.CSSProperties
variant?: 'primary'
theme: Theme
}
/**
* Clear button for text input fields
*/
class ClearAdornment extends React.Component<Props, {}> {
public render() {
if (this.props.value) {
return (
<IconButton style={{ ...this.props.style, padding: '1px' }} onClick={this.props.action}>
<Clear style={{ fontSize: '16px' }} />
</IconButton>
)
}
function ClearAdornment(props: Props) {
if (!props.value) {
return null
}
const color = props.variant === 'primary' ? props.theme.palette.primary.contrastText : undefined
return (
<IconButton style={{ ...props.style, padding: '1px' }} onClick={props.action}>
<Clear style={{ color, fontSize: '16px' }} />
</IconButton>
)
}
export default ClearAdornment
export default withTheme(ClearAdornment)
@@ -4,10 +4,10 @@ import { AppState } from '../../reducers'
import { connect } from 'react-redux'
import { ConnectionHealth } from '../../reducers/Connection'
import { green, orange, red } from '@material-ui/core/colors'
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
import { withStyles, Theme } from '@material-ui/core/styles'
import { Tooltip } from '@material-ui/core'
const styles: StyleRulesCallback = theme => ({
const styles = (theme: Theme) => ({
offline: {
color: red[700],
},
@@ -18,7 +18,10 @@ const styles: StyleRulesCallback = theme => ({
color: orange[600],
},
icon: {
boxShadow: theme.shadows[2].split('),').map(s => `inset ${s}`).join('),'),
boxShadow: theme.shadows[2]
.split('),')
.map(s => `inset ${s}`)
.join('),'),
padding: '6px',
borderRadius: '50%',
backgroundColor: '#eee',
@@ -47,7 +50,7 @@ class ConnectionHealthIndicator extends React.Component<Props, {}> {
return (
<Tooltip title={`Connection health "${health}"`}>
<div>
<div style={{ display: 'inherit' }}>
<DeviceHubOutlined className={`${[classes[health]]} ${this.props.withBackground ? classes.icon : ''}`} />
</div>
</Tooltip>
+28 -38
View File
@@ -2,78 +2,68 @@ import * as React from 'react'
import Check from '@material-ui/icons/Check'
import CustomIconButton from './CustomIconButton'
import FileCopy from '@material-ui/icons/FileCopy'
import green from '@material-ui/core/colors/green'
import { Snackbar, SnackbarContent, Tooltip } from '@material-ui/core'
import { Theme, withStyles } from '@material-ui/core/styles'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { globalActions } from '../../actions'
const copy = require('copy-text-to-clipboard')
interface Props {
value: string
classes: any
actions: {
global: typeof globalActions
}
}
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 }
this.state = { didCopy: false }
}
private handleClick = (event: React.MouseEvent) => {
event.stopPropagation()
copy(this.props.value)
this.setState({ didCopy: true, snackBarOpen: true })
this.props.actions.global.showNotification('Copied to clipboard')
this.setState({ didCopy: true })
setTimeout(() => {
this.setState({ didCopy: false })
}, 1500)
}
public render() {
const icon = !this.state.didCopy
? <FileCopy fontSize="inherit" />
: <Check fontSize="inherit" style={{ cursor: 'default' }} />
const icon = !this.state.didCopy ? (
<FileCopy fontSize="inherit" />
) : (
<Check fontSize="inherit" style={{ cursor: 'default' }} />
)
return (
<span>
<Tooltip placement="top" title="Copy to clipboard">
<span style={{ fontSize: '16px' }}>
<CustomIconButton onClick={this.handleClick} >
<span style={{ fontSize: '16px' }}>
<CustomIconButton onClick={this.handleClick} tooltip="Copy to clipboard">
{icon}
</CustomIconButton>
</span>
</Tooltip>
<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>
)
}
}
export default withStyles(styles)(Copy)
const mapDispatchToProps = (dispatch: any) => {
return {
actions: {
global: bindActionCreators(globalActions, dispatch),
},
}
}
export default connect(
undefined,
mapDispatchToProps
)(Copy)
+15 -4
View File
@@ -1,16 +1,23 @@
import * as React from 'react'
import { IconButton } from '@material-ui/core'
import { IconButton, Tooltip } from '@material-ui/core'
import { Theme, withStyles } from '@material-ui/core/styles'
interface Props {
onClick: any,
classes: any,
onClick: any
tooltip: string
classes: any
style?: React.CSSProperties
}
const styles = (theme: Theme) => ({
button: {
padding: '6px',
fontSize: '1.2em',
width: '32px',
height: '32px',
},
label: {
marginTop: '-2px',
},
})
@@ -26,7 +33,11 @@ class CustomIconButton extends React.Component<Props, {}> {
public render() {
return (
<IconButton className={this.props.classes.button} onClick={this.onClick}>{this.props.children}</IconButton>
<IconButton className={this.props.classes.button} style={this.props.style} onClick={this.onClick}>
<Tooltip title={this.props.tooltip} className={this.props.classes.label}>
<span>{this.props.children}</span>
</Tooltip>
</IconButton>
)
}
}
+21 -9
View File
@@ -1,8 +1,12 @@
import * as React from 'react'
import * as moment from 'moment'
import * as React from 'react'
import { AppState } from '../../reducers'
import { connect } from 'react-redux'
interface Props {
date: Date
overrideLocale?: string
locale?: string
intervalSince?: Date
}
@@ -13,11 +17,10 @@ const unitMapping = {
}
class DateFormatter extends React.Component<Props, {}> {
private intervalSince(intervalSince: Date) {
const interval = intervalSince.getTime() - this.props.date.getTime()
const unit = this.unitForInterval(interval)
return `${moment.duration(interval).as(unit)} ${unitMapping[unit]}`
return `${Math.round(moment.duration(interval).as(unit) * 100) / 100} ${unitMapping[unit]}`
}
private legacyDate() {
@@ -25,25 +28,28 @@ class DateFormatter extends React.Component<Props, {}> {
}
private localizedDate(locale: string) {
return moment(this.props.date).locale(locale).format('L LTS')
return moment(this.props.date)
.locale(locale)
.format('L LTS')
}
private unitForInterval(millis: number) {
private unitForInterval(milliseconds: number) {
const oneMinute = 1000 * 60
const oneHour = oneMinute * 60
if (millis > oneHour * 2) {
if (milliseconds > oneHour * 2) {
return 'h'
}
if (millis > oneMinute * 2) {
if (milliseconds > oneMinute * 2) {
return 'm'
}
return 's'
}
public render() {
const locale = window.navigator.language
const locale = this.props.overrideLocale || this.props.locale
if (this.props.intervalSince) {
return <span>{this.intervalSince(this.props.intervalSince)}</span>
}
@@ -51,4 +57,10 @@ class DateFormatter extends React.Component<Props, {}> {
}
}
export default DateFormatter
const mapStateToProps = (state: AppState) => {
return {
locale: state.settings.get('timeLocale'),
}
}
export default connect(mapStateToProps)(DateFormatter)
@@ -6,7 +6,7 @@ export function isElementInViewport(el: any) {
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) /*or $(window).height() */ &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
)
}
+3 -11
View File
@@ -11,18 +11,10 @@ import { ThemeProvider } from '@material-ui/styles'
import './utils/tracking'
import { themes } from './theme'
const composeEnhancers = /*(window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || */ compose
const store = createStore(
reducers,
composeEnhancers(
applyMiddleware(
reduxThunk,
batchDispatchMiddleware
)
)
)
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(reducers, composeEnhancers(applyMiddleware(reduxThunk, batchDispatchMiddleware)))
function ApplicationRenderer(props: {theme: 'light' | 'dark'}) {
function ApplicationRenderer(props: { theme: 'light' | 'dark' }) {
return (
<ThemeProvider theme={props.theme === 'light' ? themes.lightTheme : themes.darkTheme}>
<App />
+6 -5
View File
@@ -21,7 +21,7 @@ export interface ConnectionOptions {
certValidation: boolean
selfSignedCertificate?: CertificateParameters
clientId?: string
subscriptions: string[]
subscriptions: Array<string>
}
export function toMqttConnection(options: ConnectionOptions): MqttOptions | undefined {
@@ -65,11 +65,12 @@ export function createEmptyConnection(): ConnectionOptions {
export function makeDefaultConnections() {
return {
'iot.eclipse.org': {
// remember: there was also iot.eclipse.org once
'mqtt.eclipse.org': {
...createEmptyConnection(),
id: 'iot.eclipse.org',
name: 'iot.eclipse.org',
host: 'iot.eclipse.org',
id: 'mqtt.eclipse.org',
name: 'mqtt.eclipse.org',
host: 'mqtt.eclipse.org',
},
'test.mosquitto.org': {
...createEmptyConnection(),
+2 -2
View File
@@ -17,7 +17,7 @@ export function clearLegacyConnectionOptions() {
window.localStorage.setItem('connectionSettings', '')
}
export function loadLegacyConnectionOptions(): {[s: string]: ConnectionOptions} | {} {
export function loadLegacyConnectionOptions(): { [s: string]: ConnectionOptions } | {} {
const legacySettingsString = window.localStorage.getItem('connectionSettings')
if (!legacySettingsString) {
return {}
@@ -30,7 +30,7 @@ export function loadLegacyConnectionOptions(): {[s: string]: ConnectionOptions}
return {}
}
const protocolMap: {[s: string]: string} = {
const protocolMap: { [s: string]: string } = {
'tcp://': 'mqtt',
'ws://': 'ws',
'mqtt://': 'mqtt',
+7 -2
View File
@@ -1,13 +1,18 @@
import { Destroyable } from '../../../backend/src/Model/Destroyable'
import { EventDispatcher } from '../../../events'
export class TopicViewModel {
export class TopicViewModel implements Destroyable {
private selected: boolean
public change = new EventDispatcher<void, TopicViewModel>(this)
public change = new EventDispatcher<void, TopicViewModel>()
public constructor() {
this.selected = false
}
public destroy() {
this.change.removeAllListeners()
}
public isSelected() {
return this.selected
}
+109
View File
@@ -0,0 +1,109 @@
import { Action } from 'redux'
import { createReducer } from './lib'
import { Record, List } from 'immutable'
import MoveUp from '../components/ChartPanel/ChartSettings/MoveUp'
export type PlotCurveTypes = 'curve' | 'linear' | 'cubic_basis_spline' | 'step_after' | 'step_before'
export interface ChartParameters {
topic: string
dotPath?: string
interpolation?: PlotCurveTypes
range?: {
from?: number
to?: number
}
width?: 'big' | 'medium' | 'small'
color?: string
}
export interface ChartsStateModel {
charts: List<ChartParameters>
}
export type ChartsState = Record<ChartsStateModel>
export type Action = AddChart | RemoveChart | SetCharts | UpdateChart | MoveUp
export enum ActionTypes {
CHARTS_ADD = 'CHARTS_ADD',
CHARTS_REMOVE = 'CHARTS_REMOVE',
CHARTS_SET = 'CHARTS_SET',
CHARTS_UPDATE = 'CHARTS_UPDATE',
CHARTS_MOVE_UP = 'CHARTS_MOVE_UP',
}
export interface AddChart {
type: ActionTypes.CHARTS_ADD
chart: ChartParameters
}
export interface MoveUp {
type: ActionTypes.CHARTS_ADD
topic: string
dotPath?: string
}
export interface UpdateChart {
type: ActionTypes.CHARTS_ADD
topic: string
dotPath?: string
parameters: Partial<ChartParameters>
}
export interface RemoveChart {
type: ActionTypes.CHARTS_REMOVE
chart: ChartParameters
}
export interface SetCharts {
type: ActionTypes.CHARTS_SET
charts: Array<ChartParameters>
}
const initialState = Record<ChartsStateModel>({
charts: List<ChartParameters>(),
})
export const chartsReducer = createReducer(initialState(), {
CHARTS_ADD: addChart,
CHARTS_REMOVE: removeChart,
CHARTS_SET: setCharts,
CHARTS_UPDATE: updateChart,
CHARTS_MOVE_UP: moveUp,
})
function addChart(state: ChartsState, action: AddChart) {
return state.set('charts', state.get('charts').push(action.chart))
}
function moveUp(state: ChartsState, action: MoveUp) {
const charts = state.get('charts')
const idx = charts.findIndex(chart => chart.topic === action.topic && chart.dotPath === action.dotPath)
const item = charts.get(idx)
const previousItem = charts.get(idx - 1)
if (idx === 0 || !item || !previousItem) {
return
}
const newlyOrderedCharts = charts.set(idx - 1, item).set(idx, previousItem)
return state.set('charts', newlyOrderedCharts)
}
function updateChart(state: ChartsState, action: UpdateChart) {
const charts = state.get('charts')
const chartIdx = charts.findIndex(chart => chart.topic === action.topic && chart.dotPath === action.dotPath)
const chart = charts.get(chartIdx)
return state.set('charts', chart ? charts.set(chartIdx, { ...chart, ...action.parameters }) : charts)
}
function removeChart(state: ChartsState, action: RemoveChart) {
const charts = state.get('charts')
const newCharts = charts.filter(chart => chart.topic !== action.chart.topic || chart.dotPath !== action.chart.dotPath)
return state.set('charts', newCharts)
}
function setCharts(state: ChartsState, action: SetCharts) {
return state.set('charts', List(action.charts))
}
+1 -1
View File
@@ -27,7 +27,7 @@ export enum ActionTypes {
}
export interface SetConnecting {
type: ActionTypes.CONNECTION_SET_CONNECTING,
type: ActionTypes.CONNECTION_SET_CONNECTING
connectionId: string
}
+11 -3
View File
@@ -3,7 +3,7 @@ import { ConnectionOptions } from '../model/ConnectionOptions'
import { createReducer } from './lib'
export interface ConnectionManagerState {
connections: {[s: string]: ConnectionOptions},
connections: { [s: string]: ConnectionOptions }
selected?: string
showAdvancedSettings: boolean
}
@@ -14,7 +14,15 @@ const initialState: ConnectionManagerState = {
showAdvancedSettings: false,
}
export type Action = SetConnections | SelectConnection | UpdateConnection | AddConnection | DeleteConnection | ToggleAdvancedSettings | DeleteSubscription | AddSubscription
export type Action =
| SetConnections
| SelectConnection
| UpdateConnection
| AddConnection
| DeleteConnection
| ToggleAdvancedSettings
| DeleteSubscription
| AddSubscription
export enum ActionTypes {
CONNECTION_MANAGER_SET_CONNECTIONS = 'CONNECTION_MANAGER_SET_CONNECTIONS',
@@ -29,7 +37,7 @@ export enum ActionTypes {
export interface SetConnections {
type: ActionTypes.CONNECTION_MANAGER_SET_CONNECTIONS
connections: {[s: string]: ConnectionOptions}
connections: { [s: string]: ConnectionOptions }
}
export interface SelectConnection {
+74
View File
@@ -0,0 +1,74 @@
import { Action, Reducer } from 'redux'
import { Record } from 'immutable'
import { trackEvent } from '../utils/tracking'
export enum ActionTypes {
showUpdateNotification = 'SHOW_UPDATE_NOTIFICATION',
showUpdateDetails = 'SHOW_UPDATE_DETAILS',
showError = 'SHOW_ERROR',
showNotification = 'SHOW_NOTIFICATION',
didLaunch = 'DID_LAUNCH',
toggleSettingsVisibility = 'TOGGLE_SETTINGS_VISIBILITY',
}
export interface GlobalAction extends Action {
type: ActionTypes
showUpdateNotification?: boolean
showUpdateDetails?: boolean
error?: string
notification?: string
}
interface GlobalStateInterface {
showUpdateNotification?: boolean
showUpdateDetails: boolean
error?: string
notification?: string
launching: boolean
settingsVisible: boolean
}
export type GlobalState = Record<GlobalStateInterface>
const initialStateFactory = Record<GlobalStateInterface>({
showUpdateNotification: false,
showUpdateDetails: false,
error: undefined,
notification: undefined,
launching: true,
settingsVisible: false,
})
export const globalState: Reducer<Record<GlobalStateInterface>, GlobalAction> = (
state = initialStateFactory(),
action
): GlobalState => {
trackEvent(action.type)
console.log(action.type)
switch (action.type) {
case ActionTypes.showUpdateNotification:
return state.set('showUpdateNotification', action.showUpdateNotification)
case ActionTypes.toggleSettingsVisibility:
return state.set('settingsVisible', !state.get('settingsVisible'))
case ActionTypes.showError:
return state.set('error', action.error)
case ActionTypes.showNotification:
return state.set('notification', action.notification)
case ActionTypes.didLaunch:
return state.set('launching', false)
case ActionTypes.showUpdateDetails:
if (action.showUpdateDetails === undefined) {
return state
}
return state.set('showUpdateDetails', action.showUpdateDetails)
default:
return state
}
}
+27 -24
View File
@@ -12,7 +12,7 @@ export type ValueRendererDisplayMode = 'diff' | 'raw'
export interface SettingsState {
autoExpandLimit: number
visible: boolean
timeLocale: string
topicOrder: TopicOrder
topicFilter?: string
highlightTopicUpdates: boolean
@@ -21,19 +21,18 @@ export interface SettingsState {
theme: 'light' | 'dark'
}
export type Actions = SetAutoExpandLimitAction
& DidLoadSettingsAction
& ToggleVisibilityAction
& SetTopicOrderAction
& FilterTopicsAction
& ToggleHighlightTopicUpdatesAction
& SetValueRendererDisplayModeAction
& SetTheme
& SetSelectTopicWithMouseOverAction
export type Actions = SetAutoExpandLimitAction &
DidLoadSettingsAction &
SetTopicOrderAction &
FilterTopicsAction &
ToggleHighlightTopicUpdatesAction &
SetValueRendererDisplayModeAction &
SetTheme &
SetSelectTopicWithMouseOverAction &
SetTimeLocale
export enum ActionTypes {
SETTINGS_SET_AUTO_EXPAND_LIMIT = 'SETTINGS_SET_AUTO_EXPAND_LIMIT',
SETTINGS_TOGGLE_VISIBILITY = 'SETTINGS_TOGGLE_VISIBILITY',
SETTINGS_SET_TOPIC_ORDER = 'SETTINGS_SET_TOPIC_ORDER',
SETTINGS_FILTER_TOPICS = 'SETTINGS_FILTER_TOPICS',
SETTINGS_TOGGLE_HIGHLIGHT_ACTIVITY = 'SETTINGS_TOGGLE_HIGHLIGHT_ACTIVITY',
@@ -42,25 +41,28 @@ export enum ActionTypes {
SETTINGS_SET_SELECT_TOPIC_WITH_MOUSE_OVER = 'SETTINGS_SET_SELECT_TOPIC_WITH_MOUSE_OVER',
SETTINGS_SET_THEME_LIGHT = 'SETTINGS_SET_THEME_LIGHT',
SETTINGS_SET_THEME_DARK = 'SETTINGS_SET_THEME_DARK',
SETTINGS_SET_TIME_LOCALE = 'SETTINGS_SET_TIME_LOCALE',
}
const initialState = Record<SettingsState>({
timeLocale: window.navigator.language,
autoExpandLimit: 0,
topicOrder: TopicOrder.none,
visible: false,
highlightTopicUpdates: true,
valueRendererDisplayMode: 'diff',
selectTopicWithMouseOver: false,
theme: 'light',
topicFilter: undefined,
})
const setTheme = (theme: 'light' | 'dark') => (state: Record<SettingsState>) => {
return state.set('theme', theme)
}
const reducerActions: {[s: string]: (state: Record<SettingsState>, action: Actions) => Record<SettingsState>} = {
const reducerActions: {
[s: string]: (state: Record<SettingsState>, action: Actions) => Record<SettingsState>
} = {
SETTINGS_SET_AUTO_EXPAND_LIMIT: setAutoExpandLimit,
SETTINGS_TOGGLE_VISIBILITY: toggleVisibility,
SETTINGS_SET_TOPIC_ORDER: setTopicOrder,
SETTINGS_FILTER_TOPICS: filterTopics,
SETTINGS_TOGGLE_HIGHLIGHT_ACTIVITY: toggleHighlightTopicUpdates,
@@ -69,13 +71,14 @@ const reducerActions: {[s: string]: (state: Record<SettingsState>, action: Actio
SETTINGS_SET_SELECT_TOPIC_WITH_MOUSE_OVER: setSelectTopicWithMouseOver,
SETTINGS_SET_THEME_LIGHT: setTheme('light'),
SETTINGS_SET_THEME_DARK: setTheme('dark'),
SETTINGS_SET_TIME_LOCALE: setTimeLocale,
}
export const settingsReducer = createReducer(initialState(), reducerActions)
export interface SetTheme {
type: ActionTypes.SETTINGS_SET_THEME_LIGHT | ActionTypes.SETTINGS_SET_THEME_DARK
theme: 'light'
theme: 'light' | 'dark'
}
export interface DidLoadSettingsAction {
@@ -96,6 +99,15 @@ export function setSelectTopicWithMouseOver(state: Record<SettingsState>, action
return state.set('selectTopicWithMouseOver', !state.get('selectTopicWithMouseOver'))
}
export interface SetTimeLocale {
type: ActionTypes.SETTINGS_SET_TIME_LOCALE
timeLocale: string
}
export function setTimeLocale(state: Record<SettingsState>, action: SetTimeLocale): Record<SettingsState> {
return state.set('timeLocale', action.timeLocale)
}
export interface SetValueRendererDisplayModeAction {
type: ActionTypes.SETTINGS_SET_VALUE_RENDERER_DISPLAY_MODE
valueRendererDisplayMode: ValueRendererDisplayMode
@@ -122,15 +134,6 @@ function toggleHighlightTopicUpdates(state: Record<SettingsState>, action: Toggl
return state.set('highlightTopicUpdates', !state.get('highlightTopicUpdates'))
}
export interface ToggleVisibilityAction {
type: ActionTypes.SETTINGS_TOGGLE_VISIBILITY
}
// Todo: Should not be part of the settings store, it would require all tree nodes to re-render when toggeling settings
function toggleVisibility(state: Record<SettingsState>, action: ToggleVisibilityAction) {
return state.set('visible', !state.get('visible'))
}
export interface SetTopicOrderAction {
type: ActionTypes.SETTINGS_SET_TOPIC_ORDER
topicOrder: TopicOrder
+46
View File
@@ -0,0 +1,46 @@
import * as q from '../../../backend/src/Model'
import { Action } from 'redux'
import { createReducer } from './lib'
import { Record } from 'immutable'
interface SidebarModel {
compareMessage?: q.Message
}
const initialStateFactory = Record<SidebarModel>({
compareMessage: undefined,
})
export type Action = SetCompareMessage
export enum ActionTypes {
SIDEBAR_SET_COMPARE_MESSAGE = 'SIDEBAR_SET_COMPARE_MESSAGE',
SIDEBAR_RESET_STORE = 'SIDEBAR_RESET_STORE',
}
export type SidebarState = Record<SidebarModel>
const actions: {
[s: string]: (state: SidebarState, action: Action) => SidebarState
} = {
SIDEBAR_SET_COMPARE_MESSAGE: setCompareMessage,
SIDEBAR_RESET_STORE: resetStore,
}
export const sidebarReducer = createReducer(initialStateFactory(), actions)
export interface SetCompareMessage {
type: ActionTypes.SIDEBAR_SET_COMPARE_MESSAGE
message?: q.Message
}
function setCompareMessage(state: SidebarState, action: SetCompareMessage): SidebarState {
return state.set('compareMessage', action.message)
}
export interface ResetStore {
type: ActionTypes.SIDEBAR_RESET_STORE
}
function resetStore(): SidebarState {
return initialStateFactory()
}
+34 -21
View File
@@ -1,22 +1,26 @@
import * as q from '../../../backend/src/Model'
import { Action } from 'redux'
import { createReducer } from './lib'
import { Record } from 'immutable'
import { TopicViewModel } from '../model/TopicViewModel'
export interface TreeState {
interface TreeStateModel {
tree?: q.Tree<TopicViewModel>
selectedTopic?: q.TreeNode<TopicViewModel>
filter?: string
paused: boolean
}
export type Action = ShowTree | SelectTopic
export type TreeState = Record<TreeStateModel>
export type Action = ShowTree | SelectTopic | ResetStore
export enum ActionTypes {
TREE_SHOW_TREE = 'TREE_SHOW_TREE',
TREE_SELECT_TOPIC = 'TREE_SELECT_TOPIC',
TREE_RESUME_UPDATES = 'TREE_RESUME_UPDATES',
TREE_PAUSE_UPDATES = 'TREE_PAUSE_UPDATES',
TREE_RESET_STORE = 'TREE_RESET_STORE',
}
export interface ShowTree {
@@ -34,35 +38,44 @@ export interface SetPause {
type: ActionTypes.TREE_PAUSE_UPDATES | ActionTypes.TREE_RESUME_UPDATES
}
const initialState: TreeState = {
const initialStateFactory = Record<TreeStateModel>({
paused: false,
tree: undefined,
selectedTopic: undefined,
filter: undefined,
})
const setPaused = (pause: boolean) => (state: TreeState, action: ShowTree): TreeState => {
return state.set('paused', pause)
}
const setPaused = (pause: boolean) => (state: TreeState, action: ShowTree) => {
return {
...state,
paused: pause,
}
}
export const treeReducer = createReducer(initialState, {
const actions: {
[s: string]: (state: TreeState, action: Action) => TreeState
} = {
TREE_SHOW_TREE: showTree,
TREE_SELECT_TOPIC: selectTopic,
TREE_PAUSE_UPDATES: setPaused(true),
TREE_RESUME_UPDATES: setPaused(false),
})
TREE_RESET_STORE: resetStore,
}
function showTree(state: TreeState, action: ShowTree) {
return {
...state,
export const treeReducer = createReducer(initialStateFactory(), actions)
function showTree(state: TreeState, action: ShowTree): TreeState {
return state.merge({
tree: action.tree,
filter: action.filter,
}
})
}
function selectTopic(state: TreeState, action: SelectTopic) {
return {
...state,
selectedTopic: action.selectedTopic,
}
function selectTopic(state: TreeState, action: SelectTopic): TreeState {
return state.set('selectedTopic', action.selectedTopic)
}
export interface ResetStore {
type: ActionTypes.TREE_RESET_STORE
}
function resetStore(state: TreeState, action: ResetStore): TreeState {
return initialStateFactory()
}
+10 -81
View File
@@ -1,103 +1,32 @@
import { Action, combineReducers, Reducer } from 'redux'
import { chartsReducer, ChartsState } from './Charts'
import { combineReducers } from 'redux'
import { connectionManagerReducer, ConnectionManagerState } from './ConnectionManager'
import { connectionReducer, ConnectionState } from './Connection'
import { GlobalState, globalState } from './Global'
import { publishReducer, PublishState } from './Publish'
import { Record } from 'immutable'
import { settingsReducer, SettingsState } from './Settings'
import { trackEvent } from '../utils/tracking'
import { sidebarReducer, SidebarState } from './Sidebar'
import { treeReducer, TreeState } from './Tree'
export enum ActionTypes {
showUpdateNotification = 'SHOW_UPDATE_NOTIFICATION',
showUpdateDetails = 'SHOW_UPDATE_DETAILS',
showError = 'SHOW_ERROR',
showNotification = 'SHOW_NOTIFICATION',
didLaunch = 'DID_LAUNCH',
}
export interface CustomAction extends Action {
type: ActionTypes,
showUpdateNotification?: boolean
showUpdateDetails?: boolean
error?: string
notification?: string
}
export interface AppState {
globalState: GlobalState
tree: TreeState
settings: Record<SettingsState>,
settings: Record<SettingsState>
publish: PublishState
charts: ChartsState
sidebar: SidebarState
connection: ConnectionState
connectionManager: ConnectionManagerState
}
export interface GlobalState {
showUpdateNotification?: boolean
showUpdateDetails: boolean
error?: string
notification?: string
launching: boolean
}
const initialGlobalState: GlobalState = {
showUpdateDetails: false,
launching: true,
}
const globalState: Reducer<GlobalState | undefined, CustomAction> = (state = initialGlobalState, action) => {
if (!state) {
throw Error('No initial state')
}
trackEvent(action.type)
console.log(action.type)
switch (action.type) {
case ActionTypes.showUpdateNotification:
return {
...state,
showUpdateNotification: action.showUpdateNotification,
}
case ActionTypes.showError:
return {
...state,
error: action.error,
}
case ActionTypes.showNotification:
console.log(action)
return {
...state,
notification: action.notification,
}
case ActionTypes.didLaunch:
return {
...state,
launching: false,
}
case ActionTypes.showUpdateDetails:
if (action.showUpdateDetails === undefined) {
return state
}
return {
...state,
showUpdateDetails: action.showUpdateDetails,
}
default:
return state
}
}
const reducer = combineReducers({
export default combineReducers({
globalState,
charts: chartsReducer,
publish: publishReducer,
sidebar: sidebarReducer,
connection: connectionReducer,
settings: settingsReducer,
tree: treeReducer,
connectionManager: connectionManagerReducer,
})
export default reducer
+19 -5
View File
@@ -1,5 +1,5 @@
import { createMuiTheme } from "@material-ui/core";
import { amber } from "@material-ui/core/colors";
import { createMuiTheme } from '@material-ui/core'
import { amber } from '@material-ui/core/colors'
const baseTheme = {
typography: {
@@ -12,14 +12,14 @@ const baseTheme = {
},
}
const lightTheme = createMuiTheme({
const darkTheme = createMuiTheme({
...(baseTheme as any),
palette: {
type: 'dark',
},
})
const darkTheme = createMuiTheme({
const lightTheme = createMuiTheme({
...(baseTheme as any),
palette: {
type: 'light',
@@ -27,9 +27,23 @@ const darkTheme = createMuiTheme({
default: '#fafafa',
},
primary: {
main: '#931e2e',
// main: '#931e2e',
// main: '#172A3A',
// main: '#004346',
// main: '#7D4F50',
// main: '#C14953',
// main: '#4C4C47',
// main: '#2D2D2A',
// main: '#37000A',
// main: '#56000F',
// main: '#89023E',
// main: '#30343F',
main: '#335C67', // ⭐️
},
secondary: amber,
// secondary: {
// main: '#E09F3E',
// },
action: {
disabledBackground: '#fafafa',
},
+5 -1
View File
@@ -46,7 +46,11 @@ class RemoteStorage implements PersistentStorage {
public store<Model>(identifier: StorageIdentifier<Model>, data: Model): Promise<void> {
const transactionId = v4()
const expectation = this.expectAck(transactionId)
rendererEvents.emit(storageStoreEvent, { data, transactionId, store: identifier.id })
rendererEvents.emit(storageStoreEvent, {
data,
transactionId,
store: identifier.id,
})
return expectation
}
@@ -0,0 +1,24 @@
export const selectTextWithCtrlA = (options?: { targetSelector: string }) => (
e: React.KeyboardEvent<HTMLDivElement>
) => {
const isCtrlA = (e.metaKey || e.ctrlKey) && e.key === 'a'
if (isCtrlA && window.getSelection) {
e.persist()
e.preventDefault()
e.stopPropagation()
const selection = window.getSelection()
const range = document.createRange()
const eventTarget = e.target as HTMLElement
const target: HTMLElement | null = options ? eventTarget.querySelector(options.targetSelector) : eventTarget
if (!target) {
console.error('Could not find matching target for Ctrl+A Event')
}
if (selection && target) {
range.selectNodeContents(target)
selection.removeAllRanges()
selection.addRange(range)
}
}
}
+16 -4
View File
@@ -4,9 +4,18 @@ import { electronRendererTelementry } from 'electron-telemetry'
function trackProcessStatistics() {
setInterval(() => {
try {
electronRendererTelementry.trackCustomEvent({ name: 'heapStatistics', payload: process.getHeapStatistics() })
electronRendererTelementry.trackCustomEvent({ name: 'cpuUsage', payload: process.getCPUUsage() })
electronRendererTelementry.trackCustomEvent({ name: 'runningSince', payload: performance.now() })
electronRendererTelementry.trackCustomEvent({
name: 'heapStatistics',
payload: process.getHeapStatistics(),
})
electronRendererTelementry.trackCustomEvent({
name: 'cpuUsage',
payload: process.getCPUUsage(),
})
electronRendererTelementry.trackCustomEvent({
name: 'runningSince',
payload: performance.now(),
})
} catch (error) {
console.error(error)
}
@@ -19,5 +28,8 @@ export function trackEvent(name: string) {
if (name.match(/^@@redux/)) {
return
}
electronRendererTelementry.trackEvent(name)
const blacklist = ['CONNECTION_SET_HEALTH']
if (blacklist.indexOf(name) === -1) {
electronRendererTelementry.trackEvent(name)
}
}
+26 -3
View File
@@ -14,6 +14,7 @@ module.exports = {
path: `${__dirname}/build`,
},
optimization: {
minimize: false,
splitChunks: {
chunks: 'all',
minSize: 30000,
@@ -44,10 +45,10 @@ module.exports = {
},
target: 'electron-renderer',
mode: 'production',
devtool: 'cheap-source-map',
devtool: 'source-map',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json'],
extensions: ['.ts', '.mjs', '.m.js', '.tsx', '.js', '.json', '.node'],
},
module: {
rules: [
@@ -68,6 +69,24 @@ module.exports = {
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {},
},
],
},
{
test: /\.node$/,
use: {
loader: 'node-loader',
options: {
modules: true,
}
}
},
],
},
@@ -75,7 +94,11 @@ module.exports = {
new HtmlWebpackPlugin({ template: './index.html', file: './build/index.html', inject: false }),
// new BundleAnalyzerPlugin(),
new HardSourceWebpackPlugin(),
new webpack.HotModuleReplacementPlugin()
new webpack.HotModuleReplacementPlugin(),
new webpack.IgnorePlugin({
resourceRegExp: /\.\/build\/Debug\/addon/,
contextRegExp: /heapdump$/
}),
],
// When importing a module whose path matches one of the following, just

Some files were not shown because too many files have changed in this diff Show More