Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripted fields interface #2076

Merged
merged 39 commits into from
Dec 4, 2014
Merged

Scripted fields interface #2076

merged 39 commits into from
Dec 4, 2014

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented Dec 2, 2014

Adds interface to create, edit and remove scripted fields from the index pattern.

  • New interface lives in settings/indices in a new tab called "Scripted Fields"
  • Button to add new scripted fields
  • Interface to create an edit scripted fields
    • Includes error message when using a name that matches an existing indexed field

Also adds another change to the paginated-table directive - columns can now be marked as not sortable.

This completes the second task on #1537

@rashidkpc rashidkpc mentioned this pull request Dec 2, 2014
5 tasks
@w33ble w33ble added the review label Dec 2, 2014
@spalger
Copy link
Contributor

spalger commented Dec 3, 2014

I think it'd be really helpful if there was some info about writing scripts. Maybe warnings about dangerous operations, useful "quick start" examples, and a link to the docs for different scripting languages?

## Warning
Something about scripting being potentially expensive, but
there are ways to mitigate that...

## Reference
Our examples 

## Quick Start

**append some text to a value**
   'prefix' + doc['fieldname'].value + 'postfix'

**padd values to 20 characters**
   doc['fieldname'].value.padLeft(20, ' ')

@spalger
Copy link
Contributor

spalger commented Dec 3, 2014

I think it'd make sense to use text-align rather than float on the right column. Notice how the borders don't line up in this screenshot.

image

}];

$scope.$watch('indexPattern.scriptedFields', function () {
_.invoke(rowScopes, '$destroy');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to clear the rowScopes array too.

@spalger spalger removed the review label Dec 3, 2014
@spalger spalger assigned w33ble and unassigned spalger Dec 3, 2014
@w33ble w33ble assigned spalger and unassigned w33ble Dec 4, 2014
@w33ble w33ble added the review label Dec 4, 2014
@spalger
Copy link
Contributor

spalger commented Dec 4, 2014

Seeing a weird behavior when choosing the result type "string"

2014-12-04 08_42_32

if (type === 'scripted') {
return _.where(self.fields, { scripted: true });
}
return _.where(self.fields, { scripted: undefined });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that this probably works fine, but an explicit check for undefined is dangerous IMO. The scripted property is boolean and should probably be treated as true or false-y, not true or undefined.

var getScripted = type === 'scripted';
return _.where(self.fields, function (field) {
  return field.scripted ? getScripted : !getScripted;
});

@spalger spalger removed the review label Dec 4, 2014
@spalger spalger assigned w33ble and unassigned spalger Dec 4, 2014
@w33ble w33ble assigned spalger and unassigned w33ble Dec 4, 2014
@w33ble w33ble added the review label Dec 4, 2014
@spalger
Copy link
Contributor

spalger commented Dec 4, 2014

👍

spalger pushed a commit that referenced this pull request Dec 4, 2014
@spalger spalger merged commit 215b212 into elastic:master Dec 4, 2014
@w33ble w33ble deleted the scripted-interface branch February 6, 2015 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants