Moved map js files, added exporting and saving of dashboard, added timer service to manage global timer cancelling, switched to font awesome

This commit is contained in:
Rashid Khan
2013-02-12 08:42:31 -07:00
parent 0d8f1fab9b
commit 0703dd8799
25 changed files with 1123 additions and 97 deletions
+1
View File
@@ -30,6 +30,7 @@ var labjs = $LAB
.script("common/lib/date.js")
.script("common/lib/datepicker.js")
.script("common/lib/shared.js")
.script("common/lib/filesaver.js")
.script("dashboards.js")
.script("js/services.js")
.script("js/controllers.js")
+22 -2
View File
@@ -3,10 +3,16 @@
'use strict';
angular.module('kibana.controllers', [])
.controller('DashCtrl', function($scope, $rootScope, ejsResource) {
.controller('DashCtrl', function($scope, $rootScope, ejsResource, timer) {
$scope.config = config;
$scope.dashboards = dashboards
if (Modernizr.localstorage && !(_.isUndefined(localStorage['dashboard']))) {
$scope.dashboards = JSON.parse(localStorage['dashboard']);
} else {
$scope.dashboards = dashboards;
}
var ejs = $scope.ejs = ejsResource(config.elasticsearch);
@@ -15,6 +21,20 @@ angular.module('kibana.controllers', [])
row.collapse = row.collapse ? false : true;
}
$scope.export = function() {
var blob = new Blob([angular.toJson($scope.dashboards)], {type: "application/json;charset=utf-8"});
saveAs(blob, $scope.dashboards.title+"-"+new Date().getTime());
}
$scope.default = function() {
if (Modernizr.localstorage) {
localStorage['dashboard'] = angular.toJson($scope.dashboards);
alert($scope.dashboards.title + " has been set as your default dashboard")
} else {
alert("Sorry, your browser is too old for this functionality");
}
}
});
+2 -1
View File
@@ -45,7 +45,7 @@ angular.module('kibana.directives', [])
}
};
})
.directive('upload', function(){
.directive('upload', function(timer){
return {
restrict: 'A',
link: function(scope, elem, attrs) {
@@ -60,6 +60,7 @@ angular.module('kibana.directives', [])
return function(e) {
// Render thumbnail.
scope.dashboards = JSON.parse(e.target.result)
timer.cancel_all();
scope.$apply();
};
})(f);
-69
View File
@@ -2,73 +2,4 @@
/*global angular:true */
'use strict';
/* NOTE: This is very much a preview, many things will change. In fact, this
file will probably go away
*/
/*
METAPARAMETERS
If you're implementing a panel, these are used by default. You need not handle
them in your directive.
span: The grid is made up of N rows, however there are only 12 columns. Span
is a number, 1-12
type: This is the name of your directive.
*/
/*
Histogram
Draw a histogram of a single query
NOTE: This will likely be renamed or get a setting that allows for non-time
based keys. It may also be updated to allow multiple stacked or unstacked
queries.
query: query to execute
interval: Bucket size in the standard Nunit (eg 1d, 5m, 30s) Attempts to auto
scale itself based on timespan
color: line/bar color.
show: array of what to show, (eg ['bars','lines','points'])
*/
/*
Piequery
Use a query facets to compare counts of for different queries, then show them
on a pie chart
queries: An array of queries
donut: Make a hole in the middle?
tilt: Tilt the pie in a 3dish way
legend: Show it or not?
colors: An array of colors to use for slices. These map 1-to-1 with the #
of queries in your queries array
*/
/* Pieterms
Use a terms facet to calculate the most popular terms for a field
query: Query to perform the facet on
size: Limit to this many terms
exclude: An array of terms to exclude from the results
donut: Make a hole in the middle?
tilt: Tilt the pie in a 3dish way
legend: Show it or not?
*/
/* Stackedquery
Use date histograms to assemble stacked bar or line charts representing
multple queries over time
queries: An array of queries
interval: Bucket size in the standard Nunit (eg 1d, 5m, 30s) Attempts to auto
scale itself based on timespan
colors: An array of colors to use for slices. These map 1-to-1 with the #
of queries in your queries array
show: array of what to show, (eg ['bars','lines','points'])
*/
angular.module('kibana.panels', [])
+24
View File
@@ -36,4 +36,28 @@ angular.module('kibana.services', [])
});
}
})
.service('timer', function($timeout) {
// This service really just tracks a list of $timeout promises to give us a
// method for cancelling them all when we need to
var timers = [];
this.register = function(promise) {
timers.push(promise);
return promise;
}
this.cancel = function(promise) {
timers = _.without(timers,promise)
$timeout.cancel(promise)
}
this.cancel_all = function() {
_.each(timers, function(t){
$timeout.cancel(t);
});
timers = new Array();
}
});