Some more stuff
This commit is contained in:
@@ -1,78 +1,21 @@
|
||||
app.factory('ApiService', function($http){
|
||||
var ApiService = function(http, endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
this.baseUrl = OC.generateUrl('/apps/deck/' + endpoint);
|
||||
this.http = http;
|
||||
this.hashMap = {};
|
||||
this.values = [];
|
||||
this.once = null;
|
||||
app.factory('StackService', function(ApiService, $http, $q){
|
||||
var StackService = function($http, ep, $q) {
|
||||
ApiService.call(this, $http, ep, $q);
|
||||
};
|
||||
|
||||
ApiService.prototype.getAll = function(){
|
||||
return $http.get(this.baseUrl);
|
||||
}
|
||||
|
||||
ApiService.prototype.getOne = function (id) {
|
||||
self = this;
|
||||
$http.get(this.baseUrl + '/' + id).then(function (response) {
|
||||
self.once = response.data;
|
||||
return response.data;
|
||||
StackService.prototype = angular.copy(ApiService.prototype);
|
||||
StackService.prototype.fetchAll = function(boardId) {
|
||||
var deferred = $q.defer();
|
||||
var self=this;
|
||||
$http.get(this.baseUrl +'/'+boardId).then(function (response) {
|
||||
self.addAll(response.data);
|
||||
deferred.resolve(self.data);
|
||||
}, function (error) {
|
||||
deferred.reject('Error while loading stacks');
|
||||
});
|
||||
return this.once;
|
||||
return deferred.promise;
|
||||
|
||||
};
|
||||
|
||||
ApiService.prototype.create = function (entity) {
|
||||
return $http.post(this.baseUrl, entity);
|
||||
};
|
||||
|
||||
ApiService.prototype.update = function (entity) {
|
||||
return $http.put(this.baseUrl, entity)
|
||||
};
|
||||
|
||||
ApiService.prototype.delete = function (id) {
|
||||
return $http.delete(this.baseUrl + '/' + id);
|
||||
};
|
||||
|
||||
return ApiService;
|
||||
});
|
||||
|
||||
app.factory('stackFactory', function($http){
|
||||
var service = {};
|
||||
var baseUrl = OC.generateUrl('/apps/deck/stacks');
|
||||
|
||||
service.getStacks = function(boardId){
|
||||
return $http.get(baseUrl + '/' + boardId);
|
||||
}
|
||||
|
||||
service.getStack = function (id) {
|
||||
return $http.get(baseUrl + '/' + id);
|
||||
};
|
||||
|
||||
service.createStack = function (stack) {
|
||||
return $http.post(baseUrl, stack);
|
||||
};
|
||||
|
||||
service.updateStack = function (stack) {
|
||||
return $http.put(baseUrl, stack)
|
||||
};
|
||||
|
||||
service.deleteStack = function (id) {
|
||||
return $http.delete(baseUrl + '/' + id);
|
||||
};
|
||||
|
||||
service = new StackService($http, 'stacks', $q)
|
||||
return service;
|
||||
});
|
||||
|
||||
app.factory('StackService', function(ApiService, $http){
|
||||
var StackService = function($http, ep) {
|
||||
ApiService.call(this, $http, ep);
|
||||
};
|
||||
StackService.prototype = ApiService.prototype;
|
||||
StackService.prototype.getAll = function(boardId) {
|
||||
return $http.get(this.baseUrl + '/' + boardId);
|
||||
}
|
||||
service = new StackService($http, 'stacks')
|
||||
return service;
|
||||
});
|
||||
Reference in New Issue
Block a user