mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-11 14:52:55 +01:00
chore: clean up user nodes (#53)
This commit is contained in:
committed by
Richard Osborne
parent
b714b7774e
commit
365e96a1ac
@@ -1,18 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Node, EdgeTriggeredInput } = require('@noodl/runtime');
|
|
||||||
const UserService = require('./userservice');
|
const UserService = require('./userservice');
|
||||||
|
|
||||||
var LoginNodeDefinition = {
|
const LoginNodeDefinition = {
|
||||||
name: 'net.noodl.user.LogIn',
|
name: 'net.noodl.user.LogIn',
|
||||||
docs: 'https://docs.noodl.net/nodes/data/user/log-in',
|
docs: 'https://docs.noodl.net/nodes/data/user/log-in',
|
||||||
displayNodeName: 'Log In',
|
displayNodeName: 'Log In',
|
||||||
category: 'Cloud Services',
|
category: 'Cloud Services',
|
||||||
color: 'data',
|
color: 'data',
|
||||||
initialize: function () {
|
|
||||||
var internal = this._internal;
|
|
||||||
},
|
|
||||||
getInspectInfo() {},
|
|
||||||
outputs: {
|
outputs: {
|
||||||
success: {
|
success: {
|
||||||
type: 'signal',
|
type: 'signal',
|
||||||
@@ -28,7 +23,7 @@ var LoginNodeDefinition = {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
displayName: 'Error',
|
displayName: 'Error',
|
||||||
group: 'Error',
|
group: 'Error',
|
||||||
getter: function () {
|
getter() {
|
||||||
return this._internal.error;
|
return this._internal.error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +32,7 @@ var LoginNodeDefinition = {
|
|||||||
login: {
|
login: {
|
||||||
displayName: 'Do',
|
displayName: 'Do',
|
||||||
group: 'Actions',
|
group: 'Actions',
|
||||||
valueChangedToTrue: function () {
|
valueChangedToTrue() {
|
||||||
this.scheduleLogIn();
|
this.scheduleLogIn();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -45,7 +40,7 @@ var LoginNodeDefinition = {
|
|||||||
displayName: 'Username',
|
displayName: 'Username',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
group: 'General',
|
group: 'General',
|
||||||
set: function (value) {
|
set(value) {
|
||||||
this._internal.username = value;
|
this._internal.username = value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -53,13 +48,13 @@ var LoginNodeDefinition = {
|
|||||||
displayName: 'Password',
|
displayName: 'Password',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
group: 'General',
|
group: 'General',
|
||||||
set: function (value) {
|
set(value) {
|
||||||
this._internal.password = value;
|
this._internal.password = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setError: function (err) {
|
setError(err) {
|
||||||
this._internal.error = err;
|
this._internal.error = err;
|
||||||
this.flagOutputDirty('error');
|
this.flagOutputDirty('error');
|
||||||
this.sendSignalOnOutput('failure');
|
this.sendSignalOnOutput('failure');
|
||||||
@@ -76,9 +71,7 @@ var LoginNodeDefinition = {
|
|||||||
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scheduleLogIn: function () {
|
scheduleLogIn() {
|
||||||
const internal = this._internal;
|
|
||||||
|
|
||||||
if (this.logInScheduled === true) return;
|
if (this.logInScheduled === true) return;
|
||||||
this.logInScheduled = true;
|
this.logInScheduled = true;
|
||||||
|
|
||||||
@@ -100,89 +93,7 @@ var LoginNodeDefinition = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*function updatePorts(nodeId, parameters, editorConnection, dbCollections) {
|
|
||||||
var ports = [];
|
|
||||||
|
|
||||||
ports.push({
|
|
||||||
name: 'collectionName',
|
|
||||||
displayName: "Class",
|
|
||||||
group: "General",
|
|
||||||
type: { name: 'enum', enums: (dbCollections !== undefined) ? dbCollections.map((c) => { return { value: c.name, label: c.name } }) : [], allowEditOnly: true },
|
|
||||||
plug: 'input'
|
|
||||||
})
|
|
||||||
|
|
||||||
if (parameters.collectionName && dbCollections) {
|
|
||||||
// Fetch ports from collection keys
|
|
||||||
var c = dbCollections.find((c) => c.name === parameters.collectionName);
|
|
||||||
if (c && c.schema && c.schema.properties) {
|
|
||||||
var props = c.schema.properties;
|
|
||||||
for (var key in props) {
|
|
||||||
var p = props[key];
|
|
||||||
if (ports.find((_p) => _p.name === key)) continue;
|
|
||||||
|
|
||||||
if(p.type === 'Relation') {
|
|
||||||
|
|
||||||
}
|
|
||||||
else { // Other schema type ports
|
|
||||||
const _typeMap = {
|
|
||||||
"String":"string",
|
|
||||||
"Boolean":"boolean",
|
|
||||||
"Number":"number",
|
|
||||||
"Date":"date"
|
|
||||||
}
|
|
||||||
|
|
||||||
ports.push({
|
|
||||||
type: {
|
|
||||||
name: _typeMap[p.type]?_typeMap[p.type]:'*',
|
|
||||||
},
|
|
||||||
plug: 'output',
|
|
||||||
group: 'Properties',
|
|
||||||
name: 'prop-' + key,
|
|
||||||
displayName: key,
|
|
||||||
})
|
|
||||||
|
|
||||||
ports.push({
|
|
||||||
type: 'signal',
|
|
||||||
plug: 'output',
|
|
||||||
group: 'Changed Events',
|
|
||||||
displayName: key+ ' Changed',
|
|
||||||
name: 'changed-' + key,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editorConnection.sendDynamicPorts(nodeId, ports);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
node: LoginNodeDefinition,
|
node: LoginNodeDefinition,
|
||||||
setup: function (context, graphModel) {
|
setup(_context, _graphModel) {}
|
||||||
/* if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _managePortsForNode(node) {
|
|
||||||
updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('dbCollections'));
|
|
||||||
|
|
||||||
node.on("parameterUpdated", function (event) {
|
|
||||||
updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('dbCollections'));
|
|
||||||
});
|
|
||||||
|
|
||||||
graphModel.on('metadataChanged.dbCollections', function (data) {
|
|
||||||
updatePorts(node.id, node.parameters, context.editorConnection, data);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
graphModel.on("editorImportComplete", ()=> {
|
|
||||||
graphModel.on("nodeAdded.DbModel2", function (node) {
|
|
||||||
_managePortsForNode(node)
|
|
||||||
})
|
|
||||||
|
|
||||||
for(const node of graphModel.getNodesWithType('DbModel2')) {
|
|
||||||
_managePortsForNode(node)
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Node, EdgeTriggeredInput } = require('@noodl/runtime');
|
|
||||||
const UserService = require('./userservice');
|
const UserService = require('./userservice');
|
||||||
|
|
||||||
var LogOutNodeDefinition = {
|
const LogOutNodeDefinition = {
|
||||||
name: 'net.noodl.user.LogOut',
|
name: 'net.noodl.user.LogOut',
|
||||||
docs: 'https://docs.noodl.net/nodes/data/user/log-out',
|
docs: 'https://docs.noodl.net/nodes/data/user/log-out',
|
||||||
displayNodeName: 'Log Out',
|
displayNodeName: 'Log Out',
|
||||||
category: 'Cloud Services',
|
category: 'Cloud Services',
|
||||||
color: 'data',
|
color: 'data',
|
||||||
initialize: function () {
|
|
||||||
var internal = this._internal;
|
|
||||||
},
|
|
||||||
getInspectInfo() {},
|
|
||||||
outputs: {
|
outputs: {
|
||||||
success: {
|
success: {
|
||||||
type: 'signal',
|
type: 'signal',
|
||||||
@@ -28,7 +23,7 @@ var LogOutNodeDefinition = {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
displayName: 'Error',
|
displayName: 'Error',
|
||||||
group: 'Error',
|
group: 'Error',
|
||||||
getter: function () {
|
getter() {
|
||||||
return this._internal.error;
|
return this._internal.error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,13 +32,13 @@ var LogOutNodeDefinition = {
|
|||||||
login: {
|
login: {
|
||||||
displayName: 'Do',
|
displayName: 'Do',
|
||||||
group: 'Actions',
|
group: 'Actions',
|
||||||
valueChangedToTrue: function () {
|
valueChangedToTrue() {
|
||||||
this.scheduleLogOut();
|
this.scheduleLogOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setError: function (err) {
|
setError(err) {
|
||||||
this._internal.error = err;
|
this._internal.error = err;
|
||||||
this.flagOutputDirty('error');
|
this.flagOutputDirty('error');
|
||||||
this.sendSignalOnOutput('failure');
|
this.sendSignalOnOutput('failure');
|
||||||
@@ -60,9 +55,7 @@ var LogOutNodeDefinition = {
|
|||||||
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scheduleLogOut: function () {
|
scheduleLogOut() {
|
||||||
const internal = this._internal;
|
|
||||||
|
|
||||||
if (this.logOutScheduled === true) return;
|
if (this.logOutScheduled === true) return;
|
||||||
this.logOutScheduled = true;
|
this.logOutScheduled = true;
|
||||||
|
|
||||||
@@ -84,5 +77,5 @@ var LogOutNodeDefinition = {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
node: LogOutNodeDefinition,
|
node: LogOutNodeDefinition,
|
||||||
setup: function (context, graphModel) {}
|
setup(_context, _graphModel) {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Node, EdgeTriggeredInput } = require('@noodl/runtime');
|
|
||||||
const UserService = require('./userservice');
|
const UserService = require('./userservice');
|
||||||
|
|
||||||
var SignUpNodeDefinition = {
|
const SignUpNodeDefinition = {
|
||||||
name: 'net.noodl.user.SignUp',
|
name: 'net.noodl.user.SignUp',
|
||||||
docs: 'https://docs.noodl.net/nodes/data/user/sign-up',
|
docs: 'https://docs.noodl.net/nodes/data/user/sign-up',
|
||||||
displayNodeName: 'Sign Up',
|
displayNodeName: 'Sign Up',
|
||||||
category: 'Cloud Services',
|
category: 'Cloud Services',
|
||||||
color: 'data',
|
color: 'data',
|
||||||
initialize: function () {
|
initialize() {
|
||||||
var internal = this._internal;
|
const internal = this._internal;
|
||||||
|
|
||||||
internal.userProperties = {};
|
internal.userProperties = {};
|
||||||
},
|
},
|
||||||
getInspectInfo() {},
|
|
||||||
outputs: {
|
outputs: {
|
||||||
success: {
|
success: {
|
||||||
type: 'signal',
|
type: 'signal',
|
||||||
@@ -30,7 +27,7 @@ var SignUpNodeDefinition = {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
displayName: 'Error',
|
displayName: 'Error',
|
||||||
group: 'Error',
|
group: 'Error',
|
||||||
getter: function () {
|
getter() {
|
||||||
return this._internal.error;
|
return this._internal.error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +36,7 @@ var SignUpNodeDefinition = {
|
|||||||
signup: {
|
signup: {
|
||||||
displayName: 'Do',
|
displayName: 'Do',
|
||||||
group: 'Actions',
|
group: 'Actions',
|
||||||
valueChangedToTrue: function () {
|
valueChangedToTrue() {
|
||||||
this.scheduleSignUp();
|
this.scheduleSignUp();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -47,7 +44,7 @@ var SignUpNodeDefinition = {
|
|||||||
displayName: 'Username',
|
displayName: 'Username',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
group: 'General',
|
group: 'General',
|
||||||
set: function (value) {
|
set(value) {
|
||||||
this._internal.username = value;
|
this._internal.username = value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -55,7 +52,7 @@ var SignUpNodeDefinition = {
|
|||||||
displayName: 'Password',
|
displayName: 'Password',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
group: 'General',
|
group: 'General',
|
||||||
set: function (value) {
|
set(value) {
|
||||||
this._internal.password = value;
|
this._internal.password = value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -63,13 +60,13 @@ var SignUpNodeDefinition = {
|
|||||||
displayName: 'Email',
|
displayName: 'Email',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
group: 'General',
|
group: 'General',
|
||||||
set: function (value) {
|
set(value) {
|
||||||
this._internal.email = value;
|
this._internal.email = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setError: function (err) {
|
setError(err) {
|
||||||
this._internal.error = err;
|
this._internal.error = err;
|
||||||
this.flagOutputDirty('error');
|
this.flagOutputDirty('error');
|
||||||
this.sendSignalOnOutput('failure');
|
this.sendSignalOnOutput('failure');
|
||||||
@@ -86,7 +83,7 @@ var SignUpNodeDefinition = {
|
|||||||
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scheduleSignUp: function () {
|
scheduleSignUp() {
|
||||||
const internal = this._internal;
|
const internal = this._internal;
|
||||||
|
|
||||||
if (this.signUpScheduled === true) return;
|
if (this.signUpScheduled === true) return;
|
||||||
@@ -109,23 +106,24 @@ var SignUpNodeDefinition = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setUserProperty: function (name, value) {
|
setUserProperty(name, value) {
|
||||||
this._internal.userProperties[name] = value;
|
this._internal.userProperties[name] = value;
|
||||||
},
|
},
|
||||||
registerInputIfNeeded: function (name) {
|
registerInputIfNeeded(name) {
|
||||||
if (this.hasInput(name)) {
|
if (this.hasInput(name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.startsWith('prop-'))
|
if (name.startsWith('prop-')) {
|
||||||
return this.registerInput(name, {
|
return this.registerInput(name, {
|
||||||
set: this.setUserProperty.bind(this, name.substring('prop-'.length))
|
set: this.setUserProperty.bind(this, name.substring('prop-'.length))
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function updatePorts(nodeId, parameters, editorConnection, systemCollections) {
|
function updatePorts(nodeId, _parameters, editorConnection, systemCollections) {
|
||||||
var ports = [];
|
var ports = [];
|
||||||
|
|
||||||
if (systemCollections) {
|
if (systemCollections) {
|
||||||
@@ -169,7 +167,7 @@ function updatePorts(nodeId, parameters, editorConnection, systemCollections) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
node: SignUpNodeDefinition,
|
node: SignUpNodeDefinition,
|
||||||
setup: function (context, graphModel) {
|
setup(context, graphModel) {
|
||||||
if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {
|
if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,7 +175,7 @@ module.exports = {
|
|||||||
function _managePortsForNode(node) {
|
function _managePortsForNode(node) {
|
||||||
updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));
|
updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));
|
||||||
|
|
||||||
node.on('parameterUpdated', function (event) {
|
node.on('parameterUpdated', function (_event) {
|
||||||
updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));
|
updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user