Skip to content

Commit

Permalink
Clickable cells (#41)
Browse files Browse the repository at this point in the history
yesoreyeram authored Nov 11, 2018
1 parent f2ce20a commit 93d32ba
Showing 13 changed files with 89 additions and 7 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ Logic is same as background color. But the value to be displayed can be altered

`_row_name_` will be replaced by row name. This will be useful when you hide the first column.

`_col_name_` will be replaced by row name. This will be useful when you hide the table header.
`_col_name_` will be replaced by col name. This will be useful when you hide the table header.

Example transformation patterns :

@@ -226,6 +226,20 @@ Sample value transformation: (Assume your metrics results, 95 and it is percenta
HOT (_value_ > threshold of 80%) --> HOT (95% > threshold of 80%)
Contact helpdesk --> Contact helpdesk

Table Cell links
----------------

Table cells can be clickable and open links in new tabs.

If the URL contains `_row_name_`, it will be replaced by row name.

If the URL contains `_col_name_`, it will be replaced by col name.

Note : If the row_name / col_name contains font awesome keywords like `_fa-circle_`, they will be ignored.


Example : `https://mysite.com/_row_name_/_col_name_/?foo=bar`

Filter
------

@@ -301,6 +315,7 @@ Same as other time series data sources. You need to properly format your legend
* Filter option to hide rows based on value
* Option to hide the first column and table header
* Font Awesome icons support (From 0.4.6)
* Clickable cells (From 0.4.7)

**Version 0.3.x**

17 changes: 16 additions & 1 deletion dist/README.md
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ Logic is same as background color. But the value to be displayed can be altered

`_row_name_` will be replaced by row name. This will be useful when you hide the first column.

`_col_name_` will be replaced by row name. This will be useful when you hide the table header.
`_col_name_` will be replaced by col name. This will be useful when you hide the table header.

Example transformation patterns :

@@ -226,6 +226,20 @@ Sample value transformation: (Assume your metrics results, 95 and it is percenta
HOT (_value_ > threshold of 80%) --> HOT (95% > threshold of 80%)
Contact helpdesk --> Contact helpdesk

Table Cell links
----------------

Table cells can be clickable and open links in new tabs.

If the URL contains `_row_name_`, it will be replaced by row name.

If the URL contains `_col_name_`, it will be replaced by col name.

Note : If the row_name / col_name contains font awesome keywords like `_fa-circle_`, they will be ignored.


Example : `https://mysite.com/_row_name_/_col_name_/?foo=bar`

Filter
------

@@ -301,6 +315,7 @@ Same as other time series data sources. You need to properly format your legend
* Filter option to hide rows based on value
* Option to hide the first column and table header
* Font Awesome icons support (From 0.4.6)
* Clickable cells (From 0.4.7)

**Version 0.3.x**

2 changes: 2 additions & 0 deletions dist/app/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions dist/module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions dist/partials/patterns.html
Original file line number Diff line number Diff line change
@@ -128,6 +128,19 @@ <h5 class="text-warning">Patterns</h5>
ng-blur="ctrl.render()" data-ng-change="ctrl.render();">
</div>
</div>
<div class="gr-form-inline">
<div class="gf-form">
<label class="gf-form-label width-13">Enable Cell links</label>
<input type="checkbox" class="gf-form-input width-4" ng-model="pattern.enable_clickable_cells" ng-blur="ctrl.render()" ng-change="ctrl.render()">
</div>
</div>
<div class="gr-form-inline" data-ng-if="pattern.enable_clickable_cells">
<div class="gf-form">
<label class="gf-form-label width-13">Cells target URL</label>
<input type="text" placeholder="#" class="gf-form-input width-18" ng-model="pattern.clickable_cells_link" bs-tooltip="'Cell target URL'"
ng-blur="ctrl.render()" data-ng-change="ctrl.render();">
</div>
</div>
</div>
</div>
<div class="editor-row">
2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"url": "https://github.com/yesoreyeram/yesoreyeram-boomtable-panel"
}
],
"version": "0.4.6"
"version": "0.4.7"
},
"dependencies": {
"grafanaVersion": "4.x.x",
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yesoreyeram-boomtable-panel",
"version": "0.4.6",
"version": "0.4.7",
"description": "Boom table panel for Graphite, InfluxDB, Prometheus",
"main": "dist/module.js",
"scripts": {
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"url": "https://github.com/yesoreyeram/yesoreyeram-boomtable-panel"
}
],
"version": "0.4.6"
"version": "0.4.7"
},
"dependencies": {
"grafanaVersion": "4.x.x",
2 changes: 2 additions & 0 deletions src/app/app.ts
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ const config: any = {
format: "none",
null_color: "darkred",
null_value: "No data",
enable_clickable_cells : false,
clickable_cells_link : "",
filter : {
value_below : "",
value_above : ""
11 changes: 11 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -58,6 +58,8 @@ class GrafanaBoomTableCtrl extends MetricsPanelCtrl {
format: "none",
null_color: "darkred",
null_value: "No data",
enable_clickable_cells : false,
clickable_cells_link : "",
filter : {
value_below : "",
value_above : "",
@@ -409,6 +411,15 @@ GrafanaBoomTableCtrl.prototype.render = function () {
if(series.col_name && series.col_name.indexOf("_fa-")>-1) series.col_name = this.replaceFontAwesomeIcons(series.col_name)
return series;
});
this.dataComputed = this.dataComputed.map(series => {
if(series.pattern.enable_clickable_cells){
let targetLink = series.pattern.clickable_cells_link || "#";
targetLink = targetLink.replace(new RegExp("_row_name_", "g"), this.getActualNameWithoutFA(series.actual_row_name).trim());
targetLink = targetLink.replace(new RegExp("_col_name_", "g"), this.getActualNameWithoutFA(series.actual_col_name).trim());
series.displayValue = `<a href="${targetLink}" target="_blank">${series.displayValue}</a>`
}
return series;
});
// Grouping
const rows_found = utils.getFields(this.dataComputed, "row_name");
const cols_found = utils.getFields(this.dataComputed, "col_name");
13 changes: 13 additions & 0 deletions src/partials/patterns.html
Original file line number Diff line number Diff line change
@@ -128,6 +128,19 @@ <h5 class="text-warning">Patterns</h5>
ng-blur="ctrl.render()" data-ng-change="ctrl.render();">
</div>
</div>
<div class="gr-form-inline">
<div class="gf-form">
<label class="gf-form-label width-13">Enable Cell links</label>
<input type="checkbox" class="gf-form-input width-4" ng-model="pattern.enable_clickable_cells" ng-blur="ctrl.render()" ng-change="ctrl.render()">
</div>
</div>
<div class="gr-form-inline" data-ng-if="pattern.enable_clickable_cells">
<div class="gf-form">
<label class="gf-form-label width-13">Cells target URL</label>
<input type="text" placeholder="#" class="gf-form-input width-18" ng-model="pattern.clickable_cells_link" bs-tooltip="'Cell target URL'"
ng-blur="ctrl.render()" data-ng-change="ctrl.render();">
</div>
</div>
</div>
</div>
<div class="editor-row">

0 comments on commit 93d32ba

Please sign in to comment.