mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
create string paramtype, use for string input
This commit is contained in:
parent
c334dc6504
commit
9aa5d0a08a
6 changed files with 47 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
|||
define(function (require) {
|
||||
return function AggParamsFactory(Private) {
|
||||
require('filters/label');
|
||||
var _ = require('lodash');
|
||||
var IndexedArray = require('utils/indexed_array/index');
|
||||
|
||||
|
@ -7,6 +8,7 @@ define(function (require) {
|
|||
var FieldAggParam = Private(require('components/agg_types/param_types/field'));
|
||||
var OptionedAggParam = Private(require('components/agg_types/param_types/optioned'));
|
||||
var RegexAggParam = Private(require('components/agg_types/param_types/regex'));
|
||||
var StringAggParam = Private(require('components/agg_types/param_types/string'));
|
||||
|
||||
/**
|
||||
* Wraps a list of {{#crossLink "AggParam"}}{{/crossLink}} objects; owned by an {{#crossLink "AggType"}}{{/crossLink}}
|
||||
|
@ -43,6 +45,9 @@ define(function (require) {
|
|||
else if (param.type === 'regex') {
|
||||
return new RegexAggParam(param);
|
||||
}
|
||||
else if (param.type === 'string') {
|
||||
return new StringAggParam(param);
|
||||
}
|
||||
else {
|
||||
return new BaseAggParam(param);
|
||||
}
|
||||
|
|
|
@ -30,13 +30,8 @@ define(function (require) {
|
|||
},
|
||||
{
|
||||
name: 'script',
|
||||
editor: require('text!components/agg_types/controls/script.html'),
|
||||
advanced: true,
|
||||
write: function (aggConfig, output) {
|
||||
if (aggConfig.params.script && aggConfig.params.script.length)
|
||||
output.params.script = aggConfig.params.script;
|
||||
return;
|
||||
}
|
||||
type: 'string',
|
||||
advanced: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
define(function (require) {
|
||||
return function TermsAggDefinition(Private) {
|
||||
var _ = require('lodash');
|
||||
require('filters/label');
|
||||
var AggType = Private(require('components/agg_types/_agg_type'));
|
||||
var bucketCountBetween = Private(require('components/agg_types/buckets/_bucket_count_between'));
|
||||
|
||||
|
@ -67,13 +66,8 @@ define(function (require) {
|
|||
},
|
||||
{
|
||||
name: 'script',
|
||||
editor: require('text!components/agg_types/controls/script.html'),
|
||||
advanced: true,
|
||||
write: function (aggConfig, output) {
|
||||
if (aggConfig.params.script && aggConfig.params.script.length)
|
||||
output.params.script = aggConfig.params.script;
|
||||
return;
|
||||
}
|
||||
type: 'string',
|
||||
advanced: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<div class="form-group">
|
||||
<label>Script</label>
|
||||
<div>
|
||||
<input type="text" ng-model="params.script" class="form-control">
|
||||
</div>
|
||||
</div>
|
6
src/kibana/components/agg_types/controls/string.html
Normal file
6
src/kibana/components/agg_types/controls/string.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<div class="form-group">
|
||||
<label>{{ aggParam.name | label }}</label>
|
||||
<div>
|
||||
<input type="text" ng-model="params[aggParam.name]" class="form-control">
|
||||
</div>
|
||||
</div>
|
32
src/kibana/components/agg_types/param_types/string.js
Normal file
32
src/kibana/components/agg_types/param_types/string.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
define(function (require) {
|
||||
return function FieldAggParamFactory(Private) {
|
||||
var _ = require('lodash');
|
||||
|
||||
var editorHtml = require('text!components/agg_types/controls/string.html');
|
||||
var BaseAggParam = Private(require('components/agg_types/param_types/base'));
|
||||
|
||||
_(ScriptAggParam).inherits(BaseAggParam);
|
||||
function ScriptAggParam(config) {
|
||||
ScriptAggParam.Super.call(this, config);
|
||||
}
|
||||
|
||||
ScriptAggParam.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
ScriptAggParam.prototype.write = function (aggConfig, output) {
|
||||
if (aggConfig.params.script && aggConfig.params.script.length)
|
||||
output.params.script = aggConfig.params.script;
|
||||
};
|
||||
|
||||
return ScriptAggParam;
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue