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

Improve post-aggretation section #1

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 85 additions & 4 deletions dist/partials/query.editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@
<div ng-switch-when="arithmetic">
<label class="gf-form-label">
{{postAggregator.type}}:&nbsp;name&nbsp;=&nbsp;{{postAggregator.name}},&nbsp;fn&nbsp;=&nbsp;{{postAggregator.fn}}, &nbsp;fields&nbsp;=&nbsp;{{postAggregator.fields}}
<a ng-click="ctrl.editPostAggregator($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregator($index)">
<i class="fa fa-remove"></i>
</a>
Expand All @@ -424,6 +427,9 @@
<div ng-switch-when="max">
<label class="gf-form-label">
{{postAggregator.type}}:&nbsp;name&nbsp;=&nbsp;{{postAggregator.name}},&nbsp;field&nbsp;=&nbsp;{{postAggregator.fieldName}}
<a ng-click="ctrl.editPostAggregator($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregator($index)">
<i class="fa fa-remove"></i>
</a>
Expand All @@ -432,6 +438,9 @@
<div ng-switch-when="min">
<label class="gf-form-label">
{{postAggregator.type}}:&nbsp;name&nbsp;=&nbsp;{{postAggregator.name}},&nbsp;field&nbsp;=&nbsp;{{postAggregator.fieldName}}
<a ng-click="ctrl.editPostAggregator($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregator($index)">
<i class="fa fa-remove"></i>
</a>
Expand All @@ -440,6 +449,9 @@
<div ng-switch-when="quantile">
<label class="gf-form-label">
{{postAggregator.type}}:&nbsp;name&nbsp;=&nbsp;{{postAggregator.name}},&nbsp;field&nbsp;=&nbsp;{{postAggregator.fieldName}}, &nbsp;prob&nbsp;=&nbsp;{{postAggregator.probability}}
<a ng-click="ctrl.editPostAggregator($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregator($index)">
<i class="fa fa-remove"></i>
</a>
Expand All @@ -459,9 +471,75 @@

<!-- arithmetic -->
<div class="gf-form" ng-show="ctrl.addPostAggregatorMode" ng-switch on="ctrl.target.currentPostAggregator.type">
<input type="text" ng-switch-when="arithmetic" class="input-small gf-form-input" spellcheck="false" ng-model="ctrl.target.currentPostAggregator.name" placeholder="output name" ng-blur="ctrl.targetBlur()">
<select ng-switch-when="arithmetic" class="input-small gf-form-input" ng-model="ctrl.target.currentPostAggregator.fn" ng-options="fn for fn in ctrl.arithmeticPostAggregator" ng-change="ctrl.targetBlur()"></select>
<input type="text" ng-switch-when="arithmetic" class="input-small gf-form-input" spellcheck="false" ng-model="ctrl.target.currentPostAggregator.fields" placeholder="field1,field2" ng-blur="ctrl.targetBlur()">
<input type="text" ng-switch-when="arithmetic" class="input-small gf-form-input width-9" spellcheck="false" ng-model="ctrl.target.currentPostAggregator.name" placeholder="output name" ng-blur="ctrl.targetBlur()">
<select ng-switch-when="arithmetic" class="input-small gf-form-input width-3" ng-model="ctrl.target.currentPostAggregator.fn" ng-options="fn for fn in ctrl.arithmeticPostAggregator" ng-change="ctrl.targetBlur()"></select>

<label ng-switch-when=arithmetic class="gf-form-label query-keyword width-5">
Fields
</label>

<div class="gf-form" ng-switch-when="arithmetic" ng-repeat="field in ctrl.target.currentPostAggregator.fields track by $index">
<div ng-switch="field.type">
<div ng-switch-when="fieldAccess">
<label class="gf-form-label">
{{field.type}}:&nbsp;name&nbsp;=&nbsp;{{field.fieldName}}
<a ng-click="ctrl.editPostAggregatorField($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregatorField($index)">
<i class="fa fa-remove"></i>
</a>
</label>
</div>
<div ng-switch-when="constant">
<label class="gf-form-label">
{{field.type}}:&nbsp;{{field.value}}
<a ng-click="ctrl.editPostAggregatorField($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregatorField($index)">
<i class="fa fa-remove"></i>
</a>
</label>
</div>
<div ng-switch-when="hyperUniqueCardinality">
<label class="gf-form-label">
{{field.type}}:&nbsp;name&nbsp;=&nbsp;{{field.fieldName}}
<a ng-click="ctrl.editPostAggregatorField($index)">
<i class="fa fa-pencil"></i>
</a>
<a ng-click="ctrl.removePostAggregatorField($index)">
<i class="fa fa-remove"></i>
</a>
</label>
</div>

</div>
</div>

<div class="gf-form-select-wrapper max-width-15" ng-switch-when="arithmetic" ng-show="ctrl.addPostAggregatorFieldMode">
<select ng-model="ctrl.target.currentPostAggregatorField.type" class="gf-form-input" ng-options="type for type in ctrl.arithmeticPostAggregatorFieldsTypes" ng-change="ctrl.targetBlur()"></select>
</div>
<div class="gf-form" ng-switch-when="arithmetic" ng-show="ctrl.addPostAggregatorFieldMode" ng-switch on="ctrl.target.currentPostAggregatorField.type">
<input ng-switch-when="fieldAccess|hyperUniqueCardinality" ng-switch-when-separator="|" type="text" class="gf-form-input width-8" spellcheck="false" ng-model="ctrl.target.currentPostAggregatorField.fieldName" placeholder="fieldName" ng-blur="ctrl.targetBlur()">
<input ng-switch-when="constant" type="text" class="gf-form-input width-8" spellcheck="false" ng-model="ctrl.target.currentPostAggregatorField.value" placeholder="value" ng-blur="ctrl.targetBlur()">
</div>

