2021-11-08 11:41:04 -06:00
|
|
|
import { SqlPartDef, SqlPart } from 'app/angular/components/sql_part/sql_part';
|
2018-01-30 15:57:38 -06:00
|
|
|
|
2019-07-01 04:11:57 -05:00
|
|
|
const index: any[] = [];
|
2018-01-30 15:57:38 -06:00
|
|
|
|
2019-07-01 04:11:57 -05:00
|
|
|
function createPart(part: any): any {
|
2018-08-31 12:02:46 -05:00
|
|
|
const def = index[part.type];
|
2018-01-30 15:57:38 -06:00
|
|
|
if (!def) {
|
2018-07-10 07:45:36 -05:00
|
|
|
return null;
|
2018-01-30 15:57:38 -06:00
|
|
|
}
|
|
|
|
|
2018-05-21 04:10:00 -05:00
|
|
|
return new SqlPart(part, def);
|
2018-01-30 15:57:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function register(options: any) {
|
2018-05-21 04:10:00 -05:00
|
|
|
index[options.type] = new SqlPartDef(options);
|
2018-01-30 15:57:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
register({
|
2018-03-03 13:57:00 -06:00
|
|
|
type: 'column',
|
2018-05-21 05:53:06 -05:00
|
|
|
style: 'label',
|
2018-03-03 13:57:00 -06:00
|
|
|
params: [{ type: 'column', dynamicLookup: true }],
|
2018-01-30 15:57:38 -06:00
|
|
|
defaultParams: ['value'],
|
|
|
|
});
|
|
|
|
|
2018-06-30 04:11:34 -05:00
|
|
|
register({
|
|
|
|
type: 'expression',
|
|
|
|
style: 'expression',
|
|
|
|
label: 'Expr:',
|
|
|
|
params: [
|
|
|
|
{ name: 'left', type: 'string', dynamicLookup: true },
|
|
|
|
{ name: 'op', type: 'string', dynamicLookup: true },
|
|
|
|
{ name: 'right', type: 'string', dynamicLookup: true },
|
|
|
|
],
|
|
|
|
defaultParams: ['value', '=', 'value'],
|
|
|
|
});
|
|
|
|
|
2018-07-06 03:38:52 -05:00
|
|
|
register({
|
|
|
|
type: 'macro',
|
2018-07-10 03:19:30 -05:00
|
|
|
style: 'label',
|
2018-07-06 03:38:52 -05:00
|
|
|
label: 'Macro:',
|
|
|
|
params: [],
|
|
|
|
defaultParams: [],
|
|
|
|
});
|
|
|
|
|
2018-01-30 15:57:38 -06:00
|
|
|
register({
|
2018-03-26 11:34:40 -05:00
|
|
|
type: 'aggregate',
|
2018-05-21 05:53:06 -05:00
|
|
|
style: 'label',
|
2018-07-29 06:30:21 -05:00
|
|
|
params: [
|
|
|
|
{
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
options: ['avg', 'count', 'min', 'max', 'sum', 'stddev', 'variance'],
|
|
|
|
},
|
|
|
|
],
|
2018-03-26 11:34:40 -05:00
|
|
|
defaultParams: ['avg'],
|
2018-01-30 15:57:38 -06:00
|
|
|
});
|
|
|
|
|
2018-07-29 06:30:21 -05:00
|
|
|
register({
|
|
|
|
type: 'percentile',
|
|
|
|
label: 'Aggregate:',
|
|
|
|
style: 'label',
|
|
|
|
params: [
|
|
|
|
{
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
options: ['percentile_cont', 'percentile_disc'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'fraction',
|
|
|
|
type: 'number',
|
|
|
|
options: ['0.5', '0.75', '0.9', '0.95', '0.99'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
defaultParams: ['percentile_cont', '0.95'],
|
|
|
|
});
|
|
|
|
|
2018-01-30 15:57:38 -06:00
|
|
|
register({
|
|
|
|
type: 'alias',
|
2018-05-21 05:53:06 -05:00
|
|
|
style: 'label',
|
2018-01-30 15:57:38 -06:00
|
|
|
params: [{ name: 'name', type: 'string', quote: 'double' }],
|
|
|
|
defaultParams: ['alias'],
|
|
|
|
});
|
|
|
|
|
2018-03-04 03:18:11 -06:00
|
|
|
register({
|
|
|
|
type: 'time',
|
2018-05-21 05:53:06 -05:00
|
|
|
style: 'function',
|
2018-05-21 04:44:37 -05:00
|
|
|
label: 'time',
|
2018-03-04 03:18:11 -06:00
|
|
|
params: [
|
|
|
|
{
|
|
|
|
name: 'interval',
|
|
|
|
type: 'interval',
|
|
|
|
options: ['$__interval', '1s', '10s', '1m', '5m', '10m', '15m', '1h'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'fill',
|
|
|
|
type: 'string',
|
2018-08-08 05:23:41 -05:00
|
|
|
options: ['none', 'NULL', 'previous', '0'],
|
2018-03-04 03:18:11 -06:00
|
|
|
},
|
|
|
|
],
|
2018-06-30 04:11:34 -05:00
|
|
|
defaultParams: ['$__interval', 'none'],
|
2018-03-04 03:18:11 -06:00
|
|
|
});
|
|
|
|
|
2018-07-10 14:43:10 -05:00
|
|
|
register({
|
2018-07-28 14:30:08 -05:00
|
|
|
type: 'window',
|
2018-07-10 14:43:10 -05:00
|
|
|
style: 'label',
|
|
|
|
params: [
|
|
|
|
{
|
|
|
|
name: 'function',
|
|
|
|
type: 'string',
|
2018-10-31 13:26:18 -05:00
|
|
|
options: ['delta', 'increase', 'rate', 'sum'],
|
2018-07-10 14:43:10 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
defaultParams: ['increase'],
|
|
|
|
});
|
|
|
|
|
2018-08-03 00:44:36 -05:00
|
|
|
register({
|
|
|
|
type: 'moving_window',
|
|
|
|
style: 'label',
|
|
|
|
label: 'Moving Window:',
|
|
|
|
params: [
|
|
|
|
{
|
|
|
|
name: 'function',
|
|
|
|
type: 'string',
|
|
|
|
options: ['avg'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'window_size',
|
|
|
|
type: 'number',
|
|
|
|
options: ['3', '5', '7', '10', '20'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
defaultParams: ['avg', '5'],
|
|
|
|
});
|
|
|
|
|
2018-01-30 15:57:38 -06:00
|
|
|
export default {
|
|
|
|
create: createPart,
|
|
|
|
};
|