Compare commits

..

552 Commits

Author SHA1 Message Date
Nick O'Leary
3169f93cc2 Bump for 0.19.2 2018-08-24 13:25:02 +01:00
Nick O'Leary
c1a1a73599 Ensure node default color is used if palette.theme has no match 2018-08-24 13:08:49 +01:00
Christopher Hiller
db1b0ccb79 fix lost messages / properties in TCPRequest Node; closes #1863 (#1864)
- Added some more checks around this.
- We're choosing to only use the latest message when sending, which is
  effectively what was happening before the queue implementation.
2018-08-23 08:50:51 +01:00
Nick O'Leary
d373105b32 Fix typo in template.html 2018-08-21 13:42:51 +01:00
Nick O'Leary
28b311b7ed Improve error reporting from context plugin loading 2018-08-16 14:36:11 +01:00
Nick O'Leary
dcda513901 Prevent no-op edit of node marking as changed due to icon 2018-08-16 10:54:27 +01:00
Nick O'Leary
72c400794c Change node must handle empty rule set 2018-08-16 09:41:43 +01:00
Nick O'Leary
042409f870 Update for 0.19.1 2018-08-15 15:33:24 +01:00
Nick O'Leary
5b8f4f4069 Pull in latest twitter node 2018-08-15 15:31:55 +01:00
Nick O'Leary
d132d63c1d Handle windows paths for context storage 2018-08-15 15:31:42 +01:00
Nick O'Leary
ef8b936069 Handle persisting objects with circular refs in context 2018-08-15 10:19:37 +01:00
Nick O'Leary
36e3bfffb4 Ensure js editor can expand to fill available space 2018-08-14 17:30:25 +01:00
Nick O'Leary
91a38bdb60 Add example localfilesystem contextStorage to settings 2018-08-14 16:28:59 +01:00
Nick O'Leary
f169a68319 Fix template node handling of nested context tags 2018-08-14 16:21:38 +01:00
Nick O'Leary
ee886f98dd Update dependencies 2018-08-13 11:19:05 +01:00
Nick O'Leary
a3826cc6a7 Bump version to 0.19 2018-08-13 11:06:38 +01:00
Nick O'Leary
ba33b832ba Info side putting info text in wrong pane 2018-08-13 11:05:33 +01:00
Nick O'Leary
f6c017176b Add core:toggle-navigator action 2018-08-13 11:04:34 +01:00
Nick O'Leary
7a01b115bb User settings view tab does not scroll properly 2018-08-13 11:03:55 +01:00
Nick O'Leary
1dc021e871 Improve custom context store module logging 2018-08-09 15:37:04 +01:00
Nick O'Leary
c9f916ebab Fixup context test case to block until context close completes 2018-08-09 15:36:43 +01:00
Nick O'Leary
ff627fd128 Fix localfilesystem clean handling 2018-08-09 14:39:20 +01:00
Nick O'Leary
dfa077fd5f Update package versions 2018-07-30 15:25:10 +01:00
Nick O'Leary
5155770213 Ensure add/remove modules are handled sequentially 2018-07-30 10:08:39 +01:00
Nick O'Leary
f1d5bbb036 Remove type editors from master template 2018-07-28 22:36:31 +01:00
Nick O'Leary
69ed0aebc3 Merge pull request #1850 from node-red-hitachi/without-callback
Allow `get` and `keys` to be called without callback
2018-07-28 22:08:36 +01:00
Nick O'Leary
549e56e220 Add editorTheme.palette.theme to allow overriding colours 2018-07-27 22:05:42 +01:00
Nick O'Leary
450f4d9a5a Fix error reporting of invalid jsonata in Join/reduce 2018-07-27 22:05:42 +01:00
HirokiUchikawa
6533a9793c Allow get and keys to be called without callback 2018-07-27 21:33:38 +09:00
Nick O'Leary
2000cadb17 Merge pull request #1847 from node-red-hitachi/update-uitest
Add UItest for http endpoints
2018-07-27 13:21:20 +01:00
Nick O'Leary
083c321efa Merge pull request #1848 from node-red-hitachi/grunt-on-windows
Fix test cases on windows and under proxy
2018-07-27 13:21:06 +01:00
Nick O'Leary
f64c4a981f Merge pull request #1846 from node-red-hitachi/remove-html-element
Fix to remove unnecessary typedInput option element
2018-07-27 13:20:44 +01:00
Nick O'Leary
3ac8ce03bf Merge pull request #1845 from node-red-hitachi/fix-file-node-test-for-ordering-assumption-of-output-message
Update file node test to cope with occasional failure
2018-07-27 13:20:27 +01:00
nakanishi
66fca8710e Fix test cases on windows and under proxy 2018-07-27 15:40:55 +09:00
Yuma Matsuura
1e245ece46 Update cookbook uitest 2018-07-27 13:48:43 +09:00
Hiroyasu Nishiyama
81efce03ba update file node test to cope with occasional failure 2018-07-27 08:30:03 +09:00
Nick O'Leary
4e549dd426 Add function tests for multiple-set access to context 2018-07-26 21:15:32 +01:00
Nick O'Leary
52f74ff7e0 Join: reduce fails if count not in first msg received 2018-07-26 14:13:12 +01:00
HirokiUchikawa
3c71b815f5 Fix to remove unnecessary typedInput element 2018-07-26 20:13:08 +09:00
Nick O'Leary
9efd48fe51 Fixup Join node to apply reduce_fixup asynchronously 2018-07-25 11:08:03 +01:00
Nick O'Leary
4609ee75b6 Revert jsonata sync access to context stores
- store access only possible with callback
2018-07-25 11:07:29 +01:00
Nick O'Leary
963ea4177e Add store arg to sync $flowContext/$globalContext 2018-07-25 10:18:59 +01:00
Nick O'Leary
17e6940a42 Update context plugins to use get/setObjectProperty 2018-07-25 09:59:26 +01:00
Nick O'Leary
315a9ceba3 Add RED.util.get/setObjectProperty to avoid stripping msg. 2018-07-25 09:27:27 +01:00
Nick O'Leary
a2bdeedb09 Merge pull request #1843 from node-red-hitachi/test-runtime-util
Add tests for runtime util
2018-07-25 09:16:50 +01:00
Nick O'Leary
da5700d2d7 Merge pull request #1842 from node-red-hitachi/runtime-message-jp
Update Japanese message catalogue of runtime.json
2018-07-25 09:15:18 +01:00
nakanishi
90e7f30247 Add tests for runtime util 2018-07-25 09:15:27 +09:00
Hiroyasu Nishiyama
3ccf6ba892 update Japanese message catalogue of runtime.json 2018-07-24 21:53:59 +09:00
Nick O'Leary
e50cd5b745 Bump bcrypt dependency 2018-07-24 10:21:08 +01:00
Nick O'Leary
db77be5d72 Update i18next in runtime 2018-07-23 23:25:57 +01:00
Nick O'Leary
c36870c23e Bump sem-ver minor dependencies 2018-07-23 15:52:02 +01:00
Nick O'Leary
e9be007040 Tidy up context store error messages 2018-07-23 15:20:13 +01:00
Nick O'Leary
9e400d9aa6 Merge pull request #1838 from node-red-hitachi/translate-node-jp
Update Japanese translation(MQTT node and editor.json)
2018-07-23 13:37:09 +01:00
Nick O'Leary
490c8dae75 Merge pull request #1837 from node-red-hitachi/master-switch-change-test
Fix and add test cases for persistable context
2018-07-23 13:29:23 +01:00
Nick O'Leary
3bcffe375d Merge pull request #1834 from node-red-hitachi/add-tests-for-context-admin-api
Add tests for context admin api
2018-07-23 13:29:10 +01:00
Nick O'Leary
9f81a591e1 Move multiple-get/set logic into individual context stores 2018-07-23 13:28:06 +01:00
Yuma Matsuura
3db5306c70 Update Japanese text of type input 2018-07-23 10:11:35 +09:00
Yuma Matsuura
45029dd084 Update Japanese text of type input 2018-07-23 10:11:23 +09:00
Yuma Matsuura
b01cd30339 Update Japanease text of mqtt node 2018-07-23 10:11:10 +09:00
Hiroyasu Nishiyama
09329e1104 add tests for context admin api 2018-07-21 12:00:54 +09:00
Nick O'Leary
ab0fc2ecfa Merge pull request #1818 from node-red-hitachi/context-store-logging
Add logging of context store
2018-07-20 20:23:32 +01:00
Nick O'Leary
bf5d36d6bd Merge branch 'master' into context-store-logging 2018-07-20 20:23:19 +01:00
Hiroyasu Nishiyama
a29527ec96 use implicit logging of context store 2018-07-20 23:26:47 +09:00
Nick O'Leary
45e7ad8049 Merge pull request #1831 from node-red-hitachi/update-info-of-file-node
Update info text of file node (English & Japanese)
2018-07-20 12:47:17 +01:00
Nick O'Leary
4d54663efd Merge pull request #1832 from node-red-hitachi/fix-isempty-rule
Fix bugs about "isEmpty" rule in Switch node
2018-07-20 12:45:53 +01:00
Nick O'Leary
29d386cc51 Merge pull request #1833 from node-red-hitachi/update-test-for-file-node
Update test for file node for new output port
2018-07-20 11:45:39 +01:00
Nick O'Leary
ba1a67969b Merge pull request #1825 from node-red-hitachi/add-types-to-trigger-node
Add support of bin, data, and env type to trigger node
2018-07-20 11:45:17 +01:00
Nick O'Leary
390ea5419e Merge pull request #1826 from node-red-hitachi/update-join-httpreq-info-jp
Update Japanese info text of JSON and HTTP Request node
2018-07-20 11:45:03 +01:00
Nick O'Leary
0fdeec7cc4 Merge pull request #1827 from node-red-hitachi/context-test-localfile
Add test cases for localfilesystem context
2018-07-20 11:44:39 +01:00
Nick O'Leary
e34d883e50 Merge pull request #1828 from node-red-hitachi/master-editorjson
Update Japanese translation (editor.json)
2018-07-20 11:44:19 +01:00
Nick O'Leary
507871687b Merge pull request #1830 from node-red-hitachi/translate-switch
Translate switch and batch nodes and icon palette
2018-07-20 11:44:13 +01:00
Nick O'Leary
ed58f62cd1 Merge pull request #1824 from node-red-hitachi/update-exec-node-info-jp
Update Japanese info text of exec node
2018-07-20 11:43:11 +01:00
Nick O'Leary
94bc4e7125 Merge pull request #1822 from node-red-hitachi/context-test-memory
Add test cases for memory context
2018-07-20 11:42:45 +01:00
Nick O'Leary
5832f7930d Merge pull request #1821 from node-red-hitachi/uitest-httprequest
Add UItest for http request
2018-07-20 11:42:28 +01:00
Nick O'Leary
0066a20c22 Merge pull request #1820 from node-red-hitachi/context-test-index
Add test cases for index.js of context
2018-07-20 11:42:10 +01:00
Nick O'Leary
774e4bfced Merge pull request #1819 from node-red-hitachi/fix-template-node-test
Fix test for template node for persistable context
2018-07-20 11:41:41 +01:00
Hiroyasu Nishiyama
054c7a76a4 update test for file node for new output port 2018-07-20 18:28:49 +09:00
HirokiUchikawa
c7f3b77aac Fix test cases of empty rule 2018-07-20 17:04:49 +09:00
HirokiUchikawa
a6a4620374 Fix an error that occurs when evaluating null on isEmpty rule. 2018-07-20 17:03:23 +09:00
HirokiUchikawa
5148c62d1c Fix appearance about Empty rules. 2018-07-20 16:53:30 +09:00
HirokiUchikawa
6fc863a91e Fix wrong test cases 2018-07-20 15:24:44 +09:00
Hiroyasu Nishiyama
e066a154a1 update info text of file node (English & Japanese) 2018-07-20 14:59:52 +09:00
nakanishi
d432edaed2 Translate icon palette parts into Japanese 2018-07-20 13:36:59 +09:00
nakanishi
8f34f4e80b Update Japanese translation for switch and batch nodes 2018-07-20 13:35:24 +09:00
nakanishi
39b751acf5 Add test cases for localfilesystem context 2018-07-20 11:23:37 +09:00
Kazuhito Yokoi
bd5e8ba961 Add test case of persistalbe context for switch node 2018-07-20 10:34:43 +09:00
HirokiUchikawa
ed20327c41 Update Japanese text of editor.json 2018-07-20 10:23:28 +09:00
Kazuhito Yokoi
991c68c394 Update Japanese translation (editor.json) 2018-07-20 10:23:27 +09:00
HirokiUchikawa
2acc31a4e7 Update Japanese info text of json node 2018-07-19 21:35:00 +09:00
Hiroyasu Nishiyama
b9733e3dfa add support of bin, data, and env to trigger node 2018-07-19 21:20:02 +09:00
Hiroyasu Nishiyama
bb106bfce7 small update of Japanese info text of exec node 2018-07-19 20:13:27 +09:00
HirokiUchikawa
daf1388a6a Update Japanese info text of http request node 2018-07-19 19:32:53 +09:00
Nick O'Leary
8226f1fa75 Merge pull request #1823 from node-red-hitachi/fix-referenceerror
Fix the ReferenceError in change node
2018-07-19 10:08:36 +01:00
HirokiUchikawa
e675512fa3 Fix ReferenceError in change node
and add a test case
2018-07-19 14:44:21 +09:00
Hiroyasu Nishiyama
65e67b6c3e add a space to align position of ":" 2018-07-19 14:18:27 +09:00
Hiroyasu Nishiyama
7612481570 ignore default store from logging 2018-07-19 14:12:01 +09:00
nakanishi
f6c7cb5804 Add test cases for global context of memory context 2018-07-19 13:49:36 +09:00
Yuma Matsuura
2201c9062f Add UItest for http request 2018-07-19 13:17:41 +09:00
nakanishi
ca3da262da Add test cases for index.js of context 2018-07-19 12:58:42 +09:00
Hiroyasu Nishiyama
5847f92bef fix test for template node for persistable context 2018-07-19 11:06:57 +09:00
Hiroyasu Nishiyama
31ee1be81e add logging of context store 2018-07-19 07:40:52 +09:00
Nick O'Leary
6bccdd015f Update changelog 2018-07-18 22:17:11 +01:00
Nick O'Leary
cecea318da Merge branch 'master' into 0.19 2018-07-18 13:22:35 +01:00
Nick O'Leary
8663ec6880 Merge pull request #1817 from node-red-hitachi/0.19-add-test-cases-for-inject-node
Add test cases for inject node
2018-07-18 11:35:51 +01:00
Nick O'Leary
9b03f128aa Merge pull request #1815 from node-red-hitachi/0.19-add-tests-for-function-node
Add persistable context tests for function node
2018-07-18 11:35:35 +01:00
Nick O'Leary
8a51f97616 Merge pull request #1816 from node-red-hitachi/0.19-update-info-text-for-function-node
update Japanese info text of function node
2018-07-18 11:35:17 +01:00
Hiroyasu Nishiyama
ee74ed9ce9 add test cases for inject node 2018-07-18 18:13:07 +09:00
Hiroyasu Nishiyama
0f947c756e update Japanese info text of function node 2018-07-18 17:17:23 +09:00
Hiroyasu Nishiyama
cae7949a48 add persistable context tests for function node 2018-07-18 16:43:12 +09:00
Nick O'Leary
be58b614e1 Index all node properties when searching
Fixes #1446
2018-07-17 20:58:10 +01:00
Nick O'Leary
b0a01fa4b2 Merge pull request #1813 from node-red-hitachi/0.19-jsonata-persistablecontext
Add context store support to JSONata functions
2018-07-17 20:34:53 +01:00
Nick O'Leary
9734228001 Merge branch 'boneskull-issue/1414' into 0.19 2018-07-17 20:29:36 +01:00
Nick O'Leary
9df1d44bc4 Merge branch 'issue/1414' of https://github.com/boneskull/node-red into boneskull-issue/1414 2018-07-17 20:28:40 +01:00
HirokiUchikawa
13d887028a Add test cases accessing context with JSONata to Sort Node 2018-07-17 18:43:10 +09:00
HirokiUchikawa
83a8979309 Add test cases accessing context with JSONata to Switch Node 2018-07-17 17:46:21 +09:00
Nick O'Leary
75c29f1cb7 Disallow store names that are not A-Za-z0-9_ 2018-07-16 16:44:33 +01:00
Nick O'Leary
d9d15e41c7 Support multiple stores in context sidebar 2018-07-16 16:36:05 +01:00
Nick O'Leary
d3598d5854 NLS Context sidebar 2018-07-16 13:17:18 +01:00
HirokiUchikawa
3a8aaee5d7 Add test cases accessing context with JSONata to Join Node 2018-07-16 18:42:16 +09:00
HirokiUchikawa
4fcf57d42c Add test cases accessing context with JSONata to Change Node 2018-07-16 18:25:03 +09:00
HirokiUchikawa
adb0891335 Allow the JSONata Expression to handle persistable store. 2018-07-16 18:00:57 +09:00
Nick O'Leary
d21e719cc1 Merge pull request #1812 from node-red-hitachi/0.19-add-env-var-support-for-split-node
Allow environment variable as reduce init value in split node
2018-07-16 09:38:26 +01:00
Nick O'Leary
5807ab82c1 Merge pull request #1811 from node-red-hitachi/0.19-fix-typo-in-utils
Fix typos in util.js
2018-07-16 08:36:13 +01:00
Hiroyasu Nishiyama
65cb04da63 fix typos in utils.js 2018-07-16 16:09:15 +09:00
Hiroyasu Nishiyama
312e3611b1 allow environment variable as reduce init value 2018-07-16 13:45:59 +09:00
Nick O'Leary
46acc62279 Make Trigger node timeout test 1ms more tolerable 2018-07-15 21:13:02 +01:00
Nick O'Leary
529b358c9b Split out expandable editors and add JS editor 2018-07-15 21:06:51 +01:00
Nick O'Leary
7fca04404e Fix debug test for _enc_ change 2018-07-14 23:18:55 +01:00
Nick O'Leary
3a1cc6a2be Change __encoded__ to __enc__ for debug message encoding 2018-07-14 23:06:15 +01:00
Nick O'Leary
5b76c91004 Merge pull request #1806 from node-red-hitachi/0.19-template-node-for-persistable-context
Add support of persistable context to template node
2018-07-14 22:40:50 +01:00
Nick O'Leary
cf87837f7d Merge pull request #1810 from node-red-hitachi/0.19-fix-inject-node-notification-for-persistable-context
Fix context access appearance of inject node in editor
2018-07-14 22:40:19 +01:00
Nick O'Leary
5a0a7b907b Merge pull request #1809 from node-red-hitachi/0.19-fix-tests-for-trigger-node
Add multiple persistable store tests for trigger node
2018-07-14 22:39:05 +01:00
Nick O'Leary
6a2b1669b3 Merge pull request #1808 from node-red-hitachi/0.19-fix-tests-for-inject-node
Add multiple persistable store tests for inject node
2018-07-14 22:38:58 +01:00
Nick O'Leary
ca8264b3f4 Merge pull request #1807 from node-red-hitachi/0.19-fix-tests-for-change-node
Add multiple persistable store tests for change node
2018-07-14 22:38:17 +01:00
Hiroyasu Nishiyama
b44ecd8819 fix context access appearance of inject node in editor 2018-07-14 14:47:40 +09:00
Hiroyasu Nishiyama
987942959e empty commit to rerun travis 2018-07-14 12:37:30 +09:00
Hiroyasu Nishiyama
91992b48c1 add multiple persistable store tests 2018-07-14 12:15:26 +09:00
Hiroyasu Nishiyama
c9a335a6f9 add multiple persistable store tests 2018-07-14 11:50:49 +09:00
Hiroyasu Nishiyama
b7ed159b50 add multiple persistable context tests 2018-07-14 11:00:57 +09:00
Hiroyasu Nishiyama
c72961a52a add support of persistable context to template node 2018-07-14 00:11:59 +09:00
Nick O'Leary
afe6afca36 Merge pull request #1801 from node-red-hitachi/0.19-multi-values
Make it possible to set multiple values
2018-07-13 14:03:03 +01:00
HirokiUchikawa
050acd239c Allow arrays of different lengths to be passed to set. 2018-07-13 20:59:45 +09:00
Nick O'Leary
24505ee4f5 Merge pull request #1803 from kazuhitoyokoi/0.19-addtestcases
Add test cases of persistable context for trigger node
2018-07-13 11:59:40 +01:00
Nick O'Leary
63a249aba3 Merge pull request #1802 from kazuhitoyokoi/0.19-updatejapanese
Update Japanese language files (messages.json and jsonata.json)
2018-07-13 11:59:09 +01:00
Nick O'Leary
7bd94df2a0 Merge pull request #1804 from node-red-hitachi/0.19-fix-cache-error
Fix the error that the parent directory of the context does not exist
2018-07-13 11:58:14 +01:00
Kazuhito Yokoi
761161a8e5 Fix async problem in test cases 2018-07-13 17:34:04 +09:00
Kazuhito Yokoi
513579a7ee Empty commit to run travis again 2018-07-13 15:53:47 +09:00
Kazuhito Yokoi
7165483d83 Empty commit to run travis again 2018-07-13 15:40:21 +09:00
Kazuhito Yokoi
f8bcf219cb Empty commit to run travis again 2018-07-13 15:37:50 +09:00
Kazuhito Yokoi
590506e306 Add test cases of persistable context for trigger node 2018-07-13 15:26:07 +09:00
Kazuhito Yokoi
9a5439c580 Update Japanese language files (message.json and jsonata.json) 2018-07-13 15:17:30 +09:00
HirokiUchikawa
6b2f5fbb19 Allow multiple keys and values to be passed to set 2018-07-12 19:19:55 +09:00
Nick O'Leary
051c147b41 Merge pull request #1800 from node-red-hitachi/0.19-callback-called-twice
Prevent the callback to be called twice
2018-07-12 10:45:58 +01:00
HirokiUchikawa
9111adf15f Use ensureDir() insted of mkdir()
and add test case
2018-07-12 18:20:47 +09:00
HirokiUchikawa
ba18b27371 Prevent the callback to be called twice
and add test cases
2018-07-12 18:12:30 +09:00
Nick O'Leary
2a287b2ae6 Merge pull request #1796 from node-red-hitachi/0.19-multiple-values
Make it possible to get multiple values
2018-07-12 10:01:18 +01:00
Nick O'Leary
fc9040f715 Merge pull request #1799 from kazuhitoyokoi/0.19-addtestcases4persistablecontext
Add test cases of persistable context for inject node
2018-07-12 08:41:27 +01:00
Nick O'Leary
0029022ef6 Merge pull request #1797 from node-red-hitachi/0.19-uitest-flowcontrol
Added test cases of flow control on cookbook
2018-07-12 08:40:30 +01:00
Nick O'Leary
94f728d3fd Merge pull request #1798 from kazuhitoyokoi/0.19-updatelanguagefiles
Update Japanese language file (editor.json)
2018-07-12 08:39:29 +01:00
Kazuhito Yokoi
d53ced7830 Add test cases of persistable context for inject node 2018-07-12 16:26:16 +09:00
Kazuhito Yokoi
053d8c44c2 Update Japanese language file (editor.json) 2018-07-12 16:14:25 +09:00
nakanishi
9f5767ea16 Added test cases of flow control on cookbook 2018-07-12 15:28:40 +09:00
HirokiUchikawa
e8d76b0555 Allow multiple values to be passed to get 2018-07-12 14:05:36 +09:00
Nick O'Leary
c2675600f6 Fix Switch msg sequence test 2018-07-11 16:37:18 +01:00
Nick O'Leary
6f087b4ec1 Merge pull request #1795 from node-red-hitachi/0.19-fix-change-for-persistable-context
Fix persistable context handling of switch node
2018-07-11 16:17:26 +01:00
Nick O'Leary
e94708606d Add isEmpty check to switch node 2018-07-11 16:14:09 +01:00
Hiroyasu Nishiyama
c248f1a762 fix persistable context handling of switch node 2018-07-11 23:39:34 +09:00
Nick O'Leary
28402b0894 Add sidebar tab icons to drop-down menu 2018-07-11 14:15:31 +01:00
Nick O'Leary
7dd98e99f9 Node errors should be Strings not Errors
Fixes #1781
2018-07-11 13:40:53 +01:00
Nick O'Leary
dba195b396 Add detection of connection timeout in git communication
Fixes #1770
2018-07-11 13:26:45 +01:00
Nick O'Leary
88b153bc12 Merge pull request #1794 from kazuhitoyokoi/0.19-fixi18n
Remove and change keys in language files
2018-07-11 13:25:08 +01:00
Kazuhito Yokoi
d4a47dc974 Empty commit to run travis again 2018-07-11 16:13:32 +09:00
Kazuhito Yokoi
fe3ea6edfd : 2018-07-11 16:12:56 +09:00
Kazuhito Yokoi
6c8fc4846b Fix i18n bugs in projects 2018-07-11 15:33:25 +09:00
Nick O'Leary
54d9656f09 Add servername option to TLS config node for SNI 2018-07-10 23:24:32 +01:00
Nick O'Leary
49da324c5d Fix jsonata err reporting in sort node 2018-07-10 17:26:54 +01:00
Nick O'Leary
9bf87697fd Merge pull request #1780 from natcl/json-schema
Add JSON schema validation to JSON node
2018-07-10 17:06:17 +01:00
Nathanaël Lécaudé
f368f5a9c4 JSON node: Add link to JSON schema spec in node help 2018-07-10 11:29:01 -04:00
Nathanaël Lécaudé
eea85485e6 Merge remote-tracking branch 'upstream/0.19' into json-schema 2018-07-10 11:11:15 -04:00
YumaMatsuura
1a544b3b82 Headless option for ui test (#1784) 2018-07-10 12:42:56 +01:00
Kazuhito Yokoi
8b38fe9fe0 Support i18n in websocket node (#1785) 2018-07-10 12:42:32 +01:00
Hiroki Uchikawa
1bf4addf63 Fix an error when initializing the cache (#1788)
* Fix a error when initializing the cache

* Make context directory if it is not there  in initialization
2018-07-10 12:41:16 +01:00
Hiroyasu Nishiyama
407e16e900 Fix appearrence of switch node port label for flow/global ref. (#1793)
* fix appearrence of switch node port label for flow/global ref

* use RED.utils.parseContextKey
2018-07-10 12:40:52 +01:00
Hiroyasu Nishiyama
6e9fe3248a Fix appearrence of change node label for flow/global ref (#1792)
* fix appearence of change node label for flow/global ref

* use RED.utils.parseContextKey
2018-07-10 12:40:31 +01:00
Nick O'Leary
d8cf86fd6f Add RED.utils.parseContextKey 2018-07-10 11:41:46 +01:00
Nick O'Leary
f8aa4a9588 Merge branch 'async-split' into 0.19 2018-07-10 11:30:38 +01:00
Nick O'Leary
c249907846 Merge pull request #1791 from node-red/join-node-keep-top-level-properties
join-node-keep-top-level-properties
2018-07-10 11:28:55 +01:00
Nick O'Leary
57c1524a9a Add async jsonata support to join node 2018-07-10 11:24:57 +01:00
Nick O'Leary
d8d82e2ba3 Update sort node for async use of jsonata 2018-07-09 23:06:51 +01:00
Nick O'Leary
807b512ef7 Add JSONata async support to Switch and Change nodes 2018-07-09 21:56:39 +01:00
Nick O'Leary
b2f06b6777 Add async mode to evaluateJSONataExpression 2018-07-09 15:12:09 +01:00
Nick O'Leary
d7adff9a65 Add async message handling to Trigger node 2018-07-09 14:12:44 +01:00
Nick O'Leary
b0d7e11d48 Fix evaluateNodeProperty handling of unknown types 2018-07-09 12:40:25 +01:00
Nick O'Leary
fc9cdb61f2 Add async property handling to Switch node 2018-07-09 11:31:10 +01:00
Nick O'Leary
9c00492dc2 WIP: create async Switch node helper functions 2018-07-09 11:31:10 +01:00
Nick O'Leary
1a6babd199 Lint Switch code 2018-07-09 11:31:10 +01:00
Nick O'Leary
1b693eed37 Add async context support to Change node 2018-07-09 11:31:10 +01:00
Nick O'Leary
afb566b6b4 Add async context support to Inject node 2018-07-09 11:31:10 +01:00
Dave Conway-Jones
f870e9ed3e Let Join node accumulate top level properties
Last in is still most significant
2018-07-08 16:52:30 +01:00
Dave Conway-Jones
4bcf13cb58 Let nrgpio code work with python 3
(just in case that becomes default)
2018-07-07 19:01:14 +01:00
Nick O'Leary
946a6d6041 Update RED.util.evaluateNodeProperty to support context stores 2018-07-05 10:43:33 +01:00
Nick O'Leary
372c213c2c Still parse/export typedInput values even when no options set 2018-07-04 14:23:18 +01:00
Nick O'Leary
a5a79d3ab7 Merge branch '0.19' into typedInput-context 2018-07-04 13:37:05 +01:00
Nick O'Leary
e6c5cfb703 Do not show TypedInput context options if there's only one available 2018-07-04 13:36:23 +01:00
Nick O'Leary
7843eccae8 Merge pull request #1786 from node-red-hitachi/0.19-fix-typedInput-error
Fix typedInput error on initialization
2018-07-04 13:35:55 +01:00
Hiroyasu Nishiyama
7ca153abd0 fix error on typedInput initialization 2018-07-04 20:50:33 +09:00
Nick O'Leary
33b4774c49 Load typedinput context list from settings 2018-07-03 21:40:58 +01:00
Nick O'Leary
c243481432 Add sub options to Inject node 2018-07-03 21:40:58 +01:00
Nick O'Leary
80873e4ea9 fix settings api test for context stores 2018-07-03 21:27:55 +01:00
Nick O'Leary
4e4a1f11e6 Fix context admin api for empty contexts 2018-07-03 21:18:43 +01:00
Nick O'Leary
9bbe405cd0 Do not show blank popovers 2018-07-03 21:18:15 +01:00
Nick O'Leary
c440a4c730 Expose list of context stores to the editor 2018-07-03 14:17:42 +01:00
Nick O'Leary
a1251371d7 Avoid unnecessary re-reading of file context when caching is enabled 2018-07-03 11:29:45 +01:00
Nick O'Leary
7d702e8332 Remove console.log 2018-07-02 22:38:37 +01:00
Nick O'Leary
43d7c8d48c Add caching to localfilesystem context 2018-07-02 22:32:20 +01:00
Nick O'Leary
7423583508 Create default store for node tests to use 2018-07-02 15:47:47 +01:00
Nick O'Leary
08b0838f9a Fix linting in view.js 2018-07-02 15:32:29 +01:00
Nick O'Leary
038d821a7c Apply fGC to all global contexts for default values 2018-07-02 15:21:13 +01:00
Nathanaël Lécaudé
6a218814d3 Merge remote-tracking branch 'upstream/0.19' into json-schema 2018-06-30 16:20:13 -07:00
Nathanaël Lécaudé
905f89b0f5 JSON node: finalize JSON Schema validation 2018-06-30 16:19:39 -07:00
Nick O'Leary
14882bda78 Ensure runtime errors in Change node can be caught
Fixes #1769
2018-06-29 11:50:16 +01:00
Nick O'Leary
781fa4634b Merge pull request #1777 from node-red-hitachi/uitest-typedinput
Follow the change of typedinput interface for UI test
2018-06-29 10:53:27 +01:00
Nick O'Leary
cdb173fd6e Handle NaN and Infinity properly in debug sidebar
Fixes #1778 #1779
2018-06-29 10:50:07 +01:00
Nick O'Leary
466cb4be89 Small tidy up on context plugin loading 2018-06-29 09:48:38 +01:00
Nathanaël Lécaudé
c39e2ffd56 JSON node: add JSON schema validation via msg.schema 2018-06-28 23:16:43 -07:00
Kazuki-Nakanishi
17bf09e276 Follow the change of typedinput interface for UI test 2018-06-29 10:41:44 +09:00
Nick O'Leary
bc01f9f8fd add placeholder api/admin/context_spec 2018-06-28 17:00:17 +01:00
Nick O'Leary
c0870c5694 Merge branch '0.19' into context-tab 2018-06-27 16:05:17 +01:00
Nick O'Leary
3b5174a2ea Merge branch '0.19' of github.com:node-red/node-red into 0.19 2018-06-27 15:56:57 +01:00
Nick O'Leary
af6885f3e8 Merge pull request #1720 from node-red-hitachi/persistablecontext
Add persistable context backend
2018-06-27 15:37:46 +01:00
Nick O'Leary
e01996095f Add refresh timestamp to context sidebar 2018-06-27 10:00:23 +01:00
Nick O'Leary
5d86f7b6ba Refresh context sidebar tab based on selection 2018-06-26 23:34:32 +01:00
Nick O'Leary
8d6ac6406d Initial context sidebar tab 2018-06-26 11:32:24 +01:00
HirokiUchikawa
40ff54f67e Improve context storage handling 2018-06-26 11:43:37 +09:00
HirokiUchikawa
cce7ac09d0 Add callback handling to memory plugin 2018-06-26 11:36:37 +09:00
Nick O'Leary
73a18891c5 Add RED.popover.tooltip for common reuse 2018-06-25 22:32:34 +01:00
Nick O'Leary
fe22cedc1d Move debug encode/decode to utils for reuse 2018-06-25 22:32:34 +01:00
Nick O'Leary
fa09c7c8b2 Merge branch '0.19' of github.com:node-red/node-red into 0.19 2018-06-25 13:55:21 +01:00
Nick O'Leary
15e28e3cc0 Merge branch 'pr_1766' into 0.19 2018-06-25 13:55:07 +01:00
Nick O'Leary
2cb4f6b1fc Prevent horizontal scroll when palette name cannot wrap 2018-06-25 13:54:34 +01:00
Nick O'Leary
b17a483b85 Merge pull request #1771 from node-red-hitachi/0.19-fix-i18n-project-message
Fix appearance of retry button of remote branch management dialog
2018-06-25 13:50:11 +01:00
Nick O'Leary
7c3e5443ab Merge pull request #1772 from node-red-hitachi/uitest-debugtab
Follow the change of tab interface for UI test
2018-06-25 13:37:53 +01:00
Nick O'Leary
f95a2851c8 Ignore middle-click on node/ports to enable panning 2018-06-25 13:36:58 +01:00
Nick O'Leary
2b2eee352f Better wire layout when looping back 2018-06-25 13:18:37 +01:00
Kazuki-Nakanishi
11569d8056 Follow the change of tab interface for UI test 2018-06-25 18:48:01 +09:00
Nick O'Leary
bdf87452b6 Reset typedInput option when type changes 2018-06-25 10:39:20 +01:00
Hiroyasu Nishiyama
0c6bf81c24 fix appearence of retry button of remote branch management dialog 2018-06-23 12:49:09 +09:00
HirokiUchikawa
f2fa26fb07 Use the callback instead of Promise in context API
and remove unnecessary functions
2018-06-22 17:11:54 +09:00
Nick O'Leary
f5e212ff1e Refresh type options properly when typedInput.types called 2018-06-21 10:49:39 +01:00
Nick O'Leary
461e6562ca Allow typedInputs to have options plus value 2018-06-21 10:47:30 +01:00
HirokiUchikawa
fd67d08402 Remove unnecessary module
and skip persistable context test cases temporally
2018-06-20 20:09:02 +09:00
HirokiUchikawa
e6411d11b1 Remove unnecessary context storage APIs
and rename context storage APIs
2018-06-20 20:00:39 +09:00
HirokiUchikawa
dd81d947fc Use native Promise instead of when.js 2018-06-20 19:50:55 +09:00
HirokiUchikawa
23b887c30e Add a test case for context/index 2018-06-20 19:42:09 +09:00
HirokiUchikawa
c4eae3f130 Fix file extension 2018-06-20 19:42:08 +09:00
HirokiUchikawa
41a04a2849 Add async API to context
and add test cases for async
2018-06-20 19:42:07 +09:00
HirokiUchikawa
ed1d34e678 Use fs-extra instead of node-json-db 2018-06-20 19:42:06 +09:00
HirokiUchikawa
f44487338d Fix a wrong statement 2018-06-20 19:42:05 +09:00
Hiroki Uchikawa
7aced85a31 Use Array.indexOf() instead of Array.includes() 2018-06-20 19:42:04 +09:00
HirokiUchikawa
fbe0e2d6eb Delete async function in context/index 2018-06-20 19:42:03 +09:00
HirokiUchikawa
6e34f0697c Allow .get/set/keys to return asynchronous results 2018-06-20 19:42:02 +09:00
HirokiUchikawa
a835f9f0cb Fix ENOENT error in LocalFileSystem.clean() 2018-06-20 19:42:01 +09:00
HirokiUchikawa
16715673c3 Add test case 2018-06-20 19:42:00 +09:00
HirokiUchikawa
c48c74f173 Delete unused variables 2018-06-20 19:42:00 +09:00
HirokiUchikawa
f262348497 Add clean to context plugin
and don't delete local context unless the context is deleted by a user
2018-06-20 19:41:59 +09:00
HirokiUchikawa
7185bcd51f Add open/close API for context 2018-06-20 19:41:58 +09:00
HirokiUchikawa
28d05e2449 Allow multiple instances of a given storage module to exist 2018-06-20 19:41:57 +09:00
Hiroki Uchikawa
7fafa21a1b Change the order of arguments 2018-06-20 19:41:56 +09:00
HirokiUchikawa
84f598e143 Change prefix from $ to # 2018-06-20 19:41:51 +09:00
HirokiUchikawa
e30f8628db Revert runtime/util 2018-06-20 19:41:02 +09:00
Hiroki Uchikawa
0be9c88106 Improve processing when default is an alias
and fix test cases
2018-06-20 19:41:01 +09:00
Kazuki-Nakanishi
e046fc1ac5 Refactor parseKey and implement parseStorage 2018-06-20 19:41:00 +09:00
Kazuki-Nakanishi
3a476ac493 Implemented error handlings 2018-06-20 19:40:54 +09:00
Hiroki Uchikawa
e33ec0cf50 update external context
- Implement `delete` function
- Swap default easily
- Change memory context as a plugin
- Update localfilesystem plugin
  -  Change file/folder structure
2018-06-20 19:40:26 +09:00
Hiroki Uchikawa
b4b70a988e Change delimiter to "_" from ":" 2018-06-20 19:40:25 +09:00
Hiroki Uchikawa
e66b381070 add external context files 2018-06-20 19:40:25 +09:00
Hiroki Uchikawa
771b598c09 Add persistable context
and avoid exception when arg is undefined in util/getMessageProperty
2018-06-20 19:40:24 +09:00
Hiroki Uchikawa
cd44f13171 Move context_spec.js to context folder
and rename context_spec.js -> index_spec.js
2018-06-20 19:40:23 +09:00
Hiroki Uchikawa
aa6b72ac87 Move context.js to context folder
and rename context.js -> index.js
2018-06-20 19:40:22 +09:00
Nick O'Leary
a467fe5ed7 Reposition tab menu before opening 2018-06-19 10:49:50 +01:00
Hiroyasu Nishiyama
467411c6c3 merge 0.19 2018-06-17 01:26:31 +09:00
Nick O'Leary
2648b7ca54 Handle releasing ctrl when using quick-add node dialog 2018-06-15 22:33:53 +01:00
Nick O'Leary
de35c7024a Tab buttons should use editor-button-toggle style 2018-06-15 17:28:29 +01:00
Dave Conway-Jones
9d219c163d Don't accidentally re-use udp port when set to not do so
to close Issue #1764
2018-06-15 14:53:02 +01:00
Nick O'Leary
f7434b5ec8 Add output to File Out node and update icons 2018-06-15 13:25:28 +01:00
Nick O'Leary
5ed3360c0b Fix css for single toggle buttons 2018-06-15 13:25:28 +01:00
Dave Conway-Jones
6f5974f875 Fix join node manual mode array
msg.complete was adding an unwanted null to the array (if no payload)
Added tests for msg.complete with array and object
2018-06-14 20:00:42 +01:00
Nick O'Leary
56db1da3cf Merge pull request #1732 from node-red/pi-nodes-editable-when-na
let Pi nodes be visible/editable on all platforms
2018-06-13 15:46:21 +01:00
Nick O'Leary
fef71f29c4 Merge pull request #1750 from node-red-hitachi/logic-nodes-test
Add test cases for logic nodes
2018-06-13 15:45:13 +01:00
Nick O'Leary
d46b66878a Show unknown node properties in info tab 2018-06-13 14:56:09 +01:00
Nick O'Leary
6cad80c4ad Add node icon picker widget 2018-06-12 23:46:06 +01:00
Nick O'Leary
68779caa2e Only edit nodes on dbl click on primary button with no modifiers 2018-06-12 15:34:08 +01:00
Nick O'Leary
2a122ed283 Allow subflows to be put in any palette category 2018-06-12 12:54:32 +01:00
Nick O'Leary
17c5fdf0d5 Add flow navigator widget 2018-06-08 23:32:17 +01:00
Nick O'Leary
f6274445a2 Merge branch 'master' into 0.19 2018-06-06 21:41:48 +01:00
Nick O'Leary
3b0300b834 Cache flow library result to improve response time
Fixes #1753
2018-06-06 21:38:44 +01:00
Nick O'Leary
4fbf1fe780 Add middle-button-drag to pan the workspace 2018-06-06 20:51:30 +01:00
Hiroyasu Nishiyama
dcf44fed58 allow multi-line category name in editor 2018-06-05 20:18:40 +09:00
Nick O'Leary
7136dc1c72 Merge pull request #1749 from kazuhitoyokoi/0.19
Add i18n support for projectSettings.js
2018-06-04 23:32:55 +01:00
Kazuhito Yokoi
0e4cedbc5e Remove new lines 2018-06-04 07:21:48 +09:00
Kazuhito Yokoi
dc139bcc30 Remove new line 2018-06-04 07:15:26 +09:00
KatsuyaHoshii
b204b183de Add logic nodes test cases 2018-06-01 14:33:20 +09:00
Kazuhito Yokoi
ab788bc1e3 Add i18n support for projectSettings.js 2018-06-01 12:58:09 +09:00
Nick O'Leary
95b4c8d515 Merge pull request #1748 from node-red-hitachi/0.19-editor-diff-i18n-jp
Add i18n support for project
2018-05-31 10:44:36 +01:00
Nick O'Leary
b025644525 Merge pull request #1744 from node-red-hitachi/0.19-i18n-defaultFileSet
Add i18n support for default file set for a project
2018-05-31 08:51:53 +01:00
Yuma Matsuura
9e87a60597 modify translate project diff 2018-05-31 16:47:03 +09:00
Yuma Matsuura
5a70bea67a add translate project diff 2018-05-31 16:46:46 +09:00
Hiroyasu Nishiyama
2a95af3928 merged 0.19-allow-i18n-translation-in-runtime 2018-05-30 21:59:20 +09:00
Nick O'Leary
0a0ca380d3 Ensure apiMaxLength applies to HTTP Nodes
Fixes #1278
2018-05-30 13:32:38 +01:00
Nick O'Leary
4cfbf7f71c Merge pull request #1743 from node-red-hitachi/0.19-allow-i18n-translation-in-runtime
Allow i18n translation in runtime
2018-05-30 13:20:05 +01:00
Hiroyasu Nishiyama
de43148341 change current_locale to getCurrentLocale 2018-05-30 20:32:56 +09:00
Nick O'Leary
0a2aab7d68 Merge pull request #1746 from node-red-hitachi/0.19-user-settings-projects-i18n-jp
Modify i18n support for user settings of project
2018-05-30 10:30:25 +01:00
Nick O'Leary
745821c420 Merge pull request #1745 from node-red-hitachi/0.19-version-projects-i18n-jp
Add i18n support for version control of project
2018-05-30 10:30:12 +01:00
Nick O'Leary
57c4c754d0 Merge pull request #1742 from node-red-hitachi/0.19-editor-main-i18n-jp
Update i18n support for main editor interface and Japanese message …
2018-05-30 10:22:38 +01:00
Nick O'Leary
4b5c437533 Merge pull request #1741 from node-red-hitachi/0.19-editor-projects-i18n-jp
Add i18n support for projects interface and Japanese message catalogue
2018-05-30 10:21:29 +01:00
Nick O'Leary
8d63b6a1ed Merge pull request #1734 from node-red-hitachi/0.19-fix-icon-scan-test-for-win
Fix test failure of icon scan on Windows
2018-05-30 10:18:57 +01:00
Nick O'Leary
245a8adbf9 Merge pull request #1736 from node-red-hitachi/0.19-httpreq
Move to request module
2018-05-30 10:18:21 +01:00
Yuma Matsuura
4f7d98aace modify translate user settings 2018-05-29 10:12:52 +09:00
Kazuki-Nakanishi
b0c693cc3a move comment from json to js 2018-05-28 17:06:38 +09:00
Kazuki-Nakanishi
b2cca10e8b Add i18n support for version control of project 2018-05-28 17:01:53 +09:00
Hiroyasu Nishiyama
a84b2ab5bb update defaultFileSet test for i18n support 2018-05-27 22:30:05 +09:00
Hiroyasu Nishiyama
4565342b05 add i18n support for project default files generation 2018-05-27 01:38:54 +09:00
Hiroyasu Nishiyama
0ad54cc2d1 allow i18n translation in runtime 2018-05-27 01:05:50 +09:00
Hiroyasu Nishiyama
865853da19 add some i18n support for main editor interface and Japanese message catalogue 2018-05-26 20:08:39 +09:00
Hiroyasu Nishiyama
392ed706fd add i18n support for projects interface and Japanese message catalogue 2018-05-26 14:21:30 +09:00
Nick O'Leary
0ff0f25aaf Merge branch 'master' into 0.19 2018-05-25 13:58:15 +01:00
Nick O'Leary
c157960846 Change debug sidebar icon 2018-05-25 13:55:35 +01:00
YumaMatsuura
a5c00b5c81 add translate-user-settings (#1740) 2018-05-25 13:55:03 +01:00
Nick O'Leary
472bbdb59f Fix typo in CHANGELOG 2018-05-25 13:27:58 +01:00
Nick O'Leary
7877093713 Bump 0.18.7 2018-05-25 13:23:18 +01:00
Nick O'Leary
8cb2e51407 Relax twitter node version ready for major version bump 2018-05-25 11:40:14 +01:00
Nick O'Leary
d5cee81fb6 Merge branch 'pr_1739' 2018-05-25 11:37:37 +01:00
Nick O'Leary
bca020bc4d Tidy up default grunt task and fixup test break due to reorder
Fixes #1738
2018-05-25 11:36:17 +01:00
Nick O'Leary
5069f2844c Bump jsonata version 2018-05-25 10:55:44 +01:00
Nick O'Leary
252df81f59 Pass Date into the Function node sandbox to fix instanceof tests 2018-05-25 10:55:44 +01:00
KatsuyaHoshii
7f89a4a26f Update .travis.yml 2018-05-25 11:48:33 +09:00
Dave Conway-Jones
40f4167894 let TCP in node report remote ip and port when in single packet mode 2018-05-24 21:39:46 +01:00
Nick O'Leary
0ef16989cd Do not trim wires if node declares outputs in defaults but misses value
Fixes #1737
2018-05-24 20:27:07 +01:00
Dave Conway-Jones
3df3d6f516 add debug to trigger test to help work out fails 2018-05-24 10:02:51 +01:00
Edward Vielmetti
10395ef254 typo fix *hierarchy (#1735) 2018-05-24 09:48:05 +01:00
Hiroyasu Nishiyama
83854c28db fix test failure of icon scan on windows 2018-05-24 12:06:39 +09:00
Nick O'Leary
fcbea2629c Support flow.disabled and .info in /flow API 2018-05-23 22:41:39 +01:00
Nick O'Leary
26bc142cc2 Handle loading empty nodesDir 2018-05-23 10:59:08 +01:00
Nick O'Leary
a4eb8e11c3 Collapse sidebar tabs 2018-05-23 10:25:47 +01:00
HirokiUchikawa
9fd5d1db56 Move to request module 2018-05-23 17:16:20 +09:00
Dave Conway-Jones
1d05b4c981 relax test spec slightly 2018-05-23 08:58:04 +01:00
HirokiUchikawa
61f6535be8 Add test case for preventing following redirect 2018-05-23 16:54:03 +09:00
Dave Conway-Jones
7dd329b5ee Add basic loading tests for GPIO nodes 2018-05-22 17:26:52 +01:00
Dave Conway-Jones
b761904424 let Pi nodes be visible/editable on all platforms
even where they are not physically available.
2018-05-22 15:48:24 +01:00
Nick O'Leary
36105412b1 Add 'private' property to userDir generated package.json
This stops the warnings from npm about missing repo and license fields.
As there's no expectation for a user to publish their userDir to npm, then
setting private is entirely appropriate.
2018-05-22 11:41:22 +01:00
Nick O'Leary
184b1b018c Add missing resource file 2018-05-21 22:38:07 +01:00
Nick O'Leary
f3e1b85d82 Add RED.require to allow nodes to access other modules 2018-05-21 22:08:04 +01:00
Nick O'Leary
626d012775 Do not disable the export-clipboard menu option with empty selection 2018-05-21 16:14:43 +01:00
Nick O'Leary
9ad9c0ec6a Add $env function to JSONata expressions 2018-05-21 15:28:15 +01:00
Nick O'Leary
e13fed9fc6 Widen support for env var to use ${} or $() syntax 2018-05-21 15:19:50 +01:00
Nick O'Leary
eb6d093e56 Add env-var support to TypedInput 2018-05-21 15:10:06 +01:00
Hiroyasu Nishiyama
af1ea610ea allow id and name reference in function node code (#1731) 2018-05-21 11:34:56 +01:00
Nick O'Leary
d4d9190919 Bump version 2018-05-18 11:03:49 +01:00
Nick O'Leary
4d3d1a02a8 Add editorTheme.projects.enabled to default settings.js 2018-05-18 11:03:00 +01:00
Nick O'Leary
30c2aa96d6 Update changelog 2018-05-17 12:21:06 +01:00
Nick O'Leary
4edb1f80b0 Update mailing list references to new forum 2018-05-17 12:17:55 +01:00
Nick O'Leary
0a82459233 Handle a node having wires in the editor on ports it no longer has
Fixes #1724
2018-05-17 11:28:35 +01:00
Dave Conway-Jones
db87b0dfa5 Add missing ACE snippet files
to stop 404 in console
2018-05-15 22:10:14 +01:00
Nick O'Leary
cd42cf7583 Fix wireClippedNodes is not defined
Fixes #1726
2018-05-12 17:02:07 +01:00
Nick O'Leary
2d5980ff2a Split node html to isolate bad nodes when loading 2018-05-11 22:30:57 +01:00
Nick O'Leary
d49c7a3adb Avoid unnecessary use of .html() where .text() will do 2018-05-11 14:05:52 +01:00
Nick O'Leary
4fdd09a262 Changelog tidy 2018-05-10 13:04:37 +01:00
Nick O'Leary
d6878512c4 Bump version for 0.18.5 2018-05-10 13:02:59 +01:00
Nick O'Leary
8b1b8250ff update changelog 2018-05-10 11:29:20 +01:00
Hiroyasu Nishiyama
9dccbf747e Japanese message catalogue update (#1723)
* update Japanese message catalogue for mqtt node

* update Japanese message catalogue for udp node

* update Japanese message catalogue for html node

* update Japanese message catalogue for rpi-gpio node
2018-05-10 11:26:56 +01:00
Nick O'Leary
08727e1938 Show node load errors in the palette manager 2018-05-10 11:21:59 +01:00
Nick O'Leary
7584820987 Filter req.user in /settings to prevent leaking info 2018-05-09 10:03:22 +01:00
Nick O'Leary
d572356642 Update to latest test-helper module 2018-05-08 23:44:39 +01:00
Nick O'Leary
3b5a2815a9 Merge master 2018-05-08 23:27:27 +01:00
Nick O'Leary
f3cf01df25 Update changelog 2018-05-08 22:06:32 +01:00
Nick O'Leary
63e6e64ad3 Merge branch 'pr_1719' 2018-05-08 17:23:57 +01:00
Nick O'Leary
e8d7b48bff Fix up sizing of mqtt message inputs 2018-05-08 17:23:28 +01:00
mblackstock
12944d1ebd add back removed Retain message 2018-05-08 08:30:10 -07:00
Nick O'Leary
fa1ff6e393 Update changelog 2018-05-08 15:41:25 +01:00
Nick O'Leary
98546b6e6a Fixup Function node error line reporting 2018-05-08 11:40:16 +01:00
Nick O'Leary
2fef6fd1fa Fix proper closing of http request test ssl/proxy servers 2018-05-08 11:26:28 +01:00
Nick O'Leary
20cf91f1dc Merge branch 'pr_1700' 2018-05-08 10:47:35 +01:00
Nick O'Leary
2efa78d590 Fix up function stack issues 2018-05-08 10:47:20 +01:00
Nick O'Leary
880af0671a Merge branch 'pr_1706' 2018-05-08 10:44:35 +01:00
Nick O'Leary
62471e4531 Handle null error object in Flow.handleError
Fixes #1721
2018-05-08 10:37:41 +01:00
mblackstock
b15f8535f8 document close message 2018-05-06 20:02:20 -07:00
mblackstock
7a3a4493da tighten vertically, change section order 2018-05-06 15:38:45 -07:00
mblackstock
11078235c4 added deleted 'retain' in tip 2018-05-06 15:08:15 -07:00
mblackstock
f3e05cd08a set default expand behaviour 2018-05-04 16:52:21 -07:00
Nick O'Leary
0ca3cabbe8 Refector how Project object is instantiated 2018-05-04 16:24:00 +01:00
mblackstock
44a75c1291 move to two lines, add publish on close 2018-05-03 13:47:14 -07:00
Dave Conway-Jones
4a4513a746 Add type checks to switch node options (#1714)
* Add type checks to switch node options

* add isType to messages.json
2018-05-03 11:24:44 +01:00
iurly
60ff8660de node-red-pi: fix behavior with old bash version (#1713)
For some reason the following will result
in an endless loop under bash-4.3.42:

while([ -h "${SCRIPT_PATH}" ])

Just remove the round brackets (parentheses) to fix the issue.
They're not needed anyway.
2018-05-03 09:41:37 +01:00
Nathan Allen
6fa0d671c0 Fix ENOENT error on first start when no user dir (#1711)
* Fix ENOENT error on first start when no user dir

Write backup using `copySync` and move it below the `fsync` to ensure file is present when backup is made.

* Check for path to exist before attempting backup
2018-05-03 09:40:51 +01:00
mblackstock
f478d7c9f0 experiments with mqtt ui (wip) 2018-05-02 16:02:53 -07:00
Nick O'Leary
53e3e08d70 Handle cloning a project without package.json 2018-05-02 16:24:58 +01:00
Nick O'Leary
c4d1ccb6f5 Keep remote branch state in sync between editor and runtime 2018-05-02 13:59:39 +01:00
Nick O'Leary
e3520309fc Add clone project to welcome screen 2018-05-02 13:38:50 +01:00
Martin Guillon
27bf72372e fix after comments 2018-05-01 14:00:05 +02:00
Nick O'Leary
ae4b1b17a9 Increase trigger node test timings 2018-05-01 12:59:53 +01:00
Dave Conway-Jones
94cb03f4b5 bind to correct port when doing udp broadcast/multicast (#1686)
* bind to correct port when doing broadcast/multicast

to allow better re-use of ports.

* allow udp multicast to work out if ip address

makes life easier for mortals

* udp also handle bind to ipv6 multicast if

tidy prompts to suit new function

* udp node, add face to debug log for multicast if known
2018-05-01 12:43:51 +01:00
Dave Conway-Jones
e691351976 update settings comments to describe how to setup for ipv6 (#1675)
* change default server bind to support ipv6 and ipv4

to close #1674

* Add comment re ipv6 so folk know it's capable

* slightly more words re ipv6 config

* Leave defaults as ipv4 but add doc to settings
2018-05-01 12:43:10 +01:00
Dave Conway-Jones
3190de873e add output property select to HTML parse node (#1701) 2018-05-01 12:42:27 +01:00
Christopher Hiller
e8a637498d add Node.js v10 to build matrix (#1708)
* add Node.js v10 to build matrix

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>

* only compute coverage once

We have to pick *which* version of Node.js to run coverage on, so I just
picked the latest.

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
2018-04-24 23:21:34 +01:00
Christopher Hiller
e1195ac00a fix many test problems (#1677)
* fix many test problems

- adds [stoppable](https://npm.im/stoppable) to force-stop net & http
  servers
- upgrades to latest mocha
- much cleanup of servers
- some removal of useless code

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>

* increase wait time to hack at race condition

* PoC with fork of stoppable

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>

* fix custom stoppable url for newer npm

* make travis go faster; attempt to avoid npm troubles

* fix coveralls executable path

* add extra time for flake to trigger spec

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
2018-04-23 12:37:26 +01:00
KatsuyaHoshii
6cd9ccc37c Refactor test cases 2018-04-23 14:31:37 +09:00
Nick O'Leary
25345302e8 Only add _alias/z to log messages if they are defined 2018-04-18 10:28:51 +01:00
Nick O'Leary
eccd5e9801 Handle additional debug msg props in Node_spec 2018-04-17 23:29:56 +01:00
mblackstock
ff355af9f2 use newer test helper 2018-04-17 11:59:47 -07:00
Martin Guillon
5967f4b0d4 fix error stack 2018-04-17 15:46:09 +02:00
Nick O'Leary
ff18618032 Highlight subflow node when log msg comes from inside
Fixes #1698
2018-04-17 12:44:58 +01:00
Martin Guillon
20f03c356c better script error handling.
Also pass the error in msg so that it can handled later
2018-04-17 10:52:53 +02:00
Nick O'Leary
27fdc9e56e Remove credential props after diffing flow to prevent future false positives
Fixes #1359
2018-04-16 15:36:23 +01:00
Nick O'Leary
52d9578a19 Log error if settings unavailable when saving user settings
Fixes #1645
2018-04-16 15:02:28 +01:00
Nick O'Leary
f4c2938b41 Ensure node wires array is not longer than outputs value
Fixes #1678
2018-04-16 13:23:36 +01:00
Nick O'Leary
9f703de5ec Allow importing an unknown config node to be undone
Fixes #1681
2018-04-16 11:20:37 +01:00
Dave Conway-Jones
a327fd85e2 Fix template to default typed input field
to close #1697
2018-04-16 11:14:15 +01:00
Dave Conway-Jones
9d22a86ec8 fix typo in switch label, make function label consistent 2018-04-16 11:12:21 +01:00
Ted
29e0b194dd Handle and display for invalid flow credentials when project is disabled #1689 (#1694)
* Handle and display for invalid flow credentials when project is disabled #1689

* fixed extra character

* fixed whitespace
2018-04-15 11:51:26 +01:00
Nick O'Leary
ae9cf13fc2 Fix http request doc type
Fixes #1690
2018-04-15 11:46:10 +01:00
Nick O'Leary
64ae67586a Ensure keyboard shortcuts get saved in runtime settings
Fixes #1696
2018-04-15 11:43:03 +01:00
Dave Conway-Jones
838c7a5e89 make debug slightly larger to pass WCAG AA rating 2018-04-05 11:25:08 +01:00
Dave Conway-Jones
89bfc90f40 Make core nodes labels more consistent, to close #1673
and make them translateable
2018-03-30 14:31:59 +01:00
Dave Conway-Jones
acad9f57f9 Add "not available" to common messages 2018-03-30 14:03:04 +01:00
Fabien Marchewka
0d08dc410e Prevent Following Redirect (#615) (#1684) 2018-03-29 08:28:44 +01:00
Nick O'Leary
ebb3fb96cd Merge pull request #1670 from node-red-hitachi/subflow-icon-change
Enable user defined icon for subflow
2018-03-27 10:22:20 +01:00
Nick O'Leary
f31f23ff07 Allow template node to be updated more than once
Fixes #1671
2018-03-27 10:14:39 +01:00
KatsuyaHoshii
d2aa3d1868 Add SSL server certificate 2018-03-27 17:07:29 +09:00
KatsuyaHoshii
c9e2fce94d test for httprequest node 2018-03-27 16:09:04 +09:00
Kazuki-Nakanishi
8b0e76dd55 Hide the subflow check logic inside getDefaultNodeIcon function 2018-03-22 14:14:09 +09:00
Dave Conway-Jones
884618adfe remove down carat from typed input with only 1 type 2018-03-20 21:01:10 +00:00
Christopher Hiller
6e2e36e7a0 tcp: queue messages while connecting; closes #1414
- queues messages on a per-client basis while waiting for TCP server
  connection
- add `denque` package for performance (`shift()` happens in constant
  instead of `Array`'s linear time)
- add tests
- remove a duplicate test in `31-tcp_request.spec.js`
- cap queue at value specified in settings (`tcpMsgQueueSize`); default
  to 1000
- add `tcpMsgQueueSize` to `settings.js`

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
2018-03-20 13:45:44 -07:00
Christopher Hiller
9994df9601 tcprequest tests: normalize indents 2018-03-20 13:45:44 -07:00
Nick O'Leary
98f7271ac8 Merge pull request #1657 from node-red-hitachi/move-i18n-info-text
move i18n info text of core nodes under nodes/core/locales directory
2018-03-20 20:44:54 +00:00
Dave Conway-Jones
087cd121b8 add debug and trace to function node (#1654) 2018-03-20 20:40:36 +00:00
Kazuki Nakanishi
2d52527fb4 Don't mark a subflow changed when actually modified nothing (#1665) 2018-03-20 20:39:46 +00:00
Kazuki Nakanishi
fe289e62b5 Fix the problem that output labels of switch node sometimes disappear (#1664) 2018-03-20 20:37:29 +00:00
Nick O'Leary
2845475e3f Keep backup of .config.json 2018-03-20 00:04:52 +00:00
Nick O'Leary
b307492487 Add warning if using _credentialSecret 2018-03-20 00:04:52 +00:00
Nick O'Leary
d48284f7ea Remove unused references to settings 2018-03-20 00:04:52 +00:00
Dave Conway-Jones
7e416797e9 make trigger test a bit more robust 2018-03-19 17:33:18 +00:00
Kroderia
5d54ca7477 Chinese translations for core nodes (#1607)
* Fix typo

* Fix and Update some Chinese translations.

* Fix and Add Chinese translations to match all en-US's items
2018-03-17 17:49:17 +00:00
Qi Xiu
b979b4e61a Master chinese3 (#1666)
* Translated jsonata.json to Chinese

* Translated file jsonata.json to Chinese
2018-03-17 17:48:01 +00:00
Kazuki Nakanishi
2527f7984a Translate rpi-gpio node (#1669)
Thanks
2018-03-17 17:46:44 +00:00
Kazuki-Nakanishi
d9350b2362 Enable user defined icon for subflow 2018-03-14 13:51:50 +09:00
Kazuhito Yokoi
bd0b903f1a Fix typo in info messages of file node 2018-03-14 01:19:37 +00:00
Kazuhito Yokoi
f243c0df19 Fix typo in info messages of json node 2018-03-14 01:18:00 +00:00
Kazuhito Yokoi
7482978953 Fix typo in info messages of html node 2018-03-14 01:16:59 +00:00
Kazuhito Yokoi
77966689d4 Fix typo in info messages of csv node 2018-03-14 01:15:36 +00:00
Kazuhito Yokoi
cf43939d65 Fix typo in info messages of split node 2018-03-14 01:11:11 +00:00
Kazuhito Yokoi
391ac4b351 Fix typo in info messages of change node 2018-03-14 01:09:29 +00:00
Kazuhito Yokoi
e1e48aadd9 Fix typo in info messages of switch node 2018-03-14 01:08:10 +00:00
Kazuhito Yokoi
0681f206c4 Fix typo in info messages of udp node 2018-03-14 01:05:38 +00:00
Kazuhito Yokoi
d257c6f3d3 Fix typo in info messages of tcpin node 2018-03-14 01:04:21 +00:00
Kazuhito Yokoi
fa45c82cdc Fix typo in info messages of watch node 2018-03-14 01:01:58 +00:00
Kazuhito Yokoi
e805b58da6 Fix typo in info messages of websocket node 2018-03-14 01:00:13 +00:00
Kazuhito Yokoi
943976d207 Fix typo in info messages of trigger node 2018-03-14 00:49:44 +00:00
Kazuhito Yokoi
3a2e5a6ccd Fix typo in info messages of exec node 2018-03-14 00:47:50 +00:00
Kazuhito Yokoi
35ef036246 Fix typo in info messages of debug node 2018-03-14 00:46:07 +00:00
Kazuhito Yokoi
e09c3bbdd3 Fix typo in info messages of inject node 2018-03-14 00:41:07 +00:00
Nick O'Leary
3b12076d4b Ignore subflow debug nodes when building filter
Fixes #1660

As the editor doesn't know the ids of subflow instance debug nodes
there's no easy way to build a list of them as part of the filter
options. So for now, disable the filter option if we don't know
about the debug node.
2018-03-03 22:41:02 +00:00
Hiroyasu Nishiyama
cfcf78ae28 fix failure of node installation (#1658) 2018-03-03 07:35:17 +00:00
Hiroyasu Nishiyama
341ff9bf5c move i18n info text of core nodes under nodes/core/locales directory 2018-03-03 10:39:11 +09:00
mblackstock
10d8ca30b0 use node-red-node-test-helper for node tests 2018-03-01 20:41:16 -08:00
Dave Conway-Jones
4ebb5d099e add trigger reset test for null on 2nd output 2018-03-01 14:00:14 +00:00
Dave Conway-Jones
1e82b66bf0 remove octalbonescript example line from settings as no longer supported 2018-03-01 11:41:53 +00:00
Nick O'Leary
06a5e4273b Move all event emitting into runtime side, not api side 2018-02-28 11:24:12 +00:00
Dave Conway-Jones
e123e7b0b0 Fix pi gpio output of boolean to actually send 1/0
rather than true/false
2018-02-27 23:26:32 +00:00
Nick O'Leary
aeadc40c65 Bump for 0.18.4 2018-02-27 16:41:10 +00:00
Nick O'Leary
7ef418ec52 Ensure sshkey file path is properly escaped on Windows 2018-02-27 13:05:10 +00:00
Nick O'Leary
2ed52820b6 Fix fs/fspath reference 2018-02-27 11:11:02 +00:00
Nick O'Leary
e8fd7484b6 Normalize ssh key paths for Windows file names 2018-02-27 10:58:54 +00:00
Nick O'Leary
ce5242cfe8 Ensure userDir is an absolute path when used with sshkeygen 2018-02-26 23:46:08 +00:00
Nick O'Leary
af947879d8 Merge pull request #1614 from node-red-hitachi/no-tabs
Fix the problem that the last flow tab can be deleted
2018-02-22 19:02:12 -08:00
Kazuki-Nakanishi
3ed112cde6 Changed coding style 2018-02-23 11:48:40 +09:00
Nick O'Leary
99c6a9eccd Merge pull request #1646 from node-red-hitachi/no-defaults-node
Fixed the problems when using a node without defaults
2018-02-22 18:12:41 -08:00
Nick O'Leary
2029f6ea0a Merge pull request #1638 from node-red-hitachi/i18n-info-jp
add Japanese info text of core nodes
2018-02-22 18:01:56 -08:00
Nick O'Leary
e984e1f30f Merge pull request #1616 from node-red-hitachi/fix-i18n-message-lookup
fix message lookup for core nodes in case of i18 locales directory ex…
2018-02-22 17:59:52 -08:00
Kazuki-Nakanishi
f21260370f Fixed the problems when using a node without defaults 2018-02-22 14:10:31 +09:00
Dave Conway-Jones
fdae75c99b ensure trigger gets reset when 2nd output is null
to fix #1644
2018-02-21 21:56:03 +00:00
Nick O'Leary
a0489f2a0d Fix tests for existing file flag in settings 2018-02-21 08:38:52 -08:00
Nick O'Leary
0123eacbdb Merge pull request #1642 from node-red-hitachi/subflow-icon
Disable user defined icon for subflow
2018-02-21 08:24:41 -08:00
Nick O'Leary
53401b6aa7 Fix merging a remote diff 2018-02-20 15:01:45 -08:00
Nick O'Leary
9a5139f452 Detect if there are no existing flows to migrate into a project 2018-02-20 14:30:37 -08:00
Nick O'Leary
2ee0c8c228 Use relative urls when retriving flow history 2018-02-20 14:27:47 -08:00
Kazuki-Nakanishi
c53562cc9c Disable user defined icon for subflow 2018-02-20 15:29:52 +09:00
Nick O'Leary
ec5d7c2e5c Add credentialSecret to clone pane 2018-02-18 17:09:19 +00:00
Nick O'Leary
d6fc258485 Delay clearing inflight when changing credentials key 2018-02-18 16:43:40 +00:00
Nick O'Leary
f953612695 Mark deploy inflight when reverting a file change 2018-02-18 16:30:47 +00:00
Kazuki-Nakanishi
2ab93acca8 Revise the fix for the problem that the last flow tab can be deleted 2018-02-16 11:54:52 +09:00
Nick O'Leary
326c6c496e Handle missing_flow_file error on clone properly 2018-02-15 22:47:07 +00:00
Nick O'Leary
9f7f50664c Remote project from cached list on delete so it can be reused 2018-02-15 22:46:36 +00:00
Nick O'Leary
f6f1436123 getDefaultNodeIcon should handle subflow instance nodes
Fixes #1635
2018-02-15 15:34:15 +00:00
Hiroyasu Nishiyama
c3c519419d merge i18n-info-jp-storage 2018-02-15 22:47:15 +09:00
Hiroyasu Nishiyama
e569a80b72 merge i18n-info-jp-parsers 2018-02-15 22:47:05 +09:00
Hiroyasu Nishiyama
284f437c1a merge i18n-info-jp-logic 2018-02-15 22:46:58 +09:00
Hiroyasu Nishiyama
1fd44a9958 merge i18n-info-jp-io 2018-02-15 22:46:46 +09:00
Hiroyasu Nishiyama
cad34742f6 merge i18n-info-jp-core 2018-02-15 22:46:18 +09:00
Hiroyasu Nishiyama
323359b3c8 merge i18n-info-jp-analysis 2018-02-15 22:46:10 +09:00
Hiroyasu Nishiyama
35db8b45f0 add Japanese info text for io category nodes 2018-02-15 22:39:46 +09:00
Nick O'Leary
50ae815ceb Update changelog 2018-02-14 13:53:55 +00:00
Nick O'Leary
1a4389c90d Fix offset calculation when dragging node from palette 2018-02-14 13:37:24 +00:00
Nick O'Leary
fdaa5ce1da Merge pull request #1624 from node-red/library-extra-element
let library createUi accept elements other than node-input-name
2018-02-14 13:16:39 +00:00
Nick O'Leary
09d9936aed Change remote-diff shortcut and add it to keymap
Fixes #1628
2018-02-14 09:54:07 +00:00
Nick O'Leary
b3f6109b1c Update changelog and bump package 2018-02-13 23:51:16 +00:00
Nick O'Leary
5fb3ffc240 Merge pull request #1627 from node-red-hitachi/fix-batch-concat-mode-msg-modification
fixed message modificcation of concat mode of BATCH node
2018-02-13 23:45:19 +00:00
Nick O'Leary
360db252bb Merge pull request #1626 from node-red-hitachi/fix-typo-in-jp-message-catalog
fix typo in Japanese message catalog
2018-02-13 23:44:48 +00:00
Nick O'Leary
0b6e290271 Merge pull request #1625 from node-red-hitachi/fix-typo-in-info-text
Fix typo in info text
2018-02-13 23:44:35 +00:00
Nick O'Leary
7f0174e6db Merge pull request #1617 from node-red-hitachi/fix-backquote-in-info
Fix backquote in info text
2018-02-13 23:43:56 +00:00
Nick O'Leary
a25dad6c2e Ensure debug tools show for 'complete msg object' 2018-02-13 23:42:22 +00:00
Nick O'Leary
6191a49ed3 Use flow-diff to resolve merge conflicts 2018-02-13 23:09:51 +00:00
Hiroyasu Nishiyama
6252b075bc fixed message modificcation of concat mode of BATCH node 2018-02-13 20:55:03 +09:00
Hiroyasu Nishiyama
7face138fd add Japanese info text for analysis category nodes 2018-02-12 14:04:29 +09:00
Hiroyasu Nishiyama
382b83b093 add Japanese info text for parsers category nodes 2018-02-12 12:24:03 +09:00
Hiroyasu Nishiyama
691687d1bc add Japanese info text for storage category nodes 2018-02-11 23:07:07 +09:00
Hiroyasu Nishiyama
5814b80a72 add Japanese info text for logic category nodes 2018-02-11 20:59:01 +09:00
Hiroyasu Nishiyama
e147fbb1fa add Japanese info text for core category nodes 2018-02-11 20:52:44 +09:00
Hiroyasu Nishiyama
b9e256adfa fix typo in Japanese message catalog 2018-02-11 02:11:29 +09:00
Hiroyasu Nishiyama
3b7bf04e22 fix typo in info text of DELAY node 2018-02-11 02:07:51 +09:00
Hiroyasu Nishiyama
43408a724c fix unmatched tag in info text of BATCH node 2018-02-11 02:06:28 +09:00
Dave Conway-Jones
5fbd5bf9e2 handle other fields in library - by only changing prefix
(rather than whole property  - so ...-name is still the name required)
2018-02-10 16:49:47 +00:00
Dave Conway-Jones
5e87828b29 let library createUi accept elements other than node-input-name 2018-02-10 16:16:49 +00:00
Nick O'Leary
9066cedc29 Better merge-conflict commit button layout 2018-02-09 09:35:47 +00:00
Nick O'Leary
aa1cf0b228 Avoid git fetch when refreshing local status 2018-02-08 23:30:07 +00:00
Nick O'Leary
06a6a4408f Handle allow-unrelated-histories option on pull 2018-02-08 23:21:14 +00:00
Nick O'Leary
d5619d2b9d Fix up merge conflict handling 2018-02-08 22:22:58 +00:00
Nick O'Leary
2f6ac42efe Add comment blocks to GitHub templates to reduce clutter 2018-02-08 14:39:58 +00:00
Hiroyasu Nishiyama
0bba3dd83d merge upstream/master 2018-02-08 23:22:00 +09:00
Hiroyasu Nishiyama
abe60b62e6 change backquote in info text to <code>...</code> 2018-02-08 23:20:53 +09:00
Nick O'Leary
555b7df986 Handle more git 2.1 differences 2018-02-07 13:47:09 +00:00
Nick O'Leary
b3786700e6 Handle changing case of git error messages between versions 2018-02-07 13:10:04 +00:00
Hiroyasu Nishiyama
ce9643d21b fix message lookup for core nodes in case of i18 locales directory exists 2018-02-07 21:59:58 +09:00
Nick O'Leary
4a5cb7f2f5 Ensure commit list has a refs object even if empty 2018-02-07 11:33:07 +00:00
Nick O'Leary
42a7e902e6 Handle host key verification as auth error 2018-02-07 11:32:50 +00:00
Nick O'Leary
aebe080e85 Add support for GIT_SSH on older levels of git 2018-02-07 10:50:32 +00:00
Kazuki-Nakanishi
c316284924 Fix the problem that the last flow tab can be deleted 2018-02-07 14:19:18 +09:00
Nick O'Leary
8d98b228ab Bump 0.18.2 2018-02-06 15:28:43 +00:00
Nick O'Leary
5b4c42ff05 Update changelog 2018-02-06 14:30:31 +00:00
Dave Conway-Jones
a596a4551a undo exec node change (investigate test fail) 2018-02-06 11:42:33 +00:00
Dave Conway-Jones
0968f96982 add a default keepalive to tcp client mode
to address #1469
2018-02-06 11:36:14 +00:00
Dave Conway-Jones
5931e13b9c move node.send in exec and httprequest nodes
just in case
2018-02-06 11:36:13 +00:00
Nick O'Leary
415c768ae4 Filter out %D from git log command for older git versions 2018-02-06 11:00:11 +00:00
Nick O'Leary
b4c8bf21d5 Ensure projects are created as logged in user 2018-02-06 10:38:41 +00:00
Nick O'Leary
5fe5db603d Better error handling/reporting in project creation 2018-02-05 15:59:11 +00:00
Nick O'Leary
9f7dd7f5d4 Add Project Settings menu option 2018-02-05 10:58:09 +00:00
Nick O'Leary
e6d32aab7b Refresh vc sidebar on remote add/remove 2018-02-05 10:10:26 +00:00
Dave Conway-Jones
08bd6d963c Ensure send is last thing trigger does 2018-02-04 21:25:25 +00:00
Dave Conway-Jones
ff05fb14a6 ensure trigger doesn't set two simultaneous timeouts 2018-02-04 20:17:43 +00:00
Nick O'Leary
22d942b705 Fix auth prompt for ssh repos 2018-02-03 23:44:19 +00:00
Nick O'Leary
0526372f28 Bump rbe dependency 2018-02-03 20:48:43 +00:00
Dave Conway-Jones
f99051906a add missing property select var to HTML node 2018-02-02 23:40:01 +00:00
Nick O'Leary
d1f7fd8bfd Prevent http git urls from including username/pword 2018-02-02 22:43:29 +00:00
288 changed files with 21604 additions and 5537 deletions

View File

@@ -1,3 +1,4 @@
<!--
## Before you hit that Submit button....
This issue tracker is for problems with the Node-RED runtime, the editor or the core nodes.
@@ -7,13 +8,16 @@ If your issue is:
- a feature request or suggestion for a change,
- or problems with 3rd party (`node-red-contrib-`) nodes
please use the [mailing list](https://groups.google.com/forum/#!forum/node-red), [slack team](https://nodered.org/slack) or ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`.
please use the [Node-RED Forum](https://discourse.nodered.org) or [slack team](https://nodered.org/slack).
You could also consider asking a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`.
That way the whole Node-RED user community can help, rather than rely on the core development team.
## So you have a real issue to raise...
To help us understand the issue, please fill-in as much of the following information as you can:
-->
### What are the steps to reproduce?

View File

@@ -1,3 +1,4 @@
<!--
## Before you hit that Submit button....
Please read our [contribution guidelines](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
@@ -6,23 +7,26 @@ before submitting a pull-request.
## Types of changes
What types of changes does your code introduce?
_Put an `x` in the boxes that apply_
Put an `x` in the boxes that apply
-->
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
<!--
If you want to raise a pull-request with a new feature, or a refactoring
of existing code, it **may well get rejected** if it hasn't been discussed on
the [mailing list](https://groups.google.com/forum/#!forum/node-red) or
the [forum](https://discourse.nodered.org) or
[slack team](https://nodered.org/slack) first.
-->
## Proposed changes
Describe the nature of this change. What problem does it address?
<!-- Describe the nature of this change. What problem does it address? -->
## Checklist
_Put an `x` in the boxes that apply_
<!-- Put an `x` in the boxes that apply -->
- [ ] I have read the [contribution guidelines](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
- [ ] For non-bugfix PRs, I have discussed this change on the mailing list/slack team.

View File

@@ -1,20 +1,12 @@
sudo: false
language: node_js
env:
- CXX="g++-4.8"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- gcc-4.8
node_js:
- "8"
- "6"
- "4"
script:
- istanbul cover ./node_modules/.bin/grunt --report lcovonly && istanbul report text && ( cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js || true ) && rm -rf coverage
before_script:
- npm install -g istanbul
- npm install coveralls
matrix:
include:
- node_js: "10"
script:
- ./node_modules/.bin/grunt && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage
before_script:
- npm install -g istanbul coveralls
- node_js: "8"
- node_js: "6"
- node_js: "4"

View File

@@ -1,3 +1,248 @@
#### 0.19.2: Maintenance Release
- Ensure node default colour is used if palette.theme has no match
- fix lost messages / properties in TCPRequest Node; closes #1863 (#1864)
- Fix typo in template.html
- Improve error reporting from context plugin loading
- Prevent no-op edit of node marking as changed due to icon
- Change node must handle empty rule set
#### 0.19.1: Maintenance Release
- Pull in latest twitter node
- Handle windows paths for context storage
- Handle persisting objects with circular refs in context
- Ensure js editor can expand to fill available space
- Add example localfilesystem contextStorage to settings
- Fix template node handling of nested context tags
#### 0.19: Milestone Release
Editor
- Add editorTheme.palette.theme to allow overriding colours
- Index all node properties when searching Fixes #1446
- Handle NaN and Infinity properly in debug sidebar Fixes #1778 #1779
- Prevent horizontal scroll when palette name cannot wrap
- Ignore middle-click on node/ports to enable panning
- Better wire layout when looping back
- fix appearence of retry button of remote branch management dialog
- Handle releasing ctrl when using quick-add node dialog
- Add $env function to JSONata expressions
- Widen support for env var to use ${} or $() syntax
- Add env-var support to TypedInput
- Show unknown node properties in info tab
- Add node icon picker widget
- Only edit nodes on dbl click on primary button with no modifiers
- Allow subflows to be put in any palette category
- Add flow navigator widget
- Cache flow library result to improve response time Fixes #1753
- Add middle-button-drag to pan the workspace
- allow multi-line category name in editor
- Redesign sidebar tabs
- Do not disable the export-clipboard menu option with empty selection
Nodes
- Change: Ensure runtime errors in Change node can be caught Fixes #1769
- File: Add output to File Out node
- Function: add expandable JavaScript editor pane
- Function: allow id and name reference in function node code (#1731)
- HTTP Request: Move to request module
- HTTP: Ensure apiMaxLength applies to HTTP Nodes Fixes #1278
- Join: accumulate top level properties
- Join: allow environment variable as reduce init value
- JSON: add JSON schema validation via msg.schema
- Pi: Let nrgpio code work with python 3
- Pi: let Pi nodes be visible/editable on all platforms
- Switch: add isEmpty rule
- TCP: queue messages while connecting; closes #1414
- TLS: Add servername option to TLS config node for SNI Fixes #1805
- UDP: Don't accidentally re-use udp port when set to not do so
Persistent Context
- Add Context data sidebar
- Add persistable context option
- Add default memory store
- Add file-based context store
- Add async mode to evaluateJSONataExpression
- Update RED.util.evaluateNodeProperty to support context stores
Runtime
- Support flow.disabled and .info in /flow API
- Node errors should be Strings not Errors Fixes #1781
- Add detection of connection timeout in git communication Fixes #1770
- Handle loading empty nodesDir
- Add 'private' property to userDir generated package.json
- Add RED.require to allow nodes to access other modules
- Ensure add/remove modules are run sequentially
#### 0.18.7: Maintenance Release
Editor Fixes
- Do not trim wires if node declares outputs in defaults but misses value Fixes #1737
Node Fixes
- Relax twitter node version ready for major version bump
- Pass Date into the Function node sandbox to fix instanceof tests
- let TCP in node report remote ip and port when in single packet mode
- typo fix in node help (#1735)
Other Fixes
- Tidy up default grunt task and fixup test break due to reorder Fixes #1738
- Bump jsonata version
#### 0.18.6: Maintenance Release
Editor Fixes
- Handle a node having wires in the editor on ports it no longer has Fixes #1724
- Add missing ACE snippet files
- Fix wireClippedNodes is not defined Fixes #1726
- Split node html to isolate bad nodes when loading
- Avoid unnecessary use of .html() where .text() will do
- Add editorTheme.projects.enabled to default settings.js"
#### 0.18.5: Maintenance Release
Projects
- Add clone project to welcome screen
- Handle cloning a project without package.json
- Keep remote branch state in sync between editor and runtime
New Features
- Add type checks to switch node options (#1714)
- add output property select to HTML parse node (#1701)
- Add Prevent Following Redirect to HTTP Request node (#615) (#1684)
- Add debug and trace functions to function node (#1654)
- Enable user defined icon for subflow
- Add MQTT disconnect message and rework broker node UI (#1719)
- Japanese message catalogue updates (#1723)
- Show node load errors in the Palette Manager view
Editor Fixes
- Highlight subflow node when log msg comes from inside Fixes #1698
- Ensure node wires array is not longer than outputs value Fixes #1678
- Allow importing an unknown config node to be undone Fixes #1681
- Ensure keyboard shortcuts get saved in runtime settings Fixes #1696
- Don't mark a subflow changed when actually modified nothing (#1665)
Node Fixes
- bind to correct port when doing udp broadcast/multicast (#1686)
- Provide full error stack in Function node log message (#1700)
- Fix http request doc type Fixes #1690
- Make debug slightly larger to pass WCAG AA rating
- Make core nodes labels more consistent, to close #1673
- Allow template node to be updated more than once Fixes #1671
- Fix the problem that output labels of switch node sometimes disappear (#1664)
- Chinese translations for core nodes (#1607)
Runtime Fixes
- Handle and display for invalid flow credentials when project is disabled #1689 (#1694)
- node-red-pi: fix behavior with old bash version (#1713)
- Fix ENOENT error on first start when no user dir (#1711)
- Handle null error object in Flow.handleError Fixes #1721
- update settings comments to describe how to setup for ipv6 (#1675)
- Remove credential props after diffing flow to prevent future false positives Fixes #1359
- Log error if settings unavailable when saving user settings Fixes #1645
- Keep backup of .config.json
- Add warning if using \_credentialSecret from .config.json
- Filter req.user in /settings to prevent potentially leaking info
#### 0.18.4: Maintenance Release
Projects
- Ensure sshkey file path is properly escaped on Windows
- Normalize ssh key paths for Windows file names
- Ensure userDir is an absolute path when used with sshkeygen
- Detect if there are no existing flows to migrate into a project
- Use relative urls when retriving flow history
- Add credentialSecret to clone pane
- Delay clearing inflight when changing credentials key
- Mark deploy inflight when reverting a file change
- Handle missing_flow_file error on clone properly
- Remote project from cached list on delete so it can be reused
- Fix tests for existing file flag in settings
Editor Fixes
- Fix merging a remote diff
- Fixed the problems when using a node without defaults
- Disable user defined icon for subflow
- getDefaultNodeIcon should handle subflow instance nodes Fixes #1635
- Add Japanese info text for core nodes
- Fix message lookup for core nodes in case of i18 locales directory exists
- Prevent the last tab from being deleted
Node Fixes
- Ensure trigger gets reset when 2nd output is null
#### 0.18.3: Maintenance Release
Projects
- Fix permissions on git/ssh scripts
- Add support for GIT_SSH on older levels of git
- Handle host key verification as auth error
- Ensure commit list has a refs object even if empty
- Make git error detection case-insensitive
- Fix up merge conflict handling
- Use flow-diff when looking at flow file changes
Node Fixes
- Ensure debug tools show for 'complete msg object'
- Fix msg.parts handling in concat mode of Batch node
Editor Fixes
- Fix offset calculation when dragging node from palette
- Allow a library entry to use non-default node-input- prefixes
- Change remote-diff shortcut and add it to keymap Fixes #1628
#### 0.18.2: Maintenance Release
Projects
- Filter out %D from git log command for older git versions
- Ensure projects are created as logged in user
- Better error handling/reporting in project creation
- Add Project Settings menu option
- Refresh vc sidebar on remote add/remove
- Fix auth prompt for ssh repos
- Prevent http git urls from including username/pword
- Fix fetch auth handling on non-default remote
- Avoid exception if git not installed
- Check version of git client on startup
- Fix pull/push when no tracked branch
- Add git_pull_unrelated_history handling
- Handle delete of last remote in project settings
Node Fixes
- Fix and Add some Chinese translations
- Update sort/batch docs
- Don't assume node has defaults when exporting icon property
- Ensure send is last thing trigger does
- Ensure trigger doesn't set two simultaneous timeouts
- Add missing property select var to HTML node
- Add a default keepalive to tcp client mode
- Move node.send in exec and httprequest nodes
#### 0.18.1: Maintenance Release
Projects

View File

@@ -30,13 +30,13 @@ At a minimum, please include:
## Feature requests
For feature requests, please raise them on the [mailing list](https://groups.google.com/forum/#!forum/node-red).
For feature requests, please raise them on the [forum](https://discourse.nodered.org).
## Pull-Requests
If you want to raise a pull-request with a new feature, or a refactoring
of existing code, it may well get rejected if you haven't discussed it on
the [mailing list](https://groups.google.com/forum/#!forum/node-red) first.
the [forum](https://discourse.nodered.org) first.
All contributors need to sign the JS Foundation's Contributor License Agreement.
It is an online process and quick to do. You can read the details of the agreement

View File

@@ -24,6 +24,10 @@ module.exports = function(grunt) {
nodemonArgs.push(flowFile);
}
var nonHeadless = grunt.option('non-headless');
if (nonHeadless) {
process.env.NODE_RED_NON_HEADLESS = 'true';
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
paths: {
@@ -55,7 +59,7 @@ module.exports = function(grunt) {
reportFormats: ['lcov','html'],
print: 'both'
},
all: { src: ['test/**/*_spec.js'] },
all: { src: ["test/_spec.js","test/red/**/*_spec.js","test/nodes/**/*_spec.js"] },
core: { src: ["test/_spec.js","test/red/**/*_spec.js"]},
nodes: { src: ["test/nodes/**/*_spec.js"]}
},
@@ -144,12 +148,15 @@ module.exports = function(grunt) {
"editor/js/ui/keyboard.js",
"editor/js/ui/workspaces.js",
"editor/js/ui/view.js",
"editor/js/ui/view-navigator.js",
"editor/js/ui/sidebar.js",
"editor/js/ui/palette.js",
"editor/js/ui/tab-info.js",
"editor/js/ui/tab-config.js",
"editor/js/ui/tab-context.js",
"editor/js/ui/palette-editor.js",
"editor/js/ui/editor.js",
"editor/js/ui/editors/*.js",
"editor/js/ui/tray.js",
"editor/js/ui/clipboard.js",
"editor/js/ui/library.js",
@@ -392,9 +399,9 @@ module.exports = function(grunt) {
mode: '755'
},
release: {
// Target-specific file/dir lists and/or options go here.
src: [
path.resolve('<%= paths.dist %>/node-red-<%= pkg.version %>/nodes/core/hardware/nrgpio*')
path.resolve('<%= paths.dist %>/node-red-<%= pkg.version %>/nodes/core/hardware/nrgpio*'),
path.resolve('<%= paths.dist %>/node-red-<%= pkg.version %>/red/runtime/storage/localfilesystem/projects/git/node-red-*sh')
]
}
},
@@ -474,7 +481,7 @@ module.exports = function(grunt) {
grunt.registerTask('default',
'Builds editor content then runs code style checks and unit tests on all components',
['build','test-core','test-editor','test-nodes']);
['build','jshint:editor','mocha_istanbul:all']);
grunt.registerTask('test-core',
'Runs code style check and unit tests on core runtime code',

View File

@@ -22,8 +22,7 @@ started.
More documentation can be found [here](http://nodered.org/docs).
For further help, or general discussion, please use the
[mailing list](https://groups.google.com/forum/#!forum/node-red).
For further help, or general discussion, please use the [Node-RED Forum](https://discourse.nodered.org) or [slack team](https://nodered.org/slack).
## Developers

View File

@@ -31,7 +31,7 @@ done
# Find the real location of this script
CURRENT_PATH=`pwd`
SCRIPT_PATH="${BASH_SOURCE[0]}";
while([ -h "${SCRIPT_PATH}" ]); do
while [ -h "${SCRIPT_PATH}" ]; do
cd "`dirname "${SCRIPT_PATH}"`"
SCRIPT_PATH="$(readlink "`basename "${SCRIPT_PATH}"`")";
done

BIN
editor/icons/file-in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

BIN
editor/icons/file-out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

View File

@@ -191,7 +191,7 @@ RED.history = (function() {
} else if (ev.t == "edit") {
for (i in ev.changes) {
if (ev.changes.hasOwnProperty(i)) {
if (ev.node._def.defaults[i] && ev.node._def.defaults[i].type) {
if (ev.node._def.defaults && ev.node._def.defaults[i] && ev.node._def.defaults[i].type) {
// This is a config node property
var currentConfigNode = RED.nodes.node(ev.node[i]);
if (currentConfigNode) {
@@ -229,10 +229,12 @@ RED.history = (function() {
}
});
}
RED.editor.validateNode(ev.node);
RED.nodes.filterNodes({type:"subflow:"+ev.node.id}).forEach(function(n) {
n.inputs = ev.node.in.length;
n.outputs = ev.node.out.length;
RED.editor.updateNodeProperties(n);
RED.editor.validateNode(n);
});
} else {
var outputMap;

View File

@@ -10,11 +10,12 @@
"ctrl-g i": "core:show-info-tab",
"ctrl-g d": "core:show-debug-tab",
"ctrl-g c": "core:show-config-tab",
"ctrl-g x": "core:show-context-tab",
"ctrl-e": "core:show-export-dialog",
"ctrl-i": "core:show-import-dialog",
"ctrl-space": "core:toggle-sidebar",
"ctrl-,": "core:show-user-settings",
"ctrl-alt-r": "core:show-remote-diff",
"ctrl-alt-n": "core:new-project",
"ctrl-alt-o": "core:open-project",
"ctrl-g v": "core:show-version-control-tab"

View File

@@ -15,6 +15,25 @@
**/
(function() {
function appendNodeConfig(nodeConfig) {
var m = /<!-- --- \[red-module:(\S+)\] --- -->/.exec(nodeConfig.trim());
var moduleId;
if (m) {
moduleId = m[1];
} else {
moduleId = "unknown";
}
try {
$("body").append(nodeConfig);
} catch(err) {
RED.notify(RED._("notification.errors.failedToAppendNode",{module:moduleId, error:err.toString()}),{
type: "error",
timeout: 10000
});
console.log("["+moduleId+"] "+err.toString());
}
}
function loadNodeList() {
$.ajax({
headers: {
@@ -55,7 +74,11 @@
cache: false,
url: 'nodes',
success: function(data) {
$("body").append(data);
var configs = data.trim().split(/(?=<!-- --- \[red-module:\S+\] --- -->)/);
configs.forEach(function(data) {
appendNodeConfig(data);
});
$("body").i18n();
$("#palette > .palette-spinner").hide();
$(".palette-scroll").removeClass("hide");
@@ -67,6 +90,7 @@
if (!activeProject) {
// Projects enabled but no active project
RED.menu.setDisabled('menu-item-projects-open',true);
RED.menu.setDisabled('menu-item-projects-settings',true);
if (activeProject === false) {
// User previously decline the migration to projects.
} else { // null/undefined
@@ -129,12 +153,13 @@
loadFlows(function() {
var project = RED.projects.getActiveProject();
var message = {
"change-branch":"Change to local branch '"+project.git.branches.local+"'",
"abort-merge":"Git merge aborted",
"loaded":"Project '"+msg.project+"' loaded",
"updated":"Project '"+msg.project+"' updated",
"pull":"Project '"+msg.project+"' reloaded",
"revert": "Project '"+msg.project+"' reloaded"
"change-branch": RED._("notification.project.change-branch", {project: project.git.branches.local}),
"merge-abort": RED._("notification.project.merge-abort"),
"loaded": RED._("notification.project.loaded", {project: msg.project}),
"updated": RED._("notification.project.updated", {project: msg.project}),
"pull": RED._("notification.project.pull", {project: msg.project}),
"revert": RED._("notification.project.revert", {project: msg.project}),
"merge-complete": RED._("notification.project.merge-complete")
}[msg.action];
RED.notify("<p>"+message+"</p>");
RED.sidebar.info.refresh()
@@ -158,7 +183,7 @@
if (!!RED.projects.getActiveProject()) {
options.buttons = [
{
text: "Manage project dependencies",
text: RED._("notification.label.manage-project-dep"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.settings.show('deps');
@@ -169,7 +194,7 @@
} else {
options.buttons = [
{
text: "Close",
text: RED._("common.label.close"),
click: function() {
persistentNotifications[notificationId].hideNotification();
}
@@ -177,13 +202,25 @@
]
}
} else if (msg.error === "credentials_load_failed") {
if (RED.user.hasPermission("projects.write")) {
if (RED.settings.theme("projects.enabled",false)) {
// projects enabled
if (RED.user.hasPermission("projects.write")) {
options.buttons = [
{
text: RED._("notification.label.setup-cred"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.showCredentialsPrompt();
}
}
]
}
} else {
options.buttons = [
{
text: "Setup credentials",
text: RED._("common.label.close"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.showCredentialsPrompt();
}
}
]
@@ -192,7 +229,7 @@
if (RED.user.hasPermission("projects.write")) {
options.buttons = [
{
text: "Setup project files",
text: RED._("notification.label.setup-project"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.showFilesPrompt();
@@ -200,17 +237,29 @@
}
]
}
} else if (msg.error === "missing_package_file") {
if (RED.user.hasPermission("projects.write")) {
options.buttons = [
{
text: RED._("notification.label.create-default-package"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.createDefaultPackageFile();
}
}
]
}
} else if (msg.error === "project_empty") {
if (RED.user.hasPermission("projects.write")) {
options.buttons = [
{
text: "No thanks",
text: RED._("notification.label.no-thanks"),
click: function() {
persistentNotifications[notificationId].hideNotification();
}
},
{
text: "Create default project files",
text: RED._("notification.label.create-default-project"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.createDefaultFileSet();
@@ -218,6 +267,20 @@
}
]
}
} else if (msg.error === "git_merge_conflict") {
RED.nodes.clear();
RED.sidebar.versionControl.refresh(true);
if (RED.user.hasPermission("projects.write")) {
options.buttons = [
{
text: RED._("notification.label.show-merge-conflicts"),
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.sidebar.versionControl.showLocalChanges();
}
}
]
}
}
}
if (!persistentNotifications.hasOwnProperty(notificationId)) {
@@ -256,7 +319,7 @@
addedTypes = addedTypes.concat(m.types);
RED.i18n.loadCatalog(id, function() {
$.get('nodes/'+id, function(data) {
$("body").append(data);
appendNodeConfig(data);
});
});
});
@@ -284,7 +347,7 @@
RED.notify(RED._("palette.event.nodeEnabled", {count:msg.types.length})+typeList,"success");
} else {
$.get('nodes/'+msg.id, function(data) {
$("body").append(data);
appendNodeConfig(data);
typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
RED.notify(RED._("palette.event.nodeAdded", {count:msg.types.length})+typeList,"success");
});
@@ -319,9 +382,10 @@
function loadEditor() {
var menuOptions = [];
if (RED.settings.theme("projects.enabled",false)) {
menuOptions.push({id:"menu-item-projects-menu",label:"Projects",options:[
{id:"menu-item-projects-new",label:"New...",disabled:false,onselect:"core:new-project"},
{id:"menu-item-projects-open",label:"Open...",disabled:false,onselect:"core:open-project"}
menuOptions.push({id:"menu-item-projects-menu",label:RED._("menu.label.projects"),options:[
{id:"menu-item-projects-new",label:RED._("menu.label.projects-new"),disabled:false,onselect:"core:new-project"},
{id:"menu-item-projects-open",label:RED._("menu.label.projects-open"),disabled:false,onselect:"core:open-project"},
{id:"menu-item-projects-settings",label:RED._("menu.label.projects-settings"),disabled:false,onselect:"core:show-project-settings"}
]});
}
@@ -346,8 +410,8 @@
{id:"menu-item-import-clipboard",label:RED._("menu.label.clipboard"),onselect:"core:show-import-dialog"},
{id:"menu-item-import-library",label:RED._("menu.label.library"),options:[]}
]});
menuOptions.push({id:"menu-item-export",label:RED._("menu.label.export"),disabled:true,options:[
{id:"menu-item-export-clipboard",label:RED._("menu.label.clipboard"),disabled:true,onselect:"core:show-export-dialog"},
menuOptions.push({id:"menu-item-export",label:RED._("menu.label.export"),options:[
{id:"menu-item-export-clipboard",label:RED._("menu.label.clipboard"),onselect:"core:show-export-dialog"},
{id:"menu-item-export-library",label:RED._("menu.label.library"),disabled:true,onselect:"core:library-export"}
]});
menuOptions.push(null);

View File

@@ -133,7 +133,7 @@ RED.nodes = (function() {
registerNodeType: function(nt,def) {
nodeDefinitions[nt] = def;
def.type = nt;
if (def.category != "subflows") {
if (nt.substring(0,8) != "subflow:") {
def.set = nodeSets[typeToId[nt]];
nodeSets[typeToId[nt]].added = true;
nodeSets[typeToId[nt]].enabled = true;
@@ -355,8 +355,8 @@ RED.nodes = (function() {
RED.nodes.registerType("subflow:"+sf.id, {
defaults:{name:{value:""}},
info: sf.info,
icon:"subflow.png",
category: "subflows",
icon: function() { return sf.icon||"subflow.png" },
category: sf.category || "subflows",
inputs: sf.in.length,
outputs: sf.out.length,
color: "#da9",
@@ -491,7 +491,9 @@ RED.nodes = (function() {
for (var j=0;j<wires.length;j++) {
var w = wires[j];
if (w.target.type != "subflow") {
node.wires[w.sourcePort].push(w.target.id);
if (w.sourcePort < node.wires.length) {
node.wires[w.sourcePort].push(w.target.id);
}
}
}
@@ -517,6 +519,7 @@ RED.nodes = (function() {
node.type = n.type;
node.name = n.name;
node.info = n.info;
node.category = n.category;
node.in = [];
node.out = [];
@@ -550,7 +553,11 @@ RED.nodes = (function() {
if (node.out.length > 0 && n.outputLabels && !/^\s*$/.test(n.outputLabels.join(""))) {
node.outputLabels = n.outputLabels.slice();
}
if (n.icon) {
if (n.icon !== "node-red/subflow.png") {
node.icon = n.icon;
}
}
return node;
}
@@ -749,7 +756,7 @@ RED.nodes = (function() {
if (!isInitialLoad && unknownTypes.length > 0) {
var typeList = "<ul><li>"+unknownTypes.join("</li><li>")+"</li></ul>";
var type = "type"+(unknownTypes.length > 1?"s":"");
RED.notify("<strong>"+RED._("clipboard.importUnrecognised",{count:unknownTypes.length})+"</strong>"+typeList,"error",false,10000);
RED.notify("<p>"+RED._("clipboard.importUnrecognised",{count:unknownTypes.length})+"</p>"+typeList,"error",false,10000);
}
var activeWorkspace = RED.workspaces.active();
@@ -1008,6 +1015,13 @@ RED.nodes = (function() {
set: registry.getNodeSet("node-red/unknown")
};
node.users = [];
// This is a config node, so delete the default
// non-config node properties
delete node.x;
delete node.y;
delete node.wires;
delete node.inputLabels;
delete node.outputLabels;
}
var orig = {};
for (var p in n) {
@@ -1020,10 +1034,31 @@ RED.nodes = (function() {
node.type = "unknown";
}
if (node._def.category != "config") {
node.inputs = n.inputs||node._def.inputs;
node.outputs = n.outputs||node._def.outputs;
if (n.hasOwnProperty('inputs')) {
node.inputs = n.inputs;
node._config.inputs = JSON.stringify(n.inputs);
} else {
node.inputs = node._def.inputs;
}
if (n.hasOwnProperty('outputs')) {
node.outputs = n.outputs;
node._config.outputs = JSON.stringify(n.outputs);
} else {
node.outputs = node._def.outputs;
}
if (node.hasOwnProperty('wires') && node.wires.length > node.outputs) {
if (!node._def.defaults.hasOwnProperty("outputs") || !isNaN(parseInt(n.outputs))) {
// If 'wires' is longer than outputs, clip wires
console.log("Warning: node.wires longer than node.outputs - trimming wires:",node.id," wires:",node.wires.length," outputs:",node.outputs);
node.wires = node.wires.slice(0,node.outputs);
} else {
// The node declares outputs in its defaults, but has not got a valid value
// Defer to the length of the wires array
node.outputs = node.wires.length;
}
}
for (d in node._def.defaults) {
if (node._def.defaults.hasOwnProperty(d)) {
if (node._def.defaults.hasOwnProperty(d) && d !== 'inputs' && d !== 'outputs') {
node[d] = n[d];
node._config[d] = JSON.stringify(n[d]);
}
@@ -1043,7 +1078,9 @@ RED.nodes = (function() {
addNode(node);
RED.editor.validateNode(node);
node_map[n.id] = node;
if (node._def.category != "config") {
// If an 'unknown' config node, it will not have been caught by the
// proper config node handling, so needs adding to new_nodes here
if (node.type === "unknown" || node._def.category !== "config") {
new_nodes.push(node);
}
}

View File

@@ -276,9 +276,20 @@ RED.clipboard = (function() {
if (typeof value !== "string" ) {
value = JSON.stringify(value, function(key,value) {
if (value !== null && typeof value === 'object') {
if (value.__encoded__ && value.hasOwnProperty('data') && value.hasOwnProperty('length')) {
truncated = value.data.length !== value.length;
return value.data;
if (value.__enc__) {
if (value.hasOwnProperty('data') && value.hasOwnProperty('length')) {
truncated = value.data.length !== value.length;
return value.data;
}
if (value.type === 'function' || value.type === 'internal') {
return undefined
}
if (value.type === 'number') {
// Handle NaN and Infinity - they are not permitted
// in JSON. We can either substitute with a String
// representation or null
return null;
}
}
}
return value;
@@ -309,18 +320,6 @@ RED.clipboard = (function() {
$('<input type="text" id="clipboard-hidden">').appendTo("body");
RED.events.on("view:selection-changed",function(selection) {
if (!selection.nodes) {
RED.menu.setDisabled("menu-item-export",true);
RED.menu.setDisabled("menu-item-export-clipboard",true);
RED.menu.setDisabled("menu-item-export-library",true);
} else {
RED.menu.setDisabled("menu-item-export",false);
RED.menu.setDisabled("menu-item-export-clipboard",false);
RED.menu.setDisabled("menu-item-export-library",false);
}
});
RED.actions.add("core:show-export-dialog",exportNodes);
RED.actions.add("core:show-import-dialog",importNodes);

View File

@@ -19,12 +19,14 @@ RED.popover = (function() {
"default": {
top: 10,
leftRight: 17,
leftLeft: 25
leftLeft: 25,
leftBottom: 8,
},
"small": {
top: 5,
leftRight: 17,
leftLeft: 16
leftLeft: 16,
leftBottom: 3,
}
}
function createPopover(options) {
@@ -46,29 +48,39 @@ RED.popover = (function() {
var openPopup = function(instant) {
if (active) {
div = $('<div class="red-ui-popover red-ui-popover-'+direction+'"></div>').appendTo("body");
div = $('<div class="red-ui-popover red-ui-popover-'+direction+'"></div>');
if (size !== "default") {
div.addClass("red-ui-popover-size-"+size);
}
if (typeof content === 'function') {
content.call(res).appendTo(div);
var result = content.call(res);
if (result === null) {
return;
}
if (typeof result === 'string') {
div.text(result);
} else {
div.append(result);
}
} else {
div.html(content);
}
if (width !== "auto") {
div.width(width);
}
div.appendTo("body");
var targetPos = target.offset();
var targetWidth = target.width();
var targetHeight = target.height();
var targetWidth = target.outerWidth();
var targetHeight = target.outerHeight();
var divHeight = div.height();
var divWidth = div.width();
if (direction === 'right') {
div.css({top: targetPos.top+targetHeight/2-divHeight/2-deltaSizes[size].top,left:targetPos.left+targetWidth+deltaSizes[size].leftRight});
} else if (direction === 'left') {
div.css({top: targetPos.top+targetHeight/2-divHeight/2-deltaSizes[size].top,left:targetPos.left-deltaSizes[size].leftLeft-divWidth});
} else if (direction === 'bottom') {
div.css({top: targetPos.top+targetHeight+deltaSizes[size].top,left:targetPos.left+targetWidth/2-divWidth/2 - deltaSizes[size].leftBottom});
}
if (instant) {
div.show();
@@ -143,7 +155,17 @@ RED.popover = (function() {
}
return {
create: createPopover
create: createPopover,
tooltip: function(target,content) {
RED.popover.create({
target:target,
trigger: "hover",
size: "small",
direction: "bottom",
content: content,
delay: { show: 550, hide: 10 }
});
}
}
})();

View File

@@ -17,10 +17,15 @@
RED.tabs = (function() {
var defaultTabIcon = "fa fa-lemon-o";
function createTabs(options) {
var tabs = {};
var pinnedTabsCount = 0;
var currentTabWidth;
var currentActiveTabWidth = 0;
var collapsibleMenu;
var ul = options.element || $("#"+options.id);
var wrapper = ul.wrap( "<div>" ).parent();
@@ -50,6 +55,56 @@ RED.tabs = (function() {
scrollRight = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-right"><a href="#" style="display:none;"><i class="fa fa-caret-right"></i></a></div>').appendTo(wrapper).find("a");
scrollRight.on('mousedown',function(evt) { scrollEventHandler(evt,'+=150') }).on('click',function(evt){ evt.preventDefault();});
}
if (options.collapsible) {
// var dropDown = $('<div>',{class:"red-ui-tabs-select"}).appendTo(wrapper);
// ul.hide();
wrapper.addClass("red-ui-tabs-collapsible");
var collapsedButtonsRow = $('<div class="red-ui-tab-link-buttons"></div>').appendTo(wrapper);
var selectButton = $('<a href="#"><i class="fa fa-caret-down"></i></a>').appendTo(collapsedButtonsRow);
selectButton.addClass("red-ui-tab-link-button-menu")
selectButton.click(function(evt) {
evt.preventDefault();
if (!collapsibleMenu) {
var pinnedOptions = [];
var options = [];
ul.children().each(function(i,el) {
var id = $(el).data('tabId');
var opt = {
id:"red-ui-tabs-menu-option-"+id,
icon: tabs[id].iconClass || defaultTabIcon,
label: tabs[id].name,
onselect: function() {
activateTab(id);
}
};
if (tabs[id].pinned) {
pinnedOptions.push(opt);
} else {
options.push(opt);
}
});
options = pinnedOptions.concat(options);
collapsibleMenu = RED.menu.init({id:"debug-message-option-menu",options: options});
collapsibleMenu.css({
position: "absolute"
})
collapsibleMenu.on('mouseleave', function(){ $(this).hide() });
collapsibleMenu.on('mouseup', function() { $(this).hide() });
collapsibleMenu.appendTo("body");
}
var elementPos = selectButton.offset();
collapsibleMenu.css({
top: (elementPos.top+selectButton.height()-20)+"px",
left: (elementPos.left - collapsibleMenu.width() + selectButton.width())+"px"
})
collapsibleMenu.toggle();
})
}
function scrollEventHandler(evt,dir) {
evt.preventDefault();
if ($(this).hasClass('disabled')) {
@@ -118,6 +173,9 @@ RED.tabs = (function() {
ul.children().removeClass("active");
ul.children().css({"transition": "width 100ms"});
link.parent().addClass("active");
var parentId = link.parent().attr('id');
wrapper.find(".red-ui-tab-link-button").removeClass("active selected");
$("#"+parentId+"-link-button").addClass("active selected");
if (options.scrollable) {
var pos = link.parent().position().left;
if (pos-21 < 0) {
@@ -155,41 +213,70 @@ RED.tabs = (function() {
var tabs = ul.find("li.red-ui-tab");
var width = wrapper.width();
var tabCount = tabs.size();
var tabWidth = (width-12-(tabCount*6))/tabCount;
currentTabWidth = (100*tabWidth/width)+"%";
currentActiveTabWidth = currentTabWidth+"%";
if (options.scrollable) {
tabWidth = Math.max(tabWidth,140);
currentTabWidth = tabWidth+"px";
currentActiveTabWidth = 0;
var listWidth = Math.max(wrapper.width(),12+(tabWidth+6)*tabCount);
ul.width(listWidth);
updateScroll();
} else if (options.hasOwnProperty("minimumActiveTabWidth")) {
if (tabWidth < options.minimumActiveTabWidth) {
tabCount -= 1;
tabWidth = (width-12-options.minimumActiveTabWidth-(tabCount*6))/tabCount;
currentTabWidth = (100*tabWidth/width)+"%";
currentActiveTabWidth = options.minimumActiveTabWidth+"px";
var tabWidth;
if (options.collapsible) {
tabWidth = width - collapsedButtonsRow.width()-10;
if (tabWidth < 198) {
var delta = 198 - tabWidth;
var b = collapsedButtonsRow.find("a:last").prev();
while (b.is(":not(:visible)")) {
b = b.prev();
}
if (!b.hasClass("red-ui-tab-link-button-pinned")) {
b.hide();
}
tabWidth = width - collapsedButtonsRow.width()-10;
} else {
currentActiveTabWidth = 0;
var space = width - 198 - collapsedButtonsRow.width();
if (space > 40) {
collapsedButtonsRow.find("a:not(:visible):first").show();
tabWidth = width - collapsedButtonsRow.width()-10;
}
}
}
tabs.css({width:currentTabWidth});
if (tabWidth < 50) {
ul.find(".red-ui-tab-close").hide();
ul.find(".red-ui-tab-icon").hide();
ul.find(".red-ui-tab-label").css({paddingLeft:Math.min(12,Math.max(0,tabWidth-38))+"px"})
tabs.css({width:tabWidth});
} else {
ul.find(".red-ui-tab-close").show();
ul.find(".red-ui-tab-icon").show();
ul.find(".red-ui-tab-label").css({paddingLeft:""})
}
if (currentActiveTabWidth !== 0) {
ul.find("li.red-ui-tab.active").css({"width":options.minimumActiveTabWidth});
ul.find("li.red-ui-tab.active .red-ui-tab-close").show();
ul.find("li.red-ui-tab.active .red-ui-tab-icon").show();
ul.find("li.red-ui-tab.active .red-ui-tab-label").css({paddingLeft:""})
var tabWidth = (width-12-(tabCount*6))/tabCount;
currentTabWidth = (100*tabWidth/width)+"%";
currentActiveTabWidth = currentTabWidth+"%";
if (options.scrollable) {
tabWidth = Math.max(tabWidth,140);
currentTabWidth = tabWidth+"px";
currentActiveTabWidth = 0;
var listWidth = Math.max(wrapper.width(),12+(tabWidth+6)*tabCount);
ul.width(listWidth);
updateScroll();
} else if (options.hasOwnProperty("minimumActiveTabWidth")) {
if (tabWidth < options.minimumActiveTabWidth) {
tabCount -= 1;
tabWidth = (width-12-options.minimumActiveTabWidth-(tabCount*6))/tabCount;
currentTabWidth = (100*tabWidth/width)+"%";
currentActiveTabWidth = options.minimumActiveTabWidth+"px";
} else {
currentActiveTabWidth = 0;
}
}
if (options.collapsible) {
console.log(currentTabWidth);
}
tabs.css({width:currentTabWidth});
if (tabWidth < 50) {
ul.find(".red-ui-tab-close").hide();
ul.find(".red-ui-tab-icon").hide();
ul.find(".red-ui-tab-label").css({paddingLeft:Math.min(12,Math.max(0,tabWidth-38))+"px"})
} else {
ul.find(".red-ui-tab-close").show();
ul.find(".red-ui-tab-icon").show();
ul.find(".red-ui-tab-label").css({paddingLeft:""})
}
if (currentActiveTabWidth !== 0) {
ul.find("li.red-ui-tab.active").css({"width":options.minimumActiveTabWidth});
ul.find("li.red-ui-tab.active .red-ui-tab-close").show();
ul.find("li.red-ui-tab.active .red-ui-tab-icon").show();
ul.find("li.red-ui-tab.active .red-ui-tab-label").css({paddingLeft:""})
}
}
}
@@ -210,11 +297,15 @@ RED.tabs = (function() {
activateTab(tab.find("a"));
}
li.remove();
if (tabs[id].pinned) {
pinnedTabsCount--;
}
if (options.onremove) {
options.onremove(tabs[id]);
}
delete tabs[id];
updateTabWidths();
collapsibleMenu = null;
}
return {
@@ -223,13 +314,48 @@ RED.tabs = (function() {
var li = $("<li/>",{class:"red-ui-tab"}).appendTo(ul);
li.attr('id',"red-ui-tab-"+(tab.id.replace(".","-")));
li.data("tabId",tab.id);
if (options.maximumTabWidth) {
li.css("maxWidth",options.maximumTabWidth+"px");
}
var link = $("<a/>",{href:"#"+tab.id, class:"red-ui-tab-label"}).appendTo(li);
if (tab.icon) {
$('<img src="'+tab.icon+'" class="red-ui-tab-icon"/>').appendTo(link);
} else if (tab.iconClass) {
$('<i>',{class:"red-ui-tab-icon "+tab.iconClass}).appendTo(link);
}
var span = $('<span/>',{class:"bidiAware"}).text(tab.label).appendTo(link);
span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label));
if (options.collapsible) {
li.addClass("red-ui-tab-pinned");
var pinnedLink = $('<a href="#'+tab.id+'" class="red-ui-tab-link-button"></a>');
if (tab.pinned) {
if (pinnedTabsCount === 0) {
pinnedLink.prependTo(collapsedButtonsRow)
} else {
pinnedLink.insertAfter(collapsedButtonsRow.find("a.red-ui-tab-link-button-pinned:last"));
}
} else {
pinnedLink.insertBefore(collapsedButtonsRow.find("a:last"));
}
pinnedLink.attr('id',li.attr('id')+"-link-button");
if (tab.iconClass) {
$('<i>',{class:tab.iconClass}).appendTo(pinnedLink);
} else {
$('<i>',{class:defaultTabIcon}).appendTo(pinnedLink);
}
pinnedLink.click(function(evt) {
evt.preventDefault();
activateTab(tab.id);
});
if (tab.pinned) {
pinnedLink.addClass("red-ui-tab-link-button-pinned");
pinnedTabsCount++;
}
RED.popover.tooltip($(pinnedLink), tab.name);
}
link.on("click",onTabClick);
link.on("dblclick",onTabDblClick);
if (tab.closeable) {
@@ -241,7 +367,6 @@ RED.tabs = (function() {
removeTab(tab.id);
});
}
updateTabWidths();
if (options.onadd) {
options.onadd(tab);
}
@@ -326,6 +451,10 @@ RED.tabs = (function() {
}
})
}
setTimeout(function() {
updateTabWidths();
},10);
collapsibleMenu = null;
},
removeTab: removeTab,
activateTab: activateTab,

View File

@@ -14,10 +14,38 @@
* limitations under the License.
**/
(function($) {
var contextParse = function(v) {
var parts = RED.utils.parseContextKey(v);
return {
option: parts.store,
value: parts.key
}
}
var contextExport = function(v,opt) {
if (!opt) {
return v;
}
var store = ((typeof opt === "string")?opt:opt.value)
if (store !== RED.settings.context.default) {
return "#:("+store+")::"+v;
} else {
return v;
}
}
var allOptions = {
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression},
flow: {value:"flow",label:"flow.",validate:RED.utils.validatePropertyExpression},
global: {value:"global",label:"global.",validate:RED.utils.validatePropertyExpression},
flow: {value:"flow",label:"flow.",hasValue:true,
options:[],
validate:RED.utils.validatePropertyExpression,
parse: contextParse,
export: contextExport
},
global: {value:"global",label:"global.",hasValue:true,
options:[],
validate:RED.utils.validatePropertyExpression,
parse: contextParse,
export: contextExport
},
str: {value:"str",label:"string",icon:"red/images/typedInput/az.png"},
num: {value:"num",label:"number",icon:"red/images/typedInput/09.png",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/},
bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.png",options:["true","false"]},
@@ -76,31 +104,51 @@
}
})
}
},
env: {
value: "env",
label: "env variable",
icon: "red/images/typedInput/env.png"
}
};
var nlsd = false;
$.widget( "nodered.typedInput", {
_create: function() {
try {
if (!nlsd && RED && RED._) {
for (var i in allOptions) {
if (allOptions.hasOwnProperty(i)) {
allOptions[i].label = RED._("typedInput.type."+i,{defaultValue:allOptions[i].label});
}
}
var contextStores = RED.settings.context.stores;
var contextOptions = contextStores.map(function(store) {
return {value:store,label: store, icon:'<i class="red-ui-typedInput-icon fa fa-database" style="color: #'+(store==='memory'?'ddd':'777')+'"></i>'}
})
if (contextOptions.length < 2) {
allOptions.flow.options = [];
allOptions.global.options = [];
} else {
allOptions.flow.options = contextOptions;
allOptions.global.options = contextOptions;
}
}
nlsd = true;
var that = this;
this.disarmClick = false;
this.input = $('<input type="text"></input>');
this.input.insertAfter(this.element);
this.input.val(this.element.val());
this.element.addClass('red-ui-typedInput');
this.uiWidth = this.element.outerWidth();
this.elementDiv = this.element.wrap("<div>").parent().addClass('red-ui-typedInput-input');
this.elementDiv = this.input.wrap("<div>").parent().addClass('red-ui-typedInput-input');
this.uiSelect = this.elementDiv.wrap( "<div>" ).parent();
var attrStyle = this.element.attr('style');
var m;
if ((m = /width\s*:\s*(calc\s*\(.*\)|\d+(%|px))/i.exec(attrStyle)) !== null) {
this.element.css('width','100%');
this.input.css('width','100%');
this.uiSelect.width(m[1]);
this.uiWidth = null;
} else {
@@ -109,17 +157,19 @@
["Right","Left"].forEach(function(d) {
var m = that.element.css("margin"+d);
that.uiSelect.css("margin"+d,m);
that.element.css("margin"+d,0);
that.input.css("margin"+d,0);
});
this.uiSelect.addClass("red-ui-typedInput-container");
this.element.attr('type','hidden');
this.options.types = this.options.types||Object.keys(allOptions);
this.selectTrigger = $('<button tabindex="0"></button>').prependTo(this.uiSelect);
if (this.options.types.length > 1) {
$('<i class="fa fa-sort-desc"></i>').appendTo(this.selectTrigger);
}
this.selectLabel = $('<span></span>').appendTo(this.selectTrigger);
$('<i class="red-ui-typedInput-icon fa fa-sort-desc"></i>').toggle(this.options.types.length > 1).appendTo(this.selectTrigger);
this.selectLabel = $('<span class="red-ui-typedInput-type-label"></span>').appendTo(this.selectTrigger);
this.types(this.options.types);
@@ -133,14 +183,16 @@
this.typeField = $("<input>",{type:'hidden'}).appendTo(this.uiSelect);
}
this.element.on('focus', function() {
this.input.on('focus', function() {
that.uiSelect.addClass('red-ui-typedInput-focus');
});
this.element.on('blur', function() {
this.input.on('blur', function() {
that.uiSelect.removeClass('red-ui-typedInput-focus');
});
this.element.on('change', function() {
this.input.on('change', function() {
that.validate();
that.element.val(that.value());
that.element.trigger('change',that.propertyType,that.value());
})
this.selectTrigger.click(function(event) {
event.preventDefault();
@@ -156,8 +208,11 @@
})
// explicitly set optionSelectTrigger display to inline-block otherwise jQ sets it to 'inline'
this.optionSelectTrigger = $('<button tabindex="0" class="red-ui-typedInput-option-trigger" style="display:inline-block"><span class="red-ui-typedInput-option-caret"><i class="fa fa-sort-desc"></i></span></button>').appendTo(this.uiSelect);
this.optionSelectTrigger = $('<button tabindex="0" class="red-ui-typedInput-option-trigger" style="display:inline-block"><span class="red-ui-typedInput-option-caret"><i class="red-ui-typedInput-icon fa fa-sort-desc"></i></span></button>').appendTo(this.uiSelect);
this.optionSelectLabel = $('<span class="red-ui-typedInput-option-label"></span>').prependTo(this.optionSelectTrigger);
RED.popover.tooltip(this.optionSelectLabel,function() {
return that.optionValue;
});
this.optionSelectTrigger.click(function(event) {
event.preventDefault();
that._showOptionSelectMenu();
@@ -172,17 +227,18 @@
that.uiSelect.addClass('red-ui-typedInput-focus');
});
this.optionExpandButton = $('<button tabindex="0" class="red-ui-typedInput-option-expand" style="display:inline-block"><i class="fa fa-ellipsis-h"></i></button>').appendTo(this.uiSelect);
this.optionExpandButton = $('<button tabindex="0" class="red-ui-typedInput-option-expand" style="display:inline-block"><i class="red-ui-typedInput-icon fa fa-ellipsis-h"></i></button>').appendTo(this.uiSelect);
this.type(this.options.default||this.typeList[0].value);
}catch(err) {
console.log(err.stack);
}
},
_showTypeMenu: function() {
if (this.typeList.length > 1) {
this._showMenu(this.menu,this.selectTrigger);
this.menu.find("[value='"+this.propertyType+"']").focus();
} else {
this.element.focus();
this.input.focus();
}
},
_showOptionSelectMenu: function() {
@@ -191,8 +247,8 @@
minWidth:this.optionSelectLabel.width()
});
this._showMenu(this.optionMenu,this.optionSelectLabel);
var selectedOption = this.optionMenu.find("[value='"+this.value()+"']");
this._showMenu(this.optionMenu,this.optionSelectTrigger);
var selectedOption = this.optionMenu.find("[value='"+this.optionValue+"']");
if (selectedOption.length === 0) {
selectedOption = this.optionMenu.children(":first");
}
@@ -204,7 +260,7 @@
$(document).off("mousedown.close-property-select");
menu.hide();
if (this.elementDiv.is(":visible")) {
this.element.focus();
this.input.focus();
} else if (this.optionSelectTrigger.is(":visible")){
this.optionSelectTrigger.focus();
} else {
@@ -223,10 +279,19 @@
op.text(opt.label);
}
if (opt.icon) {
$('<img>',{src:opt.icon,style:"margin-right: 4px; height: 18px;"}).prependTo(op);
if (opt.icon.indexOf("<") === 0) {
$(opt.icon).prependTo(op);
} else if (opt.icon.indexOf("/") !== -1) {
$('<img>',{src:opt.icon,style:"margin-right: 4px; height: 18px;"}).prependTo(op);
} else {
$('<i>',{class:"red-ui-typedInput-icon "+opt.icon}).prependTo(op);
}
} else {
op.css({paddingLeft: "18px"});
}
if (!opt.icon && !opt.label) {
op.text(opt.value);
}
op.click(function(event) {
event.preventDefault();
@@ -305,7 +370,8 @@
if (this.uiWidth !== null) {
this.uiSelect.width(this.uiWidth);
}
if (this.typeMap[this.propertyType] && this.typeMap[this.propertyType].hasValue === false) {
var type = this.typeMap[this.propertyType];
if (type && type.hasValue === false) {
this.selectTrigger.addClass("red-ui-typedInput-full-width");
} else {
this.selectTrigger.removeClass("red-ui-typedInput-full-width");
@@ -315,13 +381,68 @@
this.elementDiv.css('right',"22px");
} else {
this.elementDiv.css('right','0');
this.input.css({
'border-top-right-radius': '4px',
'border-bottom-right-radius': '4px'
});
}
// if (this.optionSelectTrigger) {
// this.optionSelectTrigger.css({'left':(labelWidth)+"px",'width':'calc( 100% - '+labelWidth+'px )'});
// }
if (this.optionSelectTrigger) {
this.optionSelectTrigger.css({'left':(labelWidth)+"px",'width':'calc( 100% - '+labelWidth+'px )'});
if (type && type.options && type.hasValue === true) {
this.optionSelectLabel.css({'left':'auto'})
var lw = this._getLabelWidth(this.optionSelectLabel);
this.optionSelectTrigger.css({'width':(23+lw)+"px"});
this.elementDiv.css('right',(23+lw)+"px");
this.input.css({
'border-top-right-radius': 0,
'border-bottom-right-radius': 0
});
} else {
this.optionSelectLabel.css({'left':'0'})
this.optionSelectTrigger.css({'width':'calc( 100% - '+labelWidth+'px )'});
if (!this.optionExpandButton.is(":visible")) {
this.elementDiv.css({'right':0});
this.input.css({
'border-top-right-radius': '4px',
'border-bottom-right-radius': '4px'
});
}
}
}
}
},
_updateOptionSelectLabel: function(o) {
var opt = this.typeMap[this.propertyType];
this.optionSelectLabel.empty();
if (o.icon) {
if (o.icon.indexOf("<") === 0) {
$(o.icon).prependTo(this.optionSelectLabel);
} else if (o.icon.indexOf("/") !== -1) {
// url
$('<img>',{src:o.icon,style:"height: 18px;"}).prependTo(this.optionSelectLabel);
} else {
// icon class
$('<i>',{class:"red-ui-typedInput-icon "+o.icon}).prependTo(this.optionSelectLabel);
}
} else if (o.label) {
this.optionSelectLabel.text(o.label);
} else {
this.optionSelectLabel.text(o.value);
}
if (opt.hasValue) {
this.optionValue = o.value;
this._resize();
this.input.trigger('change',this.propertyType,this.value());
}
},
_destroy: function() {
if (this.optionMenu) {
this.optionMenu.remove();
}
this.menu.remove();
},
types: function(types) {
@@ -339,13 +460,18 @@
return result;
});
this.selectTrigger.toggleClass("disabled", this.typeList.length === 1);
this.selectTrigger.find(".fa-sort-desc").toggle(this.typeList.length > 1)
if (this.menu) {
this.menu.remove();
}
this.menu = this._createMenu(this.typeList, function(v) { that.type(v) });
if (currentType && !this.typeMap.hasOwnProperty(currentType)) {
this.type(this.typeList[0].value);
} else {
this.propertyType = null;
this.type(currentType);
}
setTimeout(function() {that._resize();},0);
},
width: function(desiredWidth) {
this.uiWidth = desiredWidth;
@@ -353,33 +479,33 @@
},
value: function(value) {
if (!arguments.length) {
return this.element.val();
var v = this.input.val();
if (this.typeMap[this.propertyType].export) {
v = this.typeMap[this.propertyType].export(v,this.optionValue)
}
return v;
} else {
var selectedOption;
if (this.typeMap[this.propertyType].options) {
var validValue = false;
var label;
for (var i=0;i<this.typeMap[this.propertyType].options.length;i++) {
var op = this.typeMap[this.propertyType].options[i];
if (typeof op === "string") {
if (op === value) {
label = value;
validValue = true;
selectedOption = this.activeOptions[op];
break;
}
} else if (op.value === value) {
label = op.label||op.value;
validValue = true;
selectedOption = op;
break;
}
}
if (!validValue) {
value = "";
label = "";
if (!selectedOption) {
selectedOption = {value:""}
}
this.optionSelectLabel.text(label);
this._updateOptionSelectLabel(selectedOption)
}
this.element.val(value);
this.element.trigger('change',this.type(),value);
this.input.val(value);
this.input.trigger('change',this.type(),value);
}
},
type: function(type) {
@@ -390,7 +516,9 @@
var opt = this.typeMap[type];
if (opt && this.propertyType !== type) {
this.propertyType = type;
this.typeField.val(type);
if (this.typeField) {
this.typeField.val(type);
}
this.selectLabel.empty();
var image;
if (opt.icon) {
@@ -407,37 +535,88 @@
}
if (this.optionSelectTrigger) {
this.optionSelectTrigger.show();
this.elementDiv.hide();
this.optionMenu = this._createMenu(opt.options,function(v){
that.optionSelectLabel.text(v);
that.value(v);
if (!opt.hasValue) {
this.elementDiv.hide();
} else {
this.elementDiv.show();
}
this.activeOptions = {};
opt.options.forEach(function(o) {
if (typeof o === 'string') {
that.activeOptions[o] = {label:o,value:o};
} else {
that.activeOptions[o.value] = o;
}
});
if (!that.activeOptions.hasOwnProperty(that.optionValue)) {
that.optionValue = null;
}
this.optionMenu = this._createMenu(opt.options,function(v){
that._updateOptionSelectLabel(that.activeOptions[v]);
if (!opt.hasValue) {
that.value(that.activeOptions[v].value)
}
});
var currentVal = this.element.val();
var validValue = false;
var op;
for (var i=0;i<opt.options.length;i++) {
op = opt.options[i];
if (typeof op === "string") {
if (op === currentVal) {
this.optionSelectLabel.text(currentVal);
if (!opt.hasValue) {
var currentVal = this.input.val();
var validValue = false;
for (var i=0;i<opt.options.length;i++) {
op = opt.options[i];
if (typeof op === "string" && op === currentVal) {
that._updateOptionSelectLabel({value:currentVal});
validValue = true;
break;
} else if (op.value === currentVal) {
that._updateOptionSelectLabel(op);
validValue = true;
break;
}
} else if (op.value === currentVal) {
this.optionSelectLabel.text(op.label||op.value);
validValue = true;
break;
}
}
if (!validValue) {
op = opt.options[0];
if (typeof op === "string") {
this.value(op);
if (!validValue) {
op = opt.options[0];
if (typeof op === "string") {
this.value(op);
that._updateOptionSelectLabel({value:op});
} else {
this.value(op.value);
that._updateOptionSelectLabel(op);
}
}
} else {
var selectedOption = this.optionValue||opt.options[0];
if (opt.parse) {
var parts = opt.parse(this.input.val());
if (parts.option) {
selectedOption = parts.option;
if (!this.activeOptions.hasOwnProperty(selectedOption)) {
parts.option = Object.keys(this.activeOptions)[0];
selectedOption = parts.option
}
}
this.input.val(parts.value);
if (opt.export) {
this.element.val(opt.export(parts.value,parts.option||selectedOption));
}
}
if (typeof selectedOption === "string") {
this.optionValue = selectedOption;
if (!this.activeOptions.hasOwnProperty(selectedOption)) {
selectedOption = Object.keys(this.activeOptions)[0];
}
if (!selectedOption) {
this.optionSelectTrigger.hide();
} else {
this._updateOptionSelectLabel(this.activeOptions[selectedOption]);
}
} else if (selectedOption) {
this.optionValue = selectedOption.value;
this._updateOptionSelectLabel(selectedOption);
} else {
this.value(op.value);
this.optionSelectTrigger.hide();
}
}
console.log(validValue);
}
} else {
if (this.optionMenu) {
@@ -448,27 +627,29 @@
this.optionSelectTrigger.hide();
}
if (opt.hasValue === false) {
this.oldValue = this.element.val();
this.element.val("");
this.oldValue = this.input.val();
this.input.val("");
this.elementDiv.hide();
} else {
if (this.oldValue !== undefined) {
this.element.val(this.oldValue);
this.input.val(this.oldValue);
delete this.oldValue;
}
this.elementDiv.show();
}
if (opt.expand && typeof opt.expand === 'function') {
this.optionExpandButton.show();
this.optionExpandButton.off('click');
this.optionExpandButton.on('click',function(evt) {
evt.preventDefault();
opt.expand.call(that);
})
} else {
this.optionExpandButton.hide();
if (this.optionExpandButton) {
if (opt.expand && typeof opt.expand === 'function') {
this.optionExpandButton.show();
this.optionExpandButton.off('click');
this.optionExpandButton.on('click',function(evt) {
evt.preventDefault();
opt.expand.call(that);
})
} else {
this.optionExpandButton.hide();
}
}
this.element.trigger('change',this.propertyType,this.value());
this.input.trigger('change',this.propertyType,this.value());
}
if (image) {
image.onload = function() { that._resize(); }

View File

@@ -408,9 +408,12 @@ RED.deploy = (function() {
delete confNode.credentials;
}
});
RED.nodes.eachSubflow(function(subflow) {
subflow.changed = false;
});
RED.nodes.eachWorkspace(function(ws) {
ws.changed = false;
})
});
// Once deployed, cannot undo back to a clean state
RED.history.markAllDirty();
RED.view.redraw();

View File

@@ -9,29 +9,30 @@ RED.diff = (function() {
// RED.actions.add("core:show-current-diff",showLocalDiff);
RED.actions.add("core:show-remote-diff",showRemoteDiff);
// RED.keyboard.add("*","ctrl-shift-l","core:show-current-diff");
RED.keyboard.add("*","ctrl-shift-r","core:show-remote-diff");
// RED.keyboard.add("*","ctrl-shift-r","core:show-remote-diff");
RED.actions.add("core:show-test-flow-diff-1",function(){showTestFlowDiff(1)});
RED.keyboard.add("*","ctrl-shift-f 1","core:show-test-flow-diff-1");
RED.actions.add("core:show-test-flow-diff-2",function(){showTestFlowDiff(2)});
RED.keyboard.add("*","ctrl-shift-f 2","core:show-test-flow-diff-2");
RED.actions.add("core:show-test-flow-diff-3",function(){showTestFlowDiff(3)});
RED.keyboard.add("*","ctrl-shift-f 3","core:show-test-flow-diff-3");
// RED.actions.add("core:show-test-flow-diff-1",function(){showTestFlowDiff(1)});
// RED.keyboard.add("*","ctrl-shift-f 1","core:show-test-flow-diff-1");
//
// RED.actions.add("core:show-test-flow-diff-2",function(){showTestFlowDiff(2)});
// RED.keyboard.add("*","ctrl-shift-f 2","core:show-test-flow-diff-2");
// RED.actions.add("core:show-test-flow-diff-3",function(){showTestFlowDiff(3)});
// RED.keyboard.add("*","ctrl-shift-f 3","core:show-test-flow-diff-3");
}
function createDiffTable(container) {
function createDiffTable(container,CurrentDiff) {
var diffList = $('<ol class="node-dialog-view-diff-diff"></ol>').appendTo(container);
diffList.editableList({
addButton: false,
height: "auto",
scrollOnAdd: false,
addItem: function(container,i,object) {
var localDiff = object.diff;
var remoteDiff = object.remoteDiff;
var tab = object.tab.n;
var def = object.def;
var conflicts = currentDiff.conflicts;
var conflicts = CurrentDiff.conflicts;
var tabDiv = $('<div>',{class:"node-diff-tab"}).appendTo(container);
tabDiv.addClass('collapsed');
@@ -50,11 +51,11 @@ RED.diff = (function() {
var tabForLabel = (object.newTab || object.tab).n;
var titleSpan = $('<span>',{class:"node-diff-tab-title-meta"}).appendTo(originalCell);
if (tabForLabel.type === 'tab') {
titleSpan.html(tabForLabel.label||tabForLabel.id);
titleSpan.text(tabForLabel.label||tabForLabel.id);
} else if (tab.type === 'subflow') {
titleSpan.html((tabForLabel.name||tabForLabel.id));
titleSpan.text((tabForLabel.name||tabForLabel.id));
} else {
titleSpan.html(RED._("diff.globalNodes"));
titleSpan.text(RED._("diff.globalNodes"));
}
var flowStats = {
local: {
@@ -130,7 +131,7 @@ RED.diff = (function() {
}
}
$('<span class="node-diff-chevron"><i class="fa fa-angle-down"></i></span>').appendTo(originalNodeDiv);
$('<span>').html(RED._("diff.flowProperties")).appendTo(originalNodeDiv);
$('<span>').text(RED._("diff.flowProperties")).appendTo(originalNodeDiv);
row.click(function(evt) {
evt.preventDefault();
@@ -150,10 +151,10 @@ RED.diff = (function() {
}
div.addClass("node-diff-node-entry-conflict");
} else {
selectState = currentDiff.resolutions[tab.id];
selectState = CurrentDiff.resolutions[tab.id];
}
// Tab properties row
createNodeConflictRadioBoxes(tab,div,localNodeDiv,remoteNodeDiv,true,!conflicts[tab.id],selectState);
createNodeConflictRadioBoxes(tab,div,localNodeDiv,remoteNodeDiv,true,!conflicts[tab.id],selectState,CurrentDiff);
}
}
// var stats = $('<span>',{class:"node-diff-tab-stats"}).appendTo(titleRow);
@@ -162,14 +163,14 @@ RED.diff = (function() {
var seen = {};
object.tab.nodes.forEach(function(node) {
seen[node.id] = true;
createNodeDiffRow(node,flowStats).appendTo(nodesDiv)
createNodeDiffRow(node,flowStats,CurrentDiff).appendTo(nodesDiv)
});
if (object.newTab) {
localNodeCount = object.newTab.nodes.length;
object.newTab.nodes.forEach(function(node) {
if (!seen[node.id]) {
seen[node.id] = true;
createNodeDiffRow(node,flowStats).appendTo(nodesDiv)
createNodeDiffRow(node,flowStats,CurrentDiff).appendTo(nodesDiv)
}
});
}
@@ -177,7 +178,7 @@ RED.diff = (function() {
remoteNodeCount = object.remoteTab.nodes.length;
object.remoteTab.nodes.forEach(function(node) {
if (!seen[node.id]) {
createNodeDiffRow(node,flowStats).appendTo(nodesDiv)
createNodeDiffRow(node,flowStats,CurrentDiff).appendTo(nodesDiv)
}
});
}
@@ -205,7 +206,7 @@ RED.diff = (function() {
}
}
var localStats = $('<span>',{class:"node-diff-tab-stats"}).appendTo(localCell);
$('<span class="node-diff-status"></span>').html(RED._('diff.nodeCount',{count:localNodeCount})).appendTo(localStats);
$('<span class="node-diff-status"></span>').text(RED._('diff.nodeCount',{count:localNodeCount})).appendTo(localStats);
if (flowStats.conflicts + flowStats.local.addedCount + flowStats.local.changedCount + flowStats.local.deletedCount > 0) {
$('<span class="node-diff-status"> [ </span>').appendTo(localStats);
@@ -244,7 +245,7 @@ RED.diff = (function() {
}
}
var remoteStats = $('<span>',{class:"node-diff-tab-stats"}).appendTo(remoteCell);
$('<span class="node-diff-status"></span>').html(RED._('diff.nodeCount',{count:remoteNodeCount})).appendTo(remoteStats);
$('<span class="node-diff-status"></span>').text(RED._('diff.nodeCount',{count:remoteNodeCount})).appendTo(remoteStats);
if (flowStats.conflicts + flowStats.remote.addedCount + flowStats.remote.changedCount + flowStats.remote.deletedCount > 0) {
$('<span class="node-diff-status"> [ </span>').appendTo(remoteStats);
if (flowStats.conflicts > 0) {
@@ -269,12 +270,12 @@ RED.diff = (function() {
if (flowStats.conflicts > 0) {
titleRow.addClass("node-diff-node-entry-conflict");
} else {
selectState = currentDiff.resolutions[tab.id];
selectState = CurrentDiff.resolutions[tab.id];
}
if (tab.id) {
var hide = !(flowStats.conflicts > 0 &&(localDiff.deleted[tab.id] || remoteDiff.deleted[tab.id]));
// Tab parent row
createNodeConflictRadioBoxes(tab,titleRow,localCell,remoteCell, false, hide, selectState);
createNodeConflictRadioBoxes(tab,titleRow,localCell,remoteCell, false, hide, selectState, CurrentDiff);
}
}
@@ -291,11 +292,8 @@ RED.diff = (function() {
var diffHeaders = $('<div class="node-dialog-view-diff-headers"></div>').appendTo(diffPanel);
if (options.mode === "merge") {
diffPanel.addClass("node-dialog-view-diff-panel-merge");
var toolbar = $('<div class="node-diff-toolbar">'+
'<span><span id="node-diff-toolbar-resolved-conflicts"></span></span> '+
'</div>').prependTo(diffPanel);
}
var diffList = createDiffTable(diffPanel);
var diffList = createDiffTable(diffPanel, diff);
var localDiff = diff.localDiff;
var remoteDiff = diff.remoteDiff;
@@ -466,7 +464,7 @@ RED.diff = (function() {
wires.forEach(function(p,i) {
var port = $("<li>").appendTo(list);
if (p && p.length > 0) {
$("<span>").html(i+1).appendTo(port);
$("<span>").text(i+1).appendTo(port);
var links = $("<ul>").appendTo(port);
p.forEach(function(d) {
c++;
@@ -476,15 +474,15 @@ RED.diff = (function() {
var def = RED.nodes.getType(node.type)||{};
createNode(node,def).appendTo(entry);
} else {
entry.html(d);
entry.text(d);
}
})
} else {
port.html('none');
port.text('none');
}
})
if (c === 0) {
result.html("none");
result.text("none");
} else {
list.appendTo(result);
}
@@ -492,7 +490,7 @@ RED.diff = (function() {
}
function createNodeIcon(node,def) {
var nodeDiv = $("<div>",{class:"node-diff-node-entry-node"});
var colour = def.color;
var colour = RED.utils.getNodeColor(node.type,def);
var icon_url = RED.utils.getNodeIcon(def,node);
if (node.type === 'tab') {
colour = "#C0DEED";
@@ -509,13 +507,13 @@ RED.diff = (function() {
createNodeIcon(node,def).appendTo(nodeTitleDiv);
var contentDiv = $('<div>',{class:"node-diff-node-description"}).appendTo(nodeTitleDiv);
var nodeLabel = node.label || node.name || node.id;
$('<span>',{class:"node-diff-node-label"}).html(nodeLabel).appendTo(contentDiv);
$('<span>',{class:"node-diff-node-label"}).text(nodeLabel).appendTo(contentDiv);
return nodeTitleDiv;
}
function createNodeDiffRow(node,stats) {
var localDiff = currentDiff.localDiff;
var remoteDiff = currentDiff.remoteDiff;
var conflicted = currentDiff.conflicts[node.id];
function createNodeDiffRow(node,stats,CurrentDiff) {
var localDiff = CurrentDiff.localDiff;
var remoteDiff = CurrentDiff.remoteDiff;
var conflicted = CurrentDiff.conflicts[node.id];
var hasChanges = false; // exists in original and local/remote but with changes
var unChanged = true; // existing in original,local,remote unchanged
@@ -703,10 +701,10 @@ RED.diff = (function() {
}
div.addClass("node-diff-node-entry-conflict");
} else {
selectState = currentDiff.resolutions[node.id];
selectState = CurrentDiff.resolutions[node.id];
}
// Node row
createNodeConflictRadioBoxes(node,div,localNodeDiv,remoteNodeDiv,false,!conflicted,selectState);
createNodeConflictRadioBoxes(node,div,localNodeDiv,remoteNodeDiv,false,!conflicted,selectState,CurrentDiff);
row.click(function(evt) {
$(this).parent().toggleClass('collapsed');
});
@@ -741,7 +739,7 @@ RED.diff = (function() {
var status;
row = $("<tr>").appendTo(nodePropertiesTableBody);
$("<td>",{class:"node-diff-property-cell-label"}).html("id").appendTo(row);
$("<td>",{class:"node-diff-property-cell-label"}).text("id").appendTo(row);
localCell = $("<td>",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row);
if (localNode) {
localCell.addClass("node-diff-node-unchanged");
@@ -784,7 +782,7 @@ RED.diff = (function() {
conflict = true;
}
row = $("<tr>").appendTo(nodePropertiesTableBody);
$("<td>",{class:"node-diff-property-cell-label"}).html("position").appendTo(row);
$("<td>",{class:"node-diff-property-cell-label"}).text("position").appendTo(row);
localCell = $("<td>",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row);
if (localNode) {
localCell.addClass("node-diff-node-"+(localChanged?"changed":"unchanged"));
@@ -852,7 +850,7 @@ RED.diff = (function() {
conflict = true;
}
row = $("<tr>").appendTo(nodePropertiesTableBody);
$("<td>",{class:"node-diff-property-cell-label"}).html("wires").appendTo(row);
$("<td>",{class:"node-diff-property-cell-label"}).text("wires").appendTo(row);
localCell = $("<td>",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row);
if (localNode) {
if (!conflict) {
@@ -883,7 +881,6 @@ RED.diff = (function() {
}
}
}
var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))});
if (def.defaults) {
properties = properties.concat(Object.keys(def.defaults));
@@ -891,6 +888,13 @@ RED.diff = (function() {
if (node.type !== 'tab') {
properties = properties.concat(['inputLabels','outputLabels']);
}
if ( ((localNode && localNode.hasOwnProperty('icon')) || (remoteNode && remoteNode.hasOwnProperty('icon'))) &&
properties.indexOf('icon') === -1
) {
properties.unshift('icon');
}
properties.forEach(function(d) {
localChanged = false;
remoteChanged = false;
@@ -919,7 +923,7 @@ RED.diff = (function() {
}
row = $("<tr>").appendTo(nodePropertiesTableBody);
var propertyNameCell = $("<td>",{class:"node-diff-property-cell-label"}).html(d).appendTo(row);
var propertyNameCell = $("<td>",{class:"node-diff-property-cell-label"}).text(d).appendTo(row);
localCell = $("<td>",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row);
if (localNode) {
if (!conflict) {
@@ -982,7 +986,7 @@ RED.diff = (function() {
});
return nodePropertiesDiv;
}
function createNodeConflictRadioBoxes(node,row,localDiv,remoteDiv,propertiesTable,hide,state) {
function createNodeConflictRadioBoxes(node,row,localDiv,remoteDiv,propertiesTable,hide,state,diff) {
var safeNodeId = "node-diff-selectbox-"+node.id.replace(/\./g,'-')+(propertiesTable?"-props":"");
var className = "";
if (node.z||propertiesTable) {
@@ -1019,7 +1023,7 @@ RED.diff = (function() {
row.addClass("node-diff-select-remote");
row.removeClass("node-diff-select-local");
}
refreshConflictHeader();
refreshConflictHeader(diff);
}
var localSelectDiv = $('<label>',{class:"node-diff-selectbox",for:safeNodeId+"-local"}).click(function(e) { e.stopPropagation();}).appendTo(localDiv);
@@ -1037,7 +1041,7 @@ RED.diff = (function() {
}
}
function refreshConflictHeader() {
function refreshConflictHeader(currentDiff) {
var resolutionCount = 0;
$(".node-diff-selectbox>input:checked").each(function() {
if (currentDiff.conflicts[$(this).data('node-id')]) {
@@ -1053,6 +1057,7 @@ RED.diff = (function() {
}
if (conflictCount === resolutionCount) {
$("#node-diff-view-diff-merge").removeClass('disabled');
$("#node-diff-view-resolve-diff").removeClass('disabled');
}
}
function getRemoteDiff(callback) {
@@ -1231,10 +1236,10 @@ RED.diff = (function() {
var localDiff = diff.localDiff;
var remoteDiff = diff.remoteDiff;
var conflicts = diff.conflicts;
currentDiff = diff;
// currentDiff = diff;
var trayOptions = {
title: options.title||"Review Changes", //TODO: nls
title: options.title||RED._("diff.reviewChanges"),
width: Infinity,
overlay: true,
buttons: [
@@ -1250,7 +1255,11 @@ RED.diff = (function() {
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var diffTable = buildDiffPanel(trayBody,diff,options);
var toolbar = $('<div class="node-diff-toolbar">'+
'<span><span id="node-diff-toolbar-resolved-conflicts"></span></span> '+
'</div>').prependTo(trayBody);
var diffContainer = $('<div class="node-diff-container"></div>').appendTo(trayBody);
var diffTable = buildDiffPanel(diffContainer,diff,options);
diffTable.list.hide();
if (remoteDiff) {
$("#node-diff-view-diff-merge").show();
@@ -1262,7 +1271,7 @@ RED.diff = (function() {
} else {
$("#node-diff-view-diff-merge").hide();
}
refreshConflictHeader();
refreshConflictHeader(diff);
// console.log("--------------");
// console.log(localDiff);
// console.log(remoteDiff);
@@ -1290,8 +1299,8 @@ RED.diff = (function() {
class: "primary disabled",
click: function() {
if (!$("#node-diff-view-diff-merge").hasClass('disabled')) {
refreshConflictHeader();
mergeDiff(currentDiff);
refreshConflictHeader(diff);
mergeDiff(diff);
RED.tray.close();
}
}
@@ -1302,7 +1311,7 @@ RED.diff = (function() {
RED.tray.show(trayOptions);
}
function mergeDiff(diff) {
function applyDiff(diff) {
var currentConfig = diff.localDiff.currentConfig;
var localDiff = diff.localDiff;
var remoteDiff = diff.remoteDiff;
@@ -1356,6 +1365,20 @@ RED.diff = (function() {
}
}
}
return {
config: newConfig,
nodeChangedStates: nodeChangedStates,
localChangedStates: localChangedStates
}
}
function mergeDiff(diff) {
var appliedDiff = applyDiff(diff);
var newConfig = appliedDiff.config;
var nodeChangedStates = appliedDiff.nodeChangedStates;
var localChangedStates = appliedDiff.localChangedStates;
var historyEvent = {
t:"replace",
config: RED.nodes.createCompleteNodeSet(),
@@ -1374,7 +1397,7 @@ RED.diff = (function() {
}
})
RED.nodes.version(remoteDiff.rev);
RED.nodes.version(diff.remoteDiff.rev);
RED.view.redraw(true);
RED.palette.refresh();
@@ -1399,7 +1422,7 @@ RED.diff = (function() {
function showTextDiff(textA,textB) {
var trayOptions = {
title: "Compare Changes", //TODO: nls
title: RED._("diff.compareChanges"),
width: Infinity,
overlay: true,
buttons: [
@@ -1417,7 +1440,7 @@ RED.diff = (function() {
var trayBody = tray.find('.editor-tray-body');
var diffPanel = $('<div class="node-text-diff"></div>').appendTo(trayBody);
var codeTable = $("<table>").appendTo(diffPanel);
var codeTable = $("<table>",{class:"node-text-diff-content"}).appendTo(diffPanel);
$('<colgroup><col width="50"><col width="50%"><col width="50"><col width="50%"></colgroup>').appendTo(codeTable);
var codeBody = $('<tbody>').appendTo(codeTable);
var diffSummary = diffText(textA||"",textB||"");
@@ -1681,7 +1704,7 @@ RED.diff = (function() {
files.forEach(function(file) {
var hunks = file.hunks;
var isBinary = file.binary;
var codeTable = $("<table>").appendTo(diffPanel);
var codeTable = $("<table>",{class:"node-text-diff-content"}).appendTo(diffPanel);
$('<colgroup><col width="50"><col width="50"><col width="100%"></colgroup>').appendTo(codeTable);
var codeBody = $('<tbody>').appendTo(codeTable);
@@ -1700,56 +1723,92 @@ RED.diff = (function() {
var unresolvedConflicts = 0;
var resolvedConflicts = 0;
var conflictResolutions = {};
if (commitOptions.project.files && commitOptions.project.files.flow === file.file) {
if (commitOptions.unmerged) {
$('<span style="float: right;"><span id="node-diff-toolbar-resolved-conflicts"></span></span>').appendTo(content);
}
var diffRow = $('<tr class="node-text-diff-header">').appendTo(codeBody);
var flowDiffContent = $('<td class="flow-diff" colspan="3"></td>').appendTo(diffRow);
if (!commitOptions.unmerged && commitOptions.project.files && commitOptions.project.files.flow === file.file) {
var tools = $('<span style="float: right;" class="button-group"></span>').appendTo(content);
$('<button class="editor-button editor-button-small">show flow diff</button>').appendTo(tools).click(function(e) {
e.preventDefault();
e.stopPropagation();
var projectName = commitOptions.project.name;
var filename = commitOptions.project.files.flow;
var oldVersionUrl = "/projects/"+projectName+"/files/"+commitOptions.oldRev+"/"+filename;
var newVersionUrl = "/projects/"+projectName+"/files/"+commitOptions.newRev+"/"+filename;
$.when($.getJSON(oldVersionUrl),$.getJSON(newVersionUrl)).done(function(oldVersion,newVersion) {
var oldFlow;
var newFlow;
var projectName = commitOptions.project.name;
var filename = commitOptions.project.files.flow;
var commonVersionUrl = "projects/"+projectName+"/files/"+commitOptions.commonRev+"/"+filename;
var oldVersionUrl = "projects/"+projectName+"/files/"+commitOptions.oldRev+"/"+filename;
var newVersionUrl = "projects/"+projectName+"/files/"+commitOptions.newRev+"/"+filename;
var promises = [$.Deferred(),$.Deferred(),$.Deferred()];
if (commitOptions.commonRev) {
var commonVersionUrl = "projects/"+projectName+"/files/"+commitOptions.commonRev+"/"+filename;
$.ajax({dataType: "json",url: commonVersionUrl}).then(function(data) { promises[0].resolve(data); }).fail(function() { promises[0].resolve(null);})
} else {
promises[0].resolve(null);
}
$.ajax({dataType: "json",url: oldVersionUrl}).then(function(data) { promises[1].resolve(data); }).fail(function() { promises[1].resolve({content:"[]"});})
$.ajax({dataType: "json",url: newVersionUrl}).then(function(data) { promises[2].resolve(data); }).fail(function() { promises[2].resolve({content:"[]"});})
$.when.apply($,promises).always(function(commonVersion, oldVersion,newVersion) {
var commonFlow;
var oldFlow;
var newFlow;
if (commonVersion) {
try {
oldFlow = JSON.parse(oldVersion[0].content||"[]");
commonFlow = JSON.parse(commonVersion.content||"[]");
} catch(err) {
console.log("Old Version doesn't contain valid JSON:",oldVersionUrl);
console.log(RED._("diff.commonVersionError"),commonVersionUrl);
console.log(err);
return;
}
try {
newFlow = JSON.parse(newVersion[0].content||"[]");
} catch(err) {
console.log("New Version doesn't contain valid JSON:",newFlow);
console.log(err);
return;
}
var localDiff = generateDiff(oldFlow,oldFlow);
var remoteDiff = generateDiff(oldFlow,newFlow);
var diff = resolveDiffs(localDiff,remoteDiff);
showDiff(diff,{
title: filename,
mode: 'view',
oldRevTitle: commitOptions.oldRevTitle,
newRevTitle: commitOptions.newRevTitle
});
// var flowDiffRow = $("<tr>").insertAfter(diffRow);
// var content = $('<td colspan="3"></td>').appendTo(flowDiffRow);
// currentDiff = diff;
// var diffTable = buildDiffPanel(content,diff,{mode:"view"}).finish();
}
try {
oldFlow = JSON.parse(oldVersion.content||"[]");
} catch(err) {
console.log(RED._("diff.oldVersionError"),oldVersionUrl);
console.log(err);
return;
}
if (!commonFlow) {
commonFlow = oldFlow;
}
try {
newFlow = JSON.parse(newVersion.content||"[]");
} catch(err) {
console.log(RED._("diff.newVersionError"),newFlow);
console.log(err);
return;
}
var localDiff = generateDiff(commonFlow,oldFlow);
var remoteDiff = generateDiff(commonFlow,newFlow);
commitOptions.currentDiff = resolveDiffs(localDiff,remoteDiff);
var diffTable = buildDiffPanel(flowDiffContent,commitOptions.currentDiff,{
title: filename,
mode: commitOptions.commonRev?'merge':'view',
oldRevTitle: commitOptions.oldRevTitle,
newRevTitle: commitOptions.newRevTitle
});
})
}
diffTable.list.hide();
refreshConflictHeader(commitOptions.currentDiff);
setTimeout(function() {
diffTable.finish();
diffTable.list.show();
},300);
// var flowDiffRow = $("<tr>").insertAfter(diffRow);
// var content = $('<td colspan="3"></td>').appendTo(flowDiffRow);
// currentDiff = diff;
// var diffTable = buildDiffPanel(content,diff,{mode:"view"}).finish();
});
} else
if (isBinary) {
var diffBinaryRow = $('<tr class="node-text-diff-header">').appendTo(codeBody);
var binaryContent = $('<td colspan="3"></td>').appendTo(diffBinaryRow);
$('<span></span>').text("Cannot show binary file contents").appendTo(binaryContent);
$('<span></span>').text(RED._("diff.noBinaryFileShowed")).appendTo(binaryContent);
} else {
if (commitOptions.unmerged) {
conflictHeader = $('<span style="float: right;">'+RED._("diff.conflictHeader",{resolved:resolvedConflicts, unresolved:unresolvedConflicts})+'</span>').appendTo(content);
}
hunks.forEach(function(hunk) {
var diffRow = $('<tr class="node-text-diff-header">').appendTo(codeBody);
var content = $('<td colspan="3"></td>').appendTo(diffRow);
@@ -1768,7 +1827,7 @@ RED.diff = (function() {
// }
var actualLineNumber = hunk.diffStart + lineNumber;
var isMergeHeader = isConflict && /^..(<<<<<<<|=======$|>>>>>>>)/.test(lineText);
var isMergeHeader = isConflict && /^\+\+(<<<<<<<|=======$|>>>>>>>)/.test(lineText);
var diffRow = $('<tr>').appendTo(codeBody);
var localLineNo = $('<td class="lineno">').appendTo(diffRow);
var remoteLineNo;
@@ -1827,7 +1886,7 @@ RED.diff = (function() {
$('<span>').text(lineText.substring(prefixEnd)).appendTo(line);
} else {
diffRow.addClass("mergeHeader");
var isSeparator = /^..(=======$)/.test(lineText);
var isSeparator = /^\+\+=======$/.test(lineText);
if (!isSeparator) {
var isOurs = /^..<<<<<<</.test(lineText);
if (isOurs) {
@@ -1861,7 +1920,7 @@ RED.diff = (function() {
diffRow.remove();
addedRows.find(".linetext").addClass('added');
conflictHeader.empty();
$('<span><span>'+resolvedConflicts+'</span> of <span>'+unresolvedConflicts+'</span> conflicts resolved</span>').appendTo(conflictHeader);
$('<span>'+RED._("diff.conflictHeader",{resolved:resolvedConflicts, unresolved:unresolvedConflicts})+'</span>').appendTo(conflictHeader);
conflictResolutions[file.file] = conflictResolutions[file.file] || {};
conflictResolutions[file.file][hunk.localChangeStart] = {
@@ -1886,9 +1945,6 @@ RED.diff = (function() {
});
});
}
if (commitOptions.unmerged) {
conflictHeader = $('<span style="float: right;"><span>'+resolvedConflicts+'</span> of <span>'+unresolvedConflicts+'</span> conflicts resolved</span>').appendTo(content);
}
});
return diffPanel;
}
@@ -1896,7 +1952,7 @@ RED.diff = (function() {
function showCommitDiff(options) {
var commit = parseCommitDiff(options.commit);
var trayOptions = {
title: "View Commit Changes", //TODO: nls
title: RED._("diff.viewCommitDiff"),
width: Infinity,
overlay: true,
buttons: [
@@ -1914,7 +1970,7 @@ RED.diff = (function() {
var trayBody = tray.find('.editor-tray-body');
var diffPanel = $('<div class="node-text-diff"></div>').appendTo(trayBody);
var codeTable = $("<table>").appendTo(diffPanel);
var codeTable = $("<table>",{class:"node-text-diff-content"}).appendTo(diffPanel);
$('<colgroup><col width="50"><col width="50"><col width="100%"></colgroup>').appendTo(codeTable);
var codeBody = $('<tbody>').appendTo(codeTable);
@@ -1957,9 +2013,8 @@ RED.diff = (function() {
}
}
var trayOptions = {
title: title||"Compare Changes", //TODO: nls
title: title|| RED._("diff.compareChanges"),
width: Infinity,
overlay: true,
buttons: [
@@ -1992,10 +2047,19 @@ RED.diff = (function() {
trayOptions.buttons.push(
{
id: "node-diff-view-resolve-diff",
text: "Save conflict resolution",
text: RED._("diff.saveConflict"),
class: "primary disabled",
click: function() {
if (!$("#node-diff-view-resolve-diff").hasClass('disabled')) {
if (options.currentDiff) {
// This is a flow file. Need to apply the diff
// and generate the new flow.
var result = applyDiff(options.currentDiff);
currentResolution = {
resolutions:{}
};
currentResolution.resolutions[options.project.files.flow] = JSON.stringify(result.config,"",4);
}
if (options.onresolve) {
options.onresolve(currentResolution);
}
@@ -2047,7 +2111,7 @@ RED.diff = (function() {
} else {
lines = diff.split("\n");
}
var diffHeader = /^diff --git a\/(.*) b\/(.*)$/;
var diffHeader = /^diff (?:(?:--git a\/(.*) b\/(.*))|(?:--cc (.*)))$/;
var fileHeader = /^\+\+\+ b\/(.*)\t?/;
var binaryFile = /^Binary files /;
var hunkHeader = /^@@ -((\d+)(,(\d+))?) \+((\d+)(,(\d+))?) @@ ?(.*)$/;
@@ -2066,7 +2130,7 @@ RED.diff = (function() {
}
currentHunk = null;
currentFile = {
file: diffLine[1],
file: diffLine[1]||diffLine[3],
hunks: []
}
} else if (binaryFile.test(line)) {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,209 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.editor.types._buffer = (function() {
var template = '<script type="text/x-red" data-template-name="_buffer"><div id="node-input-buffer-panels"><div id="node-input-buffer-panel-str" class="red-ui-panel"><div class="form-row" style="margin-bottom: 3px; text-align: right;"><span class="node-input-buffer-type"><i class="fa fa-exclamation-circle"></i> <span id="node-input-buffer-type-string" data-i18n="bufferEditor.modeString"></span><span id="node-input-buffer-type-array" data-i18n="bufferEditor.modeArray"></span></span></div><div class="form-row node-text-editor-row"><div class="node-text-editor" id="node-input-buffer-str"></div></div></div><div id="node-input-buffer-panel-bin" class="red-ui-panel"><div class="form-row node-text-editor-row" style="margin-top: 10px"><div class="node-text-editor" id="node-input-buffer-bin"></div></div></div></div></script>';
function stringToUTF8Array(str) {
var data = [];
var i=0, l = str.length;
for (i=0; i<l; i++) {
var char = str.charCodeAt(i);
if (char < 0x80) {
data.push(char);
} else if (char < 0x800) {
data.push(0xc0 | (char >> 6));
data.push(0x80 | (char & 0x3f));
} else if (char < 0xd800 || char >= 0xe000) {
data.push(0xe0 | (char >> 12));
data.push(0x80 | ((char>>6) & 0x3f));
data.push(0x80 | (char & 0x3f));
} else {
i++;
char = 0x10000 + (((char & 0x3ff)<<10) | (str.charAt(i) & 0x3ff));
data.push(0xf0 | (char >>18));
data.push(0x80 | ((char>>12) & 0x3f));
data.push(0x80 | ((char>>6) & 0x3f));
data.push(0x80 | (char & 0x3f));
}
}
return data;
}
return {
init: function() {
$(template).appendTo(document.body);
},
show: function(options) {
var value = options.value;
var onComplete = options.complete;
var type = "_buffer"
RED.view.state(RED.state.EDITING);
var bufferStringEditor = [];
var bufferBinValue;
var panels;
var trayOptions = {
title: options.title,
width: "inherit",
buttons: [
{
id: "node-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
RED.tray.close();
}
},
{
id: "node-dialog-ok",
text: RED._("common.label.done"),
class: "primary",
click: function() {
onComplete(JSON.stringify(bufferBinValue));
RED.tray.close();
}
}
],
resize: function(dimensions) {
var height = $("#dialog-form").height();
if (panels) {
panels.resize(height);
}
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
bufferStringEditor = RED.editor.createEditor({
id: 'node-input-buffer-str',
value: "",
mode:"ace/mode/text"
});
bufferStringEditor.getSession().setValue(value||"",-1);
bufferBinEditor = RED.editor.createEditor({
id: 'node-input-buffer-bin',
value: "",
mode:"ace/mode/text",
readOnly: true
});
var changeTimer;
var buildBuffer = function(data) {
var valid = true;
var isString = typeof data === 'string';
var binBuffer = [];
if (isString) {
bufferBinValue = stringToUTF8Array(data);
} else {
bufferBinValue = data;
}
var i=0,l=bufferBinValue.length;
var c = 0;
for(i=0;i<l;i++) {
var d = parseInt(bufferBinValue[i]);
if (!isString && (isNaN(d) || d < 0 || d > 255)) {
valid = false;
break;
}
if (i>0) {
if (i%8 === 0) {
if (i%16 === 0) {
binBuffer.push("\n");
} else {
binBuffer.push(" ");
}
} else {
binBuffer.push(" ");
}
}
binBuffer.push((d<16?"0":"")+d.toString(16).toUpperCase());
}
if (valid) {
$("#node-input-buffer-type-string").toggle(isString);
$("#node-input-buffer-type-array").toggle(!isString);
bufferBinEditor.setValue(binBuffer.join(""),1);
}
return valid;
}
var bufferStringUpdate = function() {
var value = bufferStringEditor.getValue();
var isValidArray = false;
if (/^[\s]*\[[\s\S]*\][\s]*$/.test(value)) {
isValidArray = true;
try {
var data = JSON.parse(value);
isValidArray = buildBuffer(data);
} catch(err) {
isValidArray = false;
}
}
if (!isValidArray) {
buildBuffer(value);
}
}
bufferStringEditor.getSession().on('change', function() {
clearTimeout(changeTimer);
changeTimer = setTimeout(bufferStringUpdate,200);
});
bufferStringUpdate();
dialogForm.i18n();
panels = RED.panels.create({
id:"node-input-buffer-panels",
resize: function(p1Height,p2Height) {
var p1 = $("#node-input-buffer-panel-str");
p1Height -= $(p1.children()[0]).outerHeight(true);
var editorRow = $(p1.children()[1]);
p1Height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-buffer-str").css("height",(p1Height-5)+"px");
bufferStringEditor.resize();
var p2 = $("#node-input-buffer-panel-bin");
editorRow = $(p2.children()[0]);
p2Height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-buffer-bin").css("height",(p2Height-5)+"px");
bufferBinEditor.resize();
}
});
$(".node-input-buffer-type").click(function(e) {
e.preventDefault();
RED.sidebar.info.set(RED._("bufferEditor.modeDesc"));
RED.sidebar.info.show();
})
},
close: function() {
if (options.onclose) {
options.onclose();
}
bufferStringEditor.destroy();
bufferBinEditor.destroy();
},
show: function() {}
}
RED.tray.show(trayOptions);
}
}
})();

View File

@@ -0,0 +1,325 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.editor.types._expression = (function() {
var template = '<script type="text/x-red" data-template-name="_expression"><div id="node-input-expression-panels"><div id="node-input-expression-panel-expr" class="red-ui-panel"><div class="form-row" style="margin-bottom: 3px; text-align: right;"><span class="node-input-expression-legacy"><i class="fa fa-exclamation-circle"></i> <span data-i18n="expressionEditor.compatMode"></span></span><button id="node-input-expression-reformat" class="editor-button editor-button-small"><span data-i18n="expressionEditor.format"></span></button></div><div class="form-row node-text-editor-row"><div class="node-text-editor" id="node-input-expression"></div></div></div><div id="node-input-expression-panel-info" class="red-ui-panel"><div class="form-row"><ul id="node-input-expression-tabs"></ul><div id="node-input-expression-tab-help" class="node-input-expression-tab-content hide"><div><select id="node-input-expression-func"></select><button id="node-input-expression-func-insert" class="editor-button" data-i18n="expressionEditor.insert"></button></div><div id="node-input-expression-help"></div></div><div id="node-input-expression-tab-test" class="node-input-expression-tab-content hide"><div><span style="display: inline-block; width: calc(50% - 5px);"><span data-i18n="expressionEditor.data"></span><button style="float: right; margin-right: 5px;" id="node-input-example-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button></span><span style="display: inline-block; width: calc(50% - 5px);" data-i18n="expressionEditor.result"></span></div><div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-data"></div><div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-result"></div></div></div></div></div></script>';
var expressionTestCache = {};
return {
init: function() {
$(template).appendTo(document.body);
},
show: function(options) {
var expressionTestCacheId = options.parent||"_";
var value = options.value;
var onComplete = options.complete;
var type = "_expression"
RED.view.state(RED.state.EDITING);
var expressionEditor;
var testDataEditor;
var testResultEditor
var panels;
var trayOptions = {
title: options.title,
width: "inherit",
buttons: [
{
id: "node-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
RED.tray.close();
}
},
{
id: "node-dialog-ok",
text: RED._("common.label.done"),
class: "primary",
click: function() {
$("#node-input-expression-help").text("");
onComplete(expressionEditor.getValue());
RED.tray.close();
}
}
],
resize: function(dimensions) {
var height = $("#dialog-form").height();
if (panels) {
panels.resize(height);
}
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
trayBody.addClass("node-input-expression-editor")
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form','_expression','editor');
var funcSelect = $("#node-input-expression-func");
Object.keys(jsonata.functions).forEach(function(f) {
funcSelect.append($("<option></option>").val(f).text(f));
})
funcSelect.change(function(e) {
var f = $(this).val();
var args = RED._('jsonata:'+f+".args",{defaultValue:''});
var title = "<h5>"+f+"("+args+")</h5>";
var body = marked(RED._('jsonata:'+f+'.desc',{defaultValue:''}));
$("#node-input-expression-help").html(title+"<p>"+body+"</p>");
})
expressionEditor = RED.editor.createEditor({
id: 'node-input-expression',
value: "",
mode:"ace/mode/jsonata",
options: {
enableBasicAutocompletion:true,
enableSnippets:true,
enableLiveAutocompletion: true
}
});
var currentToken = null;
var currentTokenPos = -1;
var currentFunctionMarker = null;
expressionEditor.getSession().setValue(value||"",-1);
expressionEditor.on("changeSelection", function() {
var c = expressionEditor.getCursorPosition();
var token = expressionEditor.getSession().getTokenAt(c.row,c.column);
if (token !== currentToken || (token && /paren/.test(token.type) && c.column !== currentTokenPos)) {
currentToken = token;
var r,p;
var scopedFunction = null;
if (token && token.type === 'keyword') {
r = c.row;
scopedFunction = token;
} else {
var depth = 0;
var next = false;
if (token) {
if (token.type === 'paren.rparen') {
// If this is a block of parens ')))', set
// depth to offset against the cursor position
// within the block
currentTokenPos = c.column;
depth = c.column - (token.start + token.value.length);
}
r = c.row;
p = token.index;
} else {
r = c.row-1;
p = -1;
}
while ( scopedFunction === null && r > -1) {
var rowTokens = expressionEditor.getSession().getTokens(r);
if (p === -1) {
p = rowTokens.length-1;
}
while (p > -1) {
var type = rowTokens[p].type;
if (next) {
if (type === 'keyword') {
scopedFunction = rowTokens[p];
// console.log("HIT",scopedFunction);
break;
}
next = false;
}
if (type === 'paren.lparen') {
depth-=rowTokens[p].value.length;
} else if (type === 'paren.rparen') {
depth+=rowTokens[p].value.length;
}
if (depth < 0) {
next = true;
depth = 0;
}
// console.log(r,p,depth,next,rowTokens[p]);
p--;
}
if (!scopedFunction) {
r--;
}
}
}
expressionEditor.session.removeMarker(currentFunctionMarker);
if (scopedFunction) {
//console.log(token,.map(function(t) { return t.type}));
funcSelect.val(scopedFunction.value).change();
}
}
});
dialogForm.i18n();
$("#node-input-expression-func-insert").click(function(e) {
e.preventDefault();
var pos = expressionEditor.getCursorPosition();
var f = funcSelect.val();
var snippet = jsonata.getFunctionSnippet(f);
expressionEditor.insertSnippet(snippet);
expressionEditor.focus();
});
$("#node-input-expression-reformat").click(function(evt) {
evt.preventDefault();
var v = expressionEditor.getValue()||"";
try {
v = jsonata.format(v);
} catch(err) {
// TODO: do an optimistic auto-format
}
expressionEditor.getSession().setValue(v||"",-1);
});
var tabs = RED.tabs.create({
element: $("#node-input-expression-tabs"),
onchange:function(tab) {
$(".node-input-expression-tab-content").hide();
tab.content.show();
trayOptions.resize();
}
})
tabs.addTab({
id: 'expression-help',
label: RED._('expressionEditor.functionReference'),
content: $("#node-input-expression-tab-help")
});
tabs.addTab({
id: 'expression-tests',
label: RED._('expressionEditor.test'),
content: $("#node-input-expression-tab-test")
});
testDataEditor = RED.editor.createEditor({
id: 'node-input-expression-test-data',
value: expressionTestCache[expressionTestCacheId] || '{\n "payload": "hello world"\n}',
mode:"ace/mode/json",
lineNumbers: false
});
var changeTimer;
$(".node-input-expression-legacy").click(function(e) {
e.preventDefault();
RED.sidebar.info.set(RED._("expressionEditor.compatModeDesc"));
RED.sidebar.info.show();
})
var testExpression = function() {
var value = testDataEditor.getValue();
var parsedData;
var currentExpression = expressionEditor.getValue();
var expr;
var usesContext = false;
var legacyMode = /(^|[^a-zA-Z0-9_'"])msg([^a-zA-Z0-9_'"]|$)/.test(currentExpression);
$(".node-input-expression-legacy").toggle(legacyMode);
try {
expr = jsonata(currentExpression);
expr.assign('flowContext',function(val) {
usesContext = true;
return null;
});
expr.assign('globalContext',function(val) {
usesContext = true;
return null;
});
} catch(err) {
testResultEditor.setValue(RED._("expressionEditor.errors.invalid-expr",{message:err.message}),-1);
return;
}
try {
parsedData = JSON.parse(value);
} catch(err) {
testResultEditor.setValue(RED._("expressionEditor.errors.invalid-msg",{message:err.toString()}))
return;
}
try {
var result = expr.evaluate(legacyMode?{msg:parsedData}:parsedData);
if (usesContext) {
testResultEditor.setValue(RED._("expressionEditor.errors.context-unsupported"),-1);
return;
}
var formattedResult;
if (result !== undefined) {
formattedResult = JSON.stringify(result,null,4);
} else {
formattedResult = RED._("expressionEditor.noMatch");
}
testResultEditor.setValue(formattedResult,-1);
} catch(err) {
testResultEditor.setValue(RED._("expressionEditor.errors.eval",{message:err.message}),-1);
}
}
testDataEditor.getSession().on('change', function() {
clearTimeout(changeTimer);
changeTimer = setTimeout(testExpression,200);
expressionTestCache[expressionTestCacheId] = testDataEditor.getValue();
});
expressionEditor.getSession().on('change', function() {
clearTimeout(changeTimer);
changeTimer = setTimeout(testExpression,200);
});
testResultEditor = RED.editor.createEditor({
id: 'node-input-expression-test-result',
value: "",
mode:"ace/mode/json",
lineNumbers: false,
readOnly: true
});
panels = RED.panels.create({
id:"node-input-expression-panels",
resize: function(p1Height,p2Height) {
var p1 = $("#node-input-expression-panel-expr");
p1Height -= $(p1.children()[0]).outerHeight(true);
var editorRow = $(p1.children()[1]);
p1Height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-expression").css("height",(p1Height-5)+"px");
expressionEditor.resize();
var p2 = $("#node-input-expression-panel-info > .form-row > div:first-child");
p2Height -= p2.outerHeight(true) + 20;
$(".node-input-expression-tab-content").height(p2Height);
$("#node-input-expression-test-data").css("height",(p2Height-5)+"px");
testDataEditor.resize();
$("#node-input-expression-test-result").css("height",(p2Height-5)+"px");
testResultEditor.resize();
}
});
$("#node-input-example-reformat").click(function(evt) {
evt.preventDefault();
var v = testDataEditor.getValue()||"";
try {
v = JSON.stringify(JSON.parse(v),null,4);
} catch(err) {
// TODO: do an optimistic auto-format
}
testDataEditor.getSession().setValue(v||"",-1);
});
testExpression();
},
close: function() {
if (options.onclose) {
options.onclose();
}
expressionEditor.destroy();
testDataEditor.destroy();
},
show: function() {}
}
RED.tray.show(trayOptions);
}
}
})();

102
editor/js/ui/editors/js.js Normal file
View File

@@ -0,0 +1,102 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.editor.types._js = (function() {
var template = '<script type="text/x-red" data-template-name="_js"><div class="form-row node-text-editor-row"><div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-js"></div></div></script>';
return {
init: function() {
$(template).appendTo(document.body);
},
show: function(options) {
var value = options.value;
var onComplete = options.complete;
var type = "_js"
RED.view.state(RED.state.EDITING);
var expressionEditor;
var changeTimer;
var trayOptions = {
title: options.title,
width: "inherit",
buttons: [
{
id: "node-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
RED.tray.close();
}
},
{
id: "node-dialog-ok",
text: RED._("common.label.done"),
class: "primary",
click: function() {
onComplete(expressionEditor.getValue(),expressionEditor.getCursorPosition());
RED.tray.close();
}
}
],
resize: function(dimensions) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var editorRow = $("#dialog-form>div.node-text-editor-row");
var height = $("#dialog-form").height();
for (var i=0;i<rows.size();i++) {
height -= $(rows[i]).outerHeight(true);
}
$(".node-text-editor").css("height",height+"px");
expressionEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
expressionEditor = RED.editor.createEditor({
id: 'node-input-js',
mode: 'ace/mode/javascript',
value: value,
globals: {
msg:true,
context:true,
RED: true,
util: true,
flow: true,
global: true,
console: true,
Buffer: true,
setTimeout: true,
clearTimeout: true,
setInterval: true,
clearInterval: true
}
});
if (options.cursor) {
expressionEditor.gotoLine(options.cursor.row+1,options.cursor.column,false);
}
dialogForm.i18n();
},
close: function() {
expressionEditor.destroy();
if (options.onclose) {
options.onclose();
}
},
show: function() {}
}
RED.tray.show(trayOptions);
}
}
})();

View File

@@ -0,0 +1,118 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.editor.types._json = (function() {
var template = '<script type="text/x-red" data-template-name="_json"><div class="form-row" style="margin-bottom: 3px; text-align: right;"><button id="node-input-json-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button></div><div class="form-row node-text-editor-row"><div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-json"></div></div></script>';
return {
init: function() {
$(template).appendTo(document.body);
},
show: function(options) {
var value = options.value;
var onComplete = options.complete;
var type = "_json"
RED.view.state(RED.state.EDITING);
var expressionEditor;
var changeTimer;
var checkValid = function() {
var v = expressionEditor.getValue();
try {
JSON.parse(v);
$("#node-dialog-ok").removeClass('disabled');
return true;
} catch(err) {
$("#node-dialog-ok").addClass('disabled');
return false;
}
}
var trayOptions = {
title: options.title,
width: "inherit",
buttons: [
{
id: "node-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
RED.tray.close();
}
},
{
id: "node-dialog-ok",
text: RED._("common.label.done"),
class: "primary",
click: function() {
if (options.requireValid && !checkValid()) {
return;
}
onComplete(expressionEditor.getValue());
RED.tray.close();
}
}
],
resize: function(dimensions) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var editorRow = $("#dialog-form>div.node-text-editor-row");
var height = $("#dialog-form").height();
for (var i=0;i<rows.size();i++) {
height -= $(rows[i]).outerHeight(true);
}
height -= (parseInt($("#dialog-form").css("marginTop"))+parseInt($("#dialog-form").css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
expressionEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
expressionEditor = RED.editor.createEditor({
id: 'node-input-json',
value: "",
mode:"ace/mode/json"
});
expressionEditor.getSession().setValue(value||"",-1);
if (options.requireValid) {
expressionEditor.getSession().on('change', function() {
clearTimeout(changeTimer);
changeTimer = setTimeout(checkValid,200);
});
checkValid();
}
$("#node-input-json-reformat").click(function(evt) {
evt.preventDefault();
var v = expressionEditor.getValue()||"";
try {
v = JSON.stringify(JSON.parse(v),null,4);
} catch(err) {
// TODO: do an optimistic auto-format
}
expressionEditor.getSession().setValue(v||"",-1);
});
dialogForm.i18n();
},
close: function() {
expressionEditor.destroy();
if (options.onclose) {
options.onclose();
}
},
show: function() {}
}
RED.tray.show(trayOptions);
}
}
})();

View File

@@ -0,0 +1,90 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.editor.types._markdown = (function() {
var template = '<script type="text/x-red" data-template-name="_markdown"><div class="form-row" id="node-input-markdown-title" style="margin-bottom: 3px; text-align: right;"></div><div class="form-row node-text-editor-row"><div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-markdown"></div></div></script>';
return {
init: function() {
$(template).appendTo(document.body);
},
show: function(options) {
var value = options.value;
var onComplete = options.complete;
var type = "_markdown"
RED.view.state(RED.state.EDITING);
var expressionEditor;
var trayOptions = {
title: options.title,
width: "inherit",
buttons: [
{
id: "node-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
RED.tray.close();
}
},
{
id: "node-dialog-ok",
text: RED._("common.label.done"),
class: "primary",
click: function() {
onComplete(expressionEditor.getValue());
RED.tray.close();
}
}
],
resize: function(dimensions) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var editorRow = $("#dialog-form>div.node-text-editor-row");
var height = $("#dialog-form").height();
for (var i=0;i<rows.size();i++) {
height -= $(rows[i]).outerHeight(true);
}
height -= (parseInt($("#dialog-form").css("marginTop"))+parseInt($("#dialog-form").css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
expressionEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
expressionEditor = RED.editor.createEditor({
id: 'node-input-markdown',
value: value,
mode:"ace/mode/markdown"
});
if (options.header) {
options.header.appendTo(tray.find('#node-input-markdown-title'));
}
dialogForm.i18n();
},
close: function() {
expressionEditor.destroy();
if (options.onclose) {
options.onclose();
}
},
show: function() {}
}
RED.tray.show(trayOptions);
}
}
})();

View File

@@ -389,6 +389,7 @@ RED.keyboard = (function() {
var currentEditorSettings = RED.settings.get('editor') || {};
var userKeymap = currentEditorSettings.keymap || {};
userKeymap[object.id] = null;
currentEditorSettings.keymap = userKeymap;
RED.settings.set('editor',currentEditorSettings);
var obj = {
@@ -442,6 +443,7 @@ RED.keyboard = (function() {
var currentEditorSettings = RED.settings.get('editor') || {};
var userKeymap = currentEditorSettings.keymap || {};
userKeymap[object.id] = RED.keyboard.getShortcut(object.id);
currentEditorSettings.keymap = userKeymap;
RED.settings.set('editor',currentEditorSettings);
}
}

View File

@@ -15,8 +15,8 @@
**/
RED.library = (function() {
var exportToLibraryDialog;
var elementPrefix = "node-input-";
function loadFlowLibrary() {
$.getJSON("library/flows",function(data) {
@@ -86,6 +86,7 @@ RED.library = (function() {
var libraryData = {};
var selectedLibraryItem = null;
var libraryEditor = null;
elementPrefix = options.elementPrefix || "node-input-";
// Orion editor has set/getText
// ACE editor has set/getValue
@@ -157,8 +158,8 @@ RED.library = (function() {
return ul;
}
$('#node-input-name').css("width","66%").after(
'<div class="btn-group" style="margin-left: 5px;">'+
$('#'+elementPrefix+"name").css("width","calc(100% - 52px)").after(
'<div class="btn-group" style="margin-left:5px;">'+
'<a id="node-input-'+options.type+'-lookup" class="editor-button" data-toggle="dropdown"><i class="fa fa-book"></i> <i class="fa fa-caret-down"></i></a>'+
'<ul class="dropdown-menu pull-right" role="menu">'+
'<li><a id="node-input-'+options.type+'-menu-open-library" tabindex="-1" href="#">'+RED._("library.openLibrary")+'</a></li>'+
@@ -187,7 +188,7 @@ RED.library = (function() {
$('#node-input-'+options.type+'-menu-save-library').click(function(e) {
//var found = false;
var name = $("#node-input-name").val().replace(/(^\s*)|(\s*$)/g,"");
var name = $("#"+elementPrefix+"name").val().replace(/(^\s*)|(\s*$)/g,"");
//var buildPathList = function(data,root) {
// var paths = [];
@@ -264,7 +265,7 @@ RED.library = (function() {
if (selectedLibraryItem) {
for (var i=0; i<options.fields.length; i++) {
var field = options.fields[i];
$("#node-input-"+field).val(selectedLibraryItem[field]);
$("#"+elementPrefix+field).val(selectedLibraryItem[field]);
}
options.editor.setValue(libraryEditor.getValue(),-1);
}
@@ -286,7 +287,7 @@ RED.library = (function() {
});
function saveToLibrary(overwrite) {
var name = $("#node-input-name").val().replace(/(^\s*)|(\s*$)/g,"");
var name = $("#"+elementPrefix+"name").val().replace(/(^\s*)|(\s*$)/g,"");
if (name === "") {
name = RED._("library.unnamedType",{type:options.type});
}
@@ -330,7 +331,7 @@ RED.library = (function() {
if (field == "name") {
data.name = name;
} else {
data[field] = $("#node-input-"+field).val();
data[field] = $("#"+elementPrefix+field).val();
}
}
@@ -413,12 +414,8 @@ RED.library = (function() {
RED.events.on("view:selection-changed",function(selection) {
if (!selection.nodes) {
RED.menu.setDisabled("menu-item-export",true);
RED.menu.setDisabled("menu-item-export-clipboard",true);
RED.menu.setDisabled("menu-item-export-library",true);
} else {
RED.menu.setDisabled("menu-item-export",false);
RED.menu.setDisabled("menu-item-export-clipboard",false);
RED.menu.setDisabled("menu-item-export-library",false);
}
});

View File

@@ -171,7 +171,7 @@ RED.notifications = (function() {
if (options.buttons) {
var buttonSet = $('<div style="margin-top: 20px;" class="ui-dialog-buttonset"></div>').appendTo(nn)
options.buttons.forEach(function(buttonDef) {
var b = $('<button>').html(buttonDef.text).click(buttonDef.click).appendTo(buttonSet);
var b = $('<button>').text(buttonDef.text).click(buttonDef.click).appendTo(buttonSet);
if (buttonDef.id) {
b.attr('id',buttonDef.id);
}

View File

@@ -208,6 +208,8 @@ RED.palette.editor = (function() {
if (nodeEntry) {
var activeTypeCount = 0;
var typeCount = 0;
var errorCount = 0;
nodeEntry.errorList.empty();
nodeEntries[module].totalUseCount = 0;
nodeEntries[module].setUseCount = {};
@@ -216,7 +218,10 @@ RED.palette.editor = (function() {
var inUseCount = 0;
var set = moduleInfo.sets[setName];
var setElements = nodeEntry.sets[setName];
if (set.err) {
errorCount++;
$("<li>").text(set.err).appendTo(nodeEntry.errorList);
}
if (set.enabled) {
activeTypeCount += set.types.length;
}
@@ -228,7 +233,7 @@ RED.palette.editor = (function() {
if (set.enabled) {
var def = RED.nodes.getType(t);
if (def && def.color) {
swatch.css({background:def.color});
swatch.css({background:RED.utils.getNodeColor(t,def)});
swatch.css({border: "1px solid "+getContrastingBorder(swatch.css('backgroundColor'))})
} else {
@@ -242,24 +247,31 @@ RED.palette.editor = (function() {
nodeEntries[module].totalUseCount += inUseCount;
if (inUseCount > 0) {
setElements.enableButton.html(RED._('palette.editor.inuse'));
setElements.enableButton.text(RED._('palette.editor.inuse'));
setElements.enableButton.addClass('disabled');
} else {
setElements.enableButton.removeClass('disabled');
if (set.enabled) {
setElements.enableButton.html(RED._('palette.editor.disable'));
setElements.enableButton.text(RED._('palette.editor.disable'));
} else {
setElements.enableButton.html(RED._('palette.editor.enable'));
setElements.enableButton.text(RED._('palette.editor.enable'));
}
}
setElements.setRow.toggleClass("palette-module-set-disabled",!set.enabled);
}
}
if (errorCount === 0) {
nodeEntry.errorRow.hide()
} else {
nodeEntry.errorRow.show();
}
var nodeCount = (activeTypeCount === typeCount)?typeCount:activeTypeCount+" / "+typeCount;
nodeEntry.setCount.html(RED._('palette.editor.nodeCount',{count:typeCount,label:nodeCount}));
nodeEntry.setCount.text(RED._('palette.editor.nodeCount',{count:typeCount,label:nodeCount}));
if (nodeEntries[module].totalUseCount > 0) {
nodeEntry.enableButton.html(RED._('palette.editor.inuse'));
nodeEntry.enableButton.text(RED._('palette.editor.inuse'));
nodeEntry.enableButton.addClass('disabled');
nodeEntry.removeButton.hide();
} else {
@@ -268,20 +280,20 @@ RED.palette.editor = (function() {
nodeEntry.removeButton.css('display', 'inline-block');
}
if (activeTypeCount === 0) {
nodeEntry.enableButton.html(RED._('palette.editor.enableall'));
nodeEntry.enableButton.text(RED._('palette.editor.enableall'));
} else {
nodeEntry.enableButton.html(RED._('palette.editor.disableall'));
nodeEntry.enableButton.text(RED._('palette.editor.disableall'));
}
nodeEntry.container.toggleClass("disabled",(activeTypeCount === 0));
}
}
if (moduleInfo.pending_version) {
nodeEntry.versionSpan.html(moduleInfo.version+' <i class="fa fa-long-arrow-right"></i> '+moduleInfo.pending_version).appendTo(nodeEntry.metaRow)
nodeEntry.updateButton.html(RED._('palette.editor.updated')).addClass('disabled').show();
nodeEntry.updateButton.text(RED._('palette.editor.updated')).addClass('disabled').show();
} else if (loadedIndex.hasOwnProperty(module)) {
if (semVerCompare(loadedIndex[module].version,moduleInfo.version) === 1) {
nodeEntry.updateButton.show();
nodeEntry.updateButton.html(RED._('palette.editor.update',{version:loadedIndex[module].version}));
nodeEntry.updateButton.text(RED._('palette.editor.update',{version:loadedIndex[module].version}));
} else {
nodeEntry.updateButton.hide();
}
@@ -355,7 +367,7 @@ RED.palette.editor = (function() {
loadedIndex = {};
packageList.editableList('empty');
$(".palette-module-shade-status").html(RED._('palette.editor.loading'));
$(".palette-module-shade-status").text(RED._('palette.editor.loading'));
var catalogues = RED.settings.theme('palette.catalogues')||['https://catalogue.nodered.org/catalogue.json'];
catalogueLoadStatus = [];
catalogueLoadErrors = false;
@@ -461,7 +473,7 @@ RED.palette.editor = (function() {
if (filteredList[i].info.id === ns.module) {
var installButton = filteredList[i].elements.installButton;
installButton.addClass('disabled');
installButton.html(RED._('palette.editor.installed'));
installButton.text(RED._('palette.editor.installed'));
break;
}
}
@@ -477,7 +489,7 @@ RED.palette.editor = (function() {
if (filteredList[i].info.id === ns.module) {
var installButton = filteredList[i].elements.installButton;
installButton.removeClass('disabled');
installButton.html(RED._('palette.editor.install'));
installButton.text(RED._('palette.editor.install'));
break;
}
}
@@ -583,15 +595,18 @@ RED.palette.editor = (function() {
if (entry) {
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
var titleRow = $('<div class="palette-module-meta palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
$('<span>').html(entry.name).appendTo(titleRow);
$('<span>').text(entry.name).appendTo(titleRow);
var metaRow = $('<div class="palette-module-meta palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
var versionSpan = $('<span>').html(entry.version).appendTo(metaRow);
var versionSpan = $('<span>').text(entry.version).appendTo(metaRow);
var errorRow = $('<div class="palette-module-meta palette-module-errors"><i class="fa fa-warning"></i></div>').hide().appendTo(headerRow);
var errorList = $('<ul class="palette-module-error-list"></ul>').appendTo(errorRow);
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
var setButton = $('<a href="#" class="editor-button editor-button-small palette-module-set-button"><i class="fa fa-angle-right palette-module-node-chevron"></i> </a>').appendTo(buttonRow);
var setCount = $('<span>').appendTo(setButton);
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
var updateButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.update')).appendTo(buttonGroup);
var updateButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.update')).appendTo(buttonGroup);
updateButton.attr('id','up_'+Math.floor(Math.random()*1000000000));
updateButton.click(function(evt) {
evt.preventDefault();
@@ -602,7 +617,7 @@ RED.palette.editor = (function() {
})
var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.remove')).appendTo(buttonGroup);
var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.remove')).appendTo(buttonGroup);
removeButton.attr('id','up_'+Math.floor(Math.random()*1000000000));
removeButton.click(function(evt) {
evt.preventDefault();
@@ -611,7 +626,7 @@ RED.palette.editor = (function() {
if (!entry.local) {
removeButton.hide();
}
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.disableall')).appendTo(buttonGroup);
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.disableall')).appendTo(buttonGroup);
var contentRow = $('<div>',{class:"palette-module-content"}).appendTo(container);
var shade = $('<div class="palette-module-shade hide"><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(container);
@@ -620,6 +635,8 @@ RED.palette.editor = (function() {
updateButton: updateButton,
removeButton: removeButton,
enableButton: enableButton,
errorRow: errorRow,
errorList: errorList,
setCount: setCount,
container: container,
shade: shade,
@@ -649,9 +666,8 @@ RED.palette.editor = (function() {
set.types.forEach(function(t) {
var typeDiv = $('<div>',{class:"palette-module-type"}).appendTo(setRow);
typeSwatches[t] = $('<span>',{class:"palette-module-type-swatch"}).appendTo(typeDiv);
$('<span>',{class:"palette-module-type-node"}).html(t).appendTo(typeDiv);
$('<span>',{class:"palette-module-type-node"}).text(t).appendTo(typeDiv);
})
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').appendTo(buttonGroup);
enableButton.click(function(evt) {
evt.preventDefault();
@@ -689,7 +705,7 @@ RED.palette.editor = (function() {
})
refreshNodeModule(entry.name);
} else {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
}
}
});
@@ -729,7 +745,7 @@ RED.palette.editor = (function() {
});
$('<span>').html(RED._("palette.editor.sort")+' ').appendTo(toolBar);
$('<span>').text(RED._("palette.editor.sort")+' ').appendTo(toolBar);
var sortGroup = $('<span class="button-group"></span>').appendTo(toolBar);
var sortAZ = $('<a href="#" class="sidebar-header-button-toggle selected" data-i18n="palette.editor.sortAZ"></a>').appendTo(sortGroup);
var sortRecent = $('<a href="#" class="sidebar-header-button-toggle" data-i18n="palette.editor.sortRecent"></a>').appendTo(sortGroup);
@@ -771,13 +787,13 @@ RED.palette.editor = (function() {
scrollOnAdd: false,
addItem: function(container,i,object) {
if (object.count) {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('palette.editor.moduleCount',{count:object.count})).appendTo(container);
$('<div>',{class:"red-ui-search-empty"}).text(RED._('palette.editor.moduleCount',{count:object.count})).appendTo(container);
return
}
if (object.more) {
container.addClass('palette-module-more');
var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container);
var moreLink = $('<a href="#"></a>').html(RED._('palette.editor.more',{count:object.more})).appendTo(moreRow);
var moreLink = $('<a href="#"></a>').text(RED._('palette.editor.more',{count:object.more})).appendTo(moreRow);
moreLink.click(function(e) {
e.preventDefault();
packageList.editableList('removeItem',object);
@@ -794,17 +810,17 @@ RED.palette.editor = (function() {
var entry = object.info;
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
var titleRow = $('<div class="palette-module-meta"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
$('<span>',{class:"palette-module-name"}).html(entry.name||entry.id).appendTo(titleRow);
$('<span>',{class:"palette-module-name"}).text(entry.name||entry.id).appendTo(titleRow);
$('<a target="_blank" class="palette-module-link"><i class="fa fa-external-link"></i></a>').attr('href',entry.url).appendTo(titleRow);
var descRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
$('<div>',{class:"palette-module-description"}).html(entry.description).appendTo(descRow);
$('<div>',{class:"palette-module-description"}).text(entry.description).appendTo(descRow);
var metaRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
$('<span class="palette-module-version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
$('<span class="palette-module-updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
var installButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.install')).appendTo(buttonGroup);
var installButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.install')).appendTo(buttonGroup);
installButton.click(function(e) {
e.preventDefault();
if (!$(this).hasClass('disabled')) {
@@ -813,14 +829,14 @@ RED.palette.editor = (function() {
})
if (nodeEntries.hasOwnProperty(entry.id)) {
installButton.addClass('disabled');
installButton.html(RED._('palette.editor.installed'));
installButton.text(RED._('palette.editor.installed'));
}
object.elements = {
installButton:installButton
}
} else {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
}
}
});

View File

@@ -21,7 +21,18 @@ RED.palette = (function() {
var categoryContainers = {};
function createCategoryContainer(category, label) {
function createCategory(originalCategory,rootCategory,category,ns) {
if ($("#palette-base-category-"+rootCategory).length === 0) {
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
}
$("#palette-container-"+rootCategory).show();
if ($("#palette-"+category).length === 0) {
$("#palette-base-category-"+rootCategory).append('<div id="palette-'+category+'"></div>');
}
}
function createCategoryContainer(originalCategory,category, labelId) {
var label = RED._(labelId, {defaultValue:category});
label = (label || category).replace(/_/g, " ");
var catDiv = $('<div id="palette-container-'+category+'" class="palette-category palette-close hide">'+
'<div id="palette-header-'+category+'" class="palette-header"><i class="expanded fa fa-angle-down"></i><span>'+label+'</span></div>'+
@@ -31,7 +42,8 @@ RED.palette = (function() {
'<div id="palette-'+category+'-function"></div>'+
'</div>'+
'</div>').appendTo("#palette-container");
catDiv.data('category',originalCategory);
catDiv.data('label',label);
categoryContainers[category] = {
container: catDiv,
close: function() {
@@ -116,6 +128,12 @@ RED.palette = (function() {
el.data('popover').setContent(popOverContent);
}
function setIcon(element,sf) {
var iconElement = element.find(".palette_icon");
var icon_url = RED.utils.getNodeIcon(sf._def,sf);
iconElement.attr("style", "background-image: url("+icon_url+")");
}
function escapeNodeType(nt) {
return nt.replace(" ","_").replace(".","_").replace(":","_");
}
@@ -127,6 +145,7 @@ RED.palette = (function() {
}
if (exclusion.indexOf(def.category)===-1) {
var originalCategory = def.category;
var category = def.category.replace(/ /g,"_");
var rootCategory = category.split("-")[0];
@@ -147,14 +166,13 @@ RED.palette = (function() {
d.className="palette_node";
if (def.icon) {
var icon_url = RED.utils.getNodeIcon(def);
var iconContainer = $('<div/>',{class:"palette_icon_container"+(def.align=="right"?" palette_icon_container_right":"")}).appendTo(d);
$('<div/>',{class:"palette_icon",style:"background-image: url("+icon_url+")"}).appendTo(iconContainer);
}
d.style.backgroundColor = def.color;
d.style.backgroundColor = RED.utils.getNodeColor(nt,def);
if (def.outputs > 0) {
var portOut = document.createElement("div");
@@ -168,21 +186,12 @@ RED.palette = (function() {
d.appendChild(portIn);
}
if ($("#palette-base-category-"+rootCategory).length === 0) {
if(coreCategories.indexOf(rootCategory) !== -1){
createCategoryContainer(rootCategory, RED._("node-red:palette.label."+rootCategory, {defaultValue:rootCategory}));
} else {
var ns = def.set.id;
createCategoryContainer(rootCategory, RED._(ns+":palette.label."+rootCategory, {defaultValue:rootCategory}));
}
}
$("#palette-container-"+rootCategory).show();
if ($("#palette-"+category).length === 0) {
$("#palette-base-category-"+rootCategory).append('<div id="palette-'+category+'"></div>');
}
createCategory(def.category,rootCategory,category,(coreCategories.indexOf(rootCategory) !== -1)?"node-red":def.set.id);
$("#palette-"+category).append(d);
$(d).data('category',rootCategory);
d.onmousedown = function(e) { e.preventDefault(); };
var popover = RED.popover.create({
@@ -219,13 +228,19 @@ RED.palette = (function() {
var mouseX;
var mouseY;
var spliceTimer;
var paletteWidth;
var paletteTop;
$(d).draggable({
helper: 'clone',
appendTo: 'body',
revert: true,
revertDuration: 50,
containment:'#main-container',
start: function() {RED.view.focus();},
start: function() {
paletteWidth = $("#palette").width();
paletteTop = $("#palette").parent().position().top + $("#palette-container").position().top;
RED.view.focus();
},
stop: function() { d3.select('.link_splice').classed('link_splice',false); if (spliceTimer) { clearTimeout(spliceTimer); spliceTimer = null;}},
drag: function(e,ui) {
@@ -235,9 +250,8 @@ RED.palette = (function() {
ui.position.left += 17.5;
if (def.inputs > 0 && def.outputs > 0) {
mouseX = ui.position.left+(ui.helper.width()/2) - chartOffset.left + chart.scrollLeft();
mouseY = ui.position.top+(ui.helper.height()/2) - chartOffset.top + chart.scrollTop();
mouseX = ui.position.left-paletteWidth+(ui.helper.width()/2) - chartOffset.left + chart.scrollLeft();
mouseY = ui.position.top-paletteTop+(ui.helper.height()/2) - chartOffset.top + chart.scrollTop();
if (!spliceTimer) {
spliceTimer = setTimeout(function() {
var nodes = [];
@@ -259,6 +273,7 @@ RED.palette = (function() {
mouseY /= RED.view.scale();
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
}
for (var i=0;i<nodes.length;i++) {
if (d3.select(nodes[i]).classed('link_background')) {
var length = nodes[i].getTotalLength();
@@ -296,7 +311,7 @@ RED.palette = (function() {
});
var nodeInfo = null;
if (def.category == "subflows") {
if (nt.indexOf("subflow:") === 0) {
$(d).dblclick(function(e) {
RED.workspaces.show(nt.substring(8));
e.preventDefault();
@@ -369,6 +384,32 @@ RED.palette = (function() {
portOutput.remove();
}
setLabel(sf.type+":"+sf.id,paletteNode,sf.name,marked(sf.info||""));
setIcon(paletteNode,sf);
var currentCategory = paletteNode.data('category');
var newCategory = (sf.category||"subflows");
if (currentCategory !== newCategory) {
var category = newCategory.replace(/ /g,"_");
createCategory(newCategory,category,category,"node-red");
var currentCategoryNode = paletteNode.closest(".palette-category");
var newCategoryNode = $("#palette-"+category);
newCategoryNode.append(paletteNode);
if (newCategoryNode.find(".palette_node").length === 1) {
categoryContainers[category].open();
}
paletteNode.data('category',newCategory);
if (currentCategoryNode.find(".palette_node").length === 0) {
if (currentCategoryNode.find("i").hasClass("expanded")) {
currentCategoryNode.find(".palette-content").slideToggle();
currentCategoryNode.find("i").toggleClass("expanded");
}
}
}
});
}
@@ -458,7 +499,7 @@ RED.palette = (function() {
categoryList = coreCategories
}
categoryList.forEach(function(category){
createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category}));
createCategoryContainer(category, category, "palette.label."+category);
});
$("#palette-collapse-all").on("click", function(e) {
@@ -478,13 +519,20 @@ RED.palette = (function() {
}
});
}
function getCategories() {
var categories = [];
$("#palette-container .palette-category").each(function(i,d) {
categories.push({id:$(d).data('category'),label:$(d).data('label')});
})
return categories;
}
return {
init: init,
add:addNodeType,
remove:removeNodeType,
hide:hideNodeType,
show:showNodeType,
refresh:refreshNodeTypes
refresh:refreshNodeTypes,
getCategories: getCategories
};
})();

View File

@@ -49,7 +49,7 @@ RED.projects.settings = (function() {
var tabContainer;
var trayOptions = {
title: "Project Information",// RED._("menu.label.userSettings"),, // TODO: nls
title: RED._("menu.label.userSettings"),
buttons: [
{
id: "node-dialog-ok",
@@ -143,7 +143,8 @@ RED.projects.settings = (function() {
RED.sidebar.versionControl.refresh(true);
},
400: {
'unexpected_error': function(error) {
'*': function(error) {
utils.reportUnexpectedError(error);
done(error,null);
}
},
@@ -172,14 +173,14 @@ RED.projects.settings = (function() {
container.empty();
var bg = $('<span class="button-row" style="position: relative; float: right; margin-right:0;"></span>').appendTo(container);
var input = $('<input type="text" style="width: calc(100% - 150px); margin-right: 10px;">').val(summary||"").appendTo(container);
$('<button class="editor-button">Cancel</button>')
$('<button class="editor-button">' + RED._("common.label.cancel") + '</button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
updateProjectSummary(activeProject.summary, container);
editButton.show();
});
$('<button class="editor-button">Save</button>')
$('<button class="editor-button">' + RED._("common.label.save") + '</button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
@@ -208,7 +209,8 @@ RED.projects.settings = (function() {
done(null,data);
},
400: {
'unexpected_error': function(error) {
'*': function(error) {
utils.reportUnexpectedError(error);
done(error,null);
}
},
@@ -221,7 +223,7 @@ RED.projects.settings = (function() {
if (summary) {
container.text(summary).removeClass('node-info-node');
} else {
container.text("No summary available").addClass('node-info-none');// TODO: nls
container.text(RED._("sidebar.project.projectSettings.noSummaryAvailable")).addClass('node-info-none');
}
}
@@ -233,7 +235,7 @@ RED.projects.settings = (function() {
var summaryContent = $('<div></div>',{style:"color: #999"}).appendTo(summary);
updateProjectSummary(activeProject.summary, summaryContent);
if (RED.user.hasPermission("projects.write")) {
$('<button class="editor-button editor-button-small" style="float: right;">edit description</button>')
$('<button class="editor-button editor-button-small" style="float: right;">' + RED._('sidebar.project.editDescription') + '</button>')
.prependTo(summary)
.click(function(evt) {
evt.preventDefault();
@@ -248,7 +250,7 @@ RED.projects.settings = (function() {
updateProjectDescription(activeProject, descriptionContent);
if (RED.user.hasPermission("projects.write")) {
$('<button class="editor-button editor-button-small" style="float: right;">edit README.md</button>')
$('<button class="editor-button editor-button-small" style="float: right;">' + RED._('sidebar.project.editReadme') + '</button>')
.prependTo(description)
.click(function(evt) {
evt.preventDefault();
@@ -314,7 +316,7 @@ RED.projects.settings = (function() {
// depsList.editableList('addItem',{index:3, label:"Unused dependencies"}); // TODO: nls
// }
if (totalCount === 0) {
depsList.editableList('addItem',{index:0, label:"None"}); // TODO: nls
depsList.editableList('addItem',{index:0, label:RED._("sidebar.project.projectSettings.none")});
}
}
@@ -379,7 +381,7 @@ RED.projects.settings = (function() {
function createDependenciesPane(activeProject) {
var pane = $('<div id="project-settings-tab-deps" class="project-settings-tab-pane node-help"></div>');
if (RED.user.hasPermission("projects.write")) {
$('<button class="editor-button editor-button-small" style="margin-top:10px;float: right;">edit</button>')
$('<button class="editor-button editor-button-small" style="margin-top:10px;float: right;">' + RED._("sidebar.project.projectSettings.edit") + '</button>')
.appendTo(pane)
.click(function(evt) {
evt.preventDefault();
@@ -442,14 +444,14 @@ RED.projects.settings = (function() {
}
var icon = $('<i class="fa '+iconClass+'"></i>').appendTo(titleRow);
entry.icon = icon;
$('<span>').html(entry.id).appendTo(titleRow);
$('<span>').text(entry.id).appendTo(titleRow);
var metaRow = $('<div class="palette-module-meta palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
var versionSpan = $('<span>').html(entry.version).appendTo(metaRow);
var versionSpan = $('<span>').text(entry.version).appendTo(metaRow);
metaRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
var buttons = $('<div class="palette-module-button-group"></div>').appendTo(metaRow);
if (RED.user.hasPermission("projects.write")) {
if (!entry.installed && RED.settings.theme('palette.editable') !== false) {
$('<a href="#" class="editor-button editor-button-small">install</a>').appendTo(buttons)
$('<a href="#" class="editor-button editor-button-small">' + RED._("sidebar.project.projectSettings.install") + '</a>').appendTo(buttons)
.click(function(evt) {
evt.preventDefault();
RED.palette.editor.install(entry,row,function(err) {
@@ -466,7 +468,7 @@ RED.projects.settings = (function() {
});
})
} else if (entry.known && entry.count === 0) {
$('<a href="#" class="editor-button editor-button-small">remove from project</a>').appendTo(buttons)
$('<a href="#" class="editor-button editor-button-small">' + RED._("sidebar.project.projectSettings.removeFromProject") + '</a>').appendTo(buttons)
.click(function(evt) {
evt.preventDefault();
var deps = $.extend(true, {}, activeProject.dependencies);
@@ -482,7 +484,7 @@ RED.projects.settings = (function() {
});
});
} else if (!entry.known) {
$('<a href="#" class="editor-button editor-button-small">add to project</a>').appendTo(buttons)
$('<a href="#" class="editor-button editor-button-small">' + RED._("sidebar.project.projectSettings.addToProject") + '</a>').appendTo(buttons)
.click(function(evt) {
evt.preventDefault();
var deps = $.extend(true, {}, activeProject.dependencies);
@@ -721,10 +723,10 @@ RED.projects.settings = (function() {
// }
function createFilesSection(activeProject,pane) {
var title = $('<h3></h3>').text("Files").appendTo(pane);
var title = $('<h3></h3>').text(RED._("sidebar.project.projectSettings.files")).appendTo(pane);
var filesContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
if (RED.user.hasPermission("projects.write")) {
var editFilesButton = $('<button class="editor-button editor-button-small" style="float: right;">edit</button>')
var editFilesButton = $('<button class="editor-button editor-button-small" style="float: right;">' + RED._('sidebar.project.projectSettings.edit') + '</button>')
.appendTo(title)
.click(function(evt) {
evt.preventDefault();
@@ -748,7 +750,7 @@ RED.projects.settings = (function() {
// Flow files
row = $('<div class="user-settings-row"></div>').appendTo(filesContainer);
$('<label for=""></label>').text('Flow').appendTo(row);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.flow")).appendTo(row);
var flowFileLabel = $('<div class="uneditable-input" style="padding:0">').appendTo(row);
var flowFileLabelText = $('<span style="display:inline-block; padding: 6px">').text(activeProject.files.flow).appendTo(flowFileLabel);
@@ -785,7 +787,7 @@ RED.projects.settings = (function() {
})
row = $('<div class="user-settings-row"></div>').appendTo(filesContainer);
$('<label for=""></label>').text('Credentials').appendTo(row);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.credentials")).appendTo(row);
var credFileLabel = $('<div class="uneditable-input">').text(activeProject.files.credentials).appendTo(row);
var credFileInput = $('<div class="uneditable-input">').text(activeProject.files.credentials).hide().insertAfter(credFileLabel);
@@ -897,12 +899,12 @@ RED.projects.settings = (function() {
var credentialFormRows = $('<div>',{style:"margin-top:10px"}).hide().appendTo(credentialStateLabel);
var credentialSetLabel = $('<div style="margin: 20px 0 10px 5px;">Set the encryption key:</div>').hide().appendTo(credentialFormRows);
var credentialChangeLabel = $('<div style="margin: 20px 0 10px 5px;">Change the encryption key:</div>').hide().appendTo(credentialFormRows);
var credentialResetLabel = $('<div style="margin: 20px 0 10px 5px;">Reset the encryption key:</div>').hide().appendTo(credentialFormRows);
var credentialSetLabel = $('<div style="margin: 20px 0 10px 5px;">' + RED._("sidebar.project.projectSettings.setTheEncryptionKey") + '</div>').hide().appendTo(credentialFormRows);
var credentialChangeLabel = $('<div style="margin: 20px 0 10px 5px;">' + RED._("sidebar.project.projectSettings.changeTheEncryptionKey") + '</div>').hide().appendTo(credentialFormRows);
var credentialResetLabel = $('<div style="margin: 20px 0 10px 5px;">' + RED._("sidebar.project.projectSettings.resetTheEncryptionKey") + '</div>').hide().appendTo(credentialFormRows);
var credentialSecretExistingRow = $('<div class="user-settings-row user-settings-row-credentials"></div>').appendTo(credentialFormRows);
$('<label for=""></label>').text('Current key').appendTo(credentialSecretExistingRow);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.currentKey")).appendTo(credentialSecretExistingRow);
var credentialSecretExistingInput = $('<input type="password">').appendTo(credentialSecretExistingRow)
.on("change keyup paste",function() {
if (popover) {
@@ -915,10 +917,10 @@ RED.projects.settings = (function() {
var credentialSecretNewRow = $('<div class="user-settings-row user-settings-row-credentials"></div>').appendTo(credentialFormRows);
$('<label for=""></label>').text('New key').appendTo(credentialSecretNewRow);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.newKey")).appendTo(credentialSecretNewRow);
var credentialSecretNewInput = $('<input type="password">').appendTo(credentialSecretNewRow).on("change keyup paste",checkFiles);
var credentialResetWarning = $('<div class="form-tips form-warning" style="margin: 10px;"><i class="fa fa-warning"></i> This will delete all existing credentials</div>').hide().appendTo(credentialFormRows);
var credentialResetWarning = $('<div class="form-tips form-warning" style="margin: 10px;"><i class="fa fa-warning"></i>' + RED._("sidebar.project.projectSettings.credentialsAlert") + '</div>').hide().appendTo(credentialFormRows);
var hideEditForm = function() {
@@ -948,13 +950,13 @@ RED.projects.settings = (function() {
}
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin-right:0;"></span>').hide().appendTo(filesContainer);
$('<button class="editor-button">Cancel</button>')
$('<button class="editor-button">' + RED._("common.label.cancel") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
evt.preventDefault();
hideEditForm();
});
var saveButton = $('<button class="editor-button">Save</button>')
var saveButton = $('<button class="editor-button">' + RED._("common.label.save") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
evt.preventDefault();
@@ -962,7 +964,7 @@ RED.projects.settings = (function() {
var done = function(err) {
spinner.remove();
if (err) {
console.log(err);
utils.reportUnexpectedError(err);
return;
}
flowFileLabelText.text(flowFileInput.val());
@@ -1005,10 +1007,6 @@ RED.projects.settings = (function() {
'credentials_load_failed': function(error) {
done(error);
},
'unexpected_error': function(error) {
console.log(error);
done(error);
},
'missing_current_credential_key': function(error) {
credentialSecretExistingInput.addClass("input-error");
popover = RED.popover.create({
@@ -1019,23 +1017,28 @@ RED.projects.settings = (function() {
autoClose: 3000
}).open();
done(error);
},
'*': function(error) {
done(error);
}
},
}
},payload).always(function() {
RED.deploy.setDeployInflight(false);
setTimeout(function() {
RED.deploy.setDeployInflight(false);
},500);
});
});
var updateForm = function() {
if (activeProject.settings.credentialSecretInvalid) {
credentialStateLabel.find(".user-settings-credentials-state-icon").removeClass().addClass("user-settings-credentials-state-icon fa fa-warning");
credentialStateLabel.find(".user-settings-credentials-state").text("Invalid encryption key");
credentialStateLabel.find(".user-settings-credentials-state").text(RED._("sidebar.project.projectSettings.invalidEncryptionKey"));
} else if (activeProject.settings.credentialsEncrypted) {
credentialStateLabel.find(".user-settings-credentials-state-icon").removeClass().addClass("user-settings-credentials-state-icon fa fa-lock");
credentialStateLabel.find(".user-settings-credentials-state").text("Encryption enabled");
credentialStateLabel.find(".user-settings-credentials-state").text(RED._("sidebar.project.projectSettings.encryptionEnabled"));
} else {
credentialStateLabel.find(".user-settings-credentials-state-icon").removeClass().addClass("user-settings-credentials-state-icon fa fa-unlock");
credentialStateLabel.find(".user-settings-credentials-state").text("Encryption disabled");
credentialStateLabel.find(".user-settings-credentials-state").text(RED._("sidebar.project.projectSettings.encryptionDisabled"));
}
credentialSecretResetButton.toggleClass('disabled',!activeProject.settings.credentialSecretInvalid && !activeProject.settings.credentialsEncrypted);
credentialSecretResetButton.prop('disabled',!activeProject.settings.credentialSecretInvalid && !activeProject.settings.credentialsEncrypted);
@@ -1047,7 +1050,7 @@ RED.projects.settings = (function() {
function createLocalBranchListSection(activeProject,pane) {
var localBranchContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
$('<h4></h4>').text("Branches").appendTo(localBranchContainer);
$('<h4></h4>').text(RED._("sidebar.project.projectSettings.branches")).appendTo(localBranchContainer);
var row = $('<div class="user-settings-row projects-dialog-list"></div>').appendTo(localBranchContainer);
@@ -1060,7 +1063,7 @@ RED.projects.settings = (function() {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text("No branches");
container.text(RED._("sidebar.project.projectSettings.noBranches"));
return;
}
if (entry.current) {
@@ -1092,7 +1095,7 @@ RED.projects.settings = (function() {
.click(function(e) {
e.preventDefault();
var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
var notification = RED.notify("Are you sure you want to delete the local branch '"+entry.name+"'? This cannot be undone.", {
var notification = RED.notify(RED._("sidebar.project.projectSettings.deleteConfirm", { name: entry.name }), {
type: "warning",
modal: true,
fixed: true,
@@ -1120,7 +1123,7 @@ RED.projects.settings = (function() {
},
400: {
'git_delete_branch_unmerged': function(error) {
notification = RED.notify("The local branch '"+entry.name+"' has unmerged changes that will be lost. Are you sure you want to delete it?", {
notification = RED.notify(RED._("sidebar.project.projectSettings.unmergedConfirm", { name: entry.name }), {
type: "warning",
modal: true,
fixed: true,
@@ -1132,7 +1135,7 @@ RED.projects.settings = (function() {
notification.close();
}
},{
text: 'Delete unmerged branch',
text: RED._("sidebar.project.projectSettings.deleteUnmergedBranch"),
click: function() {
options.url += "?force=true";
notification.close();
@@ -1142,8 +1145,8 @@ RED.projects.settings = (function() {
]
});
},
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
spinner.remove();
}
},
@@ -1180,25 +1183,32 @@ RED.projects.settings = (function() {
}
function createRemoteRepositorySection(activeProject,pane) {
$('<h3></h3>').text("Version Control").appendTo(pane);
$('<h3></h3>').text(RED._("sidebar.project.projectSettings.versionControl")).appendTo(pane);
createLocalBranchListSection(activeProject,pane);
var repoContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
var title = $('<h4></h4>').text("Git remotes").appendTo(repoContainer);
var title = $('<h4></h4>').text(RED._("sidebar.project.projectSettings.gitRemotes")).appendTo(repoContainer);
var editRepoButton = $('<button class="editor-button editor-button-small" style="float: right; margin-right: 10px;">add remote</button>')
var editRepoButton = $('<button class="editor-button editor-button-small" style="float: right; margin-right: 10px;">' + RED._("sidebar.project.projectSettings.addRemote") + '</button>')
.appendTo(title)
.click(function(evt) {
editRepoButton.attr('disabled',true);
addRemoteDialog.slideDown(200, function() {
addRemoteDialog[0].scrollIntoView();
if (isEmpty) {
remoteNameInput.val('origin');
remoteURLInput.focus();
} else {
remoteNameInput.focus();
}
validateForm();
});
});
var emptyItem = { empty: true };
var isEmpty = true;
var row = $('<div class="user-settings-row"></div>').appendTo(repoContainer);
var addRemoteDialog = $('<div class="projects-dialog-list-dialog"></div>').hide().appendTo(row);
row = $('<div class="user-settings-row projects-dialog-list"></div>').appendTo(repoContainer);
@@ -1211,7 +1221,7 @@ RED.projects.settings = (function() {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text("No remotes");
container.text(RED._("sidebar.project.projectSettings.noRemotes"));
return;
} else {
$('<span class="entry-icon"><i class="fa fa-globe"></i></span>').appendTo(container);
@@ -1230,7 +1240,7 @@ RED.projects.settings = (function() {
.click(function(e) {
e.preventDefault();
var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
var notification = RED.notify("Are you sure you want to delete the remote '"+entry.name+"'?", {
var notification = RED.notify(RED._("sidebar.project.projectSettings.deleteRemoteConfrim", { name: entry.name }), {
type: "warning",
modal: true,
fixed: true,
@@ -1242,9 +1252,17 @@ RED.projects.settings = (function() {
notification.close();
}
},{
text: 'Delete remote',
text: RED._("sidebar.project.projectSettings.deleteRemote"),
click: function() {
notification.close();
if (activeProject.git.branches.remote && activeProject.git.branches.remote.indexOf(entry.name+"/") === 0) {
delete activeProject.git.branches.remote;
}
if (activeProject.git.branches.remoteAlt && activeProject.git.branches.remoteAlt.indexOf(entry.name+"/") === 0) {
delete activeProject.git.branches.remoteAlt;
}
var url = "projects/"+activeProject.name+"/remotes/"+entry.name;
var options = {
url: url,
@@ -1256,6 +1274,7 @@ RED.projects.settings = (function() {
setTimeout(spinner.remove, 100);
if (data.remotes.length === 0) {
delete activeProject.git.remotes;
isEmpty = true;
remotesList.editableList('addItem',emptyItem);
} else {
activeProject.git.remotes = {};
@@ -1265,11 +1284,13 @@ RED.projects.settings = (function() {
activeProject.git.remotes[name] = remote;
});
}
delete activeProject.git.branches.remoteAlt;
RED.sidebar.versionControl.refresh();
});
},
400: {
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
spinner.remove();
}
},
@@ -1290,30 +1311,43 @@ RED.projects.settings = (function() {
var validateForm = function() {
var validName = /^[a-zA-Z0-9\-_]+$/.test(remoteNameInput.val());
var repo = remoteURLInput.val();
// var validRepo = /^(?:file|git|ssh|https?|[\d\w\.\-_]+@[\w\.]+):(?:\/\/)?[\w\.@:\/~_-]+(?:\.git)?(?:\/?|\#[\d\w\.\-_]+?)$/.test(remoteURLInput.val());
var validRepo = !/\s/.test(remoteURLInput.val());
var validRepo = repo.length > 0 && !/\s/.test(repo);
if (/^https?:\/\/[^/]+@/i.test(repo)) {
remoteURLLabel.text(RED._("sidebar.project.projectSettings.urlRule2"));
validRepo = false;
} else {
remoteURLLabel.text(RED._("sidebar.project.projectSettings.urlRule"));
}
saveButton.attr('disabled',(!validName || !validRepo))
remoteNameInput.toggleClass('input-error',remoteNameInputChanged&&!validName);
remoteURLInput.toggleClass('input-error',remoteURLInputChanged&&!validRepo);
if (popover) {
popover.close();
popover = null;
}
};
var popover;
var remoteNameInputChanged = false;
var remoteURLInputChanged = false;
$('<div class="projects-dialog-list-dialog-header">').text('Add remote').appendTo(addRemoteDialog);
$('<div class="projects-dialog-list-dialog-header">').text(RED._('sidebar.project.projectSettings.addRemote2')).appendTo(addRemoteDialog);
row = $('<div class="user-settings-row"></div>').appendTo(addRemoteDialog);
$('<label for=""></label>').text('Remote name').appendTo(row);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.remoteName")).appendTo(row);
var remoteNameInput = $('<input type="text">').appendTo(row).on("change keyup paste",function() {
remoteNameInputChanged = true;
validateForm();
});
var remoteNameInputChanged = false;
$('<label class="projects-edit-form-sublabel"><small>Must contain only A-Z 0-9 _ -</small></label>').appendTo(row).find("small");
$('<label class="projects-edit-form-sublabel"><small>' + RED._("sidebar.project.projectSettings.nameRule") + '</small></label>').appendTo(row).find("small");
row = $('<div class="user-settings-row"></div>').appendTo(addRemoteDialog);
$('<label for=""></label>').text('URL').appendTo(row);
var remoteURLInput = $('<input type="text">').appendTo(row).on("change keyup paste",validateForm);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.url")).appendTo(row);
var remoteURLInput = $('<input type="text">').appendTo(row).on("change keyup paste",function() {
remoteURLInputChanged = true;
validateForm()
});
var remoteURLLabel = $('<label class="projects-edit-form-sublabel"><small>' + RED._("sidebar.project.projectSettings.urlRule") +'</small></label>').appendTo(row).find("small");
var hideEditForm = function() {
editRepoButton.attr('disabled',false);
@@ -1327,13 +1361,13 @@ RED.projects.settings = (function() {
}
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin: 10px;"></span>')
.appendTo(addRemoteDialog);
$('<button class="editor-button">Cancel</button>')
$('<button class="editor-button">' + RED._("common.label.cancel") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
evt.preventDefault();
hideEditForm();
});
var saveButton = $('<button class="editor-button">Add remote</button>')
var saveButton = $('<button class="editor-button">' + RED._("sidebar.project.projectSettings.addRemote2") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
evt.preventDefault();
@@ -1367,6 +1401,7 @@ RED.projects.settings = (function() {
activeProject.git.remotes[name] = remote;
});
updateForm();
RED.sidebar.versionControl.refresh();
done();
},
400: {
@@ -1381,14 +1416,15 @@ RED.projects.settings = (function() {
remoteNameInput.addClass('input-error');
done(error);
},
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
done(error);
}
},
}
},payload);
});
var updateForm = function() {
remotesList.editableList('empty');
var count = 0;
@@ -1400,7 +1436,8 @@ RED.projects.settings = (function() {
}
}
}
if (count === 0) {
isEmpty = (count === 0);
if (isEmpty) {
remotesList.editableList('addItem',emptyItem);
}
}
@@ -1447,19 +1484,19 @@ RED.projects.settings = (function() {
utils = _utils;
addPane({
id:'main',
title: "Project", // TODO: nls
title: RED._("sidebar.project.name"),
get: createMainPane,
close: function() { }
});
addPane({
id:'deps',
title: "Dependencies", // TODO: nls
title: RED._("sidebar.project.dependencies"),
get: createDependenciesPane,
close: function() { }
});
addPane({
id:'settings',
title: "Settings", // TODO: nls
title: RED._("sidebar.project.settings"),
get: createSettingsPane,
close: function() {
if (popover) {

View File

@@ -24,18 +24,18 @@ RED.projects.userSettings = (function() {
var currentGitSettings = RED.settings.get('git') || {};
currentGitSettings.user = currentGitSettings.user || {};
var title = $('<h3></h3>').text("Committer Details").appendTo(pane);
var title = $('<h3></h3>').text(RED._("editor:sidebar.project.userSettings.committerDetail")).appendTo(pane);
var gitconfigContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
$('<div style="color:#aaa;"></div>').appendTo(gitconfigContainer).text("Leave blank to use system default");
$('<div style="color:#aaa;"></div>').appendTo(gitconfigContainer).text(RED._("editor:sidebar.project.userSettings.committerTip"));
var row = $('<div class="user-settings-row"></div>').appendTo(gitconfigContainer);
$('<label for=""></label>').text('Username').appendTo(row);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.userName")).appendTo(row);
gitUsernameInput = $('<input type="text">').appendTo(row);
gitUsernameInput.val(currentGitSettings.user.name||"");
row = $('<div class="user-settings-row"></div>').appendTo(gitconfigContainer);
$('<label for=""></label>').text('Email').appendTo(row);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.email")).appendTo(row);
gitEmailInput = $('<input type="text">').appendTo(row);
gitEmailInput.val(currentGitSettings.user.email||"");
}
@@ -44,10 +44,10 @@ RED.projects.userSettings = (function() {
function createSSHKeySection(pane) {
var container = $('<div class="user-settings-section"></div>').appendTo(pane);
var popover;
var title = $('<h3></h3>').text("SSH Keys").appendTo(container);
var subtitle = $('<div style="color:#aaa;"></div>').appendTo(container).text("Allows you to create secure connections to remote git repositories.");
var title = $('<h3></h3>').text(RED._("editor:sidebar.project.userSettings.sshKeys")).appendTo(container);
var subtitle = $('<div style="color:#aaa;"></div>').appendTo(container).text(RED._("editor:sidebar.project.userSettings.sshKeysTip"));
var addKeyButton = $('<button id="user-settings-gitconfig-add-key" class="editor-button editor-button-small" style="float: right; margin-right: 10px;">add key</button>')
var addKeyButton = $('<button id="user-settings-gitconfig-add-key" class="editor-button editor-button-small" style="float: right; margin-right: 10px;">'+RED._("editor:sidebar.project.userSettings.add")+'</button>')
.appendTo(subtitle)
.click(function(evt) {
addKeyButton.attr('disabled',true);
@@ -72,9 +72,9 @@ RED.projects.userSettings = (function() {
var validPassphrase = passphrase.length === 0 || passphrase.length >= 8;
passphraseInput.toggleClass('input-error',!validPassphrase);
if (!validPassphrase) {
passphraseInputSubLabel.text("Passphrase too short");
passphraseInputSubLabel.text(RED._("editor:sidebar.project.userSettings.passphraseShort"));
} else if (passphrase.length === 0) {
passphraseInputSubLabel.text("Optional");
passphraseInputSubLabel.text(RED._("editor:sidebar.project.userSettings.optional"));
} else {
passphraseInputSubLabel.text("");
}
@@ -91,11 +91,11 @@ RED.projects.userSettings = (function() {
var row = $('<div class="user-settings-row"></div>').appendTo(container);
var addKeyDialog = $('<div class="projects-dialog-list-dialog"></div>').hide().appendTo(row);
$('<div class="projects-dialog-list-dialog-header">').text('Add SSH Key').appendTo(addKeyDialog);
$('<div class="projects-dialog-list-dialog-header">').text(RED._("editor:sidebar.project.userSettings.addSshKey")).appendTo(addKeyDialog);
var addKeyDialogBody = $('<div>').appendTo(addKeyDialog);
row = $('<div class="user-settings-row"></div>').appendTo(addKeyDialogBody);
$('<div style="color:#aaa;"></div>').appendTo(row).text("Generate a new public/private key pair");
$('<div style="color:#aaa;"></div>').appendTo(row).text(RED._("editor:sidebar.project.userSettings.addSshKeyTip"));
// var bg = $('<div></div>',{class:"button-group", style:"text-align: center"}).appendTo(row);
// var addLocalButton = $('<button class="editor-button toggle selected">use local key</button>').appendTo(bg);
// var uploadButton = $('<button class="editor-button toggle">upload key</button>').appendTo(bg);
@@ -125,19 +125,19 @@ RED.projects.userSettings = (function() {
row = $('<div class="user-settings-row"></div>').appendTo(addKeyDialogBody);
$('<label for=""></label>').text('Name').appendTo(row);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.name")).appendTo(row);
var keyNameInputChanged = false;
var keyNameInput = $('<input type="text">').appendTo(row).on("change keyup paste",function() {
keyNameInputChanged = true;
validateForm();
});
$('<label class="projects-edit-form-sublabel"><small>Must contain only A-Z 0-9 _ -</small></label>').appendTo(row).find("small");
$('<label class="projects-edit-form-sublabel"><small>'+RED._("editor:sidebar.project.userSettings.nameRule")+'</small></label>').appendTo(row).find("small");
var generateKeyPane = $('<div>').appendTo(addKeyDialogBody);
row = $('<div class="user-settings-row"></div>').appendTo(generateKeyPane);
$('<label for=""></label>').text('Passphrase').appendTo(row);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.passphrase")).appendTo(row);
var passphraseInput = $('<input type="password">').appendTo(row).on("change keyup paste",validateForm);
var passphraseInputSubLabel = $('<label class="projects-edit-form-sublabel"><small>Optional</small></label>').appendTo(row).find("small");
var passphraseInputSubLabel = $('<label class="projects-edit-form-sublabel"><small>'+RED._("editor:sidebar.project.userSettings.optional")+'</small></label>').appendTo(row).find("small");
// var addLocalKeyPane = $('<div>').hide().appendTo(addKeyDialogBody);
// row = $('<div class="user-settings-row"></div>').appendTo(addLocalKeyPane);
@@ -179,13 +179,13 @@ RED.projects.userSettings = (function() {
}
}
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin: 10px;"></span>').appendTo(addKeyDialog);
$('<button class="editor-button">Cancel</button>')
$('<button class="editor-button">'+RED._("editor:sidebar.project.userSettings.cancel")+'</button>')
.appendTo(formButtons)
.click(function(evt) {
evt.preventDefault();
hideEditForm();
});
var saveButton = $('<button class="editor-button">Generate key</button>')
var saveButton = $('<button class="editor-button">'+RED._("editor:sidebar.project.userSettings.generate")+'</button>')
.appendTo(formButtons)
.click(function(evt) {
evt.preventDefault();
@@ -264,7 +264,7 @@ RED.projects.userSettings = (function() {
utils.sendRequest(options);
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin: 10px;"></span>').appendTo(row);
$('<button class="editor-button editor-button-small">Copy public key to clipboard</button>')
$('<button class="editor-button editor-button-small">'+RED._("editor:sidebar.project.userSettings.copyPublicKey")+'</button>')
.appendTo(formButtons)
.click(function(evt) {
try {
@@ -289,7 +289,7 @@ RED.projects.userSettings = (function() {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text("No SSH keys");
container.text(RED._("editor:sidebar.project.userSettings.noSshKeys"));
return;
}
var topRow = $('<div class="projects-dialog-ssh-key-header">').appendTo(container);
@@ -313,7 +313,7 @@ RED.projects.userSettings = (function() {
.click(function(e) {
e.stopPropagation();
var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
var notification = RED.notify("Are you sure you want to delete the SSH key '"+entry.name+"'? This cannot be undone.", {
var notification = RED.notify(RED._("editor:sidebar.project.userSettings.deleteConfirm", {name:entry.name}), {
type: 'warning',
modal: true,
fixed: true,
@@ -326,7 +326,7 @@ RED.projects.userSettings = (function() {
}
},
{
text: "Delete key",
text: RED._("editor:sidebar.project.userSettings.delete"),
click: function() {
notification.close();
var url = "settings/user/keys/"+entry.name;
@@ -400,7 +400,7 @@ RED.projects.userSettings = (function() {
utils = _utils;
RED.userSettings.add({
id:'gitconfig',
title: "Git config", // TODO: nls
title: RED._("editor:sidebar.project.userSettings.gitConfig"),
get: createSettingsPane,
close: function() {
var currentGitSettings = RED.settings.get('git') || {};

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,6 @@ RED.sidebar.versionControl = (function() {
var unmergedContent;
var unmergedChangesList;
var commitButton;
var mergeConflictNotification;
var localChanges;
var localCommitList;
@@ -51,17 +50,13 @@ RED.sidebar.versionControl = (function() {
// done(error,null);
},
200: function(data) {
if (mergeConflictNotification) {
mergeConflictNotification.close();
mergeConflictNotification = null;
}
var title;
if (state === 'unstaged') {
title = 'Unstaged changes : '+entry.file
title = RED._("sidebar.project.versionControl.unstagedChanges")+' : '+entry.file
} else if (state === 'staged') {
title = 'Staged changes : '+entry.file
title = RED._("sidebar.project.versionControl.stagedChanges")+' : '+entry.file
} else {
title = 'Resolve conflicts : '+entry.file
title = RED._("sidebar.project.versionControl.resolveConflicts")+' : '+entry.file
}
var options = {
diff: data.diff,
@@ -70,16 +65,21 @@ RED.sidebar.versionControl = (function() {
project: activeProject
}
if (state == 'unstaged') {
options.oldRevTitle = entry.indexStatus === " "?"HEAD":"Staged";
options.newRevTitle = "Unstaged";
options.oldRevTitle = entry.indexStatus === " "?RED._("sidebar.project.versionControl.head"):RED._("sidebar.project.versionControl.staged");
options.newRevTitle = RED._("sidebar.project.versionControl.unstaged");
options.oldRev = entry.indexStatus === " "?"@":":0";
options.newRev = "_";
} else if (state === 'staged') {
options.oldRevTitle = "HEAD";
options.newRevTitle = "Staged";
options.oldRevTitle = RED._("sidebar.project.versionControl.head");
options.newRevTitle = RED._("sidebar.project.versionControl.staged");
options.oldRev = "@";
options.newRev = ":0";
} else {
options.oldRevTitle = RED._("sidebar.project.versionControl.local");
options.newRevTitle = RED._("sidebar.project.versionControl.remote");
options.commonRev = ":1";
options.oldRev = ":2";
options.newRev = ":3";
options.onresolve = function(resolution) {
utils.sendRequest({
url: "projects/"+activeProject.name+"/resolve/"+encodeURIComponent(entry.file),
@@ -102,9 +102,7 @@ RED.sidebar.versionControl = (function() {
},{resolutions:resolution.resolutions[entry.file]});
}
}
options.oncancel = showMergeConflictNotification;
RED.diff.showUnifiedDiff(options);
// console.log(data.diff);
},
400: {
'unexpected_error': function(error) {
@@ -122,6 +120,18 @@ RED.sidebar.versionControl = (function() {
if (entry.label) {
row.addClass('node-info-none');
container.text(entry.label);
if (entry.button) {
container.css({
display: "inline-block",
maxWidth: "300px",
textAlign: "left"
})
var toolbar = $('<div style="float: right; margin: 5px; height: 50px;"></div>').appendTo(container);
$('<button class="editor-button editor-button-small"></button>').text(entry.button.label)
.appendTo(toolbar)
.click(entry.button.click);
}
return;
}
@@ -144,8 +154,9 @@ RED.sidebar.versionControl = (function() {
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
var spinner = utils.addSpinnerOverlay(container).addClass('projects-dialog-spinner-contain');
var notification = RED.notify("Are you sure you want to revert the changes to '"+entry.file+"'? This cannot be undone.", {
var notification = RED.notify(RED._("sidebar.project.versionControl.revert",{file:entry.file}), {
type: "warning",
modal: true,
fixed: true,
@@ -157,7 +168,7 @@ RED.sidebar.versionControl = (function() {
notification.close();
}
},{
text: 'Revert changes',
text: RED._("sidebar.project.versionControl.revertChanges"),
click: function() {
notification.close();
var activeProject = RED.projects.getActiveProject();
@@ -178,7 +189,12 @@ RED.sidebar.versionControl = (function() {
}
}
}
utils.sendRequest(options);
RED.deploy.setDeployInflight(true);
utils.sendRequest(options).always(function() {
setTimeout(function() {
RED.deploy.setDeployInflight(false);
},500);
});
}
}
@@ -265,6 +281,8 @@ RED.sidebar.versionControl = (function() {
entry["update"+((state==='unstaged')?"Unstaged":"Staged")](entry, status);
}
var utils;
var emptyStagedItem;
var emptyMergedItem;
function init(_utils) {
utils = _utils;
@@ -296,7 +314,7 @@ RED.sidebar.versionControl = (function() {
});
localChanges = sections.add({
title: "Local Changes",
title: RED._("sidebar.project.versionControl.localChanges"),
collapsible: true
});
localChanges.expand();
@@ -310,10 +328,12 @@ RED.sidebar.versionControl = (function() {
refresh(true);
})
emptyStagedItem = { label: RED._("sidebar.project.versionControl.none") };
emptyMergedItem = { label: RED._("sidebar.project.versionControl.conflictResolve") };
var unstagedContent = $('<div class="sidebar-version-control-change-container"></div>').appendTo(localChanges.content);
var header = $('<div class="sidebar-version-control-change-header">Local files</div>').appendTo(unstagedContent);
stageAllButton = $('<button class="editor-button editor-button-small" style="float: right"><i class="fa fa-plus"></i> all</button>')
var header = $('<div class="sidebar-version-control-change-header">'+RED._("sidebar.project.versionControl.localFiles")+'</div>').appendTo(unstagedContent);
stageAllButton = $('<button class="editor-button editor-button-small" style="float: right"><i class="fa fa-plus"></i> '+RED._("sidebar.project.versionControl.all")+'</button>')
.appendTo(header)
.click(function(evt) {
evt.preventDefault();
@@ -343,15 +363,16 @@ RED.sidebar.versionControl = (function() {
unmergedContent = $('<div class="sidebar-version-control-change-container"></div>').appendTo(localChanges.content);
header = $('<div class="sidebar-version-control-change-header">Unmerged changes</div>').appendTo(unmergedContent);
header = $('<div class="sidebar-version-control-change-header">'+RED._("sidebar.project.versionControl.unmergedChanges")+'</div>').appendTo(unmergedContent);
bg = $('<div style="float: right"></div>').appendTo(header);
var abortMergeButton = $('<button class="editor-button editor-button-small" style="margin-right: 5px;">abort merge</button>')
var abortMergeButton = $('<button class="editor-button editor-button-small" style="margin-right: 5px;">'+RED._("sidebar.project.versionControl.abortMerge")+'</button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
evt.stopPropagation();
var spinner = utils.addSpinnerOverlay(unmergedContent);
var activeProject = RED.projects.getActiveProject();
RED.deploy.setDeployInflight(true);
utils.sendRequest({
url: "projects/"+activeProject.name+"/merge",
type: "DELETE",
@@ -369,6 +390,10 @@ RED.sidebar.versionControl = (function() {
}
},
}
}).always(function() {
setTimeout(function() {
RED.deploy.setDeployInflight(false);
},500);
});
});
unmergedChangesList = $("<ol>",{style:"position: absolute; top: 30px; bottom: 0; right:0; left:0;"}).appendTo(unmergedContent);
@@ -376,6 +401,16 @@ RED.sidebar.versionControl = (function() {
addButton: false,
scrollOnAdd: false,
addItem: function(row,index,entry) {
if (entry === emptyMergedItem) {
entry.button = {
label: RED._("sidebar.project.versionControl.commit"),
click: function(evt) {
evt.preventDefault();
evt.stopPropagation();
showCommitBox();
}
}
}
createChangeEntry(row,entry,entry.treeStatus,'unmerged');
},
sort: function(A,B) {
@@ -392,33 +427,37 @@ RED.sidebar.versionControl = (function() {
var stagedContent = $('<div class="sidebar-version-control-change-container"></div>').appendTo(localChanges.content);
header = $('<div class="sidebar-version-control-change-header">Changes to commit</div>').appendTo(stagedContent);
header = $('<div class="sidebar-version-control-change-header">'+RED._("sidebar.project.versionControl.changeToCommit")+'</div>').appendTo(stagedContent);
bg = $('<div style="float: right"></div>').appendTo(header);
commitButton = $('<button class="editor-button editor-button-small" style="margin-right: 5px;">commit</button>')
var showCommitBox = function() {
commitMessage.val("");
submitCommitButton.attr("disabled",true);
unstagedContent.css("height","30px");
if (unmergedContent.is(":visible")) {
unmergedContent.css("height","30px");
stagedContent.css("height","calc(100% - 60px - 175px)");
} else {
stagedContent.css("height","calc(100% - 30px - 175px)");
}
commitBox.show();
setTimeout(function() {
commitBox.css("height","175px");
},10);
stageAllButton.attr("disabled",true);
unstageAllButton.attr("disabled",true);
commitButton.attr("disabled",true);
abortMergeButton.attr("disabled",true);
commitMessage.focus();
}
commitButton = $('<button class="editor-button editor-button-small" style="margin-right: 5px;">'+RED._("sidebar.project.versionControl.commit")+'</button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
evt.stopPropagation();
commitMessage.val("");
submitCommitButton.attr("disabled",true);
unstagedContent.css("height","30px");
if (unmergedContent.is(":visible")) {
unmergedContent.css("height","30px");
stagedContent.css("height","calc(100% - 60px - 175px)");
} else {
stagedContent.css("height","calc(100% - 30px - 175px)");
}
commitBox.show();
setTimeout(function() {
commitBox.css("height","175px");
},10);
stageAllButton.attr("disabled",true);
unstageAllButton.attr("disabled",true);
commitButton.attr("disabled",true);
commitMessage.focus();
showCommitBox();
});
unstageAllButton = $('<button class="editor-button editor-button-small"><i class="fa fa-minus"></i> all</button>')
unstageAllButton = $('<button class="editor-button editor-button-small"><i class="fa fa-minus"></i> '+RED._("sidebar.project.versionControl.all")+'</button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
@@ -445,14 +484,14 @@ RED.sidebar.versionControl = (function() {
commitBox = $('<div class="sidebar-version-control-slide-box sidebar-version-control-slide-box-bottom"></div>').hide().appendTo(localChanges.content);
var commitMessage = $('<textarea>')
var commitMessage = $('<textarea placeholder='+RED._("sidebar.project.versionControl.commitPlaceholder")+'></textarea>')
.appendTo(commitBox)
.on("change keyup paste",function() {
submitCommitButton.attr('disabled',$(this).val().trim()==="");
});
var commitToolbar = $('<div class="sidebar-version-control-slide-box-toolbar button-group">').appendTo(commitBox);
var cancelCommitButton = $('<button class="editor-button">Cancel</button>')
var cancelCommitButton = $('<button class="editor-button">'+RED._("sidebar.project.versionControl.cancelCapital")+'</button>')
.appendTo(commitToolbar)
.click(function(evt) {
evt.preventDefault();
@@ -467,13 +506,16 @@ RED.sidebar.versionControl = (function() {
stageAllButton.attr("disabled",false);
unstageAllButton.attr("disabled",false);
commitButton.attr("disabled",false);
abortMergeButton.attr("disabled",false);
})
var submitCommitButton = $('<button class="editor-button">Commit</button>')
var submitCommitButton = $('<button class="editor-button">'+RED._("sidebar.project.versionControl.commitCapital")+'</button>')
.appendTo(commitToolbar)
.click(function(evt) {
evt.preventDefault();
var spinner = utils.addSpinnerOverlay(submitCommitButton).addClass('projects-dialog-spinner-sidebar');
var activeProject = RED.projects.getActiveProject();
RED.deploy.setDeployInflight(true);
utils.sendRequest({
url: "projects/"+activeProject.name+"/commit",
type: "POST",
@@ -487,22 +529,23 @@ RED.sidebar.versionControl = (function() {
refresh(true);
},
400: {
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
}
},
}
},{
message:commitMessage.val()
});
}).always(function() {
setTimeout(function() {
RED.deploy.setDeployInflight(false);
},500);
})
})
var localHistory = sections.add({
title: "Commit History",
title: RED._("sidebar.project.versionControl.commitHistory"),
collapsible: true
});
@@ -511,12 +554,12 @@ RED.sidebar.versionControl = (function() {
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
refresh(true);
refresh(true,true);
})
var localBranchToolbar = $('<div class="sidebar-version-control-change-header" style="text-align: right;"></div>').appendTo(localHistory.content);
var localBranchButton = $('<button class="editor-button editor-button-small"><i class="fa fa-code-fork"></i> Branch: <span id="sidebar-version-control-local-branch"></span></button>')
var localBranchButton = $('<button class="editor-button editor-button-small"><i class="fa fa-code-fork"></i> '+RED._("sidebar.project.versionControl.branch")+' <span id="sidebar-version-control-local-branch"></span></button>')
.appendTo(localBranchToolbar)
.click(function(evt) {
evt.preventDefault();
@@ -553,7 +596,10 @@ RED.sidebar.versionControl = (function() {
closeBranchBox();
localCommitListShade.show();
$(this).addClass('selected');
var activeProject = RED.projects.getActiveProject();
$("#sidebar-version-control-repo-toolbar-set-upstream-row").toggle(!!activeProject.git.branches.remoteAlt);
remoteBox.show();
setTimeout(function() {
remoteBox.css("height","265px");
},100);
@@ -570,7 +616,7 @@ RED.sidebar.versionControl = (function() {
row.addClass('sidebar-version-control-commit-entry');
if (entry.url) {
row.addClass('sidebar-version-control-commit-more');
row.text("+ "+(entry.total-entry.totalKnown)+" more commit(s)");
row.text("+ "+(entry.total-entry.totalKnown)+RED._("sidebar.project.versionControl.moreCommits"));
row.click(function(e) {
e.preventDefault();
getCommits(entry.url,localCommitList,row,entry.limit,entry.before);
@@ -584,8 +630,8 @@ RED.sidebar.versionControl = (function() {
result.parents = entry.parents;
result.oldRev = entry.sha+"~1";
result.newRev = entry.sha;
result.oldRevTitle = "Commit "+entry.sha.substring(0,7)+"~1";
result.newRevTitle = "Commit "+entry.sha.substring(0,7);
result.oldRevTitle = RED._("sidebar.project.versionControl.commitCapital")+" "+entry.sha.substring(0,7)+"~1";
result.newRevTitle = RED._("sidebar.project.versionControl.commitCapital")+" "+entry.sha.substring(0,7);
result.date = humanizeSinceDate(parseInt(entry.date));
RED.diff.showCommitDiff(result);
});
@@ -624,10 +670,10 @@ RED.sidebar.versionControl = (function() {
}
var localBranchBox = $('<div class="sidebar-version-control-slide-box sidebar-version-control-slide-box-top" style="top:30px;"></div>').hide().appendTo(localHistory.content);
$('<div class="sidebar-version-control-slide-box-header"></div>').text("Change local branch").appendTo(localBranchBox);
$('<div class="sidebar-version-control-slide-box-header"></div>').text(RED._("sidebar.project.versionControl.changeLocalBranch")).appendTo(localBranchBox);
var localBranchList = utils.createBranchList({
placeholder: "Find or create a branch",
placeholder: RED._("sidebar.project.versionControl.createBranchPlaceholder"),
container: localBranchBox,
onselect: function(body) {
if (body.current) {
@@ -659,7 +705,7 @@ RED.sidebar.versionControl = (function() {
400: {
'git_local_overwrite': function(error) {
spinner.remove();
RED.notify("You have local changes that would be overwritten by changing the branch. You must either commit or undo those changes first.",{
RED.notify(RED._("sidebar.project.versionControl.localOverwrite"),{
type:'error',
timeout: 8000
});
@@ -702,10 +748,10 @@ RED.sidebar.versionControl = (function() {
},200);
}
}
$('<div class="sidebar-version-control-slide-box-header"></div>').text("Manage remote branch").appendTo(remoteBox);
$('<div class="sidebar-version-control-slide-box-header"></div>').text(RED._("sidebar.project.versionControl.manageRemoteBranch")).appendTo(remoteBox);
var remoteBranchRow = $('<div style="margin-bottom: 5px;"></div>').appendTo(remoteBox);
var remoteBranchButton = $('<button id="sidebar-version-control-repo-branch" class="sidebar-version-control-repo-action editor-button"><i class="fa fa-code-fork"></i> Remote: <span id="sidebar-version-control-remote-branch"></span></button>')
var remoteBranchButton = $('<button id="sidebar-version-control-repo-branch" class="sidebar-version-control-repo-action editor-button"><i class="fa fa-code-fork"></i> '+RED._("sidebar.project.versionControl.remote")+': <span id="sidebar-version-control-remote-branch"></span></button>')
.appendTo(remoteBranchRow)
.click(function(evt) {
evt.preventDefault();
@@ -728,9 +774,9 @@ RED.sidebar.versionControl = (function() {
var errorMessage = $('<div id="sidebar-version-control-repo-toolbar-error-message" class="sidebar-version-control-slide-box-header" style="min-height: 100px;"></div>').hide().appendTo(remoteBox);
$('<div style="margin-top: 10px;"><i class="fa fa-warning"></i> Unable to access remote repository</div>').appendTo(errorMessage)
$('<div style="margin-top: 10px;"><i class="fa fa-warning"></i> '+RED._("sidebar.project.versionControl.unableToAccess")+'</div>').appendTo(errorMessage)
var buttonRow = $('<div style="margin: 10px 30px; text-align: center"></div>').appendTo(errorMessage);
$('<button class="editor-button" style="width: 80%;"><i class="fa fa-refresh"></i> Retry</button>')
$('<button class="editor-button" style="width: 80%;"><i class="fa fa-refresh"></i> '+RED._("sidebar.project.versionControl.retry")+'</button>')
.appendTo(buttonRow)
.click(function(e) {
e.preventDefault();
@@ -749,7 +795,13 @@ RED.sidebar.versionControl = (function() {
},
400: {
'git_connection_failed': function(error) {
RED.notify(error.message);
RED.notify(error.message,'error');
},
'git_not_a_repository': function(error) {
RED.notify(error.message,'error');
},
'git_repository_not_found': function(error) {
RED.notify(error.message,'error');
},
'unexpected_error': function(error) {
console.log(error);
@@ -762,12 +814,12 @@ RED.sidebar.versionControl = (function() {
});
})
$('<div class="sidebar-version-control-slide-box-header" style="height: 20px;"><label id="sidebar-version-control-repo-toolbar-set-upstream-row" for="sidebar-version-control-repo-toolbar-set-upstream" class="hide"><input type="checkbox" id="sidebar-version-control-repo-toolbar-set-upstream"> Set as upstream branch</label></div>').appendTo(remoteBox);
$('<div class="sidebar-version-control-slide-box-header" style="height: 20px;"><label id="sidebar-version-control-repo-toolbar-set-upstream-row" for="sidebar-version-control-repo-toolbar-set-upstream" class="hide"><input type="checkbox" id="sidebar-version-control-repo-toolbar-set-upstream"> '+RED._("sidebar.project.versionControl.setUpstreamBranch")+'</label></div>').appendTo(remoteBox);
var remoteBranchSubRow = $('<div style="height: 0;overflow:hidden; transition: height 0.2s ease-in-out;"></div>').hide().appendTo(remoteBranchRow);
var remoteBranchList = utils.createBranchList({
placeholder: "Find or create a remote branch",
currentLabel: "upstream",
placeholder: RED._("sidebar.project.versionControl.createRemoteBranchPlaceholder"),
currentLabel: RED._("sidebar.project.versionControl.upstream"),
remote: function() {
var project = RED.projects.getActiveProject();
var remotes = Object.keys(project.git.remotes);
@@ -797,11 +849,11 @@ RED.sidebar.versionControl = (function() {
})
} else {
if (!activeProject.git.branches.remote) {
$('#sidebar-version-control-repo-toolbar-message').text("The created branch will be set as the tracked upstream branch.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.trackedUpstreamBranch"));
$("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked',true);
$("#sidebar-version-control-repo-toolbar-set-upstream").prop('disabled',true);
} else {
$('#sidebar-version-control-repo-toolbar-message').text("The branch will be created. Select below to set it as the tracked upstream branch.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.selectUpstreamBranch"));
}
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',false);
@@ -813,7 +865,7 @@ RED.sidebar.versionControl = (function() {
var row = $('<div style="margin-bottom: 5px;"></div>').appendTo(remoteBox);
$('<button id="sidebar-version-control-repo-push" class="sidebar-version-control-repo-sub-action editor-button"><i class="fa fa-long-arrow-up"></i> <span>push</span></button>')
$('<button id="sidebar-version-control-repo-push" class="sidebar-version-control-repo-sub-action editor-button"><i class="fa fa-long-arrow-up"></i> <span data-i18n="sidebar.project.versionControl.push"></span></button>')
.appendTo(row)
.click(function(e) {
e.preventDefault();
@@ -823,7 +875,8 @@ RED.sidebar.versionControl = (function() {
if (activeProject.git.branches.remoteAlt) {
url+="/"+activeProject.git.branches.remoteAlt;
}
if ($("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked')) {
var setUpstream = $("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked');
if (setUpstream) {
url+="?u=true"
}
utils.sendRequest({
@@ -835,13 +888,17 @@ RED.sidebar.versionControl = (function() {
// done(error,null);
},
200: function(data) {
if (setUpstream && activeProject.git.branches.remoteAlt) {
activeProject.git.branches.remote = activeProject.git.branches.remoteAlt;
delete activeProject.git.branches.remoteAlt;
}
refresh(true);
closeRemoteBox();
},
400: {
'git_push_failed': function(err) {
// TODO: better message + NLS
RED.notify("NLS: Push failed as the remote has more recent commits. Pull first and write a better error message!","error");
// TODO: better message
RED.notify(RED._("sidebar.project.versionControl.pushFailed"),"error");
},
'unexpected_error': function(error) {
console.log(error);
@@ -854,54 +911,91 @@ RED.sidebar.versionControl = (function() {
});
});
$('<button id="sidebar-version-control-repo-pull" class="sidebar-version-control-repo-sub-action editor-button"><i class="fa fa-long-arrow-down"></i> <span>pull</span></button>')
.appendTo(row)
.click(function(e) {
e.preventDefault();
var spinner = utils.addSpinnerOverlay(remoteBox).addClass("projects-dialog-spinner-contain");
var activeProject = RED.projects.getActiveProject();
var url = "projects/"+activeProject.name+"/pull";
if (activeProject.git.branches.remoteAlt) {
url+="/"+activeProject.git.branches.remoteAlt;
var pullRemote = function(options) {
options = options || {};
var spinner = utils.addSpinnerOverlay(remoteBox).addClass("projects-dialog-spinner-contain");
var activeProject = RED.projects.getActiveProject();
var url = "projects/"+activeProject.name+"/pull";
if (activeProject.git.branches.remoteAlt) {
url+="/"+activeProject.git.branches.remoteAlt;
}
if (options.setUpstream || options.allowUnrelatedHistories) {
url+="?";
}
if (options.setUpstream) {
url += "setUpstream=true"
if (options.allowUnrelatedHistories) {
url += "&";
}
if ($("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked')) {
url+="?u=true"
}
utils.sendRequest({
url: url,
type: "POST",
responses: {
0: function(error) {
console.log(error);
// done(error,null);
}
if (options.allowUnrelatedHistories) {
url += "allowUnrelatedHistories=true"
}
utils.sendRequest({
url: url,
type: "POST",
responses: {
0: function(error) {
console.log(error);
// done(error,null);
},
200: function(data) {
if (options.setUpstream && activeProject.git.branches.remoteAlt) {
activeProject.git.branches.remote = activeProject.git.branches.remoteAlt;
delete activeProject.git.branches.remoteAlt;
}
refresh(true);
closeRemoteBox();
},
400: {
'git_local_overwrite': function(err) {
RED.notify(RED._("sidebar.project.versionControl.unablePull")+
'<p><a href="#" onclick="RED.sidebar.versionControl.showLocalChanges(); return false;">'+RED._("sidebar.project.versionControl.showUnstagedChanges")+'</a></p>',"error",false,10000000);
},
200: function(data) {
'git_pull_merge_conflict': function(err) {
refresh(true);
closeRemoteBox();
},
400: {
'git_local_overwrite': function(err) {
RED.notify("Unable to pull remote changes; your unstaged local changes would be overwritten. Commit your changes and try again."+
'<p><a href="#" onclick="RED.sidebar.versionControl.showLocalChanges(); return false;">'+'Show unstaged changes'+'</a></p>',"error",false,10000000);
},
'git_pull_merge_conflict': function(err) {
refresh(true);
},
'git_connection_failed': function(err) {
RED.notify("Could not connect to remote repository: "+err.toString(),"warning")
},
'unexpected_error': function(error) {
console.log(error);
// done(error,null);
},
'git_pull_unrelated_history': function(error) {
RED.notify("Unable to pull remote changes; refusing to merge unrelated histories.","error");
}
'git_connection_failed': function(err) {
RED.notify(RED._("sidebar.project.versionControl.connectionFailed")+err.toString(),"warning")
},
}
},{}).always(function() {
spinner.remove();
'git_pull_unrelated_history': function(error) {
var notification = RED.notify(RED._("sidebar.project.versionControl.pullUnrelatedHistory"),{
type: 'error',
modal: true,
fixed: true,
buttons: [
{
text: RED._("common.label.cancel"),
click: function() {
notification.close();
}
},{
text: RED._("sidebar.project.versionControl.pullChanges"),
click: function() {
notification.close();
options.allowUnrelatedHistories = true;
pullRemote(options)
}
}
]
});
},
'*': function(error) {
utils.reportUnexpectedError(error);
}
},
}
},{}).always(function() {
spinner.remove();
});
}
$('<button id="sidebar-version-control-repo-pull" class="sidebar-version-control-repo-sub-action editor-button"><i class="fa fa-long-arrow-down"></i> <span data-i18n="sidebar.project.versionControl.pull"></span></button>')
.appendTo(row)
.click(function(e) {
e.preventDefault();
pullRemote({
setUpstream: $("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked')
});
});
@@ -909,10 +1003,12 @@ RED.sidebar.versionControl = (function() {
RED.sidebar.addTab({
id: "version-control",
label: "history",
label: RED._("sidebar.project.versionControl.history"),
name: "Project History",
content: sidebarContent,
enableOnEdit: false,
pinned: true,
iconClass: "fa fa-code-fork",
onchange: function() {
setTimeout(function() {
sections.resize();
@@ -929,17 +1025,17 @@ RED.sidebar.versionControl = (function() {
if (daysDelta > 30) {
return (new Date(date*1000)).toLocaleDateString();
} else if (daysDelta > 0) {
return daysDelta+" day"+(daysDelta>1?"s":"")+" ago";
return RED._("sidebar.project.versionControl.daysAgo", {count:daysDelta})
}
var hoursDelta = Math.floor(delta / (60*60));
if (hoursDelta > 0) {
return hoursDelta+" hour"+(hoursDelta>1?"s":"")+" ago";
return RED._("sidebar.project.versionControl.hoursAgo", {count:hoursDelta})
}
var minutesDelta = Math.floor(delta / 60);
if (minutesDelta > 0) {
return minutesDelta+" minute"+(minutesDelta>1?"s":"")+" ago";
return RED._("sidebar.project.versionControl.minsAgo", {count:minutesDelta})
}
return "Seconds ago";
return RED._("sidebar.project.versionControl.secondsAgo");
}
function updateBulk(files,unstaged) {
@@ -974,9 +1070,6 @@ RED.sidebar.versionControl = (function() {
var refreshInProgress = false;
var emptyStagedItem = { label:"None" };
var emptyMergedItem = { label:"All conflicts resolved. Commit the changes to complete the merge." };
function getCommits(url,targetList,spinnerTarget,limit,before) {
var spinner = utils.addSpinnerOverlay(spinnerTarget);
var fullUrl = url+"?limit="+(limit||20);
@@ -1039,16 +1132,6 @@ RED.sidebar.versionControl = (function() {
// }
// }
function showMergeConflictNotification() {
if (isMerging) {
mergeConflictNotification = RED.notify("NLS: Automatic merging of remote changes failed. Fix the unmerged conflicts then commit the results."+
'<p><a href="#" onclick="RED.sidebar.versionControl.showLocalChanges(); return false;">'+'Show merge conflicts'+'</a></p>',"error",true);
}
}
function refreshFiles(result) {
var files = result.files;
if (bulkChangeSpinner) {
@@ -1057,16 +1140,9 @@ RED.sidebar.versionControl = (function() {
}
isMerging = !!result.merging;
if (isMerging) {
if (!mergeConflictNotification) {
showMergeConflictNotification();
}
sidebarContent.addClass("sidebar-version-control-merging");
unmergedContent.show();
} else {
if (mergeConflictNotification) {
mergeConflictNotification.close();
mergeConflictNotification = null;
}
sidebarContent.removeClass("sidebar-version-control-merging");
unmergedContent.hide();
}
@@ -1173,7 +1249,7 @@ RED.sidebar.versionControl = (function() {
}
}
function refresh(full) {
function refresh(full, includeRemote) {
if (refreshInProgress) {
return;
}
@@ -1193,11 +1269,15 @@ RED.sidebar.versionControl = (function() {
var activeProject = RED.projects.getActiveProject();
if (activeProject) {
$.getJSON("projects/"+activeProject.name+"/status",function(result) {
var url = "projects/"+activeProject.name+"/status";
if (includeRemote) {
url += "?remote=true"
}
$.getJSON(url,function(result) {
refreshFiles(result);
$('#sidebar-version-control-local-branch').text(result.branches.local);
$('#sidebar-version-control-remote-branch').text(result.branches.remote||"none");
$('#sidebar-version-control-remote-branch').text(result.branches.remote||RED._("sidebar.project.versionControl.none"));
var commitsAhead = result.commits.ahead || 0;
var commitsBehind = result.commits.behind || 0;
@@ -1227,7 +1307,7 @@ RED.sidebar.versionControl = (function() {
$('#sidebar-version-control-commits-ahead').text("");
$('#sidebar-version-control-commits-behind').text("");
$('#sidebar-version-control-repo-toolbar-message').text("Your local branch is not currently tracking a remote branch.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.notTracking"));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
}
@@ -1237,6 +1317,8 @@ RED.sidebar.versionControl = (function() {
}
refreshInProgress = false;
$('.sidebar-version-control-shade').hide();
}).fail(function() {
refreshInProgress = false;
});
} else {
$('.sidebar-version-control-shade').show();
@@ -1251,23 +1333,26 @@ RED.sidebar.versionControl = (function() {
$('#sidebar-version-control-commits-ahead').text(commitsAhead);
$('#sidebar-version-control-commits-behind').text(commitsBehind);
if (isMerging) {
$('#sidebar-version-control-repo-toolbar-message').text("Your repository has unmerged changes. You need to fix the conflicts and commit the result.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.statusUnmergedChanged"));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
} else if (commitsAhead > 0 && commitsBehind === 0) {
$('#sidebar-version-control-repo-toolbar-message').text("Your repository is "+commitsAhead+" commit"+(commitsAhead===1?'':'s')+" ahead of the remote. You can push "+(commitsAhead===1?'this commit':'these commits')+" now.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.commitsAhead", {count:commitsAhead}));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',false);
} else if (commitsAhead === 0 && commitsBehind > 0) {
$('#sidebar-version-control-repo-toolbar-message').text("Your repository is "+commitsBehind+" commit"+(commitsBehind===1?'':'s')+" behind of the remote. You can pull "+(commitsBehind===1?'this commit':'these commits')+" now.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.commitsBehind",{ count: commitsBehind }));
$("#sidebar-version-control-repo-pull").attr('disabled',false);
$("#sidebar-version-control-repo-push").attr('disabled',true);
} else if (commitsAhead > 0 && commitsBehind > 0) {
$('#sidebar-version-control-repo-toolbar-message').text("Your repository is "+commitsBehind+" commit"+(commitsBehind===1?'':'s')+" behind and "+commitsAhead+" commit"+(commitsAhead===1?'':'s')+" ahead of the remote. You must pull the remote commit"+(commitsBehind===1?'':'s')+" down before pushing.");
$('#sidebar-version-control-repo-toolbar-message').text(
RED._("sidebar.project.versionControl.commitsAheadAndBehind1",{ count:commitsBehind })+
RED._("sidebar.project.versionControl.commitsAheadAndBehind2",{ count:commitsAhead })+
RED._("sidebar.project.versionControl.commitsAheadAndBehind3",{ count:commitsBehind }));
$("#sidebar-version-control-repo-pull").attr('disabled',false);
$("#sidebar-version-control-repo-push").attr('disabled',true);
} else if (commitsAhead === 0 && commitsBehind === 0) {
$('#sidebar-version-control-repo-toolbar-message').text("Your repository is up to date.");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.repositoryUpToDate"));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
}

View File

@@ -26,6 +26,24 @@ RED.search = (function() {
var keys = [];
var results = [];
function indexProperty(node,label,property) {
if (typeof property === 'string' || typeof property === 'number') {
property = (""+property).toLowerCase();
index[property] = index[property] || {};
index[property][node.id] = {node:node,label:label};
} else if (Array.isArray(property)) {
property.forEach(function(prop) {
indexProperty(node,label,prop);
})
} else if (typeof property === 'object') {
for (var prop in property) {
if (property.hasOwnProperty(prop)) {
indexProperty(node,label,property[prop])
}
}
}
}
function indexNode(n) {
var l = RED.utils.getNodeLabel(n);
if (l) {
@@ -42,17 +60,11 @@ RED.search = (function() {
}
for (var i=0;i<properties.length;i++) {
if (n.hasOwnProperty(properties[i])) {
var v = n[properties[i]];
if (typeof v === 'string' || typeof v === 'number') {
v = (""+v).toLowerCase();
index[v] = index[v] || {};
index[v][n.id] = {node:n,label:l};
}
indexProperty(n, l, n[properties[i]]);
}
}
}
function indexWorkspace() {
index = {};
RED.nodes.eachWorkspace(indexNode);
@@ -174,14 +186,14 @@ RED.search = (function() {
addItem: function(container,i,object) {
var node = object.node;
if (node === undefined) {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
} else {
var def = node._def;
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
var colour = def.color;
var colour = RED.utils.getNodeColor(node.type,def);
var icon_url = RED.utils.getNodeIcon(def,node);
if (node.type === 'tab') {
colour = "#C0DEED";
@@ -200,12 +212,12 @@ RED.search = (function() {
} else {
workspace = "flow:"+workspace.label;
}
$('<div>',{class:"red-ui-search-result-node-flow"}).html(workspace).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-flow"}).text(workspace).appendTo(contentDiv);
}
$('<div>',{class:"red-ui-search-result-node-label"}).html(object.label || node.id).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-type"}).html(node.type).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-id"}).html(node.id).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-label"}).text(object.label || node.id).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-type"}).text(node.type).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-id"}).text(node.id).appendTo(contentDiv);
div.click(function(evt) {
evt.preventDefault();

View File

@@ -35,7 +35,8 @@ RED.sidebar = (function() {
tab.onremove.call(tab);
}
},
minimumActiveTabWidth: 70
// minimumActiveTabWidth: 70,
collapsible: true
// scrollable: true
});
@@ -59,6 +60,8 @@ RED.sidebar = (function() {
options = title;
}
delete options.closeable;
options.wrapper = $('<div>',{style:"height:100%"}).appendTo("#sidebar-content")
options.wrapper.append(options.content);
options.wrapper.hide();
@@ -82,6 +85,8 @@ RED.sidebar = (function() {
group: "sidebar-tabs"
});
options.iconClass = options.iconClass || "fa fa-square-o"
knownTabs[options.id] = options;
if (options.visible !== false) {
@@ -213,6 +218,7 @@ RED.sidebar = (function() {
showSidebar();
RED.sidebar.info.init();
RED.sidebar.config.init();
RED.sidebar.context.init();
// hide info bar at start if screen rather narrow...
if ($(window).width() < 600) { RED.menu.setSelected("menu-item-sidebar",false); }
}

View File

@@ -23,5 +23,6 @@ RED.state = {
EXPORT: 6,
IMPORT: 7,
IMPORT_DRAGGING: 8,
QUICK_JOINING: 9
QUICK_JOINING: 9,
PANNING: 10
}

View File

@@ -139,7 +139,7 @@ RED.subflow = (function() {
RED.view.select();
RED.nodes.dirty(true);
RED.view.redraw();
$("#workspace-subflow-output .spinner-value").html(subflow.out.length);
$("#workspace-subflow-output .spinner-value").text(subflow.out.length);
}
function removeSubflowOutput(removedSubflowOutputs) {
@@ -216,7 +216,7 @@ RED.subflow = (function() {
$("#workspace-subflow-input-add").toggleClass("active", activeSubflow.in.length !== 0);
$("#workspace-subflow-input-remove").toggleClass("active",activeSubflow.in.length === 0);
$("#workspace-subflow-output .spinner-value").html(activeSubflow.out.length);
$("#workspace-subflow-output .spinner-value").text(activeSubflow.out.length);
}
}

View File

@@ -221,8 +221,7 @@ RED.sidebar.config = (function() {
name: RED._("sidebar.config.name"),
content: content,
toolbar: toolbar,
closeable: true,
visible: false,
iconClass: "fa fa-cog",
onchange: function() { refreshConfigNodeList(); }
});
RED.actions.add("core:show-config-tab",function() {RED.sidebar.show('config')});

292
editor/js/ui/tab-context.js Normal file
View File

@@ -0,0 +1,292 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.sidebar.context = (function() {
var content;
var sections;
var localCache = {};
var nodeSection;
// var subflowSection;
var flowSection;
var globalSection;
var currentNode;
var currentFlow;
function init() {
content = $("<div>").css({"position":"relative","height":"100%"});
content.className = "sidebar-context"
// var toolbar = $('<div class="sidebar-header">'+
// '</div>').appendTo(content);
var footerToolbar = $('<div>'+
// '<span class="button-group"><a class="sidebar-footer-button" href="#" data-i18n="[title]node-red:debug.sidebar.openWindow"><i class="fa fa-desktop"></i></a></span> ' +
'</div>');
var stackContainer = $("<div>",{class:"sidebar-context-stack"}).appendTo(content);
sections = RED.stack.create({
container: stackContainer
});
nodeSection = sections.add({
title: RED._("sidebar.context.node"),
collapsible: true,
// onexpand: function() {
// updateNode(currentNode,true);
// }
});
nodeSection.expand();
nodeSection.content.css({height:"100%"});
nodeSection.timestamp = $('<div class="sidebar-context-updated">&nbsp;</div>').appendTo(nodeSection.content);
var table = $('<table class="node-info"></table>').appendTo(nodeSection.content);
nodeSection.table = $('<tbody>').appendTo(table);
var bg = $('<div style="float: right"></div>').appendTo(nodeSection.header);
$('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.stopPropagation();
evt.preventDefault();
updateNode(currentNode, true);
})
// subflowSection = sections.add({
// title: "Subflow",
// collapsible: true
// });
// subflowSection.expand();
// subflowSection.content.css({height:"100%"});
// bg = $('<div style="float: right"></div>').appendTo(subflowSection.header);
// $('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
// .appendTo(bg)
// .click(function(evt) {
// evt.stopPropagation();
// evt.preventDefault();
// })
//
// subflowSection.container.hide();
flowSection = sections.add({
title: RED._("sidebar.context.flow"),
collapsible: true
});
flowSection.expand();
flowSection.content.css({height:"100%"});
flowSection.timestamp = $('<div class="sidebar-context-updated">&nbsp;</div>').appendTo(flowSection.content);
var table = $('<table class="node-info"></table>').appendTo(flowSection.content);
flowSection.table = $('<tbody>').appendTo(table);
bg = $('<div style="float: right"></div>').appendTo(flowSection.header);
$('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.stopPropagation();
evt.preventDefault();
updateFlow(currentFlow);
})
globalSection = sections.add({
title: RED._("sidebar.context.global"),
collapsible: true
});
globalSection.expand();
globalSection.content.css({height:"100%"});
globalSection.timestamp = $('<div class="sidebar-context-updated">&nbsp;</div>').appendTo(globalSection.content);
var table = $('<table class="node-info"></table>').appendTo(globalSection.content);
globalSection.table = $('<tbody>').appendTo(table);
bg = $('<div style="float: right"></div>').appendTo(globalSection.header);
$('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.stopPropagation();
evt.preventDefault();
updateEntry(globalSection,"context/global","global");
})
RED.actions.add("core:show-context-tab",show);
RED.sidebar.addTab({
id: "context",
label: RED._("sidebar.context.label"),
name: RED._("sidebar.context.name"),
iconClass: "fa fa-database",
content: content,
toolbar: footerToolbar,
// pinned: true,
enableOnEdit: false
});
// var toggleLiveButton = $("#sidebar-context-toggle-live");
// toggleLiveButton.click(function(evt) {
// evt.preventDefault();
// if ($(this).hasClass("selected")) {
// $(this).removeClass("selected");
// $(this).find("i").removeClass("fa-pause");
// $(this).find("i").addClass("fa-play");
// } else {
// $(this).addClass("selected");
// $(this).find("i").removeClass("fa-play");
// $(this).find("i").addClass("fa-pause");
// }
// });
// RED.popover.tooltip(toggleLiveButton, function() {
// if (toggleLiveButton.hasClass("selected")) {
// return "Pause live updates"
// } else {
// return "Start live updates"
// }
// });
RED.events.on("view:selection-changed", function(event) {
var selectedNode = event.nodes && event.nodes.length === 1 && event.nodes[0];
updateNode(selectedNode);
})
RED.events.on("workspace:change", function(event) {
updateFlow(RED.nodes.workspace(event.workspace));
})
updateEntry(globalSection,"context/global","global");
}
function updateNode(node,force) {
currentNode = node;
if (force) {
if (node) {
updateEntry(nodeSection,"context/node/"+node.id,node.id);
// if (/^subflow:/.test(node.type)) {
// subflowSection.container.show();
// updateEntry(subflowSection,"context/flow/"+node.id,node.id);
// } else {
// subflowSection.container.hide();
// }
} else {
// subflowSection.container.hide();
updateEntry(nodeSection)
}
} else {
$(nodeSection.table).empty();
if (node) {
$('<tr class="node-info-node-row red-ui-search-empty blank" colspan="2"><td data-i18n="sidebar.context.refresh"></td></tr>').appendTo(nodeSection.table).i18n();
} else {
$('<tr class="node-info-node-row red-ui-search-empty blank" colspan="2"><td data-i18n="sidebar.context.none"></td></tr>').appendTo(nodeSection.table).i18n();
}
nodeSection.timestamp.html("&nbsp;");
}
}
function updateFlow(flow) {
currentFlow = flow;
if (flow) {
updateEntry(flowSection,"context/flow/"+flow.id,flow.id);
} else {
updateEntry(flowSection)
}
}
function refreshEntry(section,baseUrl,id) {
var contextStores = RED.settings.context.stores;
var container = section.table;
$.getJSON(baseUrl, function(data) {
$(container).empty();
var sortedData = {};
for (var store in data) {
if (data.hasOwnProperty(store)) {
for (var key in data[store]) {
if (data[store].hasOwnProperty(key)) {
if (!sortedData.hasOwnProperty(key)) {
sortedData[key] = [];
}
data[store][key].store = store;
sortedData[key].push(data[store][key])
}
}
}
}
var keys = Object.keys(sortedData);
keys.sort();
var l = keys.length;
for (var i = 0; i < l; i++) {
sortedData[keys[i]].forEach(function(v) {
var k = keys[i];
var l2 = sortedData[k].length;
var propRow = $('<tr class="node-info-node-row"><td class="sidebar-context-property"></td><td></td></tr>').appendTo(container);
var obj = $(propRow.children()[0]);
obj.text(k);
var tools = $('<span class="debug-message-tools button-group"></span>').appendTo(obj);
var refreshItem = $('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>').appendTo(tools).click(function(e) {
e.preventDefault();
e.stopPropagation();
$.getJSON(baseUrl+"/"+k+"?store="+v.store, function(data) {
$(propRow.children()[1]).empty();
var payload = data.msg;
var format = data.format;
payload = RED.utils.decodeObject(payload,format);
RED.utils.createObjectElement(payload, {
typeHint: data.format,
sourceId: id+"."+k
}).appendTo(propRow.children()[1]);
})
});
var payload = v.msg;
var format = v.format;
payload = RED.utils.decodeObject(payload,format);
RED.utils.createObjectElement(payload, {
typeHint: v.format,
sourceId: id+"."+k
}).appendTo(propRow.children()[1]);
if (contextStores.length > 1) {
$("<span>",{class:"sidebar-context-property-storename"}).text(v.store).appendTo($(propRow.children()[0]))
}
});
}
if (l === 0) {
$('<tr class="node-info-node-row red-ui-search-empty blank" colspan="2"><td data-i18n="sidebar.context.empty"></td></tr>').appendTo(container).i18n();
}
$(section.timestamp).text(new Date().toLocaleString());
});
}
function updateEntry(section,baseUrl,id) {
var container = section.table;
if (id) {
refreshEntry(section,baseUrl,id);
} else {
$(container).empty();
$('<tr class="node-info-node-row red-ui-search-empty blank" colspan="2"><td data-i18n="sidebar.context.none"></td></tr>').appendTo(container).i18n();
}
}
function show() {
RED.sidebar.show("context");
}
return {
init: init
}
})();

View File

@@ -83,7 +83,9 @@ RED.sidebar.info = (function() {
id: "info",
label: RED._("sidebar.info.label"),
name: RED._("sidebar.info.name"),
iconClass: "fa fa-info",
content: content,
pinned: true,
enableOnEdit: true
});
if (tips.enabled()) {
@@ -167,24 +169,42 @@ RED.sidebar.info = (function() {
$(propRow.children()[1]).text(node.label||node.name||"");
if (node.type === "tab") {
propRow = $('<tr class="node-info-node-row"><td>'+RED._("sidebar.info.status")+'</td><td></td></tr>').appendTo(tableBody);
$(propRow.children()[1]).html((!!!node.disabled)?RED._("sidebar.info.enabled"):RED._("sidebar.info.disabled"))
$(propRow.children()[1]).text((!!!node.disabled)?RED._("sidebar.info.enabled"):RED._("sidebar.info.disabled"))
} else if (node.type === "subflow") {
propRow = $('<tr class="node-info-node-row"><td>'+RED._("subflow.category")+'</td><td></td></tr>').appendTo(tableBody);
var category = node.category||"subflows";
$(propRow.children()[1]).text(RED._("palette.label."+category,{defaultValue:category}))
}
} else {
propRow = $('<tr class="node-info-node-row"><td>'+RED._("sidebar.info.node")+"</td><td></td></tr>").appendTo(tableBody);
RED.utils.createObjectElement(node.id).appendTo(propRow.children()[1]);
if (node.type !== "subflow" && node.name) {
$('<tr class="node-info-node-row"><td>'+RED._("common.label.name")+'</td><td><span class="bidiAware" dir="'+RED.text.bidi.resolveBaseTextDir(node.name)+'">'+node.name+'</span></td></tr>').appendTo(tableBody);
if (node.type !== "subflow" && node.type !== "unknown" && node.name) {
propRow = $('<tr class="node-info-node-row"><td>'+RED._("common.label.name")+'</td><td></td></tr>').appendTo(tableBody);
$('<span class="bidiAware" dir="'+RED.text.bidi.resolveBaseTextDir(node.name)+'"></span>').text(node.name).appendTo(propRow.children()[1]);
}
if (!m) {
$('<tr class="node-info-node-row"><td>'+RED._("sidebar.info.type")+"</td><td>"+node.type+"</td></tr>").appendTo(tableBody);
propRow = $('<tr class="node-info-node-row"><td>'+RED._("sidebar.info.type")+"</td><td></td></tr>").appendTo(tableBody);
$(propRow.children()[1]).text((node.type === "unknown")?node._orig.type:node.type);
if (node.type === "unknown") {
$('<span style="float: right; font-size: 0.8em"><i class="fa fa-warning"></i></span>').prependTo($(propRow.children()[1]))
}
}
if (!m && node.type != "subflow" && node.type != "comment") {
if (node._def) {
var defaults;
if (node.type === 'unknown') {
defaults = {};
Object.keys(node._orig).forEach(function(k) {
if (k !== 'type') {
defaults[k] = {};
}
})
} else if (node._def) {
defaults = node._def.defaults;
}
if (defaults) {
var count = 0;
var defaults = node._def.defaults;
for (var n in defaults) {
if (n != "name" && defaults.hasOwnProperty(n)) {
var val = node[n];
@@ -201,12 +221,12 @@ RED.sidebar.info = (function() {
var div = $('<span>',{class:""}).appendTo(container);
var nodeDiv = $('<div>',{class:"palette_node palette_node_small"}).appendTo(div);
var colour = configNode._def.color;
var colour = RED.utils.getNodeColor(configNode.type,configNode._def);
var icon_url = RED.utils.getNodeIcon(configNode._def);
nodeDiv.css({'backgroundColor':colour, "cursor":"pointer"});
var iconContainer = $('<div/>',{class:"palette_icon_container"}).appendTo(nodeDiv);
$('<div/>',{class:"palette_icon",style:"background-image: url("+icon_url+")"}).appendTo(iconContainer);
var nodeContainer = $('<span></span>').css({"verticalAlign":"top","marginLeft":"6px"}).html(configLabel).appendTo(container);
var nodeContainer = $('<span></span>').css({"verticalAlign":"top","marginLeft":"6px"}).text(configLabel).appendTo(container);
nodeDiv.on('dblclick',function() {
RED.editor.editConfig("", configNode.type, configNode.id);
@@ -231,24 +251,27 @@ RED.sidebar.info = (function() {
}
}
if (m) {
propRow = $('<tr class="node-info-node-row"><td>'+RED._("subflow.category")+'</td><td></td></tr>').appendTo(tableBody);
var category = subflowNode.category||"subflows";
$(propRow.children()[1]).text(RED._("palette.label."+category,{defaultValue:category}))
$('<tr class="node-info-subflow-row"><td>'+RED._("sidebar.info.instances")+"</td><td>"+subflowUserCount+'</td></tr>').appendTo(tableBody);
}
var infoText = "";
if (!subflowNode && node.type !== "comment" && node.type !== "tab") {
infoSection.title.html(RED._("sidebar.info.nodeHelp"));
infoSection.title.text(RED._("sidebar.info.nodeHelp"));
var helpText = $("script[data-help-name='"+node.type+"']").html()||('<span class="node-info-none">'+RED._("sidebar.info.none")+'</span>');
infoText = helpText;
} else if (node.type === "tab") {
infoSection.title.html(RED._("sidebar.info.flowDesc"));
infoSection.title.text(RED._("sidebar.info.flowDesc"));
infoText = marked(node.info||"")||('<span class="node-info-none">'+RED._("sidebar.info.none")+'</span>');
}
if (subflowNode) {
infoText = infoText + (marked(subflowNode.info||"")||('<span class="node-info-none">'+RED._("sidebar.info.none")+'</span>'));
infoSection.title.html(RED._("sidebar.info.subflowDesc"));
infoSection.title.text(RED._("sidebar.info.subflowDesc"));
} else if (node._def && node._def.info) {
infoSection.title.html(RED._("sidebar.info.nodeHelp"));
infoSection.title.text(RED._("sidebar.info.nodeHelp"));
var info = node._def.info;
var textInfo = (typeof info === "function" ? info.call(node) : info);
// TODO: help
@@ -257,8 +280,7 @@ RED.sidebar.info = (function() {
if (infoText) {
setInfoText(infoText);
}
$(".sidebar-node-info-stack").scrollTop(0);
$(".node-info-property-header").click(function(e) {
e.preventDefault();
expandedSections["property"] = !expandedSections["property"];
@@ -372,10 +394,9 @@ RED.sidebar.info = (function() {
function set(html,title) {
// tips.stop();
// sections.show();
// nodeSection.container.hide();
infoSection.title.text(title||"");
refresh(null);
$(infoSection.content).empty();
nodeSection.container.hide();
infoSection.title.text(title||RED._("sidebar.info.info"));
setInfoText(html);
$(".sidebar-node-info-stack").scrollTop(0);
}

View File

@@ -52,7 +52,7 @@ RED.tray = (function() {
b.attr('id',button.id);
}
if (button.text) {
b.html(button.text);
b.text(button.text);
}
if (button.click) {
b.click((function(action) {

View File

@@ -128,7 +128,7 @@ RED.typeSearch = (function() {
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
var colour = def.color;
var colour = RED.utils.getNodeColor(object.type,def);
var icon_url = RED.utils.getNodeIcon(def);
nodeDiv.css('backgroundColor',colour);
@@ -147,7 +147,7 @@ RED.typeSearch = (function() {
var label = object.label;
object.index += "|"+label.toLowerCase();
$('<div>',{class:"red-ui-search-result-node-label"}).html(label).appendTo(contentDiv);
$('<div>',{class:"red-ui-search-result-node-label"}).text(label).appendTo(contentDiv);
div.click(function(evt) {
evt.preventDefault();

View File

@@ -26,14 +26,18 @@ RED.utils = (function() {
function buildMessageSummaryValue(value) {
var result;
if (Array.isArray(value)) {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').html('array['+value.length+']');
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').text('array['+value.length+']');
} else if (value === null) {
result = $('<span class="debug-message-object-value debug-message-type-null">null</span>');
} else if (typeof value === 'object') {
if (value.hasOwnProperty('type') && value.type === 'Buffer' && value.hasOwnProperty('data')) {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').html('buffer['+value.length+']');
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').text('buffer['+value.length+']');
} else if (value.hasOwnProperty('type') && value.type === 'array' && value.hasOwnProperty('data')) {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').html('array['+value.length+']');
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').text('array['+value.length+']');
} else if (value.hasOwnProperty('type') && value.type === 'function') {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').text('function');
} else if (value.hasOwnProperty('type') && value.type === 'number') {
result = $('<span class="debug-message-object-value debug-message-type-number"></span>').text(value.data);
} else {
result = $('<span class="debug-message-object-value debug-message-type-meta">object</span>');
}
@@ -45,6 +49,8 @@ RED.utils = (function() {
subvalue = sanitize(value);
}
result = $('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(subvalue)+'"');
} else if (typeof value === 'number') {
result = $('<span class="debug-message-object-value debug-message-type-number"></span>').text(""+value);
} else {
result = $('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+value);
}
@@ -125,7 +131,7 @@ RED.utils = (function() {
e.stopPropagation();
RED.clipboard.copyText(msg,copyPayload,"clipboard.copyMessageValue");
})
if (strippedKey !== '') {
if (strippedKey !== undefined && strippedKey !== '') {
var isPinned = pinnedPaths[sourceId].hasOwnProperty(strippedKey);
var pinPath = $('<button class="editor-button editor-button-small debug-message-tools-pin"><i class="fa fa-map-pin"></i></button>').appendTo(tools).click(function(e) {
@@ -292,19 +298,24 @@ RED.utils = (function() {
var isArray = Array.isArray(obj);
var isArrayObject = false;
if (obj && typeof obj === 'object' && obj.hasOwnProperty('type') && obj.hasOwnProperty('data') && ((obj.__encoded__ && obj.type === 'array') || obj.type === 'Buffer')) {
if (obj && typeof obj === 'object' && obj.hasOwnProperty('type') && obj.hasOwnProperty('data') && ((obj.__enc__ && obj.type === 'array') || obj.type === 'Buffer')) {
isArray = true;
isArrayObject = true;
}
if (obj === null || obj === undefined) {
$('<span class="debug-message-type-null">'+obj+'</span>').appendTo(entryObj);
} else if (obj.__enc__ && obj.type === 'number') {
e = $('<span class="debug-message-type-number debug-message-object-header"></span>').text(obj.data).appendTo(entryObj);
} else if (typeHint === "function" || (obj.__enc__ && obj.type === 'function')) {
e = $('<span class="debug-message-type-meta debug-message-object-header"></span>').text("function").appendTo(entryObj);
} else if (typeHint === "internal" || (obj.__enc__ && obj.type === 'internal')) {
e = $('<span class="debug-message-type-meta debug-message-object-header"></span>').text("[internal]").appendTo(entryObj);
} else if (typeof obj === 'string') {
if (/[\t\n\r]/.test(obj)) {
element.addClass('collapsed');
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header);
makeExpandable(header, function() {
$('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||'string').appendTo(header);
$('<span class="debug-message-type-meta debug-message-object-type-header"></span>').text(typeHint||'string').appendTo(header);
var row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
$('<pre class="debug-message-type-string"></pre>').text(obj).appendTo(row);
},function(state) {if (ontoggle) { ontoggle(path,state);}}, checkExpanded(strippedKey,expandPaths));
@@ -343,7 +354,7 @@ RED.utils = (function() {
if (originalLength === undefined) {
originalLength = data.length;
}
if (data.__encoded__) {
if (data.__enc__) {
data = data.data;
}
type = obj.type.toLowerCase();
@@ -358,7 +369,7 @@ RED.utils = (function() {
element.addClass('debug-message-buffer-raw');
}
if (key) {
headerHead = $('<span class="debug-message-type-meta"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(entryObj);
headerHead = $('<span class="debug-message-type-meta"></span>').text(typeHint||(type+'['+originalLength+']')).appendTo(entryObj);
} else {
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(entryObj);
$('<span>[ </span>').appendTo(headerHead);
@@ -381,7 +392,7 @@ RED.utils = (function() {
makeExpandable(header,function() {
if (!key) {
headerHead = $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(header);
headerHead = $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').text(typeHint||(type+'['+originalLength+']')).appendTo(header);
}
if (type === 'buffer') {
var stringRow = $('<div class="debug-message-string-rows"></div>').appendTo(element);
@@ -394,7 +405,7 @@ RED.utils = (function() {
}
$('<pre class="debug-message-type-string"></pre>').text(stringEncoding).appendTo(sr);
var bufferOpts = $('<span class="debug-message-buffer-opts"></span>').appendTo(headerHead);
var switchFormat = $('<a href="#"></a>').addClass('selected').html('raw').appendTo(bufferOpts).click(function(e) {
var switchFormat = $('<a href="#"></a>').addClass('selected').text('raw').appendTo(bufferOpts).click(function(e) {
e.preventDefault();
e.stopPropagation();
formatBuffer(element,$(this),sourceId,path,true);
@@ -471,12 +482,12 @@ RED.utils = (function() {
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header);
makeExpandable(header, function() {
if (!key) {
$('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html('object').appendTo(header);
$('<span class="debug-message-type-meta debug-message-object-type-header"></span>').text('object').appendTo(header);
}
for (i=0;i<keys.length;i++) {
var row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
var newPath = path;
if (newPath) {
if (newPath !== undefined) {
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(keys[i])) {
newPath += (newPath.length > 0?".":"")+keys[i];
} else {
@@ -507,7 +518,7 @@ RED.utils = (function() {
checkExpanded(strippedKey,expandPaths));
}
if (key) {
$('<span class="debug-message-type-meta"></span>').html('object').appendTo(entryObj);
$('<span class="debug-message-type-meta"></span>').text('object').appendTo(entryObj);
} else {
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(entryObj);
$('<span>{ </span>').appendTo(headerHead);
@@ -708,7 +719,9 @@ RED.utils = (function() {
function getDefaultNodeIcon(def,node) {
var icon_url;
if (typeof def.icon === "function") {
if (node && node.type === "subflow") {
icon_url = "node-red/subflow.png";
} else if (typeof def.icon === "function") {
try {
icon_url = def.icon.call(node);
} catch(err) {
@@ -721,11 +734,26 @@ RED.utils = (function() {
var iconPath = separateIconPath(icon_url);
if (!iconPath.module) {
iconPath.module = def.set.module;
if (def.set) {
iconPath.module = def.set.module;
} else {
// Handle subflow instance nodes that don't have def.set
iconPath.module = "node-red";
}
}
return iconPath;
}
function isIconExists(iconPath) {
var iconSets = RED.nodes.getIconSets();
var iconFileList = iconSets[iconPath.module];
if (iconFileList && iconFileList.indexOf(iconPath.file) !== -1) {
return true;
} else {
return false;
}
}
function getNodeIcon(def,node) {
if (def.category === 'config') {
return "icons/node-red/cog.png"
@@ -733,18 +761,19 @@ RED.utils = (function() {
return "icons/node-red/subflow.png"
} else if (node && node.type === 'unknown') {
return "icons/node-red/alert.png"
} else if (node && node.type === 'subflow') {
return "icons/node-red/subflow.png"
} else if (node && node.icon) {
var iconPath = separateIconPath(node.icon);
var iconSets = RED.nodes.getIconSets();
var iconFileList = iconSets[iconPath.module];
if (iconFileList && iconFileList.indexOf(iconPath.file) !== -1) {
if (isIconExists(iconPath)) {
return "icons/" + node.icon;
}
}
var iconPath = getDefaultNodeIcon(def, node);
if (def.category === 'subflows') {
if (!isIconExists(iconPath)) {
return "icons/node-red/subflow.png";
}
}
return "icons/"+iconPath.module+"/"+iconPath.file;
}
@@ -765,6 +794,41 @@ RED.utils = (function() {
return RED.text.bidi.enforceTextDirectionWithUCC(l);
}
var nodeColorCache = {};
function getNodeColor(type, def) {
var result = def.color;
var paletteTheme = RED.settings.theme('palette.theme') || [];
if (paletteTheme.length > 0) {
if (!nodeColorCache.hasOwnProperty(type)) {
nodeColorCache[type] = def.color;
var l = paletteTheme.length;
for (var i = 0; i < l; i++ ){
var themeRule = paletteTheme[i];
if (themeRule.hasOwnProperty('category')) {
if (!themeRule.hasOwnProperty('_category')) {
themeRule._category = new RegExp(themeRule.category);
}
if (!themeRule._category.test(def.category)) {
continue;
}
}
if (themeRule.hasOwnProperty('type')) {
if (!themeRule.hasOwnProperty('_type')) {
themeRule._type = new RegExp(themeRule.type);
}
if (!themeRule._type.test(type)) {
continue;
}
}
nodeColorCache[type] = themeRule.color || def.color;
break;
}
}
result = nodeColorCache[type];
}
return result;
}
function addSpinnerOverlay(container,contain) {
var spinner = $('<div class="projects-dialog-spinner "><img src="red/images/spin.svg"/></div>').appendTo(container);
if (contain) {
@@ -773,6 +837,47 @@ RED.utils = (function() {
return spinner;
}
function decodeObject(payload,format) {
if ((format === 'number') && (payload === "NaN")) {
payload = Number.NaN;
} else if ((format === 'number') && (payload === "Infinity")) {
payload = Infinity;
} else if ((format === 'number') && (payload === "-Infinity")) {
payload = -Infinity;
} else if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number' ) {
payload = JSON.parse(payload);
} else if (/error/i.test(format)) {
payload = JSON.parse(payload);
payload = (payload.name?payload.name+": ":"")+payload.message;
} else if (format === 'null') {
payload = null;
} else if (format === 'undefined') {
payload = undefined;
} else if (/^buffer/.test(format)) {
var buffer = payload;
payload = [];
for (var c = 0; c < buffer.length; c += 2) {
payload.push(parseInt(buffer.substr(c, 2), 16));
}
}
return payload;
}
function parseContextKey(key) {
var parts = {};
var m = /^#:\((\S+?)\)::(.*)$/.exec(key);
if (m) {
parts.store = m[1];
parts.key = m[2];
} else {
parts.key = key;
if (RED.settings.context) {
parts.store = RED.settings.context.default;
}
}
return parts;
}
return {
createObjectElement: buildMessageElement,
getMessageProperty: getMessageProperty,
@@ -782,6 +887,9 @@ RED.utils = (function() {
getDefaultNodeIcon: getDefaultNodeIcon,
getNodeIcon: getNodeIcon,
getNodeLabel: getNodeLabel,
addSpinnerOverlay: addSpinnerOverlay
getNodeColor: getNodeColor,
addSpinnerOverlay: addSpinnerOverlay,
decodeObject: decodeObject,
parseContextKey: parseContextKey
}
})();

View File

@@ -0,0 +1,168 @@
/**
* Copyright 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.view.navigator = (function() {
var nav_scale = 25;
var nav_width = 5000/nav_scale;
var nav_height = 5000/nav_scale;
var navContainer;
var navBox;
var navBorder;
var navVis;
var scrollPos;
var scaleFactor;
var chartSize;
var dimensions;
var isDragging;
var isShowing = false;
function refreshNodes() {
if (!isShowing) {
return;
}
var navNode = navVis.selectAll(".navnode").data(RED.view.getActiveNodes(),function(d){return d.id});
navNode.exit().remove();
navNode.enter().insert("rect")
.attr('class','navnode')
.attr("pointer-events", "none");
navNode.each(function(d) {
d3.select(this).attr("x",function(d) { return (d.x-d.w/2)/nav_scale })
.attr("y",function(d) { return (d.y-d.h/2)/nav_scale })
.attr("width",function(d) { return Math.max(9,d.w/nav_scale) })
.attr("height",function(d) { return Math.max(3,d.h/nav_scale) })
.attr("fill",function(d) { return RED.utils.getNodeColor(d.type,d._def);})
});
}
function onScroll() {
if (!isDragging) {
resizeNavBorder();
}
}
function resizeNavBorder() {
if (navBorder) {
scaleFactor = RED.view.scale();
chartSize = [ $("#chart").width(), $("#chart").height()];
scrollPos = [$("#chart").scrollLeft(),$("#chart").scrollTop()];
navBorder.attr('x',scrollPos[0]/nav_scale)
.attr('y',scrollPos[1]/nav_scale)
.attr('width',chartSize[0]/nav_scale/scaleFactor)
.attr('height',chartSize[1]/nav_scale/scaleFactor)
}
}
function toggle() {
if (!isShowing) {
isShowing = true;
$("#btn-navigate").addClass("selected");
resizeNavBorder();
refreshNodes();
$("#chart").on("scroll",onScroll);
navContainer.fadeIn(200);
} else {
isShowing = false;
navContainer.fadeOut(100);
$("#chart").off("scroll",onScroll);
$("#btn-navigate").removeClass("selected");
}
}
return {
init: function() {
$(window).resize(resizeNavBorder);
RED.events.on("sidebar:resize",resizeNavBorder);
RED.actions.add("core:toggle-navigator",toggle);
var hideTimeout;
navContainer = $('<div>').css({
"position":"absolute",
"bottom":$("#workspace-footer").height(),
"right":0,
zIndex: 1
}).appendTo("#workspace").hide();
navBox = d3.select(navContainer[0])
.append("svg:svg")
.attr("width", nav_width)
.attr("height", nav_height)
.attr("pointer-events", "all")
.style({
position: "absolute",
bottom: 0,
right:0,
zIndex: 101,
"border-left": "1px solid #ccc",
"border-top": "1px solid #ccc",
background: "rgba(245,245,245,0.5)",
"box-shadow": "-1px 0 3px rgba(0,0,0,0.1)"
});
navBox.append("rect").attr("x",0).attr("y",0).attr("width",nav_width).attr("height",nav_height).style({
fill:"none",
stroke:"none",
pointerEvents:"all"
}).on("mousedown", function() {
// Update these in case they have changed
scaleFactor = RED.view.scale();
chartSize = [ $("#chart").width(), $("#chart").height()];
dimensions = [chartSize[0]/nav_scale/scaleFactor, chartSize[1]/nav_scale/scaleFactor];
var newX = Math.max(0,Math.min(d3.event.offsetX+dimensions[0]/2,nav_width)-dimensions[0]);
var newY = Math.max(0,Math.min(d3.event.offsetY+dimensions[1]/2,nav_height)-dimensions[1]);
navBorder.attr('x',newX).attr('y',newY);
isDragging = true;
$("#chart").scrollLeft(newX*nav_scale*scaleFactor);
$("#chart").scrollTop(newY*nav_scale*scaleFactor);
}).on("mousemove", function() {
if (!isDragging) { return }
if (d3.event.buttons === 0) {
isDragging = false;
return;
}
var newX = Math.max(0,Math.min(d3.event.offsetX+dimensions[0]/2,nav_width)-dimensions[0]);
var newY = Math.max(0,Math.min(d3.event.offsetY+dimensions[1]/2,nav_height)-dimensions[1]);
navBorder.attr('x',newX).attr('y',newY);
$("#chart").scrollLeft(newX*nav_scale*scaleFactor);
$("#chart").scrollTop(newY*nav_scale*scaleFactor);
}).on("mouseup", function() {
isDragging = false;
})
navBorder = navBox.append("rect")
.attr("stroke-dasharray","5,5")
.attr("pointer-events", "none")
.style({
stroke: "#999",
strokeWidth: 1,
fill: "white",
});
navVis = navBox.append("svg:g")
$("#btn-navigate").click(function(evt) {
evt.preventDefault();
toggle();
})
},
refresh: refreshNodes,
resize: resizeNavBorder,
toggle: toggle
}
})();

View File

@@ -58,7 +58,10 @@ RED.view = (function() {
lastClickNode = null,
dblClickPrimed = null,
clickTime = 0,
clickElapsed = 0;
clickElapsed = 0,
scroll_position = [],
quickAddActive = false,
quickAddLink = null;
var clipboard = "";
@@ -73,6 +76,8 @@ RED.view = (function() {
var PORT_TYPE_INPUT = 1;
var PORT_TYPE_OUTPUT = 0;
var chart = $("#chart");
var outer = d3.select("#chart")
.append("svg:svg")
.attr("width", space_width)
@@ -94,6 +99,16 @@ RED.view = (function() {
.on("mousemove", canvasMouseMove)
.on("mousedown", canvasMouseDown)
.on("mouseup", canvasMouseUp)
.on("mouseenter", function() {
if (lasso) {
if (d3.event.buttons !== 1) {
lasso.remove();
lasso = null;
}
} else if (mouse_mode === RED.state.PANNING && d3.event.buttons !== 4) {
resetMouseVars();
}
})
.on("touchend", function() {
clearTimeout(touchStartTime);
touchStartTime = null;
@@ -283,7 +298,6 @@ RED.view = (function() {
function init() {
RED.events.on("workspace:change",function(event) {
var chart = $("#chart");
if (event.old !== 0) {
workspaceScrollPositions[event.old] = {
left:chart.scrollLeft(),
@@ -320,6 +334,8 @@ RED.view = (function() {
redraw();
});
RED.view.navigator.init();
$("#btn-zoom-out").click(function() {zoomOut();});
$("#btn-zoom-zero").click(function() {zoomZero();});
$("#btn-zoom-in").click(function() {zoomIn();});
@@ -448,6 +464,82 @@ RED.view = (function() {
RED.actions.add("core:step-selection-left", function() { moveSelection(-20,0);});
}
function generateLinkPath(origX,origY, destX, destY, sc) {
var dy = destY-origY;
var dx = destX-origX;
var delta = Math.sqrt(dy*dy+dx*dx);
var scale = lineCurveScale;
var scaleY = 0;
if (dx*sc > 0) {
if (delta < node_width) {
scale = 0.75-0.75*((node_width-delta)/node_width);
// scale += 2*(Math.min(5*node_width,Math.abs(dx))/(5*node_width));
// if (Math.abs(dy) < 3*node_height) {
// scaleY = ((dy>0)?0.5:-0.5)*(((3*node_height)-Math.abs(dy))/(3*node_height))*(Math.min(node_width,Math.abs(dx))/(node_width)) ;
// }
}
} else {
scale = 0.4-0.2*(Math.max(0,(node_width-Math.min(Math.abs(dx),Math.abs(dy)))/node_width));
}
if (dx*sc > 0) {
return "M "+origX+" "+origY+
" C "+(origX+sc*(node_width*scale))+" "+(origY+scaleY*node_height)+" "+
(destX-sc*(scale)*node_width)+" "+(destY-scaleY*node_height)+" "+
destX+" "+destY
} else {
var midX = Math.floor(destX-dx/2);
var midY = Math.floor(destY-dy/2);
//
if (dy === 0) {
midY = destY + node_height;
}
var cp_height = node_height/2;
var y1 = (destY + midY)/2
var topX =origX + sc*node_width*scale;
var topY = dy>0?Math.min(y1 - dy/2 , origY+cp_height):Math.max(y1 - dy/2 , origY-cp_height);
var bottomX = destX - sc*node_width*scale;
var bottomY = dy>0?Math.max(y1, destY-cp_height):Math.min(y1, destY+cp_height);
var x1 = (origX+topX)/2;
var scy = dy>0?1:-1;
var cp = [
// Orig -> Top
[x1,origY],
[topX,dy>0?Math.max(origY, topY-cp_height):Math.min(origY, topY+cp_height)],
// Top -> Mid
// [Mirror previous cp]
[x1,dy>0?Math.min(midY, topY+cp_height):Math.max(midY, topY-cp_height)],
// Mid -> Bottom
// [Mirror previous cp]
[bottomX,dy>0?Math.max(midY, bottomY-cp_height):Math.min(midY, bottomY+cp_height)],
// Bottom -> Dest
// [Mirror previous cp]
[(destX+bottomX)/2,destY]
];
if (cp[2][1] === topY+scy*cp_height) {
if (Math.abs(dy) < cp_height*10) {
cp[1][1] = topY-scy*cp_height/2;
cp[3][1] = bottomY-scy*cp_height/2;
}
cp[2][0] = topX;
}
return "M "+origX+" "+origY+
" C "+
cp[0][0]+" "+cp[0][1]+" "+
cp[1][0]+" "+cp[1][1]+" "+
topX+" "+topY+
" S "+
cp[2][0]+" "+cp[2][1]+" "+
midX+" "+midY+
" S "+
cp[3][0]+" "+cp[3][1]+" "+
bottomX+" "+bottomY+
" S "+
cp[4][0]+" "+cp[4][1]+" "+
destX+" "+destY
}
}
function addNode(type,x,y) {
var m = /^subflow:(.+)$/.exec(type);
@@ -490,6 +582,7 @@ RED.view = (function() {
}
} else {
var subflow = RED.nodes.subflow(m[1]);
nn.name = "";
nn.inputs = subflow.in.length;
nn.outputs = subflow.out.length;
}
@@ -525,6 +618,15 @@ RED.view = (function() {
function canvasMouseDown() {
var point;
if (d3.event.button === 1) {
// Middle Click pan
mouse_mode = RED.state.PANNING;
mouse_position = [d3.event.pageX,d3.event.pageY]
scroll_position = [chart.scrollLeft(),chart.scrollTop()];
return;
}
if (!mousedown_node && !mousedown_link) {
selected_link = null;
updateSelection();
@@ -545,14 +647,16 @@ RED.view = (function() {
mouse_mode = RED.state.QUICK_JOINING;
$(window).on('keyup',disableQuickJoinEventHandler);
}
quickAddActive = true;
RED.typeSearch.show({
x:d3.event.clientX-mainPos.left-node_width/2,
y:d3.event.clientY-mainPos.top-node_height/2,
cancel: function() {
quickAddActive = false;
resetMouseVars();
},
add: function(type) {
quickAddActive = false;
var result = addNode(type);
if (!result) {
return;
@@ -561,11 +665,10 @@ RED.view = (function() {
var historyEvent = result.historyEvent;
nn.x = point[0];
nn.y = point[1];
if (mouse_mode === RED.state.QUICK_JOINING) {
if (drag_lines.length > 0) {
var drag_line = drag_lines[0];
if (mouse_mode === RED.state.QUICK_JOINING || quickAddLink) {
if (quickAddLink || drag_lines.length > 0) {
var drag_line = quickAddLink||drag_lines[0];
var src = null,dst,src_port;
if (drag_line.portType === PORT_TYPE_OUTPUT && nn.inputs > 0) {
src = drag_line.node;
src_port = drag_line.port;
@@ -580,9 +683,9 @@ RED.view = (function() {
RED.nodes.addLink(link);
historyEvent.links = [link];
hideDragLines();
if (drag_line.portType === PORT_TYPE_OUTPUT && nn.outputs > 0) {
if (!quickAddLink && drag_line.portType === PORT_TYPE_OUTPUT && nn.outputs > 0) {
showDragLines([{node:nn,port:0,portType:PORT_TYPE_OUTPUT}]);
} else if (drag_line.portType === PORT_TYPE_INPUT && nn.inputs > 0) {
} else if (!quickAddLink && drag_line.portType === PORT_TYPE_INPUT && nn.inputs > 0) {
showDragLines([{node:nn,port:0,portType:PORT_TYPE_INPUT}]);
} else {
resetMouseVars();
@@ -600,9 +703,9 @@ RED.view = (function() {
resetMouseVars();
}
}
quickAddLink = null;
}
RED.history.push(historyEvent);
RED.nodes.add(nn);
RED.editor.validateNode(nn);
@@ -643,7 +746,6 @@ RED.view = (function() {
function canvasMouseMove() {
var i;
var node;
mouse_position = d3.touches(this)[0]||d3.mouse(this);
// Prevent touch scrolling...
//if (d3.touches(this)[0]) {
// d3.event.preventDefault();
@@ -654,6 +756,22 @@ RED.view = (function() {
//if (point[0]-container.scrollLeft < 30 && container.scrollLeft > 0) { container.scrollLeft -= 15; }
//console.log(d3.mouse(this),container.offsetWidth,container.offsetHeight,container.scrollLeft,container.scrollTop);
if (mouse_mode === RED.state.PANNING) {
var pos = [d3.event.pageX,d3.event.pageY];
var deltaPos = [
mouse_position[0]-pos[0],
mouse_position[1]-pos[1]
];
chart.scrollLeft(scroll_position[0]+deltaPos[0])
chart.scrollTop(scroll_position[1]+deltaPos[1])
return
}
mouse_position = d3.touches(this)[0]||d3.mouse(this);
if (lasso) {
var ox = parseInt(lasso.attr("ox"));
var oy = parseInt(lasso.attr("oy"));
@@ -752,28 +870,7 @@ RED.view = (function() {
var sc = (drag_line.portType === PORT_TYPE_OUTPUT)?1:-1;
var dy = mousePos[1]-(drag_line.node.y+portY);
var dx = mousePos[0]-(drag_line.node.x+sc*drag_line.node.w/2);
var delta = Math.sqrt(dy*dy+dx*dx);
var scale = lineCurveScale;
var scaleY = 0;
if (delta < node_width) {
scale = 0.75-0.75*((node_width-delta)/node_width);
}
if (dx*sc < 0) {
scale += 2*(Math.min(5*node_width,Math.abs(dx))/(5*node_width));
if (Math.abs(dy) < 3*node_height) {
scaleY = ((dy>0)?0.5:-0.5)*(((3*node_height)-Math.abs(dy))/(3*node_height))*(Math.min(node_width,Math.abs(dx))/(node_width)) ;
}
}
drag_line.el.attr("d",
"M "+(drag_line.node.x+sc*drag_line.node.w/2)+" "+(drag_line.node.y+portY)+
" C "+(drag_line.node.x+sc*(drag_line.node.w/2+node_width*scale))+" "+(drag_line.node.y+portY+scaleY*node_height)+" "+
(mousePos[0]-sc*(scale)*node_width)+" "+(mousePos[1]-scaleY*node_height)+" "+
mousePos[0]+" "+mousePos[1]
);
drag_line.el.attr("d",generateLinkPath(drag_line.node.x+sc*drag_line.node.w/2,drag_line.node.y+portY,mousePos[0],mousePos[1],sc));
}
d3.event.preventDefault();
} else if (mouse_mode == RED.state.MOVING) {
@@ -905,6 +1002,10 @@ RED.view = (function() {
function canvasMouseUp() {
var i;
var historyEvent;
if (mouse_mode === RED.state.PANNING) {
resetMouseVars();
return
}
if (mouse_mode === RED.state.QUICK_JOINING) {
return;
}
@@ -1019,17 +1120,20 @@ RED.view = (function() {
function zoomIn() {
if (scaleFactor < 2) {
scaleFactor += 0.1;
RED.view.navigator.resize();
redraw();
}
}
function zoomOut() {
if (scaleFactor > 0.3) {
scaleFactor -= 0.1;
RED.view.navigator.resize();
redraw();
}
}
function zoomZero() {
scaleFactor = 1;
RED.view.navigator.resize();
redraw();
}
@@ -1366,6 +1470,9 @@ RED.view = (function() {
function disableQuickJoinEventHandler(evt) {
// Check for ctrl (all browsers), "Meta" (Chrome/FF), keyCode 91 (Safari)
if (evt.keyCode === 17 || evt.key === "Meta" || evt.keyCode === 91) {
if (quickAddActive && drag_lines.length > 0) {
quickAddLink = drag_lines[0];
}
resetMouseVars();
hideDragLines();
redraw();
@@ -1377,6 +1484,10 @@ RED.view = (function() {
//console.log(d,portType,portIndex);
// disable zoom
//vis.call(d3.behavior.zoom().on("zoom"), null);
if (d3.event.button === 1) {
return;
}
mousedown_node = d;
mousedown_port_type = portType;
mousedown_port_index = portIndex || 0;
@@ -1608,6 +1719,9 @@ RED.view = (function() {
function nodeMouseDown(d) {
focusView();
if (d3.event.button === 1) {
return;
}
//var touch0 = d3.event;
//var pos = [touch0.pageX,touch0.pageY];
//RED.touch.radialMenu.show(d3.select(this),pos);
@@ -1651,7 +1765,9 @@ RED.view = (function() {
clickElapsed = now-clickTime;
clickTime = now;
dblClickPrimed = (lastClickNode == mousedown_node);
dblClickPrimed = (lastClickNode == mousedown_node &&
d3.event.buttons === 1 &&
!d3.event.shiftKey && !d3.event.metaKey && !d3.event.altKey && !d3.event.ctrlKey);
lastClickNode = mousedown_node;
var i;
@@ -1922,7 +2038,7 @@ RED.view = (function() {
.attr("ry",4)
.attr("width",16)
.attr("height",node_height-12)
.attr("fill",function(d) { return d._def.color;})
.attr("fill",function(d) { return RED.utils.getNodeColor(d.type,d._def); /*d._def.color;*/})
.attr("cursor","pointer")
.on("mousedown",function(d) {if (!lasso && isButtonEnabled(d)) {focusView();d3.select(this).attr("fill-opacity",0.2);d3.event.preventDefault(); d3.event.stopPropagation();}})
.on("mouseup",function(d) {if (!lasso && isButtonEnabled(d)) { d3.select(this).attr("fill-opacity",0.4);d3.event.preventDefault();d3.event.stopPropagation();}})
@@ -1943,7 +2059,7 @@ RED.view = (function() {
.classed("node_unknown",function(d) { return d.type == "unknown"; })
.attr("rx", 5)
.attr("ry", 5)
.attr("fill",function(d) { return d._def.color;})
.attr("fill",function(d) { return RED.utils.getNodeColor(d.type,d._def); /*d._def.color;*/})
.on("mouseup",nodeMouseUp)
.on("mousedown",nodeMouseDown)
.on("touchstart",function(d) {
@@ -2340,32 +2456,17 @@ RED.view = (function() {
var numOutputs = d.source.outputs || 1;
var sourcePort = d.sourcePort || 0;
var y = -((numOutputs-1)/2)*13 +13*sourcePort;
var dy = d.target.y-(d.source.y+y);
var dx = (d.target.x-d.target.w/2)-(d.source.x+d.source.w/2);
var delta = Math.sqrt(dy*dy+dx*dx);
var scale = lineCurveScale;
var scaleY = 0;
if (delta < node_width) {
scale = 0.75-0.75*((node_width-delta)/node_width);
}
if (dx < 0) {
scale += 2*(Math.min(5*node_width,Math.abs(dx))/(5*node_width));
if (Math.abs(dy) < 3*node_height) {
scaleY = ((dy>0)?0.5:-0.5)*(((3*node_height)-Math.abs(dy))/(3*node_height))*(Math.min(node_width,Math.abs(dx))/(node_width)) ;
}
}
d.x1 = d.source.x+d.source.w/2;
d.y1 = d.source.y+y;
d.x2 = d.target.x-d.target.w/2;
d.y2 = d.target.y;
return "M "+d.x1+" "+d.y1+
" C "+(d.x1+scale*node_width)+" "+(d.y1+scaleY*node_height)+" "+
(d.x2-scale*node_width)+" "+(d.y2-scaleY*node_height)+" "+
d.x2+" "+d.y2;
// return "M "+d.x1+" "+d.y1+
// " C "+(d.x1+scale*node_width)+" "+(d.y1+scaleY*node_height)+" "+
// (d.x2-scale*node_width)+" "+(d.y2-scaleY*node_height)+" "+
// d.x2+" "+d.y2;
return generateLinkPath(d.x1,d.y1,d.x2,d.y2,1);
});
}
})
@@ -2501,7 +2602,7 @@ RED.view = (function() {
}
).classed("link_selected", false);
}
RED.view.navigator.refresh();
if (d3.event) {
d3.event.preventDefault();
}
@@ -2775,7 +2876,9 @@ RED.view = (function() {
gridSize = Math.max(5,v);
updateGrid();
}
},
getActiveNodes: function() {
return activeNodes;
}
};
})();

View File

@@ -43,7 +43,7 @@ RED.workspaces = (function() {
return ws;
}
function deleteWorkspace(ws) {
if (workspace_tabs.count() == 1) {
if (workspaceTabCount === 1) {
return;
}
removeWorkspace(ws);
@@ -65,7 +65,7 @@ RED.workspaces = (function() {
buttons: [
{
id: "node-dialog-delete",
class: 'leftButton'+((workspace_tabs.count() == 1)?" disabled":""),
class: 'leftButton'+((workspaceTabCount === 1)?" disabled":""),
text: RED._("common.label.delete"), //'<i class="fa fa-trash"></i>',
click: function() {
deleteWorkspace(workspace);
@@ -172,12 +172,12 @@ RED.workspaces = (function() {
i.addClass('fa-toggle-on');
i.removeClass('fa-toggle-off');
$("#node-input-disabled").prop("checked",false);
$("#node-input-disabled-label").html(RED._("editor:workspace.enabled"));
$("#node-input-disabled-label").text(RED._("editor:workspace.enabled"));
} else {
i.addClass('fa-toggle-off');
i.removeClass('fa-toggle-on');
$("#node-input-disabled").prop("checked",true);
$("#node-input-disabled-label").html(RED._("editor:workspace.disabled"));
$("#node-input-disabled-label").text(RED._("editor:workspace.disabled"));
}
})
@@ -185,13 +185,13 @@ RED.workspaces = (function() {
$("#node-input-disabled").prop("checked",workspace.disabled);
if (workspace.disabled) {
dialogForm.find("#node-input-disabled-btn i").removeClass('fa-toggle-on').addClass('fa-toggle-off');
$("#node-input-disabled-label").html(RED._("editor:workspace.disabled"));
$("#node-input-disabled-label").text(RED._("editor:workspace.disabled"));
} else {
$("#node-input-disabled-label").html(RED._("editor:workspace.enabled"));
$("#node-input-disabled-label").text(RED._("editor:workspace.enabled"));
}
} else {
workspace.disabled = false;
$("#node-input-disabled-label").html(RED._("editor:workspace.enabled"));
$("#node-input-disabled-label").text(RED._("editor:workspace.enabled"));
}
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
@@ -214,6 +214,7 @@ RED.workspaces = (function() {
var workspace_tabs;
var workspaceTabCount = 0;
function createWorkspaceTabs() {
workspace_tabs = RED.tabs.create({
id: "workspace-tabs",
@@ -240,18 +241,24 @@ RED.workspaces = (function() {
}
},
onadd: function(tab) {
if (tab.type === "tab") {
workspaceTabCount++;
}
$('<span class="workspace-disabled-icon"><i class="fa fa-ban"></i> </span>').prependTo("#red-ui-tab-"+(tab.id.replace(".","-"))+" .red-ui-tab-label");
if (tab.disabled) {
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('workspace-disabled');
}
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() <= 1);
if (workspace_tabs.count() === 1) {
RED.menu.setDisabled("menu-item-workspace-delete",workspaceTabCount <= 1);
if (workspaceTabCount === 1) {
showWorkspace();
}
},
onremove: function(tab) {
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() <= 1);
if (workspace_tabs.count() === 0) {
if (tab.type === "tab") {
workspaceTabCount--;
}
RED.menu.setDisabled("menu-item-workspace-delete",workspaceTabCount <= 1);
if (workspaceTabCount === 0) {
hideWorkspace();
}
},
@@ -266,6 +273,7 @@ RED.workspaces = (function() {
addWorkspace();
}
});
workspaceTabCount = 0;
}
function showWorkspace() {
$("#workspace .red-ui-tabs").show()
@@ -334,7 +342,7 @@ RED.workspaces = (function() {
return workspace_tabs.contains(id);
},
count: function() {
return workspace_tabs.count();
return workspaceTabCount;
},
active: function() {
return activeWorkspace

View File

@@ -19,3 +19,7 @@
div.btn-group, a.btn {
@include disable-selection;
}
.dropdown-menu>li>a {
color: #444;
}

View File

@@ -64,22 +64,22 @@
display: inline-block;
}
}
.debug-message-row {
.debug-message-tools-pin {
display: none;
}
&.debug-message-row-pinned .debug-message-tools-pin {
display: inline-block;
}
&:hover {
background: #f3f3f3;
&>.debug-message-tools {
.debug-message-tools-copy {
display: inline-block;
}
.debug-message-tools-pin {
display: inline-block;
}
}
.debug-message-row {
.debug-message-tools-pin {
display: none;
}
&.debug-message-row-pinned .debug-message-tools-pin {
display: inline-block;
}
&:hover {
background: #f3f3f3;
&>.debug-message-tools {
.debug-message-tools-copy {
display: inline-block;
}
.debug-message-tools-pin {
display: inline-block;
}
}
}
@@ -113,8 +113,8 @@
.debug-message-meta {
background: #fff;
font-size: 10px;
color: #777;
font-size: 11px;
color: #707070;
}
.debug-message-date {
padding: 1px 5px 1px 1px;
@@ -125,7 +125,7 @@
}
.debug-message-name {
padding: 1px 5px;
color: #777;
color: #707070;
}
.debug-message-tools {
position: absolute;
@@ -159,7 +159,7 @@
.debug-message-element {
color: #333;
font-family: Menlo, monospace;
font-size: 12px !important;
font-size: 13px !important;
line-height: 1.3em;
}
.debug-message-object-key {
@@ -188,11 +188,9 @@
.debug-message-element.collapsed>span>.debug-message-object-handle {
transform: rotate(0deg);
}
.debug-message-object-entry.collapsed > .debug-message-object-entry {
display:none;
}
.debug-message-element.collapsed .debug-message-object-entry {
display:none;
}
@@ -202,14 +200,13 @@
.debug-message-element.collapsed .debug-message-buffer-opts {
display: none;
}
.debug-message-element.collapsed .debug-message-object-type-header {
display:none;
}
.debug-message-object-entry pre {
font-family: Menlo, monospace;
font-size: 12px;
line-height: 1.4em;
font-size: 13px;
line-height: 1.2em;
margin: 0 0 0 -1em;
}

View File

@@ -16,17 +16,16 @@
.node-dialog-view-diff-panel {
padding: 5px;
padding-top: 30px;
position: relative;
.red-ui-editableList-container {
border-radius:1px;
padding:0;
background: #f9f9f9;
}
.node-dialog-view-diff-diff {
position: absolute;
top:30px;
bottom:10px;
left:10px;
right:10px;
li {
background: #f9f9f9;
padding: 0px;
@@ -38,21 +37,20 @@
padding: 5px;
// padding-bottom: 5px;
}
&.node-dialog-view-diff-panel-merge {
.node-dialog-view-diff-diff {
top: 80px
}
.node-dialog-view-diff-headers {
top: 55px;
}
}
}
.node-diff-container {
position: absolute;
top: 40px;
right:0;
bottom: 0;
left: 0;
overflow-y: scroll;
}
.node-dialog-view-diff-headers {
position: absolute;
left:237px;
right:18px;
left:232px;
right:12px;
top: 5px;
height: 25px;
div {
@@ -76,11 +74,6 @@
}
.node-diff-toolbar {
position:absolute;
top:0;
left:0;
right:0;
height: 43px;
box-sizing: border-box;
color: #666;
text-align: right;
@@ -555,129 +548,129 @@ ul.node-dialog-configm-deploy-list {
.node-text-diff {
height: 100%;
overflow-y:auto;
table {
table.node-text-diff-content {
margin: 10px;
border: 1px solid $secondary-border-color;
border-radius: 3px;
table-layout: fixed;
width: calc(100% - 20px);
}
td {
vertical-align: top;
word-wrap: break-word;
}
td.lineno {
font-family: monospace;
text-align: right;
color: #aaa;
background: #f6f6f6;
padding: 1px 5px;
}
td.lineno:nth-child(3) {
border-left: 1px solid $secondary-border-color;
}
td.linetext {
font-family: monospace;
white-space: pre-wrap;
padding: 1px 5px;
span.prefix {
width: 30px;
display: inline-block;
text-align: center;
color: #999;
td {
vertical-align: top;
word-wrap: break-word;
}
}
td.blank {
background: #f6f6f6;
}
td.added {
background: #eefaee;
}
td.removed {
background: #fadddd;
}
tr.mergeHeader td {
color: #800080;
background: #e5f9ff;
height: 26px;
vertical-align: middle;
}
tr.mergeHeader-separator td {
color: #800080;
background: darken(#e5f9ff, 10%);
height: 0px;
}
tr.mergeHeader-ours td {
border-top: 2px solid darken(#e5f9ff, 10%);
}
tr.mergeHeader-theirs td {
border-bottom: 2px solid darken(#e5f9ff, 10%);
}
td.unchanged {
color: #999;
}
tr.unchanged {
background: #fefefe;
}
tr.start-block {
border-top: 1px solid #f0f0f0;
}
tr.end-block {
border-bottom: 1px solid #f0f0f0;
}
tr.node-text-diff-file-header td {
.filename {
td.lineno {
font-family: monospace;
text-align: right;
color: #aaa;
background: #f6f6f6;
padding: 1px 5px;
}
background: #f3f3f3;
padding: 5px 10px 5px 0;
color: #333;
cursor: pointer;
i.node-diff-chevron {
width: 30px;
td.lineno:nth-child(3) {
border-left: 1px solid $secondary-border-color;
}
}
tr.node-text-diff-file-header.collapsed {
td i.node-diff-chevron {
transform: rotate(-90deg);
td.linetext {
font-family: monospace;
white-space: pre-wrap;
padding: 1px 5px;
span.prefix {
width: 30px;
display: inline-block;
text-align: center;
color: #999;
}
}
}
tr.node-text-diff-commit-header td {
background: #f3f3f3;
padding: 5px 10px;
color: #333;
h3 {
font-size: 1.4em;
margin: 0;
td.blank {
background: #f6f6f6;
}
.commit-summary {
border-top: 1px solid $secondary-border-color;
padding-top: 5px;
td.added {
background: #eefaee;
}
td.removed {
background: #fadddd;
}
tr.mergeHeader td {
color: #800080;
background: #e5f9ff;
height: 26px;
vertical-align: middle;
}
tr.mergeHeader-separator td {
color: #800080;
background: darken(#e5f9ff, 10%);
height: 0px;
}
tr.mergeHeader-ours td {
border-top: 2px solid darken(#e5f9ff, 10%);
}
tr.mergeHeader-theirs td {
border-bottom: 2px solid darken(#e5f9ff, 10%);
}
td.unchanged {
color: #999;
}
.commit-body {
margin-bottom:15px;
white-space: pre;
line-height: 1.2em;
tr.unchanged {
background: #fefefe;
}
tr.start-block {
border-top: 1px solid #f0f0f0;
}
tr.end-block {
border-bottom: 1px solid #f0f0f0;
}
tr.node-text-diff-file-header td {
.filename {
font-family: monospace;
}
background: #f3f3f3;
padding: 5px 10px 5px 0;
color: #333;
cursor: pointer;
i.node-diff-chevron {
width: 30px;
}
}
tr.node-text-diff-file-header.collapsed {
td i.node-diff-chevron {
transform: rotate(-90deg);
}
}
tr.node-text-diff-commit-header td {
background: #f3f3f3;
padding: 5px 10px;
color: #333;
h3 {
font-size: 1.4em;
margin: 0;
}
.commit-summary {
border-top: 1px solid $secondary-border-color;
padding-top: 5px;
color: #999;
}
.commit-body {
margin-bottom:15px;
white-space: pre;
line-height: 1.2em;
}
}
tr.node-text-diff-header > td:not(.flow-diff) {
font-family: monospace;
padding: 5px 10px;
text-align: left;
color: #666;
background: #ffd;
height: 30px;
vertical-align: middle;
border-top: 1px solid #f0f0f0;
border-bottom: 1px solid #f0f0f0;
}
tr.node-text-diff-expand td {
cursor: pointer;
&:hover {
background: #ffc;
}
}
}
tr.node-text-diff-header td {
font-family: monospace;
padding: 5px 10px;
text-align: left;
color: #666;
background: #ffd;
height: 30px;
vertical-align: middle;
border-top: 1px solid #f0f0f0;
border-bottom: 1px solid #f0f0f0;
}
tr.node-text-diff-expand td {
cursor: pointer;
&:hover {
background: #ffc;
}
}
}

View File

@@ -178,7 +178,7 @@
}
.form-row label {
display: inline-block;
min-width: 100px;
width: 100px;
}
.form-row input, .form-row div[contenteditable="true"] {
width:70%;
@@ -323,7 +323,6 @@
margin-right: 20px;
text-align: right;
width: 30px;
min-width: 30px;
}
button {
margin-left: 10px;
@@ -354,3 +353,64 @@
}
}
#node-settings-icon {
margin-left: 10px;
width: calc(100% - 163px);
}
.red-ui-icon-picker {
position: absolute;
border: 1px solid $primary-border-color;
box-shadow: 0 1px 6px -3px black;
background: white;
z-Index: 21;
display: none;
select {
box-sizing: border-box;
margin: 3px;
width: calc(100% - 6px);
}
}
.red-ui-icon-list {
width: 308px;
height: 200px;
overflow-y: scroll;
line-height: 0px;
}
.red-ui-icon-list-icon {
display: inline-block;
margin: 2px;
padding: 4px;
cursor: pointer;
border-radius: 4px;
&:hover {
background: lighten($node-selected-color,20%);
}
&.selected {
background: lighten($node-selected-color,20%);
.red-ui-search-result-node {
border-color: white;
}
}
}
.red-ui-icon-list-module {
background: $palette-header-background;
font-size: 0.9em;
padding: 3px;
color: #666;
clear: both;
i {
margin-right: 5px;
}
}
.red-ui-icon-meta {
border-top: 1px solid $secondary-border-color;
span {
padding: 4px;
color: #666;
font-size: 0.9em;
}
button {
float: right;
margin: 2px;
}
}

View File

@@ -248,7 +248,7 @@
.link_outline {
stroke: #fff;
stroke-width: 4;
stroke-width: 5;
cursor: crosshair;
fill: none;
pointer-events: none;

View File

@@ -134,15 +134,18 @@
color: $workspace-button-toggle-color !important;
background:$workspace-button-background-active;
margin-bottom: 1px;
&.selected:not(.disabled) {
&.selected:not(.disabled):not(:disabled) {
color: $workspace-button-toggle-color-selected !important;
background: $workspace-button-background;
border-bottom-width: 2px;
border-bottom-color: $form-input-border-selected-color;
margin-bottom: 0;
cursor: default;
&:not(.single) {
cursor: default;
}
}
&.disabled {
&.disabled,&:disabled {
color: $workspace-button-toggle-color-disabled !important;
}
}
@@ -203,7 +206,7 @@
height: 25px;
line-height: 23px;
padding: 0 10px;
user-select: none;
.button-group:not(:last-child) {
margin-right: 5px;
@@ -227,6 +230,7 @@
font-size: 11px;
line-height: 17px;
height: 18px;
width: 18px;
&.text-button {
width: auto;
padding: 0 5px;

View File

@@ -49,7 +49,12 @@
.palette-module-version {
color: #aaa;
}
.palette-module-errors .fa-warning {
opacity: 0.5;
}
ul.palette-module-error-list li {
color: #aaa;
}
}
@@ -222,6 +227,20 @@
margin-left: 5px;
}
}
.palette-module-meta .fa-warning {
color: #AD1625;
}
ul.palette-module-error-list {
display: inline-block;
list-style-type: none;
margin: 0;
font-size: 0.9em;
li {
border: none;
background: none;
}
}
.palette-module-shade {
@include shade;
text-align: center;

View File

@@ -90,13 +90,14 @@
text-align: left;
padding: 9px;
font-weight: bold;
padding-left: 30px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
user-select: none;
}
.palette-header > i {
margin: 3px 10px 3px 3px;
position: absolute;
left: 11px;
top: 12px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;

View File

@@ -30,7 +30,6 @@
}
.red-ui-popover:after, .red-ui-popover:before {
top: 50%;
border: solid transparent;
content: " ";
height: 0;
@@ -39,12 +38,18 @@
pointer-events: none;
}
.red-ui-popover.red-ui-popover-right:after, .red-ui-popover.red-ui-popover-right:before {
top: 50%;
right: 100%;
}
.red-ui-popover.red-ui-popover-left:after, .red-ui-popover.red-ui-popover-left:before {
top: 50%;
left: 100%;
}
.red-ui-popover.red-ui-popover-bottom:after, .red-ui-popover.red-ui-popover-bottom:before {
bottom: 100%;
left: 50%;
}
.red-ui-popover.red-ui-popover-right:after {
border-color: rgba(136, 183, 213, 0);
@@ -72,6 +77,21 @@
margin-top: -11px;
}
.red-ui-popover.red-ui-popover-bottom:after {
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #fff;
border-width: 10px;
margin-left: -10px;
}
.red-ui-popover.red-ui-popover-bottom:before {
border-color: rgba(194, 225, 245, 0);
border-bottom-color: $primary-border-color;
border-width: 11px;
margin-left: -11px;
}
.red-ui-popover-size-small {
font-size: 11px;
padding: 5px;
@@ -93,4 +113,12 @@
border-width: 6px;
margin-top: -6px;
}
&.red-ui-popover-bottom:after {
border-width: 5px;
margin-left: -5px;
}
&.red-ui-popover-bottom:before {
border-width: 6px;
margin-left: -6px;
}
}

View File

@@ -139,16 +139,17 @@
}
}
button.editor-button {
width: calc(50% - 40px);
width: calc(50% - 80px);
margin: 20px;
height: 175px;
height: auto;
line-height: 2em;
font-size: 1.5em !important;
padding: 10px;
border-color: #aaa;
i {
color: #ccc;
color: #aaa;
}
&:hover i {
color: #aaa;
color: #999;
}
}
.button-group {
@@ -160,7 +161,6 @@
button.projects-dialog-screen-create-type {
height: auto;
padding: 10px;
}
.button-group {
text-align: center;
@@ -501,9 +501,9 @@
top: 4px;
right: 4px;
display: none;
}
button {
width: 24px;
button {
width: 24px;
}
}
&:hover {

View File

@@ -40,6 +40,7 @@
@import "panels";
@import "tabs";
@import "tab-config";
@import "tab-context";
@import "tab-info";
@import "popover";
@import "flow";

View File

@@ -0,0 +1,54 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
.sidebar-context-stack {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow-y: scroll;
.palette-category {
&:not(.palette-category-expanded) button {
display: none;
}
}
}
.sidebar-context-property {
position: relative;
.debug-message-tools {
right: 0px;
margin-right: 5px;
display: none;
}
&:hover .debug-message-tools {
display: inline-block;
}
}
.sidebar-context-updated {
text-align: right;
font-size: 11px;
color: #bbb;
padding: 1px 3px;
}
.sidebar-context-property-storename {
display: block;
font-size: 0.8em;
font-style: italic;
color: #aaa;
}

View File

@@ -93,7 +93,7 @@
color: $workspace-button-color-hover;
}
}
.red-ui-tab-icon {
img.red-ui-tab-icon {
opacity: 0.2;
}
}
@@ -113,6 +113,21 @@
&.red-ui-tabs-add.red-ui-tabs-scrollable {
padding-right: 59px;
}
&.red-ui-tabs-collapsible {
li:not(.active) {
display: none;
&.red-ui-tab-pinned {
a {
padding-left: 0;
text-align: center;
}
span {
display: none;
}
width: 32px;
}
}
}
&.red-ui-tabs-vertical {
box-sizing: border-box;
@@ -157,6 +172,15 @@
}
}
}
.red-ui-tabs-select {
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
opacity: 0.4;
background: red;
}
}
.red-ui-tab-button {
position: absolute;
@@ -180,7 +204,32 @@
z-index: 2;
}
}
.red-ui-tab-link-buttons {
position: absolute;
box-sizing: border-box;
top: 0;
right: 0;
height: 35px;
background: #fff;
border-bottom: 1px solid $primary-border-color;
z-index: 2;
a {
@include workspace-button-toggle;
line-height: 26px;
height: 28px;
width: 28px;
margin: 4px 3px 3px;
z-index: 2;
&.red-ui-tab-link-button {
&:not(.active) {
background: #eee;
}
}
&.red-ui-tab-link-button-menu {
border-color: white;
}
}
}
.red-ui-tab-scroll {
width: 21px;
top: 0;
@@ -216,7 +265,7 @@
right: 38px;
}
.red-ui-tab-icon {
img.red-ui-tab-icon {
margin-left: -8px;
margin-right: 3px;
margin-top: -2px;
@@ -225,6 +274,11 @@
height: 20px;
vertical-align: middle;
}
i.red-ui-tab-icon {
opacity: 0.7;
width: 18px;
height: 20px;
}
.red-ui-tabs-badges {
position: absolute;

View File

@@ -23,7 +23,7 @@
margin: 0;
vertical-align: middle;
box-sizing: border-box;
overflow:hidden;
overflow:visible;
position: relative;
.red-ui-typedInput-input {
position: absolute;
@@ -43,6 +43,7 @@
border-bottom-left-radius: 0;
box-shadow: none;
vertical-align: middle;
// backgroun/d: #f0fff0;
}
&.red-ui-typedInput-focus:not(.input-error) {
@@ -63,7 +64,7 @@
line-height: 32px;
vertical-align: middle;
color: #555;
i {
i.red-ui-typedInput-icon {
position: relative;
top: -3px;
margin-left: 1px;
@@ -76,11 +77,11 @@
}
&.disabled {
cursor: default;
i {
i.red-ui-typedInput-icon {
color: #bbb;
}
}
span {
.red-ui-typedInput-type-label,.red-ui-typedInput-option-label {
display: inline-block;
height: 100%;
padding: 0 1px 0 5px;
@@ -121,26 +122,25 @@
border-bottom-right-radius: 4px;
padding: 0 0 0 0;
position:absolute;
width: calc( 100% );
i {
position:absolute;
right: 4px;
top: 7px;
}
right: 0;
.red-ui-typedInput-option-label {
background:#fff;
background:$typedInput-button-background;
position:absolute;
left:0;
right:23px;
top: 0;
padding: 0 5px 0 5px;
padding: 0 5px 0 8px;
i.red-ui-typedInput-icon {
margin-right: 4px;
margin-top: 4px;
}
}
.red-ui-typedInput-option-caret {
top: 0;
position: absolute;
right: 0;
width: 17px;
padding-left: 6px;
}
&:focus {
box-shadow: none;
@@ -175,4 +175,7 @@
background: $typedInput-button-background-active;
}
}
.red-ui-typedInput-icon {
margin-right: 4px;
}
}

View File

@@ -61,7 +61,13 @@
}
#user-settings-tab-view {
position: absolute;
top:0;
right: 0;
left: 0;
bottom: 0;
padding: 8px 20px 20px;
overflow-y: scroll;
}
.user-settings-row {
padding: 5px 10px 2px;

View File

@@ -47,7 +47,9 @@
.workspace-footer-button {
@include component-footer-button;
}
.workspace-footer-button-toggle {
@include component-footer-button-toggle;
}
#workspace-footer {
@include component-footer;
}

View File

@@ -51,6 +51,7 @@
<a class="workspace-footer-button" id="btn-zoom-out" href="#"><i class="fa fa-minus"></i></a>
<a class="workspace-footer-button" id="btn-zoom-zero" href="#"><i class="fa fa-circle-o"></i></a>
<a class="workspace-footer-button" id="btn-zoom-in" href="#"><i class="fa fa-plus"></i></a>
<a class="workspace-footer-button-toggle single" id="btn-navigate" href="#"><i class="fa fa-map-o"></i></a>
</div>
<div id="editor-shade" class="hide"></div>
</div>
@@ -131,6 +132,10 @@
<i class="fa fa-tag"></i>
<label for="subflow-input-name" data-i18n="common.label.name"></label><input type="text" id="subflow-input-name">
</div>
<div class="form-row">
<i class="fa fa-folder-o"></i>
<label for="subflow-input-category" data-i18n="editor:subflow.category"></label><select style="width: 250px;" id="subflow-input-category"></select><input style="display:none; margin-left: 10px; width:calc(100% - 250px)" type="text" id="subflow-input-custom-category">
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="subflow-input-info" data-i18n="editor:subflow.info"></label>
<a href="https://help.github.com/articles/markdown-basics/" style="font-size: 0.8em; float: right;" data-i18n="[html]subflow.format"></a>
@@ -140,76 +145,6 @@
</div>
<div class="form-row form-tips" id="subflow-dialog-user-count"></div>
</script>
<script type="text/x-red" data-template-name="_expression">
<div id="node-input-expression-panels">
<div id="node-input-expression-panel-expr" class="red-ui-panel">
<div class="form-row" style="margin-bottom: 3px; text-align: right;">
<span class="node-input-expression-legacy"><i class="fa fa-exclamation-circle"></i> <span data-i18n="expressionEditor.compatMode"></span></span>
<button id="node-input-expression-reformat" class="editor-button editor-button-small"><span data-i18n="expressionEditor.format"></span></button>
</div>
<div class="form-row node-text-editor-row">
<div class="node-text-editor" id="node-input-expression"></div>
</div>
</div>
<div id="node-input-expression-panel-info" class="red-ui-panel">
<div class="form-row">
<ul id="node-input-expression-tabs"></ul>
<div id="node-input-expression-tab-help" class="node-input-expression-tab-content hide">
<div>
<select id="node-input-expression-func"></select>
<button id="node-input-expression-func-insert" class="editor-button" data-i18n="expressionEditor.insert"></button>
</div>
<div id="node-input-expression-help"></div>
</div>
<div id="node-input-expression-tab-test" class="node-input-expression-tab-content hide">
<div>
<span style="display: inline-block; width: calc(50% - 5px);">
<span data-i18n="expressionEditor.data"></span>
<button style="float: right; margin-right: 5px;" id="node-input-example-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button>
</span>
<span style="display: inline-block; width: calc(50% - 5px);" data-i18n="expressionEditor.result"></span>
</div>
<div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-data"></div>
<div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-result"></div>
</div>
</div>
</div>
</div>
</script>
<script type="text/x-red" data-template-name="_json">
<div class="form-row" style="margin-bottom: 3px; text-align: right;">
<button id="node-input-json-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button>
</div>
<div class="form-row node-text-editor-row">
<div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-json"></div>
</div>
</script>
<script type="text/x-red" data-template-name="_markdown">
<div class="form-row" id="node-input-markdown-title" style="margin-bottom: 3px; text-align: right;">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-markdown"></div>
</div>
</script>
<script type="text/x-red" data-template-name="_buffer">
<div id="node-input-buffer-panels">
<div id="node-input-buffer-panel-str" class="red-ui-panel">
<div class="form-row" style="margin-bottom: 3px; text-align: right;">
<span class="node-input-buffer-type"><i class="fa fa-exclamation-circle"></i> <span id="node-input-buffer-type-string" data-i18n="bufferEditor.modeString"></span><span id="node-input-buffer-type-array" data-i18n="bufferEditor.modeArray"></span></span>
</div>
<div class="form-row node-text-editor-row">
<div class="node-text-editor" id="node-input-buffer-str"></div>
</div>
</div>
<div id="node-input-buffer-panel-bin" class="red-ui-panel">
<div class="form-row node-text-editor-row" style="margin-top: 10px">
<div class="node-text-editor" id="node-input-buffer-bin"></div>
</div>
</div>
</div>
</script>
<script src="vendor/vendor.js"></script>
<script src="vendor/jsonata/jsonata.min.js"></script>
<script src="vendor/ace/ace.js"></script>

1
editor/vendor/ace/snippets/json.js vendored Normal file
View File

@@ -0,0 +1 @@
ace.define("ace/snippets/json",["require","exports","module"],function(e,t,n){"use strict";t.snippetText=undefined,t.scope="json"})

1
editor/vendor/ace/snippets/sql.js vendored Normal file
View File

@@ -0,0 +1 @@
ace.define("ace/snippets/sql",["require","exports","module"],function(e,t,n){"use strict";t.snippetText="snippet tbl\n create table ${1:table} (\n ${2:columns}\n );\nsnippet col\n ${1:name} ${2:type} ${3:default ''} ${4:not null}\nsnippet ccol\n ${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null}\nsnippet ncol\n ${1:name} number ${3:default 0} ${4:not null}\nsnippet dcol\n ${1:name} date ${3:default sysdate} ${4:not null}\nsnippet ind\n create index ${3:$1_$2} on ${1:table}(${2:column});\nsnippet uind\n create unique index ${1:name} on ${2:table}(${3:column});\nsnippet tblcom\n comment on table ${1:table} is '${2:comment}';\nsnippet colcom\n comment on column ${1:table}.${2:column} is '${3:comment}';\nsnippet addcol\n alter table ${1:table} add (${2:column} ${3:type});\nsnippet seq\n create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};\nsnippet s*\n select * from ${1:table}\n",t.scope="sql"})

1
editor/vendor/ace/snippets/swift.js vendored Normal file
View File

@@ -0,0 +1 @@
ace.define("ace/snippets/swift",["require","exports","module"],function(e,t,n){"use strict";t.snippetText=undefined,t.scope="swift"})

View File

@@ -117,6 +117,7 @@
'$contains':{ args:[ 'str', 'pattern' ]},
'$count':{ args:[ 'array' ]},
'$each':{ args:[ 'object', 'function' ]},
'$env': { args:[ 'arg' ]},
'$exists':{ args:[ 'arg' ]},
'$filter':{ args:[ 'array', 'function' ]},
'$floor':{ args:[ 'number' ]},

View File

@@ -237,10 +237,9 @@ If you want every 20 minutes from now - use the <i>"interval"</i> option.</p>
} else {
return this._("inject.timestamp")+suffix;
}
} else if (this.payloadType === 'flow' && this.payload.length < 19) {
return 'flow.'+this.payload+suffix;
} else if (this.payloadType === 'global' && this.payload.length < 17) {
return 'global.'+this.payload+suffix;
} else if (this.payloadType === 'flow' || this.payloadType === 'global') {
var key = RED.utils.parseContextKey(this.payload);
return this.payloadType+"."+key.key+suffix;
} else {
return this._("inject.inject")+suffix;
}
@@ -263,7 +262,7 @@ If you want every 20 minutes from now - use the <i>"interval"</i> option.</p>
$("#node-input-payload").typedInput({
default: 'str',
typeField: $("#node-input-payloadType"),
types:['flow','global','str','num','bool','json','bin','date']
types:['flow','global','str','num','bool','json','bin','date','env']
});
$("#inject-time-type-select").change(function() {
@@ -502,7 +501,13 @@ If you want every 20 minutes from now - use the <i>"interval"</i> option.</p>
if (this.changed) {
return RED.notify(RED._("notification.warning", {message:RED._("notification.warnings.undeployedChanges")}),"warning");
}
var label = (this.name||this.payload);
var payload = this.payload;
if ((this.payloadType === 'flow') ||
(this.payloadType === 'global')) {
var key = RED.utils.parseContextKey(payload);
payload = this.payloadType+"."+key.key;
}
var label = (this.name||payload);
if (label.length > 30) {
label = label.substring(0,50)+"...";
}

View File

@@ -63,21 +63,33 @@ module.exports = function(RED) {
}
this.on("input",function(msg) {
try {
msg.topic = this.topic;
if ( (this.payloadType == null && this.payload === "") || this.payloadType === "date") {
msg.payload = Date.now();
} else if (this.payloadType == null) {
msg.payload = this.payload;
} else if (this.payloadType === 'none') {
msg.payload = "";
} else {
msg.payload = RED.util.evaluateNodeProperty(this.payload,this.payloadType,this,msg);
msg.topic = this.topic;
if (this.payloadType !== 'flow' && this.payloadType !== 'global') {
try {
if ( (this.payloadType == null && this.payload === "") || this.payloadType === "date") {
msg.payload = Date.now();
} else if (this.payloadType == null) {
msg.payload = this.payload;
} else if (this.payloadType === 'none') {
msg.payload = "";
} else {
msg.payload = RED.util.evaluateNodeProperty(this.payload,this.payloadType,this,msg);
}
this.send(msg);
msg = null;
} catch(err) {
this.error(err,msg);
}
this.send(msg);
msg = null;
} catch(err) {
this.error(err,msg);
} else {
RED.util.evaluateNodeProperty(this.payload,this.payloadType,this,msg, function(err,res) {
if (err) {
node.error(err,msg);
} else {
msg.payload = res;
node.send(msg);
}
});
}
});
}

View File

@@ -154,7 +154,9 @@
name: this._("debug.sidebar.name"),
content: uiComponents.content,
toolbar: uiComponents.footer,
enableOnEdit: true
enableOnEdit: true,
pinned: true,
iconClass: "fa fa-bug"
});
RED.actions.add("core:show-debug-tab",function() { RED.sidebar.show('debug'); });
@@ -181,7 +183,7 @@
this.handleDebugMessage = function(t,o) {
var sourceNode = RED.nodes.node(o.id) || RED.nodes.node(o.z);
if (sourceNode) {
o._source = {id:sourceNode.id,z:sourceNode.z,name:sourceNode.name};
o._source = {id:sourceNode.id,z:sourceNode.z,name:sourceNode.name,type:sourceNode.type,_alias:o._alias};
}
RED.debug.handleDebugMessage(o);
if (subWindow) {

View File

@@ -4,7 +4,6 @@ module.exports = function(RED) {
var util = require("util");
var events = require("events");
var path = require("path");
var safeJSONStringify = require("json-stringify-safe");
var debuglength = RED.settings.debugMaxLength || 1000;
var useColors = RED.settings.debugUseColors || false;
util.inspect.styles.boolean = "red";
@@ -104,111 +103,7 @@ module.exports = function(RED) {
function sendDebug(msg) {
// don't put blank errors in sidebar (but do add to logs)
//if ((msg.msg === "") && (msg.hasOwnProperty("level")) && (msg.level === 20)) { return; }
if (msg.msg instanceof Error) {
msg.format = "error";
var errorMsg = {};
if (msg.msg.name) {
errorMsg.name = msg.msg.name;
}
if (msg.msg.hasOwnProperty('message')) {
errorMsg.message = msg.msg.message;
} else {
errorMsg.message = msg.msg.toString();
}
msg.msg = JSON.stringify(errorMsg);
} else if (msg.msg instanceof Buffer) {
msg.format = "buffer["+msg.msg.length+"]";
msg.msg = msg.msg.toString('hex');
if (msg.msg.length > debuglength) {
msg.msg = msg.msg.substring(0,debuglength);
}
} else if (msg.msg && typeof msg.msg === 'object') {
try {
msg.format = msg.msg.constructor.name || "Object";
// Handle special case of msg.req/res objects from HTTP In node
if (msg.format === "IncomingMessage" || msg.format === "ServerResponse") {
msg.format = "Object";
}
} catch(err) {
msg.format = "Object";
}
if (/error/i.test(msg.format)) {
msg.msg = JSON.stringify({
name: msg.msg.name,
message: msg.msg.message
});
} else {
var isArray = util.isArray(msg.msg);
if (isArray) {
msg.format = "array["+msg.msg.length+"]";
if (msg.msg.length > debuglength) {
// msg.msg = msg.msg.slice(0,debuglength);
msg.msg = {
__encoded__: true,
type: "array",
data: msg.msg.slice(0,debuglength),
length: msg.msg.length
}
}
}
if (isArray || (msg.format === "Object")) {
msg.msg = safeJSONStringify(msg.msg, function(key, value) {
if (key === '_req' || key === '_res') {
value = "[internal]"
} else if (value instanceof Error) {
value = value.toString()
} else if (util.isArray(value) && value.length > debuglength) {
value = {
__encoded__: true,
type: "array",
data: value.slice(0,debuglength),
length: value.length
}
} else if (typeof value === 'string') {
if (value.length > debuglength) {
value = value.substring(0,debuglength)+"...";
}
} else if (value && value.constructor) {
if (value.type === "Buffer") {
value.__encoded__ = true;
value.length = value.data.length;
if (value.length > debuglength) {
value.data = value.data.slice(0,debuglength);
}
} else if (value.constructor.name === "ServerResponse") {
value = "[internal]"
} else if (value.constructor.name === "Socket") {
value = "[internal]"
}
}
return value;
}," ");
} else {
try { msg.msg = msg.msg.toString(); }
catch(e) { msg.msg = "[Type not printable]"; }
}
}
} else if (typeof msg.msg === "boolean") {
msg.format = "boolean";
msg.msg = msg.msg.toString();
} else if (typeof msg.msg === "number") {
msg.format = "number";
msg.msg = msg.msg.toString();
} else if (msg.msg === 0) {
msg.format = "number";
msg.msg = "0";
} else if (msg.msg === null || typeof msg.msg === "undefined") {
msg.format = (msg.msg === null)?"null":"undefined";
msg.msg = "(undefined)";
} else {
msg.format = "string["+msg.msg.length+"]";
if (msg.msg.length > debuglength) {
msg.msg = msg.msg.substring(0,debuglength)+"...";
}
}
// if (msg.msg.length > debuglength) {
// msg.msg = msg.msg.substr(0,debuglength) +" ....";
// }
msg = RED.util.encodeObject(msg,{maxLength:debuglength});
RED.comms.publish("debug",msg);
}

View File

@@ -138,7 +138,7 @@
icon: "arrow-in.png",
align: "right",
label: function() {
return this.name||this.command;
return this.name||this.command||(this.useSpawn=="true"?this._("exec.spawn"):this._("exec.exec"));
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@@ -9,7 +9,8 @@
<input type="hidden" id="node-input-func" autofocus="autofocus">
<input type="hidden" id="node-input-noerr">
</div>
<div class="form-row node-text-editor-row">
<div class="form-row node-text-editor-row" style="position:relative">
<div style="position: absolute; right:0; bottom:calc(100% + 3px);"><button id="node-function-expand-js" class="editor-button editor-button-small"><i class="fa fa-expand"></i></button></div>
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-func-editor" ></div>
</div>
<div class="form-row">
@@ -52,6 +53,12 @@
<p>The Catch node can also be used to handle errors. To invoke a Catch node,
pass <code>msg</code> as a second argument to <code>node.error</code>:</p>
<pre>node.error("Error",msg);</pre>
<h4>Referring Node Information</h4>
<p>In the function block, id and name of the node can be referenced using the following properties:</p>
<ul>
<li><code>node.id</code> - id of the node</li>
<li><code>node.name</code> - name of the node</li>
</ul>
</script>
<script type="text/javascript">
@@ -68,7 +75,7 @@
outputs:1,
icon: "function.png",
label: function() {
return this.name;
return this.name||this._("function.function");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
@@ -113,6 +120,22 @@
fields:['name','outputs']
});
this.editor.focus();
$("#node-function-expand-js").click(function(e) {
e.preventDefault();
var value = that.editor.getValue();
RED.editor.editJavaScript({
value: value,
cursor: that.editor.getCursorPosition(),
complete: function(v,cursor) {
that.editor.setValue(v, -1);
that.editor.gotoLine(cursor.row+1,cursor.column,false);
setTimeout(function() {
that.editor.focus();
},300);
}
})
})
},
oneditsave: function() {
var annot = this.editor.getSession().getAnnotations();

View File

@@ -62,9 +62,13 @@ module.exports = function(RED) {
"results = (function(msg){ "+
"var __msgid__ = msg._msgid;"+
"var node = {"+
"id:__node__.id,"+
"name:__node__.name,"+
"log:__node__.log,"+
"error:__node__.error,"+
"warn:__node__.warn,"+
"debug:__node__.debug,"+
"trace:__node__.trace,"+
"on:__node__.on,"+
"status:__node__.status,"+
"send:function(msgs){ __node__.send(__msgid__,msgs);}"+
@@ -78,10 +82,13 @@ module.exports = function(RED) {
console:console,
util:util,
Buffer:Buffer,
Date: Date,
RED: {
util: RED.util
},
__node__: {
id: node.id,
name: node.name,
log: function() {
node.log.apply(node, arguments);
},
@@ -91,6 +98,12 @@ module.exports = function(RED) {
warn: function() {
node.warn.apply(node, arguments);
},
debug: function() {
node.debug.apply(node, arguments);
},
trace: function() {
node.trace.apply(node, arguments);
},
send: function(id, msgs) {
sendResults(node, id, msgs);
},
@@ -196,7 +209,14 @@ module.exports = function(RED) {
}
var context = vm.createContext(sandbox);
try {
this.script = vm.createScript(functionText);
this.script = vm.createScript(functionText, {
filename: 'Function node:'+this.id+(this.name?' ['+this.name+']':''), // filename for stack traces
displayErrors: true
// Using the following options causes node 4/6 to not include the line number
// in the stack output. So don't use them.
// lineOffset: -11, // line number offset to be used for stack traces
// columnOffset: 0, // column number offset to be used for stack traces
});
this.on("input", function(msg) {
try {
var start = process.hrtime();
@@ -211,6 +231,13 @@ module.exports = function(RED) {
this.status({fill:"yellow",shape:"dot",text:""+converted});
}
} catch(err) {
//remove unwanted part
var index = err.stack.search(/\n\s*at ContextifyScript.Script.runInContext/);
err.stack = err.stack.slice(0, index).split('\n').slice(0,-1).join('\n');
var stack = err.stack.split(/\r?\n/);
//store the error in msg to be used in flows
msg.error = err;
var line = 0;
var errorMessage;

View File

@@ -77,7 +77,9 @@
}</pre>
<p>The resulting property will be:
<pre>Hello Fred. Today is Monday</pre>
<p>It is possible to use a property from the flow context or global context. Just use <code>{{flow.name}}</code> or <code>{{global.name}}</code>.
<p>It is possible to use a property from the flow context or global context. Just use <code>{{flow.name}}</code> or
<code>{{global.name}}</code>, or for persistable store <code>store</code> use <code>{{flow[store].name}}</code> or
<code>{{global[store].name}}</code>.
<p><b>Note: </b>By default, <i>mustache</i> will escape any HTML entities in the values it substitutes.
To prevent this, use <code>{{{triple}}}</code> braces.
</script>
@@ -88,7 +90,7 @@
category: 'function',
defaults: {
name: {value:""},
field: {value:"payload", validate: RED.validators.typedInput("fieldType")},
field: {value:"payload", validate:RED.validators.typedInput("fieldType")},
fieldType: {value:"msg"},
format: {value:"handlebars"},
syntax: {value:"mustache"},
@@ -99,13 +101,17 @@
outputs:1,
icon: "template.png",
label: function() {
return this.name;
return this.name||this._("template.template");;
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
var that = this;
if (!this.field) {
this.field = 'payload';
$("#node-input-field").val("payload");
}
if (!this.fieldType) {
this.fieldType = 'msg';
}

View File

@@ -19,15 +19,41 @@ module.exports = function(RED) {
var mustache = require("mustache");
var yaml = require("js-yaml");
function extractTokens(tokens,set) {
set = set || new Set();
tokens.forEach(function(token) {
if (token[0] !== 'text') {
set.add(token[1]);
if (token.length > 4) {
extractTokens(token[4],set);
}
}
});
return set;
}
function parseContext(key) {
var match = /^(flow|global)(\[(\w+)\])?\.(.+)/.exec(key);
if (match) {
var parts = {};
parts.type = match[1];
parts.store = (match[3] === '') ? "default" : match[3];
parts.field = match[4];
return parts;
}
return undefined;
}
/**
* Custom Mustache Context capable to resolve message property and node
* Custom Mustache Context capable to collect message property and node
* flow and global context
*/
function NodeContext(msg, nodeContext, parent, escapeStrings) {
function NodeContext(msg, nodeContext, parent, escapeStrings, cachedContextTokens) {
this.msgContext = new mustache.Context(msg,parent);
this.nodeContext = nodeContext;
this.escapeStrings = escapeStrings;
this.cachedContextTokens = cachedContextTokens;
}
NodeContext.prototype = new mustache.Context();
@@ -48,26 +74,26 @@ module.exports = function(RED) {
return value;
}
// try node context:
var dot = name.indexOf(".");
if (dot > 0) {
var contextName = name.substr(0, dot);
var variableName = name.substr(dot + 1);
if (contextName === "flow" && this.nodeContext.flow) {
return this.nodeContext.flow.get(variableName);
}
else if (contextName === "global" && this.nodeContext.global) {
return this.nodeContext.global.get(variableName);
// try flow/global context:
var context = parseContext(name);
if (context) {
var type = context.type;
var store = context.store;
var field = context.field;
var target = this.nodeContext[type];
if (target) {
return this.cachedContextTokens[name];
}
}
}catch(err) {
return '';
}
catch(err) {
throw err;
}
}
NodeContext.prototype.push = function push (view) {
return new NodeContext(view, this.nodeContext,this.msgContext);
return new NodeContext(view, this.nodeContext, this.msgContext, undefined, this.cachedContextTokens);
};
function TemplateNode(n) {
@@ -80,45 +106,89 @@ module.exports = function(RED) {
this.outputFormat = n.output || "str";
var node = this;
function output(msg,value) {
/* istanbul ignore else */
if (node.outputFormat === "json") {
value = JSON.parse(value);
}
/* istanbul ignore else */
if (node.outputFormat === "yaml") {
value = yaml.load(value);
}
if (node.fieldType === 'msg') {
RED.util.setMessageProperty(msg, node.field, value);
node.send(msg);
} else if ((node.fieldType === 'flow') ||
(node.fieldType === 'global')) {
var context = RED.util.parseContextStore(node.field);
var target = node.context()[node.fieldType];
target.set(context.key, value, context.store, function (err) {
if (err) {
node.error(err, msg);
} else {
node.send(msg);
}
});
}
}
node.on("input", function(msg) {
try {
var value;
/***
* Allow template contents to be defined externally
* through inbound msg.template IFF node.template empty
*/
var template = node.template;
if (msg.hasOwnProperty("template")) {
if (node.template == "" || node.template === null) {
node.template = msg.template;
if (template == "" || template === null) {
template = msg.template;
}
}
if (node.syntax === "mustache") {
if (node.outputFormat === "json") {
value = mustache.render(node.template,new NodeContext(msg, node.context(), null, true));
} else {
value = mustache.render(node.template,new NodeContext(msg, node.context(), null, false));
}
} else {
value = node.template;
}
if (node.outputFormat === "json") {
value = JSON.parse(value);
}
if (node.outputFormat === "yaml") {
value = yaml.load(value);
}
var is_json = (node.outputFormat === "json");
var promises = [];
var tokens = extractTokens(mustache.parse(template));
var resolvedTokens = {};
tokens.forEach(function(name) {
var context = parseContext(name);
if (context) {
var type = context.type;
var store = context.store;
var field = context.field;
var target = node.context()[type];
if (target) {
var promise = new Promise((resolve, reject) => {
target.get(field, store, (err, val) => {
if (err) {
reject(err);
} else {
resolvedTokens[name] = val;
resolve();
}
});
});
promises.push(promise);
return;
}
}
});
if (node.fieldType === 'msg') {
RED.util.setMessageProperty(msg,node.field,value);
} else if (node.fieldType === 'flow') {
node.context().flow.set(node.field,value);
} else if (node.fieldType === 'global') {
node.context().global.set(node.field,value);
Promise.all(promises).then(function() {
var value = mustache.render(template, new NodeContext(msg, node.context(), null, is_json, resolvedTokens));
output(msg, value);
}).catch(function (err) {
node.error(err.message,msg);
});
} else {
output(msg, template);
}
node.send(msg);
} catch(err) {
node.error(err.message);
}
catch(err) {
node.error(err.message, msg);
}
});
}

View File

@@ -108,7 +108,7 @@
outstanding messages held by the node are cleared without being sent.</dd>
</dl>
<h3>Details</h3>
<p>When configured to delay messages, the delay interval can be a fixed value
<p>When configured to delay messages, the delay interval can be a fixed value,
a random value within a range or dynamically set for each message.</p>
<p>When configured to rate limit messages, their delivery is spread across
the configured time period. The status shows the number of messages currently in the queue.

View File

@@ -162,7 +162,7 @@
$("#node-input-op1").typedInput({
default: 'str',
typeField: $("#node-input-op1type"),
types:['flow','global','str','num','bool','json',
types:['flow','global','str','num','bool','json','bin','date','env',
optionPayload,
optionNothing
]
@@ -170,7 +170,7 @@
$("#node-input-op2").typedInput({
default: 'str',
typeField: $("#node-input-op2type"),
types:['flow','global','str','num','bool','json',
types:['flow','global','str','num','bool','json','bin','date','env',
optionOriginalPayload,
optionLatestPayload,
optionNothing

View File

@@ -76,8 +76,43 @@ module.exports = function(RED) {
var node = this;
node.topics = {};
this.on("input", function(msg) {
var pendingMessages = [];
var activeMessagePromise = null;
var processMessageQueue = function(msg) {
if (msg) {
// A new message has arrived - add it to the message queue
pendingMessages.push(msg);
if (activeMessagePromise !== null) {
// The node is currently processing a message, so do nothing
// more with this message
return;
}
}
if (pendingMessages.length === 0) {
// There are no more messages to process, clear the active flag
// and return
activeMessagePromise = null;
return;
}
// There are more messages to process. Get the next message and
// start processing it. Recurse back in to check for any more
var nextMsg = pendingMessages.shift();
activeMessagePromise = processMessage(nextMsg)
.then(processMessageQueue)
.catch((err) => {
node.error(err,nextMsg);
return processMessageQueue();
});
}
this.on('input', function(msg) {
processMessageQueue(msg);
});
var processMessage = function(msg) {
var topic = msg.topic || "_none";
var promise;
if (node.bytopic === "all") { topic = "_none"; }
node.topics[topic] = node.topics[topic] || {};
if (msg.hasOwnProperty("reset") || ((node.reset !== '') && msg.hasOwnProperty("payload") && (msg.payload !== null) && msg.payload.toString && (msg.payload.toString() == node.reset)) ) {
@@ -88,46 +123,88 @@ module.exports = function(RED) {
}
else {
if (((!node.topics[topic].tout) && (node.topics[topic].tout !== 0)) || (node.loop === true)) {
promise = Promise.resolve();
if (node.op2type === "pay" || node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); }
else if (node.op2Templated) { node.topics[topic].m2 = mustache.render(node.op2,msg); }
else if (node.op2type !== "nul") {
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
}
if (node.op1type === "pay") { }
else if (node.op1Templated) { msg.payload = mustache.render(node.op1,msg); }
else if (node.op1type !== "nul") {
msg.payload = RED.util.evaluateNodeProperty(node.op1,node.op1type,node,msg);
}
if (node.op1type !== "nul") { node.send(RED.util.cloneMessage(msg)); }
if (node.duration === 0) { node.topics[topic].tout = 0; }
else if (node.loop === true) {
/* istanbul ignore else */
if (node.topics[topic].tout) { clearInterval(node.topics[topic].tout); }
/* istanbul ignore else */
if (node.op1type !== "nul") {
var msg2 = RED.util.cloneMessage(msg);
node.topics[topic].tout = setInterval(function() { node.send(RED.util.cloneMessage(msg2)); }, node.duration);
}
}
else {
node.topics[topic].tout = setTimeout(function() {
var msg2 = null;
if (node.op2type !== "nul") {
msg2 = RED.util.cloneMessage(msg);
if (node.op2type === "flow" || node.op2type === "global") {
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
promise = new Promise((resolve,reject) => {
RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg,(err,value) => {
if (err) {
reject(err);
} else {
node.topics[topic].m2 = value;
resolve();
}
msg2.payload = node.topics[topic].m2;
}
delete node.topics[topic];
node.status({});
node.send(msg2);
}, node.duration);
});
});
}
node.status({fill:"blue",shape:"dot",text:" "});
return promise.then(() => {
promise = Promise.resolve();
if (node.op1type === "pay") { }
else if (node.op1Templated) { msg.payload = mustache.render(node.op1,msg); }
else if (node.op1type !== "nul") {
promise = new Promise((resolve,reject) => {
RED.util.evaluateNodeProperty(node.op1,node.op1type,node,msg,(err,value) => {
if (err) {
reject(err);
} else {
msg.payload = value;
resolve();
}
});
});
}
return promise.then(() => {
if (node.duration === 0) { node.topics[topic].tout = 0; }
else if (node.loop === true) {
/* istanbul ignore else */
if (node.topics[topic].tout) { clearInterval(node.topics[topic].tout); }
/* istanbul ignore else */
if (node.op1type !== "nul") {
var msg2 = RED.util.cloneMessage(msg);
node.topics[topic].tout = setInterval(function() { node.send(RED.util.cloneMessage(msg2)); }, node.duration);
}
}
else {
if (!node.topics[topic].tout) {
node.topics[topic].tout = setTimeout(function() {
var msg2 = null;
if (node.op2type !== "nul") {
var promise = Promise.resolve();
msg2 = RED.util.cloneMessage(msg);
if (node.op2type === "flow" || node.op2type === "global") {
promise = new Promise((resolve,reject) => {
RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg,(err,value) => {
if (err) {
reject(err);
} else {
node.topics[topic].m2 = value;
resolve();
}
});
});
}
promise.then(() => {
msg2.payload = node.topics[topic].m2;
delete node.topics[topic];
node.send(msg2);
node.status({});
}).catch(err => {
node.error(err);
});
} else {
delete node.topics[topic];
node.status({});
}
}, node.duration);
}
}
node.status({fill:"blue",shape:"dot",text:" "});
if (node.op1type !== "nul") { node.send(RED.util.cloneMessage(msg)); }
});
});
}
else if ((node.extend === "true" || node.extend === true) && (node.duration > 0)) {
/* istanbul ignore else */
@@ -136,25 +213,43 @@ module.exports = function(RED) {
if (node.topics[topic].tout) { clearTimeout(node.topics[topic].tout); }
node.topics[topic].tout = setTimeout(function() {
var msg2 = null;
var promise = Promise.resolve();
if (node.op2type !== "nul") {
if (node.op2type === "flow" || node.op2type === "global") {
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
}
if (node.topics[topic] !== undefined) {
msg2 = RED.util.cloneMessage(msg);
msg2.payload = node.topics[topic].m2;
promise = new Promise((resolve,reject) => {
RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg,(err,value) => {
if (err) {
reject(err);
} else {
node.topics[topic].m2 = value;
resolve();
}
});
});
}
}
delete node.topics[topic];
node.status({});
node.send(msg2);
promise.then(() => {
if (node.op2type !== "nul") {
if (node.topics[topic] !== undefined) {
msg2 = RED.util.cloneMessage(msg);
msg2.payload = node.topics[topic].m2;
}
}
delete node.topics[topic];
node.status({});
node.send(msg2);
}).catch(err => {
node.error(err);
});
}, node.duration);
}
else {
if (node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); }
}
}
});
return Promise.resolve();
}
this.on("close", function() {
for (var t in node.topics) {
/* istanbul ignore else */

View File

@@ -33,7 +33,7 @@
outputs:0,
icon: "comment.png",
label: function() {
return this.name||"";
return this.name||this._("comment.comment");
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@@ -222,7 +222,6 @@ RED.debug = (function() {
clearMessageList(false);
});
return {
content: content,
footer: footerToolbar
@@ -238,6 +237,9 @@ RED.debug = (function() {
workspaceOrder.forEach(function(ws,i) {
workspaceOrderMap[ws] = i;
});
candidateNodes = candidateNodes.filter(function(node) {
return workspaceOrderMap.hasOwnProperty(node.z);
})
candidateNodes.sort(function(A,B) {
var wsA = workspaceOrderMap[A.z];
var wsB = workspaceOrderMap[B.z];
@@ -339,7 +341,7 @@ RED.debug = (function() {
activeMenuMessage.clearPinned();
}},
null,
{id:"debug-message-menu-item-filter",label:RED._("node-red:debug.messageMenu.filterNode"),onselect:function(){
{id:"debug-message-menu-item-filter", label:RED._("node-red:debug.messageMenu.filterNode"),onselect:function(){
var candidateNodes = RED.nodes.filterNodes({type:'debug'});
candidateNodes.forEach(function(n) {
filteredNodes[n.id] = true;
@@ -361,6 +363,15 @@ RED.debug = (function() {
menuOptionMenu.on('mouseup', function() { $(this).hide() });
menuOptionMenu.appendTo("body");
}
var filterOptionDisabled = false;
var sourceNode = RED.nodes.node(sourceId);
if (sourceNode && sourceNode.type !== 'debug') {
filterOptionDisabled = true;
}
RED.menu.setDisabled('debug-message-menu-item-filter',filterOptionDisabled);
RED.menu.setDisabled('debug-message-menu-item-clear-filter',filterOptionDisabled);
var elementPos = button.offset();
menuOptionMenu.css({
top: elementPos.top+"px",
@@ -392,12 +403,19 @@ RED.debug = (function() {
$(msg).addClass('debug-message-hover');
if (o._source) {
config.messageMouseEnter(o._source.id);
if (o._source._alias) {
config.messageMouseEnter(o._source._alias);
}
}
};
msg.onmouseleave = function() {
$(msg).removeClass('debug-message-hover');
if (o._source) {
config.messageMouseLeave(o._source.id);
if (o._source._alias) {
config.messageMouseLeave(o._source._alias);
}
}
};
var name = sanitize(((o.name?o.name:o.id)||"").toString());
@@ -437,24 +455,8 @@ RED.debug = (function() {
$('<span class="debug-message-name">'+name+'</span>').appendTo(metaRow);
}
if ((format === 'number') && (payload === "NaN")) {
payload = Number.NaN;
} else if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number' ) {
payload = JSON.parse(payload);
} else if (/error/i.test(format)) {
payload = JSON.parse(payload);
payload = (payload.name?payload.name+": ":"")+payload.message;
} else if (format === 'null') {
payload = null;
} else if (format === 'undefined') {
payload = undefined;
} else if (/^buffer/.test(format)) {
var buffer = payload;
payload = [];
for (var c = 0; c < buffer.length; c += 2) {
payload.push(parseInt(buffer.substr(c, 2), 16));
}
}
payload = RED.utils.decodeObject(payload,format);
var el = $('<span class="debug-message-payload"></span>').appendTo(msg);
var path = o.property||'';
var debugMessage = RED.utils.createObjectElement(payload, {

View File

@@ -179,7 +179,7 @@
<dt>payload <span class="property-type">number</span></dt>
<dd>the payload will be a 1 or a 0.</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>the topic will be set to `pi/{the pin number}`.</dd>
<dd>the topic will be set to <code>pi/{the pin number}</code>.</dd>
</dl>
<h3>Details</h3>
<p>You may also enable the input pullup resistor or the pulldown resistor.</p>

View File

@@ -6,35 +6,36 @@ module.exports = function(RED) {
var fs = require('fs');
var gpioCommand = __dirname+'/nrgpio';
var allOK = true;
try {
var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString();
if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); }
} catch(err) {
throw "Info : "+RED._("rpi-gpio.errors.ignorenode");
}
try {
fs.statSync("/usr/share/doc/python-rpi.gpio"); // test on Raspbian
// /usr/lib/python2.7/dist-packages/RPi/GPIO
} catch(err) {
if (cpuinfo.indexOf(": BCM") === -1) {
allOK = false;
RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.ignorenode"));
}
try {
fs.statSync("/usr/lib/python2.7/site-packages/RPi/GPIO"); // test on Arch
}
catch(err) {
fs.statSync("/usr/share/doc/python-rpi.gpio"); // test on Raspbian
// /usr/lib/python2.7/dist-packages/RPi/GPIO
} catch(err) {
try {
fs.statSync("/usr/lib/python2.7/dist-packages/RPi/GPIO"); // test on Hypriot
}
catch(err) {
RED.log.warn(RED._("rpi-gpio.errors.libnotfound"));
throw "Warning : "+RED._("rpi-gpio.errors.libnotfound");
fs.statSync("/usr/lib/python2.7/site-packages/RPi/GPIO"); // test on Arch
} catch(err) {
try {
fs.statSync("/usr/lib/python2.7/dist-packages/RPi/GPIO"); // test on Hypriot
} catch(err) {
RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.libnotfound"));
allOK = false;
}
}
}
}
if ( !(1 & parseInt((fs.statSync(gpioCommand).mode & parseInt("777", 8)).toString(8)[0]) )) {
RED.log.error(RED._("rpi-gpio.errors.needtobeexecutable",{command:gpioCommand}));
throw "Error : "+RED._("rpi-gpio.errors.mustbeexecutable");
if ( !(1 & parseInt((fs.statSync(gpioCommand).mode & parseInt("777", 8)).toString(8)[0]) )) {
RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.needtobeexecutable",{command:gpioCommand}));
allOK = false;
}
} catch(err) {
allOK = false;
RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.ignorenode"));
}
// the magic to make python print stuff immediately
@@ -61,48 +62,62 @@ module.exports = function(RED) {
}
}
if (node.pin !== undefined) {
node.child = spawn(gpioCommand, ["in",node.pin,node.intype,node.debounce]);
node.running = true;
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
if (allOK === true) {
if (node.pin !== undefined) {
node.child = spawn(gpioCommand, ["in",node.pin,node.intype,node.debounce]);
node.running = true;
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {
var d = data.toString().trim().split("\n");
for (var i = 0; i < d.length; i++) {
if (d[i] === '') { return; }
if (node.running && node.buttonState !== -1 && !isNaN(Number(d[i])) && node.buttonState !== d[i]) {
node.send({ topic:"pi/"+node.pin, payload:Number(d[i]) });
node.child.stdout.on('data', function (data) {
var d = data.toString().trim().split("\n");
for (var i = 0; i < d.length; i++) {
if (d[i] === '') { return; }
if (node.running && node.buttonState !== -1 && !isNaN(Number(d[i])) && node.buttonState !== d[i]) {
node.send({ topic:"pi/"+node.pin, payload:Number(d[i]) });
}
node.buttonState = d[i];
node.status({fill:"green",shape:"dot",text:d[i]});
if (RED.settings.verbose) { node.log("out: "+d[i]+" :"); }
}
node.buttonState = d[i];
node.status({fill:"green",shape:"dot",text:d[i]});
if (RED.settings.verbose) { node.log("out: "+d[i]+" :"); }
}
});
});
node.child.stderr.on('data', function (data) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); }
});
node.child.stderr.on('data', function (data) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); }
});
node.child.on('close', function (code) {
node.running = false;
node.child = null;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('close', function (code) {
node.running = false;
node.child = null;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error",{error:err.errno})) }
});
node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error",{error:err.errno})) }
});
}
else {
node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin);
}
}
else {
node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin);
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
if (node.read === true) {
var val;
if (node.intype == "up") { val = 1; }
if (node.intype == "down") { val = 0; }
setTimeout(function(){
node.send({ topic:"pi/"+node.pin, payload:val });
node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:val})});
},250);
}
}
node.on("close", function(done) {
@@ -142,9 +157,9 @@ module.exports = function(RED) {
var limit = 1;
if (node.out === "pwm") { limit = 100; }
if ((out >= 0) && (out <= limit)) {
if (RED.settings.verbose) { node.log("out: "+msg.payload); }
if (RED.settings.verbose) { node.log("out: "+out); }
if (node.child !== null) {
node.child.stdin.write(msg.payload+"\n");
node.child.stdin.write(out+"\n");
node.status({fill:"green",shape:"dot",text:msg.payload.toString()});
}
else {
@@ -155,20 +170,83 @@ module.exports = function(RED) {
else { node.warn(RED._("rpi-gpio.errors.invalidinput")+": "+out); }
}
if (node.pin !== undefined) {
if (node.set && (node.out === "out")) {
node.child = spawn(gpioCommand, [node.out,node.pin,node.level]);
node.status({fill:"green",shape:"dot",text:node.level});
} else {
node.child = spawn(gpioCommand, [node.out,node.pin,node.freq]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
}
node.running = true;
if (allOK === true) {
if (node.pin !== undefined) {
if (node.set && (node.out === "out")) {
node.child = spawn(gpioCommand, [node.out,node.pin,node.level]);
node.status({fill:"green",shape:"dot",text:node.level});
} else {
node.child = spawn(gpioCommand, [node.out,node.pin,node.freq]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
}
node.running = true;
node.on("input", inputlistener);
node.on("input", inputlistener);
node.child.stdout.on('data', function (data) {
if (RED.settings.verbose) { node.log("out: "+data+" :"); }
});
node.child.stderr.on('data', function (data) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); }
});
node.child.on('close', function (code) {
node.child = null;
node.running = false;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); }
});
}
else {
node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin);
}
}
else {
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
node.on("input", function(msg){
node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:msg.payload.toString()})});
});
}
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
delete pinsInUse[node.pin];
if (node.child != null) {
node.done = done;
node.child.stdin.write("close "+node.pin);
node.child.kill('SIGKILL');
}
else { done(); }
});
}
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
function PiMouseNode(n) {
RED.nodes.createNode(this,n);
this.butt = n.butt || 7;
var node = this;
if (allOK === true) {
node.child = spawn(gpioCommand+".py", ["mouse",node.butt]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {
if (RED.settings.verbose) { node.log("out: "+data+" :"); }
data = Number(data);
if (data !== 0) { node.send({ topic:"pi/mouse", button:data, payload:1 }); }
else { node.send({ topic:"pi/mouse", button:data, payload:0 }); }
});
node.child.stderr.on('data', function (data) {
@@ -192,69 +270,19 @@ module.exports = function(RED) {
else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); }
});
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
if (node.child != null) {
node.done = done;
node.child.kill('SIGINT');
node.child = null;
}
else { done(); }
});
}
else {
node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin);
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
}
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
delete pinsInUse[node.pin];
if (node.child != null) {
node.done = done;
node.child.stdin.write("close "+node.pin);
node.child.kill('SIGKILL');
}
else { done(); }
});
}
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
function PiMouseNode(n) {
RED.nodes.createNode(this,n);
this.butt = n.butt || 7;
var node = this;
node.child = spawn(gpioCommand+".py", ["mouse",node.butt]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {
data = Number(data);
if (data === 1) { node.send({ topic:"pi/mouse", button:data, payload:1 }); }
else { node.send({ topic:"pi/mouse", button:data, payload:0 }); }
});
node.child.stderr.on('data', function (data) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); }
});
node.child.on('close', function (code) {
node.child = null;
node.running = false;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); }
});
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
if (node.child != null) {
node.done = done;
node.child.kill('SIGINT');
node.child = null;
}
else { done(); }
});
}
RED.nodes.registerType("rpi-mouse",PiMouseNode);
@@ -262,39 +290,40 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
var node = this;
node.child = spawn(gpioCommand+".py", ["kbd","0"]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
if (allOK === true) {
node.child = spawn(gpioCommand+".py", ["kbd","0"]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {
var b = data.toString().trim().split(",");
var act = "up";
if (b[1] === "1") { act = "down"; }
if (b[1] === "2") { act = "repeat"; }
node.send({ topic:"pi/key", payload:Number(b[0]), action:act });
});
node.child.stdout.on('data', function (data) {
var b = data.toString().trim().split(",");
var act = "up";
if (b[1] === "1") { act = "down"; }
if (b[1] === "2") { act = "repeat"; }
node.send({ topic:"pi/key", payload:Number(b[0]), action:act });
});
node.child.stderr.on('data', function (data) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); }
});
node.child.stderr.on('data', function (data) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); }
});
node.child.on('close', function (code) {
node.running = false;
node.child = null;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('close', function (code) {
node.running = false;
node.child = null;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); }
});
node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); }
});
node.on("close", function(done) {
node.on("close", function(done) {
node.status({});
if (node.child != null) {
node.done = done;
@@ -303,24 +332,30 @@ module.exports = function(RED) {
}
else { done(); }
});
}
else {
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
}
}
RED.nodes.registerType("rpi-keyboard",PiKeyboardNode);
var pitype = { type:"" };
exec(gpioCommand+" info", function(err,stdout,stderr) {
if (err) {
RED.log.info(RED._("rpi-gpio.errors.version"));
}
else {
try {
var info = JSON.parse( stdout.trim().replace(/\'/g,"\"") );
pitype.type = info["TYPE"];
if (allOK === true) {
exec(gpioCommand+" info", function(err,stdout,stderr) {
if (err) {
RED.log.info(RED._("rpi-gpio.errors.version"));
}
catch(e) {
RED.log.info(RED._("rpi-gpio.errors.sawpitype"),stdout.trim());
else {
try {
var info = JSON.parse( stdout.trim().replace(/\'/g,"\"") );
pitype.type = info["TYPE"];
}
catch(e) {
RED.log.info(RED._("rpi-gpio.errors.sawpitype"),stdout.trim());
}
}
}
});
});
}
RED.httpAdmin.get('/rpi-gpio/:id', RED.auth.needsPermission('rpi-gpio.read'), function(req,res) {
res.json(pitype);

View File

@@ -23,10 +23,6 @@ from time import sleep
bounce = 25;
if sys.version_info >= (3,0):
print("Sorry - currently only configured to work with python 2.x")
sys.exit(1)
if len(sys.argv) > 2:
cmd = sys.argv[1].lower()
pin = int(sys.argv[2])
@@ -34,7 +30,7 @@ if len(sys.argv) > 2:
GPIO.setwarnings(False)
if cmd == "pwm":
#print "Initialised pin "+str(pin)+" to PWM"
#print("Initialised pin "+str(pin)+" to PWM")
try:
freq = int(sys.argv[3])
except:
@@ -54,10 +50,10 @@ if len(sys.argv) > 2:
GPIO.cleanup(pin)
sys.exit(0)
except Exception as ex:
print "bad data: "+data
print("bad data: "+data)
elif cmd == "buzz":
#print "Initialised pin "+str(pin)+" to Buzz"
#print("Initialised pin "+str(pin)+" to Buzz")
GPIO.setup(pin,GPIO.OUT)
p = GPIO.PWM(pin, 100)
p.stop()
@@ -76,10 +72,10 @@ if len(sys.argv) > 2:
GPIO.cleanup(pin)
sys.exit(0)
except Exception as ex:
print "bad data: "+data
print("bad data: "+data)
elif cmd == "out":
#print "Initialised pin "+str(pin)+" to OUT"
#print("Initialised pin "+str(pin)+" to OUT")
GPIO.setup(pin,GPIO.OUT)
if len(sys.argv) == 4:
GPIO.output(pin,int(sys.argv[3]))
@@ -103,11 +99,11 @@ if len(sys.argv) > 2:
GPIO.output(pin,data)
elif cmd == "in":
#print "Initialised pin "+str(pin)+" to IN"
#print("Initialised pin "+str(pin)+" to IN")
bounce = float(sys.argv[4])
def handle_callback(chan):
sleep(bounce/1000.0)
print GPIO.input(chan)
print(GPIO.input(chan))
if sys.argv[3].lower() == "up":
GPIO.setup(pin,GPIO.IN,GPIO.PUD_UP)
@@ -116,7 +112,7 @@ if len(sys.argv) > 2:
else:
GPIO.setup(pin,GPIO.IN)
print GPIO.input(pin)
print(GPIO.input(pin))
GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=int(bounce))
while True:
@@ -129,7 +125,7 @@ if len(sys.argv) > 2:
sys.exit(0)
elif cmd == "byte":
#print "Initialised BYTE mode - "+str(pin)+
#print("Initialised BYTE mode - "+str(pin)+)
list = [7,11,13,12,15,16,18,22]
GPIO.setup(list,GPIO.OUT)
@@ -152,7 +148,7 @@ if len(sys.argv) > 2:
GPIO.output(list[bit], data & mask)
elif cmd == "borg":
#print "Initialised BORG mode - "+str(pin)+
#print("Initialised BORG mode - "+str(pin)+)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
@@ -190,7 +186,7 @@ if len(sys.argv) > 2:
button = ord( buf[0] ) & pin # mask out just the required button(s)
if button != oldbutt: # only send if changed
oldbutt = button
print button
print(button)
while True:
try:
@@ -215,7 +211,7 @@ if len(sys.argv) > 2:
# type,code,value
print("%u,%u" % (code, value))
event = file.read(EVENT_SIZE)
print "0,0"
print("0,0")
file.close()
sys.exit(0)
except:
@@ -225,14 +221,14 @@ if len(sys.argv) > 2:
elif len(sys.argv) > 1:
cmd = sys.argv[1].lower()
if cmd == "rev":
print GPIO.RPI_REVISION
print(GPIO.RPI_REVISION)
elif cmd == "ver":
print GPIO.VERSION
print(GPIO.VERSION)
elif cmd == "info":
print GPIO.RPI_INFO
print(GPIO.RPI_INFO)
else:
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}"
print " only ver (gpio version) and info (board information) accept no pin parameter."
print("Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}")
print(" only ver (gpio version) and info (board information) accept no pin parameter.")
else:
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}"
print("Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}")

View File

@@ -63,6 +63,11 @@
<input type="checkbox" id="node-config-input-verifyservercert" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-verifyservercert" style="width: calc(100% - 170px);" data-i18n="tls.label.verify-server-cert"></label>
</div>
<div class="form-row">
<label style="width: 120px;" for="node-config-input-servername"><i class="fa fa-server"></i> <span data-i18n="tls.label.servername"></span></label>
<input style="width: calc(100% - 170px);" type="text" id="node-config-input-servername" data-i18n="[placeholder]tls.placeholder.servername">
</div>
<hr>
<div class="form-row">
<label style="width: 120px;" for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
<input style="width: calc(100% - 170px);" type="text" id="node-config-input-name" data-i18n="[placeholder]common.label.name">
@@ -96,6 +101,7 @@
certname: {value:""},
keyname: {value:""},
caname: {value:""},
servername: {value:""},
verifyservercert: {value: true}
},
credentials: {

View File

@@ -25,6 +25,7 @@ module.exports = function(RED) {
var certPath = n.cert.trim();
var keyPath = n.key.trim();
var caPath = n.ca.trim();
this.servername = (n.servername||"").trim();
if ((certPath.length > 0) || (keyPath.length > 0)) {
@@ -102,6 +103,9 @@ module.exports = function(RED) {
if (this.credentials && this.credentials.passphrase) {
opts.passphrase = this.credentials.passphrase;
}
if (this.servername) {
opts.servername = this.servername;
}
opts.rejectUnauthorized = this.verifyservercert;
}
return opts;

View File

@@ -41,7 +41,7 @@
<dt>payload <span class="property-type">string | buffer</span></dt>
<dd>a string unless detected as a binary buffer.</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>the MQTT topic, uses / as a heirarchy separator.</dd>
<dd>the MQTT topic, uses / as a hierarchy separator.</dd>
<dt>qos <span class="property-type">number</span> </dt>
<dd>0, fire and forget - 1, at least once - 2, once and once only.</dd>
<dt>retain <span class="property-type">boolean</span></dt>
@@ -212,48 +212,84 @@
<input type="password" id="node-config-input-password">
</div>
</div>
<div id="mqtt-broker-tab-birth" style="display:none">
<div class="form-row">
<label for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
<input type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic">
<div id="mqtt-broker-tab-messages" style="display:none">
<div id="mqtt-broker-section-birth">
<div class="palette-header">
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.birth-message"></span>
</div>
<div class="section-content" style="padding:10px 0 0 10px">
<div class="form-row">
<label style="width: 100px !important;" for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic">
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-birthRetain"><i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span></label>
<select id="node-config-input-birthRetain" style="width:75px !important">
<option value="false" data-i18n="mqtt.false"></option>
<option value="true" data-i18n="mqtt.true"></option>
</select>
</div>
<div class="form-row">
<label style="width: 100px !important;" for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-birthPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-birthQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
<select id="node-config-input-birthQos" style="width:75px !important">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
</div>
</div>
<div class="form-row">
<label for="node-config-input-birthQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
<select id="node-config-input-birthQos" style="width:125px !important">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
&nbsp;&nbsp;<i class="fa fa-history"></i>&nbsp;<span data-i18n="mqtt.retain"></span> &nbsp;<select id="node-config-input-birthRetain" style="width:125px !important">
<option value="false" data-i18n="mqtt.false"></option>
<option value="true" data-i18n="mqtt.true"></option>
</select>
<div id="mqtt-broker-section-close">
<div class="palette-header">
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.close-message"></span>
</div>
<div class="section-content" style="padding:10px 0 0 10px">
<div class="form-row">
<label style="width: 100px !important;" for="node-config-input-closeTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-closeTopic" style="width:300px" data-i18n="[placeholder]mqtt.placeholder.close-topic">
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-closeRetain"><i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span></label>
<select id="node-config-input-closeRetain" style="width:75px !important">
<option value="false" data-i18n="mqtt.false"></option>
<option value="true" data-i18n="mqtt.true"></option>
</select>
</div>
<div class="form-row">
<label style="width: 100px !important;" for="node-config-input-closePayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-closePayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-closeQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
<select id="node-config-input-closeQos" style="width:75px !important">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
</div>
</div>
<div class="form-row">
<label for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
<input type="text" id="node-config-input-birthPayload" data-i18n="[placeholder]common.label.payload">
</div>
</div>
<div id="mqtt-broker-tab-will" style="display:none">
<div class="form-row">
<label for="node-config-input-willTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
<input type="text" id="node-config-input-willTopic" data-i18n="[placeholder]mqtt.placeholder.will-topic">
</div>
<div class="form-row">
<label for="node-config-input-willQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
<select id="node-config-input-willQos" style="width:125px !important">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
&nbsp;&nbsp;<i class="fa fa-history"></i>&nbsp;<span data-i18n="mqtt.retain"></span> &nbsp;<select id="node-config-input-willRetain" style="width:125px !important">
<option value="false" data-i18n="mqtt.false"></option>
<option value="true" data-i18n="mqtt.true"></option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
<input type="text" id="node-config-input-willPayload" data-i18n="[placeholder]common.label.payload">
<div id="mqtt-broker-section-will">
<div class="palette-header">
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.will-message"></span>
</div>
<div class="section-content" style="padding:10px 0 0 10px">
<div class="form-row">
<label style="width: 100px !important;" for="node-config-input-willTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-willTopic" style="width:300px" data-i18n="[placeholder]mqtt.placeholder.will-topic">
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-willRetain"><i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span></label>
<select id="node-config-input-willRetain" style="width:75px !important">
<option value="false" data-i18n="mqtt.false"></option>
<option value="true" data-i18n="mqtt.true"></option>
</select>
</div>
<div class="form-row">
<label style="width: 100px !important;" for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-willPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-willQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
<select id="node-config-input-willQos" style="width:75px !important">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
</div>
</div>
</div>
</div>
@@ -269,6 +305,9 @@
<h4>Birth Message</h4>
<p>This is a message that will be published on the configured topic whenever the
connection is established.</p>
<h4>Close Message</h4>
<p>This is a message that will be published on the configured topic before the
connection is closed normally, either by re-deploying the node, or by shutting down.</p>
<h4>Will Message</h4>
<p>This is a message that will be published by the broker in the event the node
unexpectedly loses its connection.</p>
@@ -300,14 +339,18 @@
compatmode: { value: true},
keepalive: {value:60,validate:RED.validators.number()},
cleansession: {value: true},
willTopic: {value:""},
willQos: {value:"0"},
willRetain: {value:false},
willPayload: {value:""},
birthTopic: {value:""},
birthQos: {value:"0"},
birthRetain: {value:false},
birthPayload: {value:""}
birthPayload: {value:""},
closeTopic: {value:""},
closeQos: {value:"0"},
closeRetain: {value:false},
closePayload: {value:""},
willTopic: {value:""},
willQos: {value:"0"},
willRetain: {value:false},
willPayload: {value:""}
},
credentials: {
user: {type:"text"},
@@ -343,14 +386,39 @@
id: "mqtt-broker-tab-security",
label: this._("mqtt.tabs-label.security")
});
tabs.addTab({
id: "mqtt-broker-tab-birth",
label: this._("mqtt.tabs-label.birth")
});
tabs.addTab({
id: "mqtt-broker-tab-will",
label: this._("mqtt.tabs-label.will")
id: "mqtt-broker-tab-messages",
label: this._("mqtt.tabs-label.messages")
});
function setUpSection(sectionId, isExpanded) {
var birthMessageSection = $(sectionId);
var paletteHeader = birthMessageSection.find('.palette-header');
var twistie = paletteHeader.find('i');
var sectionContent = birthMessageSection.find('.section-content');
function toggleSection(expanded) {
twistie.toggleClass('expanded', expanded);
sectionContent.toggle(expanded);
}
paletteHeader.click(function(e) {
e.preventDefault();
var isExpanded = twistie.hasClass('expanded');
toggleSection(!isExpanded);
});
toggleSection(isExpanded);
}
// show first section if none are set so the user gets the idea
var showBirthSection = this.birthTopic !== ""
|| this.willTopic === ""
&& this.birthTopic === ""
&& this.closeTopic == "";
setUpSection('#mqtt-broker-section-birth', showBirthSection);
setUpSection('#mqtt-broker-section-close', this.closeTopic !== "");
setUpSection('#mqtt-broker-section-will', this.willTopic !== "");
setTimeout(function() { tabs.resize(); },0);
if (typeof this.cleansession === 'undefined') {
this.cleansession = true;
@@ -368,14 +436,18 @@
this.keepalive = 15;
$("#node-config-input-keepalive").val(this.keepalive);
}
if (typeof this.willQos === 'undefined') {
this.willQos = "0";
$("#node-config-input-willQos").val("0");
}
if (typeof this.birthQos === 'undefined') {
this.birthQos = "0";
$("#node-config-input-birthQos").val("0");
}
if (typeof this.closeQos === 'undefined') {
this.willQos = "0";
$("#node-config-input-willQos").val("0");
}
if (typeof this.willQos === 'undefined') {
this.willQos = "0";
$("#node-config-input-willQos").val("0");
}
function updateTLSOptions() {
if ($("#node-config-input-usetls").is(':checked')) {

View File

@@ -60,6 +60,15 @@ module.exports = function(RED) {
};
}
if (n.closeTopic) {
this.closeMessage = {
topic: n.closeTopic,
payload: n.closePayload || "",
qos: Number(n.closeQos||0),
retain: n.closeRetain=="true"|| n.closeRetain===true
};
}
if (this.credentials) {
this.username = this.credentials.user;
this.password = this.credentials.password;
@@ -314,6 +323,10 @@ module.exports = function(RED) {
this.on('close', function(done) {
this.closing = true;
if (this.connected) {
// Send close message
if (node.closeMessage) {
node.publish(node.closeMessage);
}
this.client.once('close', function() {
done();
});

View File

@@ -75,7 +75,7 @@
<p>The node will listen on the configured path for requests of a particular type.
The path can be fully specified, such as <code>/user</code>, or include
named parameters that accept any value, such as <code>/user/:name</code>.
When named parameters are used, their actual value in a request can be accessed under `msg.req.params`.</p>
When named parameters are used, their actual value in a request can be accessed under <code>msg.req.params</code>.</p>
<p>For requests that include a body, such as a POST or PUT, the contents of
the request is made available as <code>msg.payload</code>.</p>
<p>If the content type of the request can be determined, the body will be parsed to

View File

@@ -21,8 +21,6 @@ module.exports = function(RED) {
var cookieParser = require("cookie-parser");
var getBody = require('raw-body');
var cors = require('cors');
var jsonParser = bodyParser.json();
var urlencParser = bodyParser.urlencoded({extended:true});
var onHeaders = require('on-headers');
var typer = require('media-typer');
var isUtf8 = require('is-utf8');
@@ -212,6 +210,10 @@ module.exports = function(RED) {
}
}
var maxApiRequestSize = RED.settings.apiMaxLength || '5mb';
var jsonParser = bodyParser.json({limit:maxApiRequestSize});
var urlencParser = bodyParser.urlencoded({limit:maxApiRequestSize,extended:true});
var metricsHandler = function(req,res,next) { next(); }
if (this.metric()) {
metricsHandler = function(req, res, next) {

View File

@@ -86,8 +86,10 @@
<dt class="optional">payload</dt>
<dd>Sent as the body of the request.</dd>
<dt class="optional">rejectUnauthorized</dt>
<dd>If set to <code>true</code>, allows requests to be made to https sites that use
<dd>If set to <code>false</code>, allows requests to be made to https sites that use
self signed certificates.</dd>
<dt class="optional">followRedirects</dt>
<dd>If set to <code>false</code> prevent following Redirect (HTTP 301).<code>true</code> by default</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
@@ -117,7 +119,7 @@
the response headers. The next node will then use those headers for its request - this
is not usually the right thing to do. If <code>msg.headers</code> property is left unchanged
between nodes, it will be ignored by the second node. To set custom headers, <code>msg.headers</code>
should first be deleted or reset to an empty object: `{}`.
should first be deleted or reset to an empty object: <code>{}</code>.
<h4>Cookie handling</h4>
<p>The <code>cookies</code> property passed to the node must be an object of name/value pairs.
The value can be either a string to set the value of the cookie or it can be an

View File

@@ -16,9 +16,7 @@
module.exports = function(RED) {
"use strict";
var http = require("follow-redirects").http;
var https = require("follow-redirects").https;
var urllib = require("url");
var request = require("request");
var mustache = require("mustache");
var querystring = require("querystring");
var cookie = require("cookie");
@@ -78,9 +76,13 @@ module.exports = function(RED) {
if (msg.method && n.method && (n.method === "use")) {
method = msg.method.toUpperCase(); // use the msg parameter
}
var opts = urllib.parse(url);
var opts = {};
opts.url = url;
opts.timeout = node.reqTimeout;
opts.method = method;
opts.headers = {};
opts.encoding = null; // Force NodeJs to return a Buffer (instead of a string)
opts.maxRedirects = 21;
var ctSet = "Content-Type"; // set default camel case
var clSet = "Content-Length";
if (msg.headers) {
@@ -108,6 +110,9 @@ module.exports = function(RED) {
}
}
}
if (msg.hasOwnProperty('followRedirects')) {
opts.followRedirect = msg.followRedirects;
}
if (msg.cookies) {
var cookies = [];
if (opts.headers.hasOwnProperty('cookie')) {
@@ -131,7 +136,10 @@ module.exports = function(RED) {
}
}
if (this.credentials && this.credentials.user) {
opts.auth = this.credentials.user+":"+(this.credentials.password||"");
opts.auth = {
user: this.credentials.user,
pass: this.credentials.password||""
};
}
var payload = null;
@@ -157,6 +165,7 @@ module.exports = function(RED) {
opts.headers[clSet] = Buffer.byteLength(payload);
}
}
opts.body = payload;
}
// revert to user supplied Capitalisation if needed.
if (opts.headers.hasOwnProperty('content-type') && (ctSet !== 'content-type')) {
@@ -167,7 +176,6 @@ module.exports = function(RED) {
opts.headers[clSet] = opts.headers['content-length'];
delete opts.headers['content-length'];
}
var urltotest = url;
var noproxy;
if (noprox) {
for (var i in noprox) {
@@ -177,22 +185,11 @@ module.exports = function(RED) {
if (prox && !noproxy) {
var match = prox.match(/^(http:\/\/)?(.+)?:([0-9]+)?/i);
if (match) {
//opts.protocol = "http:";
//opts.host = opts.hostname = match[2];
//opts.port = (match[3] != null ? match[3] : 80);
opts.headers['Host'] = opts.host;
var heads = opts.headers;
var path = opts.pathname = opts.href;
opts = urllib.parse(prox);
opts.path = opts.pathname = path;
opts.headers = heads;
opts.method = method;
urltotest = match[0];
if (opts.auth) {
opts.headers['Proxy-Authorization'] = "Basic "+new Buffer(opts.auth).toString('Base64')
}
opts.proxy = prox;
} else {
node.warn("Bad proxy url: "+ prox);
opts.proxy = null;
}
else { node.warn("Bad proxy url: "+process.env.http_proxy); }
}
if (tlsNode) {
tlsNode.addTLSOptions(opts);
@@ -201,42 +198,37 @@ module.exports = function(RED) {
opts.rejectUnauthorized = msg.rejectUnauthorized;
}
}
var req = ((/^https/.test(urltotest))?https:http).request(opts,function(res) {
// Force NodeJs to return a Buffer (instead of a string)
// See https://github.com/nodejs/node/issues/6038
res.setEncoding(null);
delete res._readableState.decoder;
msg.statusCode = res.statusCode;
msg.headers = res.headers;
msg.responseUrl = res.responseUrl;
msg.payload = [];
if (msg.headers.hasOwnProperty('set-cookie')) {
msg.responseCookies = {};
msg.headers['set-cookie'].forEach(function(c) {
var parsedCookie = cookie.parse(c);
var eq_idx = c.indexOf('=');
var key = c.substr(0, eq_idx).trim()
parsedCookie.value = parsedCookie[key];
delete parsedCookie[key];
msg.responseCookies[key] = parsedCookie;
})
}
msg.headers['x-node-red-request-node'] = hashSum(msg.headers);
// msg.url = url; // revert when warning above finally removed
res.on('data',function(chunk) {
if (!Buffer.isBuffer(chunk)) {
// if the 'setEncoding(null)' fix above stops working in
// a new Node.js release, throw a noisy error so we know
// about it.
throw new Error("HTTP Request data chunk not a Buffer");
request(opts, function(err, res, body) {
if(err){
if(err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
node.error(RED._("common.notification.errors.no-response"), msg);
node.status({fill:"red", shape:"ring", text:"common.notification.errors.no-response"});
}else{
node.error(err,msg);
node.status({fill:"red", shape:"ring", text:err.code});
}
msg.payload.push(chunk);
});
res.on('end',function() {
msg.payload = err.toString() + " : " + url;
msg.statusCode = err.code;
node.send(msg);
}else{
msg.statusCode = res.statusCode;
msg.headers = res.headers;
msg.responseUrl = res.request.uri.href;
msg.payload = body;
if (msg.headers.hasOwnProperty('set-cookie')) {
msg.responseCookies = {};
msg.headers['set-cookie'].forEach(function(c) {
var parsedCookie = cookie.parse(c);
var eq_idx = c.indexOf('=');
var key = c.substr(0, eq_idx).trim()
parsedCookie.value = parsedCookie[key];
delete parsedCookie[key];
msg.responseCookies[key] = parsedCookie;
});
}
msg.headers['x-node-red-request-node'] = hashSum(msg.headers);
// msg.url = url; // revert when warning above finally removed
if (node.metric()) {
// Calculate request time
var diff = process.hrtime(preRequestTimestamp);
@@ -248,45 +240,19 @@ module.exports = function(RED) {
}
}
// Check that msg.payload is an array - if the req error
// handler has been called, it will have been set to a string
// and the error already handled - so no further action should
// be taken. #1344
if (Array.isArray(msg.payload)) {
// Convert the payload to the required return type
msg.payload = Buffer.concat(msg.payload); // bin
if (node.ret !== "bin") {
msg.payload = msg.payload.toString('utf8'); // txt
// Convert the payload to the required return type
if (node.ret !== "bin") {
msg.payload = msg.payload.toString('utf8'); // txt
if (node.ret === "obj") {
try { msg.payload = JSON.parse(msg.payload); } // obj
catch(e) { node.warn(RED._("httpin.errors.json-error")); }
}
if (node.ret === "obj") {
try { msg.payload = JSON.parse(msg.payload); } // obj
catch(e) { node.warn(RED._("httpin.errors.json-error")); }
}
node.send(msg);
node.status({});
}
});
node.status({});
node.send(msg);
}
});
req.setTimeout(node.reqTimeout, function() {
node.error(RED._("common.notification.errors.no-response"),msg);
setTimeout(function() {
node.status({fill:"red",shape:"ring",text:"common.notification.errors.no-response"});
},10);
req.abort();
});
req.on('error',function(err) {
node.error(err,msg);
msg.payload = err.toString() + " : " + url;
msg.statusCode = err.code;
node.send(msg);
node.status({fill:"red",shape:"ring",text:err.code});
});
if (payload) {
req.write(payload);
}
req.end();
});
this.on("close",function() {

View File

@@ -212,11 +212,11 @@ module.exports = function(RED) {
if (this.serverConfig) {
this.serverConfig.registerInputNode(this);
// TODO: nls
this.serverConfig.on('opened', function(n) { node.status({fill:"green",shape:"dot",text:"connected "+n}); });
this.serverConfig.on('erro', function() { node.status({fill:"red",shape:"ring",text:"error"}); });
this.serverConfig.on('opened', function(n) { node.status({fill:"green",shape:"dot",text:RED._("websocket.status.connected",{count:n})}); });
this.serverConfig.on('erro', function() { node.status({fill:"red",shape:"ring",text:"common.status.error"}); });
this.serverConfig.on('closed', function(n) {
if (n > 0) { node.status({fill:"green",shape:"dot",text:"connected "+n}); }
else { node.status({fill:"red",shape:"ring",text:"disconnected"}); }
if (n > 0) { node.status({fill:"green",shape:"dot",text:RED._("websocket.status.connected",{count:n})}); }
else { node.status({fill:"red",shape:"ring",text:"common.status.disconnected"}); }
});
} else {
this.error(RED._("websocket.errors.missing-conf"));
@@ -240,11 +240,11 @@ module.exports = function(RED) {
}
else {
// TODO: nls
this.serverConfig.on('opened', function(n) { node.status({fill:"green",shape:"dot",text:"connected "+n}); });
this.serverConfig.on('erro', function() { node.status({fill:"red",shape:"ring",text:"error"}); });
this.serverConfig.on('opened', function(n) { node.status({fill:"green",shape:"dot",text:RED._("websocket.status.connected",{count:n})}); });
this.serverConfig.on('erro', function() { node.status({fill:"red",shape:"ring",text:"common.status.error"}); });
this.serverConfig.on('closed', function(n) {
if (n > 0) { node.status({fill:"green",shape:"dot",text:"connected "+n}); }
else { node.status({fill:"red",shape:"ring",text:"disconnected"}); }
if (n > 0) { node.status({fill:"green",shape:"dot",text:RED._("websocket.status.connected",{count:n})}); }
else { node.status({fill:"red",shape:"ring",text:"common.status.disconnected"}); }
});
}
this.on("input", function(msg) {

View File

@@ -59,7 +59,7 @@
outputs:1,
icon: "watch.png",
label: function() {
return this.name||this.files;
return this.name||this.files||this._("watch.watch");
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@@ -18,10 +18,36 @@ module.exports = function(RED) {
"use strict";
var reconnectTime = RED.settings.socketReconnectTime||10000;
var socketTimeout = RED.settings.socketTimeout||null;
const msgQueueSize = RED.settings.tcpMsgQueueSize || 1000;
const Denque = require('denque');
var net = require('net');
var connectionPool = {};
/**
* Enqueue `item` in `queue`
* @param {Denque} queue - Queue
* @param {*} item - Item to enqueue
* @private
* @returns {Denque} `queue`
*/
const enqueue = (queue, item) => {
// drop msgs from front of queue if size is going to be exceeded
if (queue.size() === msgQueueSize) {
queue.shift();
}
queue.push(item);
return queue;
};
/**
* Shifts item off front of queue
* @param {Deque} queue - Queue
* @private
* @returns {*} Item previously at front of queue
*/
const dequeue = queue => queue.shift();
function TcpIn(n) {
RED.nodes.createNode(this,n);
this.host = n.host;
@@ -52,6 +78,7 @@ module.exports = function(RED) {
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
client.setKeepAlive(true,120000);
connectionPool[id] = client;
client.on('data', function (data) {
@@ -123,11 +150,14 @@ module.exports = function(RED) {
clearTimeout(reconnectTimeout);
if (!node.connected) { done(); }
});
} else {
}
else {
var server = net.createServer(function (socket) {
socket.setKeepAlive(true,120000);
if (socketTimeout !== null) { socket.setTimeout(socketTimeout); }
var id = (1+Math.random()*4294967295).toString(16);
var fromi;
var fromp;
connectionPool[id] = socket;
count++;
node.status({text:RED._("tcpin.status.connections",{count:count})});
@@ -153,18 +183,21 @@ module.exports = function(RED) {
msg._session = {type:"tcp",id:id};
node.send(msg);
}
} else {
}
else {
if ((typeof data) === "string") {
buffer = buffer+data;
} else {
buffer = Buffer.concat([buffer,data],buffer.length+data.length);
}
fromi = socket.remoteAddress;
fromp = socket.remotePort;
}
});
socket.on('end', function() {
if (!node.stream || (node.datatype === "utf8" && node.newline !== "")) {
if (buffer.length > 0) {
var msg = {topic:node.topic, payload:buffer, ip:socket.remoteAddress, port:socket.remotePort};
var msg = {topic:node.topic, payload:buffer, ip:fromi, port:fromp};
msg._session = {type:"tcp",id:id};
node.send(msg);
}
@@ -184,6 +217,7 @@ module.exports = function(RED) {
node.log(err);
});
});
server.on('error', function(err) {
if (err) {
node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err.toString()}));
@@ -237,6 +271,7 @@ module.exports = function(RED) {
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
client.setKeepAlive(true,120000);
client.on('error', function (err) {
node.log(RED._("tcpin.errors.error",{error:err.toString()}));
});
@@ -288,7 +323,8 @@ module.exports = function(RED) {
if (!node.connected) { done(); }
});
} else if (node.beserver == "reply") {
}
else if (node.beserver == "reply") {
node.on("input",function(msg) {
if (msg._session && msg._session.type == "tcp") {
var client = connectionPool[msg._session.id];
@@ -314,7 +350,8 @@ module.exports = function(RED) {
}
}
});
} else {
}
else {
var connectedSockets = [];
node.status({text:RED._("tcpin.status.connections",{count:0})});
var server = net.createServer(function (socket) {
@@ -424,11 +461,15 @@ module.exports = function(RED) {
// the clients object will have:
// clients[id].client, clients[id].msg, clients[id].timeout
var connection_id = host + ":" + port;
clients[connection_id] = clients[connection_id] || {};
clients[connection_id].msg = msg;
clients[connection_id].connected = clients[connection_id].connected || false;
clients[connection_id] = clients[connection_id] || {
msgQueue: new Denque(),
connected: false,
connecting: false
};
enqueue(clients[connection_id].msgQueue, msg);
clients[connection_id].lastMsg = msg;
if (!clients[connection_id].connected) {
if (!clients[connection_id].connecting && !clients[connection_id].connected) {
var buf;
if (this.out == "count") {
if (this.splitc === 0) { buf = Buffer.alloc(1); }
@@ -440,14 +481,19 @@ module.exports = function(RED) {
if (socketTimeout !== null) { clients[connection_id].client.setTimeout(socketTimeout);}
if (host && port) {
clients[connection_id].connecting = true;
clients[connection_id].client.connect(port, host, function() {
//node.log(RED._("tcpin.errors.client-connected"));
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
if (clients[connection_id] && clients[connection_id].client) {
clients[connection_id].connected = true;
clients[connection_id].client.write(clients[connection_id].msg.payload);
clients[connection_id].connecting = false;
let msg;
while (msg = dequeue(clients[connection_id].msgQueue)) {
clients[connection_id].client.write(msg.payload);
}
if (node.out === "time" && node.splitc < 0) {
clients[connection_id].connected = false;
clients[connection_id].connected = clients[connection_id].connecting = false;
clients[connection_id].client.end();
delete clients[connection_id];
node.status({});
@@ -462,9 +508,9 @@ module.exports = function(RED) {
clients[connection_id].client.on('data', function(data) {
if (node.out === "sit") { // if we are staying connected just send the buffer
if (clients[connection_id]) {
if (!clients[connection_id].hasOwnProperty("msg")) { clients[connection_id].msg = {}; }
clients[connection_id].msg.payload = data;
node.send(RED.util.cloneMessage(clients[connection_id].msg));
const msg = clients[connection_id].lastMsg || {};
msg.payload = data;
node.send(RED.util.cloneMessage(msg));
}
}
// else if (node.splitc === 0) {
@@ -484,9 +530,10 @@ module.exports = function(RED) {
clients[connection_id].timeout = setTimeout(function () {
if (clients[connection_id]) {
clients[connection_id].timeout = null;
clients[connection_id].msg.payload = Buffer.alloc(i+1);
buf.copy(clients[connection_id].msg.payload,0,0,i+1);
node.send(clients[connection_id].msg);
const msg = clients[connection_id].lastMsg || {};
msg.payload = Buffer.alloc(i+1);
buf.copy(msg.payload,0,0,i+1);
node.send(msg);
if (clients[connection_id].client) {
node.status({});
clients[connection_id].client.destroy();
@@ -505,9 +552,10 @@ module.exports = function(RED) {
i += 1;
if ( i >= node.splitc) {
if (clients[connection_id]) {
clients[connection_id].msg.payload = Buffer.alloc(i);
buf.copy(clients[connection_id].msg.payload,0,0,i);
node.send(clients[connection_id].msg);
const msg = clients[connection_id].lastMsg || {};
msg.payload = Buffer.alloc(i);
buf.copy(msg.payload,0,0,i);
node.send(msg);
if (clients[connection_id].client) {
node.status({});
clients[connection_id].client.destroy();
@@ -523,9 +571,10 @@ module.exports = function(RED) {
i += 1;
if (data[j] == node.splitc) {
if (clients[connection_id]) {
clients[connection_id].msg.payload = Buffer.alloc(i);
buf.copy(clients[connection_id].msg.payload,0,0,i);
node.send(clients[connection_id].msg);
const msg = clients[connection_id].lastMsg || {};
msg.payload = Buffer.alloc(i);
buf.copy(msg.payload,0,0,i);
node.send(msg);
if (clients[connection_id].client) {
node.status({});
clients[connection_id].client.destroy();
@@ -543,7 +592,7 @@ module.exports = function(RED) {
//console.log("END");
node.status({fill:"grey",shape:"ring",text:"common.status.disconnected"});
if (clients[connection_id] && clients[connection_id].client) {
clients[connection_id].connected = false;
clients[connection_id].connected = clients[connection_id].connecting = false;
clients[connection_id].client = null;
}
});
@@ -551,7 +600,7 @@ module.exports = function(RED) {
clients[connection_id].client.on('close', function() {
//console.log("CLOSE");
if (clients[connection_id]) {
clients[connection_id].connected = false;
clients[connection_id].connected = clients[connection_id].connecting = false;
}
var anyConnected = false;
@@ -581,21 +630,23 @@ module.exports = function(RED) {
clients[connection_id].client.on('timeout',function() {
//console.log("TIMEOUT");
if (clients[connection_id]) {
clients[connection_id].connected = false;
clients[connection_id].connected = clients[connection_id].connecting = false;
node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"});
//node.warn(RED._("tcpin.errors.connect-timeout"));
if (clients[connection_id].client) {
clients[connection_id].connecting = true;
clients[connection_id].client.connect(port, host, function() {
clients[connection_id].connected = true;
clients[connection_id].connecting = false;
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
}
}
});
}
else {
else if (!clients[connection_id].connecting && clients[connection_id].connected) {
if (clients[connection_id] && clients[connection_id].client) {
clients[connection_id].client.write(clients[connection_id].msg.payload);
clients[connection_id].client.write(dequeue(clients[connection_id].msgQueue));
}
}
});

View File

@@ -29,7 +29,7 @@
</div>
<div class="form-row node-input-iface">
<label for="node-input-iface"><i class="fa fa-random"></i> <span data-i18n="udp.label.interface"></span></label>
<input type="text" id="node-input-iface" data-i18n="[placeholder]udp.label.interfaceprompt">
<input type="text" id="node-input-iface" data-i18n="[placeholder]udp.placeholder.interfaceprompt">
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-sign-in"></i> <span data-i18n="udp.label.onport"></span></label>

View File

@@ -16,6 +16,7 @@
module.exports = function(RED) {
"use strict";
var os = require('os');
var dgram = require('dgram');
var udpInputPortsInUse = {};
@@ -30,6 +31,29 @@ module.exports = function(RED) {
this.ipv = n.ipv || "udp4";
var node = this;
if (node.iface && node.iface.indexOf(".") === -1) {
try {
if ((os.networkInterfaces())[node.iface][0].hasOwnProperty("scopeid")) {
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][1].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][0].address;
}
}
else {
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][0].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][1].address;
}
}
}
catch(e) {
node.warn(RED._("udp.errors.ifnotfound",{iface:node.iface}));
node.iface = null;
}
}
var opts = {type:node.ipv, reuseAddr:true};
if (process.version.indexOf("v0.10") === 0) { opts = node.ipv; }
var server;
@@ -39,7 +63,7 @@ module.exports = function(RED) {
udpInputPortsInUse[this.port] = server;
}
else {
node.warn(RED._("udp.errors.alreadyused",node.port));
node.log(RED._("udp.errors.alreadyused",{port:node.port}));
server = udpInputPortsInUse[this.port]; // re-use existing
}
@@ -121,12 +145,37 @@ module.exports = function(RED) {
this.ipv = n.ipv || "udp4";
var node = this;
if (node.iface && node.iface.indexOf(".") === -1) {
try {
if ((os.networkInterfaces())[node.iface][0].hasOwnProperty("scopeid")) {
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][1].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][0].address;
}
}
else {
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][0].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][1].address;
}
}
}
catch(e) {
node.warn(RED._("udp.errors.ifnotfound",{iface:node.iface}));
node.iface = null;
}
}
var opts = {type:node.ipv, reuseAddr:true};
if (process.version.indexOf("v0.10") === 0) { opts = node.ipv; }
var sock;
if (udpInputPortsInUse[this.outport || this.port]) {
sock = udpInputPortsInUse[this.outport || this.port];
var p = this.outport || this.port || "0";
if (udpInputPortsInUse[p]) {
sock = udpInputPortsInUse[p];
node.log(RED._("udp.status.re-use",{outport:node.outport,host:node.addr,port:node.port}));
}
else {
sock = dgram.createSocket(opts); // default to udp4
@@ -136,36 +185,35 @@ module.exports = function(RED) {
// prevent it going to the global error handler and shutting node-red
// down.
});
udpInputPortsInUse[this.outport || this.port] = sock;
}
udpInputPortsInUse[p] = sock;
if (node.multicast != "false") {
if (node.outport === "") { node.outport = node.port; }
sock.bind(node.outport, function() { // have to bind before you can enable broadcast...
sock.setBroadcast(true); // turn on broadcast
if (node.multicast == "multi") {
try {
sock.setMulticastTTL(128);
sock.addMembership(node.addr,node.iface); // Add to the multicast group
node.log(RED._("udp.status.mc-ready",{outport:node.outport,host:node.addr,port:node.port}));
} catch (e) {
if (e.errno == "EINVAL") {
node.error(RED._("udp.errors.bad-mcaddress"));
} else if (e.errno == "ENODEV") {
node.error(RED._("udp.errors.interface"));
} else {
node.error(RED._("udp.errors.error",{error:e.errno}));
if (node.multicast != "false") {
sock.bind(node.outport, function() { // have to bind before you can enable broadcast...
sock.setBroadcast(true); // turn on broadcast
if (node.multicast == "multi") {
try {
sock.setMulticastTTL(128);
sock.addMembership(node.addr,node.iface); // Add to the multicast group
node.log(RED._("udp.status.mc-ready",{iface:node.iface,outport:node.outport,host:node.addr,port:node.port}));
} catch (e) {
if (e.errno == "EINVAL") {
node.error(RED._("udp.errors.bad-mcaddress"));
} else if (e.errno == "ENODEV") {
node.error(RED._("udp.errors.interface"));
} else {
node.error(RED._("udp.errors.error",{error:e.errno}));
}
}
} else {
node.log(RED._("udp.status.bc-ready",{outport:node.outport,host:node.addr,port:node.port}));
}
} else {
node.log(RED._("udp.status.bc-ready",{outport:node.outport,host:node.addr,port:node.port}));
}
});
} else if ((node.outport !== "") && (!udpInputPortsInUse[node.outport])) {
sock.bind(node.outport);
node.log(RED._("udp.status.ready",{outport:node.outport,host:node.addr,port:node.port}));
} else {
node.log(RED._("udp.status.ready-nolocal",{host:node.addr,port:node.port}));
});
} else if ((node.outport !== "") && (!udpInputPortsInUse[node.outport])) {
sock.bind(node.outport);
node.log(RED._("udp.status.ready",{outport:node.outport,host:node.addr,port:node.port}));
} else {
node.log(RED._("udp.status.ready-nolocal",{host:node.addr,port:node.port}));
}
}
node.on("input", function(msg) {
@@ -198,8 +246,8 @@ module.exports = function(RED) {
});
node.on("close", function() {
if (udpInputPortsInUse.hasOwnProperty(node.outport || node.port)) {
delete udpInputPortsInUse[node.outport || node.port];
if (udpInputPortsInUse.hasOwnProperty(p)) {
delete udpInputPortsInUse[p];
}
try {
sock.close();

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