<div class="gf-form" ng-switch-when="arithmetic" ng-show="ctrl.addPostAggregatorFieldMode">
<label class="gf-form-label" bs-tooltip="ctrl.errors.currentPostAggregatorField" style="color: rgb(229, 189, 28)" ng-show="ctrl.errors.currentPostAggregatorField">
<i class="fa fa-warning"></i>
</label>
<label class="gf-form-label width-6">
<a ng-click="ctrl.addPostAggregatorField()">add field</a>
<a ng-click="ctrl.clearCurrentPostAggregatorField()"><i class="fa fa-remove"></i></a>
</label>
</div>

<div class="gf-form" ng-hide="ctrl.addPostAggregatorFieldMode" ng-switch-when=arithmetic>
<label class="gf-form-label query-keyword">
<a ng-click="ctrl.addPostAggregatorField()"><i class="fa fa-plus"></i></a>
</label>
</div>
</div>

<!-- max -->
Expand All @@ -484,8 +562,11 @@
</div>

<div class="gf-form" ng-show="ctrl.addPostAggregatorMode">
<label class="gf-form-label" bs-tooltip="ctrl.errors.currentPostAggregator" style="color: rgb(229, 189, 28)" ng-show="ctrl.errors.currentPostAggregator">
<i class="fa fa-warning"></i>
</label>
<label class="gf-form-label">
<a ng-click="ctrl.addPostAggregator()">add tag</a>
<a ng-click="ctrl.addPostAggregator()">add post-agg</a>
<a ng-click="ctrl.clearCurrentPostAggregator()"><i class="fa fa-remove"></i></a>
</label>
</div>
Expand Down
24 changes: 24 additions & 0 deletions dist/query_ctrl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export declare class DruidQueryCtrl extends QueryCtrl {
addFilterMode: boolean;
addAggregatorMode: boolean;
addPostAggregatorMode: boolean;
addPostAggregatorFieldMode: boolean;
addDimensionsMode: boolean;
addMetricsMode: boolean;
listDataSources: any;
Expand All @@ -19,6 +20,7 @@ export declare class DruidQueryCtrl extends QueryCtrl {
filterTypes: any;
aggregatorTypes: any;
postAggregatorTypes: any;
postAggregatorFieldTypes: any;
arithmeticPostAggregator: any;
customGranularity: any;
target: any;
Expand Down Expand Up @@ -49,19 +51,32 @@ export declare class DruidQueryCtrl extends QueryCtrl {
"min": any;
"quantile": any;
};
postAggregatorFieldValidators: {
"fieldAccess": any;
"hyperUniqueCardinality": any;
"constant": any;
};
arithmeticPostAggregatorFns: {
'+': any;
'-': any;
'*': any;
'/': any;
};
arithmeticPostAggregatorFieldsTypes: {
'fieldAccess': any;
'constant': any;
'hyperUniqueCardinality': any;
};
defaultQueryType: string;
defaultFilterType: string;
defaultAggregatorType: string;
defaultPostAggregator: {
type: string;
'fn': string;
};
defaultPostAggregatorField: {
type: string;
};
customGranularities: string[];
defaultCustomGranularity: string;
defaultSelectDimension: string;
Expand All @@ -85,11 +100,17 @@ export declare class DruidQueryCtrl extends QueryCtrl {
removeAggregator(index: any): void;
clearCurrentAggregator(): void;
addPostAggregator(): void;
editPostAggregator(index: any): void;
removePostAggregator(index: any): void;
clearCurrentPostAggregator(): void;
addPostAggregatorField(): void;
removePostAggregatorField(index: any): void;
clearCurrentPostAggregatorField(): void;
editPostAggregatorField(index: any): void;
isValidFilterType(type: any): any;
isValidAggregatorType(type: any): any;
isValidPostAggregatorType(type: any): any;
isValidPostAggregatorFieldType(type: any): any;
isValidQueryType(type: any): any;
isValidArithmeticPostAggregatorFn(fn: any): any;
validateMaxDataPoints(target: any, errs: any): boolean;
Expand All @@ -111,5 +132,8 @@ export declare class DruidQueryCtrl extends QueryCtrl {
validateMinPostAggregator(target: any): string;
validateQuantilePostAggregator(target: any): string;
validateArithmeticPostAggregator(target: any): "Must provide an output name for arithmetic post aggregator." | "Must provide a function for arithmetic post aggregator." | "Invalid arithmetic function" | "Must provide a list of fields for arithmetic post aggregator." | "Must provide at least two fields for arithmetic post aggregator.";
validateFieldAccessPostAggregatorField(target: any): string;
validateHyperUniqueCardinalityPostAggregatorField(target: any): string;
validateConstantPostAggregatorField(target: any): "Must provide a value for constant field type." | "The value for constant field type must be numeric.";
validateTarget(): any;
}
Loading