Small improvement to Cockpit-Node

This commit is contained in:
Jan Oberhauser 2020-04-12 12:28:36 +02:00
parent 532b9a9294
commit ef26a4bfe5
4 changed files with 32 additions and 20 deletions

View file

@ -14,17 +14,17 @@ export const collectionOperations = [
},
options: [
{
name: 'Create an entry',
name: 'Create an Entry',
value: 'create',
description: 'Create a collection entry',
},
{
name: 'Get all entries',
name: 'Get all Entries',
value: 'getAll',
description: 'Get all collection entries',
},
{
name: 'Update an entry',
name: 'Update an Entry',
value: 'update',
description: 'Update a collection entries',
},
@ -116,22 +116,24 @@ export const collectionFields = [
{
displayName: 'Fields',
name: 'fields',
type: 'json',
type: 'string',
default: '',
typeOptions: {
alwaysOpenEditWindow: true,
},
description: 'Fields to get.',
placeholder: '_id,name',
description: 'Comma separated list of fields to get.',
},
{
displayName: 'Filter',
displayName: 'Filter Query',
name: 'filter',
type: 'json',
default: '',
typeOptions: {
alwaysOpenEditWindow: true,
},
description: 'Filter result by fields.',
placeholder: '{"name": "Jim"}',
description: 'Filter query in <a href="https://jeroen.github.io/mongolite/query-data.html" target="_blank">Mongolite format</a>.',
},
{
displayName: 'Language',
@ -163,11 +165,12 @@ export const collectionFields = [
description: 'Skip number of entries.',
},
{
displayName: 'Sort',
displayName: 'Sort Query',
name: 'sort',
type: 'json',
default: '',
description: 'Sort result by fields.',
placeholder: '{"price": -1}',
description: 'Sort query in <a href="https://jeroen.github.io/mongolite/query-data.html" target="_blank">Mongolite format</a>.',
},
],
},
@ -213,7 +216,7 @@ export const collectionFields = [
description: 'If new entry fields should be set via the value-key pair UI or JSON.',
},
{
displayName: 'Data fields',
displayName: 'Entry Data',
name: 'dataFieldsJson',
type: 'json',
default: '',
@ -234,10 +237,10 @@ export const collectionFields = [
]
},
},
description: 'Data to send as JSON.',
description: 'Entry data to send as JSON.',
},
{
displayName: 'Data fields',
displayName: 'Entry Data',
name: 'dataFieldsUi',
type: 'fixedCollection',
typeOptions: {
@ -280,6 +283,6 @@ export const collectionFields = [
],
},
],
description: 'Data field to send.',
description: 'Entry data to send.',
},
] as INodeProperties[];

View file

@ -27,7 +27,16 @@ export async function getAllCollectionEntries(this: IExecuteFunctions | IExecute
const body: ICollection = {};
if (options.fields) {
body.fields = JSON.parse(options.fields.toString());
const fields = (options.fields as string).split(',').map(field => field.trim() );
const bodyFields = {
_id: false,
} as IDataObject;
for (const field of fields) {
bodyFields[field] = true;
}
body.fields = bodyFields;
}
if (options.filter) {

View file

@ -14,7 +14,7 @@ export const formOperations = [
},
options: [
{
name: 'Submit a form',
name: 'Submit a Form',
value: 'submit',
description: 'Store submission of a form',
},
@ -61,7 +61,7 @@ export const formFields = [
description: 'If form fields should be set via the value-key pair UI or JSON.',
},
{
displayName: 'Form fields',
displayName: 'Form Data',
name: 'dataFieldsJson',
type: 'json',
default: '',
@ -81,10 +81,10 @@ export const formFields = [
]
},
},
description: 'Form to send as JSON.',
description: 'Form data to send as JSON.',
},
{
displayName: 'Data fields',
displayName: 'Form Data',
name: 'dataFieldsUi',
type: 'fixedCollection',
typeOptions: {
@ -126,6 +126,6 @@ export const formFields = [
],
},
],
description: 'Form field to send.',
description: 'Form data to send.',
},
] as INodeProperties[];

View file

@ -16,7 +16,7 @@ export const singletonOperations = [
{
name: 'Get',
value: 'get',
description: 'Gets a singleton',
description: 'Gets a Singleton',
},
],
default: 'get',