-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Changes from 15 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
3cdb638
break indexed fields into its own directive
w33ble 347d908
break scripted fields into its own directive, with mock data
w33ble 8ed489f
allow columns to not be sortable
w33ble e204020
prepare for listing sripted fields, with controls
w33ble d53b37f
add control, and create/edit routes
w33ble d520b37
consolidate router, add real title
w33ble fce9b2f
create form, with name checking and mock button handlers
w33ble 97fc109
add method to save scripted fields, save on submit, use indexedArray …
w33ble 1b5eff5
change the path to scripted fields
w33ble aa2f93b
fix the display of scripted fields, tweak styling
w33ble 9a32d08
don't re-index, save does this automatically
w33ble 963884e
don't redirect, just go back
w33ble 35864b8
read exiting fields from the indexPattern, for editing
w33ble 57ebe14
allow scripted field removal
w33ble 7d6d176
make sure scriptedFields is set on the index pattern
w33ble 79393f3
add warning message about scripted fields
w33ble 0195fa6
right-align instead of pulling right
w33ble c9f61f1
clear the rowScopes array
w33ble bf28fa8
be more explicit about the paths used
w33ble c787074
change how tabs and item counts work
w33ble 867d6cd
Merge branch 'master' into scripted-interface
w33ble acf302d
streamline deleting scripted fields a bit
w33ble 6eecaff
filter field list to scripted and unscripted fields
w33ble 8822028
remove scriptedFields from the index pattern
w33ble 690055a
back out the lodash remove stuff, doesn't appear to work on IndexedArray
w33ble 529bb4f
change the indexedFields tab name, for consistency
w33ble 645571a
append scripted fields when refreshing indexed fields, make propertie…
w33ble 872c4d0
fix naming conflict check
w33ble 8ea2d43
fix tabbed interface index
w33ble 3a17105
add getFields helper, use it to fetch scripted and indexed fields
w33ble cf1f8f7
expose type maps on the CastMappingType function
w33ble 99a0e3b
add type for scripted fields, show it in the list
w33ble fb78e46
fix field name conflict check
w33ble b95365b
assign default field type to skirt weird angular issue
w33ble f303e2d
boolean check on getFields, use getFields to fetch scripted fields wh…
w33ble 6c21106
make mapping types an indexedarray, use it in scripted field type list
w33ble b605131
fieldTypes is not a class
w33ble 40b0a00
fix field type options syntax
w33ble 250ed8d
add groups to input types, use in result type select
w33ble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/kibana/plugins/settings/sections/indices/_indexed_fields.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<paginated-table | ||
columns="columns" | ||
rows="rows" | ||
per-page="perPage"> | ||
</paginated-table> |
60 changes: 60 additions & 0 deletions
60
src/kibana/plugins/settings/sections/indices/_indexed_fields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
require('components/paginated_table/paginated_table'); | ||
|
||
require('modules').get('apps/settings') | ||
.directive('indexedFields', function ($compile) { | ||
var popularityHtml = require('text!plugins/settings/sections/indices/_popularity.html'); | ||
|
||
return { | ||
restrict: 'E', | ||
template: require('text!plugins/settings/sections/indices/_indexed_fields.html'), | ||
scope: true, | ||
link: function ($scope, $el, attr) { | ||
var rowScopes = []; // track row scopes, so they can be destroyed as needed | ||
$scope.perPage = 25; | ||
|
||
$scope.columns = [{ | ||
title: 'name' | ||
}, { | ||
title: 'type' | ||
}, { | ||
title: 'analyzed', | ||
info: 'Analyzed fields may require extra memory to visualize' | ||
}, { | ||
title: 'indexed', | ||
info: 'Fields that are not indexed are unavailable for search' | ||
}, { | ||
title: 'popularity', | ||
info: 'A gauge of how often this field is used', | ||
}]; | ||
|
||
$scope.showPopularityControls = function (field) { | ||
$scope.popularityHoverState = (field) ? field : null; | ||
}; | ||
|
||
$scope.$watchCollection('indexPattern.fields', function () { | ||
_.invoke(rowScopes, '$destroy'); | ||
|
||
$scope.rows = $scope.indexPattern.fields.map(function (field) { | ||
var childScope = $scope.$new(); | ||
rowScopes.push(childScope); | ||
childScope.field = field; | ||
|
||
// update the active field via object comparison | ||
if (_.isEqual(field, $scope.popularityHoverState)) { | ||
$scope.showPopularityControls(field); | ||
} | ||
|
||
return [field.name, field.type, field.analyzed, field.indexed, | ||
{ | ||
markup: $compile(popularityHtml)(childScope), | ||
value: field.count | ||
} | ||
]; | ||
}); | ||
}); | ||
} | ||
}; | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
src/kibana/plugins/settings/sections/indices/_scripted_field_controls.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="actions pull-right"> | ||
<button ng-click="edit(field)" class="btn btn-xs btn-default"> | ||
<i class="fa fa-pencil"></i> | ||
</button> | ||
|
||
<button | ||
confirm-click="remove(field)" | ||
confirmation="Are you sure want to delete '{{field.name}}'? This action is irreversible!" | ||
class="btn btn-xs btn-danger"> | ||
<i class="fa fa-trash"></i> | ||
</button> | ||
</div> |
14 changes: 14 additions & 0 deletions
14
src/kibana/plugins/settings/sections/indices/_scripted_fields.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<header> | ||
<button ng-click="create()" class="btn btn-info"> | ||
<i class="fa fa-plus"></i> | ||
Add Scripted Field | ||
</button> | ||
</header> | ||
|
||
<paginated-table | ||
columns="columns" | ||
rows="rows" | ||
per-page="perPage"> | ||
</paginated-table> | ||
|
||
<div ng-if="rows.length === 0">No scripted fields</div> |
68 changes: 68 additions & 0 deletions
68
src/kibana/plugins/settings/sections/indices/_scripted_fields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
require('components/paginated_table/paginated_table'); | ||
|
||
require('modules').get('apps/settings') | ||
.directive('scriptedFields', function ($compile, kbnUrl) { | ||
var rowScopes = []; // track row scopes, so they can be destroyed as needed | ||
var controlsHtml = require('text!plugins/settings/sections/indices/_scripted_field_controls.html'); | ||
|
||
return { | ||
restrict: 'E', | ||
template: require('text!plugins/settings/sections/indices/_scripted_fields.html'), | ||
scope: true, | ||
link: function ($scope, $el, attr) { | ||
var fieldEditorPath = '/settings/indices/{{ indexPattern }}/scriptedField'; | ||
$scope.perPage = 25; | ||
|
||
$scope.columns = [{ | ||
title: 'name' | ||
}, { | ||
title: 'script' | ||
}, { | ||
title: 'controls', | ||
class: 'pull-right', | ||
sortable: false | ||
}]; | ||
|
||
$scope.$watch('indexPattern.scriptedFields', function () { | ||
_.invoke(rowScopes, '$destroy'); | ||
|
||
$scope.rows = $scope.indexPattern.scriptedFields.map(function (field, i) { | ||
var rowScope = $scope.$new(); | ||
var columns = [field.name, field.script]; | ||
rowScope.field = field; | ||
rowScopes.push(rowScope); | ||
|
||
columns.push({ | ||
markup: $compile(controlsHtml)(rowScope) | ||
}); | ||
|
||
return columns; | ||
}); | ||
}); | ||
|
||
$scope.create = function () { | ||
var params = { | ||
indexPattern: $scope.indexPattern.id | ||
}; | ||
|
||
kbnUrl.change(fieldEditorPath, params); | ||
}; | ||
|
||
$scope.edit = function (field) { | ||
var params = { | ||
indexPattern: $scope.indexPattern.id, | ||
fieldName: field.name | ||
}; | ||
|
||
kbnUrl.change(fieldEditorPath + '/{{ fieldName }}', params); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This path template should probably be defined up by |
||
}; | ||
|
||
$scope.remove = function (field) { | ||
$scope.indexPattern.removeScriptedField(field.name); | ||
}; | ||
} | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,5 @@ <h5> | |
</ul> | ||
</div> | ||
</div> | ||
|
||
<div class="col-md-10" ng-transclude></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/kibana/plugins/settings/sections/indices/scripted_fields/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<kbn-settings-app section="indices"> | ||
<kbn-settings-indices> | ||
|
||
<div ng-controller="scriptedFieldsEdit"> | ||
<h1>{{ action }} Scripted Field</h1> | ||
|
||
<form name="scriptedFieldForm" ng-submit="submit()"> | ||
<div class="form-group"> | ||
<label>Name</label> | ||
<input type="text" ng-model="scriptedField.name" class="form-control span12"> | ||
</div> | ||
<div class="form-group"> | ||
<label>Script</label> | ||
<textarea class="form-control span12" ng-model="scriptedField.script"></textarea> | ||
</div> | ||
</form> | ||
<div ng-if="namingConflict" class="alert alert-danger"> | ||
You already have a field with the name {{ scriptedField.name }}. Naming your scripted | ||
field with the same name means you won't be able to query both fields at the same time. | ||
</div> | ||
<div class="form-group"> | ||
<button class="btn btn-primary" ng-click="cancel()">Cancel</button> | ||
<button class="btn btn-success" ng-click="submit()" ng-disabled="scriptedFieldForm.$invalid"> | ||
Save Scripted Field | ||
</button> | ||
</div> | ||
</div> | ||
</kbn-settings-indices> | ||
</kbn-settings-app> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.