Skip to content
Snippets Groups Projects
Commit 4ad428c3 authored by Leonardo Menezes's avatar Leonardo Menezes
Browse files

created ConnectDataService

parent 834c7869
No related branches found
No related tags found
No related merge requests found
......@@ -514,6 +514,37 @@ angular.module('cerebro').controller('ConnectController', [
}]);
angular.module('cerebro').factory('ConnectDataService', ['$http',
function($http) {
this.getHosts = function(success, error) {
var config = {method: 'GET', url: 'connect/hosts'};
var handleSuccess = function(data) {
if (data.status >= 200 && data.status < 300) {
success(data.body);
} else {
error(data.body);
}
};
$http(config).success(handleSuccess).error(error);
};
this.connect = function(host, success, error) {
var config = {method: 'POST', url: 'connect', data: {host: host}};
$http(config).success(success).error(error);
};
this.authorize = function(host, username, password, success, error) {
var data = {host: host, username: username, password: password};
var config = {method: 'POST', url: 'connect', data: data};
$http(config).success(success).error(error);
};
return this;
}
]);
angular.module('cerebro').controller('CreateIndexController', ['$scope',
'AlertService', 'DataService', 'AceEditorService', 'RefreshService',
function($scope, AlertService, DataService, AceEditorService,
......
angular.module('cerebro').factory('ConnectDataService', ['$http',
function($http) {
this.getHosts = function(success, error) {
var config = {method: 'GET', url: 'connect/hosts'};
var handleSuccess = function(data) {
if (data.status >= 200 && data.status < 300) {
success(data.body);
} else {
error(data.body);
}
};
$http(config).success(handleSuccess).error(error);
};
this.connect = function(host, success, error) {
var config = {method: 'POST', url: 'connect', data: {host: host}};
$http(config).success(success).error(error);
};
this.authorize = function(host, username, password, success, error) {
var data = {host: host, username: username, password: password};
var config = {method: 'POST', url: 'connect', data: data};
$http(config).success(success).error(error);
};
return this;
}
]);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment