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

Added basic timestamp conversion support #181

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions dashboards/default
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
"@timestamp",
"@message"
],
"timestamp": [
"@timestamp"
]
"sortable": true
}
]
Expand Down
13 changes: 13 additions & 0 deletions panels/table/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ <h6>Highlighted fields <small>Click to remove</small></h6>
<span style="margin-left:3px" ng-click="toggle_highlight(field);set_refresh(true)" ng-repeat="field in $parent.panel.highlight" class="label remove pointer">{{field}} </span>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<form class="input-append">
<h6>Add field</h6>
<input bs-typeahead="fields.list" type="text" class="input-small" ng-model='newtimestamp' ng-change="set_refresh(true)">
<button class="btn" ng-click="toggle_timestamp(newtimestamp);newtimestamp=''"><i class="icon-plus"></i></button>
</form>
</div>
<div class="span8">
<h6>Timestamp fields <small>Click to remove</small></h6>
<span style="margin-left:3px" ng-click="toggle_timestamp(field);set_refresh(true)" ng-repeat="field in $parent.panel.timestamp" class="label remove pointer">{{field}} </span>
</div>
</div>
<h5>Options</h5>
<div class="row-fluid">
<div class="span1">
Expand Down
2 changes: 1 addition & 1 deletion panels/table/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
</div>
</div>
</div>
</kibana-panel>
</kibana-panel>
48 changes: 34 additions & 14 deletions panels/table/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,22 @@ angular.module('kibana.table', [])

// Set and populate defaults
var _d = {
status : "Stable",
query : "*",
size : 100, // Per page
pages : 5, // Pages available
offset : 0,
sort : ['@timestamp','desc'],
group : "default",
style : {'font-size': '9pt'},
overflow: 'height',
fields : [],
status : "Stable",
query : "*",
size : 100, // Per page
pages : 5, // Pages available
offset : 0,
sort : ['@timestamp','desc'],
group : "default",
style : {'font-size': '9pt'},
overflow : 'height',
fields : [],
highlight : [],
sortable: true,
header : true,
paging : true,
spyable: true
timestamp : ['@timestamp'],
sortable : true,
header : true,
paging : true,
spyable : true
}
_.defaults($scope.panel,_d)

Expand Down Expand Up @@ -105,6 +106,13 @@ angular.module('kibana.table', [])
$scope.panel.highlight.push(field)
}

$scope.toggle_timestamp = function(field) {
if (_.indexOf($scope.panel.timestamp,field) > -1)
$scope.panel.timestamp = _.without($scope.panel.timestamp,field)
else
$scope.panel.timestamp.push(field)
}

$scope.toggle_details = function(row) {
row.kibana = row.kibana || {};
row.kibana.details = !row.kibana.details ? $scope.without_kibana(row) : false;
Expand Down Expand Up @@ -191,6 +199,18 @@ angular.module('kibana.table', [])
if($scope.panel.sort[1] == 'desc')
$scope.data.reverse();

$scope.data = _.map($scope.data, function(row) {
result = _.map(row._source, function(v,k) {
if (_.contains($scope.panel.timestamp, k)) {
var d = new Date(v);
return d.toLocaleString();
}
return v;
});
row._source = _.object(_.keys(row._source),result);
return row;
});

// Keep only what we need for the set
$scope.data = $scope.data.slice(0,$scope.panel.size * $scope.panel.pages)

Expand Down