aboutsummaryrefslogtreecommitdiffstats
path: root/old/moon_gui/static/app/services/moon/policy/parameters/rule.service.js
blob: b1a350ae31d48ffbdce8b3327c01525c7bf86f80 (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
/**
 * @author Samy Abdallah
 */

(function() {

    'use strict';

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

    ruleService.$inject = ['$resource', 'REST_URI', 'utilService'];

    function ruleService($resource, REST_URI, utilService) {

        return {

            data: {

                policy: $resource(REST_URI.POLICIES + ':policy_id/rules/:rule_id', {}, {
                    get: {method: 'GET'},
                    create: {method: 'POST'},
                    remove: {method: 'DELETE'}
                })

            },

            findAllFromPolicyWithCallback: function(policyId, callback){

                this.data.policy.get({policy_id: policyId}).$promise.then(function(data) {

                    console.log('ruleService - findAllFromPolicyWithCallback()');
                    console.log(data);

                    var array = data['rules'];

                    console.log(JSON.stringify(array));
                    callback(utilService.transform(array, 'rules'));

                });

            }


        }

    }
})();