mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-10 14:22:53 +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';
|
||||
|
||||
const { Node, EdgeTriggeredInput } = require('@noodl/runtime');
|
||||
const UserService = require('./userservice');
|
||||
|
||||
var LoginNodeDefinition = {
|
||||
const LoginNodeDefinition = {
|
||||
name: 'net.noodl.user.LogIn',
|
||||
docs: 'https://docs.noodl.net/nodes/data/user/log-in',
|
||||
displayNodeName: 'Log In',
|
||||
category: 'Cloud Services',
|
||||
color: 'data',
|
||||
initialize: function () {
|
||||
var internal = this._internal;
|
||||
},
|
||||
getInspectInfo() {},
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'signal',
|
||||
@@ -28,7 +23,7 @@ var LoginNodeDefinition = {
|
||||
type: 'string',
|
||||
displayName: 'Error',
|
||||
group: 'Error',
|
||||
getter: function () {
|
||||
getter() {
|
||||
return this._internal.error;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +32,7 @@ var LoginNodeDefinition = {
|
||||
login: {
|
||||
displayName: 'Do',
|
||||
group: 'Actions',
|
||||
valueChangedToTrue: function () {
|
||||
valueChangedToTrue() {
|
||||
this.scheduleLogIn();
|
||||
}
|
||||
},
|
||||
@@ -45,7 +40,7 @@ var LoginNodeDefinition = {
|
||||
displayName: 'Username',
|
||||
type: 'string',
|
||||
group: 'General',
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
this._internal.username = value;
|
||||
}
|
||||
},
|
||||
@@ -53,13 +48,13 @@ var LoginNodeDefinition = {
|
||||
displayName: 'Password',
|
||||
type: 'string',
|
||||
group: 'General',
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
this._internal.password = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setError: function (err) {
|
||||
setError(err) {
|
||||
this._internal.error = err;
|
||||
this.flagOutputDirty('error');
|
||||
this.sendSignalOnOutput('failure');
|
||||
@@ -76,9 +71,7 @@ var LoginNodeDefinition = {
|
||||
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
||||
}
|
||||
},
|
||||
scheduleLogIn: function () {
|
||||
const internal = this._internal;
|
||||
|
||||
scheduleLogIn() {
|
||||
if (this.logInScheduled === true) return;
|
||||
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 = {
|
||||
node: LoginNodeDefinition,
|
||||
setup: function (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)
|
||||
}
|
||||
})*/
|
||||
}
|
||||
setup(_context, _graphModel) {}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const { Node, EdgeTriggeredInput } = require('@noodl/runtime');
|
||||
const UserService = require('./userservice');
|
||||
|
||||
var LogOutNodeDefinition = {
|
||||
const LogOutNodeDefinition = {
|
||||
name: 'net.noodl.user.LogOut',
|
||||
docs: 'https://docs.noodl.net/nodes/data/user/log-out',
|
||||
displayNodeName: 'Log Out',
|
||||
category: 'Cloud Services',
|
||||
color: 'data',
|
||||
initialize: function () {
|
||||
var internal = this._internal;
|
||||
},
|
||||
getInspectInfo() {},
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'signal',
|
||||
@@ -28,7 +23,7 @@ var LogOutNodeDefinition = {
|
||||
type: 'string',
|
||||
displayName: 'Error',
|
||||
group: 'Error',
|
||||
getter: function () {
|
||||
getter() {
|
||||
return this._internal.error;
|
||||
}
|
||||
}
|
||||
@@ -37,13 +32,13 @@ var LogOutNodeDefinition = {
|
||||
login: {
|
||||
displayName: 'Do',
|
||||
group: 'Actions',
|
||||
valueChangedToTrue: function () {
|
||||
valueChangedToTrue() {
|
||||
this.scheduleLogOut();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setError: function (err) {
|
||||
setError(err) {
|
||||
this._internal.error = err;
|
||||
this.flagOutputDirty('error');
|
||||
this.sendSignalOnOutput('failure');
|
||||
@@ -60,9 +55,7 @@ var LogOutNodeDefinition = {
|
||||
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
||||
}
|
||||
},
|
||||
scheduleLogOut: function () {
|
||||
const internal = this._internal;
|
||||
|
||||
scheduleLogOut() {
|
||||
if (this.logOutScheduled === true) return;
|
||||
this.logOutScheduled = true;
|
||||
|
||||
@@ -84,5 +77,5 @@ var LogOutNodeDefinition = {
|
||||
|
||||
module.exports = {
|
||||
node: LogOutNodeDefinition,
|
||||
setup: function (context, graphModel) {}
|
||||
setup(_context, _graphModel) {}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const { Node, EdgeTriggeredInput } = require('@noodl/runtime');
|
||||
const UserService = require('./userservice');
|
||||
|
||||
var SignUpNodeDefinition = {
|
||||
const SignUpNodeDefinition = {
|
||||
name: 'net.noodl.user.SignUp',
|
||||
docs: 'https://docs.noodl.net/nodes/data/user/sign-up',
|
||||
displayNodeName: 'Sign Up',
|
||||
category: 'Cloud Services',
|
||||
color: 'data',
|
||||
initialize: function () {
|
||||
var internal = this._internal;
|
||||
|
||||
initialize() {
|
||||
const internal = this._internal;
|
||||
internal.userProperties = {};
|
||||
},
|
||||
getInspectInfo() {},
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'signal',
|
||||
@@ -30,7 +27,7 @@ var SignUpNodeDefinition = {
|
||||
type: 'string',
|
||||
displayName: 'Error',
|
||||
group: 'Error',
|
||||
getter: function () {
|
||||
getter() {
|
||||
return this._internal.error;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +36,7 @@ var SignUpNodeDefinition = {
|
||||
signup: {
|
||||
displayName: 'Do',
|
||||
group: 'Actions',
|
||||
valueChangedToTrue: function () {
|
||||
valueChangedToTrue() {
|
||||
this.scheduleSignUp();
|
||||
}
|
||||
},
|
||||
@@ -47,7 +44,7 @@ var SignUpNodeDefinition = {
|
||||
displayName: 'Username',
|
||||
type: 'string',
|
||||
group: 'General',
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
this._internal.username = value;
|
||||
}
|
||||
},
|
||||
@@ -55,7 +52,7 @@ var SignUpNodeDefinition = {
|
||||
displayName: 'Password',
|
||||
type: 'string',
|
||||
group: 'General',
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
this._internal.password = value;
|
||||
}
|
||||
},
|
||||
@@ -63,13 +60,13 @@ var SignUpNodeDefinition = {
|
||||
displayName: 'Email',
|
||||
type: 'string',
|
||||
group: 'General',
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
this._internal.email = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setError: function (err) {
|
||||
setError(err) {
|
||||
this._internal.error = err;
|
||||
this.flagOutputDirty('error');
|
||||
this.sendSignalOnOutput('failure');
|
||||
@@ -86,7 +83,7 @@ var SignUpNodeDefinition = {
|
||||
this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-login-warning');
|
||||
}
|
||||
},
|
||||
scheduleSignUp: function () {
|
||||
scheduleSignUp() {
|
||||
const internal = this._internal;
|
||||
|
||||
if (this.signUpScheduled === true) return;
|
||||
@@ -109,23 +106,24 @@ var SignUpNodeDefinition = {
|
||||
});
|
||||
});
|
||||
},
|
||||
setUserProperty: function (name, value) {
|
||||
setUserProperty(name, value) {
|
||||
this._internal.userProperties[name] = value;
|
||||
},
|
||||
registerInputIfNeeded: function (name) {
|
||||
registerInputIfNeeded(name) {
|
||||
if (this.hasInput(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.startsWith('prop-'))
|
||||
if (name.startsWith('prop-')) {
|
||||
return this.registerInput(name, {
|
||||
set: this.setUserProperty.bind(this, name.substring('prop-'.length))
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function updatePorts(nodeId, parameters, editorConnection, systemCollections) {
|
||||
function updatePorts(nodeId, _parameters, editorConnection, systemCollections) {
|
||||
var ports = [];
|
||||
|
||||
if (systemCollections) {
|
||||
@@ -169,7 +167,7 @@ function updatePorts(nodeId, parameters, editorConnection, systemCollections) {
|
||||
|
||||
module.exports = {
|
||||
node: SignUpNodeDefinition,
|
||||
setup: function (context, graphModel) {
|
||||
setup(context, graphModel) {
|
||||
if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {
|
||||
return;
|
||||
}
|
||||
@@ -177,7 +175,7 @@ module.exports = {
|
||||
function _managePortsForNode(node) {
|
||||
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'));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user