bc18f2c890541766ea5eb5a0190069e58a28bf8e
[portal/sdk.git] /
1 appDS2.factory('SelfProfileService', function ($http, $q) {
2         return {
3                 getProfileDetail: function(profileId) {
4                         return $http({
5                                 method: "GET",
6                 url: "get_profile?profile_id=" + profileId,
7                         
8                         }).then(function(response) {
9                                 if (response.status == 200) {
10                                         return response.data;
11                                 } else {
12                                         return $q.reject(response.data);
13                                 }
14                                 return response.data;
15
16                         }, function(response) {
17                                 // something went wrong
18                                 return $q.reject(response.data);
19                         });
20                 },
21         
22                 getSelfProfileDetail: function() {
23                         return $http.get('get_self_profile')
24                         .then(function(response) {
25                                 if (typeof response.data === 'object') {
26                                         return response.data;
27                                 } else {
28                                         return $q.reject(response.data);
29                                 }
30         
31                         }, function(response) {
32                                 // something went wrong
33                                 return $q.reject(response.data);
34                         });
35                 },
36                 
37                 addRole: function(roleData,profileId) {
38                         return $http({
39                                 method: "POST",
40                 url: "profile/addNewRole?profile_id=" + profileId,
41                 data:roleData
42                         
43                         }).then(function(response) {
44                                 if (response.status == 200) {
45                                         return response.data;
46                                 } else {
47                                         return $q.reject(response.data);
48                                 }
49                                 return response.data;
50
51                         }, function(response) {
52                                 // something went wrong
53                                 return $q.reject(response.data);
54                         });
55                 },
56                 deRole: function(roleData,profileId) {
57                         return $http({
58                                 method: "POST",
59                 url: "profile/removeRole?profile_id=" + profileId,
60                 data:roleData
61                         
62                         }).then(function(response) {
63                                 if (response.status == 200) {
64                                         return response.data;
65                                 } else {
66                                         return $q.reject(response.data);
67                                 }
68                                 return response.data;
69
70                         }, function(response) {
71                                 // something went wrong
72                                 return $q.reject(response.data);
73                         });
74                 },
75                 saveProfile: function(data,profileId) {
76                         return $http({
77                                 method: "POST",
78                 url: "profile/saveProfile?profile_id=" + profileId,
79                 data:data
80                         
81                         }).then(function(response) {
82                                 if (response.status == 200) {
83                                         return response.data;
84                                 } else {
85                                         return $q.reject(response.data);
86                                 }
87                                 return response.data;
88
89                         }, function(response) {
90                                 // something went wrong
91                                 return $q.reject(response.data);
92                         });
93                 },
94                 removeRole: function(data,profileId) {
95                         return $http({
96                                 method: "POST",
97                 url: "profile/removeRole?profile_id=" + profileId,
98                 data:data
99                         
100                         }).then(function(response) {
101                                 if (response.status == 200) {
102                                         return response.data;
103                                 } else {
104                                         return $q.reject(response.data);
105                                 }
106                                 return response.data;
107
108                         }, function(response) {
109                                 // something went wrong
110                                 return $q.reject(response.data);
111                         });
112                 }
113         };
114 });