|
|
@@ -95,63 +95,5 @@ function (angular, $, kbn, _) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- /*
|
|
|
- var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
|
|
|
-
|
|
|
- this.gist_id = function(string) {
|
|
|
- if(self.is_gist(string)) {
|
|
|
- return string.match(gist_pattern)[0].replace(/.*\//, '');
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- this.is_gist = function(string) {
|
|
|
- if(!_.isUndefined(string) && string !== '' && !_.isNull(string.match(gist_pattern))) {
|
|
|
- return string.match(gist_pattern).length > 0 ? true : false;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- this.save_gist = function(title,dashboard) {
|
|
|
- var save = _.clone(dashboard || self.current);
|
|
|
- save.title = title || self.current.title;
|
|
|
- return $http({
|
|
|
- url: "https://api.github.com/gists",
|
|
|
- method: "POST",
|
|
|
- data: {
|
|
|
- "description": save.title,
|
|
|
- "public": false,
|
|
|
- "files": {
|
|
|
- "kibana-dashboard.json": {
|
|
|
- "content": angular.toJson(save,true)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }).then(function(data) {
|
|
|
- return data.data.html_url;
|
|
|
- }, function() {
|
|
|
- return false;
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- this.gist_list = function(id) {
|
|
|
- return $http.jsonp("https://api.github.com/gists/"+id+"?callback=JSON_CALLBACK"
|
|
|
- ).then(function(response) {
|
|
|
- var files = [];
|
|
|
- _.each(response.data.data.files,function(v) {
|
|
|
- try {
|
|
|
- var file = JSON.parse(v.content);
|
|
|
- files.push(file);
|
|
|
- } catch(e) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- return files;
|
|
|
- }, function() {
|
|
|
- return false;
|
|
|
- });
|
|
|
- };
|
|
|
- */
|
|
|
-
|
|
|
});
|
|
|
});
|