Skip to content

Commit

Permalink
Merge pull request #160 from Altinity/master
Browse files Browse the repository at this point in the history
Update to verison 1.9.4
  • Loading branch information
gimm3fuel authored Nov 27, 2019
2 parents 995b21b + 04172a4 commit 08c152e
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 46 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.9.4 (2019-11-27)

## Fixes:
* Ad Hoc Filters small adjustments for numeric values
* UI optimizations within Metric builder

# 1.9.3 (2019-10-18)

## Fixes:
Expand Down
2 changes: 1 addition & 1 deletion dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

43 changes: 23 additions & 20 deletions dist/partials/query.editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,14 @@
</div>

<div class="gf-form-inline">
<div class="gf-form">
<label class="gf-form-label query-keyword width-10">
<info-popover mode="right-absolute">
Select
<a href="https://clickhouse.yandex/reference_en.html#Date" target = "_blank" >EventDate</a>
column for binding with Grafana's range selector
</info-popover>
Column:Date
<i ng-if="ctrl.target.dateLoading" class="fa fa-spinner fa-spin"></i>
</label>
</div>

<div class="gf-form">
<metric-segment segment="ctrl.dateColDataTypeSegment"
get-options="ctrl.getDateColDataTypeSegments()"
on-change="ctrl.dateColDataTypeChanged()"></metric-segment>
</div>

<div class="gf-form width-14">
<div class="gf-form width-14">
<metric-segment-model property="ctrl.target.dateTimeType"
options="ctrl.dateTimeTypeOptions" css-class="query-keyword width-14 "
custom="false" select-mode="true"
on-change="ctrl.dateTimeTypeChanged()">
</metric-segment-model>
<info-popover mode="right-absolute" style = "margin-right: 10px;">
Select
Select Event
<a href="https://clickhouse.yandex/reference_en.html#DateTime" target = "_blank" >DateTime</a>
or UInt32 column for binding with Grafana's range selector
</info-popover>
Expand All @@ -70,6 +52,27 @@
</metric-segment>
</div>

<div class="gf-form">
<label class="gf-form-label query-keyword width-10">
<info-popover mode="right-absolute">
Select
<a href="https://clickhouse.yandex/reference_en.html#Date" target = "_blank" >Date</a>
column for binding with Grafana's range selector
</info-popover>
Column:Date
<i ng-if="ctrl.target.dateLoading" class="fa fa-spinner fa-spin"></i>
</label>
</div>

<style>
.typeahead.dropdown-menu a {min-height: 2em;}
</style>
<div class="gf-form">
<metric-segment segment="ctrl.dateColDataTypeSegment"
get-options="ctrl.getDateColDataTypeSegments()"
on-change="ctrl.dateColDataTypeChanged()"></metric-segment>
</div>

<div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vertamedia-clickhouse",
"version": "1.9.3",
"version": "1.9.4",
"description": "ClickHouse datasource for Grafana",
"scripts": {
"build:prod": "webpack --config webpack.config.prod.js",
Expand Down
43 changes: 23 additions & 20 deletions src/partials/query.editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,14 @@
</div>

<div class="gf-form-inline">
<div class="gf-form">
<label class="gf-form-label query-keyword width-10">
<info-popover mode="right-absolute">
Select
<a href="https://clickhouse.yandex/reference_en.html#Date" target = "_blank" >EventDate</a>
column for binding with Grafana's range selector
</info-popover>
Column:Date
<i ng-if="ctrl.target.dateLoading" class="fa fa-spinner fa-spin"></i>
</label>
</div>

<div class="gf-form">
<metric-segment segment="ctrl.dateColDataTypeSegment"
get-options="ctrl.getDateColDataTypeSegments()"
on-change="ctrl.dateColDataTypeChanged()"></metric-segment>
</div>

<div class="gf-form width-14">
<div class="gf-form width-14">
<metric-segment-model property="ctrl.target.dateTimeType"
options="ctrl.dateTimeTypeOptions" css-class="query-keyword width-14 "
custom="false" select-mode="true"
on-change="ctrl.dateTimeTypeChanged()">
</metric-segment-model>
<info-popover mode="right-absolute" style = "margin-right: 10px;">
Select
Select Event
<a href="https://clickhouse.yandex/reference_en.html#DateTime" target = "_blank" >DateTime</a>
or UInt32 column for binding with Grafana's range selector
</info-popover>
Expand All @@ -70,6 +52,27 @@
</metric-segment>
</div>

<div class="gf-form">
<label class="gf-form-label query-keyword width-10">
<info-popover mode="right-absolute">
Select
<a href="https://clickhouse.yandex/reference_en.html#Date" target = "_blank" >Date</a>
column for binding with Grafana's range selector
</info-popover>
Column:Date
<i ng-if="ctrl.target.dateLoading" class="fa fa-spinner fa-spin"></i>
</label>
</div>

<style>
.typeahead.dropdown-menu a {min-height: 2em;}
</style>
<div class="gf-form">
<metric-segment segment="ctrl.dateColDataTypeSegment"
get-options="ctrl.getDateColDataTypeSegments()"
on-change="ctrl.dateColDataTypeChanged()"></metric-segment>
</div>

<div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"url": "https://github.com/Vertamedia/clickhouse-grafana"
}
],
"version": "1.9.3"
"version": "1.9.4"
}
}
4 changes: 3 additions & 1 deletion src/query_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class SqlQueryCtrl extends QueryCtrl {
getDateColDataTypeSegments() {
var target = this.target;
target.dateLoading = true;

return this.querySegment('DATE').then(function (response) {
target.dateLoading = false;
return response;
Expand Down Expand Up @@ -352,7 +353,8 @@ class SqlQueryCtrl extends QueryCtrl {
'WHERE database = \'' + this.target.database + '\' AND ' +
'table = \'' + this.target.table + '\' AND ' +
'type = \'Date\' ' +
'ORDER BY name';
'ORDER BY name ' +
'UNION ALL SELECT \' \' AS name';
break;
case 'DATETIME':
query = 'SELECT name ' +
Expand Down
3 changes: 2 additions & 1 deletion src/sql_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class SqlQuery {
ast.where = [];
}
let target = SqlQuery.target(ast.from[0], this.target);

adhocFilters.forEach(function (af) {
let parts = af.key.split('.');
/* Wildcard table, substitute current target table */
Expand All @@ -72,7 +73,7 @@ export default class SqlQuery {
}
let operator = SqlQuery.clickhouseOperator(af.operator);
let cond = parts[2] + " " + operator + " "
+ ((af.value.indexOf("'") > -1 || af.value.indexOf(", ") > -1) ? af.value : "'" + af.value + "'");
+ ((af.value.indexOf("'") > -1 || af.value.indexOf(", ") > -1 || af.value.match(/^\s*\d+\s*$/)) ? af.value : "'" + af.value + "'");
adhocCondition.push(cond);
if (ast.where.length > 0) {
// OR is not implemented
Expand Down

0 comments on commit 08c152e

Please sign in to comment.