Compare commits
182 Commits
1.0.0-beta
...
auto-layou
Author | SHA1 | Date | |
---|---|---|---|
|
0281a9c3d0 | ||
|
17d3a5840d | ||
|
be49e1d383 | ||
|
58784b7568 | ||
|
ee6ee99577 | ||
|
607bc42f59 | ||
|
880757fb5d | ||
|
c8acc6a12e | ||
|
7d4c2442da | ||
|
e5255b0c7c | ||
|
ac3ef9b6fc | ||
|
7b5a41c3ff | ||
|
e2db958510 | ||
|
16440072fb | ||
|
be2dd6dc32 | ||
|
6032d096ec | ||
|
defa9a2270 | ||
|
77a913f858 | ||
|
6e3fa974ba | ||
|
7926055b97 | ||
|
ffd10e656e | ||
|
59c1828078 | ||
|
6164271fe8 | ||
|
26ba35933d | ||
|
87359937c9 | ||
|
9b938f6515 | ||
|
6c3913785d | ||
|
542cf3147d | ||
|
2505ac3f98 | ||
|
fde8548166 | ||
|
fe91295704 | ||
|
15b99c5749 | ||
|
9d66ca4a49 | ||
|
b749a27f86 | ||
|
083212cffe | ||
|
c4e8756210 | ||
|
3a6448f727 | ||
|
fe18df25ba | ||
|
db65460ec0 | ||
|
0ad3eceb82 | ||
|
a376d6e361 | ||
|
45c7f3f3ca | ||
|
238de59a2a | ||
|
96255e51d2 | ||
|
18c3223105 | ||
|
b9e97792f3 | ||
|
cbce9b8637 | ||
|
5ab90b85da | ||
|
f3e1e8a2c7 | ||
|
e41b292e54 | ||
|
86928bbb2d | ||
|
2f5ec8b5bf | ||
|
14ac6446de | ||
|
260a9723a4 | ||
|
4e7b000dcd | ||
|
2254e4c57e | ||
|
25a27733b9 | ||
|
6ab520984c | ||
|
04d7106956 | ||
|
db5589f2aa | ||
|
d06dbbb4bd | ||
|
b7a62bd9e7 | ||
|
93ad9a3aa6 | ||
|
f1855174f0 | ||
|
a2dedba0ef | ||
|
5a65f445f0 | ||
|
238bcb8698 | ||
|
3ee8bcad8c | ||
|
f0a51bafbe | ||
|
944f3bd329 | ||
|
8bb7b2e88b | ||
|
aab0b0b4bf | ||
|
083d6c5125 | ||
|
c2167a2c5f | ||
|
1a695e0451 | ||
|
8847f325ed | ||
|
94c9da468e | ||
|
24b38407e4 | ||
|
f49d1ae860 | ||
|
8b3b541a56 | ||
|
a974e84ad1 | ||
|
c4f4115bcb | ||
|
3c5adbee31 | ||
|
55645e3730 | ||
|
d918bb568c | ||
|
b1bff62bf7 | ||
|
d11d389ae4 | ||
|
a73c159160 | ||
|
7adf102d8d | ||
|
e4d3ff623a | ||
|
2433d59f00 | ||
|
8c68e76c3e | ||
|
0b204de5a9 | ||
|
93c811ab70 | ||
|
3ff861099a | ||
|
f22762539f | ||
|
677442a3c0 | ||
|
b73f12cdba | ||
|
28fbb61e81 | ||
|
c1104d1cd6 | ||
|
e346702292 | ||
|
90887779ea | ||
|
a941b1437c | ||
|
04bdcbd490 | ||
|
87a815fd6f | ||
|
d623848c87 | ||
|
46abd0cc42 | ||
|
e315325d91 | ||
|
f3fc083330 | ||
|
92cb57eb7b | ||
|
d645fbff2f | ||
|
8486f4d43a | ||
|
60b1a05894 | ||
|
f955d63707 | ||
|
f106019938 | ||
|
2473249c8b | ||
|
d13dc4fba3 | ||
|
41a0af032c | ||
|
70cf7b0c5a | ||
|
14f6788ab9 | ||
|
bb67049d90 | ||
|
ae2162beaf | ||
|
19f2c5e07f | ||
|
8abc5b3889 | ||
|
4d37c28bc7 | ||
|
cc0933eee4 | ||
|
2de9a804a0 | ||
|
ffeb2e91f4 | ||
|
8cf5ec9e5a | ||
|
ea0526f29a | ||
|
cfcb3a69e5 | ||
|
e3e0378857 | ||
|
ccc3809daa | ||
|
c97786e12c | ||
|
400071879f | ||
|
4cd6e20c91 | ||
|
460e3ad395 | ||
|
6f08bd6fc5 | ||
|
eed3a749db | ||
|
6587d12fbd | ||
|
f8dd68ecc4 | ||
|
f0aef2b853 | ||
|
7d27df1b97 | ||
|
457ec86c25 | ||
|
a24c66958f | ||
|
617628b886 | ||
|
6b7e623d33 | ||
|
5ca85b7e83 | ||
|
5965bf3332 | ||
|
baf2dd293b | ||
|
2cc19e7e32 | ||
|
53ab6f8569 | ||
|
cf8faac7ef | ||
|
86947a384d | ||
|
22855279bd | ||
|
e56fdecdc6 | ||
|
dc75a5812f | ||
|
33e20c9969 | ||
|
109204897f | ||
|
3b3a2d62f8 | ||
|
b1b4b3fb63 | ||
|
d583c68de5 | ||
|
d360f30af6 | ||
|
ed033565a4 | ||
|
2d6acfae1b | ||
|
10da894124 | ||
|
6dda8f21e4 | ||
|
1a9d759002 | ||
|
df24e13eb5 | ||
|
2ab19937af | ||
|
390b86cd8e | ||
|
423aba5bab | ||
|
dc0b9231cd | ||
|
3b177bedf8 | ||
|
12ce719213 | ||
|
320433b1bf | ||
|
7f35e2280e | ||
|
c514d988df | ||
|
749a080397 | ||
|
b105a12505 | ||
|
85a438a40f | ||
|
877260a243 |
2
.github/ISSUE_TEMPLATE.md
vendored
@@ -28,7 +28,7 @@ To help us understand the issue, please fill-in as much of the following informa
|
||||
### Please tell us about your environment:
|
||||
|
||||
- [ ] Node-RED version:
|
||||
- [ ] node.js version:
|
||||
- [ ] Node.js version:
|
||||
- [ ] npm version:
|
||||
- [ ] Platform/OS:
|
||||
- [ ] Browser:
|
||||
|
2
.github/ISSUE_TEMPLATE/--bug_report.md
vendored
@@ -33,7 +33,7 @@ To help us understand the issue, please fill-in as much of the following informa
|
||||
### Please tell us about your environment:
|
||||
|
||||
- [ ] Node-RED version:
|
||||
- [ ] node.js version:
|
||||
- [ ] Node.js version:
|
||||
- [ ] npm version:
|
||||
- [ ] Platform/OS:
|
||||
- [ ] Browser:
|
||||
|
7
.github/ISSUE_TEMPLATE/-anything-else.md
vendored
@@ -7,8 +7,11 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Please use the [Node-RED Forum](https://discourse.nodered.org) or [slack team](https://nodered.org/slack).
|
||||
Please DO NOT raise an issue.
|
||||
|
||||
You could also consider asking a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`.
|
||||
We DO NOT use the issue tracker for general support or feature requests. Only bug reports should be raised here using the 'Bug report' template.
|
||||
|
||||
For general support, 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.
|
||||
|
||||
For feature requests, please use the Node-RED Forum](https://discourse.nodered.org). Many ideas have already been discussed there and you should search that for your request before starting a new discussion.
|
||||
|
@@ -9,5 +9,3 @@ matrix:
|
||||
before_script:
|
||||
- npm install -g istanbul coveralls
|
||||
- node_js: "8"
|
||||
allow_failures:
|
||||
- node_js: "12"
|
||||
|
18
CHANGELOG.md
@@ -46,8 +46,24 @@ Nodes
|
||||
- Add expand editor button to Template node
|
||||
- Update catch/status nodes to use selectNodes api and treeList
|
||||
|
||||
#### 0.20.7: Maintenance Release
|
||||
|
||||
- Update jsonata to 1.6.5 which should fix #2183
|
||||
- Ensure the subflow stop promise is waiting for before restarting
|
||||
- Properly escape node types in palette
|
||||
|
||||
#### 0.20.6: Maintenance Release
|
||||
|
||||
- Revealing node position needs to account for zoom level Fixes #2172
|
||||
- stop join tripping up if last message of buffer is blank.
|
||||
- Improve handling of file upload in request node
|
||||
- Handle subflow internal node wired to a non-existant node Fixes #2202
|
||||
- Do not save subflow env vars with blank names
|
||||
- Don't allow a link node virtual wire to connect to normal port
|
||||
- Clear HTTP Request node authType when auth disabled Fixes #2215
|
||||
- Fix parsing of content-type header Fixes #2216
|
||||
- Fix join node reset issue with merging objects
|
||||
- Copy data-i18n attribute on TypedInput Fixes #2211
|
||||
|
||||
#### 0.20.5: Maintenance Release
|
||||
|
||||
@@ -709,7 +725,7 @@ Nodes
|
||||
- Initial support of sequence rules for SWITCH node (#1545)
|
||||
- initial support of SORT node (#1500)
|
||||
- Inject node - let once delay be editable (#1541)
|
||||
- Introduce `nodeMaxMessageBufferLength` setting for msg sequence nodes
|
||||
- Introduce `nodeMessageBufferMaxLength` setting for msg sequence nodes
|
||||
- Let CSV correct parts if we remove header row.
|
||||
- let default apply if msg.delay not set in override mode. (#1397)
|
||||
- let trigger node be reset by boolean message (#1554)
|
||||
|
@@ -26,7 +26,7 @@ relevant nodes, press Ctrl-E and copy the flow data from the Export dialog.
|
||||
At a minimum, please include:
|
||||
|
||||
- Version of Node-RED - either release number if you downloaded a zip, or the first few lines of `git log` if you are cloning the repository directly.
|
||||
- Version of node.js - what does `node -v` say?
|
||||
- Version of Node.js - what does `node -v` say?
|
||||
|
||||
## Feature requests
|
||||
|
||||
|
21
Gruntfile.js
@@ -169,6 +169,7 @@ module.exports = function(grunt) {
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/library.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/notifications.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/search.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/actionList.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/userSettings.js",
|
||||
@@ -495,7 +496,9 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-chmod');
|
||||
grunt.loadNpmTasks('grunt-jsonlint');
|
||||
grunt.loadNpmTasks('grunt-mocha-istanbul');
|
||||
grunt.loadNpmTasks('grunt-webdriver');
|
||||
if (fs.existsSync(path.join("node_modules", "grunt-webdriver"))) {
|
||||
grunt.loadNpmTasks('grunt-webdriver');
|
||||
}
|
||||
grunt.loadNpmTasks('grunt-jsdoc');
|
||||
grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
|
||||
grunt.loadNpmTasks('grunt-npm-command');
|
||||
@@ -554,8 +557,8 @@ module.exports = function(grunt) {
|
||||
});
|
||||
|
||||
grunt.registerTask('verifyUiTestDependencies', function() {
|
||||
if (!fs.existsSync(path.join("node_modules", "chromedriver"))) {
|
||||
grunt.fail.fatal('You need to run "npm install chromedriver@2" before running UI test.');
|
||||
if (!fs.existsSync(path.join("node_modules", "grunt-webdriver"))) {
|
||||
grunt.fail.fatal('You need to install the UI test dependencies first.\nUse the script in "scripts/install-ui-test-dependencies.sh"');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -578,9 +581,15 @@ module.exports = function(grunt) {
|
||||
'Runs code style check on editor code',
|
||||
['jshint:editor']);
|
||||
|
||||
grunt.registerTask('test-ui',
|
||||
'Builds editor content then runs unit tests on editor ui',
|
||||
['verifyUiTestDependencies','build','jshint:editor','webdriver:all']);
|
||||
if (!fs.existsSync(path.join("node_modules", "grunt-webdriver"))) {
|
||||
grunt.registerTask('test-ui',
|
||||
'Builds editor content then runs unit tests on editor ui',
|
||||
['verifyUiTestDependencies']);
|
||||
} else {
|
||||
grunt.registerTask('test-ui',
|
||||
'Builds editor content then runs unit tests on editor ui',
|
||||
['verifyUiTestDependencies','build','jshint:editor','webdriver:all']);
|
||||
}
|
||||
|
||||
grunt.registerTask('test-nodes',
|
||||
'Runs unit tests on core nodes',
|
||||
|
33
package.json
@@ -36,39 +36,37 @@
|
||||
"cors": "2.8.5",
|
||||
"cron": "1.7.1",
|
||||
"denque": "1.4.1",
|
||||
"express": "4.17.0",
|
||||
"express-session": "1.16.1",
|
||||
"fs-extra": "8.0.1",
|
||||
"express": "4.17.1",
|
||||
"express-session": "1.16.2",
|
||||
"fs-extra": "8.1.0",
|
||||
"fs.notify": "0.0.4",
|
||||
"hash-sum": "1.0.2",
|
||||
"hash-sum": "2.0.0",
|
||||
"https-proxy-agent": "2.2.1",
|
||||
"i18next": "15.1.2",
|
||||
"iconv-lite": "0.4.24",
|
||||
"iconv-lite": "0.5.0",
|
||||
"is-utf8": "0.2.1",
|
||||
"js-yaml": "3.13.1",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"jsonata": "1.6.4",
|
||||
"jsonata": "1.6.5",
|
||||
"media-typer": "1.1.0",
|
||||
"memorystore": "1.6.1",
|
||||
"mime": "2.4.3",
|
||||
"mime": "2.4.4",
|
||||
"mqtt": "2.18.8",
|
||||
"multer": "1.4.1",
|
||||
"mustache": "3.0.1",
|
||||
"node-red-node-email": "^1.4.0",
|
||||
"node-red-node-feedparser": "^0.1.14",
|
||||
"node-red-node-rbe": "^0.2.4",
|
||||
"node-red-node-sentiment": "^0.1.3",
|
||||
"node-red-node-tail": "^0.0.2",
|
||||
"node-red-node-twitter": "^1.1.4",
|
||||
"nopt": "4.0.1",
|
||||
"oauth2orize": "1.11.0",
|
||||
"on-headers": "1.0.2",
|
||||
"passport": "0.4.0",
|
||||
"passport-http-bearer": "1.0.1",
|
||||
"passport-oauth2-client-password": "0.1.2",
|
||||
"raw-body": "2.4.0",
|
||||
"raw-body": "2.4.1",
|
||||
"request": "2.88.0",
|
||||
"semver": "6.0.0",
|
||||
"uglify-js": "3.5.15",
|
||||
"semver": "6.2.0",
|
||||
"uglify-js": "3.6.0",
|
||||
"when": "3.7.8",
|
||||
"ws": "6.2.1",
|
||||
"xml2js": "0.4.19"
|
||||
@@ -77,7 +75,7 @@
|
||||
"bcrypt": "3.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~1.0.3",
|
||||
"grunt": "~1.0.4",
|
||||
"grunt-chmod": "~1.1.1",
|
||||
"grunt-cli": "~1.3.2",
|
||||
"grunt-concurrent": "~2.3.1",
|
||||
@@ -97,7 +95,6 @@
|
||||
"grunt-npm-command": "~0.1.2",
|
||||
"grunt-sass": "~2.0.0",
|
||||
"grunt-simple-mocha": "~0.4.1",
|
||||
"grunt-webdriver": "^2.0.3",
|
||||
"http-proxy": "^1.16.2",
|
||||
"istanbul": "0.4.5",
|
||||
"minami": "1.2.3",
|
||||
@@ -107,11 +104,7 @@
|
||||
"sinon": "1.17.7",
|
||||
"stoppable": "^1.1.0",
|
||||
"supertest": "3.4.2",
|
||||
"wdio-chromedriver-service": "^0.1.5",
|
||||
"wdio-mocha-framework": "^0.6.4",
|
||||
"wdio-spec-reporter": "^0.1.5",
|
||||
"webdriverio": "^4.14.1",
|
||||
"node-red-node-test-helper": "^0.2.2",
|
||||
"node-red-node-test-helper": "^0.2.3",
|
||||
"jsdoc-nr-template": "node-red/jsdoc-nr-template"
|
||||
},
|
||||
"engines": {
|
||||
|
@@ -30,7 +30,8 @@ module.exports = {
|
||||
scope: req.params.scope,
|
||||
id: req.params.id,
|
||||
key: req.params[0],
|
||||
store: req.query['store']
|
||||
store: req.query['store'],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.context.getValue(opts).then(function(result) {
|
||||
res.json(result);
|
||||
@@ -45,7 +46,8 @@ module.exports = {
|
||||
scope: req.params.scope,
|
||||
id: req.params.id,
|
||||
key: req.params[0],
|
||||
store: req.query['store']
|
||||
store: req.query['store'],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.context.delete(opts).then(function(result) {
|
||||
res.status(204).end();
|
||||
|
@@ -24,7 +24,8 @@ module.exports = {
|
||||
get: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.flows.getFlow(opts).then(function(result) {
|
||||
return res.json(result);
|
||||
@@ -35,7 +36,8 @@ module.exports = {
|
||||
post: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
flow: req.body
|
||||
flow: req.body,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.flows.addFlow(opts).then(function(id) {
|
||||
return res.json({id:id});
|
||||
@@ -47,7 +49,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
flow: req.body
|
||||
flow: req.body,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.flows.updateFlow(opts).then(function(id) {
|
||||
return res.json({id:id});
|
||||
@@ -58,7 +61,8 @@ module.exports = {
|
||||
delete: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.flows.deleteFlow(opts).then(function() {
|
||||
res.status(204).end();
|
||||
|
@@ -27,7 +27,8 @@ module.exports = {
|
||||
return res.status(400).json({code:"invalid_api_version", message:"Invalid API Version requested"});
|
||||
}
|
||||
var opts = {
|
||||
user: req.user
|
||||
user: req.user,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.flows.getFlows(opts).then(function(result) {
|
||||
if (version === "v1") {
|
||||
@@ -46,7 +47,8 @@ module.exports = {
|
||||
}
|
||||
var opts = {
|
||||
user: req.user,
|
||||
deploymentType: req.get("Node-RED-Deployment-Type")||"full"
|
||||
deploymentType: req.get("Node-RED-Deployment-Type")||"full",
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
|
||||
if (opts.deploymentType !== 'reload') {
|
||||
|
@@ -48,13 +48,13 @@ module.exports = {
|
||||
// Nodes
|
||||
adminApp.get("/nodes",needsPermission("nodes.read"),nodes.getAll,apiUtil.errorHandler);
|
||||
adminApp.post("/nodes",needsPermission("nodes.write"),nodes.post,apiUtil.errorHandler);
|
||||
adminApp.get(/\/nodes\/messages/,needsPermission("nodes.read"),nodes.getModuleCatalogs,apiUtil.errorHandler);
|
||||
adminApp.get(/\/nodes\/((@[^\/]+\/)?[^\/]+\/[^\/]+)\/messages/,needsPermission("nodes.read"),nodes.getModuleCatalog,apiUtil.errorHandler);
|
||||
adminApp.get(/\/nodes\/((@[^\/]+\/)?[^\/]+)$/,needsPermission("nodes.read"),nodes.getModule,apiUtil.errorHandler);
|
||||
adminApp.put(/\/nodes\/((@[^\/]+\/)?[^\/]+)$/,needsPermission("nodes.write"),nodes.putModule,apiUtil.errorHandler);
|
||||
adminApp.delete(/\/nodes\/((@[^\/]+\/)?[^\/]+)$/,needsPermission("nodes.write"),nodes.delete,apiUtil.errorHandler);
|
||||
adminApp.get(/\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,needsPermission("nodes.read"),nodes.getSet,apiUtil.errorHandler);
|
||||
adminApp.put(/\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,needsPermission("nodes.write"),nodes.putSet,apiUtil.errorHandler);
|
||||
adminApp.get(/^\/nodes\/messages/,needsPermission("nodes.read"),nodes.getModuleCatalogs,apiUtil.errorHandler);
|
||||
adminApp.get(/^\/nodes\/((@[^\/]+\/)?[^\/]+\/[^\/]+)\/messages/,needsPermission("nodes.read"),nodes.getModuleCatalog,apiUtil.errorHandler);
|
||||
adminApp.get(/^\/nodes\/((@[^\/]+\/)?[^\/]+)$/,needsPermission("nodes.read"),nodes.getModule,apiUtil.errorHandler);
|
||||
adminApp.put(/^\/nodes\/((@[^\/]+\/)?[^\/]+)$/,needsPermission("nodes.write"),nodes.putModule,apiUtil.errorHandler);
|
||||
adminApp.delete(/^\/nodes\/((@[^\/]+\/)?[^\/]+)$/,needsPermission("nodes.write"),nodes.delete,apiUtil.errorHandler);
|
||||
adminApp.get(/^\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,needsPermission("nodes.read"),nodes.getSet,apiUtil.errorHandler);
|
||||
adminApp.put(/^\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,needsPermission("nodes.write"),nodes.putSet,apiUtil.errorHandler);
|
||||
|
||||
// Context
|
||||
adminApp.get("/context/:scope(global)",needsPermission("context.read"),context.get,apiUtil.errorHandler);
|
||||
|
@@ -24,7 +24,8 @@ module.exports = {
|
||||
},
|
||||
getAll: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user
|
||||
user: req.user,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
if (req.get("accept") == "application/json") {
|
||||
runtimeAPI.nodes.getNodeList(opts).then(function(list) {
|
||||
@@ -42,7 +43,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
module: req.body.module,
|
||||
version: req.body.version
|
||||
version: req.body.version,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.addModule(opts).then(function(info) {
|
||||
res.json(info);
|
||||
@@ -54,7 +56,8 @@ module.exports = {
|
||||
delete: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
module: req.params[0]
|
||||
module: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.removeModule(opts).then(function() {
|
||||
res.status(204).end();
|
||||
@@ -66,7 +69,8 @@ module.exports = {
|
||||
getSet: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params[0] + "/" + req.params[2]
|
||||
id: req.params[0] + "/" + req.params[2],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
if (req.get("accept") === "application/json") {
|
||||
runtimeAPI.nodes.getNodeInfo(opts).then(function(result) {
|
||||
@@ -87,7 +91,8 @@ module.exports = {
|
||||
getModule: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
module: req.params[0]
|
||||
module: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.getModuleInfo(opts).then(function(result) {
|
||||
res.send(result);
|
||||
@@ -106,7 +111,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params[0] + "/" + req.params[2],
|
||||
enabled: body.enabled
|
||||
enabled: body.enabled,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.setNodeSetState(opts).then(function(result) {
|
||||
res.send(result);
|
||||
@@ -125,7 +131,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
module: req.params[0],
|
||||
enabled: body.enabled
|
||||
enabled: body.enabled,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.setModuleState(opts).then(function(result) {
|
||||
res.send(result);
|
||||
@@ -139,7 +146,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
module: req.params[0],
|
||||
lang: req.query.lng
|
||||
lang: req.query.lng,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.getModuleCatalog(opts).then(function(result) {
|
||||
res.json(result);
|
||||
@@ -152,7 +160,8 @@ module.exports = {
|
||||
getModuleCatalogs: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
lang: req.query.lng
|
||||
lang: req.query.lng,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.getModuleCatalogs(opts).then(function(result) {
|
||||
res.json(result);
|
||||
@@ -164,7 +173,8 @@ module.exports = {
|
||||
|
||||
getIcons: function(req,res) {
|
||||
var opts = {
|
||||
user: req.user
|
||||
user: req.user,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.nodes.getIconList(opts).then(function(list) {
|
||||
res.json(list);
|
||||
|
@@ -56,7 +56,7 @@ function expireSessions() {
|
||||
}
|
||||
if (nextExpiry < Number.MAX_SAFE_INTEGER) {
|
||||
// Allow 5 seconds grace
|
||||
expiryTimeout = setTimeout(expireSessions,(nextExpiry - Date.now()) + 5000)
|
||||
expiryTimeout = setTimeout(expireSessions,Math.min(2147483647,(nextExpiry - Date.now()) + 5000))
|
||||
}
|
||||
if (modified) {
|
||||
return storage.saveSessions(sessions);
|
||||
@@ -129,7 +129,7 @@ module.exports = {
|
||||
sessions[accessToken] = session;
|
||||
|
||||
if (!expiryTimeout) {
|
||||
expiryTimeout = setTimeout(expireSessions,(accessTokenExpiresAt - Date.now()) + 5000)
|
||||
expiryTimeout = setTimeout(expireSessions,Math.min(2147483647,(accessTokenExpiresAt - Date.now()) + 5000))
|
||||
}
|
||||
|
||||
return storage.saveSessions(sessions).then(function() {
|
||||
|
@@ -22,7 +22,8 @@ var needsPermission = require("../auth").needsPermission;
|
||||
|
||||
function listProjects(req,res) {
|
||||
var opts = {
|
||||
user: req.user
|
||||
user: req.user,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.listProjects(opts).then(function(result) {
|
||||
res.json(result);
|
||||
@@ -33,7 +34,8 @@ function listProjects(req,res) {
|
||||
function getProject(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getProject(opts).then(function(data) {
|
||||
if (data) {
|
||||
@@ -49,7 +51,8 @@ function getProjectStatus(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: req.query.remote
|
||||
remote: req.query.remote,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getStatus(opts).then(function(data){
|
||||
if (data) {
|
||||
@@ -64,7 +67,8 @@ function getProjectStatus(req,res) {
|
||||
function getProjectRemotes(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getRemotes(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -98,7 +102,8 @@ module.exports = {
|
||||
app.post("/", needsPermission("projects.write"), function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
project: req.body
|
||||
project: req.body,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.createProject(opts).then(function(result) {
|
||||
res.json(result);
|
||||
@@ -112,7 +117,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
project: req.body
|
||||
project: req.body,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
|
||||
if (req.body.active) {
|
||||
@@ -150,7 +156,8 @@ module.exports = {
|
||||
app.delete("/:id", needsPermission("projects.write"), function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.deleteProject(opts).then(function() {
|
||||
res.status(204).end();
|
||||
@@ -168,7 +175,8 @@ module.exports = {
|
||||
app.get("/:id/files", needsPermission("projects.read"), function(req,res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getFiles(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -185,7 +193,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.params[0],
|
||||
tree: req.params.treeish
|
||||
tree: req.params.treeish,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getFile(opts).then(function(data) {
|
||||
res.json({content:data});
|
||||
@@ -199,7 +208,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.params[0]
|
||||
path: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
|
||||
runtimeAPI.projects.revertFile(opts).then(function() {
|
||||
@@ -214,7 +224,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.params[0]
|
||||
path: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.stageFile(opts).then(function() {
|
||||
getProjectStatus(req,res);
|
||||
@@ -228,7 +239,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.body.files
|
||||
path: req.body.files,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.stageFile(opts).then(function() {
|
||||
getProjectStatus(req,res);
|
||||
@@ -242,7 +254,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
message: req.body.message
|
||||
message: req.body.message,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.commit(opts).then(function() {
|
||||
getProjectStatus(req,res);
|
||||
@@ -256,7 +269,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.params[0]
|
||||
path: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.unstageFile(opts).then(function() {
|
||||
getProjectStatus(req,res);
|
||||
@@ -269,7 +283,8 @@ module.exports = {
|
||||
app.delete("/:id/stage", needsPermission("projects.write"), function(req, res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.unstageFile(opts).then(function() {
|
||||
getProjectStatus(req,res);
|
||||
@@ -284,7 +299,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.params[0],
|
||||
type: req.params.type
|
||||
type: req.params.type,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getFileDiff(opts).then(function(data) {
|
||||
res.json({
|
||||
@@ -301,7 +317,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
limit: req.query.limit || 20,
|
||||
before: req.query.before
|
||||
before: req.query.before,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getCommits(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -315,7 +332,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
sha: req.params.sha
|
||||
sha: req.params.sha,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getCommit(opts).then(function(data) {
|
||||
res.json({commit:data});
|
||||
@@ -330,7 +348,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: req.params[0],
|
||||
track: req.query.u
|
||||
track: req.query.u,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.push(opts).then(function(data) {
|
||||
res.status(204).end();
|
||||
@@ -346,7 +365,8 @@ module.exports = {
|
||||
id: req.params.id,
|
||||
remote: req.params[0],
|
||||
track: req.query.setUpstream,
|
||||
allowUnrelatedHistories: req.query.allowUnrelatedHistories
|
||||
allowUnrelatedHistories: req.query.allowUnrelatedHistories,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.pull(opts).then(function(data) {
|
||||
res.status(204).end();
|
||||
@@ -359,7 +379,8 @@ module.exports = {
|
||||
app.delete("/:id/merge", needsPermission("projects.write"), function(req, res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id
|
||||
id: req.params.id,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.abortMerge(opts).then(function() {
|
||||
res.status(204).end();
|
||||
@@ -374,7 +395,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
path: req.params[0],
|
||||
resolution: req.body.resolutions
|
||||
resolution: req.body.resolutions,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.resolveMerge(opts).then(function() {
|
||||
res.status(204).end();
|
||||
@@ -388,7 +410,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: false
|
||||
remote: false,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getBranches(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -403,7 +426,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
branch: req.params.branchName,
|
||||
force: !!req.query.force
|
||||
force: !!req.query.force,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.deleteBranch(opts).then(function(data) {
|
||||
res.status(204).end();
|
||||
@@ -417,7 +441,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: true
|
||||
remote: true,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getBranches(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -431,7 +456,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
branch: req.params[0]
|
||||
branch: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.getBranchStatus(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -446,7 +472,8 @@ module.exports = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
branch: req.body.name,
|
||||
create: req.body.create
|
||||
create: req.body.create,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.setBranch(opts).then(function(data) {
|
||||
res.json(data);
|
||||
@@ -463,7 +490,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: req.body
|
||||
remote: req.body,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
if (/^https?:\/\/[^/]+@/i.test(req.body.url)) {
|
||||
res.status(400).json({error:"unexpected_error", message:"Git http url must not include username/password"});
|
||||
@@ -481,7 +509,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: req.params.remoteName
|
||||
remote: req.params.remoteName,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.removeRemote(opts).then(function(data) {
|
||||
getProjectRemotes(req,res);
|
||||
@@ -497,7 +526,8 @@ module.exports = {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
id: req.params.id,
|
||||
remote: remote
|
||||
remote: remote,
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
runtimeAPI.projects.updateRemote(opts).then(function() {
|
||||
res.status(204).end();
|
||||
|
@@ -28,7 +28,7 @@ var defaultContext = {
|
||||
},
|
||||
header: {
|
||||
title: "Node-RED",
|
||||
image: "red/images/node-red.png"
|
||||
image: "red/images/node-red.svg"
|
||||
},
|
||||
asset: {
|
||||
red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js",
|
||||
|
@@ -25,7 +25,7 @@ var theme = require("./theme");
|
||||
|
||||
var runtimeAPI;
|
||||
var editorClientDir = path.dirname(require.resolve("@node-red/editor-client"));
|
||||
var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.png");
|
||||
var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.svg");
|
||||
var editorTemplatePath = path.join(editorClientDir,"templates","index.mst");
|
||||
var editorTemplate;
|
||||
|
||||
|
@@ -47,5 +47,12 @@ module.exports = {
|
||||
code: err.code||"unexpected_error",
|
||||
message: err.message||err.toString()
|
||||
});
|
||||
},
|
||||
getRequestLogObject: function(req) {
|
||||
return {
|
||||
user: req.user,
|
||||
path: req.path,
|
||||
ip: (req.headers && req.headers['x-forwarded-for']) || (req.connection && req.connection.remoteAddress) || undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,10 +22,10 @@
|
||||
"body-parser": "1.19.0",
|
||||
"clone": "2.1.2",
|
||||
"cors": "2.8.5",
|
||||
"express-session": "1.16.1",
|
||||
"express": "4.17.0",
|
||||
"express-session": "1.16.2",
|
||||
"express": "4.17.1",
|
||||
"memorystore": "1.6.1",
|
||||
"mime": "2.4.3",
|
||||
"mime": "2.4.4",
|
||||
"mustache": "3.0.1",
|
||||
"oauth2orize": "1.11.0",
|
||||
"passport-http-bearer": "1.0.1",
|
||||
@@ -35,6 +35,6 @@
|
||||
"ws": "6.2.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"bcrypt": "3.0.5"
|
||||
"bcrypt": "3.0.6"
|
||||
}
|
||||
}
|
||||
|
@@ -310,6 +310,7 @@
|
||||
"addNewType": "Add new __type__...",
|
||||
"nodeProperties": "node properties",
|
||||
"label": "Label",
|
||||
"color": "Color",
|
||||
"portLabels": "Port labels",
|
||||
"labelInputs": "Inputs",
|
||||
"labelOutputs": "Outputs",
|
||||
@@ -321,6 +322,31 @@
|
||||
"description": "Description",
|
||||
"show": "Show",
|
||||
"hide": "Hide",
|
||||
"locale": "Select UI Language",
|
||||
"icon": "Icon",
|
||||
"inputType": "Input type",
|
||||
"previewUI": "Preview UI",
|
||||
"previewOK": "Preview OK",
|
||||
"types": {
|
||||
"str": "string",
|
||||
"num": "number",
|
||||
"bool": "bool",
|
||||
"json": "json",
|
||||
"bin": "buffer",
|
||||
"env": "env var",
|
||||
"no-value": "no value"
|
||||
},
|
||||
"menu": {
|
||||
"input": "input",
|
||||
"select": "select",
|
||||
"checkbox": "checkbox",
|
||||
"spinner": "spinner",
|
||||
"hidden": "label only"
|
||||
},
|
||||
"spinner": {
|
||||
"min": "min",
|
||||
"max": "max"
|
||||
},
|
||||
"errors": {
|
||||
"scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it",
|
||||
"invalidProperties": "Invalid properties:"
|
||||
@@ -351,7 +377,8 @@
|
||||
"pasteNode": "Paste nodes",
|
||||
"undoChange": "Undo the last change performed",
|
||||
"searchBox": "Open search box",
|
||||
"managePalette": "Manage palette"
|
||||
"managePalette": "Manage palette",
|
||||
"actionList":"Action list"
|
||||
},
|
||||
"library": {
|
||||
"library": "Library",
|
||||
@@ -365,6 +392,7 @@
|
||||
"savedNodes": "Saved nodes",
|
||||
"savedType": "Saved __type__",
|
||||
"saveFailed": "Save failed: __message__",
|
||||
"newFolder": "New folder",
|
||||
"types": {
|
||||
"local": "Local",
|
||||
"examples": "Examples"
|
||||
@@ -530,7 +558,9 @@
|
||||
"flow": "Flow",
|
||||
"global": "Global",
|
||||
"deleteConfirm": "Are you sure you want to delete this item?",
|
||||
"autoRefresh": "Auto-refresh"
|
||||
"autoRefresh": "Auto-refresh",
|
||||
"refrsh": "Refresh",
|
||||
"delete": "Delete"
|
||||
},
|
||||
"palette": {
|
||||
"name": "Palette management",
|
||||
@@ -736,7 +766,16 @@
|
||||
},
|
||||
"jsonEditor": {
|
||||
"title": "JSON editor",
|
||||
"format": "format JSON"
|
||||
"format": "format JSON",
|
||||
"rawMode": "Edit JSON",
|
||||
"uiMode": "Visual editor",
|
||||
"insertAbove": "Insert above",
|
||||
"insertBelow": "Insert below",
|
||||
"addItem": "Add item",
|
||||
"copyPath": "Copy path to item",
|
||||
"expandItems": "Expand items",
|
||||
"collapseItems": "Collapse items",
|
||||
"duplicate": "Duplicate"
|
||||
},
|
||||
"markdownEditor": {
|
||||
"title": "Markdown editor",
|
||||
@@ -926,8 +965,17 @@
|
||||
},
|
||||
"editor-tab": {
|
||||
"properties": "Properties",
|
||||
"envProperties": "Environment Variables",
|
||||
"description": "Description",
|
||||
"appearance": "Appearance",
|
||||
"env": "Environment Variables"
|
||||
"preview": "UI Preview",
|
||||
"defaultValue": "Default value"
|
||||
},
|
||||
"languages" : {
|
||||
"de": "German",
|
||||
"en-US": "English",
|
||||
"ja": "Japanese",
|
||||
"ko": "Korean",
|
||||
"zh-CN": "Chinese(Simplified)"
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,8 @@
|
||||
"status": "状態",
|
||||
"enabled": "有効",
|
||||
"disabled": "無効",
|
||||
"info": "詳細"
|
||||
"info": "詳細",
|
||||
"selectNodes": "ノードをクリックして選択"
|
||||
},
|
||||
"menu": {
|
||||
"label": {
|
||||
@@ -42,7 +43,9 @@
|
||||
"defaultDir": "標準",
|
||||
"ltr": "左から右",
|
||||
"rtl": "右から左",
|
||||
"auto": "文脈"
|
||||
"auto": "文脈",
|
||||
"language": "表示言語",
|
||||
"browserDefault": "ブラウザのデフォルト"
|
||||
},
|
||||
"sidebar": {
|
||||
"show": "サイドバーを表示"
|
||||
@@ -77,7 +80,7 @@
|
||||
"projects-new": "新規",
|
||||
"projects-open": "開く",
|
||||
"projects-settings": "設定",
|
||||
"showNodeLabelDefault": "追加したノードのラベルを表示する"
|
||||
"showNodeLabelDefault": "追加したノードのラベルを表示"
|
||||
}
|
||||
},
|
||||
"actions": {
|
||||
@@ -179,7 +182,11 @@
|
||||
"all": "全てのタブ",
|
||||
"compact": "インデントのないJSONフォーマット",
|
||||
"formatted": "インデント付きのJSONフォーマット",
|
||||
"copy": "書き出し"
|
||||
"copy": "書き出し",
|
||||
"export": "ライブラリに書き出し",
|
||||
"exportAs": "書き出し先",
|
||||
"overwrite": "更新",
|
||||
"exists": "<p><b>\"__file__\"</b>は既に存在します。</p><p>更新しますか?</p>"
|
||||
},
|
||||
"import": {
|
||||
"import": "読み込み先",
|
||||
@@ -303,6 +310,7 @@
|
||||
"addNewType": "新規に __type__ を追加...",
|
||||
"nodeProperties": "プロパティ",
|
||||
"label": "ラベル",
|
||||
"color": "色",
|
||||
"portLabels": "ポートラベル",
|
||||
"labelInputs": "入力",
|
||||
"labelOutputs": "出力",
|
||||
@@ -314,8 +322,34 @@
|
||||
"description": "詳細",
|
||||
"show": "表示",
|
||||
"hide": "非表示",
|
||||
"locale": "UI言語の選択",
|
||||
"icon": "記号",
|
||||
"inputType": "入力形式",
|
||||
"previewUI": "UI確認",
|
||||
"previewOK": "確認OK",
|
||||
"types": {
|
||||
"str": "文字列",
|
||||
"num": "数値",
|
||||
"bool": "真偽",
|
||||
"json": "JSON",
|
||||
"bin": "バッファ",
|
||||
"env": "環境変数",
|
||||
"no-value": "値無し"
|
||||
},
|
||||
"menu": {
|
||||
"input": "入力",
|
||||
"select": "選択",
|
||||
"checkbox": "チェックボックス",
|
||||
"spinner": "数値",
|
||||
"hidden": "ラベルのみ"
|
||||
},
|
||||
"spinner": {
|
||||
"min": "最小",
|
||||
"max": "最大"
|
||||
},
|
||||
"errors": {
|
||||
"scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします"
|
||||
"scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします",
|
||||
"invalidProperties": "プロパティが不正です:"
|
||||
}
|
||||
},
|
||||
"keyboard": {
|
||||
@@ -343,7 +377,8 @@
|
||||
"pasteNode": "ノードを貼り付け",
|
||||
"undoChange": "変更操作を戻す",
|
||||
"searchBox": "ノードを検索",
|
||||
"managePalette": "パレットの管理"
|
||||
"managePalette": "パレットの管理",
|
||||
"actionList": "動作一覧"
|
||||
},
|
||||
"library": {
|
||||
"library": "ライブラリ",
|
||||
@@ -351,12 +386,15 @@
|
||||
"saveToLibrary": "ライブラリへ保存",
|
||||
"typeLibrary": "__type__ ライブラリ",
|
||||
"unnamedType": "名前なし __type__",
|
||||
"exportedToLibrary": "ライブラリにノードを書き出しました",
|
||||
"dialogSaveOverwrite": "__libraryName__ という __libraryType__ は既に存在しています 上書きしますか?",
|
||||
"invalidFilename": "不正なファイル名",
|
||||
"savedNodes": "フローを保存しました",
|
||||
"savedType": "__type__ を保存しました",
|
||||
"saveFailed": "保存に失敗しました: __message__",
|
||||
"newFolder": "新規フォルダ",
|
||||
"types": {
|
||||
"local": "ローカル",
|
||||
"examples": "サンプル"
|
||||
}
|
||||
},
|
||||
@@ -516,10 +554,13 @@
|
||||
"none": "選択されていません",
|
||||
"refresh": "読み込みのため更新してください",
|
||||
"empty": "データが存在しません",
|
||||
"node": "Node",
|
||||
"flow": "Flow",
|
||||
"global": "Global",
|
||||
"deleteConfirm": "データを削除しても良いですか?"
|
||||
"node": "ノード",
|
||||
"flow": "フロー",
|
||||
"global": "グローバル",
|
||||
"deleteConfirm": "データを削除しても良いですか?",
|
||||
"autoRefresh": "自動更新",
|
||||
"refrsh": "更新",
|
||||
"delete": "削除"
|
||||
},
|
||||
"palette": {
|
||||
"name": "パレットの管理",
|
||||
@@ -719,9 +760,21 @@
|
||||
"jsEditor": {
|
||||
"title": "JavaScriptエディタ"
|
||||
},
|
||||
"textEditor": {
|
||||
"title": "テキストエディタ"
|
||||
},
|
||||
"jsonEditor": {
|
||||
"title": "JSONエディタ",
|
||||
"format": "JSONフォーマット"
|
||||
"format": "JSONフォーマット",
|
||||
"rawMode": "JSONを編集",
|
||||
"uiMode": "ビジュアルエディタ",
|
||||
"insertAbove": "上に挿入",
|
||||
"insertBelow": "下に挿入",
|
||||
"addItem": "要素を追加",
|
||||
"copyPath": "要素のパスをコピー",
|
||||
"expandItems": "要素を展開",
|
||||
"collapseItems": "要素を折り畳む",
|
||||
"duplicate": "複製"
|
||||
},
|
||||
"markdownEditor": {
|
||||
"title": "マークダウンエディタ",
|
||||
@@ -913,6 +966,13 @@
|
||||
"properties": "プロパティ",
|
||||
"description": "説明",
|
||||
"appearance": "外観",
|
||||
"env": "環境変数"
|
||||
"env": "サブフロープロパティ"
|
||||
},
|
||||
"languages": {
|
||||
"de": "ドイツ語",
|
||||
"en-US": "英語",
|
||||
"ja": "日本語",
|
||||
"ko": "韓国語",
|
||||
"zh-CN": "中国語(簡体)"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 291 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-flows-o.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="27" height="18" xmlns="http://www.w3.org/2000/svg"><g color="#000"><path fill="#fff" d="M0 5.002h10v5H0zM17 .002h10v5H17z"/><path d="M17 13.002h10v5H17z"/></g><path d="M9.5 7.502h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>
|
After Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 386 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-flows.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><path color="#000" fill="#8c101c" d="M0 .002h32v32H0z"/><g color="#000"><path fill="#fff" d="M2 13.002h10v5H2zM19 8.002h10v5H19z"/><path d="M19 21.002h10v5H19z"/></g><path d="M11.5 15.502h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>
|
After Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 289 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-full-o.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="27" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="#fff" color="#000"><path d="M0 5h10v5H0zM17 0h10v5H17zM17 13h10v5H17z"/></g><path d="M9.5 7.5h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>
|
After Width: | Height: | Size: 227 B |
Before Width: | Height: | Size: 368 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-full.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><path color="#000" fill="#8c101c" d="M0 0h32v32H0z"/><g fill="#fff" color="#000"><path d="M2 13h10v5H2zM19 8h10v5H19zM19 21h10v5H19z"/></g><path d="M11.5 15.5h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>
|
After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 290 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-nodes-o.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="27" height="18" xmlns="http://www.w3.org/2000/svg"><path color="#000" d="M0 5.002h10v5H0zM17 13.002h10v5H17z"/><path d="M9.5 7.502h2l4-5h2" fill="none" stroke="#000" stroke-width="1.5"/><path color="#000" fill="#fff" d="M17 .002h10v5H17z"/></svg>
|
After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 392 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-nodes.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><path color="#000" fill="#8c101c" d="M0 .002h32v32H0z"/><path color="#000" d="M2 13.002h10v5H2zM19 21.002h10v5H19z"/><path d="M11.5 15.502h2l4-5h2" fill="none" stroke="#000" stroke-width="1.5"/><path color="#000" fill="#fff" d="M19 8.002h10v5H19z"/></svg>
|
After Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 1015 B |
1
packages/node_modules/@node-red/editor-client/src/images/deploy-reload.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><g color="#000"><path fill="#8c101c" d="M0 .006h32v32H0z"/><path d="M11.81 25.429a10.02 10.02 0 0 0 4.19.914c5.562 0 10.107-4.545 10.107-10.106S21.562 6.131 16 6.131 5.895 10.676 5.895 16.237h3.368c0-3.74 2.997-6.737 6.738-6.737s6.737 2.996 6.737 6.737-2.996 6.738-6.737 6.738a6.775 6.775 0 0 1-2.533-.486l1.43-3.48-6.947 1.317 2.13 8.485z" fill="#fff" style="isolation:auto;mix-blend-mode:normal;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-transform:none;white-space:normal"/></g></svg>
|
After Width: | Height: | Size: 606 B |
Before Width: | Height: | Size: 393 B |
1
packages/node_modules/@node-red/editor-client/src/images/icons/arrow-in.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="40" height="60" xmlns="http://www.w3.org/2000/svg"><path d="M18 5v12H7v26h11v12l14-25z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 1019 B |
1
packages/node_modules/@node-red/editor-client/src/images/node-red.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="46.994" height="18.006" xmlns="http://www.w3.org/2000/svg"><g stroke="#d6d6d6"><g fill="#9e3131" stroke-linejoin="round" stroke-width="3.847" transform="matrix(.25848 0 0 .2614 -63.87 -108.483)"><rect x="249.04" y="435.92" width="50.294" height="22.953" ry="6.608"/><rect x="345.63" y="416.93" width="50.294" height="22.953" ry="6.608"/><rect x="376.71" y="459.01" width="50.294" height="22.953" ry="6.608"/></g><path d="M301.04 447.43c24.406.184 7.107-18.84 42.708-19.03M374.82 470.48c-46.966.538-28.989-22.664-73.619-22.944" fill="none" stroke-width="5.771" transform="matrix(.25848 0 0 .2614 -63.87 -108.483)"/></g></svg>
|
After Width: | Height: | Size: 636 B |
Before Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 410 B |
1
packages/node_modules/@node-red/editor-client/src/images/subflow_tab.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg"><path d="M25 16h7c.58 0 1-.42 1-1v-2c0-.58-.42-1-1-1h-7c-.58 0-1 .42-1 1v2c0 .58.42 1 1 1zM8 28h7c.58 0 1-.42 1-1v-2c0-.58-.42-1-1-1H8c-.58 0-1 .42-1 1v2c0 .58.42 1 1 1zm-.416 11C5.624 39 4 37.375 4 35.416V4.582C4 2.622 5.625 1 7.584 1h24.832C34.376 1 36 2.623 36 4.582v30.834C36 37.376 34.375 39 32.416 39zM32 27H19c0 2.19-1.81 4-4 4H7v4.416c0 .35.235.584.584.584h24.832c.35 0 .584-.235.584-.584v-8.417zm1-2v-6h-8c-2.19 0-4-1.81-4-4h-1c-4.333-.002-8.667.004-13 0v6h8c2.19 0 4 1.81 4 4h13zm0-16V4.582c0-.35-.235-.582-.584-.582H7.584C7.234 4 7 4.233 7 4.582v8.417c4.333.002 8.667.001 13 .001h1c0-2.19 1.81-4 4-4z" color="#000" fill="#333"/></svg>
|
After Width: | Height: | Size: 708 B |
Before Width: | Height: | Size: 638 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/09.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M14.16 27.38l1.555-.144c.132.731.383 1.261.755 1.591.371.33.848.494 1.429.494.497 0 .931-.114 1.303-.341.377-.228.686-.53.926-.908.24-.383.44-.899.602-1.546a8.122 8.122 0 0 0 .233-2.3 3.732 3.732 0 0 1-1.33 1.258 3.605 3.605 0 0 1-1.815.476c-1.09 0-2.013-.395-2.768-1.186s-1.133-1.834-1.133-3.128c0-1.336.393-2.411 1.178-3.226.79-.815 1.78-1.223 2.966-1.223.856 0 1.638.231 2.345.692.713.462 1.253 1.12 1.618 1.978.372.85.557 2.085.557 3.702 0 1.684-.182 3.026-.548 4.027-.365.994-.91 1.752-1.636 2.274-.719.52-1.563.781-2.534.781-1.03 0-1.872-.284-2.525-.853-.654-.576-1.046-1.381-1.178-2.418zm6.624-5.815c0-.928-.249-1.666-.746-2.21-.492-.546-1.085-.819-1.78-.819-.719 0-1.345.294-1.878.881s-.8 1.348-.8 2.283c0 .839.252 1.522.755 2.05.51.52 1.135.781 1.878.781.75 0 1.363-.26 1.843-.782.485-.527.728-1.255.728-2.184zM4.858 10.466c0-1.558.158-2.81.476-3.757.324-.952.8-1.686 1.429-2.201.635-.516 1.432-.773 2.39-.773.708 0 1.328.143 1.861.431.533.282.974.692 1.321 1.231.348.534.62 1.187.818 1.96.198.767.297 1.803.297 3.11 0 1.545-.16 2.794-.477 3.747-.317.947-.794 1.68-1.429 2.202-.629.515-1.426.773-2.39.773-1.27 0-2.268-.456-2.993-1.366-.869-1.097-1.303-2.882-1.303-5.357zm1.662 0c0 2.163.252 3.604.755 4.323.51.713 1.136 1.07 1.879 1.07.743 0 1.366-.36 1.87-1.079.508-.719.763-2.157.763-4.314 0-2.169-.255-3.61-.764-4.323-.503-.713-1.132-1.07-1.887-1.07-.743 0-1.336.315-1.78.944-.557.803-.836 2.286-.836 4.45z" fill="#444"/></svg>
|
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 546 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/az.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M13.27 29.15l6.733-8.143h-6.235V19.3h8.8v1.559l-6.69 8.09h6.892v1.707h-9.5zm4.909-10.125zM6.577 12.58q0 .827.604 1.304.605.478 1.432.478 1.007 0 1.95-.467 1.59-.774 1.59-2.534V9.824q-.349.222-.9.37-.552.15-1.082.213l-1.155.148q-1.04.138-1.56.435-.88.498-.88 1.59zM11.2 8.721q.657-.085.88-.551.127-.255.127-.732 0-.975-.7-1.41-.689-.445-1.983-.445-1.495 0-2.12.805-.35.446-.456 1.326H5.167q.053-2.1 1.357-2.916 1.315-.827 3.043-.827 2.004 0 3.255.763 1.24.764 1.24 2.375v6.542q0 .297.117.477.127.18.52.18.127 0 .286-.01.159-.021.34-.053v1.41q-.446.127-.68.16-.233.031-.636.031-.986 0-1.43-.7-.234-.37-.33-1.05-.583.764-1.675 1.326t-2.407.562q-1.58 0-2.587-.954-.996-.965-.996-2.407 0-1.58.986-2.45.986-.869 2.587-1.07zm-1.58-4.75z" fill="#444"/></svg>
|
After Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 638 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/bin.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M18.8 33.9c3.328 0 4.776-2.603 4.776-7.066s-1.448-7.066-4.776-7.066-4.776 2.603-4.776 7.066S15.473 33.9 18.8 33.9zm0-1.429c-2.192 0-3.073-1.781-3.073-4.522v-2.23c0-2.741.88-4.523 3.073-4.523s3.073 1.782 3.073 4.522v2.231c0 2.74-.88 4.522-3.073 4.522zm-6.306 1.194v-1.429H8.892V20.002H6.328l-3.621 3.386.959 1.038 3.445-3.21h.137v11.02H3.333v1.429zm11.2-17.7v-1.429h-3.602V2.302h-2.564l-3.621 3.386.959 1.038 3.445-3.21h.137v11.02h-3.915v1.429zM7.5 16.2c3.327 0 4.776-2.603 4.776-7.066S10.828 2.068 7.5 2.068 2.725 4.67 2.725 9.134 4.173 16.2 7.5 16.2zm0-1.429c-2.193 0-3.074-1.781-3.074-4.522V8.02c0-2.741.881-4.523 3.074-4.523s3.073 1.782 3.073 4.522v2.231c0 2.74-.881 4.522-3.073 4.522z" fill="#444"/></svg>
|
After Width: | Height: | Size: 781 B |
Before Width: | Height: | Size: 646 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/bool.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M9.96 21.98a5 5 0 1 1 6.11-7.917zm3.035-13.973c-5.512 0-10 4.488-10 10s4.488 9.998 10 9.998 10-4.486 10-9.998-4.488-10-10-10zm0 1.816c4.53 0 8.182 3.655 8.182 8.184s-3.652 8.182-8.182 8.182-8.181-3.653-8.181-8.182 3.652-8.184 8.181-8.184z" color="#000" fill="#444"/></svg>
|
After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 809 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/env.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M14.33 27.19q2.916-.136 4.024-2.131.58-1.024.58-2.37 0-2.132-1.569-3.24-.904-.648-3.035-1.228zM8.55 10.736q0 1.688 1.108 2.643 1.125.955 3.018 1.33V6.695q-2.234.085-3.189 1.364-.937 1.279-.937 2.677zm-3.07.205q0-2.592 1.893-4.672 1.91-2.08 5.337-2.115V1.887h1.62V4.12q3.393.239 5.2 2.012 1.825 1.757 1.91 4.655h-2.984q-.119-1.296-.699-2.233-1.074-1.723-3.427-1.808v8.287q3.956 1.108 5.371 2.08 2.302 1.603 2.302 4.74 0 4.536-2.95 6.446-1.637 1.057-4.723 1.398v3.308h-1.62v-3.308q-4.962-.324-6.735-3.513-.972-1.722-.972-4.655h3.018q.136 2.336.733 3.41 1.057 1.927 3.922 2.166v-9.293q-3.683-.699-5.44-2.336Q5.48 13.84 5.48 10.941z" fill="#444"/></svg>
|
After Width: | Height: | Size: 722 B |
Before Width: | Height: | Size: 563 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/expr.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-337.103 -913.25) scale(1.2585)" fill="#444" stroke-width=".795"><circle cx="284.36" cy="733.68" r="1.5" color="#000" style="isolation:auto;mix-blend-mode:normal"/><circle cx="284.33" cy="740.74" r="1.5" color="#000" style="isolation:auto;mix-blend-mode:normal"/><path d="M276.18 727.78l4.396-1.565v18.515c-.711 2.606-2.922 4.394-5.812 5.812l-4.135 1.974-.559-1.192 3.353-1.639c1.459-.724 2.689-1.87 2.869-4.955z" fill-rule="evenodd"/></g></svg>
|
After Width: | Height: | Size: 532 B |
Before Width: | Height: | Size: 588 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/json.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M15 5.225v-1.92h2.24q.608 0 1.216.288.608.256 1.12.8.48.512.8 1.312.32.768.32 1.792v5.824q0 .832.224 1.536t.608 1.216q.352.48.832.768.48.256.992.256v2.176q-.512 0-.992.256t-.832.736q-.384.48-.608 1.184t-.224 1.568v5.792q0 1.024-.32 1.792-.32.8-.8 1.312-.512.544-1.12.8-.608.288-1.216.288H15v-1.92h1.6q.48 0 .768-.256.288-.224.48-.64.16-.384.224-.896.064-.48.064-.96v-5.824q0-1.216.352-2.016.32-.8.768-1.28.448-.512.928-.736.448-.224.736-.256v-.096q-.288-.064-.736-.32-.48-.256-.928-.768t-.768-1.28q-.352-.8-.352-1.92V7.977q0-.512-.064-.992-.064-.512-.224-.896-.192-.384-.48-.608-.288-.256-.768-.256zm-3.648 0v-1.92h-2.24q-.608 0-1.216.288-.608.256-1.12.8-.48.512-.8 1.312-.32.768-.32 1.792v5.824q0 .832-.224 1.536t-.608 1.216q-.352.48-.832.768-.48.256-.992.256v2.176q.512 0 .992.256t.832.736q.384.48.608 1.184t.224 1.568v5.792q0 1.024.32 1.792.32.8.8 1.312.512.544 1.12.8.608.288 1.216.288h2.24v-1.92h-1.6q-.48 0-.768-.256-.288-.224-.48-.64-.16-.384-.224-.896-.064-.48-.064-.96v-5.824q0-1.216-.352-2.016-.32-.8-.768-1.28-.448-.512-.928-.736-.448-.224-.736-.256v-.096q.288-.064.736-.32.48-.256.928-.768t.768-1.28q.352-.8.352-1.92V7.977q0-.512.064-.992.064-.512.224-.896.192-.384.48-.608.288-.256.768-.256z" fill="#444"/></svg>
|
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 502 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/re.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M2 19h5v5H2zm16.099-3.304v-5.659h-2.654v5.66l-5.309-2.004-.901 2.404L14.543 18l-3.255 4.557 2.254 1.553 3.255-4.808 3.455 4.808 2.054-1.553L19 18l5.46-1.903-1.002-2.404z" color="#000" fill="#444444"/></svg>
|
After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 944 B |
1
packages/node_modules/@node-red/editor-client/src/images/typedInput/target.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M11 5v5.77a7.542 7.542 0 0 0-5.234 5.25L1 16c-1.432 1.397-1.232 2.722 0 4l4.75-.078a7.542 7.542 0 0 0 5.22 5.297L11 31c1.316 1.303 2.649 1.363 4 0l.009-5.775A7.542 7.542 0 0 0 20.228 20H25c1.261-1.294 1.404-2.623 0-4l-4.774-.01a7.542 7.542 0 0 0-5.23-5.22L15 5c-1.3-1.273-2.63-1.393-4 0zm2 7.499c3.05 0 5.5 2.45 5.5 5.5s-2.45 5.5-5.5 5.5-5.5-2.45-5.5-5.5 2.45-5.5 5.5-5.5z" color="#000" fill="#444"/></svg>
|
After Width: | Height: | Size: 479 B |
@@ -14,7 +14,8 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
RED.history = (function() {
|
||||
var undo_history = [];
|
||||
var undoHistory = [];
|
||||
var redoHistory = [];
|
||||
|
||||
function undoEvent(ev) {
|
||||
var i;
|
||||
@@ -22,52 +23,81 @@ RED.history = (function() {
|
||||
var node;
|
||||
var subflow;
|
||||
var modifiedTabs = {};
|
||||
var inverseEv;
|
||||
if (ev) {
|
||||
if (ev.t == 'multi') {
|
||||
inverseEv = {
|
||||
t: 'multi',
|
||||
events: []
|
||||
};
|
||||
len = ev.events.length;
|
||||
for (i=len-1;i>=0;i--) {
|
||||
undoEvent(ev.events[i]);
|
||||
var r = undoEvent(ev.events[i]);
|
||||
inverseEv.events.push(r);
|
||||
}
|
||||
} else if (ev.t == 'replace') {
|
||||
inverseEv = {
|
||||
t: 'replace',
|
||||
config: RED.nodes.createCompleteNodeSet(),
|
||||
changed: [],
|
||||
rev: RED.nodes.version()
|
||||
};
|
||||
RED.nodes.clear();
|
||||
var imported = RED.nodes.import(ev.config);
|
||||
imported[0].forEach(function(n) {
|
||||
if (ev.changed[n.id]) {
|
||||
n.changed = true;
|
||||
inverseEv.changed[n.id] = true;
|
||||
}
|
||||
})
|
||||
|
||||
RED.nodes.version(ev.rev);
|
||||
} else if (ev.t == 'add') {
|
||||
inverseEv = {
|
||||
t: "delete",
|
||||
};
|
||||
if (ev.nodes) {
|
||||
inverseEv.nodes = [];
|
||||
for (i=0;i<ev.nodes.length;i++) {
|
||||
node = RED.nodes.node(ev.nodes[i]);
|
||||
if (node.z) {
|
||||
modifiedTabs[node.z] = true;
|
||||
}
|
||||
inverseEv.nodes.push(node);
|
||||
RED.nodes.remove(ev.nodes[i]);
|
||||
}
|
||||
}
|
||||
if (ev.links) {
|
||||
inverseEv.links = [];
|
||||
for (i=0;i<ev.links.length;i++) {
|
||||
inverseEv.links.push(ev.links[i]);
|
||||
RED.nodes.removeLink(ev.links[i]);
|
||||
}
|
||||
}
|
||||
if (ev.workspaces) {
|
||||
inverseEv.workspaces = [];
|
||||
for (i=0;i<ev.workspaces.length;i++) {
|
||||
var workspaceOrder = RED.nodes.getWorkspaceOrder();
|
||||
ev.workspaces[i]._index = workspaceOrder.indexOf(ev.workspaces[i].id);
|
||||
inverseEv.workspaces.push(ev.workspaces[i]);
|
||||
RED.nodes.removeWorkspace(ev.workspaces[i].id);
|
||||
RED.workspaces.remove(ev.workspaces[i]);
|
||||
}
|
||||
}
|
||||
if (ev.subflows) {
|
||||
inverseEv.subflows = [];
|
||||
for (i=0;i<ev.subflows.length;i++) {
|
||||
inverseEv.subflows.push(ev.subflows[i]);
|
||||
RED.nodes.removeSubflow(ev.subflows[i]);
|
||||
RED.workspaces.remove(ev.subflows[i]);
|
||||
}
|
||||
}
|
||||
if (ev.subflow) {
|
||||
inverseEv.subflow = {};
|
||||
if (ev.subflow.instances) {
|
||||
inverseEv.subflow.instances = [];
|
||||
ev.subflow.instances.forEach(function(n) {
|
||||
inverseEv.subflow.instances.push(n);
|
||||
var node = RED.nodes.node(n.id);
|
||||
if (node) {
|
||||
node.changed = n.changed;
|
||||
@@ -83,21 +113,30 @@ RED.history = (function() {
|
||||
}
|
||||
}
|
||||
if (ev.removedLinks) {
|
||||
inverseEv.createdLinks = [];
|
||||
for (i=0;i<ev.removedLinks.length;i++) {
|
||||
inverseEv.createdLinks.push(ev.removedLinks[i]);
|
||||
RED.nodes.addLink(ev.removedLinks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ev.t == "delete") {
|
||||
inverseEv = {
|
||||
t: "add"
|
||||
};
|
||||
if (ev.workspaces) {
|
||||
inverseEv.workspaces = [];
|
||||
for (i=0;i<ev.workspaces.length;i++) {
|
||||
inverseEv.workspaces.push(ev.workspaces[i]);
|
||||
RED.nodes.addWorkspace(ev.workspaces[i],ev.workspaces[i]._index);
|
||||
RED.workspaces.add(ev.workspaces[i],undefined,ev.workspaces[i]._index);
|
||||
delete ev.workspaces[i]._index;
|
||||
}
|
||||
}
|
||||
if (ev.subflows) {
|
||||
inverseEv.subflows = [];
|
||||
for (i=0;i<ev.subflows.length;i++) {
|
||||
inverseEv.subflows.push(ev.subflows[i]);
|
||||
RED.nodes.addSubflow(ev.subflows[i]);
|
||||
}
|
||||
}
|
||||
@@ -126,8 +165,11 @@ RED.history = (function() {
|
||||
}
|
||||
}
|
||||
if (ev.subflow) {
|
||||
inverseEv.subflow = {};
|
||||
if (ev.subflow.hasOwnProperty('instances')) {
|
||||
inverseEv.subflow.instances = [];
|
||||
ev.subflow.instances.forEach(function(n) {
|
||||
inverseEv.subflow.instances.push(n);
|
||||
var node = RED.nodes.node(n.id);
|
||||
if (node) {
|
||||
node.changed = n.changed;
|
||||
@@ -152,14 +194,25 @@ RED.history = (function() {
|
||||
});
|
||||
}
|
||||
if (ev.nodes) {
|
||||
inverseEv.nodes = [];
|
||||
for (i=0;i<ev.nodes.length;i++) {
|
||||
RED.nodes.add(ev.nodes[i]);
|
||||
modifiedTabs[ev.nodes[i].z] = true;
|
||||
inverseEv.nodes.push(ev.nodes[i].id);
|
||||
}
|
||||
}
|
||||
if (ev.links) {
|
||||
inverseEv.links = [];
|
||||
for (i=0;i<ev.links.length;i++) {
|
||||
RED.nodes.addLink(ev.links[i]);
|
||||
inverseEv.links.push(ev.links[i]);
|
||||
}
|
||||
}
|
||||
if (ev.createdLinks) {
|
||||
inverseEv.removedLinks = [];
|
||||
for (i=0;i<ev.createdLinks.length;i++) {
|
||||
inverseEv.removedLinks.push(ev.createdLinks[i]);
|
||||
RED.nodes.removeLink(ev.createdLinks[i]);
|
||||
}
|
||||
}
|
||||
if (ev.changes) {
|
||||
@@ -179,8 +232,14 @@ RED.history = (function() {
|
||||
|
||||
}
|
||||
} else if (ev.t == "move") {
|
||||
inverseEv = {
|
||||
t: 'move',
|
||||
nodes: []
|
||||
};
|
||||
for (i=0;i<ev.nodes.length;i++) {
|
||||
var n = ev.nodes[i];
|
||||
var rn = {n: n.n, ox: n.n.x, oy: n.n.y, dirty: true, moved: n.moved};
|
||||
inverseEv.nodes.push(rn);
|
||||
n.n.x = n.ox;
|
||||
n.n.y = n.oy;
|
||||
n.n.dirty = true;
|
||||
@@ -188,18 +247,28 @@ RED.history = (function() {
|
||||
}
|
||||
// A move could have caused a link splice
|
||||
if (ev.links) {
|
||||
inverseEv.removedLinks = [];
|
||||
for (i=0;i<ev.links.length;i++) {
|
||||
inverseEv.removedLinks.push(ev.links[i]);
|
||||
RED.nodes.removeLink(ev.links[i]);
|
||||
}
|
||||
}
|
||||
if (ev.removedLinks) {
|
||||
inverseEv.links = [];
|
||||
for (i=0;i<ev.removedLinks.length;i++) {
|
||||
inverseEv.links.push(ev.removedLinks[i]);
|
||||
RED.nodes.addLink(ev.removedLinks[i]);
|
||||
}
|
||||
}
|
||||
} else if (ev.t == "edit") {
|
||||
inverseEv = {
|
||||
t: "edit",
|
||||
changes: {}
|
||||
};
|
||||
inverseEv.node = ev.node;
|
||||
for (i in ev.changes) {
|
||||
if (ev.changes.hasOwnProperty(i)) {
|
||||
inverseEv.changes[i] = ev.node[i];
|
||||
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]);
|
||||
@@ -214,23 +283,34 @@ RED.history = (function() {
|
||||
ev.node[i] = ev.changes[i];
|
||||
}
|
||||
}
|
||||
if (ev.node.type === 'tab' && ev.changes.hasOwnProperty('disabled')) {
|
||||
$("#red-ui-tab-"+(ev.node.id.replace(".","-"))).toggleClass('red-ui-workspace-disabled',!!ev.node.disabled);
|
||||
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!ev.node.disabled);
|
||||
}
|
||||
if (ev.subflow) {
|
||||
inverseEv.subflow = {};
|
||||
if (ev.subflow.hasOwnProperty('inputCount')) {
|
||||
inverseEv.subflow.inputCount = ev.node.in.length;
|
||||
if (ev.node.in.length > ev.subflow.inputCount) {
|
||||
inverseEv.subflow.inputs = ev.node.in.slice(ev.subflow.inputCount);
|
||||
ev.node.in.splice(ev.subflow.inputCount);
|
||||
} else if (ev.subflow.inputs.length > 0) {
|
||||
ev.node.in = ev.node.in.concat(ev.subflow.inputs);
|
||||
}
|
||||
}
|
||||
if (ev.subflow.hasOwnProperty('outputCount')) {
|
||||
inverseEv.subflow.outputCount = ev.node.out.length;
|
||||
if (ev.node.out.length > ev.subflow.outputCount) {
|
||||
inverseEv.subflow.outputs = ev.node.out.slice(ev.subflow.outputCount);
|
||||
ev.node.out.splice(ev.subflow.outputCount);
|
||||
} else if (ev.subflow.outputs.length > 0) {
|
||||
ev.node.out = ev.node.out.concat(ev.subflow.outputs);
|
||||
}
|
||||
}
|
||||
if (ev.subflow.hasOwnProperty('instances')) {
|
||||
inverseEv.subflow.instances = [];
|
||||
ev.subflow.instances.forEach(function(n) {
|
||||
inverseEv.subflow.instances.push(n);
|
||||
var node = RED.nodes.node(n.id);
|
||||
if (node) {
|
||||
node.changed = n.changed;
|
||||
@@ -254,9 +334,11 @@ RED.history = (function() {
|
||||
var outputMap;
|
||||
if (ev.outputMap) {
|
||||
outputMap = {};
|
||||
inverseEv.outputMap = {};
|
||||
for (var port in ev.outputMap) {
|
||||
if (ev.outputMap.hasOwnProperty(port) && ev.outputMap[port] !== "-1") {
|
||||
outputMap[ev.outputMap[port]] = port;
|
||||
inverseEv.outputMap[ev.outputMap[port]] = port;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,39 +346,107 @@ RED.history = (function() {
|
||||
RED.editor.validateNode(ev.node);
|
||||
}
|
||||
if (ev.links) {
|
||||
inverseEv.createdLinks = [];
|
||||
for (i=0;i<ev.links.length;i++) {
|
||||
RED.nodes.addLink(ev.links[i]);
|
||||
inverseEv.createdLinks.push(ev.links[i]);
|
||||
}
|
||||
}
|
||||
if (ev.createdLinks) {
|
||||
inverseEv.links = [];
|
||||
for (i=0;i<ev.createdLinks.length;i++) {
|
||||
RED.nodes.removeLink(ev.createdLinks[i]);
|
||||
inverseEv.links.push(ev.createdLinks[i]);
|
||||
}
|
||||
}
|
||||
ev.node.dirty = true;
|
||||
ev.node.changed = ev.changed;
|
||||
} else if (ev.t == "createSubflow") {
|
||||
inverseEv = {
|
||||
t: "deleteSubflow",
|
||||
activeWorkspace: ev.activeWorkspace,
|
||||
dirty: RED.nodes.dirty()
|
||||
};
|
||||
if (ev.nodes) {
|
||||
inverseEv.movedNodes = [];
|
||||
var z = ev.activeWorkspace;
|
||||
RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) {
|
||||
n.x += ev.subflow.offsetX;
|
||||
n.y += ev.subflow.offsetY;
|
||||
n.z = ev.activeWorkspace;
|
||||
n.dirty = true;
|
||||
inverseEv.movedNodes.push(n.id);
|
||||
RED.nodes.moveNodeToTab(n, z);
|
||||
});
|
||||
inverseEv.subflows = [];
|
||||
for (i=0;i<ev.nodes.length;i++) {
|
||||
inverseEv.subflows.push(RED.nodes.node(ev.nodes[i]));
|
||||
RED.nodes.remove(ev.nodes[i]);
|
||||
}
|
||||
}
|
||||
if (ev.links) {
|
||||
inverseEv.links = [];
|
||||
for (i=0;i<ev.links.length;i++) {
|
||||
inverseEv.links.push(ev.links[i]);
|
||||
RED.nodes.removeLink(ev.links[i]);
|
||||
}
|
||||
}
|
||||
|
||||
inverseEv.subflow = ev.subflow;
|
||||
RED.nodes.removeSubflow(ev.subflow.subflow);
|
||||
RED.workspaces.remove(ev.subflow.subflow);
|
||||
|
||||
if (ev.removedLinks) {
|
||||
inverseEv.createdLinks = [];
|
||||
for (i=0;i<ev.removedLinks.length;i++) {
|
||||
inverseEv.createdLinks.push(ev.removedLinks[i]);
|
||||
RED.nodes.addLink(ev.removedLinks[i]);
|
||||
}
|
||||
}
|
||||
} else if (ev.t == "deleteSubflow") {
|
||||
inverseEv = {
|
||||
t: "createSubflow",
|
||||
activeWorkspace: ev.activeWorkspace,
|
||||
dirty: RED.nodes.dirty(),
|
||||
};
|
||||
if (ev.subflow) {
|
||||
RED.nodes.addSubflow(ev.subflow.subflow);
|
||||
inverseEv.subflow = ev.subflow;
|
||||
}
|
||||
if (ev.subflows) {
|
||||
inverseEv.nodes = [];
|
||||
for (i=0;i<ev.subflows.length;i++) {
|
||||
RED.nodes.add(ev.subflows[i]);
|
||||
inverseEv.nodes.push(ev.subflows[i].id);
|
||||
}
|
||||
}
|
||||
if (ev.movedNodes) {
|
||||
ev.movedNodes.forEach(function(nid) {
|
||||
nn = RED.nodes.node(nid);
|
||||
nn.x -= ev.subflow.offsetX;
|
||||
nn.y -= ev.subflow.offsetY;
|
||||
nn.dirty = true;
|
||||
RED.nodes.moveNodeToTab(nn, ev.subflow.subflow.id);
|
||||
});
|
||||
}
|
||||
if (ev.links) {
|
||||
inverseEv.links = [];
|
||||
for (i=0;i<ev.links.length;i++) {
|
||||
inverseEv.links.push(ev.links[i]);
|
||||
RED.nodes.addLink(ev.links[i]);
|
||||
}
|
||||
}
|
||||
if (ev.createdLinks) {
|
||||
inverseEv.removedLinks = [];
|
||||
for (i=0;i<ev.createdLinks.length;i++) {
|
||||
inverseEv.removedLinks.push(ev.createdLinks[i]);
|
||||
RED.nodes.removeLink(ev.createdLinks[i]);
|
||||
}
|
||||
}
|
||||
} else if (ev.t == "reorder") {
|
||||
inverseEv = {
|
||||
t: 'reorder',
|
||||
order: RED.nodes.getWorkspaceOrder()
|
||||
};
|
||||
if (ev.order) {
|
||||
RED.workspaces.order(ev.order);
|
||||
}
|
||||
@@ -316,6 +466,8 @@ RED.history = (function() {
|
||||
RED.workspaces.refresh();
|
||||
RED.sidebar.config.refresh();
|
||||
RED.subflow.refresh();
|
||||
|
||||
return inverseEv;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -323,28 +475,42 @@ RED.history = (function() {
|
||||
return {
|
||||
//TODO: this function is a placeholder until there is a 'save' event that can be listened to
|
||||
markAllDirty: function() {
|
||||
for (var i=0;i<undo_history.length;i++) {
|
||||
undo_history[i].dirty = true;
|
||||
for (var i=0;i<undoHistory.length;i++) {
|
||||
undoHistory[i].dirty = true;
|
||||
}
|
||||
},
|
||||
list: function() {
|
||||
return undo_history
|
||||
return undoHistory;
|
||||
},
|
||||
depth: function() {
|
||||
return undo_history.length;
|
||||
return undoHistory.length;
|
||||
},
|
||||
push: function(ev) {
|
||||
undo_history.push(ev);
|
||||
undoHistory.push(ev);
|
||||
redoHistory = [];
|
||||
},
|
||||
pop: function() {
|
||||
var ev = undo_history.pop();
|
||||
undoEvent(ev);
|
||||
var ev = undoHistory.pop();
|
||||
var rev = undoEvent(ev);
|
||||
if (rev) {
|
||||
redoHistory.push(rev);
|
||||
}
|
||||
},
|
||||
peek: function() {
|
||||
return undo_history[undo_history.length-1];
|
||||
return undoHistory[undoHistory.length-1];
|
||||
},
|
||||
clear: function() {
|
||||
undo_history = [];
|
||||
undoHistory = [];
|
||||
redoHistory = [];
|
||||
},
|
||||
redo: function() {
|
||||
var ev = redoHistory.pop();
|
||||
if (ev) {
|
||||
var uev = undoEvent(ev);
|
||||
if (uev) {
|
||||
undoHistory.push(uev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -50,8 +50,21 @@ RED.i18n = (function() {
|
||||
}
|
||||
|
||||
},
|
||||
lang: function() {
|
||||
// Gets the active message catalog language. This is based on what
|
||||
// locale the editor is using and what languages are available.
|
||||
//
|
||||
var preferredLangs = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
||||
var knownLangs = RED.settings.theme("languages")||["en-US"];
|
||||
for (var i=0;i<preferredLangs.length;i++) {
|
||||
if (knownLangs.indexOf(preferredLangs[i]) > -1) {
|
||||
return preferredLangs[i]
|
||||
}
|
||||
}
|
||||
return 'end-US'
|
||||
},
|
||||
loadNodeCatalog: function(namespace,done) {
|
||||
var languageList = i18n.functions.toLanguages(i18n.detectLanguage());
|
||||
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
||||
var toLoad = languageList.length;
|
||||
languageList.forEach(function(lang) {
|
||||
$.ajax({
|
||||
@@ -73,7 +86,7 @@ RED.i18n = (function() {
|
||||
},
|
||||
|
||||
loadNodeCatalogs: function(done) {
|
||||
var languageList = i18n.functions.toLanguages(i18n.detectLanguage());
|
||||
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
||||
var toLoad = languageList.length;
|
||||
|
||||
languageList.forEach(function(lang) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"*": {
|
||||
"ctrl-shift-p":"core:manage-palette",
|
||||
"alt-shift-p":"core:manage-palette",
|
||||
"ctrl-f": "core:search",
|
||||
"ctrl-shift-f": "core:list-flows",
|
||||
"ctrl-=": "core:zoom-in",
|
||||
@@ -8,6 +8,7 @@
|
||||
"ctrl-0": "core:zoom-reset",
|
||||
"ctrl-enter": "core:confirm-edit-tray",
|
||||
"ctrl-escape": "core:cancel-edit-tray",
|
||||
"ctrl-d": "core:deploy-flows",
|
||||
"ctrl-g i": "core:show-info-tab",
|
||||
"ctrl-g d": "core:show-debug-tab",
|
||||
"ctrl-g c": "core:show-config-tab",
|
||||
@@ -17,17 +18,20 @@
|
||||
"ctrl-space": "core:toggle-sidebar",
|
||||
"ctrl-p": "core:toggle-palette",
|
||||
"ctrl-,": "core:show-user-settings",
|
||||
"ctrl-alt-l": "core:clear-debug-messages",
|
||||
"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",
|
||||
"ctrl-shift-l": "core:show-event-log"
|
||||
"ctrl-shift-l": "core:show-event-log",
|
||||
"ctrl-shift-p":"core:show-action-list"
|
||||
},
|
||||
"red-ui-sidebar-node-config": {
|
||||
"backspace": "core:delete-config-selection",
|
||||
"delete": "core:delete-config-selection",
|
||||
"ctrl-a": "core:select-all-config-nodes",
|
||||
"ctrl-z": "core:undo"
|
||||
"ctrl-z": "core:undo",
|
||||
"ctrl-y": "core:redo"
|
||||
},
|
||||
"red-ui-workspace": {
|
||||
"backspace": "core:delete-selection",
|
||||
@@ -37,6 +41,7 @@
|
||||
"ctrl-x": "core:cut-selection-to-internal-clipboard",
|
||||
"ctrl-v": "core:paste-from-internal-clipboard",
|
||||
"ctrl-z": "core:undo",
|
||||
"ctrl-y": "core:redo",
|
||||
"ctrl-a": "core:select-all-nodes",
|
||||
"shift-?": "core:show-help",
|
||||
"up": "core:move-selection-up",
|
||||
|
@@ -17,6 +17,8 @@ RED.nodes = (function() {
|
||||
|
||||
var node_defs = {};
|
||||
var nodes = [];
|
||||
var nodeTabMap = {};
|
||||
|
||||
var configNodes = {};
|
||||
var links = [];
|
||||
var defaultWorkspace;
|
||||
@@ -213,6 +215,11 @@ RED.nodes = (function() {
|
||||
n.i = nextId+1;
|
||||
}
|
||||
nodes.push(n);
|
||||
if (nodeTabMap[n.z]) {
|
||||
nodeTabMap[n.z][n.id] = n;
|
||||
} else {
|
||||
console.warn("Node added to unknown tab/subflow:",n);
|
||||
}
|
||||
}
|
||||
RED.events.emit('nodes:add',n);
|
||||
}
|
||||
@@ -246,6 +253,9 @@ RED.nodes = (function() {
|
||||
node = getNode(id);
|
||||
if (node) {
|
||||
nodes.splice(nodes.indexOf(node),1);
|
||||
if (nodeTabMap[node.z]) {
|
||||
delete nodeTabMap[node.z][node.id];
|
||||
}
|
||||
removedLinks = links.filter(function(l) { return (l.source === node) || (l.target === node); });
|
||||
removedLinks.forEach(function(l) {links.splice(links.indexOf(l), 1); });
|
||||
var updatedConfigNode = false;
|
||||
@@ -291,6 +301,17 @@ RED.nodes = (function() {
|
||||
return {links:removedLinks,nodes:removedNodes};
|
||||
}
|
||||
|
||||
function moveNodeToTab(node, z) {
|
||||
if (nodeTabMap[node.z]) {
|
||||
delete nodeTabMap[node.z][node.id];
|
||||
}
|
||||
if (!nodeTabMap[z]) {
|
||||
nodeTabMap[z] = {};
|
||||
}
|
||||
nodeTabMap[z][node.id] = node;
|
||||
node.z = z;
|
||||
}
|
||||
|
||||
function removeLink(l) {
|
||||
var index = links.indexOf(l);
|
||||
if (index != -1) {
|
||||
@@ -300,6 +321,8 @@ RED.nodes = (function() {
|
||||
|
||||
function addWorkspace(ws,targetIndex) {
|
||||
workspaces[ws.id] = ws;
|
||||
nodeTabMap[ws.id] = {};
|
||||
|
||||
ws._def = RED.nodes.getType('tab');
|
||||
if (targetIndex === undefined) {
|
||||
workspacesOrder.push(ws.id);
|
||||
@@ -312,6 +335,7 @@ RED.nodes = (function() {
|
||||
}
|
||||
function removeWorkspace(id) {
|
||||
delete workspaces[id];
|
||||
delete nodeTabMap[id];
|
||||
workspacesOrder.splice(workspacesOrder.indexOf(id),1);
|
||||
|
||||
var removedNodes = [];
|
||||
@@ -357,30 +381,32 @@ RED.nodes = (function() {
|
||||
sf.name = subflowName;
|
||||
}
|
||||
subflows[sf.id] = sf;
|
||||
nodeTabMap[sf.id] = {};
|
||||
|
||||
RED.nodes.registerType("subflow:"+sf.id, {
|
||||
defaults:{
|
||||
name:{value:""},
|
||||
env:{value:[]}
|
||||
},
|
||||
icon: function() { return sf.icon||"subflow.png" },
|
||||
icon: function() { return sf.icon||"subflow.svg" },
|
||||
category: sf.category || "subflows",
|
||||
inputs: sf.in.length,
|
||||
outputs: sf.out.length,
|
||||
color: "#da9",
|
||||
color: sf.color || "#da9",
|
||||
label: function() { return this.name||RED.nodes.subflow(sf.id).name },
|
||||
labelStyle: function() { return this.name?"red-ui-flow-node-label-italic":""; },
|
||||
paletteLabel: function() { return RED.nodes.subflow(sf.id).name },
|
||||
inputLabels: function(i) { return sf.inputLabels?sf.inputLabels[i]:null },
|
||||
outputLabels: function(i) { return sf.outputLabels?sf.outputLabels[i]:null },
|
||||
oneditresize: function(size) {
|
||||
var rows = $("#dialog-form>div:not(.node-input-env-container-row)");
|
||||
// var rows = $(".dialog-form>div:not(.node-input-env-container-row)");
|
||||
var height = size.height;
|
||||
for (var i=0; i<rows.size(); i++) {
|
||||
height -= $(rows[i]).outerHeight(true);
|
||||
}
|
||||
var editorRow = $("#dialog-form>div.node-input-env-container-row");
|
||||
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
|
||||
$("#node-input-env-container").editableList('height',height-80);
|
||||
// for (var i=0; i<rows.size(); i++) {
|
||||
// height -= $(rows[i]).outerHeight(true);
|
||||
// }
|
||||
// var editorRow = $("#dialog-form>div.node-input-env-container-row");
|
||||
// height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
|
||||
$("ol.red-ui-editor-subflow-env-list").editableList('height',height);
|
||||
},
|
||||
set:{
|
||||
module: "node-red"
|
||||
@@ -393,6 +419,7 @@ RED.nodes = (function() {
|
||||
}
|
||||
function removeSubflow(sf) {
|
||||
delete subflows[sf.id];
|
||||
delete nodeTabMap[sf.id];
|
||||
registry.removeNodeType("subflow:"+sf.id);
|
||||
}
|
||||
|
||||
@@ -463,7 +490,9 @@ RED.nodes = (function() {
|
||||
node.id = n.id;
|
||||
node.type = n.type;
|
||||
node.z = n.z;
|
||||
|
||||
if (n.d === true) {
|
||||
node.d = true;
|
||||
}
|
||||
if (node.type == "unknown") {
|
||||
for (var p in n._orig) {
|
||||
if (n._orig.hasOwnProperty(p)) {
|
||||
@@ -549,6 +578,7 @@ RED.nodes = (function() {
|
||||
node.in = [];
|
||||
node.out = [];
|
||||
node.env = n.env;
|
||||
node.color = n.color;
|
||||
|
||||
n.in.forEach(function(p) {
|
||||
var nIn = {x:p.x,y:p.y,wires:[]};
|
||||
@@ -581,7 +611,7 @@ RED.nodes = (function() {
|
||||
node.outputLabels = n.outputLabels.slice();
|
||||
}
|
||||
if (n.icon) {
|
||||
if (n.icon !== "node-red/subflow.png") {
|
||||
if (n.icon !== "node-red/subflow.svg") {
|
||||
node.icon = n.icon;
|
||||
}
|
||||
}
|
||||
@@ -967,6 +997,9 @@ RED.nodes = (function() {
|
||||
users:[],
|
||||
_config:{}
|
||||
};
|
||||
if (n.hasOwnProperty('d')) {
|
||||
configNode.d = n.d;
|
||||
}
|
||||
for (d in def.defaults) {
|
||||
if (def.defaults.hasOwnProperty(d)) {
|
||||
configNode[d] = n[d];
|
||||
@@ -1016,6 +1049,9 @@ RED.nodes = (function() {
|
||||
if (n.hasOwnProperty('l')) {
|
||||
node.l = n.l;
|
||||
}
|
||||
if (n.hasOwnProperty('d')) {
|
||||
node.d = n.d;
|
||||
}
|
||||
if (createNewIds) {
|
||||
if (subflow_blacklist[n.z]) {
|
||||
continue;
|
||||
@@ -1258,12 +1294,13 @@ RED.nodes = (function() {
|
||||
// TODO: supports filter.z|type
|
||||
function filterNodes(filter) {
|
||||
var result = [];
|
||||
var searchSet = nodes;
|
||||
if (filter.hasOwnProperty("z") && Object.hasOwnProperty("values") && nodeTabMap.hasOwnProperty(filter.z) ) {
|
||||
searchSet = Object.values(nodeTabMap[filter.z]);
|
||||
}
|
||||
|
||||
for (var n=0;n<nodes.length;n++) {
|
||||
var node = nodes[n];
|
||||
if (filter.hasOwnProperty("z") && node.z !== filter.z) {
|
||||
continue;
|
||||
}
|
||||
for (var n=0;n<searchSet.length;n++) {
|
||||
var node = searchSet[n];
|
||||
if (filter.hasOwnProperty("type") && node.type !== filter.type) {
|
||||
continue;
|
||||
}
|
||||
@@ -1331,6 +1368,7 @@ RED.nodes = (function() {
|
||||
function clear() {
|
||||
nodes = [];
|
||||
links = [];
|
||||
nodeTabMap = {};
|
||||
configNodes = {};
|
||||
workspacesOrder = [];
|
||||
var subflowIds = Object.keys(subflows);
|
||||
@@ -1440,6 +1478,8 @@ RED.nodes = (function() {
|
||||
remove: removeNode,
|
||||
clear: clear,
|
||||
|
||||
moveNodeToTab: moveNodeToTab,
|
||||
|
||||
addLink: addLink,
|
||||
removeLink: removeLink,
|
||||
|
||||
|
@@ -107,9 +107,12 @@ var RED = (function() {
|
||||
}
|
||||
|
||||
function loadNodes() {
|
||||
var lang = localStorage.getItem("editor-language")||i18n.detectLanguage();
|
||||
|
||||
$.ajax({
|
||||
headers: {
|
||||
"Accept":"text/html"
|
||||
"Accept":"text/html",
|
||||
"Accept-Language": lang
|
||||
},
|
||||
cache: false,
|
||||
url: 'nodes',
|
||||
@@ -448,6 +451,7 @@ var RED = (function() {
|
||||
{id:"menu-item-palette",label:RED._("menu.label.palette.show"),toggle:true,onselect:"core:toggle-palette", selected: true},
|
||||
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:"core:toggle-sidebar", selected: true},
|
||||
{id:"menu-item-event-log",label:RED._("eventLog.title"),onselect:"core:show-event-log"},
|
||||
{id:"menu-item-action-list",label:RED._("keyboard.actionList"),onselect:"core:show-action-list"},
|
||||
null
|
||||
]});
|
||||
menuOptions.push(null);
|
||||
@@ -518,6 +522,7 @@ var RED = (function() {
|
||||
RED.subflow.init();
|
||||
RED.clipboard.init();
|
||||
RED.search.init();
|
||||
RED.actionList.init();
|
||||
RED.editor.init();
|
||||
RED.diff.init();
|
||||
|
||||
|
230
packages/node_modules/@node-red/editor-client/src/js/ui/actionList.js
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* 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.actionList = (function() {
|
||||
|
||||
var disabled = false;
|
||||
var dialog = null;
|
||||
var searchInput;
|
||||
var searchResults;
|
||||
var selected = -1;
|
||||
var visible = false;
|
||||
|
||||
var filterTerm = "";
|
||||
var filterTerms = [];
|
||||
var previousActiveElement;
|
||||
|
||||
function ensureSelectedIsVisible() {
|
||||
var selectedEntry = searchResults.find("li.selected");
|
||||
if (selectedEntry.length === 1) {
|
||||
var scrollWindow = searchResults.parent();
|
||||
var scrollHeight = scrollWindow.height();
|
||||
var scrollOffset = scrollWindow.scrollTop();
|
||||
var y = selectedEntry.position().top;
|
||||
var h = selectedEntry.height();
|
||||
if (y+h > scrollHeight) {
|
||||
scrollWindow.animate({scrollTop: '-='+(scrollHeight-(y+h)-10)},50);
|
||||
} else if (y<0) {
|
||||
scrollWindow.animate({scrollTop: '+='+(y-10)},50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createDialog() {
|
||||
dialog = $("<div>",{id:"red-ui-actionList",class:"red-ui-search"}).appendTo("#red-ui-main-container");
|
||||
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
||||
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
|
||||
change: function() {
|
||||
filterTerm = $(this).val().trim();
|
||||
filterTerms = filterTerm.split(" ");
|
||||
searchResults.editableList('filter');
|
||||
searchResults.find("li.selected").removeClass("selected");
|
||||
var children = searchResults.children(":visible");
|
||||
if (children.length) {
|
||||
$(children[0]).addClass('selected');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
searchInput.on('keydown',function(evt) {
|
||||
var selectedChild;
|
||||
if (evt.keyCode === 40) {
|
||||
// Down
|
||||
selectedChild = searchResults.find("li.selected");
|
||||
if (!selectedChild.length) {
|
||||
var children = searchResults.children(":visible");
|
||||
if (children.length) {
|
||||
$(children[0]).addClass('selected');
|
||||
}
|
||||
} else {
|
||||
var nextChild = selectedChild.nextAll(":visible").first();
|
||||
if (nextChild.length) {
|
||||
selectedChild.removeClass('selected');
|
||||
nextChild.addClass('selected');
|
||||
}
|
||||
}
|
||||
ensureSelectedIsVisible();
|
||||
evt.preventDefault();
|
||||
} else if (evt.keyCode === 38) {
|
||||
// Up
|
||||
selectedChild = searchResults.find("li.selected");
|
||||
var nextChild = selectedChild.prevAll(":visible").first();
|
||||
if (nextChild.length) {
|
||||
selectedChild.removeClass('selected');
|
||||
nextChild.addClass('selected');
|
||||
}
|
||||
ensureSelectedIsVisible();
|
||||
evt.preventDefault();
|
||||
} else if (evt.keyCode === 13) {
|
||||
// Enter
|
||||
selectedChild = searchResults.find("li.selected");
|
||||
selectCommand(searchResults.editableList('getItem',selectedChild));
|
||||
}
|
||||
});
|
||||
searchInput.i18n();
|
||||
|
||||
var searchResultsDiv = $("<div>",{class:"red-ui-search-results-container"}).appendTo(dialog);
|
||||
searchResults = $('<ol>',{style:"position: absolute;top: 5px;bottom: 5px;left: 5px;right: 5px;"}).appendTo(searchResultsDiv).editableList({
|
||||
addButton: false,
|
||||
addItem: function(container,i,action) {
|
||||
if (action.id === undefined) {
|
||||
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
|
||||
} else {
|
||||
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
|
||||
var contentDiv = $('<div>',{class:"red-ui-search-result-action"}).appendTo(div);
|
||||
|
||||
|
||||
$('<div>').text(action.label).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);
|
||||
if (action.key) {
|
||||
$('<div>',{class:"red-ui-search-result-action-key"}).html(RED.keyboard.formatKey(action.key)).appendTo(contentDiv);
|
||||
}
|
||||
div.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
selectCommand(action);
|
||||
});
|
||||
}
|
||||
},
|
||||
scrollOnAdd: false,
|
||||
filter: function(item) {
|
||||
if (filterTerm !== "") {
|
||||
var pos=0;
|
||||
for (var i=0;i<filterTerms.length;i++) {
|
||||
var j = item._label.indexOf(filterTerms[i],pos);
|
||||
if (j > -1) {
|
||||
pos = j;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function selectCommand(command) {
|
||||
hide();
|
||||
if (command) {
|
||||
RED.actions.invoke(command.id);
|
||||
}
|
||||
}
|
||||
|
||||
function show(v) {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (!visible) {
|
||||
previousActiveElement = document.activeElement;
|
||||
RED.keyboard.add("*","escape",function(){hide()});
|
||||
$("#red-ui-header-shade").show();
|
||||
$("#red-ui-editor-shade").show();
|
||||
$("#red-ui-palette-shade").show();
|
||||
$("#red-ui-sidebar-shade").show();
|
||||
$("#red-ui-sidebar-separator").hide();
|
||||
if (dialog === null) {
|
||||
createDialog();
|
||||
}
|
||||
dialog.slideDown(300);
|
||||
searchInput.searchBox('value',v)
|
||||
searchResults.editableList('empty');
|
||||
results = [];
|
||||
var actions = RED.actions.list();
|
||||
actions.sort(function(A,B) {
|
||||
return A.id.localeCompare(B.id);
|
||||
});
|
||||
actions.forEach(function(action) {
|
||||
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
|
||||
action._label = action.label.toLowerCase();
|
||||
searchResults.editableList('addItem',action)
|
||||
})
|
||||
RED.events.emit("actionList:open");
|
||||
visible = true;
|
||||
}
|
||||
searchInput.trigger("focus");
|
||||
var children = searchResults.children(":visible");
|
||||
if (children.length) {
|
||||
$(children[0]).addClass('selected');
|
||||
}
|
||||
}
|
||||
|
||||
function hide() {
|
||||
if (visible) {
|
||||
RED.keyboard.remove("escape");
|
||||
visible = false;
|
||||
$("#red-ui-header-shade").hide();
|
||||
$("#red-ui-editor-shade").hide();
|
||||
$("#red-ui-palette-shade").hide();
|
||||
$("#red-ui-sidebar-shade").hide();
|
||||
$("#red-ui-sidebar-separator").show();
|
||||
if (dialog !== null) {
|
||||
dialog.slideUp(200,function() {
|
||||
searchInput.searchBox('value','');
|
||||
});
|
||||
}
|
||||
RED.events.emit("actionList:close");
|
||||
if (previousActiveElement) {
|
||||
$(previousActiveElement).trigger("focus");
|
||||
previousActiveElement = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
RED.actions.add("core:show-action-list",show);
|
||||
|
||||
RED.events.on("editor:open",function() { disabled = true; });
|
||||
RED.events.on("editor:close",function() { disabled = false; });
|
||||
RED.events.on("search:open",function() { disabled = true; });
|
||||
RED.events.on("search:close",function() { disabled = false; });
|
||||
RED.events.on("type-search:open",function() { disabled = true; });
|
||||
RED.events.on("type-search:close",function() { disabled = false; });
|
||||
|
||||
$("#red-ui-header-shade").on('mousedown',hide);
|
||||
$("#red-ui-editor-shade").on('mousedown',hide);
|
||||
$("#red-ui-palette-shade").on('mousedown',hide);
|
||||
$("#red-ui-sidebar-shade").on('mousedown',hide);
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
show: show,
|
||||
hide: hide
|
||||
};
|
||||
|
||||
})();
|
@@ -59,7 +59,7 @@ RED.clipboard = (function() {
|
||||
element.setAttribute('download', "flows.json");
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
element.trigger("click");
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
@@ -396,14 +396,6 @@ RED.clipboard = (function() {
|
||||
label: RED._("library.types.examples")
|
||||
});
|
||||
|
||||
tabs.activateTab("red-ui-clipboard-dialog-import-tab-"+mode);
|
||||
if (mode === 'clipboard') {
|
||||
setTimeout(function() {
|
||||
$("#red-ui-clipboard-dialog-import-text").trigger("focus");
|
||||
},100)
|
||||
}
|
||||
|
||||
|
||||
$("#red-ui-clipboard-dialog-tab-library-name").on("keyup", validateExportFilename);
|
||||
$("#red-ui-clipboard-dialog-tab-library-name").on('paste',function() { setTimeout(validateExportFilename,10)});
|
||||
$("#red-ui-clipboard-dialog-export").button("enable");
|
||||
@@ -475,6 +467,14 @@ RED.clipboard = (function() {
|
||||
$("#red-ui-clipboard-dialog-import-file-upload").trigger("click");
|
||||
})
|
||||
|
||||
tabs.activateTab("red-ui-clipboard-dialog-import-tab-"+mode);
|
||||
if (mode === 'clipboard') {
|
||||
setTimeout(function() {
|
||||
$("#red-ui-clipboard-dialog-import-text").trigger("focus");
|
||||
},100)
|
||||
}
|
||||
|
||||
|
||||
dialog.dialog("option","title",RED._("clipboard.importNodes")).dialog("open");
|
||||
popover = RED.popover.create({
|
||||
target: $("#red-ui-clipboard-dialog-import-text"),
|
||||
@@ -521,8 +521,6 @@ RED.clipboard = (function() {
|
||||
label: RED._("library.library")
|
||||
});
|
||||
|
||||
tabs.activateTab("red-ui-clipboard-dialog-export-tab-"+mode);
|
||||
|
||||
$("#red-ui-clipboard-dialog-tab-library-name").on("keyup", validateExportFilename);
|
||||
$("#red-ui-clipboard-dialog-tab-library-name").on('paste',function() { setTimeout(validateExportFilename,10)});
|
||||
$("#red-ui-clipboard-dialog-export").button("enable");
|
||||
@@ -638,6 +636,7 @@ RED.clipboard = (function() {
|
||||
} else {
|
||||
$("#red-ui-clipboard-dialog-export-fmt-mini").trigger("click");
|
||||
}
|
||||
tabs.activateTab("red-ui-clipboard-dialog-export-tab-"+mode);
|
||||
dialog.dialog("option","title",RED._("clipboard.exportNodes")).dialog( "open" );
|
||||
|
||||
$("#red-ui-clipboard-dialog-export-text").trigger("focus");
|
||||
@@ -655,7 +654,7 @@ RED.clipboard = (function() {
|
||||
// icon: 'fa fa-hdd-o',
|
||||
// label: RED._("library.types.examples"),
|
||||
// path: "",
|
||||
// children: function(item,done) {
|
||||
// children: function(done,item) {
|
||||
// RED.library.loadLibraryFolder("_examples_","flows","",function(children) {
|
||||
// item.children = children;
|
||||
// done(children);
|
||||
@@ -670,13 +669,14 @@ RED.clipboard = (function() {
|
||||
label: label,
|
||||
path: "",
|
||||
expanded: true,
|
||||
children: function(item,done) {
|
||||
children: function(done, item) {
|
||||
RED.library.loadLibraryFolder(library,"flows","",function(children) {
|
||||
item.children = children;
|
||||
done(children);
|
||||
})
|
||||
}
|
||||
}]);
|
||||
}], true);
|
||||
|
||||
}
|
||||
|
||||
function hideDropTarget() {
|
||||
@@ -730,17 +730,20 @@ RED.clipboard = (function() {
|
||||
init: function() {
|
||||
setupDialogs();
|
||||
|
||||
$('<input type="text" id="red-ui-clipboard-hidden">').appendTo("#red-ui-editor");
|
||||
$('<input type="text" id="red-ui-clipboard-hidden" tabIndex="-1">').appendTo("#red-ui-editor");
|
||||
|
||||
RED.actions.add("core:show-export-dialog",exportNodes);
|
||||
RED.actions.add("core:show-import-dialog",importNodes);
|
||||
|
||||
RED.actions.add("core:library-export",function() { exportNodes('library') });
|
||||
RED.actions.add("core:show-library-export-dialog",function() { exportNodes('library') });
|
||||
RED.actions.add("core:show-library-import-dialog",function() { importNodes('library') });
|
||||
|
||||
RED.events.on("editor:open",function() { disabled = true; });
|
||||
RED.events.on("editor:close",function() { disabled = false; });
|
||||
RED.events.on("search:open",function() { disabled = true; });
|
||||
RED.events.on("search:close",function() { disabled = false; });
|
||||
RED.events.on("actionList:open",function() { disabled = true; });
|
||||
RED.events.on("actionList:close",function() { disabled = false; });
|
||||
RED.events.on("type-search:open",function() { disabled = true; });
|
||||
RED.events.on("type-search:close",function() { disabled = false; });
|
||||
|
||||
|
@@ -32,7 +32,10 @@
|
||||
* - scrollOnAdd : boolean - whether to scroll to newly added items
|
||||
* methods:
|
||||
* - addItem(itemData)
|
||||
* - insertItemAt : function(data,index) - add an item at the specified index
|
||||
* - removeItem(itemData)
|
||||
* - getItemAt(index)
|
||||
* - indexOf(itemData)
|
||||
* - width(width)
|
||||
* - height(height)
|
||||
* - items()
|
||||
@@ -185,6 +188,11 @@
|
||||
}
|
||||
},
|
||||
_destroy: function() {
|
||||
if (this.topContainer) {
|
||||
var tc = this.topContainer;
|
||||
delete this.topContainer;
|
||||
tc.remove();
|
||||
}
|
||||
},
|
||||
_refreshFilter: function() {
|
||||
var that = this;
|
||||
@@ -230,7 +238,24 @@
|
||||
this.uiHeight = desiredHeight;
|
||||
this._resize();
|
||||
},
|
||||
addItem: function(data) {
|
||||
getItemAt: function(index) {
|
||||
var items = this.items();
|
||||
if (index >= 0 && index < items.length) {
|
||||
return $(items[index]).data('data');
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
indexOf: function(data) {
|
||||
var items = this.items();
|
||||
for (var i=0;i<items.length;i++) {
|
||||
if ($(items[i]).data('data') === data) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
},
|
||||
insertItemAt: function(data,index) {
|
||||
var that = this;
|
||||
data = data || {};
|
||||
var li = $('<li>');
|
||||
@@ -248,7 +273,13 @@
|
||||
});
|
||||
}
|
||||
if (!added) {
|
||||
li.appendTo(this.element);
|
||||
if (index <= 0) {
|
||||
li.prependTo(this.element);
|
||||
} else if (index > that.element.children().length-1) {
|
||||
li.appendTo(this.element);
|
||||
} else {
|
||||
li.insertBefore(this.element.children().eq(index));
|
||||
}
|
||||
}
|
||||
var row = $('<div/>').addClass("red-ui-editableList-item-content").appendTo(li);
|
||||
row.data('data',data);
|
||||
@@ -293,6 +324,9 @@
|
||||
},0);
|
||||
}
|
||||
},
|
||||
addItem: function(data) {
|
||||
this.insertItemAt(data,this.element.children().length)
|
||||
},
|
||||
addItems: function(items) {
|
||||
for (var i=0; i<items.length;i++) {
|
||||
this.addItem(items[i]);
|
||||
@@ -312,6 +346,7 @@
|
||||
},
|
||||
empty: function() {
|
||||
this.element.empty();
|
||||
this.uiContainer.scrollTop(0);
|
||||
},
|
||||
filter: function(filter) {
|
||||
if (filter !== undefined) {
|
||||
@@ -335,6 +370,14 @@
|
||||
if (items.length > 0) {
|
||||
this.uiContainer.scrollTop(this.uiContainer.scrollTop()+items.position().top)
|
||||
}
|
||||
},
|
||||
getItem: function(li) {
|
||||
var el = li.find(".red-ui-editableList-item-content");
|
||||
if (el.length) {
|
||||
return el.data('data');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
@@ -71,7 +71,7 @@ RED.menu = (function() {
|
||||
|
||||
}
|
||||
if (opt.icon !== undefined) {
|
||||
if (/\.png/.test(opt.icon)) {
|
||||
if (/\.(png|svg)/.test(opt.icon)) {
|
||||
linkContent += '<img src="'+opt.icon+'"/> ';
|
||||
} else {
|
||||
linkContent += '<i class="'+(opt.icon?opt.icon:'" style="display: inline-block;"')+'"></i> ';
|
||||
@@ -98,21 +98,10 @@ RED.menu = (function() {
|
||||
return;
|
||||
}
|
||||
if (opt.toggle) {
|
||||
var selected = isSelected(opt.id);
|
||||
if (typeof opt.toggle === "string") {
|
||||
if (!selected) {
|
||||
for (var m in menuItems) {
|
||||
if (menuItems.hasOwnProperty(m)) {
|
||||
var mi = menuItems[m];
|
||||
if (mi.id != opt.id && opt.toggle == mi.toggle) {
|
||||
setSelected(mi.id,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
setSelected(opt.id,true);
|
||||
}
|
||||
if (opt.toggle === true) {
|
||||
setSelected(opt.id, !isSelected(opt.id));
|
||||
} else {
|
||||
setSelected(opt.id, !selected);
|
||||
setSelected(opt.id, true);
|
||||
}
|
||||
} else {
|
||||
triggerAction(opt.id);
|
||||
@@ -209,8 +198,9 @@ RED.menu = (function() {
|
||||
}
|
||||
|
||||
function setSelected(id,state) {
|
||||
var alreadySet = false;
|
||||
if (isSelected(id) == state) {
|
||||
return;
|
||||
alreadySet = true;
|
||||
}
|
||||
var opt = menuItems[id];
|
||||
if (state) {
|
||||
@@ -218,10 +208,26 @@ RED.menu = (function() {
|
||||
} else {
|
||||
$("#"+id).removeClass("active");
|
||||
}
|
||||
if (opt && opt.onselect) {
|
||||
triggerAction(opt.id,state);
|
||||
if (opt) {
|
||||
if (opt.toggle && typeof opt.toggle === "string") {
|
||||
if (state) {
|
||||
for (var m in menuItems) {
|
||||
if (menuItems.hasOwnProperty(m)) {
|
||||
var mi = menuItems[m];
|
||||
if (mi.id != opt.id && opt.toggle == mi.toggle) {
|
||||
setSelected(mi.id,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!alreadySet && opt.onselect) {
|
||||
triggerAction(opt.id,state);
|
||||
}
|
||||
}
|
||||
if (!opt.local && !alreadySet) {
|
||||
RED.settings.set(opt.setting||("menu-"+opt.id), state);
|
||||
}
|
||||
RED.settings.set(opt.setting||("menu-"+opt.id), state);
|
||||
}
|
||||
|
||||
function toggleSelected(id) {
|
||||
|
@@ -52,6 +52,11 @@ RED.popover = (function() {
|
||||
|
||||
var openPopup = function(instant) {
|
||||
if (active) {
|
||||
var existingPopover = target.data("red-ui-popover");
|
||||
if (options.tooltip && existingPopover) {
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
div = $('<div class="red-ui-popover"></div>');
|
||||
if (size !== "default") {
|
||||
div.addClass("red-ui-popover-size-"+size);
|
||||
@@ -122,7 +127,10 @@ RED.popover = (function() {
|
||||
}
|
||||
}
|
||||
div.addClass('red-ui-popover-'+d).css({top: top, left: left});
|
||||
|
||||
if (existingPopover) {
|
||||
existingPopover.close(true);
|
||||
}
|
||||
target.data("red-ui-popover",res)
|
||||
if (instant) {
|
||||
div.show();
|
||||
} else {
|
||||
@@ -142,6 +150,7 @@ RED.popover = (function() {
|
||||
});
|
||||
}
|
||||
div = null;
|
||||
target.removeData("red-ui-popover",res)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,6 +245,7 @@ RED.popover = (function() {
|
||||
}
|
||||
}
|
||||
return RED.popover.create({
|
||||
tooltip: true,
|
||||
target:target,
|
||||
trigger: "hover",
|
||||
size: "small",
|
||||
@@ -243,6 +253,71 @@ RED.popover = (function() {
|
||||
content: label,
|
||||
delay: { show: 750, hide: 50 }
|
||||
});
|
||||
},
|
||||
panel: function(content) {
|
||||
var panel = $('<div class="red-ui-editor-dialog red-ui-popover-panel"></div>');
|
||||
panel.css({ display: "none" });
|
||||
panel.appendTo(document.body);
|
||||
content.appendTo(panel);
|
||||
var closeCallback;
|
||||
|
||||
function hide() {
|
||||
$(document).off("mousedown.red-ui-popover-panel-close");
|
||||
panel.hide();
|
||||
panel.css({
|
||||
height: "auto"
|
||||
});
|
||||
panel.remove();
|
||||
}
|
||||
function show(options) {
|
||||
var closeCallback = options.onclose;
|
||||
var target = options.target;
|
||||
var align = options.align || "left";
|
||||
|
||||
var pos = target.offset();
|
||||
var targetWidth = target.width();
|
||||
var targetHeight = target.height();
|
||||
var panelHeight = panel.height();
|
||||
var panelWidth = panel.width();
|
||||
|
||||
var top = (targetHeight+pos.top);
|
||||
if (top+panelHeight > $(window).height()) {
|
||||
top -= (top+panelHeight)-$(window).height() + 5;
|
||||
}
|
||||
if (top < 0) {
|
||||
panelHeight.height(panelHeight+top)
|
||||
top = 0;
|
||||
}
|
||||
if (align === "left") {
|
||||
panel.css({
|
||||
top: top+"px",
|
||||
left: (pos.left)+"px",
|
||||
});
|
||||
} else if(align === "right") {
|
||||
panel.css({
|
||||
top: top+"px",
|
||||
left: (pos.left-panelWidth)+"px",
|
||||
});
|
||||
}
|
||||
panel.slideDown(100);
|
||||
|
||||
$(document).on("mousedown.red-ui-popover-panel-close", function(event) {
|
||||
if(!$(event.target).closest(panel).length && !$(event.target).closest(".red-ui-editor-dialog").length) {
|
||||
if (closeCallback) {
|
||||
closeCallback();
|
||||
}
|
||||
hide();
|
||||
}
|
||||
// if ($(event.target).closest(target).length) {
|
||||
// event.preventDefault();
|
||||
// }
|
||||
})
|
||||
}
|
||||
return {
|
||||
container: panel,
|
||||
show:show,
|
||||
hide:hide
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -87,6 +87,7 @@
|
||||
that._trigger("change");
|
||||
},this.options.delay);
|
||||
} else {
|
||||
this.lastSent = this.element.val();
|
||||
this._trigger("change");
|
||||
}
|
||||
}
|
||||
|
@@ -42,12 +42,11 @@
|
||||
var enabledLabel = this.options.enabledLabel || RED._("editor:workspace.enabled");
|
||||
var disabledLabel = this.options.disabledLabel || RED._("editor:workspace.disabled");
|
||||
|
||||
this.element.addClass("red-ui-toggleButton");
|
||||
this.element.css("display","none");
|
||||
this.element.on("focus", function() {
|
||||
that.button.focus();
|
||||
});
|
||||
this.button = $('<button type="button" class="'+baseClass+' toggle single"><i class="fa"></i> <span></span></button>');
|
||||
this.button = $('<button type="button" class="red-ui-toggleButton '+baseClass+' toggle single"><i class="fa"></i> <span></span></button>');
|
||||
if (this.options.class) {
|
||||
this.button.addClass(this.options.class)
|
||||
}
|
||||
|
@@ -20,6 +20,10 @@
|
||||
* - data : array - initial items to display in tree
|
||||
* - multi : boolean - if true, .selected will return an array of results
|
||||
* otherwise, returns the first selected item
|
||||
* - sortable: boolean/string - TODO: see editableList
|
||||
* - rootSortable: boolean - if 'sortable' is set, then setting this to
|
||||
* false, prevents items being sorted to the
|
||||
* top level of the tree
|
||||
*
|
||||
* methods:
|
||||
* - data(items) - clears existing items and replaces with new data
|
||||
@@ -27,25 +31,57 @@
|
||||
* events:
|
||||
* - treelistselect : function(event, item) {}
|
||||
* - treelistconfirm : function(event,item) {}
|
||||
* - treelistchangeparent: function(event,item, oldParent, newParent) {}
|
||||
*
|
||||
* data:
|
||||
* [
|
||||
* {
|
||||
* label: 'Local', // label for the item
|
||||
* sublabel: 'Local', // a sub-label for the item
|
||||
* icon: 'fa fa-rocket', // (optional) icon for the item
|
||||
* selected: true/false, // (optional) if present, display checkbox accordingly
|
||||
* children: [] | function(item,done) // (optional) an array of child items, or a function
|
||||
* children: [] | function(done,item) // (optional) an array of child items, or a function
|
||||
* // that will call the `done` callback with an array
|
||||
* // of child items
|
||||
* expanded: true/false, // show the child items by default
|
||||
* deferBuild: true/false, // don't build any ui elements for the item's children
|
||||
* until it is expanded by the user.
|
||||
* element: // custom dom element to use for the item - ignored if `label` is set
|
||||
* }
|
||||
* ]
|
||||
*
|
||||
*
|
||||
*
|
||||
* var treeList = $("<div>").css({width: "100%", height: "100%"}).treeList({data:[...]})
|
||||
* treeList.on('treelistselect', function(e,item) { console.log(item)})
|
||||
* treeList.treeList('data',[ ... ] )
|
||||
*
|
||||
*
|
||||
* After `data` has been added to the tree, each item is augmented the following
|
||||
* properties and functions:
|
||||
*
|
||||
* item.parent - set to the parent item
|
||||
* item.treeList.container
|
||||
* item.treeList.label - the label element for the item
|
||||
* item.treeList.depth - the depth in the tree (0 == root)
|
||||
* item.treeList.parentList - the editableList instance this item is in
|
||||
* item.treeList.remove() - removes the item from the tree
|
||||
* item.treeList.makeLeaf(detachChildElements) - turns an element with children into a leaf node,
|
||||
* removing the UI decoration etc.
|
||||
* detachChildElements - any children with custom
|
||||
* elements will be detached rather than removed
|
||||
* so jQuery event handlers are preserved in case
|
||||
* the child elements need to be reattached later
|
||||
* item.treeList.makeParent(children) - turns an element into a parent node, adding the necessary
|
||||
* UI decoration.
|
||||
* item.treeList.insertChildAt(newItem,position,select) - adds a child item an the specified position.
|
||||
* Optionally selects the item after adding.
|
||||
* item.treeList.addChild(newItem,select) - appends a child item.
|
||||
* Optionally selects the item after adding.
|
||||
* item.treeList.expand(done) - expands the parent item to show children. Optional 'done' callback.
|
||||
* item.treeList.collapse() - collapse the parent item to hide children.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
$.widget( "nodered.treeList", {
|
||||
@@ -116,20 +152,30 @@
|
||||
});
|
||||
this._data = [];
|
||||
|
||||
this._topList = $('<ol>').css({
|
||||
this._topList = $('<ol class="red-ui-treeList-list">').css({
|
||||
position:'absolute',
|
||||
top: 0,
|
||||
left:0,
|
||||
right:0,
|
||||
bottom:0
|
||||
}).appendTo(wrapper).editableList({
|
||||
}).appendTo(wrapper);
|
||||
|
||||
var topListOptions = {
|
||||
addButton: false,
|
||||
scrollOnAdd: false,
|
||||
height: '100%',
|
||||
addItem: function(container,i,item) {
|
||||
that._addSubtree(that._topList,container,item,0);
|
||||
}
|
||||
})
|
||||
};
|
||||
if (this.options.rootSortable !== false && !!this.options.sortable) {
|
||||
topListOptions.sortable = this.options.sortable;
|
||||
topListOptions.connectWith = '.red-ui-treeList-sortable';
|
||||
this._topList.addClass('red-ui-treeList-sortable');
|
||||
}
|
||||
this._topList.editableList(topListOptions)
|
||||
|
||||
|
||||
if (this.options.data) {
|
||||
this.data(this.options.data);
|
||||
}
|
||||
@@ -171,23 +217,82 @@
|
||||
},
|
||||
_addChildren: function(container,parent,children,depth) {
|
||||
var that = this;
|
||||
var subtree = $('<ol>').appendTo(container).editableList({
|
||||
var subtree = $('<ol class="red-ui-treeList-list">').appendTo(container).editableList({
|
||||
connectWith: ".red-ui-treeList-sortable",
|
||||
sortable: that.options.sortable,
|
||||
addButton: false,
|
||||
scrollOnAdd: false,
|
||||
height: 'auto',
|
||||
addItem: function(container,i,item) {
|
||||
that._addSubtree(subtree,container,item,depth+1);
|
||||
},
|
||||
sortItems: function(data) {
|
||||
var children = [];
|
||||
var reparented = [];
|
||||
data.each(function() {
|
||||
var child = $(this).data('data');
|
||||
children.push(child);
|
||||
var evt = that._fixDepths(parent,child);
|
||||
if (evt) {
|
||||
reparented.push(evt);
|
||||
}
|
||||
})
|
||||
if (Array.isArray(parent.children)) {
|
||||
parent.children = children;
|
||||
}
|
||||
reparented.forEach(function(evt) {
|
||||
that._trigger("changeparent",null,evt);
|
||||
});
|
||||
that._trigger("sort",null,parent);
|
||||
}
|
||||
});
|
||||
if (!!that.options.sortable) {
|
||||
subtree.addClass('red-ui-treeList-sortable');
|
||||
}
|
||||
for (var i=0;i<children.length;i++) {
|
||||
children[i].parent = parent;
|
||||
subtree.editableList('addItem',children[i])
|
||||
}
|
||||
return subtree;
|
||||
},
|
||||
_fixDepths: function(parent,child) {
|
||||
// If child has just been moved into parent in the UI
|
||||
// this will fix up the internal data structures to match.
|
||||
// The calling function must take care of getting child
|
||||
// into the parent.children array. The rest is up to us.
|
||||
var that = this;
|
||||
var reparentedEvent = null;
|
||||
if (child.parent !== parent) {
|
||||
reparented = true;
|
||||
var oldParent = child.parent;
|
||||
child.parent = parent;
|
||||
reparentedEvent = {
|
||||
item: child,
|
||||
old: oldParent,
|
||||
}
|
||||
}
|
||||
if (child.depth !== parent.depth+1) {
|
||||
child.depth = parent.depth+1;
|
||||
var labelPaddingWidth = ((child.gutter?child.gutter.width()+2:0)+(child.depth*20));
|
||||
child.treeList.labelPadding.width(labelPaddingWidth+'px');
|
||||
if (child.element) {
|
||||
$(child.element).css({
|
||||
width: "calc(100% - "+(labelPaddingWidth+20+(child.icon?20:0))+"px)"
|
||||
})
|
||||
}
|
||||
// This corrects all child item depths
|
||||
if (child.children && Array.isArray(child.children)) {
|
||||
child.children.forEach(function(item) {
|
||||
that._fixDepths(child,item);
|
||||
})
|
||||
}
|
||||
}
|
||||
return reparentedEvent;
|
||||
},
|
||||
_addSubtree: function(parentList, container, item, depth) {
|
||||
var that = this;
|
||||
item.treeList = {};
|
||||
item.treeList.depth = depth;
|
||||
item.treeList.container = container;
|
||||
|
||||
item.treeList.parentList = parentList;
|
||||
@@ -196,87 +301,80 @@
|
||||
if (item.parent) {
|
||||
var index = item.parent.children.indexOf(item);
|
||||
item.parent.children.splice(index,1)
|
||||
that._trigger("sort",null,item.parent);
|
||||
}
|
||||
}
|
||||
var labelNodeType = "<div>";
|
||||
// if (item.children && item.hasOwnProperty('selected')) {
|
||||
// labelNodeType = "<div>";
|
||||
// }
|
||||
var label = $(labelNodeType,{class:"red-ui-treeList-label"}).appendTo(container);
|
||||
|
||||
var label = $("<div>",{class:"red-ui-treeList-label"}).appendTo(container);
|
||||
item.treeList.label = label;
|
||||
if (item.class) {
|
||||
label.addClass(item.class);
|
||||
}
|
||||
label.css({
|
||||
paddingLeft: (depth*15)+'px'
|
||||
})
|
||||
if (item.gutter) {
|
||||
item.gutter.css({
|
||||
position: 'absolute'
|
||||
}).appendTo(label)
|
||||
|
||||
}
|
||||
var labelPaddingWidth = (item.gutter?item.gutter.width()+2:0)+(depth*20);
|
||||
item.treeList.labelPadding = $('<span>').css({
|
||||
display: "inline-block",
|
||||
width: labelPaddingWidth+'px'
|
||||
}).appendTo(label);
|
||||
|
||||
label.on('mouseover',function(e) { that._trigger('itemmouseover',e,item); })
|
||||
label.on('mouseout',function(e) { that._trigger('itemmouseout',e,item); })
|
||||
label.on('mouseenter',function(e) { that._trigger('itemmouseenter',e,item); })
|
||||
label.on('mouseleave',function(e) { that._trigger('itemmouseleave',e,item); })
|
||||
|
||||
if (item.children) {
|
||||
item.treeList.addChild = function(newItem,select) {
|
||||
item.treeList.childList.editableList('addItem',newItem)
|
||||
newItem.parent = item;
|
||||
item.children.push(newItem);
|
||||
if (select) {
|
||||
setTimeout(function() {
|
||||
that.select(newItem)
|
||||
},100);
|
||||
}
|
||||
item.treeList.makeLeaf = function(detachChildElements) {
|
||||
if (!treeListIcon.children().length) {
|
||||
// Already a leaf
|
||||
return
|
||||
}
|
||||
item.treeList.expand = function(done) {
|
||||
if (container.hasClass("expanded")) {
|
||||
done && done();
|
||||
return;
|
||||
}
|
||||
if (!container.hasClass("built") && typeof item.children === 'function') {
|
||||
container.addClass('built');
|
||||
var childrenAdded = false;
|
||||
var spinner;
|
||||
var startTime = 0;
|
||||
item.children(item,function(children) {
|
||||
childrenAdded = true;
|
||||
item.treeList.childList = that._addChildren(container,item,children,depth).hide();
|
||||
var delta = Date.now() - startTime;
|
||||
if (delta < 400) {
|
||||
setTimeout(function() {
|
||||
item.treeList.childList.slideDown('fast');
|
||||
if (spinner) {
|
||||
spinner.remove();
|
||||
}
|
||||
},400-delta);
|
||||
} else {
|
||||
item.treeList.childList.slideDown('fast');
|
||||
if (spinner) {
|
||||
spinner.remove();
|
||||
if (detachChildElements && item.children) {
|
||||
var detachChildren = function(item) {
|
||||
if (item.children) {
|
||||
item.children.forEach(function(child) {
|
||||
if (child.element) {
|
||||
child.element.detach();
|
||||
}
|
||||
}
|
||||
done && done();
|
||||
that._trigger("childrenloaded",null,item)
|
||||
});
|
||||
if (!childrenAdded) {
|
||||
startTime = Date.now();
|
||||
spinner = $('<div class="red-ui-treeList-spinner">').css({
|
||||
"background-position": (35+depth*15)+'px 50%'
|
||||
}).appendTo(container);
|
||||
if (child.gutter) {
|
||||
child.gutter.detach();
|
||||
}
|
||||
detachChildren(child);
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
item.treeList.childList.slideDown('fast');
|
||||
done && done();
|
||||
}
|
||||
container.addClass("expanded");
|
||||
detachChildren(item);
|
||||
}
|
||||
item.treeList.collapse = function() {
|
||||
item.treeList.childList.slideUp('fast');
|
||||
container.removeClass("expanded");
|
||||
treeListIcon.empty();
|
||||
if (!item.deferBuild) {
|
||||
item.treeList.childList.remove();
|
||||
delete item.treeList.childList;
|
||||
}
|
||||
|
||||
$('<span class="red-ui-treeList-icon"><i class="fa fa-angle-right" /></span>').appendTo(label);
|
||||
label.off("click.red-ui-treeList-expand");
|
||||
treeListIcon.off("click.red-ui-treeList-expand");
|
||||
delete item.children;
|
||||
container.removeClass("expanded");
|
||||
}
|
||||
item.treeList.makeParent = function(children) {
|
||||
if (treeListIcon.children().length) {
|
||||
// Already a parent because we've got the angle-right icon
|
||||
return;
|
||||
}
|
||||
$('<i class="fa fa-angle-right" />').appendTo(treeListIcon);
|
||||
treeListIcon.on("click.red-ui-treeList-expand", function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (container.hasClass("expanded")) {
|
||||
item.treeList.collapse();
|
||||
} else {
|
||||
item.treeList.expand();
|
||||
}
|
||||
});
|
||||
// $('<span class="red-ui-treeList-icon"><i class="fa fa-folder-o" /></span>').appendTo(label);
|
||||
label.on("click", function(e) {
|
||||
label.on("click.red-ui-treeList-expand", function(e) {
|
||||
if (container.hasClass("expanded")) {
|
||||
if (item.hasOwnProperty('selected') || label.hasClass("selected")) {
|
||||
item.treeList.collapse();
|
||||
@@ -285,9 +383,97 @@
|
||||
item.treeList.expand();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$('<span class="red-ui-treeList-icon"></span>').appendTo(label);
|
||||
if (!item.children) {
|
||||
item.children = children||[];
|
||||
item.treeList.childList = that._addChildren(container,item,item.children,depth).hide();
|
||||
}
|
||||
}
|
||||
item.treeList.insertChildAt = function(newItem,position,select) {
|
||||
newItem.parent = item;
|
||||
item.children.splice(position,0,newItem);
|
||||
|
||||
if (!item.deferBuild) {
|
||||
item.treeList.childList.editableList('insertItemAt',newItem,position)
|
||||
if (select) {
|
||||
setTimeout(function() {
|
||||
that.select(newItem)
|
||||
},100);
|
||||
}
|
||||
that._trigger("sort",null,item);
|
||||
}
|
||||
}
|
||||
item.treeList.addChild = function(newItem,select) {
|
||||
item.treeList.insertChildAt(newItem,item.children.length,select);
|
||||
}
|
||||
item.treeList.expand = function(done) {
|
||||
if (!item.children) {
|
||||
return;
|
||||
}
|
||||
if (container.hasClass("expanded")) {
|
||||
done && done();
|
||||
return;
|
||||
}
|
||||
if (!container.hasClass("built") && (item.deferBuild || typeof item.children === 'function')) {
|
||||
container.addClass('built');
|
||||
var childrenAdded = false;
|
||||
var spinner;
|
||||
var startTime = 0;
|
||||
var completeBuild = function(children) {
|
||||
childrenAdded = true;
|
||||
item.treeList.childList = that._addChildren(container,item,children,depth).hide();
|
||||
var delta = Date.now() - startTime;
|
||||
if (delta < 400) {
|
||||
setTimeout(function() {
|
||||
item.treeList.childList.slideDown('fast');
|
||||
if (spinner) {
|
||||
spinner.remove();
|
||||
}
|
||||
},400-delta);
|
||||
} else {
|
||||
item.treeList.childList.slideDown('fast');
|
||||
if (spinner) {
|
||||
spinner.remove();
|
||||
}
|
||||
}
|
||||
done && done();
|
||||
that._trigger("childrenloaded",null,item)
|
||||
}
|
||||
if (typeof item.children === 'function') {
|
||||
item.children(completeBuild,item);
|
||||
} else {
|
||||
delete item.deferBuild;
|
||||
completeBuild(item.children);
|
||||
}
|
||||
if (!childrenAdded) {
|
||||
startTime = Date.now();
|
||||
spinner = $('<div class="red-ui-treeList-spinner">').css({
|
||||
"background-position": (35+depth*20)+'px 50%'
|
||||
}).appendTo(container);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (that._loadingData) {
|
||||
item.treeList.childList.show();
|
||||
} else {
|
||||
item.treeList.childList.slideDown('fast');
|
||||
}
|
||||
done && done();
|
||||
}
|
||||
container.addClass("expanded");
|
||||
}
|
||||
item.treeList.collapse = function() {
|
||||
if (!item.children) {
|
||||
return;
|
||||
}
|
||||
item.treeList.childList.slideUp('fast');
|
||||
container.removeClass("expanded");
|
||||
}
|
||||
|
||||
var treeListIcon = $('<span class="red-ui-treeList-icon"></span>').appendTo(label);
|
||||
if (item.children) {
|
||||
item.treeList.makeParent();
|
||||
}
|
||||
|
||||
if (item.hasOwnProperty('selected')) {
|
||||
var selectWrapper = $('<span class="red-ui-treeList-icon"></span>').appendTo(label);
|
||||
var cb = $('<input class="red-ui-treeList-checkbox" type="checkbox">').prop('checked',item.selected).appendTo(selectWrapper);
|
||||
@@ -326,19 +512,22 @@
|
||||
if (item.icon) {
|
||||
$('<span class="red-ui-treeList-icon"><i class="'+item.icon+'" /></span>').appendTo(label);
|
||||
}
|
||||
if (item.label || item.sublabel) {
|
||||
if (item.label) {
|
||||
if (item.hasOwnProperty('label') || item.hasOwnProperty('sublabel')) {
|
||||
if (item.hasOwnProperty('label')) {
|
||||
$('<span class="red-ui-treeList-label-text"></span>').text(item.label).appendTo(label);
|
||||
}
|
||||
if (item.sublabel) {
|
||||
if (item.hasOwnProperty('sublabel')) {
|
||||
$('<span class="red-ui-treeList-sublabel-text"></span>').text(item.sublabel).appendTo(label);
|
||||
}
|
||||
|
||||
} else if (item.element) {
|
||||
$(item.element).appendTo(label);
|
||||
$(item.element).css({
|
||||
width: "calc(100% - "+(labelPaddingWidth+20+(item.icon?20:0))+"px)"
|
||||
})
|
||||
}
|
||||
if (item.children) {
|
||||
if (Array.isArray(item.children)) {
|
||||
if (Array.isArray(item.children) && !item.deferBuild) {
|
||||
item.treeList.childList = that._addChildren(container,item,item.children,depth).hide();
|
||||
}
|
||||
if (item.expanded) {
|
||||
@@ -350,12 +539,17 @@
|
||||
this._topList.editableList('empty');
|
||||
},
|
||||
data: function(items) {
|
||||
var that = this;
|
||||
if (items !== undefined) {
|
||||
this._data = items;
|
||||
this._topList.editableList('empty');
|
||||
this._loadingData = true;
|
||||
for (var i=0; i<items.length;i++) {
|
||||
this._topList.editableList('addItem',items[i]);
|
||||
}
|
||||
setTimeout(function() {
|
||||
delete that._loadingData;
|
||||
},200);
|
||||
this._trigger("select")
|
||||
|
||||
} else {
|
||||
@@ -384,7 +578,11 @@
|
||||
})
|
||||
return res;
|
||||
}
|
||||
return s.parent().data('data');
|
||||
if (s.length) {
|
||||
return s.parent().data('data');
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -32,6 +32,12 @@
|
||||
return v;
|
||||
}
|
||||
}
|
||||
var mapDeprecatedIcon = function(icon) {
|
||||
if (/^red\/images\/typedInput\/.+\.png$/.test(icon)) {
|
||||
icon = icon.replace(/.png$/,".svg");
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
var allOptions = {
|
||||
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression},
|
||||
flow: {value:"flow",label:"flow.",hasValue:true,
|
||||
@@ -46,13 +52,13 @@
|
||||
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"]},
|
||||
str: {value:"str",label:"string",icon:"red/images/typedInput/az.svg"},
|
||||
num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/},
|
||||
bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.svg",options:["true","false"]},
|
||||
json: {
|
||||
value:"json",
|
||||
label:"JSON",
|
||||
icon:"red/images/typedInput/json.png",
|
||||
icon:"red/images/typedInput/json.svg",
|
||||
validate: function(v) { try{JSON.parse(v);return true;}catch(e){return false;}},
|
||||
expand: function() {
|
||||
var that = this;
|
||||
@@ -74,12 +80,12 @@
|
||||
})
|
||||
}
|
||||
},
|
||||
re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.png"},
|
||||
date: {value:"date",label:"timestamp",hasValue:false},
|
||||
re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.svg"},
|
||||
date: {value:"date",label:"timestamp",icon:"fa fa-clock-o",hasValue:false},
|
||||
jsonata: {
|
||||
value: "jsonata",
|
||||
label: "expression",
|
||||
icon: "red/images/typedInput/expr.png",
|
||||
icon: "red/images/typedInput/expr.svg",
|
||||
validate: function(v) { try{jsonata(v);return true;}catch(e){return false;}},
|
||||
expand:function() {
|
||||
var that = this;
|
||||
@@ -94,7 +100,7 @@
|
||||
bin: {
|
||||
value: "bin",
|
||||
label: "buffer",
|
||||
icon: "red/images/typedInput/bin.png",
|
||||
icon: "red/images/typedInput/bin.svg",
|
||||
expand: function() {
|
||||
var that = this;
|
||||
RED.editor.editBuffer({
|
||||
@@ -108,12 +114,12 @@
|
||||
env: {
|
||||
value: "env",
|
||||
label: "env variable",
|
||||
icon: "red/images/typedInput/env.png"
|
||||
icon: "red/images/typedInput/env.svg"
|
||||
},
|
||||
node: {
|
||||
value: "node",
|
||||
label: "node",
|
||||
icon: "red/images/typedInput/target.png",
|
||||
icon: "red/images/typedInput/target.svg",
|
||||
valueLabel: function(container,value) {
|
||||
var node = RED.nodes.node(value);
|
||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).css({
|
||||
@@ -209,7 +215,7 @@
|
||||
that.input.css("margin"+d,0);
|
||||
});
|
||||
|
||||
["type","placeholder"].forEach(function(d) {
|
||||
["type","placeholder","autocomplete","data-i18n"].forEach(function(d) {
|
||||
var m = that.element.attr(d);
|
||||
that.input.attr(d,m);
|
||||
});
|
||||
@@ -225,6 +231,8 @@
|
||||
|
||||
this.selectLabel = $('<span class="red-ui-typedInput-type-label"></span>').appendTo(this.selectTrigger);
|
||||
|
||||
this.valueLabelContainer = $('<div class="red-ui-typedInput-value-label">').appendTo(this.uiSelect)
|
||||
|
||||
this.types(this.options.types);
|
||||
|
||||
if (this.options.typeField) {
|
||||
@@ -247,9 +255,15 @@
|
||||
that.validate();
|
||||
that.element.val(that.value());
|
||||
that.element.trigger('change',that.propertyType,that.value());
|
||||
});
|
||||
this.input.on('keydown', function(evt) {
|
||||
if (evt.keyCode >= 37 && evt.keyCode <= 40) {
|
||||
evt.stopPropagation();
|
||||
}
|
||||
})
|
||||
this.selectTrigger.on("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
that._showTypeMenu();
|
||||
});
|
||||
this.selectTrigger.on('keydown',function(evt) {
|
||||
@@ -257,12 +271,11 @@
|
||||
// Down
|
||||
that._showTypeMenu();
|
||||
}
|
||||
evt.stopPropagation();
|
||||
}).on('focus', function() {
|
||||
that.uiSelect.addClass('red-ui-typedInput-focus');
|
||||
})
|
||||
|
||||
this.valueLabelContainer = $('<div class="red-ui-typedInput-value-label">').appendTo(this.uiSelect)
|
||||
|
||||
// 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="red-ui-typedInput-icon fa fa-caret-down"></i></span></button>').appendTo(this.uiSelect);
|
||||
this.optionSelectLabel = $('<span class="red-ui-typedInput-option-label"></span>').prependTo(this.optionSelectTrigger);
|
||||
@@ -271,19 +284,22 @@
|
||||
});
|
||||
this.optionSelectTrigger.on("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
that._showOptionSelectMenu();
|
||||
}).on('keydown', function(evt) {
|
||||
if (evt.keyCode === 40) {
|
||||
// Down
|
||||
that._showOptionSelectMenu();
|
||||
}
|
||||
evt.stopPropagation();
|
||||
}).on('blur', function() {
|
||||
that.uiSelect.removeClass('red-ui-typedInput-focus');
|
||||
}).on('focus', function() {
|
||||
that.uiSelect.addClass('red-ui-typedInput-focus');
|
||||
});
|
||||
|
||||
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.optionExpandButton = $('<button tabindex="0" class="red-ui-typedInput-option-expand" style="display:inline-block"></button>').appendTo(this.uiSelect);
|
||||
this.optionExpandButtonIcon = $('<i class="red-ui-typedInput-icon fa fa-ellipsis-h"></i>').appendTo(this.optionExpandButton);
|
||||
this.type(this.options.default||this.typeList[0].value);
|
||||
}catch(err) {
|
||||
console.log(err.stack);
|
||||
@@ -321,6 +337,17 @@
|
||||
menu.css({
|
||||
height: "auto"
|
||||
});
|
||||
|
||||
if (menu.opts.multiple) {
|
||||
var selected = [];
|
||||
menu.find('input[type="checkbox"]').each(function() {
|
||||
if ($(this).prop("checked")) {
|
||||
selected.push($(this).data('value'))
|
||||
}
|
||||
})
|
||||
menu.callback(selected);
|
||||
}
|
||||
|
||||
if (this.elementDiv.is(":visible")) {
|
||||
this.input.trigger("focus");
|
||||
} else if (this.optionSelectTrigger.is(":visible")){
|
||||
@@ -329,10 +356,12 @@
|
||||
this.selectTrigger.trigger("focus");
|
||||
}
|
||||
},
|
||||
_createMenu: function(opts,callback) {
|
||||
_createMenu: function(menuOptions,opts,callback) {
|
||||
var that = this;
|
||||
var menu = $("<div>").addClass("red-ui-typedInput-options");
|
||||
opts.forEach(function(opt) {
|
||||
var menu = $("<div>").addClass("red-ui-typedInput-options red-ui-editor-dialog");
|
||||
menu.opts = opts;
|
||||
menu.callback = callback;
|
||||
menuOptions.forEach(function(opt) {
|
||||
if (typeof opt === 'string') {
|
||||
opt = {value:opt,label:opt};
|
||||
}
|
||||
@@ -344,7 +373,7 @@
|
||||
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);
|
||||
$('<img>',{src:mapDeprecatedIcon(opt.icon),style:"margin-right: 4px; height: 18px;"}).prependTo(op);
|
||||
} else {
|
||||
$('<i>',{class:"red-ui-typedInput-icon "+opt.icon}).prependTo(op);
|
||||
}
|
||||
@@ -354,11 +383,20 @@
|
||||
if (!opt.icon && !opt.label) {
|
||||
op.text(opt.value);
|
||||
}
|
||||
var cb;
|
||||
if (opts.multiple) {
|
||||
cb = $('<input type="checkbox">').css("pointer-events","none").data('value',opt.value).prependTo(op).on("mousedown", function(evt) { evt.preventDefault() });
|
||||
}
|
||||
|
||||
op.on("click", function(event) {
|
||||
event.preventDefault();
|
||||
callback(opt.value);
|
||||
that._hideMenu(menu);
|
||||
event.stopPropagation();
|
||||
if (!opts.multiple) {
|
||||
callback(opt.value);
|
||||
that._hideMenu(menu);
|
||||
} else {
|
||||
cb.prop("checked",!cb.prop("checked"));
|
||||
}
|
||||
});
|
||||
});
|
||||
menu.css({
|
||||
@@ -376,13 +414,12 @@
|
||||
// UP
|
||||
$(this).children(":focus").prev().trigger("focus");
|
||||
} else if (evt.keyCode === 27) {
|
||||
// ESCAPE
|
||||
evt.preventDefault();
|
||||
that._hideMenu(menu);
|
||||
}
|
||||
evt.stopPropagation();
|
||||
})
|
||||
|
||||
|
||||
|
||||
return menu;
|
||||
|
||||
},
|
||||
@@ -391,11 +428,22 @@
|
||||
this.disarmClick = false;
|
||||
return
|
||||
}
|
||||
if (menu.opts.multiple) {
|
||||
var selected = {};
|
||||
this.value().split(",").forEach(function(f) {
|
||||
selected[f] = true;
|
||||
})
|
||||
menu.find('input[type="checkbox"]').each(function() {
|
||||
$(this).prop("checked",selected[$(this).data('value')])
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
var that = this;
|
||||
var pos = relativeTo.offset();
|
||||
var height = relativeTo.height();
|
||||
var menuHeight = menu.height();
|
||||
var top = (height+pos.top-3);
|
||||
var top = (height+pos.top);
|
||||
if (top+menuHeight > $(window).height()) {
|
||||
top -= (top+menuHeight)-$(window).height()+5;
|
||||
}
|
||||
@@ -405,7 +453,7 @@
|
||||
}
|
||||
menu.css({
|
||||
top: top+"px",
|
||||
left: (2+pos.left)+"px",
|
||||
left: (pos.left)+"px",
|
||||
});
|
||||
menu.slideDown(100);
|
||||
this._delay(function() {
|
||||
@@ -421,20 +469,27 @@
|
||||
})
|
||||
});
|
||||
},
|
||||
_getLabelWidth: function(label) {
|
||||
_getLabelWidth: function(label, done) {
|
||||
var labelWidth = label.outerWidth();
|
||||
if (labelWidth === 0) {
|
||||
var container = $('<div class="red-ui-typedInput-container"></div>').css({
|
||||
var wrapper = $('<div class="red-ui-editor"></div>').css({
|
||||
position:"absolute",
|
||||
top:0
|
||||
"white-space": "nowrap",
|
||||
top:-2000
|
||||
}).appendTo(document.body);
|
||||
var container = $('<div class="red-ui-typedInput-container"></div>').appendTo(wrapper);
|
||||
var newTrigger = label.clone().appendTo(container);
|
||||
labelWidth = newTrigger.outerWidth();
|
||||
container.remove();
|
||||
setTimeout(function() {
|
||||
labelWidth = newTrigger.outerWidth();
|
||||
wrapper.remove();
|
||||
done(labelWidth);
|
||||
},50)
|
||||
} else {
|
||||
done(labelWidth);
|
||||
}
|
||||
return labelWidth;
|
||||
},
|
||||
_resize: function() {
|
||||
var that = this;
|
||||
if (this.uiWidth !== null) {
|
||||
this.uiSelect.width(this.uiWidth);
|
||||
}
|
||||
@@ -443,71 +498,78 @@
|
||||
this.selectTrigger.addClass("red-ui-typedInput-full-width");
|
||||
} else {
|
||||
this.selectTrigger.removeClass("red-ui-typedInput-full-width");
|
||||
var labelWidth = this._getLabelWidth(this.selectTrigger);
|
||||
this.elementDiv.css('left',labelWidth+"px");
|
||||
this.valueLabelContainer.css('left',labelWidth+"px");
|
||||
if (this.optionExpandButton.is(":visible")) {
|
||||
this.elementDiv.css('right',"22px");
|
||||
this.valueLabelContainer.css('right',"22px");
|
||||
} else {
|
||||
this.elementDiv.css('right','0');
|
||||
this.valueLabelContainer.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) {
|
||||
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
|
||||
});
|
||||
this._getLabelWidth(this.selectTrigger, function(labelWidth) {
|
||||
that.elementDiv.css('left',labelWidth+"px");
|
||||
that.valueLabelContainer.css('left',labelWidth+"px");
|
||||
if (that.optionExpandButton.shown) {
|
||||
that.elementDiv.css('right',"22px");
|
||||
that.valueLabelContainer.css('right',"22px");
|
||||
} 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'
|
||||
that.elementDiv.css('right','0');
|
||||
that.valueLabelContainer.css('right','0');
|
||||
that.input.css({
|
||||
'border-top-right-radius': '4px',
|
||||
'border-bottom-right-radius': '4px'
|
||||
});
|
||||
}
|
||||
if (that.optionSelectTrigger) {
|
||||
if (type && type.options && type.hasValue === true) {
|
||||
that.optionSelectLabel.css({'left':'auto'})
|
||||
that._getLabelWidth(that.optionSelectLabel, function(lw) {
|
||||
that.optionSelectTrigger.css({'width':(23+lw)+"px"});
|
||||
that.elementDiv.css('right',(23+lw)+"px");
|
||||
that.input.css({
|
||||
'border-top-right-radius': 0,
|
||||
'border-bottom-right-radius': 0
|
||||
});
|
||||
});
|
||||
} else {
|
||||
that.optionSelectLabel.css({'left':'0'})
|
||||
that.optionSelectTrigger.css({'width':'calc( 100% - '+labelWidth+'px )'});
|
||||
if (!that.optionExpandButton.shown) {
|
||||
that.elementDiv.css({'right':0});
|
||||
that.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);
|
||||
if (this.typeMap[this.propertyType].valueLabel) {
|
||||
if (opt.multiple) {
|
||||
this.typeMap[this.propertyType].valueLabel.call(this,this.optionSelectLabel,o);
|
||||
} else {
|
||||
// icon class
|
||||
$('<i>',{class:"red-ui-typedInput-icon "+o.icon}).prependTo(this.optionSelectLabel);
|
||||
this.typeMap[this.propertyType].valueLabel.call(this,this.optionSelectLabel,o.value);
|
||||
}
|
||||
} else if (!opt.multiple) {
|
||||
if (o.icon) {
|
||||
if (o.icon.indexOf("<") === 0) {
|
||||
$(o.icon).prependTo(this.optionSelectLabel);
|
||||
} else if (o.icon.indexOf("/") !== -1) {
|
||||
// url
|
||||
$('<img>',{src:mapDeprecatedIcon(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());
|
||||
}
|
||||
} 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());
|
||||
this.optionSelectLabel.text(o.length+" selected");
|
||||
}
|
||||
},
|
||||
_destroy: function() {
|
||||
@@ -515,6 +577,7 @@
|
||||
this.optionMenu.remove();
|
||||
}
|
||||
this.menu.remove();
|
||||
this.uiSelect.remove();
|
||||
},
|
||||
types: function(types) {
|
||||
var that = this;
|
||||
@@ -535,7 +598,7 @@
|
||||
if (this.menu) {
|
||||
this.menu.remove();
|
||||
}
|
||||
this.menu = this._createMenu(this.typeList, function(v) { that.type(v) });
|
||||
this.menu = this._createMenu(this.typeList,{},function(v) { that.type(v) });
|
||||
if (currentType && !this.typeMap.hasOwnProperty(currentType)) {
|
||||
this.type(this.typeList[0].value);
|
||||
} else {
|
||||
@@ -549,37 +612,51 @@
|
||||
this._resize();
|
||||
},
|
||||
value: function(value) {
|
||||
var that = this;
|
||||
var opt = this.typeMap[this.propertyType];
|
||||
if (!arguments.length) {
|
||||
var v = this.input.val();
|
||||
if (this.typeMap[this.propertyType].export) {
|
||||
v = this.typeMap[this.propertyType].export(v,this.optionValue)
|
||||
if (opt.export) {
|
||||
v = opt.export(v,this.optionValue)
|
||||
}
|
||||
return v;
|
||||
} else {
|
||||
var selectedOption;
|
||||
if (this.typeMap[this.propertyType].options) {
|
||||
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) {
|
||||
selectedOption = this.activeOptions[op];
|
||||
var selectedOption = [];
|
||||
if (opt.options) {
|
||||
var checkValues = [value];
|
||||
if (opt.multiple) {
|
||||
selectedOption = [];
|
||||
checkValues = value.split(",");
|
||||
}
|
||||
checkValues.forEach(function(value) {
|
||||
for (var i=0;i<opt.options.length;i++) {
|
||||
var op = opt.options[i];
|
||||
if (typeof op === "string") {
|
||||
if (op === value) {
|
||||
selectedOption.push(that.activeOptions[op]);
|
||||
break;
|
||||
}
|
||||
} else if (op.value === value) {
|
||||
selectedOption.push(op);
|
||||
break;
|
||||
}
|
||||
} else if (op.value === value) {
|
||||
selectedOption = op;
|
||||
break;
|
||||
}
|
||||
})
|
||||
this.input.val(value);
|
||||
if (!opt.multiple) {
|
||||
if (!selectedOption.length === 0) {
|
||||
selectedOption = [{value:""}];
|
||||
}
|
||||
this._updateOptionSelectLabel(selectedOption[0])
|
||||
} else {
|
||||
this._updateOptionSelectLabel(selectedOption)
|
||||
}
|
||||
if (!selectedOption) {
|
||||
selectedOption = {value:""}
|
||||
}
|
||||
this._updateOptionSelectLabel(selectedOption)
|
||||
} else {
|
||||
this.input.val(value);
|
||||
}
|
||||
if (this.typeMap[this.propertyType].valueLabel) {
|
||||
this.valueLabelContainer.empty();
|
||||
this.typeMap[this.propertyType].valueLabel.call(this,this.valueLabelContainer,value);
|
||||
if (opt.valueLabel) {
|
||||
this.valueLabelContainer.empty();
|
||||
opt.valueLabel.call(this,this.valueLabelContainer,value);
|
||||
}
|
||||
}
|
||||
this.input.trigger('change',this.type(),value);
|
||||
}
|
||||
@@ -597,20 +674,23 @@
|
||||
}
|
||||
this.selectLabel.empty();
|
||||
var image;
|
||||
if (opt.icon) {
|
||||
if (opt.icon && opt.showLabel !== false) {
|
||||
if (opt.icon.indexOf("<") === 0) {
|
||||
$(opt.icon).prependTo(this.selectLabel);
|
||||
}
|
||||
else if (opt.icon.indexOf("/") !== -1) {
|
||||
image = new Image();
|
||||
image.onload = function() { that._resize(); }
|
||||
image.onerror = function() { that._resize(); }
|
||||
image.name = opt.icon;
|
||||
image.src = opt.icon;
|
||||
$('<img>',{src:opt.icon,style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel);
|
||||
image.src = mapDeprecatedIcon(opt.icon);
|
||||
$('<img>',{src:mapDeprecatedIcon(opt.icon),style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel);
|
||||
}
|
||||
else {
|
||||
$('<i>',{class:"red-ui-typedInput-icon "+opt.icon}).prependTo(this.selectLabel);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (opt.hasValue === false || (opt.showLabel !== false && !opt.icon)) {
|
||||
this.selectLabel.text(opt.label);
|
||||
}
|
||||
if (this.optionMenu) {
|
||||
@@ -620,6 +700,7 @@
|
||||
if (opt.options) {
|
||||
if (this.optionExpandButton) {
|
||||
this.optionExpandButton.hide();
|
||||
this.optionExpandButton.shown = false;
|
||||
}
|
||||
if (this.optionSelectTrigger) {
|
||||
this.optionSelectTrigger.show();
|
||||
@@ -642,36 +723,50 @@
|
||||
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 op;
|
||||
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;
|
||||
var currentVal = this.input.val();
|
||||
if (!opt.multiple) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
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 {
|
||||
// Check to see if value is a valid csv of
|
||||
// options.
|
||||
var currentValues = {};
|
||||
currentVal.split(",").forEach(function(v) {
|
||||
if (v) {
|
||||
currentValues[v] = true;
|
||||
}
|
||||
});
|
||||
for (var i=0;i<opt.options.length;i++) {
|
||||
op = opt.options[i];
|
||||
delete currentValues[op.value||op];
|
||||
}
|
||||
if (!$.isEmptyObject(currentValues)) {
|
||||
// Invalid, set to default/empty
|
||||
this.value((opt.default||[]).join(","));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -707,7 +802,21 @@
|
||||
this.optionSelectTrigger.hide();
|
||||
}
|
||||
}
|
||||
this.optionMenu = this._createMenu(opt.options,opt,function(v){
|
||||
if (!opt.multiple) {
|
||||
that._updateOptionSelectLabel(that.activeOptions[v]);
|
||||
if (!opt.hasValue) {
|
||||
that.value(that.activeOptions[v].value)
|
||||
}
|
||||
} else {
|
||||
that._updateOptionSelectLabel(v);
|
||||
if (!opt.hasValue) {
|
||||
that.value(v.join(","))
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
this._trigger("typechange",null,this.propertyType);
|
||||
this.input.trigger('change',this.propertyType,this.value());
|
||||
} else {
|
||||
if (this.optionSelectTrigger) {
|
||||
@@ -732,23 +841,47 @@
|
||||
this.elementDiv.show();
|
||||
}
|
||||
if (this.optionExpandButton) {
|
||||
if (opt.expand && typeof opt.expand === 'function') {
|
||||
if (opt.expand) {
|
||||
if (opt.expand.icon) {
|
||||
this.optionExpandButtonIcon.removeClass().addClass("red-ui-typedInput-icon fa "+opt.expand.icon)
|
||||
} else {
|
||||
this.optionExpandButtonIcon.removeClass().addClass("red-ui-typedInput-icon fa fa-ellipsis-h")
|
||||
}
|
||||
this.optionExpandButton.shown = true;
|
||||
this.optionExpandButton.show();
|
||||
this.optionExpandButton.off('click');
|
||||
this.optionExpandButton.on('click',function(evt) {
|
||||
evt.preventDefault();
|
||||
opt.expand.call(that);
|
||||
if (typeof opt.expand === 'function') {
|
||||
opt.expand.call(that);
|
||||
} else {
|
||||
var container = $('<div>');
|
||||
var content = opt.expand.content.call(that,container);
|
||||
var panel = RED.popover.panel(container);
|
||||
panel.container.css({
|
||||
width:that.valueLabelContainer.width()
|
||||
});
|
||||
if (opt.expand.minWidth) {
|
||||
panel.container.css({
|
||||
minWidth: opt.expand.minWidth+"px"
|
||||
});
|
||||
}
|
||||
panel.show({
|
||||
target:that.optionExpandButton,
|
||||
onclose:content.onclose,
|
||||
align: "right"
|
||||
});
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.optionExpandButton.shown = false;
|
||||
this.optionExpandButton.hide();
|
||||
}
|
||||
}
|
||||
this._trigger("typechange",null,this.propertyType);
|
||||
this.input.trigger('change',this.propertyType,this.value());
|
||||
}
|
||||
if (image) {
|
||||
image.onload = function() { that._resize(); }
|
||||
image.onerror = function() { that._resize(); }
|
||||
} else {
|
||||
if (!image) {
|
||||
this._resize();
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@
|
||||
RED.deploy = (function() {
|
||||
|
||||
var deploymentTypes = {
|
||||
"full":{img:"red/images/deploy-full-o.png"},
|
||||
"nodes":{img:"red/images/deploy-nodes-o.png"},
|
||||
"flows":{img:"red/images/deploy-flows-o.png"}
|
||||
"full":{img:"red/images/deploy-full-o.svg"},
|
||||
"nodes":{img:"red/images/deploy-nodes-o.svg"},
|
||||
"flows":{img:"red/images/deploy-flows-o.svg"}
|
||||
}
|
||||
|
||||
var ignoreDeployWarnings = {
|
||||
@@ -44,7 +44,7 @@ RED.deploy = (function() {
|
||||
* type: "default" - Button with drop-down options - no further customisation available
|
||||
* type: "simple" - Button without dropdown. Customisations:
|
||||
* label: the text to display - default: "Deploy"
|
||||
* icon : the icon to use. Null removes the icon. default: "red/images/deploy-full-o.png"
|
||||
* icon : the icon to use. Null removes the icon. default: "red/images/deploy-full-o.svg"
|
||||
*/
|
||||
function init(options) {
|
||||
options = options || {};
|
||||
@@ -54,7 +54,7 @@ RED.deploy = (function() {
|
||||
$('<li><span class="red-ui-deploy-button-group button-group">'+
|
||||
'<a id="red-ui-header-button-deploy" class="red-ui-deploy-button disabled" href="#">'+
|
||||
'<span class="red-ui-deploy-button-content">'+
|
||||
'<img id="red-ui-header-button-deploy-icon" src="red/images/deploy-full-o.png"> '+
|
||||
'<img id="red-ui-header-button-deploy-icon" src="red/images/deploy-full-o.svg"> '+
|
||||
'<span>'+RED._("deploy.deploy")+'</span>'+
|
||||
'</span>'+
|
||||
'<span class="red-ui-deploy-button-spinner hide">'+
|
||||
@@ -65,17 +65,17 @@ RED.deploy = (function() {
|
||||
'</span></li>').prependTo(".red-ui-header-toolbar");
|
||||
RED.menu.init({id:"red-ui-header-button-deploy-options",
|
||||
options: [
|
||||
{id:"deploymenu-item-full",toggle:"deploy-type",icon:"red/images/deploy-full.png",label:RED._("deploy.full"),sublabel:RED._("deploy.fullDesc"),selected: true, onselect:function(s) { if(s){changeDeploymentType("full")}}},
|
||||
{id:"deploymenu-item-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.png",label:RED._("deploy.modifiedFlows"),sublabel:RED._("deploy.modifiedFlowsDesc"), onselect:function(s) {if(s){changeDeploymentType("flows")}}},
|
||||
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.png",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
|
||||
{id:"deploymenu-item-full",toggle:"deploy-type",icon:"red/images/deploy-full.svg",label:RED._("deploy.full"),sublabel:RED._("deploy.fullDesc"),selected: true, onselect:function(s) { if(s){changeDeploymentType("full")}}},
|
||||
{id:"deploymenu-item-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.svg",label:RED._("deploy.modifiedFlows"),sublabel:RED._("deploy.modifiedFlowsDesc"), onselect:function(s) {if(s){changeDeploymentType("flows")}}},
|
||||
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.svg",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
|
||||
null,
|
||||
{id:"deploymenu-item-reload", icon:"red/images/deploy-reload.png",label:RED._("deploy.restartFlows"),sublabel:RED._("deploy.restartFlowsDesc"),onselect:"core:restart-flows"},
|
||||
{id:"deploymenu-item-reload", icon:"red/images/deploy-reload.svg",label:RED._("deploy.restartFlows"),sublabel:RED._("deploy.restartFlowsDesc"),onselect:"core:restart-flows"},
|
||||
|
||||
]
|
||||
});
|
||||
} else if (type == "simple") {
|
||||
var label = options.label || RED._("deploy.deploy");
|
||||
var icon = 'red/images/deploy-full-o.png';
|
||||
var icon = 'red/images/deploy-full-o.svg';
|
||||
if (options.hasOwnProperty('icon')) {
|
||||
icon = options.icon;
|
||||
}
|
||||
@@ -99,7 +99,13 @@ RED.deploy = (function() {
|
||||
});
|
||||
|
||||
RED.actions.add("core:deploy-flows",save);
|
||||
RED.actions.add("core:restart-flows",restart);
|
||||
if (type === "default") {
|
||||
RED.actions.add("core:restart-flows",restart);
|
||||
RED.actions.add("core:set-deploy-type-to-full",function() { RED.menu.setSelected("deploymenu-item-full",true);});
|
||||
RED.actions.add("core:set-deploy-type-to-modified-flows",function() { RED.menu.setSelected("deploymenu-item-flow",true); });
|
||||
RED.actions.add("core:set-deploy-type-to-modified-nodes",function() { RED.menu.setSelected("deploymenu-item-node",true); });
|
||||
}
|
||||
|
||||
|
||||
|
||||
RED.events.on('nodes:change',function(state) {
|
||||
|
@@ -399,7 +399,7 @@ RED.diff = (function() {
|
||||
diff: localDiff,
|
||||
def: {
|
||||
defaults:{},
|
||||
icon:"subflow.png",
|
||||
icon:"subflow.svg",
|
||||
category: "subflows",
|
||||
color: "#da9"
|
||||
},
|
||||
@@ -422,7 +422,7 @@ RED.diff = (function() {
|
||||
diff: localDiff,
|
||||
def: {
|
||||
defaults:{},
|
||||
icon:"subflow.png",
|
||||
icon:"subflow.svg",
|
||||
category: "subflows",
|
||||
color: "#da9"
|
||||
},
|
||||
@@ -443,7 +443,7 @@ RED.diff = (function() {
|
||||
remoteDiff: remoteDiff,
|
||||
def: {
|
||||
defaults:{},
|
||||
icon:"subflow.png",
|
||||
icon:"subflow.svg",
|
||||
category: "subflows",
|
||||
color: "#da9"
|
||||
},
|
||||
@@ -549,7 +549,7 @@ RED.diff = (function() {
|
||||
if (def === undefined) {
|
||||
if (/^subflow:/.test(node.type)) {
|
||||
def = {
|
||||
icon:"subflow.png",
|
||||
icon:"subflow.svg",
|
||||
category: "subflows",
|
||||
color: "#da9",
|
||||
defaults:{name:{value:""}}
|
||||
|
@@ -19,7 +19,6 @@
|
||||
*/
|
||||
RED.editor = (function() {
|
||||
|
||||
|
||||
var editStack = [];
|
||||
var editing_node = null;
|
||||
var editing_config_node = null;
|
||||
@@ -526,7 +525,7 @@ RED.editor = (function() {
|
||||
} else if (node.type.indexOf("subflow:")===0) {
|
||||
var subflow = RED.nodes.subflow(node.type.substring(8));
|
||||
label = RED._("subflow.editSubflowInstance",{name:RED.utils.sanitize(subflow.name)})
|
||||
} else {
|
||||
} else if (node._def !== undefined) {
|
||||
if (typeof node._def.paletteLabel !== "undefined") {
|
||||
try {
|
||||
label = RED.utils.sanitize((typeof node._def.paletteLabel === "function" ? node._def.paletteLabel.call(node._def) : node._def.paletteLabel)||"");
|
||||
@@ -546,146 +545,7 @@ RED.editor = (function() {
|
||||
return label;
|
||||
}
|
||||
|
||||
function buildEnvForm(container, node) {
|
||||
var env_container = $('#node-input-env-container');
|
||||
env_container
|
||||
.css({
|
||||
'min-height':'150px',
|
||||
'min-width':'450px'
|
||||
})
|
||||
.editableList({
|
||||
addItem: function(container, i, opt) {
|
||||
var row = $('<div/>').appendTo(container);
|
||||
if (opt.parent) {
|
||||
$('<div/>', {
|
||||
class:"uneditable-input",
|
||||
style: "margin-left: 5px; width: calc(40% - 8px)",
|
||||
}).appendTo(row).text(opt.name);
|
||||
} else {
|
||||
$('<input/>', {
|
||||
class: "node-input-env-name",
|
||||
type: "text",
|
||||
style: "margin-left: 5px; width: calc(40% - 8px)",
|
||||
placeholder: RED._("common.label.name")
|
||||
}).appendTo(row).val(opt.name);
|
||||
}
|
||||
var valueField = $('<input/>',{
|
||||
class: "node-input-env-value",
|
||||
type: "text",
|
||||
style: "margin-left: 5px; width: calc(60% - 8px)"
|
||||
}).appendTo(row)
|
||||
|
||||
valueField.typedInput({default:'str',
|
||||
types:['str','num','bool','json','bin','env']
|
||||
});
|
||||
|
||||
valueField.typedInput('type', opt.parent?(opt.type||opt.parent.type):opt.type);
|
||||
valueField.typedInput('value', opt.parent?((opt.value !== undefined)?opt.value:opt.parent.value):opt.value);
|
||||
|
||||
var actionButton = $('<a/>',{href:"#",class:"red-ui-editableList-item-remove red-ui-button red-ui-button-small"}).appendTo(container);
|
||||
$('<i/>',{class:"fa "+(opt.parent?"fa-reply":"fa-remove")}).appendTo(actionButton);
|
||||
container.parent().addClass("red-ui-editableList-item-removable");
|
||||
if (opt.parent) {
|
||||
if ((opt.value !== undefined) && (opt.value !== opt.parent.value || opt.type !== opt.parent.type)) {
|
||||
actionButton.show();
|
||||
} else {
|
||||
actionButton.hide();
|
||||
}
|
||||
var restoreTip = RED.popover.tooltip(actionButton,RED._("subflow.env.restore"));
|
||||
valueField.on("change", function(evt) {
|
||||
var newType = valueField.typedInput('type');
|
||||
var newValue = valueField.typedInput('value');
|
||||
if (newType === opt.parent.type && newValue === opt.parent.value) {
|
||||
actionButton.hide();
|
||||
} else {
|
||||
actionButton.show();
|
||||
}
|
||||
})
|
||||
actionButton.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
restoreTip.close();
|
||||
valueField.typedInput('type', opt.parent.type);
|
||||
valueField.typedInput('value', opt.parent.value);
|
||||
})
|
||||
} else {
|
||||
var removeTip = RED.popover.tooltip(actionButton,RED._("subflow.env.remove"));
|
||||
actionButton.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
removeTip.close();
|
||||
container.parent().addClass("red-ui-editableList-item-deleting")
|
||||
container.fadeOut(300, function() {
|
||||
env_container.editableList('removeItem',opt);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
sortable: false,
|
||||
removable: false
|
||||
});
|
||||
var parentEnv = {};
|
||||
var envList = [];
|
||||
if (/^subflow:/.test(node.type)) {
|
||||
var subflowDef = RED.nodes.subflow(node.type.substring(8));
|
||||
if (subflowDef.env) {
|
||||
subflowDef.env.forEach(function(env) {
|
||||
var item = {
|
||||
name:env.name,
|
||||
parent: {
|
||||
type: env.type,
|
||||
value: env.value
|
||||
}
|
||||
}
|
||||
envList.push(item);
|
||||
parentEnv[env.name] = item;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (node.env) {
|
||||
for (var i = 0; i < node.env.length; i++) {
|
||||
var env = node.env[i];
|
||||
if (parentEnv.hasOwnProperty(env.name)) {
|
||||
parentEnv[env.name].type = env.type;
|
||||
parentEnv[env.name].value = env.value;
|
||||
} else {
|
||||
envList.push({
|
||||
name: env.name,
|
||||
type: env.type,
|
||||
value: env.value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
envList.forEach(function(env) {
|
||||
env_container.editableList('addItem', env);
|
||||
})
|
||||
}
|
||||
|
||||
function exportEnvList(list) {
|
||||
if (list) {
|
||||
var env = [];
|
||||
list.each(function(i) {
|
||||
var entry = $(this);
|
||||
var item = entry.data('data');
|
||||
var name = item.parent?item.name:entry.find(".node-input-env-name").val();
|
||||
var valueInput = entry.find(".node-input-env-value");
|
||||
var value = valueInput.typedInput("value");
|
||||
var type = valueInput.typedInput("type");
|
||||
if (!item.parent || (item.parent.value !== value || item.parent.type !== type)) {
|
||||
var item = {
|
||||
name: name,
|
||||
type: type,
|
||||
value: value
|
||||
};
|
||||
env.push(item);
|
||||
}
|
||||
});
|
||||
return env;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isSameEnv(env0, env1) {
|
||||
function isSameObj(env0, env1) {
|
||||
return (JSON.stringify(env0) === JSON.stringify(env1));
|
||||
}
|
||||
|
||||
@@ -711,8 +571,8 @@ RED.editor = (function() {
|
||||
$(this).attr("data-i18n",keys.join(";"));
|
||||
});
|
||||
|
||||
if ((type === "subflow") || (type === "subflow-template")) {
|
||||
buildEnvForm(dialogForm, node);
|
||||
if (type === "subflow-template" || type === "subflow") {
|
||||
RED.subflow.buildEditForm(dialogForm,type,node);
|
||||
}
|
||||
|
||||
// Add dummy fields to prevent 'Enter' submitting the form in some
|
||||
@@ -721,6 +581,7 @@ RED.editor = (function() {
|
||||
$('<input type="password" style="display: none;" />').prependTo(dialogForm);
|
||||
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
||||
dialogForm.on("submit", function(e) { e.preventDefault();});
|
||||
dialogForm.find('input').attr("autocomplete","disable");
|
||||
return dialogForm;
|
||||
}
|
||||
|
||||
@@ -854,30 +715,8 @@ RED.editor = (function() {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function showIconPicker(container, node, iconPath, done) {
|
||||
var containerPos = container.offset();
|
||||
var pickerBackground = $('<div>').css({
|
||||
position: "absolute",top:0,bottom:0,left:0,right:0,zIndex:20
|
||||
}).appendTo("body");
|
||||
|
||||
var top = containerPos.top - 30;
|
||||
|
||||
if (top+280 > $( window ).height()) {
|
||||
top = $( window ).height() - 280;
|
||||
}
|
||||
var picker = $('<div class="red-ui-icon-picker">').css({
|
||||
top: top+"px",
|
||||
left: containerPos.left+"px",
|
||||
}).appendTo("#red-ui-editor");
|
||||
|
||||
var hide = function() {
|
||||
pickerBackground.remove();
|
||||
picker.remove();
|
||||
RED.keyboard.remove("escape");
|
||||
}
|
||||
RED.keyboard.add("*","escape",function(){hide()});
|
||||
pickerBackground.on("mousedown", hide);
|
||||
|
||||
function showIconPicker(container, backgroundColor, iconPath, faOnly, done) {
|
||||
var picker = $('<div class="red-ui-icon-picker">');
|
||||
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(picker);
|
||||
searchInput = $('<input type="text">').attr("placeholder",RED._("editor.searchIcons")).appendTo(searchDiv).searchBox({
|
||||
delay: 50,
|
||||
@@ -905,89 +744,255 @@ RED.editor = (function() {
|
||||
var summary = $('<span>').appendTo(metaRow);
|
||||
var resetButton = $('<button type="button" class="red-ui-button red-ui-button-small">'+RED._("editor.useDefault")+'</button>').appendTo(metaRow).on("click", function(e) {
|
||||
e.preventDefault();
|
||||
hide();
|
||||
iconPanel.hide();
|
||||
done(null);
|
||||
});
|
||||
var iconSets = RED.nodes.getIconSets();
|
||||
Object.keys(iconSets).forEach(function(moduleName) {
|
||||
var icons = iconSets[moduleName];
|
||||
if (icons.length > 0) {
|
||||
// selectIconModule.append($("<option></option>").val(moduleName).text(moduleName));
|
||||
var header = $('<div class="red-ui-icon-list-module"></div>').text(moduleName).appendTo(iconList);
|
||||
$('<i class="fa fa-cube"></i>').prependTo(header);
|
||||
icons.forEach(function(icon) {
|
||||
var iconDiv = $('<div>',{class:"red-ui-icon-list-icon"}).appendTo(iconList);
|
||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(iconDiv);
|
||||
var colour = RED.utils.getNodeColor(node.type, node._def);
|
||||
var icon_url = RED.settings.apiRootUrl+"icons/"+moduleName+"/"+icon;
|
||||
iconDiv.data('icon',icon_url);
|
||||
nodeDiv.css('backgroundColor',colour);
|
||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
|
||||
RED.utils.createIconElement(icon_url, iconContainer, true);
|
||||
if (!backgroundColor && faOnly) {
|
||||
iconList.addClass("red-ui-icon-list-dark");
|
||||
}
|
||||
setTimeout(function() {
|
||||
var iconSets = RED.nodes.getIconSets();
|
||||
Object.keys(iconSets).forEach(function(moduleName) {
|
||||
if (faOnly && (moduleName !== "font-awesome")) {
|
||||
return;
|
||||
}
|
||||
var icons = iconSets[moduleName];
|
||||
if (icons.length > 0) {
|
||||
// selectIconModule.append($("<option></option>").val(moduleName).text(moduleName));
|
||||
var header = $('<div class="red-ui-icon-list-module"></div>').text(moduleName).appendTo(iconList);
|
||||
$('<i class="fa fa-cube"></i>').prependTo(header);
|
||||
icons.forEach(function(icon) {
|
||||
var iconDiv = $('<div>',{class:"red-ui-icon-list-icon"}).appendTo(iconList);
|
||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(iconDiv);
|
||||
var icon_url = RED.settings.apiRootUrl+"icons/"+moduleName+"/"+icon;
|
||||
iconDiv.data('icon',icon_url);
|
||||
if (backgroundColor) {
|
||||
nodeDiv.css({
|
||||
'backgroundColor': backgroundColor
|
||||
});
|
||||
}
|
||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
|
||||
RED.utils.createIconElement(icon_url, iconContainer, true);
|
||||
|
||||
if (iconPath.module === moduleName && iconPath.file === icon) {
|
||||
iconDiv.addClass("selected");
|
||||
}
|
||||
iconDiv.on("mouseover", function() {
|
||||
summary.text(icon);
|
||||
if (iconPath.module === moduleName && iconPath.file === icon) {
|
||||
iconDiv.addClass("selected");
|
||||
}
|
||||
iconDiv.on("mouseover", function() {
|
||||
summary.text(icon);
|
||||
})
|
||||
iconDiv.on("mouseout", function() {
|
||||
summary.html(" ");
|
||||
})
|
||||
iconDiv.on("click", function() {
|
||||
iconPanel.hide();
|
||||
done(moduleName+"/"+icon);
|
||||
})
|
||||
})
|
||||
iconDiv.on("mouseout", function() {
|
||||
summary.html(" ");
|
||||
})
|
||||
iconDiv.on("click", function() {
|
||||
hide();
|
||||
done(moduleName+"/"+icon);
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
setTimeout(function() {
|
||||
spinner.remove();
|
||||
},50);
|
||||
},300);
|
||||
var spinner = RED.utils.addSpinnerOverlay(iconList,true);
|
||||
var iconPanel = RED.popover.panel(picker);
|
||||
iconPanel.show({
|
||||
target: container
|
||||
})
|
||||
|
||||
|
||||
picker.slideDown(100);
|
||||
searchInput.trigger("focus");
|
||||
}
|
||||
|
||||
function createColorPicker(colorRow, color) {
|
||||
|
||||
var colorButton = $('<button type="button" class="red-ui-button red-ui-editor-node-appearance-button">').appendTo(colorRow);
|
||||
$('<i class="fa fa-caret-down"></i>').appendTo(colorButton);
|
||||
|
||||
var colorDisp = $('<div>',{class:"red-ui-search-result-node"}).appendTo(colorButton);
|
||||
|
||||
var selector = $("<input/>", {
|
||||
id: "red-ui-editor-node-color",
|
||||
type: "text",
|
||||
value: color
|
||||
}).css({
|
||||
marginLeft: "10px",
|
||||
width: "150px",
|
||||
}).appendTo(colorRow);
|
||||
|
||||
selector.on("change", function (e) {
|
||||
var color = selector.val();
|
||||
$(".red-ui-editor-node-appearance-button .red-ui-search-result-node").css({
|
||||
"background-color": color
|
||||
});
|
||||
});
|
||||
selector.trigger("change");
|
||||
colorButton.on("click", function (e) {
|
||||
var recommendedColors = [
|
||||
"#3FADB5", "#87A980", "#A6BBCF",
|
||||
"#AAAA66", "#C0C0C0", "#C0DEED",
|
||||
"#C7E9C0", "#D7D7A0", "#D8BFD8",
|
||||
"#DAC4B4", "#DEB887", "#DEBD5C",
|
||||
"#E2D96E", "#E6E0F8", "#E7E7AE",
|
||||
"#E9967A", "#F3B567", "#FDD0A2",
|
||||
"#FDF0C2", "#FFAAAA", "#FFCC66",
|
||||
"#FFF0F0", "#FFFFFF"
|
||||
].map(function(c) {
|
||||
var r = parseInt(c.substring(1, 3), 16) / 255;
|
||||
var g = parseInt(c.substring(3, 5), 16) / 255;
|
||||
var b = parseInt(c.substring(5, 7), 16) / 255;
|
||||
return {
|
||||
hex: c,
|
||||
r: r,
|
||||
g: g,
|
||||
b: b,
|
||||
l: 0.3 * r + 0.59 * g + 0.11 * b
|
||||
}
|
||||
});
|
||||
// Sort by luminosity.
|
||||
recommendedColors.sort(function (a, b) {
|
||||
return a.l - b.l;
|
||||
});
|
||||
|
||||
var numColors = recommendedColors.length;
|
||||
var width = 30;
|
||||
var height = 30;
|
||||
var margin = 2;
|
||||
var perRow = 6;
|
||||
var picker = $("<div/>", {
|
||||
class: "red-ui-color-picker"
|
||||
}).css({
|
||||
width: ((width+margin+margin)*perRow)+"px",
|
||||
height: Math.ceil(numColors/perRow)*(height+margin+margin)+"+px"
|
||||
});
|
||||
var count = 0;
|
||||
var row = null;
|
||||
recommendedColors.forEach(function (col) {
|
||||
if ((count % perRow) == 0) {
|
||||
row = $("<div/>").appendTo(picker);
|
||||
}
|
||||
var button = $("<button/>", {
|
||||
}).css({
|
||||
width: width+"px",
|
||||
height: height+"px",
|
||||
margin: margin+"px",
|
||||
backgroundColor: col.hex,
|
||||
"border-style": "solid",
|
||||
"border-width": "1px",
|
||||
"border-color": col.luma<0.92?col.hex:'#ccc'
|
||||
}).appendTo(row);
|
||||
button.on("click", function (e) {
|
||||
e.preventDefault();
|
||||
colorPanel.hide();
|
||||
selector.val(col.hex);
|
||||
selector.trigger("change");
|
||||
});
|
||||
count++;
|
||||
});
|
||||
var colorPanel = RED.popover.panel(picker);
|
||||
colorPanel.show({
|
||||
target: colorButton
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function buildAppearanceForm(container,node) {
|
||||
var dialogForm = $('<form class="dialog-form form-horizontal" autocomplete="off"></form>').appendTo(container);
|
||||
|
||||
var i,row;
|
||||
|
||||
if (node.type === "subflow") {
|
||||
var categoryRow = $("<div/>", {
|
||||
class: "form-row"
|
||||
}).appendTo(dialogForm);
|
||||
$("<label/>", {
|
||||
for: "subflow-appearance-input-category",
|
||||
"data-i18n": "editor:subflow.category"
|
||||
}).appendTo(categoryRow);
|
||||
var categorySelector = $("<select/>", {
|
||||
id: "subflow-appearance-input-category"
|
||||
}).css({
|
||||
width: "250px"
|
||||
}).appendTo(categoryRow);
|
||||
$("<input/>", {
|
||||
type: "text",
|
||||
id: "subflow-appearance-input-custom-category"
|
||||
}).css({
|
||||
display: "none",
|
||||
"margin-left": "10px",
|
||||
width: "calc(100% - 250px)"
|
||||
}).appendTo(categoryRow);
|
||||
|
||||
var categories = RED.palette.getCategories();
|
||||
categories.sort(function(A,B) {
|
||||
return A.label.localeCompare(B.label);
|
||||
})
|
||||
categories.forEach(function(cat) {
|
||||
categorySelector.append($("<option/>").val(cat.id).text(cat.label));
|
||||
})
|
||||
categorySelector.append($("<option/>").attr('disabled',true).text("---"));
|
||||
categorySelector.append($("<option/>").val("_custom_").text(RED._("palette.addCategory")));
|
||||
|
||||
$("#subflow-appearance-input-category").on("change", function() {
|
||||
var val = $(this).val();
|
||||
if (val === "_custom_") {
|
||||
$("#subflow-appearance-input-category").width(120);
|
||||
$("#subflow-appearance-input-custom-category").show();
|
||||
} else {
|
||||
$("#subflow-appearance-input-category").width(250);
|
||||
$("#subflow-appearance-input-custom-category").hide();
|
||||
}
|
||||
})
|
||||
|
||||
$("#subflow-appearance-input-category").val(node.category||"subflows");
|
||||
var userCount = 0;
|
||||
var subflowType = "subflow:"+node.id;
|
||||
|
||||
RED.nodes.eachNode(function(n) {
|
||||
if (n.type === subflowType) {
|
||||
userCount++;
|
||||
}
|
||||
});
|
||||
$("#red-ui-editor-subflow-user-count")
|
||||
.text(RED._("subflow.subflowInstances", {count:userCount})).show();
|
||||
}
|
||||
|
||||
$('<div class="form-row">'+
|
||||
'<label for="node-input-show-label-btn" data-i18n="editor.label"></label>'+
|
||||
'<button type="button" id="node-input-show-label-btn" class="red-ui-button" style="min-width: 80px; text-align: left;" type="button"><i id="node-input-show-label-btn-i" class="fa fa-toggle-on"></i> <span id="node-input-show-label-label"></span></button> '+
|
||||
'<input type="checkbox" id="node-input-show-label" style="display: none;"/>'+
|
||||
'<span style="margin-right: 2px;"/>'+
|
||||
'<input type="checkbox" id="node-input-show-label"/>'+
|
||||
'</div>').appendTo(dialogForm);
|
||||
|
||||
var setToggleState = function(state) {
|
||||
var i = $("#node-input-show-label-btn-i");
|
||||
if (!state) {
|
||||
i.addClass('fa-toggle-off');
|
||||
i.removeClass('fa-toggle-on');
|
||||
$("#node-input-show-label").prop("checked",false);
|
||||
$("#node-input-show-label-label").text(RED._("editor.hide"));
|
||||
} else {
|
||||
i.addClass('fa-toggle-on');
|
||||
i.removeClass('fa-toggle-off');
|
||||
$("#node-input-show-label").prop("checked",true);
|
||||
$("#node-input-show-label-label").text(RED._("editor.show"));
|
||||
}
|
||||
}
|
||||
dialogForm.find('#node-input-show-label-btn').on("click",function(e) {
|
||||
e.preventDefault();
|
||||
var i = $("#node-input-show-label-btn-i");
|
||||
setToggleState(i.hasClass('fa-toggle-off'));
|
||||
$("#node-input-show-label").toggleButton({
|
||||
enabledLabel: RED._("editor.show"),
|
||||
disabledLabel: RED._("editor.hide")
|
||||
})
|
||||
|
||||
if (!node.hasOwnProperty("l")) {
|
||||
// Show label if type not link
|
||||
node.l = !/^link (in|out)$/.test(node._def.type);
|
||||
}
|
||||
setToggleState(node.l);
|
||||
$("#node-input-show-label").prop("checked",node.l).trigger("change");
|
||||
|
||||
if (node.type === "subflow") {
|
||||
// subflow template can select its color
|
||||
var color = node.color ? node.color : "#da9";
|
||||
var colorRow = $("<div/>", {
|
||||
class: "form-row"
|
||||
}).appendTo(dialogForm);
|
||||
$("<label/>").text(RED._("editor.color")).appendTo(colorRow);
|
||||
createColorPicker(colorRow, color);
|
||||
}
|
||||
|
||||
|
||||
// If a node has icon property in defaults, the icon of the node cannot be modified. (e.g, ui_button node in dashboard)
|
||||
if ((!node._def.defaults || !node._def.defaults.hasOwnProperty("icon"))) {
|
||||
var iconRow = $('<div class="form-row"></div>').appendTo(dialogForm);
|
||||
$('<label data-i18n="editor.settingIcon">').appendTo(iconRow);
|
||||
|
||||
var iconButton = $('<button type="button" class="red-ui-button" id="red-ui-editor-node-icon-button">').appendTo(iconRow);
|
||||
|
||||
var iconButton = $('<button type="button" class="red-ui-button red-ui-editor-node-appearance-button">').appendTo(iconRow);
|
||||
$('<i class="fa fa-caret-down"></i>').appendTo(iconButton);
|
||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(iconButton);
|
||||
var colour = RED.utils.getNodeColor(node.type, node._def);
|
||||
var icon_url = RED.utils.getNodeIcon(node._def,node);
|
||||
@@ -998,21 +1003,30 @@ RED.editor = (function() {
|
||||
iconButton.on("click", function(e) {
|
||||
e.preventDefault();
|
||||
var iconPath;
|
||||
var icon = $("#red-ui-editor-node-icon").text()||"";
|
||||
var icon = $("#red-ui-editor-node-icon").val()||"";
|
||||
if (icon) {
|
||||
iconPath = RED.utils.separateIconPath(icon);
|
||||
} else {
|
||||
iconPath = RED.utils.getDefaultNodeIcon(node._def, node);
|
||||
}
|
||||
showIconPicker(iconRow,node,iconPath,function(newIcon) {
|
||||
$("#red-ui-editor-node-icon").text(newIcon||"");
|
||||
var backgroundColor = RED.utils.getNodeColor(node.type, node._def);
|
||||
if (node.type === "subflow") {
|
||||
backgroundColor = $("#red-ui-editor-node-color").val();
|
||||
}
|
||||
showIconPicker(iconButton,backgroundColor,iconPath,false,function(newIcon) {
|
||||
$("#red-ui-editor-node-icon").val(newIcon||"");
|
||||
var icon_url = RED.utils.getNodeIcon(node._def,{type:node.type,icon:newIcon});
|
||||
RED.utils.createIconElement(icon_url, iconContainer, true);
|
||||
});
|
||||
});
|
||||
$('<div id="red-ui-editor-node-icon">').text(node.icon).appendTo(iconButton);
|
||||
|
||||
RED.popover.tooltip(iconButton, function() {
|
||||
return $("#red-ui-editor-node-icon").val()||"default";
|
||||
})
|
||||
$('<input type="hidden" id="red-ui-editor-node-icon">').val(node.icon).appendTo(iconRow);
|
||||
}
|
||||
|
||||
|
||||
$('<div class="form-row"><span data-i18n="editor.portLabels"></span></div>').appendTo(dialogForm);
|
||||
|
||||
var inputCount = node.inputs || node._def.inputs || 0;
|
||||
@@ -1048,6 +1062,7 @@ RED.editor = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateLabels(editing_node, changes, outputMap) {
|
||||
var inputLabels = $("#red-ui-editor-node-label-form-inputs").children().find("input");
|
||||
var outputLabels = $("#red-ui-editor-node-label-form-outputs").children().find("input");
|
||||
@@ -1335,7 +1350,7 @@ RED.editor = (function() {
|
||||
}
|
||||
|
||||
if (!editing_node._def.defaults || !editing_node._def.defaults.hasOwnProperty("icon")) {
|
||||
var icon = $("#red-ui-editor-node-icon").text()||""
|
||||
var icon = $("#red-ui-editor-node-icon").val()||""
|
||||
if (!isDefaultIcon) {
|
||||
if (icon !== editing_node.icon) {
|
||||
changes.icon = editing_node.icon;
|
||||
@@ -1393,6 +1408,20 @@ RED.editor = (function() {
|
||||
node.l = true;
|
||||
}
|
||||
}
|
||||
if ($("#node-input-node-disabled").prop('checked')) {
|
||||
if (node.d !== true) {
|
||||
changes.d = node.d;
|
||||
changed = true;
|
||||
node.d = true;
|
||||
}
|
||||
} else {
|
||||
if (node.d === true) {
|
||||
changes.d = node.d;
|
||||
changed = true;
|
||||
delete node.d;
|
||||
}
|
||||
}
|
||||
|
||||
node.resize = true;
|
||||
|
||||
var oldInfo = node.info;
|
||||
@@ -1424,13 +1453,13 @@ RED.editor = (function() {
|
||||
|
||||
if (type === "subflow") {
|
||||
var old_env = editing_node.env;
|
||||
var new_env = exportEnvList($("#node-input-env-container").editableList("items"));
|
||||
if (!isSameEnv(old_env, new_env)) {
|
||||
var new_env = RED.subflow.exportSubflowInstanceEnv(editing_node);
|
||||
if (!isSameObj(old_env, new_env)) {
|
||||
editing_node.env = new_env;
|
||||
changes.env = editing_node.env;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
var wasChanged = editing_node.changed;
|
||||
@@ -1495,6 +1524,14 @@ RED.editor = (function() {
|
||||
var trayBody = tray.find('.red-ui-tray-body');
|
||||
trayBody.parent().css('overflow','hidden');
|
||||
|
||||
var trayFooterLeft = $('<div class="red-ui-tray-footer-left"></div>').appendTo(trayFooter)
|
||||
|
||||
$('<input id="node-input-node-disabled" type="checkbox">').prop("checked",!!node.d).appendTo(trayFooterLeft).toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
|
||||
var editorTabEl = $('<ul></ul>').appendTo(trayBody);
|
||||
var editorContent = $('<div></div>').appendTo(trayBody);
|
||||
|
||||
@@ -1540,6 +1577,19 @@ RED.editor = (function() {
|
||||
buildEditForm(nodePropertiesTab.content,"dialog-form",type,ns,node);
|
||||
editorTabs.addTab(nodePropertiesTab);
|
||||
|
||||
if (/^subflow:/.test(node.type)) {
|
||||
var subflowPropertiesTab = {
|
||||
id: "editor-subflow-envProperties",
|
||||
label: RED._("editor-tab.envProperties"),
|
||||
name: RED._("editor-tab.envProperties"),
|
||||
content: $('<div>', {class:"red-ui-tray-content"}).appendTo(editorContent).hide(),
|
||||
iconClass: "fa fa-list"
|
||||
};
|
||||
|
||||
RED.subflow.buildPropertiesForm(subflowPropertiesTab.content,node);
|
||||
editorTabs.addTab(subflowPropertiesTab);
|
||||
}
|
||||
|
||||
if (!node._def.defaults || !node._def.defaults.hasOwnProperty('info')) {
|
||||
var descriptionTab = {
|
||||
id: "editor-tab-description",
|
||||
@@ -1672,9 +1722,17 @@ RED.editor = (function() {
|
||||
var trayHeader = tray.find(".red-ui-tray-header");
|
||||
var trayBody = tray.find('.red-ui-tray-body');
|
||||
var trayFooter = tray.find(".red-ui-tray-footer");
|
||||
var userCountDiv;
|
||||
|
||||
var trayFooterLeft = $('<div class="red-ui-tray-footer-left"></div>').appendTo(trayFooter)
|
||||
|
||||
$('<input id="node-config-input-node-disabled" type="checkbox">').prop("checked",!!editing_config_node.d).appendTo(trayFooterLeft).toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
|
||||
if (node_def.hasUsers !== false) {
|
||||
userCountDiv = $('<div class="red-ui-tray-footer-left"><i class="fa fa-info-circle"></i> <span></span></div>').prependTo(trayFooter);
|
||||
$('<span><i class="fa fa-info-circle"></i> <span id="red-ui-editor-config-user-count"></span></span>').css("margin-left", "10px").appendTo(trayFooterLeft);
|
||||
}
|
||||
trayFooter.append('<span class="red-ui-tray-footer-right"><span id="red-ui-editor-config-scope-warning" data-i18n="[title]editor.errors.scopeChange"><i class="fa fa-warning"></i></span><select id="red-ui-editor-config-scope"></select></span>');
|
||||
|
||||
@@ -1768,8 +1826,8 @@ RED.editor = (function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (node_def.hasUsers !== false && userCountDiv) {
|
||||
userCountDiv.find("span").text(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show();
|
||||
if (node_def.hasUsers !== false) {
|
||||
$("#red-ui-editor-config-user-count").text(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show();
|
||||
}
|
||||
trayBody.i18n();
|
||||
trayFooter.i18n();
|
||||
@@ -1800,7 +1858,6 @@ RED.editor = (function() {
|
||||
var configId = editing_config_node.id;
|
||||
var configAdding = adding;
|
||||
var configTypeDef = RED.nodes.getType(configType);
|
||||
|
||||
if (configTypeDef.oneditcancel) {
|
||||
// TODO: what to pass as this to call
|
||||
if (configTypeDef.oneditcancel) {
|
||||
@@ -1904,6 +1961,16 @@ RED.editor = (function() {
|
||||
editing_config_node.label = configTypeDef.label;
|
||||
editing_config_node.z = scope;
|
||||
|
||||
if ($("#node-config-input-node-disabled").prop('checked')) {
|
||||
if (editing_config_node.d !== true) {
|
||||
editing_config_node.d = true;
|
||||
}
|
||||
} else {
|
||||
if (editing_config_node.d === true) {
|
||||
delete editing_config_node.d;
|
||||
}
|
||||
}
|
||||
|
||||
if (scope) {
|
||||
// Search for nodes that use this one that are no longer
|
||||
// in scope, so must be removed
|
||||
@@ -2058,7 +2125,7 @@ RED.editor = (function() {
|
||||
RED.nodes.eachConfig(function(config) {
|
||||
if (config.type == type && (!config.z || config.z === activeWorkspace.id)) {
|
||||
var label = RED.utils.getNodeLabel(config,config.id);
|
||||
config.__label__ = label;
|
||||
config.__label__ = label+(config.d?" ["+RED._("workspace.disabled")+"]":"");
|
||||
configNodes.push(config);
|
||||
}
|
||||
});
|
||||
@@ -2127,16 +2194,16 @@ RED.editor = (function() {
|
||||
if (updateLabels(editing_node, changes, null)) {
|
||||
changed = true;
|
||||
}
|
||||
var icon = $("#red-ui-editor-node-icon").text()||"";
|
||||
if ((editing_node.icon === undefined && icon !== "node-red/subflow.png") ||
|
||||
var icon = $("#red-ui-editor-node-icon").val()||"";
|
||||
if ((editing_node.icon === undefined && icon !== "node-red/subflow.svg") ||
|
||||
(editing_node.icon !== undefined && editing_node.icon !== icon)) {
|
||||
changes.icon = editing_node.icon;
|
||||
editing_node.icon = icon;
|
||||
changed = true;
|
||||
}
|
||||
var newCategory = $("#subflow-input-category").val().trim();
|
||||
var newCategory = $("#subflow-appearance-input-category").val().trim();
|
||||
if (newCategory === "_custom_") {
|
||||
newCategory = $("#subflow-input-custom-category").val().trim();
|
||||
newCategory = $("#subflow-appearance-input-custom-category").val().trim();
|
||||
if (newCategory === "") {
|
||||
newCategory = editing_node.category;
|
||||
}
|
||||
@@ -2150,14 +2217,22 @@ RED.editor = (function() {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
var oldColor = editing_node.color;
|
||||
var newColor = $("#red-ui-editor-node-color").val();
|
||||
if (oldColor !== newColor) {
|
||||
editing_node.color = newColor;
|
||||
changes.color = newColor;
|
||||
changed = true;
|
||||
RED.utils.clearNodeColorCache();
|
||||
}
|
||||
|
||||
var old_env = editing_node.env;
|
||||
var new_env = exportEnvList($("#node-input-env-container").editableList("items"));
|
||||
if (!isSameEnv(old_env, new_env)) {
|
||||
var new_env = RED.subflow.exportSubflowTemplateEnv($("#node-input-env-container").editableList("items"));
|
||||
if (!isSameObj(old_env, new_env)) {
|
||||
editing_node.env = new_env;
|
||||
changes.env = editing_node.env;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
RED.palette.refresh();
|
||||
|
||||
if (changed) {
|
||||
@@ -2171,6 +2246,7 @@ RED.editor = (function() {
|
||||
id:n.id,
|
||||
changed:n.changed
|
||||
})
|
||||
n._def.color = editing_node.color;
|
||||
n.changed = true;
|
||||
n.dirty = true;
|
||||
updateNodeProperties(n);
|
||||
@@ -2198,21 +2274,39 @@ RED.editor = (function() {
|
||||
],
|
||||
resize: function(size) {
|
||||
$(".red-ui-tray-content").height(size.height - 50);
|
||||
// var form = $(".red-ui-tray-content form").height(size.height - 50 - 40);
|
||||
var rows = $("#dialog-form>div:not(.node-input-env-container-row)");
|
||||
var height = size.height;
|
||||
for (var i=0; i<rows.size(); i++) {
|
||||
height -= $(rows[i]).outerHeight(true);
|
||||
var envContainer = $("#node-input-env-container");
|
||||
if (envContainer.length) {
|
||||
// var form = $(".red-ui-tray-content form").height(size.height - 50 - 40);
|
||||
var rows = $("#dialog-form>div:not(#subflow-env-tabs-content)");
|
||||
var height = size.height;
|
||||
for (var i=0; i<rows.size(); i++) {
|
||||
height -= $(rows[i]).outerHeight(true);
|
||||
}
|
||||
// var editorRow = $("#dialog-form>div.node-input-env-container-row");
|
||||
// height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
|
||||
$("#node-input-env-container").editableList('height',height-95);
|
||||
}
|
||||
var editorRow = $("#dialog-form>div.node-input-env-container-row");
|
||||
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
|
||||
$("#node-input-env-container").editableList('height',height-80);
|
||||
},
|
||||
open: function(tray) {
|
||||
var trayFooter = tray.find(".red-ui-tray-footer");
|
||||
var trayFooterLeft = $("<div/>", {
|
||||
class: "red-ui-tray-footer-left"
|
||||
}).appendTo(trayFooter)
|
||||
var trayBody = tray.find('.red-ui-tray-body');
|
||||
trayBody.parent().css('overflow','hidden');
|
||||
|
||||
if (editing_node.type === "subflow") {
|
||||
var span = $("<span/>").css({
|
||||
"margin-left": "10px"
|
||||
}).appendTo(trayFooterLeft);
|
||||
$("<i/>", {
|
||||
class: "fa fa-info-circle"
|
||||
}).appendTo(span);
|
||||
$("<span/>").text(" ").appendTo(span);
|
||||
$("<i/>", {
|
||||
id: "red-ui-editor-subflow-user-count"
|
||||
}).appendTo(span);
|
||||
}
|
||||
|
||||
if (editing_node) {
|
||||
RED.sidebar.info.refresh(editing_node);
|
||||
@@ -2272,46 +2366,9 @@ RED.editor = (function() {
|
||||
buildAppearanceForm(appearanceTab.content,editing_node);
|
||||
editorTabs.addTab(appearanceTab);
|
||||
|
||||
|
||||
|
||||
|
||||
$("#subflow-input-name").val(subflow.name);
|
||||
RED.text.bidi.prepareInput($("#subflow-input-name"));
|
||||
|
||||
$("#subflow-input-category").empty();
|
||||
var categories = RED.palette.getCategories();
|
||||
categories.sort(function(A,B) {
|
||||
return A.label.localeCompare(B.label);
|
||||
})
|
||||
categories.forEach(function(cat) {
|
||||
$("#subflow-input-category").append($("<option></option>").val(cat.id).text(cat.label));
|
||||
})
|
||||
$("#subflow-input-category").append($("<option></option>").attr('disabled',true).text("---"));
|
||||
$("#subflow-input-category").append($("<option></option>").val("_custom_").text(RED._("palette.addCategory")));
|
||||
|
||||
|
||||
$("#subflow-input-category").on("change", function() {
|
||||
var val = $(this).val();
|
||||
if (val === "_custom_") {
|
||||
$("#subflow-input-category").width(120);
|
||||
$("#subflow-input-custom-category").show();
|
||||
} else {
|
||||
$("#subflow-input-category").width(250);
|
||||
$("#subflow-input-custom-category").hide();
|
||||
}
|
||||
})
|
||||
|
||||
$("#subflow-input-category").val(subflow.category||"subflows");
|
||||
var userCount = 0;
|
||||
var subflowType = "subflow:"+editing_node.id;
|
||||
|
||||
RED.nodes.eachNode(function(n) {
|
||||
if (n.type === subflowType) {
|
||||
userCount++;
|
||||
}
|
||||
});
|
||||
$("#subflow-dialog-user-count").text(RED._("subflow.subflowInstances", {count:userCount})).show();
|
||||
|
||||
trayBody.i18n();
|
||||
finishedBuilding = true;
|
||||
},
|
||||
@@ -2464,6 +2521,8 @@ RED.editor = (function() {
|
||||
validateNode: validateNode,
|
||||
updateNodeProperties: updateNodeProperties, // TODO: only exposed for edit-undo
|
||||
|
||||
showIconPicker:showIconPicker,
|
||||
|
||||
/**
|
||||
* Show a type editor.
|
||||
* @param {string} type - the type to display
|
||||
|
@@ -16,7 +16,419 @@
|
||||
(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="red-ui-button red-ui-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>';
|
||||
// var template = '<script type="text/x-red" data-template-name="_json"></script>';
|
||||
var template = '<script type="text/x-red" data-template-name="_json">'+
|
||||
'<ul id="red-ui-editor-type-json-tabs"></ul>'+
|
||||
'<div id="red-ui-editor-type-json-tab-raw" class="red-ui-editor-type-json-tab-content hide">'+
|
||||
'<div class="form-row" style="margin-bottom: 3px; text-align: right;">'+
|
||||
'<button id="node-input-json-reformat" class="red-ui-button red-ui-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>'+
|
||||
'</div>'+
|
||||
'<div id="red-ui-editor-type-json-tab-ui" class="red-ui-editor-type-json-tab-content hide">'+
|
||||
'<div id="red-ui-editor-type-json-tab-ui-container"></div>'+
|
||||
'</div>'+
|
||||
'</script>';
|
||||
|
||||
var activeTab;
|
||||
|
||||
function insertNewItem(parent,index,copyIndex) {
|
||||
var newValue = "";
|
||||
|
||||
if (parent.children.length > 0) {
|
||||
switch (parent.children[Math.max(0,Math.min(parent.children.length-1,copyIndex))].type) {
|
||||
case 'string': newValue = ""; break;
|
||||
case 'number': newValue = 0; break;
|
||||
case 'boolean': newValue = true; break;
|
||||
case 'null': newValue = null; break;
|
||||
case 'object': newValue = {}; break;
|
||||
case 'array': newValue = []; break;
|
||||
}
|
||||
}
|
||||
var newKey;
|
||||
if (parent.type === 'array') {
|
||||
newKey = parent.children.length;
|
||||
} else {
|
||||
var usedKeys = {};
|
||||
parent.children.forEach(function(child) { usedKeys[child.key] = true })
|
||||
var keyRoot = "item";
|
||||
var keySuffix = 2;
|
||||
newKey = keyRoot;
|
||||
while(usedKeys[newKey]) {
|
||||
newKey = keyRoot+"-"+(keySuffix++);
|
||||
}
|
||||
}
|
||||
var newItem = handleItem(newKey,newValue,parent.depth+1,parent);
|
||||
parent.treeList.insertChildAt(newItem, index, true);
|
||||
parent.treeList.expand();
|
||||
}
|
||||
function showObjectMenu(button,item) {
|
||||
var elementPos = button.offset();
|
||||
var options = [];
|
||||
if (item.parent) {
|
||||
options.push({id:"red-ui-editor-type-json-menu-insert-above", icon:"fa fa-toggle-up", label:RED._('jsonEditor.insertAbove'),onselect:function(){
|
||||
var index = item.parent.children.indexOf(item);
|
||||
insertNewItem(item.parent,index,index);
|
||||
}});
|
||||
options.push({id:"red-ui-editor-type-json-menu-insert-below", icon:"fa fa-toggle-down", label:RED._('jsonEditor.insertBelow'),onselect:function(){
|
||||
var index = item.parent.children.indexOf(item)+1;
|
||||
insertNewItem(item.parent,index,index-1);
|
||||
}});
|
||||
}
|
||||
if (item.type === 'array' || item.type === 'object') {
|
||||
options.push({id:"red-ui-editor-type-json-menu-add-child", icon:"fa fa-plus", label:RED._('jsonEditor.addItem'),onselect:function(){
|
||||
insertNewItem(item,item.children.length,item.children.length-1);
|
||||
}});
|
||||
}
|
||||
if (item.parent) {
|
||||
options.push({id:"red-ui-editor-type-json-menu-copy-path", icon:"fa fa-terminal", label:RED._('jsonEditor.copyPath'),onselect:function(){
|
||||
var i = item;
|
||||
var path = "";
|
||||
var newPath;
|
||||
while(i.parent) {
|
||||
if (i.parent.type === "array") {
|
||||
newPath = "["+i.key+"]";
|
||||
} else {
|
||||
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(i.key)) {
|
||||
newPath = i.key;
|
||||
} else {
|
||||
newPath = "[\""+i.key.replace(/"/,"\\\"")+"\"]"
|
||||
}
|
||||
}
|
||||
path = newPath+(path.length>0 && path[0] !== "["?".":"")+path;
|
||||
i = i.parent;
|
||||
}
|
||||
RED.clipboard.copyText(path,item.element,"clipboard.copyMessagePath");
|
||||
}});
|
||||
|
||||
options.push({id:"red-ui-editor-type-json-menu-duplicate", icon:"fa fa-copy", label:RED._("jsonEditor.duplicate"),onselect:function(){
|
||||
var newKey = item.key;
|
||||
if (item.parent.type === 'array') {
|
||||
newKey = parent.children.length;
|
||||
} else {
|
||||
var m = /^(.*?)(-(\d+))?$/.exec(newKey);
|
||||
var usedKeys = {};
|
||||
item.parent.children.forEach(function(child) { usedKeys[child.key] = true })
|
||||
var keyRoot = m[1];
|
||||
var keySuffix = 2;
|
||||
if (m[3] !== undefined) {
|
||||
keySuffix = parseInt(m[3]);
|
||||
}
|
||||
newKey = keyRoot;
|
||||
while(usedKeys[newKey]) {
|
||||
newKey = keyRoot+"-"+(keySuffix++);
|
||||
}
|
||||
}
|
||||
var newItem = handleItem(newKey,convertToObject(item),item.parent.depth+1,item.parent);
|
||||
var index = item.parent.children.indexOf(item)+1;
|
||||
|
||||
item.parent.treeList.insertChildAt(newItem, index, true);
|
||||
item.parent.treeList.expand();
|
||||
}});
|
||||
|
||||
options.push({id:"red-ui-editor-type-json-menu-delete", icon:"fa fa-times", label:RED._('common.label.delete'),onselect:function(){
|
||||
item.treeList.remove();
|
||||
}});
|
||||
}
|
||||
if (item.type === 'array' || item.type === 'object') {
|
||||
options.push(null)
|
||||
options.push({id:"red-ui-editor-type-json-menu-expand-children",icon:"fa fa-angle-double-down", label:RED._('jsonEditor.expandItems'),onselect:function(){
|
||||
item.treeList.expand();
|
||||
item.children.forEach(function(child) {
|
||||
child.treeList.expand();
|
||||
})
|
||||
}});
|
||||
options.push({id:"red-ui-editor-type-json-menu-collapse-children",icon:"fa fa-angle-double-up", label:RED._('jsonEditor.collapseItems'),onselect:function(){
|
||||
item.children.forEach(function(child) {
|
||||
child.treeList.collapse();
|
||||
})
|
||||
}});
|
||||
}
|
||||
|
||||
var menuOptionMenu = RED.menu.init({
|
||||
id:"red-ui-editor-type-json-menu",
|
||||
options: options
|
||||
});
|
||||
menuOptionMenu.css({
|
||||
position: "absolute"
|
||||
})
|
||||
menuOptionMenu.on('mouseleave', function(){ $(this).hide() });
|
||||
menuOptionMenu.on('mouseup', function() { $(this).hide() });
|
||||
menuOptionMenu.appendTo("body");
|
||||
var top = elementPos.top;
|
||||
var height = menuOptionMenu.height();
|
||||
var winHeight = $(window).height();
|
||||
if (top+height > winHeight) {
|
||||
top -= (top+height)-winHeight + 20;
|
||||
}
|
||||
menuOptionMenu.css({
|
||||
top: top+"px",
|
||||
left: elementPos.left+"px"
|
||||
})
|
||||
menuOptionMenu.show();
|
||||
}
|
||||
|
||||
function parseObject(obj,depth,parent) {
|
||||
var result = [];
|
||||
for (var prop in obj) {
|
||||
if (obj.hasOwnProperty(prop)) {
|
||||
result.push(handleItem(prop,obj[prop],depth,parent));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function parseArray(obj,depth,parent) {
|
||||
var result = [];
|
||||
var l = obj.length;
|
||||
for (var i=0;i<l;i++) {
|
||||
result.push(handleItem(i,obj[i],depth,parent));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function handleItem(key,val,depth,parent) {
|
||||
var item = {depth:depth, type: typeof val};
|
||||
var container = $('<span class="red-ui-editor-type-json-editor-label">');
|
||||
if (key != null) {
|
||||
item.key = key;
|
||||
var keyText;
|
||||
if (typeof key === 'string') {
|
||||
keyText = '"'+key+'"';
|
||||
} else {
|
||||
keyText = key;
|
||||
}
|
||||
var keyLabel = $('<span class="red-ui-debug-msg-object-key red-ui-editor-type-json-editor-label-key">').text(keyText).appendTo(container);
|
||||
keyLabel.addClass('red-ui-debug-msg-type-'+(typeof key));
|
||||
if (parent && parent.type === "array") {
|
||||
keyLabel.addClass("red-ui-editor-type-json-editor-label-array-key")
|
||||
}
|
||||
|
||||
keyLabel.on("click", function(evt) {
|
||||
if (item.parent.type === 'array') {
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
var w = Math.max(150,keyLabel.width());
|
||||
var keyInput = $('<input type="text" class="red-ui-editor-type-json-editor-key">').css({width:w+"px"}).val(""+item.key).insertAfter(keyLabel).typedInput({types:['str']});
|
||||
$(document).on("mousedown.nr-ui-json-editor", function(evt) {
|
||||
var typedInputElement = keyInput.next(".red-ui-typedInput-container")[0];
|
||||
var target = evt.target;
|
||||
while (target.nodeName !== 'BODY' && target !== typedInputElement && !$(target).hasClass("red-ui-typedInput-options")) {
|
||||
target = target.parentElement;
|
||||
}
|
||||
if (target.nodeName === 'BODY') {
|
||||
var newKey = keyInput.typedInput("value");
|
||||
item.key = newKey;
|
||||
var keyText;
|
||||
if (typeof newKey === 'string') {
|
||||
keyText = '"'+newKey+'"';
|
||||
} else {
|
||||
keyText = newKey;
|
||||
}
|
||||
keyLabel.text(keyText);
|
||||
keyInput.remove();
|
||||
keyLabel.show();
|
||||
$(document).off("mousedown.nr-ui-json-editor");
|
||||
$(document).off("keydown.nr-ui-json-editor");
|
||||
}
|
||||
});
|
||||
$(document).on("keydown.nr-ui-json-editor",function(evt) {
|
||||
if (evt.keyCode === 27) {
|
||||
// Escape
|
||||
keyInput.remove();
|
||||
keyLabel.show();
|
||||
$(document).off("mousedown.nr-ui-json-editor");
|
||||
$(document).off("keydown.nr-ui-json-editor");
|
||||
}
|
||||
});
|
||||
keyLabel.hide();
|
||||
});
|
||||
$('<span>').text(" : ").appendTo(container);
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
item.expanded = depth < 2;
|
||||
item.type = "array";
|
||||
item.deferBuild = depth >= 2;
|
||||
item.children = parseArray(val,depth+1,item);
|
||||
} else if (val !== null && item.type === "object") {
|
||||
item.expanded = depth < 2;
|
||||
item.children = parseObject(val,depth+1,item);
|
||||
item.deferBuild = depth >= 2;
|
||||
} else {
|
||||
item.value = val;
|
||||
if (val === null) {
|
||||
item.type = 'null'
|
||||
}
|
||||
}
|
||||
|
||||
var valType;
|
||||
var valValue = "";
|
||||
var valClass;
|
||||
switch(item.type) {
|
||||
case 'string': valType = 'str'; valValue = '"'+item.value+'"'; valClass = "red-ui-debug-msg-type-string"; break;
|
||||
case 'number': valType = 'num'; valValue = item.value; valClass = "red-ui-debug-msg-type-number";break;
|
||||
case 'boolean': valType = 'bool'; valValue = item.value; valClass = "red-ui-debug-msg-type-other";break;
|
||||
case 'null': valType = item.type; valValue = item.type; valClass = "red-ui-debug-msg-type-null";break;
|
||||
case 'object':
|
||||
valType = item.type;
|
||||
valValue = item.type;//+"{"+item.children.length+"}";
|
||||
valClass = "red-ui-debug-msg-type-meta";
|
||||
break;
|
||||
case 'array':
|
||||
valType = item.type;
|
||||
valValue = item.type+"["+item.children.length+"]";
|
||||
valClass = "red-ui-debug-msg-type-meta";
|
||||
break;
|
||||
}
|
||||
//
|
||||
var orphanedChildren;
|
||||
var valueLabel = $('<span class="red-ui-editor-type-json-editor-label-value">').addClass(valClass).text(valValue).appendTo(container);
|
||||
valueLabel.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
if (valType === 'str') {
|
||||
valValue = valValue.substring(1,valValue.length-1);
|
||||
} else if (valType === 'array') {
|
||||
valValue = "";
|
||||
} else if (valType === 'object') {
|
||||
valValue = "";
|
||||
}
|
||||
var w = Math.max(150,valueLabel.width());
|
||||
var val = $('<input type="text" class="red-ui-editor-type-json-editor-value">').css({width:w+"px"}).val(""+valValue).insertAfter(valueLabel).typedInput({
|
||||
types:[
|
||||
'str','num','bool',
|
||||
{value:"null",label:"null",hasValue:false},
|
||||
{value:"array",label:"array",hasValue:false},
|
||||
{value:"object",label:"object",hasValue:false}
|
||||
],
|
||||
default: valType
|
||||
});
|
||||
$(document).on("mousedown.nr-ui-json-editor", function(evt) {
|
||||
var typedInputElement = val.next(".red-ui-typedInput-container")[0];
|
||||
var target = evt.target;
|
||||
while (target.nodeName !== 'BODY' && target !== typedInputElement && !$(target).hasClass("red-ui-typedInput-options")) {
|
||||
target = target.parentElement;
|
||||
}
|
||||
if (target.nodeName === 'BODY') {
|
||||
valType = val.typedInput("type");
|
||||
valValue = val.typedInput("value");
|
||||
if (valType === 'num') {
|
||||
valValue = valValue.trim();
|
||||
if (isNaN(valValue)) {
|
||||
valType = 'str';
|
||||
} else if (valValue === "") {
|
||||
valValue = 0;
|
||||
}
|
||||
}
|
||||
item.value = valValue;
|
||||
var valClass;
|
||||
switch(valType) {
|
||||
case 'str': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "string"; valClass = "red-ui-debug-msg-type-string"; valValue = '"'+valValue+'"'; break;
|
||||
case 'num': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "number"; valClass = "red-ui-debug-msg-type-number"; break;
|
||||
case 'bool': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "boolean"; valClass = "red-ui-debug-msg-type-other"; item.value = (valValue === "true"); break;
|
||||
case 'null': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "null"; valClass = "red-ui-debug-msg-type-null"; item.value = valValue = "null"; break;
|
||||
case 'object':
|
||||
item.treeList.makeParent(orphanedChildren);
|
||||
item.type = "object";
|
||||
valClass = "red-ui-debug-msg-type-meta";
|
||||
item.value = valValue = "object";
|
||||
item.children.forEach(function(child,i) {
|
||||
if (child.hasOwnProperty('_key')) {
|
||||
child.key = child._key;
|
||||
delete child._key;
|
||||
var keyText;
|
||||
var keyLabel = child.element.find(".red-ui-editor-type-json-editor-label-key");
|
||||
keyLabel.removeClass("red-ui-editor-type-json-editor-label-array-key");
|
||||
if (typeof child.key === 'string') {
|
||||
keyText = '"'+child.key+'"';
|
||||
keyLabel.addClass('red-ui-debug-msg-type-string');
|
||||
keyLabel.removeClass('red-ui-debug-msg-type-number');
|
||||
} else {
|
||||
keyText = child.key;
|
||||
keyLabel.removeClass('red-ui-debug-msg-type-string');
|
||||
keyLabel.addClass('red-ui-debug-msg-type-number');
|
||||
}
|
||||
keyLabel.text(keyText);
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 'array':
|
||||
item.treeList.makeParent(orphanedChildren);
|
||||
item.type = "array";
|
||||
valClass = "red-ui-debug-msg-type-meta";
|
||||
item.value = valValue = "array["+(item.children.length)+"]";
|
||||
item.children.forEach(function(child,i) {
|
||||
child._key = child.key;
|
||||
child.key = i;
|
||||
child.element.find(".red-ui-editor-type-json-editor-label-key")
|
||||
.addClass("red-ui-editor-type-json-editor-label-array-key")
|
||||
.text(""+child.key)
|
||||
.removeClass('red-ui-debug-msg-type-string')
|
||||
.addClass('red-ui-debug-msg-type-number');
|
||||
})
|
||||
break;
|
||||
}
|
||||
valueLabel.text(valValue).removeClass().addClass("red-ui-editor-type-json-editor-label-value "+valClass);
|
||||
val.remove();
|
||||
valueLabel.show();
|
||||
$(document).off("mousedown.nr-ui-json-editor");
|
||||
$(document).off("keydown.nr-ui-json-editor");
|
||||
}
|
||||
})
|
||||
|
||||
$(document).on("keydown.nr-ui-json-editor",function(evt) {
|
||||
if (evt.keyCode === 27) {
|
||||
// Escape
|
||||
val.remove();
|
||||
valueLabel.show();
|
||||
if (valType === 'str') {
|
||||
valValue = '"'+valValue+'"';
|
||||
}
|
||||
$(document).off("mousedown.nr-ui-json-editor");
|
||||
$(document).off("keydown.nr-ui-json-editor");
|
||||
}
|
||||
});
|
||||
valueLabel.hide();
|
||||
})
|
||||
item.gutter = $('<span class="red-ui-editor-type-json-editor-item-gutter"></span>');
|
||||
|
||||
if (parent) {//red-ui-editor-type-json-editor-item-handle
|
||||
$('<span class="red-ui-editor-type-json-editor-item-handle"><i class="fa fa-bars"></span>').appendTo(item.gutter);
|
||||
} else {
|
||||
$('<span></span>').appendTo(item.gutter);
|
||||
}
|
||||
$('<button type="button" class="editor-button editor-button-small"><i class="fa fa-caret-down"></button>').appendTo(item.gutter).on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
showObjectMenu($(this), item);
|
||||
});
|
||||
item.element = container;
|
||||
return item;
|
||||
}
|
||||
function convertToObject(item) {
|
||||
var element;
|
||||
switch (item.type) {
|
||||
case 'string': element = item.value; break;
|
||||
case 'number': element = Number(item.value); break;
|
||||
case 'boolean': element = item.value; break;
|
||||
case 'null': element = null; break;
|
||||
case 'object':
|
||||
element = {};
|
||||
item.children.forEach(function(child) {
|
||||
element[child.key] = convertToObject(child);
|
||||
})
|
||||
break;
|
||||
case 'array':
|
||||
element = item.children.map(function(child) {
|
||||
return convertToObject(child);
|
||||
})
|
||||
break;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
var definition = {
|
||||
show: function(options) {
|
||||
@@ -41,9 +453,11 @@
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var rootNode;
|
||||
|
||||
var trayOptions = {
|
||||
title: options.title,
|
||||
width: "inherit",
|
||||
width: options.width||700,
|
||||
buttons: [
|
||||
{
|
||||
id: "node-dialog-cancel",
|
||||
@@ -60,25 +474,60 @@
|
||||
if (options.requireValid && !checkValid()) {
|
||||
return;
|
||||
}
|
||||
onComplete(expressionEditor.getValue());
|
||||
var result;
|
||||
if (activeTab === "json-ui") {
|
||||
if (rootNode) {
|
||||
result = JSON.stringify(convertToObject(rootNode),null,4);
|
||||
} else {
|
||||
result = expressionEditor.getValue();
|
||||
}
|
||||
} else if (activeTab === "json-raw") {
|
||||
result = expressionEditor.getValue();
|
||||
}
|
||||
onComplete && onComplete(result);
|
||||
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");
|
||||
var height = $(".red-ui-editor-type-json-tab-content").height();
|
||||
$(".node-text-editor").css("height",(height-45)+"px");
|
||||
expressionEditor.resize();
|
||||
},
|
||||
open: function(tray) {
|
||||
var trayBody = tray.find('.red-ui-tray-body');
|
||||
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
|
||||
|
||||
var container = $("#red-ui-editor-type-json-tab-ui-container").css({"height":"100%"});
|
||||
var filterDepth = Infinity;
|
||||
var list = $('<div class="red-ui-debug-msg-payload red-ui-editor-type-json-editor">').appendTo(container).treeList({
|
||||
rootSortable: false,
|
||||
sortable: ".red-ui-editor-type-json-editor-item-handle",
|
||||
}).on("treelistchangeparent", function(event, evt) {
|
||||
if (evt.old.type === 'array') {
|
||||
evt.old.element.find(".red-ui-editor-type-json-editor-label-type").text("array["+evt.old.children.length+"]");
|
||||
}
|
||||
if (evt.item.parent.type === 'array') {
|
||||
evt.item.parent.element.find(".red-ui-editor-type-json-editor-label-type").text("array["+evt.item.parent.children.length+"]");
|
||||
}
|
||||
}).on("treelistsort", function(event, item) {
|
||||
item.children.forEach(function(child,i) {
|
||||
if (item.type === 'array') {
|
||||
child.key = i;
|
||||
child.element.find(".red-ui-editor-type-json-editor-label-key")
|
||||
.text(child.key)
|
||||
.removeClass('red-ui-debug-msg-type-string')
|
||||
.addClass('red-ui-debug-msg-type-number');
|
||||
} else {
|
||||
child.element.find(".red-ui-editor-type-json-editor-label-key")
|
||||
.text('"'+child.key+'"')
|
||||
.removeClass('red-ui-debug-msg-type-number')
|
||||
.addClass('red-ui-debug-msg-type-string');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
expressionEditor = RED.editor.createEditor({
|
||||
id: 'node-input-json',
|
||||
value: "",
|
||||
@@ -103,9 +552,56 @@
|
||||
expressionEditor.getSession().setValue(v||"",-1);
|
||||
});
|
||||
dialogForm.i18n();
|
||||
|
||||
var finishedBuild = false;
|
||||
var tabs = RED.tabs.create({
|
||||
element: $("#red-ui-editor-type-json-tabs"),
|
||||
onchange:function(tab) {
|
||||
activeTab = tab.id;
|
||||
$(".red-ui-editor-type-json-tab-content").hide();
|
||||
if (finishedBuild) {
|
||||
if (tab.id === "json-raw") {
|
||||
if (rootNode) {
|
||||
var result = JSON.stringify(convertToObject(rootNode),null,4);
|
||||
expressionEditor.getSession().setValue(result||"",-1);
|
||||
}
|
||||
|
||||
} else if (tab.id === "json-ui") {
|
||||
var raw = expressionEditor.getValue().trim() ||"{}";
|
||||
try {
|
||||
var parsed = JSON.parse(raw);
|
||||
rootNode = handleItem(null,parsed,0,null);
|
||||
rootNode.class = "red-ui-editor-type-json-root-node"
|
||||
list.treeList('data',[rootNode]);
|
||||
} catch(err) {
|
||||
rootNode = null;
|
||||
list.treeList('data',[{
|
||||
label: "Invalid JSON: "+err.toString()
|
||||
}]);
|
||||
}
|
||||
}
|
||||
}
|
||||
tab.content.show();
|
||||
trayOptions.resize();
|
||||
}
|
||||
})
|
||||
|
||||
tabs.addTab({
|
||||
id: 'json-raw',
|
||||
label: RED._('jsonEditor.rawMode'),
|
||||
content: $("#red-ui-editor-type-json-tab-raw")
|
||||
});
|
||||
tabs.addTab({
|
||||
id: 'json-ui',
|
||||
label: RED._('jsonEditor.uiMode'),
|
||||
content: $("#red-ui-editor-type-json-tab-ui")
|
||||
});
|
||||
finishedBuild = true;
|
||||
|
||||
|
||||
},
|
||||
close: function() {
|
||||
expressionEditor.destroy();
|
||||
// expressionEditor.destroy();
|
||||
if (options.onclose) {
|
||||
options.onclose();
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ RED.keyboard = (function() {
|
||||
|
||||
var handlers = {};
|
||||
var partialState;
|
||||
RED.h = handlers;
|
||||
|
||||
var keyMap = {
|
||||
"left":37,
|
||||
"up":38,
|
||||
|
@@ -133,7 +133,7 @@ RED.library = (function() {
|
||||
icon: 'fa fa-folder',
|
||||
label: d,
|
||||
path: root+d+"/",
|
||||
children: function(item,done) {
|
||||
children: function(done, item) {
|
||||
loadLibraryFolder(library,type,root+d+"/", function(children) {
|
||||
item.children = children; // TODO: should this be done by treeList for us
|
||||
done(children);
|
||||
@@ -325,7 +325,7 @@ RED.library = (function() {
|
||||
|
||||
var menuOptionMenu = RED.menu.init({id:"red-ui-library-browser-menu",
|
||||
options: [
|
||||
{id:"red-ui-library-browser-menu-addFolder",label:"New folder", onselect: function() {
|
||||
{id:"red-ui-library-browser-menu-addFolder",label:RED._("library.newFolder"), onselect: function() {
|
||||
var defaultFolderName = "new-folder";
|
||||
var defaultFolderNameMatches = {};
|
||||
|
||||
@@ -431,11 +431,13 @@ RED.library = (function() {
|
||||
focus: function() {
|
||||
dirList.focus();
|
||||
},
|
||||
data: function(content) {
|
||||
data: function(content,selectFirst) {
|
||||
dirList.treeList('data',content);
|
||||
// setTimeout(function() {
|
||||
// dirList.treeList('select',content[0]);
|
||||
// },100);
|
||||
if (selectFirst) {
|
||||
setTimeout(function() {
|
||||
dirList.treeList('select',content[0]);
|
||||
},100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -149,13 +149,12 @@ RED.palette = (function() {
|
||||
RED.utils.createIconElement(icon_url, iconContainer, true);
|
||||
}
|
||||
|
||||
function escapeNodeType(nt) {
|
||||
return nt.replace(" ","_").replace(".","_").replace(":","_");
|
||||
function getPaletteNode(type) {
|
||||
return $(".red-ui-palette-node[data-palette-type='"+type+"']");
|
||||
}
|
||||
|
||||
function addNodeType(nt,def) {
|
||||
var nodeTypeId = escapeNodeType(nt);
|
||||
if ($("#red-ui-palette-node_"+nodeTypeId).length) {
|
||||
if (getPaletteNode(nt).length) {
|
||||
return;
|
||||
}
|
||||
if (exclusion.indexOf(def.category)===-1) {
|
||||
@@ -164,9 +163,7 @@ RED.palette = (function() {
|
||||
var category = def.category.replace(/ /g,"_");
|
||||
var rootCategory = category.split("-")[0];
|
||||
|
||||
var d = document.createElement("div");
|
||||
d.id = "red-ui-palette-node_"+nodeTypeId;
|
||||
d.type = nt;
|
||||
var d = $('<div>',{class:"red-ui-palette-node"}).attr("data-palette-type",nt).data('category',rootCategory);
|
||||
|
||||
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
|
||||
if (typeof def.paletteLabel !== "undefined") {
|
||||
@@ -182,7 +179,6 @@ RED.palette = (function() {
|
||||
+ (((!def.align && def.inputs !== 0 && def.outputs === 0) || "right" === def.align) ? " red-ui-palette-label-right" : "")
|
||||
}).appendTo(d);
|
||||
|
||||
d.className="red-ui-palette-node";
|
||||
|
||||
if (def.icon) {
|
||||
var icon_url = RED.utils.getNodeIcon(def);
|
||||
@@ -193,36 +189,35 @@ RED.palette = (function() {
|
||||
RED.utils.createIconElement(icon_url, iconContainer, true);
|
||||
}
|
||||
|
||||
d.style.backgroundColor = RED.utils.getNodeColor(nt,def);
|
||||
d.css("backgroundColor", RED.utils.getNodeColor(nt,def));
|
||||
|
||||
if (def.outputs > 0) {
|
||||
var portOut = document.createElement("div");
|
||||
portOut.className = "red-ui-palette-port red-ui-palette-port-output";
|
||||
d.appendChild(portOut);
|
||||
d.append(portOut);
|
||||
}
|
||||
|
||||
if (def.inputs > 0) {
|
||||
var portIn = document.createElement("div");
|
||||
portIn.className = "red-ui-palette-port red-ui-palette-port-input";
|
||||
d.appendChild(portIn);
|
||||
d.append(portIn);
|
||||
}
|
||||
|
||||
createCategory(def.category,rootCategory,category,(coreCategories.indexOf(rootCategory) !== -1)?"node-red":def.set.id);
|
||||
|
||||
$("#red-ui-palette-"+category).append(d);
|
||||
|
||||
$(d).data('category',rootCategory);
|
||||
|
||||
d.onmousedown = function(e) { e.preventDefault(); };
|
||||
d.on("mousedown", function(e) { e.preventDefault();});
|
||||
|
||||
var popover = RED.popover.create({
|
||||
target:$(d),
|
||||
target:d,
|
||||
trigger: "hover",
|
||||
width: "300px",
|
||||
content: "hi",
|
||||
delay: { show: 750, hide: 50 }
|
||||
});
|
||||
$(d).data('popover',popover);
|
||||
|
||||
d.data('popover',popover);
|
||||
|
||||
// $(d).popover({
|
||||
// title:d.type,
|
||||
@@ -232,18 +227,20 @@ RED.palette = (function() {
|
||||
// html: true,
|
||||
// container:'body'
|
||||
// });
|
||||
$(d).on("click", function() {
|
||||
d.on("click", function() {
|
||||
RED.view.focus();
|
||||
var helpText;
|
||||
if (nt.indexOf("subflow:") === 0) {
|
||||
helpText = marked(RED.nodes.subflow(nt.substring(8)).info||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
} else {
|
||||
helpText = $("script[data-help-name='"+d.type+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
helpText = $("script[data-help-name='"+d.attr("data-palette-type")+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
}
|
||||
// Don't look too closely. RED.sidebar.info.set will set the 'Description'
|
||||
// section of the sidebar. Pass in the title of the Help section so it looks
|
||||
// right.
|
||||
RED.sidebar.info.set(helpText,RED._("sidebar.info.nodeHelp"));
|
||||
});
|
||||
var chart = $("#red-ui-workspace-chart");
|
||||
var chartOffset = chart.offset();
|
||||
var chartSVG = $("#red-ui-workspace-chart>svg").get(0);
|
||||
var activeSpliceLink;
|
||||
var mouseX;
|
||||
@@ -267,8 +264,8 @@ RED.palette = (function() {
|
||||
ui.originalPosition.left = $('#' + e.target.id).offset().left;
|
||||
|
||||
if (def.inputs > 0 && def.outputs > 0) {
|
||||
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();
|
||||
mouseX = ui.position.left - paletteWidth + (ui.helper.width()/2) + chart.scrollLeft();
|
||||
mouseY = ui.position.top - paletteTop + (ui.helper.height()/2) + chart.scrollTop();
|
||||
if (!spliceTimer) {
|
||||
spliceTimer = setTimeout(function() {
|
||||
var nodes = [];
|
||||
@@ -330,13 +327,13 @@ RED.palette = (function() {
|
||||
|
||||
var nodeInfo = null;
|
||||
if (nt.indexOf("subflow:") === 0) {
|
||||
$(d).on("dblclick", function(e) {
|
||||
d.on("dblclick", function(e) {
|
||||
RED.workspaces.show(nt.substring(8));
|
||||
e.preventDefault();
|
||||
});
|
||||
nodeInfo = marked(def.info||"");
|
||||
}
|
||||
setLabel(nt,$(d),label,nodeInfo);
|
||||
setLabel(nt,d,label,nodeInfo);
|
||||
|
||||
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
|
||||
if (categoryNode.find(".red-ui-palette-node").length === 1) {
|
||||
@@ -347,8 +344,7 @@ RED.palette = (function() {
|
||||
}
|
||||
|
||||
function removeNodeType(nt) {
|
||||
var nodeTypeId = escapeNodeType(nt);
|
||||
var paletteNode = $("#red-ui-palette-node_"+nodeTypeId);
|
||||
var paletteNode = getPaletteNode(nt);
|
||||
var categoryNode = paletteNode.closest(".red-ui-palette-category");
|
||||
paletteNode.remove();
|
||||
if (categoryNode.find(".red-ui-palette-node").length === 0) {
|
||||
@@ -360,8 +356,7 @@ RED.palette = (function() {
|
||||
}
|
||||
|
||||
function hideNodeType(nt) {
|
||||
var nodeTypeId = escapeNodeType(nt);
|
||||
var paletteNode = $("#red-ui-palette-node_"+nodeTypeId);
|
||||
var paletteNode = getPaletteNode(nt);
|
||||
paletteNode.hide();
|
||||
var categoryNode = paletteNode.closest(".red-ui-palette-category");
|
||||
var cl = categoryNode.find(".red-ui-palette-node");
|
||||
@@ -373,8 +368,7 @@ RED.palette = (function() {
|
||||
}
|
||||
|
||||
function showNodeType(nt) {
|
||||
var nodeTypeId = escapeNodeType(nt);
|
||||
var paletteNode = $("#red-ui-palette-node_"+nodeTypeId);
|
||||
var paletteNode = getPaletteNode(nt);
|
||||
var categoryNode = paletteNode.closest(".red-ui-palette-category");
|
||||
categoryNode.show();
|
||||
paletteNode.show();
|
||||
@@ -382,7 +376,7 @@ RED.palette = (function() {
|
||||
|
||||
function refreshNodeTypes() {
|
||||
RED.nodes.eachSubflow(function(sf) {
|
||||
var paletteNode = $("#red-ui-palette-node_subflow_"+sf.id.replace(".","_"));
|
||||
var paletteNode = getPaletteNode('subflow:'+sf.id);
|
||||
var portInput = paletteNode.find(".red-ui-palette-port-input");
|
||||
var portOutput = paletteNode.find(".red-ui-palette-port-output");
|
||||
|
||||
@@ -396,7 +390,6 @@ RED.palette = (function() {
|
||||
+ (((!sf._def.align && sf.in.length !== 0 && sf.out.length === 0) || "right" === sf._def.align) ? " red-ui-palette-icon-container-right" : "")
|
||||
);
|
||||
|
||||
|
||||
if (portInput.length === 0 && sf.in.length > 0) {
|
||||
var portIn = document.createElement("div");
|
||||
portIn.className = "red-ui-palette-port red-ui-palette-port-input";
|
||||
@@ -422,7 +415,7 @@ RED.palette = (function() {
|
||||
createCategory(newCategory,category,category,"node-red");
|
||||
|
||||
var currentCategoryNode = paletteNode.closest(".red-ui-palette-category");
|
||||
var newCategoryNode = $("#palette-"+category);
|
||||
var newCategoryNode = $("#red-ui-palette-"+category);
|
||||
newCategoryNode.append(paletteNode);
|
||||
if (newCategoryNode.find(".red-ui-palette-node").length === 1) {
|
||||
categoryContainers[category].open();
|
||||
@@ -435,10 +428,9 @@ RED.palette = (function() {
|
||||
currentCategoryNode.find("i").toggleClass("expanded");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
paletteNode.css("backgroundColor", sf.color);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -446,7 +438,8 @@ RED.palette = (function() {
|
||||
var re = new RegExp(val.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'),'i');
|
||||
$("#red-ui-palette-container .red-ui-palette-node").each(function(i,el) {
|
||||
var currentLabel = $(el).find(".red-ui-palette-label").text();
|
||||
if (val === "" || re.test(el.id) || re.test(currentLabel)) {
|
||||
var type = $(el).attr("data-palette-type");
|
||||
if (val === "" || re.test(type) || re.test(currentLabel)) {
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
@@ -459,8 +452,10 @@ RED.palette = (function() {
|
||||
.find(".red-ui-palette-node")
|
||||
.filter(function() { return $(this).css('display') !== 'none'}).length === 0) {
|
||||
categoryContainers[category].close();
|
||||
categoryContainers[category].container.slideUp();
|
||||
} else {
|
||||
categoryContainers[category].open();
|
||||
categoryContainers[category].container.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,9 +534,6 @@ RED.palette = (function() {
|
||||
sidebarControls.hide();
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
var categoryList = coreCategories;
|
||||
if (RED.settings.paletteCategories) {
|
||||
categoryList = RED.settings.paletteCategories;
|
||||
@@ -599,7 +591,6 @@ RED.palette = (function() {
|
||||
setTimeout(function() { $(window).trigger("resize"); } ,200);
|
||||
}
|
||||
|
||||
|
||||
function getCategories() {
|
||||
var categories = [];
|
||||
$("#red-ui-palette-container .red-ui-palette-category").each(function(i,d) {
|
||||
|
@@ -25,6 +25,7 @@ RED.search = (function() {
|
||||
var index = {};
|
||||
var keys = [];
|
||||
var results = [];
|
||||
var previousActiveElement;
|
||||
|
||||
|
||||
function indexProperty(node,label,property) {
|
||||
@@ -216,7 +217,7 @@ RED.search = (function() {
|
||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
|
||||
RED.utils.createIconElement(icon_url, iconContainer, true);
|
||||
|
||||
var contentDiv = $('<div>',{class:"red-ui-search-result-description"}).appendTo(div);
|
||||
var contentDiv = $('<div>',{class:"red-ui-search-result-node-description"}).appendTo(div);
|
||||
if (node.z) {
|
||||
var workspace = RED.nodes.workspace(node.z);
|
||||
if (!workspace) {
|
||||
@@ -253,6 +254,7 @@ RED.search = (function() {
|
||||
return;
|
||||
}
|
||||
if (!visible) {
|
||||
previousActiveElement = document.activeElement;
|
||||
RED.keyboard.add("*","escape",function(){hide()});
|
||||
$("#red-ui-header-shade").show();
|
||||
$("#red-ui-editor-shade").show();
|
||||
@@ -286,6 +288,10 @@ RED.search = (function() {
|
||||
});
|
||||
}
|
||||
RED.events.emit("search:close");
|
||||
if (previousActiveElement) {
|
||||
$(previousActiveElement).trigger("focus");
|
||||
previousActiveElement = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +302,8 @@ RED.search = (function() {
|
||||
RED.events.on("editor:close",function() { disabled = false; });
|
||||
RED.events.on("type-search:open",function() { disabled = true; });
|
||||
RED.events.on("type-search:close",function() { disabled = false; });
|
||||
RED.events.on("actionList:open",function() { disabled = true; });
|
||||
RED.events.on("actionList:close",function() { disabled = false; });
|
||||
|
||||
|
||||
|
||||
|
@@ -145,7 +145,12 @@ RED.sidebar.config = (function() {
|
||||
var entry = $('<li class="red-ui-palette-node_id_'+node.id.replace(/\./g,"-")+'"></li>').appendTo(list);
|
||||
var nodeDiv = $('<div class="red-ui-palette-node-config red-ui-palette-node"></div>').appendTo(entry);
|
||||
entry.data('node',node.id);
|
||||
$('<div class="red-ui-palette-label"></div>').text(label).appendTo(nodeDiv);
|
||||
var label = $('<div class="red-ui-palette-label"></div>').text(label).appendTo(nodeDiv);
|
||||
if (node.d) {
|
||||
nodeDiv.addClass("red-ui-palette-node-config-disabled");
|
||||
$('<i class="fa fa-ban"></i>').prependTo(label);
|
||||
}
|
||||
|
||||
if (node._def.hasUsers !== false) {
|
||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container red-ui-palette-icon-container-right"}).appendTo(nodeDiv);
|
||||
if (node.users.length === 0) {
|
||||
@@ -257,7 +262,7 @@ RED.sidebar.config = (function() {
|
||||
RED.actions.add("core:delete-config-selection", function() {
|
||||
var selectedNodes = [];
|
||||
$(content).find(".red-ui-palette-node.selected").each(function() {
|
||||
selectedNodes.push($(this).data('node'));
|
||||
selectedNodes.push($(this).parent().data('node'));
|
||||
});
|
||||
if (selectedNodes.length > 0) {
|
||||
var historyEvent = {
|
||||
|
@@ -73,6 +73,7 @@ RED.sidebar.context = (function() {
|
||||
evt.preventDefault();
|
||||
updateNode(currentNode, true);
|
||||
})
|
||||
RED.popover.tooltip(bg,RED._("sidebar.context.refrsh"));
|
||||
|
||||
// subflowSection = sections.add({
|
||||
// title: "Subflow",
|
||||
@@ -87,7 +88,7 @@ RED.sidebar.context = (function() {
|
||||
// evt.stopPropagation();
|
||||
// evt.preventDefault();
|
||||
// })
|
||||
//
|
||||
// RED.popover.tooltip(bg,RED._("sidebar.context.refrsh"));
|
||||
// subflowSection.container.hide();
|
||||
|
||||
flowSection = sections.add({
|
||||
@@ -107,6 +108,7 @@ RED.sidebar.context = (function() {
|
||||
evt.preventDefault();
|
||||
updateFlow(currentFlow, true);
|
||||
})
|
||||
RED.popover.tooltip(bg,RED._("sidebar.context.refrsh"));
|
||||
|
||||
globalSection = sections.add({
|
||||
title: RED._("sidebar.context.global"),
|
||||
@@ -126,7 +128,7 @@ RED.sidebar.context = (function() {
|
||||
evt.preventDefault();
|
||||
updateEntry(globalSection,"context/global","global");
|
||||
})
|
||||
|
||||
RED.popover.tooltip(bg,RED._("sidebar.context.refrsh"));
|
||||
|
||||
RED.actions.add("core:show-context-tab",show);
|
||||
|
||||
@@ -272,6 +274,7 @@ RED.sidebar.context = (function() {
|
||||
}
|
||||
})
|
||||
});
|
||||
RED.popover.tooltip(refreshItem,RED._("sidebar.context.refrsh"));
|
||||
var deleteItem = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-trash"></i></button>').appendTo(tools).on("click", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -324,6 +327,7 @@ RED.sidebar.context = (function() {
|
||||
popover.open();
|
||||
|
||||
});
|
||||
RED.popover.tooltip(deleteItem,RED._("sidebar.context.delete"));
|
||||
var payload = v.msg;
|
||||
var format = v.format;
|
||||
RED.utils.createObjectElement(RED.utils.decodeObject(payload,format), {
|
||||
|
@@ -128,6 +128,7 @@ RED.sidebar.info = (function() {
|
||||
$(propertiesSection.content).empty();
|
||||
$(infoSection.content).empty();
|
||||
$(helpSection.content).empty();
|
||||
infoSection.title.text(RED._("sidebar.info.desc"));
|
||||
|
||||
var propRow;
|
||||
|
||||
@@ -464,7 +465,7 @@ RED.sidebar.info = (function() {
|
||||
propertiesSection.container.hide();
|
||||
helpSection.container.hide();
|
||||
infoSection.container.show();
|
||||
//helpSection.title.text(title||RED._("sidebar.info.info"));
|
||||
infoSection.title.text(title||RED._("sidebar.info.desc"));
|
||||
setInfoText(html,infoSection.content);
|
||||
$(".red-ui-sidebar-info-stack").scrollTop(0);
|
||||
}
|
||||
|
@@ -25,9 +25,12 @@ RED.tray = (function() {
|
||||
}
|
||||
function showTray(options) {
|
||||
var el = $('<div class="red-ui-tray"></div>');
|
||||
var header = $('<div class="red-ui-tray-header"></div>').appendTo(el);
|
||||
// `editor-tray-header` is deprecated - use red-ui-tray-body instead
|
||||
var header = $('<div class="red-ui-tray-header editor-tray-header"></div>').appendTo(el);
|
||||
var bodyWrapper = $('<div class="red-ui-tray-body-wrapper"></div>').appendTo(el);
|
||||
var body = $('<div class="red-ui-tray-body"></div>').appendTo(bodyWrapper);
|
||||
// `editor-tray-body` is deprecated - use red-ui-tray-body instead
|
||||
var body = $('<div class="red-ui-tray-body editor-tray-body"></div>').appendTo(bodyWrapper);
|
||||
// `editor-tray-footer` is deprecated - use red-ui-tray-footer instead
|
||||
var footer = $('<div class="red-ui-tray-footer"></div>').appendTo(el);
|
||||
var resizer = $('<div class="red-ui-tray-resize-handle"></div>').appendTo(el);
|
||||
// var growButton = $('<a class="red-ui-tray-resize-button" style="cursor: w-resize;"><i class="fa fa-angle-left"></i></a>').appendTo(resizer);
|
||||
|
@@ -13,6 +13,7 @@ RED.typeSearch = (function() {
|
||||
var activeFilter = "";
|
||||
var addCallback;
|
||||
var cancelCallback;
|
||||
var moveCallback;
|
||||
|
||||
var typesUsed = {};
|
||||
|
||||
@@ -44,6 +45,14 @@ RED.typeSearch = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function moveDialog(dx,dy) {
|
||||
var pos = dialog.position();
|
||||
pos.top = (pos.top + dy)+"px";
|
||||
pos.left = (pos.left + dx)+"px";
|
||||
dialog.css(pos);
|
||||
moveCallback(dx,dy);
|
||||
|
||||
}
|
||||
function createDialog() {
|
||||
dialog = $("<div>",{id:"red-ui-type-search",class:"red-ui-search red-ui-type-search"}).appendTo("#red-ui-main-container");
|
||||
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
||||
@@ -55,7 +64,19 @@ RED.typeSearch = (function() {
|
||||
});
|
||||
searchInput.on('keydown',function(evt) {
|
||||
var children = searchResults.children(":visible");
|
||||
if (children.length > 0) {
|
||||
if (evt.keyCode === 40 && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
moveDialog(0,10);
|
||||
} else if (evt.keyCode === 38 && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
moveDialog(0,-10);
|
||||
} else if (evt.keyCode === 39 && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
moveDialog(10,0);
|
||||
} else if (evt.keyCode === 37 && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
moveDialog(-10,0);
|
||||
} else if (children.length > 0) {
|
||||
if (evt.keyCode === 40) {
|
||||
// Down
|
||||
if (selected < children.length-1) {
|
||||
@@ -68,7 +89,6 @@ RED.typeSearch = (function() {
|
||||
ensureSelectedIsVisible();
|
||||
evt.preventDefault();
|
||||
} else if (evt.keyCode === 38) {
|
||||
// Up
|
||||
if (selected > 0) {
|
||||
if (selected < children.length) {
|
||||
$(children[selected]).removeClass('selected');
|
||||
@@ -79,6 +99,7 @@ RED.typeSearch = (function() {
|
||||
ensureSelectedIsVisible();
|
||||
evt.preventDefault();
|
||||
} else if ((evt.metaKey || evt.ctrlKey) && evt.keyCode === 13 ) {
|
||||
evt.preventDefault();
|
||||
// (ctrl or cmd) and enter
|
||||
var index = Math.max(0,selected);
|
||||
if (index < children.length) {
|
||||
@@ -90,8 +111,12 @@ RED.typeSearch = (function() {
|
||||
addCallback(n.type,true);
|
||||
}
|
||||
$("#red-ui-type-search-input").val("").trigger("keyup");
|
||||
setTimeout(function() {
|
||||
$("#red-ui-type-search-input").focus();
|
||||
},100);
|
||||
}
|
||||
} else if (evt.keyCode === 13) {
|
||||
evt.preventDefault();
|
||||
// Enter
|
||||
var index = Math.max(0,selected);
|
||||
if (index < children.length) {
|
||||
@@ -99,6 +124,12 @@ RED.typeSearch = (function() {
|
||||
confirm($(children[index]).find(".red-ui-editableList-item-content").data('data'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (evt.keyCode === 13 ) {
|
||||
// Stop losing focus if [Cmd]-Enter is pressed on an empty list
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -137,7 +168,7 @@ RED.typeSearch = (function() {
|
||||
if (object.separator) {
|
||||
container.addClass("red-ui-search-result-separator")
|
||||
}
|
||||
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
|
||||
var div = $('<div>',{class:"red-ui-search-result"}).appendTo(container);
|
||||
|
||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
|
||||
var colour = RED.utils.getNodeColor(object.type,def);
|
||||
@@ -219,6 +250,7 @@ RED.typeSearch = (function() {
|
||||
refreshTypeList(opts);
|
||||
addCallback = opts.add;
|
||||
cancelCallback = opts.cancel;
|
||||
moveCallback = opts.move;
|
||||
RED.events.emit("type-search:open");
|
||||
//shade.show();
|
||||
if ($("#red-ui-main-container").height() - opts.y - 150 < 0) {
|
||||
@@ -283,7 +315,7 @@ RED.typeSearch = (function() {
|
||||
function refreshTypeList(opts) {
|
||||
var i;
|
||||
searchResults.editableList('empty');
|
||||
searchInput.searchBox('value','');
|
||||
searchInput.searchBox('value','').focus();
|
||||
selected = -1;
|
||||
var common = [
|
||||
'inject','debug','function','change','switch'
|
||||
|
@@ -101,10 +101,19 @@ RED.userSettings = (function() {
|
||||
RED.tray.show(trayOptions);
|
||||
}
|
||||
|
||||
function localeToName(lc) {
|
||||
var name = RED._("languages."+lc);
|
||||
return {text: (name ? name : lc), val: lc};
|
||||
}
|
||||
|
||||
function compText(a, b) {
|
||||
return a.text.localeCompare(b.text);
|
||||
}
|
||||
|
||||
var viewSettings = [
|
||||
{
|
||||
options: [
|
||||
{setting:"editor-language",local: true, label:"menu.label.view.language",options:function(done){ done([{val:'',text:RED._('menu.label.view.browserDefault')}].concat(RED.settings.theme("languages"))) }},
|
||||
{setting:"editor-language",local: true, label:"menu.label.view.language",options:function(done){ done([{val:'',text:RED._('menu.label.view.browserDefault')}].concat(RED.settings.theme("languages").map(localeToName).sort(compText))) }},
|
||||
]
|
||||
},{
|
||||
title: "menu.label.view.grid",
|
||||
|
@@ -125,12 +125,14 @@ RED.utils = (function() {
|
||||
e.stopPropagation();
|
||||
RED.clipboard.copyText(key,copyPath,"clipboard.copyMessagePath");
|
||||
})
|
||||
RED.popover.tooltip(copyPath,RED._("node-red:debug.sidebar.copyPath"));
|
||||
}
|
||||
var copyPayload = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-clipboard"></i></button>').appendTo(copyTools).on("click", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
RED.clipboard.copyText(msg,copyPayload,"clipboard.copyMessageValue");
|
||||
})
|
||||
RED.popover.tooltip(copyPayload,RED._("node-red:debug.sidebar.copyPayload"));
|
||||
if (strippedKey !== undefined && strippedKey !== '') {
|
||||
var isPinned = pinnedPaths[sourceId].hasOwnProperty(strippedKey);
|
||||
|
||||
@@ -149,6 +151,7 @@ RED.utils = (function() {
|
||||
}
|
||||
}).toggleClass("selected",isPinned);
|
||||
obj.toggleClass("red-ui-debug-msg-row-pinned",isPinned);
|
||||
RED.popover.tooltip(pinPath,RED._("node-red:debug.sidebar.pinPath"));
|
||||
}
|
||||
if (extraTools) {
|
||||
extraTools.addClass("red-ui-debug-msg-tools-other");
|
||||
@@ -799,13 +802,13 @@ RED.utils = (function() {
|
||||
function getDefaultNodeIcon(def,node) {
|
||||
var icon_url;
|
||||
if (node && node.type === "subflow") {
|
||||
icon_url = "node-red/subflow.png";
|
||||
icon_url = "node-red/subflow.svg";
|
||||
} else if (typeof def.icon === "function") {
|
||||
try {
|
||||
icon_url = def.icon.call(node);
|
||||
} catch(err) {
|
||||
console.log("Definition error: "+def.type+".icon",err);
|
||||
icon_url = "arrow-in.png";
|
||||
icon_url = "arrow-in.svg";
|
||||
}
|
||||
} else {
|
||||
icon_url = def.icon;
|
||||
@@ -835,11 +838,11 @@ RED.utils = (function() {
|
||||
|
||||
function getNodeIcon(def,node) {
|
||||
if (def.category === 'config') {
|
||||
return RED.settings.apiRootUrl+"icons/node-red/cog.png"
|
||||
return RED.settings.apiRootUrl+"icons/node-red/cog.svg"
|
||||
} else if (node && node.type === 'tab') {
|
||||
return RED.settings.apiRootUrl+"icons/node-red/subflow.png"
|
||||
return RED.settings.apiRootUrl+"icons/node-red/subflow.svg"
|
||||
} else if (node && node.type === 'unknown') {
|
||||
return RED.settings.apiRootUrl+"icons/node-red/alert.png"
|
||||
return RED.settings.apiRootUrl+"icons/node-red/alert.svg"
|
||||
} else if (node && node.icon) {
|
||||
var iconPath = separateIconPath(node.icon);
|
||||
if (isIconExists(iconPath)) {
|
||||
@@ -848,6 +851,11 @@ RED.utils = (function() {
|
||||
} else {
|
||||
return RED.settings.apiRootUrl+"icons/" + node.icon;
|
||||
}
|
||||
} else if (iconPath.module !== "font-awesome" && /.png$/i.test(iconPath.file)) {
|
||||
iconPath.file = iconPath.file.replace(/.png$/,".svg");
|
||||
if (isIconExists(iconPath)) {
|
||||
return RED.settings.apiRootUrl+"icons/" + node.icon.replace(/.png$/,".svg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,17 +866,32 @@ RED.utils = (function() {
|
||||
} else {
|
||||
return RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file;
|
||||
}
|
||||
} else {
|
||||
// This could be a non-core node trying to use a core icon.
|
||||
iconPath.module = 'node-red';
|
||||
}
|
||||
|
||||
if (/.png$/i.test(iconPath.file)) {
|
||||
var originalFile = iconPath.file;
|
||||
iconPath.file = iconPath.file.replace(/.png$/,".svg");
|
||||
if (isIconExists(iconPath)) {
|
||||
return RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file;
|
||||
}
|
||||
iconPath.file = originalFile;
|
||||
}
|
||||
|
||||
// This could be a non-core node trying to use a core icon.
|
||||
iconPath.module = 'node-red';
|
||||
if (isIconExists(iconPath)) {
|
||||
return RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file;
|
||||
}
|
||||
if (/.png$/i.test(iconPath.file)) {
|
||||
iconPath.file = iconPath.file.replace(/.png$/,".svg");
|
||||
if (isIconExists(iconPath)) {
|
||||
return RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file;
|
||||
} else if (def.category === 'subflows') {
|
||||
return RED.settings.apiRootUrl+"icons/node-red/subflow.png";
|
||||
} else {
|
||||
return RED.settings.apiRootUrl+"icons/node-red/arrow-in.png";
|
||||
}
|
||||
}
|
||||
if (def.category === 'subflows') {
|
||||
return RED.settings.apiRootUrl+"icons/node-red/subflow.svg";
|
||||
}
|
||||
return RED.settings.apiRootUrl+"icons/node-red/arrow-in.svg";
|
||||
}
|
||||
|
||||
function getNodeLabel(node,defaultLabel) {
|
||||
@@ -889,6 +912,10 @@ RED.utils = (function() {
|
||||
}
|
||||
|
||||
var nodeColorCache = {};
|
||||
function clearNodeColorCache() {
|
||||
nodeColorCache = {};
|
||||
}
|
||||
|
||||
function getNodeColor(type, def) {
|
||||
var result = def.color;
|
||||
var paletteTheme = RED.settings.theme('palette.theme') || [];
|
||||
@@ -1004,7 +1031,7 @@ RED.utils = (function() {
|
||||
return;
|
||||
}
|
||||
// If the specified name is not defined in font-awesome, show arrow-in icon.
|
||||
iconUrl = RED.settings.apiRootUrl+"icons/node-red/arrow-in.png"
|
||||
iconUrl = RED.settings.apiRootUrl+"icons/node-red/arrow-in.svg"
|
||||
}
|
||||
var imageIconElement = $('<div/>',{class:"red-ui-palette-icon"}).appendTo(iconContainer);
|
||||
imageIconElement.css("backgroundImage", "url("+iconUrl+")");
|
||||
@@ -1021,6 +1048,7 @@ RED.utils = (function() {
|
||||
getNodeIcon: getNodeIcon,
|
||||
getNodeLabel: getNodeLabel,
|
||||
getNodeColor: getNodeColor,
|
||||
clearNodeColorCache: clearNodeColorCache,
|
||||
addSpinnerOverlay: addSpinnerOverlay,
|
||||
decodeObject: decodeObject,
|
||||
parseContextKey: parseContextKey,
|
||||
|
@@ -108,6 +108,168 @@ RED.view.tools = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function layoutFlow() {
|
||||
|
||||
var selection = RED.view.selection();
|
||||
if (!selection.nodes || selection.nodes.length !== 1) {
|
||||
RED.notify("Select exactly one node");
|
||||
return;
|
||||
}
|
||||
var ns = RED.nodes.getAllFlowNodes(selection.nodes[0]);
|
||||
|
||||
// Find Input node
|
||||
|
||||
var nodes = {};
|
||||
var minRank = 0;
|
||||
var stack = [];
|
||||
var candidateInputs = {};
|
||||
var candidateOutputs = {};
|
||||
ns.forEach(function(n) {
|
||||
candidateInputs[n.id] = n;
|
||||
candidateOutputs[n.id] = n;
|
||||
nodes[n.id] = {
|
||||
n:n,
|
||||
i:[],
|
||||
o:[],
|
||||
d:-1, // depth from start
|
||||
r:-1, // rank order at that depth
|
||||
downstream: 0
|
||||
}
|
||||
});
|
||||
RED.nodes.eachLink(function(link) {
|
||||
if (nodes[link.source.id] || nodes[link.target.id]) {
|
||||
nodes[link.source.id].o.push(link.target.id);
|
||||
nodes[link.target.id].i.push(link.source.id);
|
||||
delete candidateInputs[link.target.id]
|
||||
delete candidateOutputs[link.source.id]
|
||||
}
|
||||
})
|
||||
|
||||
var inputs = Object.keys(candidateInputs);
|
||||
var outputs = Object.keys(candidateOutputs);
|
||||
|
||||
if (inputs.length > 1) {
|
||||
RED.notify("Multiple start points - bailing")
|
||||
return;
|
||||
}
|
||||
|
||||
if (outputs.length === 0) {
|
||||
RED.notify("No outputs - is this a big loop? Bailing");
|
||||
return;
|
||||
}
|
||||
|
||||
function applyDepth(id,d) {
|
||||
if (nodes[id].d < d) {
|
||||
nodes[id].d = d;
|
||||
nodes[id].o.forEach(function(nid) {
|
||||
applyDepth(nid,d+1);
|
||||
})
|
||||
}
|
||||
}
|
||||
applyDepth(inputs[0],0)
|
||||
|
||||
function calculateDownstream(id,downstream) {
|
||||
nodes[id].downstream += downstream;
|
||||
nodes[id].i.forEach(function(nid) {
|
||||
calculateDownstream(nid, nodes[id].downstream+1);
|
||||
})
|
||||
}
|
||||
outputs.forEach(function(id) {
|
||||
calculateDownstream(id, 0)
|
||||
})
|
||||
|
||||
var ranks = {};
|
||||
function rankNodes(node) {
|
||||
if (node.r === -1) {
|
||||
ranks[node.d] = ranks[node.d] || [];
|
||||
node.r = ranks[node.d].length;
|
||||
ranks[node.d].push(node);
|
||||
node.o.sort(function(a,b) {
|
||||
return nodes[b].downstream - nodes[a].downstream
|
||||
})
|
||||
node.o.forEach(function(nid) {
|
||||
rankNodes(nodes[nid])
|
||||
})
|
||||
}
|
||||
}
|
||||
rankNodes(nodes[inputs[0]]);
|
||||
function shuffleRanks(node) {
|
||||
var pushed = false;
|
||||
if (node.o.length > 1) {
|
||||
var outputs = node.o.slice(0);
|
||||
outputs.sort(function(a,b) {
|
||||
if (nodes[a].d === nodes[b].d) {
|
||||
return nodes[a].r - nodes[b].r;
|
||||
} else {
|
||||
return nodes[b].d - nodes[a].d;
|
||||
}
|
||||
})
|
||||
// outputs.forEach(function(o,i) { console.log(" ",i," + "+nodes[o].n.type," d:",nodes[o].d," r:",nodes[o].r)});
|
||||
var rank = nodes[outputs[0]].r;
|
||||
var depth = nodes[outputs[0]].d;
|
||||
for (var i=1;i<outputs.length;i++) {
|
||||
// console.log(outputs[i]);
|
||||
var n = nodes[outputs[i]];
|
||||
if (n.d !== depth && n.r === rank) {
|
||||
// need to move n down one.
|
||||
var r = n.r;
|
||||
ns.forEach(function(_n) {
|
||||
var nn = nodes[_n.id];
|
||||
if (nn.d >= n.d && nn.d < depth && nn.r >= r) {
|
||||
pushed = true;
|
||||
nn.r++;
|
||||
}
|
||||
})
|
||||
}
|
||||
depth = n.d;
|
||||
rank = n.r;
|
||||
}
|
||||
}
|
||||
node.o.forEach(function(n) {
|
||||
pushed = pushed || shuffleRanks(nodes[n])
|
||||
})
|
||||
return pushed;
|
||||
}
|
||||
var shuffle = function() {
|
||||
if (shuffleRanks(nodes[inputs[0]])) {
|
||||
shuffle();
|
||||
}
|
||||
}
|
||||
shuffle();
|
||||
|
||||
|
||||
var x = nodes[inputs[0]].n.x;
|
||||
var y = nodes[inputs[0]].n.y;
|
||||
var changedNodes = [];
|
||||
ns.forEach(function(n) {
|
||||
var d = nodes[n.id].d;
|
||||
var r = nodes[n.id].r;
|
||||
|
||||
changedNodes.push({
|
||||
n:n,
|
||||
ox: n.x,
|
||||
oy: n.y,
|
||||
moved: n.moved
|
||||
});
|
||||
|
||||
n.x = x + d*200;
|
||||
n.y = y + r*50;
|
||||
n.dirty = true;
|
||||
// n.dirtyStatus = true;
|
||||
// n.status = {
|
||||
// text:"d"+d+" : r"+r+" : ds"+nodes[n.id].downstream
|
||||
// }
|
||||
});
|
||||
|
||||
if (changedNodes.length > 0) {
|
||||
RED.history.push({t:"move",nodes:changedNodes,dirty:RED.nodes.dirty()});
|
||||
RED.nodes.dirty(true);
|
||||
RED.view.redraw(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
init: function() {
|
||||
RED.actions.add("core:align-selection-to-grid", alignToGrid);
|
||||
@@ -121,6 +283,8 @@ RED.view.tools = (function() {
|
||||
RED.actions.add("core:step-selection-right", function() { moveSelection(RED.view.gridSize(),0);});
|
||||
RED.actions.add("core:step-selection-down", function() { moveSelection(0,RED.view.gridSize());});
|
||||
RED.actions.add("core:step-selection-left", function() { moveSelection(-RED.view.gridSize(),0);});
|
||||
|
||||
RED.actions.add("core:layout-flow", function() { layoutFlow() })
|
||||
},
|
||||
/**
|
||||
* Aligns all selected nodes to the current grid
|
||||
|
@@ -328,7 +328,7 @@ RED.view = (function() {
|
||||
accept:".red-ui-palette-node",
|
||||
drop: function( event, ui ) {
|
||||
d3.event = event;
|
||||
var selected_tool = ui.draggable[0].type;
|
||||
var selected_tool = $(ui.draggable[0]).attr("data-palette-type");
|
||||
var result = addNode(selected_tool);
|
||||
if (!result) {
|
||||
return;
|
||||
@@ -358,7 +358,7 @@ RED.view = (function() {
|
||||
|
||||
var spliceLink = $(ui.helper).data("splice");
|
||||
if (spliceLink) {
|
||||
// TODO: DRY - droppable/nodeMouseDown/canvasMouseUp
|
||||
// TODO: DRY - droppable/nodeMouseDown/canvasMouseUp/showQuickAddDialog
|
||||
RED.nodes.removeLink(spliceLink);
|
||||
var link1 = {
|
||||
source:spliceLink.source,
|
||||
@@ -406,10 +406,13 @@ RED.view = (function() {
|
||||
RED.actions.add("core:delete-selection",deleteSelection);
|
||||
RED.actions.add("core:edit-selected-node",editSelection);
|
||||
RED.actions.add("core:undo",RED.history.pop);
|
||||
RED.actions.add("core:redo",RED.history.redo);
|
||||
RED.actions.add("core:select-all-nodes",selectAll);
|
||||
RED.actions.add("core:zoom-in",zoomIn);
|
||||
RED.actions.add("core:zoom-out",zoomOut);
|
||||
RED.actions.add("core:zoom-reset",zoomZero);
|
||||
RED.actions.add("core:enable-selected-nodes", function() { setSelectedNodeState(false)});
|
||||
RED.actions.add("core:disable-selected-nodes", function() { setSelectedNodeState(true)});
|
||||
|
||||
RED.actions.add("core:toggle-show-grid",function(state) {
|
||||
if (state === undefined) {
|
||||
@@ -692,271 +695,8 @@ RED.view = (function() {
|
||||
}
|
||||
if (mouse_mode === 0 || mouse_mode === RED.state.QUICK_JOINING) {
|
||||
if (d3.event.metaKey || d3.event.ctrlKey) {
|
||||
point = d3.mouse(this);
|
||||
var ox = point[0];
|
||||
var oy = point[1];
|
||||
|
||||
if (RED.settings.get("editor").view['view-snap-grid']) {
|
||||
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','red')
|
||||
point[0] = Math.round(point[0] / gridSize) * gridSize;
|
||||
point[1] = Math.round(point[1] / gridSize) * gridSize;
|
||||
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','blue')
|
||||
}
|
||||
|
||||
d3.event.stopPropagation();
|
||||
var mainPos = $("#red-ui-main-container").position();
|
||||
|
||||
if (mouse_mode !== RED.state.QUICK_JOINING) {
|
||||
mouse_mode = RED.state.QUICK_JOINING;
|
||||
$(window).on('keyup',disableQuickJoinEventHandler);
|
||||
}
|
||||
quickAddActive = true;
|
||||
|
||||
if (ghostNode) {
|
||||
ghostNode.remove();
|
||||
}
|
||||
ghostNode = eventLayer.append("g").attr('transform','translate('+(point[0] - node_width/2)+','+(point[1] - node_height/2)+')');
|
||||
ghostNode.append("rect")
|
||||
.attr("class","red-ui-flow-node-placeholder")
|
||||
.attr("rx", 5)
|
||||
.attr("ry", 5)
|
||||
.attr("width",node_width)
|
||||
.attr("height",node_height)
|
||||
.attr("fill","none")
|
||||
// var ghostLink = ghostNode.append("svg:path")
|
||||
// .attr("class","red-ui-flow-link-link")
|
||||
// .attr("d","M 0 "+(node_height/2)+" H "+(gridSize * -2))
|
||||
// .attr("opacity",0);
|
||||
|
||||
var filter = undefined;
|
||||
if (drag_lines.length > 0) {
|
||||
if (drag_lines[0].virtualLink) {
|
||||
filter = {type:drag_lines[0].node.type === 'link in'?'link out':'link in'}
|
||||
} else if (drag_lines[0].portType === PORT_TYPE_OUTPUT) {
|
||||
filter = {input:true}
|
||||
} else {
|
||||
filter = {output:true}
|
||||
}
|
||||
|
||||
quickAddLink = {
|
||||
node: drag_lines[0].node,
|
||||
port: drag_lines[0].port,
|
||||
portType: drag_lines[0].portType,
|
||||
}
|
||||
if (drag_lines[0].virtualLink) {
|
||||
quickAddLink.virtualLink = true;
|
||||
}
|
||||
hideDragLines();
|
||||
}
|
||||
var rebuildQuickAddLink = function() {
|
||||
if (!quickAddLink) {
|
||||
return;
|
||||
}
|
||||
if (!quickAddLink.el) {
|
||||
quickAddLink.el = dragGroupLayer.append("svg:path").attr("class", "red-ui-flow-drag-line");
|
||||
}
|
||||
var numOutputs = (quickAddLink.portType === PORT_TYPE_OUTPUT)?(quickAddLink.node.outputs || 1):1;
|
||||
var sourcePort = quickAddLink.port;
|
||||
var portY = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
var sc = (quickAddLink.portType === PORT_TYPE_OUTPUT)?1:-1;
|
||||
quickAddLink.el.attr("d",generateLinkPath(quickAddLink.node.x+sc*quickAddLink.node.w/2,quickAddLink.node.y+portY,point[0]-sc*node_width/2,point[1],sc));
|
||||
}
|
||||
if (quickAddLink) {
|
||||
rebuildQuickAddLink();
|
||||
}
|
||||
|
||||
|
||||
var lastAddedX;
|
||||
var lastAddedWidth;
|
||||
|
||||
RED.typeSearch.show({
|
||||
x:d3.event.clientX-mainPos.left-node_width/2 - (ox-point[0]),
|
||||
y:d3.event.clientY-mainPos.top+ node_height/2 + 5 - (oy-point[1]),
|
||||
filter: filter,
|
||||
cancel: function() {
|
||||
if (quickAddLink) {
|
||||
if (quickAddLink.el) {
|
||||
quickAddLink.el.remove();
|
||||
}
|
||||
quickAddLink = null;
|
||||
}
|
||||
quickAddActive = false;
|
||||
if (ghostNode) {
|
||||
ghostNode.remove();
|
||||
}
|
||||
resetMouseVars();
|
||||
updateSelection();
|
||||
hideDragLines();
|
||||
redraw();
|
||||
},
|
||||
add: function(type,keepAdding) {
|
||||
var result = addNode(type);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
if (keepAdding) {
|
||||
mouse_mode = RED.state.QUICK_JOINING;
|
||||
}
|
||||
|
||||
var nn = result.node;
|
||||
var historyEvent = result.historyEvent;
|
||||
nn.x = point[0];
|
||||
nn.y = point[1];
|
||||
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
||||
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
nn.l = showLabel;
|
||||
}
|
||||
if (quickAddLink) {
|
||||
var drag_line = quickAddLink;
|
||||
var src = null,dst,src_port;
|
||||
if (drag_line.portType === PORT_TYPE_OUTPUT && (nn.inputs > 0 || drag_line.virtualLink) ) {
|
||||
src = drag_line.node;
|
||||
src_port = drag_line.port;
|
||||
dst = nn;
|
||||
} else if (drag_line.portType === PORT_TYPE_INPUT && (nn.outputs > 0 || drag_line.virtualLink)) {
|
||||
src = nn;
|
||||
dst = drag_line.node;
|
||||
src_port = 0;
|
||||
}
|
||||
|
||||
if (src !== null) {
|
||||
// Joining link nodes via virual wires. Need to update
|
||||
// the src and dst links property
|
||||
if (drag_line.virtualLink) {
|
||||
historyEvent = {
|
||||
t:'multi',
|
||||
events: [historyEvent]
|
||||
}
|
||||
var oldSrcLinks = $.extend(true,{},{v:src.links}).v
|
||||
var oldDstLinks = $.extend(true,{},{v:dst.links}).v
|
||||
src.links.push(dst.id);
|
||||
dst.links.push(src.id);
|
||||
src.dirty = true;
|
||||
dst.dirty = true;
|
||||
|
||||
historyEvent.events.push({
|
||||
t:'edit',
|
||||
node: src,
|
||||
dirty: RED.nodes.dirty(),
|
||||
changed: src.changed,
|
||||
changes: {
|
||||
links:oldSrcLinks
|
||||
}
|
||||
});
|
||||
historyEvent.events.push({
|
||||
t:'edit',
|
||||
node: dst,
|
||||
dirty: RED.nodes.dirty(),
|
||||
changed: dst.changed,
|
||||
changes: {
|
||||
links:oldDstLinks
|
||||
}
|
||||
});
|
||||
src.changed = true;
|
||||
dst.changed = true;
|
||||
} else {
|
||||
var link = {source: src, sourcePort:src_port, target: dst};
|
||||
RED.nodes.addLink(link);
|
||||
historyEvent.links = [link];
|
||||
}
|
||||
if (!keepAdding) {
|
||||
quickAddLink.el.remove();
|
||||
quickAddLink = null;
|
||||
if (mouse_mode === RED.state.QUICK_JOINING) {
|
||||
if (drag_line.portType === PORT_TYPE_OUTPUT && nn.outputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_OUTPUT}]);
|
||||
} else if (!quickAddLink && drag_line.portType === PORT_TYPE_INPUT && nn.inputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_INPUT}]);
|
||||
} else {
|
||||
resetMouseVars();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quickAddLink.node = nn;
|
||||
quickAddLink.port = 0;
|
||||
}
|
||||
} else {
|
||||
hideDragLines();
|
||||
resetMouseVars();
|
||||
}
|
||||
} else {
|
||||
if (!keepAdding) {
|
||||
if (mouse_mode === RED.state.QUICK_JOINING) {
|
||||
if (nn.outputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_OUTPUT}]);
|
||||
} else if (nn.inputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_INPUT}]);
|
||||
} else {
|
||||
resetMouseVars();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nn.outputs > 0) {
|
||||
quickAddLink = {
|
||||
node: nn,
|
||||
port: 0,
|
||||
portType: PORT_TYPE_OUTPUT
|
||||
}
|
||||
} else if (nn.inputs > 0) {
|
||||
quickAddLink = {
|
||||
node: nn,
|
||||
port: 0,
|
||||
portType: PORT_TYPE_INPUT
|
||||
}
|
||||
} else {
|
||||
resetMouseVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RED.history.push(historyEvent);
|
||||
RED.nodes.add(nn);
|
||||
RED.editor.validateNode(nn);
|
||||
RED.nodes.dirty(true);
|
||||
// auto select dropped node - so info shows (if visible)
|
||||
clearSelection();
|
||||
nn.selected = true;
|
||||
moving_set.push({n:nn});
|
||||
updateActiveNodes();
|
||||
updateSelection();
|
||||
redraw();
|
||||
// At this point the newly added node will have a real width,
|
||||
// so check if the position needs nudging
|
||||
if (lastAddedX !== undefined) {
|
||||
var lastNodeRHEdge = lastAddedX + lastAddedWidth/2;
|
||||
var thisNodeLHEdge = nn.x - nn.w/2;
|
||||
var gap = thisNodeLHEdge - lastNodeRHEdge;
|
||||
if (gap != gridSize *2) {
|
||||
nn.x = nn.x + gridSize * 2 - gap;
|
||||
nn.dirty = true;
|
||||
nn.x = Math.ceil(nn.x / gridSize) * gridSize;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
if (keepAdding) {
|
||||
if (lastAddedX === undefined) {
|
||||
// ghostLink.attr("opacity",1);
|
||||
setTimeout(function() {
|
||||
RED.typeSearch.refresh({filter:{input:true}});
|
||||
},100);
|
||||
}
|
||||
|
||||
lastAddedX = nn.x;
|
||||
lastAddedWidth = nn.w;
|
||||
|
||||
point[0] = nn.x + nn.w/2 + node_width/2 + gridSize * 2;
|
||||
ghostNode.attr('transform','translate('+(point[0] - node_width/2)+','+(point[1] - node_height/2)+')');
|
||||
rebuildQuickAddLink();
|
||||
} else {
|
||||
quickAddActive = false;
|
||||
ghostNode.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateActiveNodes();
|
||||
updateSelection();
|
||||
redraw();
|
||||
showQuickAddDialog(d3.mouse(this));
|
||||
}
|
||||
}
|
||||
if (mouse_mode === 0 && !(d3.event.metaKey || d3.event.ctrlKey)) {
|
||||
@@ -977,6 +717,302 @@ RED.view = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function showQuickAddDialog(point,spliceLink) {
|
||||
var ox = point[0];
|
||||
var oy = point[1];
|
||||
|
||||
if (RED.settings.get("editor").view['view-snap-grid']) {
|
||||
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','red')
|
||||
point[0] = Math.round(point[0] / gridSize) * gridSize;
|
||||
point[1] = Math.round(point[1] / gridSize) * gridSize;
|
||||
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','blue')
|
||||
}
|
||||
|
||||
var mainPos = $("#red-ui-main-container").position();
|
||||
|
||||
if (mouse_mode !== RED.state.QUICK_JOINING) {
|
||||
mouse_mode = RED.state.QUICK_JOINING;
|
||||
$(window).on('keyup',disableQuickJoinEventHandler);
|
||||
}
|
||||
quickAddActive = true;
|
||||
|
||||
if (ghostNode) {
|
||||
ghostNode.remove();
|
||||
}
|
||||
ghostNode = eventLayer.append("g").attr('transform','translate('+(point[0] - node_width/2)+','+(point[1] - node_height/2)+')');
|
||||
ghostNode.append("rect")
|
||||
.attr("class","red-ui-flow-node-placeholder")
|
||||
.attr("rx", 5)
|
||||
.attr("ry", 5)
|
||||
.attr("width",node_width)
|
||||
.attr("height",node_height)
|
||||
.attr("fill","none")
|
||||
// var ghostLink = ghostNode.append("svg:path")
|
||||
// .attr("class","red-ui-flow-link-link")
|
||||
// .attr("d","M 0 "+(node_height/2)+" H "+(gridSize * -2))
|
||||
// .attr("opacity",0);
|
||||
|
||||
var filter = undefined;
|
||||
if (drag_lines.length > 0) {
|
||||
if (drag_lines[0].virtualLink) {
|
||||
filter = {type:drag_lines[0].node.type === 'link in'?'link out':'link in'}
|
||||
} else if (drag_lines[0].portType === PORT_TYPE_OUTPUT) {
|
||||
filter = {input:true}
|
||||
} else {
|
||||
filter = {output:true}
|
||||
}
|
||||
|
||||
quickAddLink = {
|
||||
node: drag_lines[0].node,
|
||||
port: drag_lines[0].port,
|
||||
portType: drag_lines[0].portType,
|
||||
}
|
||||
if (drag_lines[0].virtualLink) {
|
||||
quickAddLink.virtualLink = true;
|
||||
}
|
||||
hideDragLines();
|
||||
} else if (spliceLink) {
|
||||
filter = {input:true, output:true}
|
||||
}
|
||||
var rebuildQuickAddLink = function() {
|
||||
if (!quickAddLink) {
|
||||
return;
|
||||
}
|
||||
if (!quickAddLink.el) {
|
||||
quickAddLink.el = dragGroupLayer.append("svg:path").attr("class", "red-ui-flow-drag-line");
|
||||
}
|
||||
var numOutputs = (quickAddLink.portType === PORT_TYPE_OUTPUT)?(quickAddLink.node.outputs || 1):1;
|
||||
var sourcePort = quickAddLink.port;
|
||||
var portY = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
var sc = (quickAddLink.portType === PORT_TYPE_OUTPUT)?1:-1;
|
||||
quickAddLink.el.attr("d",generateLinkPath(quickAddLink.node.x+sc*quickAddLink.node.w/2,quickAddLink.node.y+portY,point[0]-sc*node_width/2,point[1],sc));
|
||||
}
|
||||
if (quickAddLink) {
|
||||
rebuildQuickAddLink();
|
||||
}
|
||||
|
||||
|
||||
var lastAddedX;
|
||||
var lastAddedWidth;
|
||||
|
||||
RED.typeSearch.show({
|
||||
x:d3.event.clientX-mainPos.left-node_width/2 - (ox-point[0]),
|
||||
y:d3.event.clientY-mainPos.top+ node_height/2 + 5 - (oy-point[1]),
|
||||
filter: filter,
|
||||
move: function(dx,dy) {
|
||||
if (ghostNode) {
|
||||
var pos = d3.transform(ghostNode.attr("transform")).translate;
|
||||
ghostNode.attr("transform","translate("+(pos[0]+dx)+","+(pos[1]+dy)+")")
|
||||
point[0] += dx;
|
||||
point[1] += dy;
|
||||
rebuildQuickAddLink();
|
||||
}
|
||||
},
|
||||
cancel: function() {
|
||||
if (quickAddLink) {
|
||||
if (quickAddLink.el) {
|
||||
quickAddLink.el.remove();
|
||||
}
|
||||
quickAddLink = null;
|
||||
}
|
||||
quickAddActive = false;
|
||||
if (ghostNode) {
|
||||
ghostNode.remove();
|
||||
}
|
||||
resetMouseVars();
|
||||
updateSelection();
|
||||
hideDragLines();
|
||||
redraw();
|
||||
},
|
||||
add: function(type,keepAdding) {
|
||||
var result = addNode(type);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
if (keepAdding) {
|
||||
mouse_mode = RED.state.QUICK_JOINING;
|
||||
}
|
||||
|
||||
var nn = result.node;
|
||||
var historyEvent = result.historyEvent;
|
||||
nn.x = point[0];
|
||||
nn.y = point[1];
|
||||
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
||||
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
nn.l = showLabel;
|
||||
}
|
||||
if (!spliceLink) {
|
||||
if (quickAddLink) {
|
||||
var drag_line = quickAddLink;
|
||||
var src = null,dst,src_port;
|
||||
if (drag_line.portType === PORT_TYPE_OUTPUT && (nn.inputs > 0 || drag_line.virtualLink) ) {
|
||||
src = drag_line.node;
|
||||
src_port = drag_line.port;
|
||||
dst = nn;
|
||||
} else if (drag_line.portType === PORT_TYPE_INPUT && (nn.outputs > 0 || drag_line.virtualLink)) {
|
||||
src = nn;
|
||||
dst = drag_line.node;
|
||||
src_port = 0;
|
||||
}
|
||||
|
||||
if (src !== null) {
|
||||
// Joining link nodes via virual wires. Need to update
|
||||
// the src and dst links property
|
||||
if (drag_line.virtualLink) {
|
||||
historyEvent = {
|
||||
t:'multi',
|
||||
events: [historyEvent]
|
||||
}
|
||||
var oldSrcLinks = $.extend(true,{},{v:src.links}).v
|
||||
var oldDstLinks = $.extend(true,{},{v:dst.links}).v
|
||||
src.links.push(dst.id);
|
||||
dst.links.push(src.id);
|
||||
src.dirty = true;
|
||||
dst.dirty = true;
|
||||
|
||||
historyEvent.events.push({
|
||||
t:'edit',
|
||||
node: src,
|
||||
dirty: RED.nodes.dirty(),
|
||||
changed: src.changed,
|
||||
changes: {
|
||||
links:oldSrcLinks
|
||||
}
|
||||
});
|
||||
historyEvent.events.push({
|
||||
t:'edit',
|
||||
node: dst,
|
||||
dirty: RED.nodes.dirty(),
|
||||
changed: dst.changed,
|
||||
changes: {
|
||||
links:oldDstLinks
|
||||
}
|
||||
});
|
||||
src.changed = true;
|
||||
dst.changed = true;
|
||||
} else {
|
||||
var link = {source: src, sourcePort:src_port, target: dst};
|
||||
RED.nodes.addLink(link);
|
||||
historyEvent.links = [link];
|
||||
}
|
||||
if (!keepAdding) {
|
||||
quickAddLink.el.remove();
|
||||
quickAddLink = null;
|
||||
if (mouse_mode === RED.state.QUICK_JOINING) {
|
||||
if (drag_line.portType === PORT_TYPE_OUTPUT && nn.outputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_OUTPUT}]);
|
||||
} else if (!quickAddLink && drag_line.portType === PORT_TYPE_INPUT && nn.inputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_INPUT}]);
|
||||
} else {
|
||||
resetMouseVars();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quickAddLink.node = nn;
|
||||
quickAddLink.port = 0;
|
||||
}
|
||||
} else {
|
||||
hideDragLines();
|
||||
resetMouseVars();
|
||||
}
|
||||
} else {
|
||||
if (!keepAdding) {
|
||||
if (mouse_mode === RED.state.QUICK_JOINING) {
|
||||
if (nn.outputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_OUTPUT}]);
|
||||
} else if (nn.inputs > 0) {
|
||||
showDragLines([{node:nn,port:0,portType:PORT_TYPE_INPUT}]);
|
||||
} else {
|
||||
resetMouseVars();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nn.outputs > 0) {
|
||||
quickAddLink = {
|
||||
node: nn,
|
||||
port: 0,
|
||||
portType: PORT_TYPE_OUTPUT
|
||||
}
|
||||
} else if (nn.inputs > 0) {
|
||||
quickAddLink = {
|
||||
node: nn,
|
||||
port: 0,
|
||||
portType: PORT_TYPE_INPUT
|
||||
}
|
||||
} else {
|
||||
resetMouseVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resetMouseVars();
|
||||
// TODO: DRY - droppable/nodeMouseDown/canvasMouseUp/showQuickAddDialog
|
||||
RED.nodes.removeLink(spliceLink);
|
||||
var link1 = {
|
||||
source:spliceLink.source,
|
||||
sourcePort:spliceLink.sourcePort,
|
||||
target: nn
|
||||
};
|
||||
var link2 = {
|
||||
source:nn,
|
||||
sourcePort:0,
|
||||
target: spliceLink.target
|
||||
};
|
||||
RED.nodes.addLink(link1);
|
||||
RED.nodes.addLink(link2);
|
||||
historyEvent.links = [link1,link2];
|
||||
historyEvent.removedLinks = [spliceLink];
|
||||
}
|
||||
RED.history.push(historyEvent);
|
||||
RED.nodes.add(nn);
|
||||
RED.editor.validateNode(nn);
|
||||
RED.nodes.dirty(true);
|
||||
// auto select dropped node - so info shows (if visible)
|
||||
clearSelection();
|
||||
nn.selected = true;
|
||||
moving_set.push({n:nn});
|
||||
updateActiveNodes();
|
||||
updateSelection();
|
||||
redraw();
|
||||
// At this point the newly added node will have a real width,
|
||||
// so check if the position needs nudging
|
||||
if (lastAddedX !== undefined) {
|
||||
var lastNodeRHEdge = lastAddedX + lastAddedWidth/2;
|
||||
var thisNodeLHEdge = nn.x - nn.w/2;
|
||||
var gap = thisNodeLHEdge - lastNodeRHEdge;
|
||||
if (gap != gridSize *2) {
|
||||
nn.x = nn.x + gridSize * 2 - gap;
|
||||
nn.dirty = true;
|
||||
nn.x = Math.ceil(nn.x / gridSize) * gridSize;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
if (keepAdding) {
|
||||
if (lastAddedX === undefined) {
|
||||
// ghostLink.attr("opacity",1);
|
||||
setTimeout(function() {
|
||||
RED.typeSearch.refresh({filter:{input:true}});
|
||||
},100);
|
||||
}
|
||||
|
||||
lastAddedX = nn.x;
|
||||
lastAddedWidth = nn.w;
|
||||
|
||||
point[0] = nn.x + nn.w/2 + node_width/2 + gridSize * 2;
|
||||
ghostNode.attr('transform','translate('+(point[0] - node_width/2)+','+(point[1] - node_height/2)+')');
|
||||
rebuildQuickAddLink();
|
||||
} else {
|
||||
quickAddActive = false;
|
||||
ghostNode.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateActiveNodes();
|
||||
updateSelection();
|
||||
redraw();
|
||||
}
|
||||
|
||||
function canvasMouseMove() {
|
||||
var i;
|
||||
var node;
|
||||
@@ -1367,24 +1403,31 @@ RED.view = (function() {
|
||||
|
||||
function zoomIn() {
|
||||
if (scaleFactor < 2) {
|
||||
scaleFactor += 0.1;
|
||||
RED.view.navigator.resize();
|
||||
redraw();
|
||||
zoomView(scaleFactor+0.1);
|
||||
}
|
||||
}
|
||||
function zoomOut() {
|
||||
if (scaleFactor > 0.3) {
|
||||
scaleFactor -= 0.1;
|
||||
RED.view.navigator.resize();
|
||||
redraw();
|
||||
zoomView(scaleFactor-0.1);
|
||||
}
|
||||
}
|
||||
function zoomZero() {
|
||||
scaleFactor = 1;
|
||||
function zoomZero() { zoomView(1); }
|
||||
|
||||
function zoomView(factor) {
|
||||
var screenSize = [chart.width(),chart.height()];
|
||||
var scrollPos = [chart.scrollLeft(),chart.scrollTop()];
|
||||
var center = [(scrollPos[0] + screenSize[0]/2)/scaleFactor,(scrollPos[1] + screenSize[1]/2)/scaleFactor];
|
||||
scaleFactor = factor;
|
||||
var newCenter = [(scrollPos[0] + screenSize[0]/2)/scaleFactor,(scrollPos[1] + screenSize[1]/2)/scaleFactor];
|
||||
var delta = [(newCenter[0]-center[0])*scaleFactor,(newCenter[1]-center[1])*scaleFactor]
|
||||
chart.scrollLeft(scrollPos[0]-delta[0]);
|
||||
chart.scrollTop(scrollPos[1]-delta[1]);
|
||||
|
||||
RED.view.navigator.resize();
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
function selectAll() {
|
||||
if (mouse_mode === RED.state.SELECTING_NODE && selectNodesOptions.single) {
|
||||
return;
|
||||
@@ -1396,11 +1439,11 @@ RED.view = (function() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!n.selected) {
|
||||
n.selected = true;
|
||||
n.dirty = true;
|
||||
moving_set.push({n:n});
|
||||
if (!n.selected) {
|
||||
n.selected = true;
|
||||
n.dirty = true;
|
||||
moving_set.push({n:n});
|
||||
}
|
||||
}
|
||||
});
|
||||
if (mouse_mode !== RED.state.SELECTING_NODE && activeSubflow) {
|
||||
@@ -1923,7 +1966,7 @@ RED.view = (function() {
|
||||
}
|
||||
var link = {source: src, sourcePort:src_port, target: dst};
|
||||
if (drag_line.virtualLink) {
|
||||
if (/^link (in|out)$/.test(src.type) && /^link (in|out)$/.test(dst.type)) {
|
||||
if (/^link (in|out)$/.test(src.type) && /^link (in|out)$/.test(dst.type) && src.type !== dst.type) {
|
||||
if (src.links.indexOf(dst.id) === -1 && dst.links.indexOf(src.id) === -1) {
|
||||
var oldSrcLinks = $.extend(true,{},{v:src.links}).v
|
||||
var oldDstLinks = $.extend(true,{},{v:dst.links}).v
|
||||
@@ -2360,7 +2403,7 @@ RED.view = (function() {
|
||||
function isButtonEnabled(d) {
|
||||
var buttonEnabled = true;
|
||||
var ws = RED.nodes.workspace(RED.workspaces.active());
|
||||
if (ws && !ws.disabled) {
|
||||
if (ws && !ws.disabled && !d.d) {
|
||||
if (d._def.button.hasOwnProperty('enabled')) {
|
||||
if (typeof d._def.button.enabled === "function") {
|
||||
buttonEnabled = d._def.button.enabled.call(d);
|
||||
@@ -2381,7 +2424,7 @@ RED.view = (function() {
|
||||
}
|
||||
var activeWorkspace = RED.workspaces.active();
|
||||
var ws = RED.nodes.workspace(activeWorkspace);
|
||||
if (ws && !ws.disabled) {
|
||||
if (ws && !ws.disabled && !d.d) {
|
||||
if (d._def.button.toggle) {
|
||||
d[d._def.button.toggle] = !d[d._def.button.toggle];
|
||||
d.dirty = true;
|
||||
@@ -2445,14 +2488,22 @@ RED.view = (function() {
|
||||
.attr("class","red-ui-flow-node-icon")
|
||||
.attr("x",0)
|
||||
.attr("width","30")
|
||||
.attr("height","30");
|
||||
.attr("height","30")
|
||||
.style("display","none");
|
||||
|
||||
var img = new Image();
|
||||
img.src = iconUrl;
|
||||
img.onload = function() {
|
||||
icon.attr("width",Math.min(img.width,30));
|
||||
icon.attr("height",Math.min(img.height,30));
|
||||
icon.attr("x",15-Math.min(img.width,30)/2);
|
||||
var largestEdge = Math.max(img.width,img.height);
|
||||
var scaleFactor = 1;
|
||||
if (largestEdge > 30) {
|
||||
scaleFactor = 30/largestEdge;
|
||||
}
|
||||
var width = img.width * scaleFactor;
|
||||
var height = img.height * scaleFactor;
|
||||
icon.attr("width",width);
|
||||
icon.attr("height",height);
|
||||
icon.attr("x",15-width/2);
|
||||
icon.attr("xlink:href",iconUrl);
|
||||
icon.style("display",null);
|
||||
//if ("right" == d._def.align) {
|
||||
@@ -2913,6 +2964,7 @@ RED.view = (function() {
|
||||
d.resize = false;
|
||||
}
|
||||
var thisNode = d3.select(this);
|
||||
thisNode.classed("red-ui-flow-node-disabled", function(d) { return d.d === true});
|
||||
thisNode.classed("red-ui-flow-subflow",function(d) { return activeSubflow != null; })
|
||||
|
||||
//thisNode.selectAll(".centerDot").attr({"cx":function(d) { return d.w/2;},"cy":function(d){return d.h/2}});
|
||||
@@ -3137,9 +3189,9 @@ RED.view = (function() {
|
||||
} else {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(3,"+(d.h+3)+")");
|
||||
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
|
||||
thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass);
|
||||
thisNode.selectAll(".red-ui-flow-node-status").style("display","inline").attr("class","red-ui-flow-node-status "+statusClass);
|
||||
}
|
||||
if (d.status.text) {
|
||||
if (d.status.hasOwnProperty('text')) {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text);
|
||||
} else {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-label").text("");
|
||||
@@ -3177,6 +3229,10 @@ RED.view = (function() {
|
||||
redraw();
|
||||
focusView();
|
||||
d3.event.stopPropagation();
|
||||
if (d3.event.metaKey || d3.event.ctrlKey) {
|
||||
l.classed("red-ui-flow-link-splice",true);
|
||||
showQuickAddDialog(d3.mouse(this), selected_link);
|
||||
}
|
||||
})
|
||||
.on("touchstart",function(d) {
|
||||
if (mouse_mode === RED.state.SELECTING_NODE) {
|
||||
@@ -3232,6 +3288,7 @@ RED.view = (function() {
|
||||
}
|
||||
return path;
|
||||
});
|
||||
link.classed("red-ui-flow-node-disabled", function(d) { return d.source.d || d.target.d; });
|
||||
}
|
||||
})
|
||||
|
||||
@@ -3562,6 +3619,48 @@ RED.view = (function() {
|
||||
//TODO: subscribe/unsubscribe here
|
||||
redraw();
|
||||
}
|
||||
function setSelectedNodeState(isDisabled) {
|
||||
if (mouse_mode === RED.state.SELECTING_NODE) {
|
||||
return;
|
||||
}
|
||||
var workspaceSelection = RED.workspaces.selection();
|
||||
var changed = false;
|
||||
if (workspaceSelection.length > 0) {
|
||||
// TODO: toggle workspace state
|
||||
} else if (moving_set.length > 0) {
|
||||
var historyEvents = [];
|
||||
for (var i=0;i<moving_set.length;i++) {
|
||||
var node = moving_set[i].n;
|
||||
if (isDisabled != node.d) {
|
||||
historyEvents.push({
|
||||
t: "edit",
|
||||
node: node,
|
||||
changed: node.changed,
|
||||
changes: {
|
||||
d: node.d
|
||||
}
|
||||
});
|
||||
if (isDisabled) {
|
||||
node.d = true;
|
||||
} else {
|
||||
delete node.d;
|
||||
}
|
||||
node.dirty = true;
|
||||
node.changed = true;
|
||||
}
|
||||
}
|
||||
if (historyEvents.length > 0) {
|
||||
RED.history.push({
|
||||
t:"multi",
|
||||
events: historyEvents,
|
||||
dirty:RED.nodes.dirty()
|
||||
})
|
||||
RED.nodes.dirty(true)
|
||||
}
|
||||
}
|
||||
RED.view.redraw();
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
@@ -3632,12 +3731,12 @@ RED.view = (function() {
|
||||
node.dirty = true;
|
||||
RED.workspaces.show(node.z);
|
||||
|
||||
var screenSize = [chart.width(),chart.height()];
|
||||
var scrollPos = [chart.scrollLeft(),chart.scrollTop()];
|
||||
var screenSize = [chart.width()/scaleFactor,chart.height()/scaleFactor];
|
||||
var scrollPos = [chart.scrollLeft()/scaleFactor,chart.scrollTop()/scaleFactor];
|
||||
|
||||
if (node.x < scrollPos[0] || node.y < scrollPos[1] || node.x > screenSize[0]+scrollPos[0] || node.y > screenSize[1]+scrollPos[1]) {
|
||||
var deltaX = '-='+((scrollPos[0] - node.x) + screenSize[0]/2);
|
||||
var deltaY = '-='+((scrollPos[1] - node.y) + screenSize[1]/2);
|
||||
var deltaX = '-='+(((scrollPos[0] - node.x) + screenSize[0]/2)*scaleFactor);
|
||||
var deltaY = '-='+(((scrollPos[1] - node.y) + screenSize[1]/2)*scaleFactor);
|
||||
chart.animate({
|
||||
scrollLeft: deltaX,
|
||||
scrollTop: deltaY
|
||||
|
@@ -60,6 +60,13 @@ RED.workspaces = (function() {
|
||||
|
||||
function showEditWorkspaceDialog(id) {
|
||||
var workspace = RED.nodes.workspace(id);
|
||||
if (!workspace) {
|
||||
var subflow = RED.nodes.subflow(id);
|
||||
if (subflow) {
|
||||
RED.editor.editSubflow(subflow);
|
||||
}
|
||||
return;
|
||||
}
|
||||
RED.view.state(RED.state.EDITING);
|
||||
var tabflowEditor;
|
||||
var trayOptions = {
|
||||
@@ -194,8 +201,11 @@ RED.workspaces = (function() {
|
||||
} else {
|
||||
workspace.disabled = false;
|
||||
}
|
||||
$("#node-input-disabled").toggleButton({invertState: true})
|
||||
|
||||
$("#node-input-disabled").toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
|
||||
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
||||
dialogForm.on("submit", function(e) { e.preventDefault();});
|
||||
@@ -331,6 +341,8 @@ RED.workspaces = (function() {
|
||||
RED.actions.add("core:add-flow",function(opts) { addWorkspace(undefined,undefined,opts?opts.index:undefined)});
|
||||
RED.actions.add("core:edit-flow",editWorkspace);
|
||||
RED.actions.add("core:remove-flow",removeWorkspace);
|
||||
RED.actions.add("core:enable-flow",enableWorkspace);
|
||||
RED.actions.add("core:disable-flow",disableWorkspace);
|
||||
|
||||
RED.actions.add("core:list-flows",function() {
|
||||
RED.actions.invoke("core:search","type:tab ");
|
||||
@@ -343,6 +355,48 @@ RED.workspaces = (function() {
|
||||
showEditWorkspaceDialog(id||activeWorkspace);
|
||||
}
|
||||
|
||||
function enableWorkspace(id) {
|
||||
setWorkspaceState(id,false);
|
||||
}
|
||||
function disableWorkspace(id) {
|
||||
setWorkspaceState(id,true);
|
||||
}
|
||||
function setWorkspaceState(id,disabled) {
|
||||
var workspace = RED.nodes.workspace(id||activeWorkspace);
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
if (workspace.disabled !== disabled) {
|
||||
var changes = { disabled: workspace.disabled };
|
||||
workspace.disabled = disabled;
|
||||
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('red-ui-workspace-disabled',!!workspace.disabled);
|
||||
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!workspace.disabled);
|
||||
var historyEvent = {
|
||||
t: "edit",
|
||||
changes:changes,
|
||||
node: workspace,
|
||||
dirty: RED.nodes.dirty()
|
||||
}
|
||||
workspace.changed = true;
|
||||
RED.history.push(historyEvent);
|
||||
RED.nodes.dirty(true);
|
||||
RED.sidebar.config.refresh();
|
||||
var selection = RED.view.selection();
|
||||
if (!selection.nodes && !selection.links) {
|
||||
RED.sidebar.info.refresh(workspace);
|
||||
}
|
||||
if (changes.hasOwnProperty('disabled')) {
|
||||
RED.nodes.eachNode(function(n) {
|
||||
if (n.z === workspace.id) {
|
||||
n.dirty = true;
|
||||
}
|
||||
});
|
||||
RED.view.redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function removeWorkspace(ws) {
|
||||
if (!ws) {
|
||||
deleteWorkspace(RED.nodes.workspace(activeWorkspace));
|
||||
@@ -385,7 +439,7 @@ RED.workspaces = (function() {
|
||||
if (!workspace_tabs.contains(id)) {
|
||||
var sf = RED.nodes.subflow(id);
|
||||
if (sf) {
|
||||
addWorkspace({type:"subflow",id:id,icon:"red/images/subflow_tab.png",label:sf.name, closeable: true});
|
||||
addWorkspace({type:"subflow",id:id,icon:"red/images/subflow_tab.svg",label:sf.name, closeable: true});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -406,6 +460,8 @@ RED.workspaces = (function() {
|
||||
},
|
||||
resize: function() {
|
||||
workspace_tabs.resize();
|
||||
}
|
||||
},
|
||||
enable: enableWorkspace,
|
||||
disable: disableWorkspace
|
||||
}
|
||||
})();
|
||||
|
@@ -60,10 +60,12 @@
|
||||
.red-ui-icon-picker {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: $primary-text-color;
|
||||
}
|
||||
a:hover,
|
||||
a:focus {
|
||||
text-decoration: none;
|
||||
color: $primary-text-color;
|
||||
}
|
||||
|
||||
p {
|
||||
|
@@ -224,10 +224,10 @@ $node-status-colors: (
|
||||
$node-selected-color: #ff7f0e;
|
||||
$port-selected-color: #ff7f0e;
|
||||
|
||||
$link-color: #888;
|
||||
$link-link-color: #ccc;
|
||||
$link-color: #999;
|
||||
$link-link-color: #aaa;
|
||||
$link-disabled-color: #ccc;
|
||||
$link-link-active-color: #ff7f0e;
|
||||
$link-subflow-color: #bbb;
|
||||
$link-unknown-color: #f00;
|
||||
|
||||
$clipboard-textarea-background: #F3E7E7;
|
||||
|
@@ -221,7 +221,7 @@
|
||||
padding: 4px 2px 2px;
|
||||
position: relative;
|
||||
&.red-ui-debug-msg-row-pinned {
|
||||
background: $list-item-border-selected;
|
||||
background: $secondary-background-selected;
|
||||
}
|
||||
}
|
||||
.red-ui-debug-msg-expandable {
|
||||
|
@@ -79,6 +79,9 @@
|
||||
}
|
||||
|
||||
a {
|
||||
img {
|
||||
max-width: 14px;
|
||||
}
|
||||
.fa {
|
||||
width: 20px;
|
||||
margin-left: -25px;
|
||||
|
@@ -79,15 +79,20 @@
|
||||
.red-ui-tray-footer {
|
||||
@include component-footer;
|
||||
height: 35px;
|
||||
font-size: 12px !important;
|
||||
font-size: 14px !important;
|
||||
line-height: 35px;
|
||||
vertical-align: middle;
|
||||
|
||||
button {
|
||||
@include editor-button;
|
||||
padding: 3px 7px;
|
||||
font-size: 11px;
|
||||
button.red-ui-button {
|
||||
padding: 0px 8px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
&.toggle:not(.selected) {
|
||||
color: $workspace-button-color-selected !important;
|
||||
background: $workspace-button-background-active;
|
||||
}
|
||||
}
|
||||
|
||||
.red-ui-tray-footer-left {
|
||||
display:inline-block;
|
||||
margin-right: 20px;
|
||||
@@ -185,6 +190,10 @@ button.red-ui-tray-resize-button {
|
||||
border-color: $form-input-border-error-color !important;
|
||||
}
|
||||
|
||||
.input-updated {
|
||||
border-color: $node-selected-color !important;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
clear: both;
|
||||
color: $form-text-color;
|
||||
@@ -383,28 +392,26 @@ button.red-ui-button-small
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#red-ui-editor-node-icon-button {
|
||||
button.red-ui-button.red-ui-editor-node-appearance-button {
|
||||
position: relative;
|
||||
padding-left: 30px;
|
||||
width: calc(100% - 150px);
|
||||
height: 35px !important;
|
||||
text-align: left;
|
||||
padding: 0 6px 0 3px;
|
||||
>i {
|
||||
width: 15px;
|
||||
vertical-align: middle;
|
||||
padding-left: 2px;
|
||||
}
|
||||
.red-ui-search-result-node {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
vertical-align: middle;
|
||||
float: none;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
|
||||
}
|
||||
}
|
||||
#red-ui-editor-node-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: $secondary-background;
|
||||
z-Index: 21;
|
||||
display: none;
|
||||
select {
|
||||
box-sizing: border-box;
|
||||
margin: 3px;
|
||||
@@ -416,6 +423,16 @@ button.red-ui-button-small
|
||||
height: 200px;
|
||||
overflow-y: scroll;
|
||||
line-height: 0px;
|
||||
position: relative;
|
||||
&.red-ui-icon-list-dark {
|
||||
.red-ui-palette-icon-fa {
|
||||
color: $secondary-text-color;
|
||||
}
|
||||
.red-ui-palette-icon-container {
|
||||
background: $secondary-background;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.red-ui-icon-list-icon {
|
||||
display: inline-block;
|
||||
@@ -423,6 +440,7 @@ button.red-ui-button-small
|
||||
padding: 4px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
background: $list-item-background-hover;
|
||||
}
|
||||
@@ -461,3 +479,519 @@ button.red-ui-button-small
|
||||
margin: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.red-ui-editor input.red-ui-editor-type-json-editor-key {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.red-ui-editor-type-json-editor {
|
||||
height: calc(100% - 10px);
|
||||
.red-ui-treeList-container {
|
||||
background: $secondary-background;
|
||||
}
|
||||
.red-ui-treeList-label {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
white-space: nowrap;
|
||||
min-height: 35px;
|
||||
.red-ui-treeList-icon:before {
|
||||
content:'';
|
||||
display: inline-block;
|
||||
height: 35px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
> span, > span > span {
|
||||
vertical-align: middle;
|
||||
}
|
||||
&:hover, &:hover .red-ui-treeList-sublabel-text {
|
||||
background: $secondary-background-disabled;
|
||||
.red-ui-editor-type-json-editor-item-gutter {
|
||||
> span, > button {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.selected {
|
||||
.red-ui-editor-type-json-editor-item-gutter {
|
||||
background: $secondary-background-hover;
|
||||
}
|
||||
&:hover {
|
||||
.red-ui-editor-type-json-editor-item-gutter {
|
||||
background: $secondary-background-selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.red-ui-editor-type-json-root-node {
|
||||
.red-ui-editor-type-json-editor-item-gutter {
|
||||
> span, > button {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.red-ui-editor-type-json-editor-controls {
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
display: none;
|
||||
}
|
||||
.red-ui-editor-type-json-editor-key {
|
||||
width: 100px;
|
||||
}
|
||||
.red-ui-editor-type-json-editor-label {
|
||||
display: inline-block;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.red-ui-editor-type-json-editor-label-value {
|
||||
min-width: 200px;
|
||||
}
|
||||
.red-ui-editor-type-json-editor-label-value,
|
||||
.red-ui-editor-type-json-editor-label-key {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
min-height: 34px;
|
||||
line-height: 30px;
|
||||
padding: 0 2px;
|
||||
border: 2px solid rgba(0,0,0,0);
|
||||
border-radius: 3px;
|
||||
&:not(.red-ui-editor-type-json-editor-label-array-key):hover {
|
||||
border-color: $list-item-background-hover;
|
||||
border-style: dashed;
|
||||
}
|
||||
}
|
||||
.red-ui-editor-type-json-editor-item-gutter {
|
||||
width: 48px;
|
||||
padding-left: 4px;
|
||||
|
||||
height: 100%;
|
||||
line-height: 35px;
|
||||
color: $tertiary-text-color;
|
||||
background: $secondary-background-disabled;
|
||||
> span {
|
||||
display: inline-block;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
width: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
> span, > button {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.red-ui-editor-type-json-editor-item-handle {
|
||||
cursor: move;
|
||||
}
|
||||
.red-ui-editor-type-json-tab-content {
|
||||
position: relative;
|
||||
height: calc(100% - 40px);
|
||||
}
|
||||
|
||||
button.red-ui-toggleButton.toggle {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
.red-ui-editor-subflow-env-ui-row {
|
||||
margin-right: 3px;
|
||||
>div {
|
||||
display: grid;
|
||||
grid-template-columns: 16px 40px 35% auto;
|
||||
}
|
||||
>div:first-child {
|
||||
font-size: 0.9em;
|
||||
color: $tertiary-text-color;
|
||||
margin: 3px 0 -4px;
|
||||
>div {
|
||||
padding-left: 3px;
|
||||
}
|
||||
}
|
||||
>div:last-child {
|
||||
>div {
|
||||
height: 40px;
|
||||
line-height: 30px;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
// border-left: 2px dashed $secondary-border-color;
|
||||
// border-bottom: 2px dashed $secondary-border-color;
|
||||
// border: 1px dashed $secondary-border-color;
|
||||
border-right: none;
|
||||
&:not(:first-child) {
|
||||
padding: 3px;
|
||||
}
|
||||
// &:last-child {
|
||||
// border-right: 1px dashed $secondary-border-color;
|
||||
// }
|
||||
.placeholder-input {
|
||||
position: relative;
|
||||
padding: 0 3px;
|
||||
line-height: 24px;
|
||||
opacity: 0.8
|
||||
}
|
||||
.red-ui-typedInput-value-label,.red-ui-typedInput-option-label {
|
||||
select,.placeholder-input {
|
||||
margin: 3px;
|
||||
height: 26px;
|
||||
width: calc(100% - 10px);
|
||||
padding-left: 3px;
|
||||
}
|
||||
.placeholder-input {
|
||||
span:first-child {
|
||||
display:inline-block;
|
||||
height: 100%;
|
||||
width: 20px;
|
||||
text-align:center;
|
||||
border-right: 1px solid $secondary-border-color;
|
||||
background: $tertiary-background;
|
||||
}
|
||||
}
|
||||
input[type="checkbox"] {
|
||||
margin-left: 8px;
|
||||
margin-top: 0;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
>div:nth-child(1) {
|
||||
border: none;
|
||||
padding: 2px;
|
||||
.red-ui-editableList-item-handle {
|
||||
position:relative;
|
||||
top: 0px;
|
||||
color: $tertiary-text-color;
|
||||
}
|
||||
}
|
||||
>div:nth-child(2) {
|
||||
margin: 4px;
|
||||
height: 32px;
|
||||
border: 1px dashed $secondary-border-color;
|
||||
text-align: center;
|
||||
a {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
line-height: 32px;
|
||||
&:hover {
|
||||
background: $secondary-background-hover;
|
||||
}
|
||||
i {
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
>div:nth-child(3) {
|
||||
position: relative;
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span.red-ui-editor-subflow-env-lang-icon {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
background: $secondary-background;
|
||||
opacity: 0.8;
|
||||
width: 20px;
|
||||
line-height: 32px;
|
||||
height: 32px;
|
||||
text-align: center;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
|
||||
}
|
||||
// .red-ui-editor-subflow-ui-grid {
|
||||
// width: 100%;
|
||||
// .red-ui-editableList-container {
|
||||
// border: none;
|
||||
// border-radius: 0;
|
||||
// }
|
||||
// .red-ui-editableList-container li {
|
||||
// border: none;
|
||||
// padding: 0;
|
||||
// &:not(:first-child) .red-ui-editableList-item-content >div:first-child >div {
|
||||
// border-top: none;
|
||||
// }
|
||||
// &.ui-sortable-helper {
|
||||
// border: 2px dashed $secondary-border-color;
|
||||
// .red-ui-editableList-item-content {
|
||||
// >div {
|
||||
// border: none;
|
||||
// opacity: 0.7
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// .red-ui-editableList-item-content {
|
||||
// >div>div {
|
||||
// display: inline-block;
|
||||
// box-sizing: border-box;
|
||||
// border-left: 1px dashed $secondary-border-color;
|
||||
// border-bottom: 1px dashed $secondary-border-color;
|
||||
// }
|
||||
// >div:first-child {
|
||||
// font-size: 0.9em;
|
||||
// display: grid;
|
||||
// grid-template-columns: 25px auto 20px;
|
||||
// >div {
|
||||
// border-top: 1px dashed $secondary-border-color;
|
||||
// padding: 1px;
|
||||
// }
|
||||
// >div:nth-child(3) {
|
||||
// border-top: none;
|
||||
// border-bottom: none;
|
||||
// // width: 20px;
|
||||
// }
|
||||
// }
|
||||
// >div:last-child {
|
||||
// display: grid;
|
||||
// grid-template-columns: 25px 140px auto 20px;
|
||||
// >div {
|
||||
// height: 48px;
|
||||
// line-height: 30px;
|
||||
// // display: inline-block;
|
||||
// // height: 48px;
|
||||
// // line-height: 30px;
|
||||
// // box-sizing: border-box;
|
||||
// //
|
||||
// // border-left: 2px dashed $secondary-border-color;
|
||||
// border-top: none;
|
||||
// // border-bottom: 2px dashed $secondary-border-color;
|
||||
// &:not(:first-child) {
|
||||
// padding: 6px 3px;
|
||||
// }
|
||||
// .placeholder-input {
|
||||
// position: relative;
|
||||
// padding: 0 3px;
|
||||
// line-height: 24px;
|
||||
// opacity: 0.8
|
||||
// }
|
||||
// .red-ui-typedInput-value-label,.red-ui-typedInput-option-label {
|
||||
// select,.placeholder-input {
|
||||
// margin: 3px;
|
||||
// height: 26px;
|
||||
// width: calc(100% - 10px);
|
||||
// padding-left: 3px;
|
||||
// }
|
||||
// input[type="checkbox"] {
|
||||
// margin-left: 8px;
|
||||
// margin-top: 0;
|
||||
// height: 100%;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// >div:nth-child(1) {
|
||||
// text-align: center;
|
||||
// a {
|
||||
// display: block;
|
||||
// width: 100%;
|
||||
// height: 100%;
|
||||
// line-height: 45px;
|
||||
// &:hover {
|
||||
// background: $secondary-background-hover;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// >div:nth-child(2) {
|
||||
// input {
|
||||
// width: 100%;
|
||||
// }
|
||||
// // width: 140px;
|
||||
// }
|
||||
// >div:nth-child(3) {
|
||||
// position: relative;
|
||||
// .options-button {
|
||||
// position: absolute;
|
||||
// top: calc(50% - 10px);
|
||||
// margin-right: 2px;
|
||||
// right: 2px;
|
||||
// }
|
||||
// }
|
||||
// >div:nth-child(4) {
|
||||
// border-top: none;
|
||||
// border-bottom: none;
|
||||
// // width: 20px;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
.red-ui-editor-subflow-ui-edit-panel {
|
||||
padding-bottom: 3px;
|
||||
background: $primary-background;
|
||||
.red-ui-editableList-border {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
border-bottom: 1px solid $secondary-border-color;
|
||||
}
|
||||
.red-ui-editableList-container {
|
||||
}
|
||||
.red-ui-editableList-addButton {
|
||||
margin-left: 2px;
|
||||
}
|
||||
.red-ui-editableList-header {
|
||||
background: $primary-background;
|
||||
display: grid;
|
||||
grid-template-columns: 50% 50%;
|
||||
color: $secondary-text-color;
|
||||
div:first-child {
|
||||
padding-left: 23px;
|
||||
}
|
||||
div:last-child {
|
||||
padding-left: 3px;
|
||||
}
|
||||
}
|
||||
.red-ui-editableList-container {
|
||||
padding: 0 1px;
|
||||
li {
|
||||
background: $secondary-background;
|
||||
// border-bottom: none;
|
||||
padding: 0;
|
||||
.red-ui-editableList-item-content {
|
||||
display: grid;
|
||||
grid-template-columns: 50% 50%;
|
||||
>div {
|
||||
position:relative;
|
||||
|
||||
}
|
||||
}
|
||||
input {
|
||||
margin-bottom: 0;
|
||||
border:none;
|
||||
width: 100%;
|
||||
border-right: 1px solid $secondary-border-color;
|
||||
|
||||
border-radius: 0;
|
||||
&:focus {
|
||||
box-shadow: 0 0 0 1px inset $form-input-focus-color;
|
||||
}
|
||||
&:first-child {
|
||||
border-left: 1px solid $secondary-border-color;
|
||||
}
|
||||
}
|
||||
button.red-ui-typedInput-type-select, button.red-ui-typedInput-option-expand, button.red-ui-typedInput-option-trigger {
|
||||
border-radius: 0;
|
||||
height: 34px;
|
||||
}
|
||||
.red-ui-typedInput-container {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
input.red-ui-typedInput-input {
|
||||
height: 34px;
|
||||
border-right: none;
|
||||
}
|
||||
}
|
||||
|
||||
.red-ui-editor-subflow-env-lang-icon {
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
border-top-right-radius:0;
|
||||
border-bottom-right-radius:0;
|
||||
}
|
||||
.red-ui-editableList-item-remove {
|
||||
right: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.node-input-env-locales-row {
|
||||
position: relative;
|
||||
top: -20px;
|
||||
float: right;
|
||||
select {
|
||||
width: 160px;
|
||||
height: 20px;
|
||||
min-width: 20px;
|
||||
line-height: 18px;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
.node-input-env-container-row {
|
||||
min-width: 470px;
|
||||
position: relative;
|
||||
.red-ui-editableList-item-content {
|
||||
label {
|
||||
margin-bottom: 0;
|
||||
line-height: 32px;
|
||||
span {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
>div:first-child {
|
||||
display: grid;
|
||||
padding-left: 5px;
|
||||
grid-template-columns: 40% auto 37px;
|
||||
> :first-child {
|
||||
width: calc(100% - 5px);
|
||||
}
|
||||
input {
|
||||
width: calc(100% - 5px);
|
||||
}
|
||||
}
|
||||
&.red-ui-editor-subflow-env-editable {
|
||||
>div:first-child {
|
||||
padding-left: 0;
|
||||
grid-template-columns: 24px 40% auto 37px;
|
||||
> a:first-child {
|
||||
text-align: center;
|
||||
line-height: 32px;
|
||||
i.fa-angle-right {
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
&.expanded {
|
||||
i.fa-angle-right {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.red-ui-editableList-border .red-ui-editableList-header {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
|
||||
background: $tertiary-background;
|
||||
padding: 0;
|
||||
>div {
|
||||
display: grid;
|
||||
grid-template-columns: 24px 40% auto 37px;
|
||||
>div {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
.red-ui-editableList-container {
|
||||
padding: 0;
|
||||
.red-ui-editableList-item-handle {
|
||||
top: 25px;
|
||||
}
|
||||
.red-ui-editableList-item-remove {
|
||||
top: 25px;
|
||||
right: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
#subflow-input-ui {
|
||||
// .form-row {
|
||||
// display: grid;
|
||||
// grid-template-columns: 120px auto;
|
||||
// label span {
|
||||
// display: inline-block;
|
||||
// width: 20px;
|
||||
// text-align: center;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|