Commit 22d3fdac by Rashid Khan

Improved portability of exported JSON files, updated underscore.js

parent 42b415cf
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<div class="container-fluid"> <div class="container-fluid">
<span class="brand"><small>Kibana Preview</small></span> <span class="brand"><small>Kibana Preview</small></span>
<span class="brand">{{dashboards.title}}</span> <span class="brand">{{dashboards.title}}</span>
<div class="brand"><i class='icon-edit pointer' bs-modal="'partials/dasheditor.html'" bs-tooltip="'Edit Dashboard'" data-placement="bottom"></i></div> <div class="brand"><i class='icon-edit pointer' ng-show='dashboards.editable' bs-modal="'partials/dasheditor.html'"></i></div>
<div class="brand"><i class='icon-download pointer' ng-click="export()" bs-tooltip="'Export this dashboard'" data-placement="bottom"></i></div> <div class="brand"><i class='icon-download pointer' ng-click="export()" bs-tooltip="'Export this dashboard'" data-placement="bottom"></i></div>
<div class="brand"><i class='icon-bookmark pointer' ng-click="default()" bs-tooltip="'Set as default dashboard'" data-placement="bottom"></i></div> <div class="brand"><i class='icon-bookmark pointer' ng-click="default()" bs-tooltip="'Set as default dashboard'" data-placement="bottom"></i></div>
<div class="brand"><i class='icon-ban-circle pointer' ng-click="purge()" bs-tooltip="'Clear default dashboard settings'" data-placement="bottom"></i></div> <div class="brand"><i class='icon-ban-circle pointer' ng-click="purge()" bs-tooltip="'Clear default dashboard settings'" data-placement="bottom"></i></div>
......
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
'use strict'; 'use strict';
angular.module('kibana.controllers', []) angular.module('kibana.controllers', [])
.controller('DashCtrl', function($scope, $rootScope, ejsResource, timer) { .controller('DashCtrl', function($scope, $rootScope, $http, ejsResource, timer) {
var _d = {
title: "",
editable: true,
rows: [],
}
$scope.init = function() { $scope.init = function() {
$scope.config = config; $scope.config = config;
...@@ -18,14 +23,17 @@ angular.module('kibana.controllers', []) ...@@ -18,14 +23,17 @@ angular.module('kibana.controllers', [])
) { ) {
$scope.dashboards = JSON.parse(localStorage['dashboard']); $scope.dashboards = JSON.parse(localStorage['dashboard']);
} else { } else {
$scope.dashboards = dashboards; $scope.dashboards = dashboards
} }
_.defaults($scope.dashboards,_d)
var ejs = $scope.ejs = ejsResource(config.elasticsearch); var ejs = $scope.ejs = ejsResource(config.elasticsearch);
} }
$scope.export = function() { $scope.export = function() {
var blob = new Blob([angular.toJson($scope.dashboards)], {type: "application/json;charset=utf-8"}); var blob = new Blob([angular.toJson($scope.dashboards,true)], {type: "application/json;charset=utf-8"});
saveAs(blob, $scope.dashboards.title+"-"+new Date().getTime()); saveAs(blob, $scope.dashboards.title+"-"+new Date().getTime());
} }
......
...@@ -42,7 +42,7 @@ angular.module('kibana.histogram', []) ...@@ -42,7 +42,7 @@ angular.module('kibana.histogram', [])
$scope.get_data = function() { $scope.get_data = function() {
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.panel.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
...@@ -52,9 +52,9 @@ angular.module('kibana.histogram', []) ...@@ -52,9 +52,9 @@ angular.module('kibana.histogram', [])
_.each($scope.panel.query, function(v) { _.each($scope.panel.query, function(v) {
queries.push($scope.ejs.FilteredQuery( queries.push($scope.ejs.FilteredQuery(
ejs.QueryStringQuery(v.query || '*'), ejs.QueryStringQuery(v.query || '*'),
ejs.RangeFilter($scope.panel.time.field) ejs.RangeFilter($scope.time.field)
.from($scope.panel.time.from) .from($scope.time.from)
.to($scope.panel.time.to)) .to($scope.time.to))
) )
}); });
...@@ -62,7 +62,7 @@ angular.module('kibana.histogram', []) ...@@ -62,7 +62,7 @@ angular.module('kibana.histogram', [])
_.each(queries, function(v) { _.each(queries, function(v) {
request = request request = request
.facet($scope.ejs.DateHistogramFacet(_.indexOf(queries,v)) .facet($scope.ejs.DateHistogramFacet(_.indexOf(queries,v))
.field($scope.panel.time.field) .field($scope.time.field)
.interval($scope.panel.interval) .interval($scope.panel.interval)
.facetFilter($scope.ejs.QueryFilter(v)) .facetFilter($scope.ejs.QueryFilter(v))
).size(0) ).size(0)
...@@ -77,11 +77,11 @@ angular.module('kibana.histogram', []) ...@@ -77,11 +77,11 @@ angular.module('kibana.histogram', [])
$scope.data = []; $scope.data = [];
_.each(results.facets, function(v, k) { _.each(results.facets, function(v, k) {
// Null values at each end of the time range ensure we see entire range // Null values at each end of the time range ensure we see entire range
var data = [[$scope.panel.time.from.getTime(), null]]; var data = [[$scope.time.from.getTime(), null]];
_.each(v.entries, function(v, k) { _.each(v.entries, function(v, k) {
data.push([v['time'],v['count']]) data.push([v['time'],v['count']])
}); });
data.push([$scope.panel.time.to.getTime(), null]) data.push([$scope.time.to.getTime(), null])
var series = { data: { var series = { data: {
label: $scope.panel.query[k].label || k, label: $scope.panel.query[k].label || k,
...@@ -97,7 +97,7 @@ angular.module('kibana.histogram', []) ...@@ -97,7 +97,7 @@ angular.module('kibana.histogram', [])
} }
function set_time(time) { function set_time(time) {
$scope.panel.time = time; $scope.time = time;
$scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index $scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index
$scope.panel.interval = secondsToHms( $scope.panel.interval = secondsToHms(
calculate_interval(time.from,time.to,50,0)/1000), calculate_interval(time.from,time.to,50,0)/1000),
......
...@@ -23,7 +23,7 @@ angular.module('kibana.hits', []) ...@@ -23,7 +23,7 @@ angular.module('kibana.hits', [])
$scope.get_data = function() { $scope.get_data = function() {
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.panel.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
...@@ -32,8 +32,8 @@ angular.module('kibana.hits', []) ...@@ -32,8 +32,8 @@ angular.module('kibana.hits', [])
.query(ejs.FilteredQuery( .query(ejs.FilteredQuery(
ejs.QueryStringQuery($scope.panel.query || '*'), ejs.QueryStringQuery($scope.panel.query || '*'),
ejs.RangeFilter(config.timefield) ejs.RangeFilter(config.timefield)
.from($scope.panel.time.from) .from($scope.time.from)
.to($scope.panel.time.to) .to($scope.time.to)
) )
) )
.size(0) .size(0)
...@@ -51,7 +51,7 @@ angular.module('kibana.hits', []) ...@@ -51,7 +51,7 @@ angular.module('kibana.hits', [])
} }
function set_time(time) { function set_time(time) {
$scope.panel.time = time; $scope.time = time;
$scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index $scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index
$scope.get_data(); $scope.get_data();
} }
......
...@@ -26,7 +26,7 @@ angular.module('kibana.map', []) ...@@ -26,7 +26,7 @@ angular.module('kibana.map', [])
$scope.get_data = function() { $scope.get_data = function() {
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.panel.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
...@@ -41,8 +41,8 @@ angular.module('kibana.map', []) ...@@ -41,8 +41,8 @@ angular.module('kibana.map', [])
ejs.FilteredQuery( ejs.FilteredQuery(
ejs.QueryStringQuery($scope.panel.query || '*'), ejs.QueryStringQuery($scope.panel.query || '*'),
ejs.RangeFilter(config.timefield) ejs.RangeFilter(config.timefield)
.from($scope.panel.time.from) .from($scope.time.from)
.to($scope.panel.time.to) .to($scope.time.to)
)))).size(0) )))).size(0)
.doSearch(); .doSearch();
...@@ -58,7 +58,7 @@ angular.module('kibana.map', []) ...@@ -58,7 +58,7 @@ angular.module('kibana.map', [])
} }
function set_time(time) { function set_time(time) {
$scope.panel.time = time; $scope.time = time;
$scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index $scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index
$scope.get_data(); $scope.get_data();
} }
......
...@@ -50,7 +50,7 @@ angular.module('kibana.pie', []) ...@@ -50,7 +50,7 @@ angular.module('kibana.pie', [])
$scope.get_data = function() { $scope.get_data = function() {
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.panel.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
...@@ -65,8 +65,8 @@ angular.module('kibana.pie', []) ...@@ -65,8 +65,8 @@ angular.module('kibana.pie', [])
queries.push(ejs.FilteredQuery( queries.push(ejs.FilteredQuery(
ejs.QueryStringQuery(v.query || '*'), ejs.QueryStringQuery(v.query || '*'),
ejs.RangeFilter(config.timefield) ejs.RangeFilter(config.timefield)
.from($scope.panel.time.from) .from($scope.time.from)
.to($scope.panel.time.to)) .to($scope.time.to))
) )
}); });
...@@ -105,8 +105,8 @@ angular.module('kibana.pie', []) ...@@ -105,8 +105,8 @@ angular.module('kibana.pie', [])
ejs.FilteredQuery( ejs.FilteredQuery(
ejs.QueryStringQuery($scope.panel.query.query || '*'), ejs.QueryStringQuery($scope.panel.query.query || '*'),
ejs.RangeFilter(config.timefield) ejs.RangeFilter(config.timefield)
.from($scope.panel.time.from) .from($scope.time.from)
.to($scope.panel.time.to) .to($scope.time.to)
.cache(false) .cache(false)
)))).size(0) )))).size(0)
.doSearch(); .doSearch();
...@@ -133,7 +133,7 @@ angular.module('kibana.pie', []) ...@@ -133,7 +133,7 @@ angular.module('kibana.pie', [])
} }
function set_time(time) { function set_time(time) {
$scope.panel.time = time; $scope.time = time;
$scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index $scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index
$scope.get_data(); $scope.get_data();
} }
......
...@@ -56,7 +56,7 @@ angular.module('kibana.table', []) ...@@ -56,7 +56,7 @@ angular.module('kibana.table', [])
$scope.get_data = function() { $scope.get_data = function() {
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.panel.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
...@@ -65,8 +65,8 @@ angular.module('kibana.table', []) ...@@ -65,8 +65,8 @@ angular.module('kibana.table', [])
.query(ejs.FilteredQuery( .query(ejs.FilteredQuery(
ejs.QueryStringQuery($scope.panel.query || '*'), ejs.QueryStringQuery($scope.panel.query || '*'),
ejs.RangeFilter(config.timefield) ejs.RangeFilter(config.timefield)
.from($scope.panel.time.from) .from($scope.time.from)
.to($scope.panel.time.to) .to($scope.time.to)
) )
) )
.size($scope.panel.size) .size($scope.panel.size)
...@@ -100,7 +100,7 @@ angular.module('kibana.table', []) ...@@ -100,7 +100,7 @@ angular.module('kibana.table', [])
} }
function set_time(time) { function set_time(time) {
$scope.panel.time = time; $scope.time = time;
$scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index $scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index
$scope.get_data(); $scope.get_data();
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<label class="small">Title</label><input type="text" class="input-large" ng-model='dashboards.title'></input> <label class="small">Title</label><input type="text" class="input-large" ng-model='dashboards.title'></input>
</div> </div>
<div class="span1"> <div class="span1">
<label class="small"> Editable </label><input type="checkbox" ng-model="row.editable" ng-checked="dashboards.editable" /> <label class="small"> Editable </label><input type="checkbox" ng-model="dashboards.editable" ng-checked="dashboards.editable" />
</div> </div>
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment