Skip to content

Commit

Permalink
Upgrade elasticjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Nov 12, 2013
1 parent 444bb40 commit 22040c7
Show file tree
Hide file tree
Showing 2 changed files with 8,155 additions and 7,827 deletions.
61 changes: 37 additions & 24 deletions src/vendor/elasticjs/elastic-angular-client.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*! elastic.js - v1.0.0 - 2013-03-05
* https://github.com/fullscale/elastic.js
* Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */
/*! 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 */
/*jshint es5:true */
'use strict';

/*
/*
Angular.js service wrapping the elastic.js API. This module can simply
be injected into your angular controllers.
be injected into your angular controllers.
*/
angular.module('elasticjs.service', [])
.factory('ejsResource', ['$http', function ($http) {

return function (url) {
return function (config) {

var

Expand All @@ -32,40 +31,54 @@ angular.module('elasticjs.service', [])
});
};

// 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 (url == null) {
url = '';
if (config.server == null) {
config.server = '';
}

/* implement the elastic.js client interface for angular */
ejs.client = {
server: function (s) {
if (s == null) {
return url;
return config.server;
}
url = s;

config.server = s;
return this;
},
post: function (path, data, successcb, errorcb) {
path = url + path;
return promiseThen($http.post(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 = url + path;
return promiseThen($http.get(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 = url + path;
return promiseThen($http.put(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 = url + path;
return promiseThen($http.delete(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 = url + path;
return $http.head(path, data)
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();
Expand All @@ -75,7 +88,7 @@ angular.module('elasticjs.service', [])
});
}
};

return ejs;
};
}]);
}]);
Loading

0 comments on commit 22040c7

Please sign in to comment.