aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_gui/static/app/services/partner/project.service.js
blob: 4ec27f2eb32e81c27a4a4d254424df71406c3322 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
 * Service providing access to the tenants
 * @author arnaud marhin<arnaud.marhin@orange.com>
 */

(function() {

	'use strict';

	angular
		.module('moon')
				.factory('projectService', projectService);

    projectService.$inject = [ '$resource' , 'REST_URI' ];
	
	function projectService( $resource, REST_URI) {
	                                   	
		return {
			
			data: {

				projects: $resource(REST_URI.KEYSTONE + 'projects/:project_id', {}, {
					query: {method: 'GET', isArray: false},
                    get: { method: 'GET', isArray: false },
                    create: { method: 'POST' },
                    remove: { method: 'DELETE' }
                })

			},

			findOne: function(project_id, callback){

                return this.data.projects.get({project_id: project_id}).$promise.then(function(data) {

                    callback(data.project);

                });

			},

            findAll: function() {

                return this.data.projects.query().$promise.then(function(listProjects) {

                    var result = [];

                    _.each(listProjects['projects'], function(item){
                        result.push(item);
                    });

                    return result;
                });

            }
        
        };
    
    }
	
})();