mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
finally removed elasticjs library
This commit is contained in:
parent
7914f65f68
commit
438455bc8c
@ -7,7 +7,6 @@ define([
|
|||||||
'underscore',
|
'underscore',
|
||||||
'require',
|
'require',
|
||||||
'config',
|
'config',
|
||||||
'elasticjs',
|
|
||||||
'bootstrap',
|
'bootstrap',
|
||||||
'angular-sanitize',
|
'angular-sanitize',
|
||||||
'angular-strap',
|
'angular-strap',
|
||||||
@ -62,7 +61,6 @@ function (angular, $, _, appLevelRequire, config) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var apps_deps = [
|
var apps_deps = [
|
||||||
'elasticjs.service',
|
|
||||||
'$strap.directives',
|
'$strap.directives',
|
||||||
'ngSanitize',
|
'ngSanitize',
|
||||||
'ngDragDrop',
|
'ngDragDrop',
|
||||||
|
@ -42,7 +42,6 @@ require.config({
|
|||||||
'jquery.flot.byte': '../vendor/jquery/jquery.flot.byte',
|
'jquery.flot.byte': '../vendor/jquery/jquery.flot.byte',
|
||||||
|
|
||||||
modernizr: '../vendor/modernizr-2.6.1',
|
modernizr: '../vendor/modernizr-2.6.1',
|
||||||
elasticjs: '../vendor/elasticjs/elastic-angular-client',
|
|
||||||
|
|
||||||
'bootstrap-tagsinput': '../vendor/tagsinput/bootstrap-tagsinput',
|
'bootstrap-tagsinput': '../vendor/tagsinput/bootstrap-tagsinput',
|
||||||
|
|
||||||
@ -103,8 +102,6 @@ require.config({
|
|||||||
timepicker: ['jquery', 'bootstrap'],
|
timepicker: ['jquery', 'bootstrap'],
|
||||||
datepicker: ['jquery', 'bootstrap'],
|
datepicker: ['jquery', 'bootstrap'],
|
||||||
|
|
||||||
elasticjs: ['angular', '../vendor/elasticjs/elastic'],
|
|
||||||
|
|
||||||
'bootstrap-tagsinput': ['jquery'],
|
'bootstrap-tagsinput': ['jquery'],
|
||||||
},
|
},
|
||||||
waitSeconds: 60,
|
waitSeconds: 60,
|
||||||
|
@ -94,7 +94,6 @@ function (angular, $, kbn, _) {
|
|||||||
/*
|
/*
|
||||||
var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
|
var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
|
||||||
|
|
||||||
|
|
||||||
this.gist_id = function(string) {
|
this.gist_id = function(string) {
|
||||||
if(self.is_gist(string)) {
|
if(self.is_gist(string)) {
|
||||||
return string.match(gist_pattern)[0].replace(/.*\//, '');
|
return string.match(gist_pattern)[0].replace(/.*\//, '');
|
||||||
@ -109,224 +108,6 @@ function (angular, $, kbn, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.to_file = function() {
|
|
||||||
var blob = new Blob([angular.toJson(self.current,true)], {type: "application/json;charset=utf-8"});
|
|
||||||
// from filesaver.js
|
|
||||||
window.saveAs(blob, self.current.title+"-"+new Date().getTime());
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.set_default = function(route) {
|
|
||||||
if (Modernizr.localstorage) {
|
|
||||||
// Purge any old dashboards
|
|
||||||
if(!_.isUndefined(window.localStorage['dashboard'])) {
|
|
||||||
delete window.localStorage['dashboard'];
|
|
||||||
}
|
|
||||||
window.localStorage.grafanaDashboardDefault = route;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.purge_default = function() {
|
|
||||||
if (Modernizr.localstorage) {
|
|
||||||
// Purge any old dashboards
|
|
||||||
if(!_.isUndefined(window.localStorage['dashboard'])) {
|
|
||||||
|
|
||||||
delete window.localStorage['dashboard'];
|
|
||||||
}
|
|
||||||
delete window.localStorage.grafanaDashboardDefault;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// TOFIX: Pretty sure this breaks when you're on a saved dashboard already
|
|
||||||
this.share_link = function(title,type,id) {
|
|
||||||
return {
|
|
||||||
location : window.location.href.replace(window.location.hash,""),
|
|
||||||
type : type,
|
|
||||||
id : id,
|
|
||||||
link : window.location.href.replace(window.location.hash,"")+"#dashboard/"+type+"/"+id,
|
|
||||||
title : title
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var renderTemplate = function(json,params) {
|
|
||||||
var _r;
|
|
||||||
_.templateSettings = {interpolate : /\{\{(.+?)\}\}/g};
|
|
||||||
var template = _.template(json);
|
|
||||||
var rendered = template({ARGS:params});
|
|
||||||
try {
|
|
||||||
_r = angular.fromJson(rendered);
|
|
||||||
} catch(e) {
|
|
||||||
_r = false;
|
|
||||||
}
|
|
||||||
return _r;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.local_load = function() {
|
|
||||||
var dashboard = JSON.parse(window.localStorage['dashboard']);
|
|
||||||
dashboard.rows.unshift({
|
|
||||||
height: "30",
|
|
||||||
title: "Deprecation Notice",
|
|
||||||
panels: [
|
|
||||||
{
|
|
||||||
title: 'WARNING: Legacy dashboard',
|
|
||||||
type: 'text',
|
|
||||||
span: 12,
|
|
||||||
mode: 'html',
|
|
||||||
content: 'This dashboard has been loaded from the browsers local cache. If you use '+
|
|
||||||
'another brower or computer you will not be able to access it! '+
|
|
||||||
'\n\n <h4>Good news!</h4> Kibana'+
|
|
||||||
' now stores saved dashboards in Elasticsearch. Click the <i class="icon-save"></i> '+
|
|
||||||
'button in the top left to save this dashboard. Then select "Set as Home" from'+
|
|
||||||
' the "advanced" sub menu to automatically use the stored dashboard as your Kibana '+
|
|
||||||
'landing page afterwards'+
|
|
||||||
'<br><br><strong>Tip:</strong> You may with to remove this row before saving!'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
self.dash_load(dashboard);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.file_load = function(file) {
|
|
||||||
return $http({
|
|
||||||
url: "app/dashboards/"+file.replace(/\.(?!json)/,"/")+'?' + new Date().getTime(),
|
|
||||||
method: "GET",
|
|
||||||
transformResponse: function(response) {
|
|
||||||
return renderTemplate(response,$routeParams);
|
|
||||||
}
|
|
||||||
}).then(function(result) {
|
|
||||||
if(!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self.dash_load(dash_defaults(result.data));
|
|
||||||
return true;
|
|
||||||
},function() {
|
|
||||||
alertSrv.set('Error',"Could not load <i>dashboards/"+file+"</i>. Please make sure it exists" ,'error');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.elasticsearch_load = function(type,id) {
|
|
||||||
var options = {
|
|
||||||
url: config.elasticsearch + "/" + config.grafana_index + "/"+type+"/"+id+'?' + new Date().getTime(),
|
|
||||||
method: "GET",
|
|
||||||
transformResponse: function(response) {
|
|
||||||
return renderTemplate(angular.fromJson(response)._source.dashboard, $routeParams);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (config.elasticsearchBasicAuth) {
|
|
||||||
options.withCredentials = true;
|
|
||||||
options.headers = {
|
|
||||||
"Authorization": "Basic " + config.elasticsearchBasicAuth
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return $http(options)
|
|
||||||
.error(function(data, status) {
|
|
||||||
if(status === 0) {
|
|
||||||
alertSrv.set('Error',"Could not contact Elasticsearch at "+config.elasticsearch+
|
|
||||||
". Please ensure that Elasticsearch is reachable from your system." ,'error');
|
|
||||||
} else {
|
|
||||||
alertSrv.set('Error',"Could not find "+id+". If you"+
|
|
||||||
" are using a proxy, ensure it is configured correctly",'error');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}).success(function(data) {
|
|
||||||
self.dash_load(data);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.script_load = function(file) {
|
|
||||||
return $http({
|
|
||||||
url: "app/dashboards/"+file.replace(/\.(?!js)/,"/"),
|
|
||||||
method: "GET"
|
|
||||||
})
|
|
||||||
.then(function(result) {
|
|
||||||
/*jshint -W054 */
|
|
||||||
/*
|
|
||||||
var script_func = new Function('ARGS','kbn','_','moment','window','document','$','jQuery', result.data);
|
|
||||||
var script_result = script_func($routeParams,kbn,_,moment, window, document, $, $);
|
|
||||||
|
|
||||||
// Handle async dashboard scripts
|
|
||||||
if (_.isFunction(script_result)) {
|
|
||||||
var deferred = $q.defer();
|
|
||||||
script_result(function(dashboard) {
|
|
||||||
$rootScope.$apply(function() {
|
|
||||||
deferred.resolve({ data: dashboard });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { data: script_result };
|
|
||||||
})
|
|
||||||
.then(function(result) {
|
|
||||||
if(!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self.dash_load(dash_defaults(result.data));
|
|
||||||
return true;
|
|
||||||
},function() {
|
|
||||||
alertSrv.set('Error',
|
|
||||||
"Could not load <i>scripts/"+file+"</i>. Please make sure it exists and returns a valid dashboard" ,
|
|
||||||
'error');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.elasticsearch_save = function(type,title,ttl) {
|
|
||||||
// Clone object so we can modify it without influencing the existing obejct
|
|
||||||
var save = _.clone(self.current);
|
|
||||||
var id;
|
|
||||||
|
|
||||||
// Change title on object clone
|
|
||||||
if (type === 'dashboard') {
|
|
||||||
id = save.title = _.isUndefined(title) ? self.current.title : title;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create request with id as title. Rethink this.
|
|
||||||
var request = ejs.Document(config.grafana_index,type,id).source({
|
|
||||||
user: 'guest',
|
|
||||||
group: 'guest',
|
|
||||||
title: save.title,
|
|
||||||
tags: save.tags,
|
|
||||||
dashboard: angular.toJson(save)
|
|
||||||
});
|
|
||||||
|
|
||||||
request = type === 'temp' && ttl ? request.ttl(ttl) : request;
|
|
||||||
|
|
||||||
return request.doIndex(
|
|
||||||
// Success
|
|
||||||
function(result) {
|
|
||||||
if(type === 'dashboard') {
|
|
||||||
$location.path('/dashboard/elasticsearch/'+title);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
// Failure
|
|
||||||
function() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.elasticsearch_delete = function(id) {
|
|
||||||
return ejs.Document(config.grafana_index,'dashboard',id).doDelete(
|
|
||||||
// Success
|
|
||||||
function(result) {
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
// Failure
|
|
||||||
function() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.save_gist = function(title,dashboard) {
|
this.save_gist = function(title,dashboard) {
|
||||||
var save = _.clone(dashboard || self.current);
|
var save = _.clone(dashboard || self.current);
|
||||||
save.title = title || self.current.title;
|
save.title = title || self.current.title;
|
||||||
@ -366,21 +147,6 @@ function (angular, $, kbn, _) {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.set_interval = function (interval) {
|
|
||||||
self.current.refresh = interval;
|
|
||||||
if(interval) {
|
|
||||||
var _i = kbn.interval_to_ms(interval);
|
|
||||||
timer.cancel(self.refresh_timer);
|
|
||||||
self.refresh_timer = timer.register($timeout(function() {
|
|
||||||
self.set_interval(interval);
|
|
||||||
self.refresh();
|
|
||||||
},_i));
|
|
||||||
self.refresh();
|
|
||||||
} else {
|
|
||||||
timer.cancel(self.refresh_timer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -45,7 +45,6 @@ require.config({
|
|||||||
'jquery.flot.byte': '../vendor/jquery/jquery.flot.byte',
|
'jquery.flot.byte': '../vendor/jquery/jquery.flot.byte',
|
||||||
|
|
||||||
modernizr: '../vendor/modernizr-2.6.1',
|
modernizr: '../vendor/modernizr-2.6.1',
|
||||||
elasticjs: '../vendor/elasticjs/elastic-angular-client',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
shim: {
|
shim: {
|
||||||
@ -100,8 +99,6 @@ require.config({
|
|||||||
|
|
||||||
timepicker: ['jquery', 'bootstrap'],
|
timepicker: ['jquery', 'bootstrap'],
|
||||||
datepicker: ['jquery', 'bootstrap'],
|
datepicker: ['jquery', 'bootstrap'],
|
||||||
|
|
||||||
elasticjs: ['angular', '../vendor/elasticjs/elastic'],
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
100
src/vendor/elasticjs/elastic-angular-client.js
vendored
100
src/vendor/elasticjs/elastic-angular-client.js
vendored
@ -1,100 +0,0 @@
|
|||||||
/*! elastic.js - v1.1.1 - 2013-05-24
|
|
||||||
* https://github.com/fullscale/elastic.js
|
|
||||||
* Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */
|
|
||||||
|
|
||||||
/*jshint browser:true */
|
|
||||||
/*global angular:true */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/*
|
|
||||||
Angular.js service wrapping the elastic.js API. This module can simply
|
|
||||||
be injected into your angular controllers.
|
|
||||||
*/
|
|
||||||
angular.module('elasticjs.service', [])
|
|
||||||
.factory('ejsResource', ['$http', function ($http) {
|
|
||||||
|
|
||||||
return function (config, basicAuth) {
|
|
||||||
|
|
||||||
var
|
|
||||||
|
|
||||||
// use existing ejs object if it exists
|
|
||||||
ejs = window.ejs || {},
|
|
||||||
|
|
||||||
/* results are returned as a promise */
|
|
||||||
promiseThen = function (httpPromise, successcb, errorcb) {
|
|
||||||
return httpPromise.then(function (response) {
|
|
||||||
(successcb || angular.noop)(response.data);
|
|
||||||
return response.data;
|
|
||||||
}, function (response) {
|
|
||||||
(errorcb || angular.noop)(response.data);
|
|
||||||
return response.data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// check if we have a config object
|
|
||||||
// if not, we have the server url so
|
|
||||||
// we convert it to a config object
|
|
||||||
if (config !== Object(config)) {
|
|
||||||
config = {server: config};
|
|
||||||
}
|
|
||||||
|
|
||||||
// set url to empty string if it was not specified
|
|
||||||
if (config.server == null) {
|
|
||||||
config.server = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// set authentication header
|
|
||||||
if (basicAuth || config.basicAuth) {
|
|
||||||
config.headers = angular.extend( config.headers||{}, {
|
|
||||||
"Authorization": "Basic " + (basicAuth||config.basicAuth)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/* implement the elastic.js client interface for angular */
|
|
||||||
ejs.client = {
|
|
||||||
server: function (s) {
|
|
||||||
if (s == null) {
|
|
||||||
return config.server;
|
|
||||||
}
|
|
||||||
|
|
||||||
config.server = s;
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
post: function (path, data, successcb, errorcb) {
|
|
||||||
path = config.server + path;
|
|
||||||
var reqConfig = {url: path, data: data, method: 'POST'};
|
|
||||||
return promiseThen($http(angular.extend(reqConfig, config)), successcb, errorcb);
|
|
||||||
},
|
|
||||||
get: function (path, data, successcb, errorcb) {
|
|
||||||
path = config.server + path;
|
|
||||||
// no body on get request, data will be request params
|
|
||||||
var reqConfig = {url: path, params: data, method: 'GET'};
|
|
||||||
return promiseThen($http(angular.extend(reqConfig, config)), successcb, errorcb);
|
|
||||||
},
|
|
||||||
put: function (path, data, successcb, errorcb) {
|
|
||||||
path = config.server + path;
|
|
||||||
var reqConfig = {url: path, data: data, method: 'PUT'};
|
|
||||||
return promiseThen($http(angular.extend(reqConfig, config)), successcb, errorcb);
|
|
||||||
},
|
|
||||||
del: function (path, data, successcb, errorcb) {
|
|
||||||
path = config.server + path;
|
|
||||||
var reqConfig = {url: path, data: data, method: 'DELETE'};
|
|
||||||
return promiseThen($http(angular.extend(reqConfig, config)), successcb, errorcb);
|
|
||||||
},
|
|
||||||
head: function (path, data, successcb, errorcb) {
|
|
||||||
path = config.server + path;
|
|
||||||
// no body on HEAD request, data will be request params
|
|
||||||
var reqConfig = {url: path, params: data, method: 'HEAD'};
|
|
||||||
return $http(angular.extend(reqConfig, config))
|
|
||||||
.then(function (response) {
|
|
||||||
(successcb || angular.noop)(response.headers());
|
|
||||||
return response.headers();
|
|
||||||
}, function (response) {
|
|
||||||
(errorcb || angular.noop)(undefined);
|
|
||||||
return undefined;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return ejs;
|
|
||||||
};
|
|
||||||
}]);
|
|
22268
src/vendor/elasticjs/elastic.js
vendored
22268
src/vendor/elasticjs/elastic.js
vendored
File diff suppressed because it is too large
Load Diff
@ -49,7 +49,6 @@ module.exports = function(config,grunt) {
|
|||||||
'settings',
|
'settings',
|
||||||
'bootstrap',
|
'bootstrap',
|
||||||
'modernizr',
|
'modernizr',
|
||||||
'elasticjs',
|
|
||||||
'timepicker',
|
'timepicker',
|
||||||
'datepicker',
|
'datepicker',
|
||||||
'underscore',
|
'underscore',
|
||||||
|
Loading…
Reference in New Issue
Block a user