20 |
20 |
@Injectable()
|
21 |
21 |
export class HelpContentService {
|
22 |
22 |
|
23 |
|
constructor(private http:HttpClient) {
|
24 |
|
}
|
|
23 |
constructor(private http:HttpClient) {
|
|
24 |
}
|
25 |
25 |
|
26 |
|
static removeNulls(obj){
|
27 |
|
var isArray = obj instanceof Array;
|
28 |
|
for (var k in obj){
|
29 |
|
if (obj[k]===null || obj[k]==='') isArray ? obj.splice(k,1) : delete obj[k];
|
30 |
|
else if (typeof obj[k]=="object") HelpContentService.removeNulls(obj[k]);
|
31 |
|
}
|
32 |
|
}
|
33 |
|
|
34 |
|
getDivIdsFull(page_id: string, helpContentUrl:string, pid: string = null) {
|
35 |
|
let parameters: string = "";
|
36 |
|
if(page_id || pid) {
|
37 |
|
parameters = "?";
|
38 |
|
if(page_id) {
|
39 |
|
parameters += "&page="+page_id;
|
40 |
|
}
|
41 |
|
if(pid) {
|
42 |
|
parameters += "&portal="+pid;
|
43 |
|
}
|
|
26 |
static removeNulls(obj){
|
|
27 |
var isArray = obj instanceof Array;
|
|
28 |
for (var k in obj){
|
|
29 |
if (obj[k]===null || obj[k]==='') isArray ? obj.splice(k,1) : delete obj[k];
|
|
30 |
else if (typeof obj[k]=="object") HelpContentService.removeNulls(obj[k]);
|
44 |
31 |
}
|
|
32 |
}
|
45 |
33 |
|
46 |
|
return this.http.get<Array<DivId>>(helpContentUrl + 'divFull'+parameters)
|
47 |
|
//.map(res => <Array<DivId>> res.json())
|
48 |
|
.pipe(catchError(this.handleError));
|
49 |
|
}
|
|
34 |
getEntities(helpContentUrl:string) {
|
|
35 |
return this.http.get<Array<Entity>>(helpContentUrl + 'entity')
|
|
36 |
//.map(res => <Array<Entity>> res.json())
|
|
37 |
.pipe(catchError(this.handleError));
|
|
38 |
}
|
50 |
39 |
|
51 |
|
updateDivId(divId: DivId, helpContentUrl:string) {
|
52 |
|
HelpContentService.removeNulls(divId);
|
|
40 |
saveEntity(entity: Entity, helpContentUrl:string) {
|
|
41 |
HelpContentService.removeNulls(entity);
|
53 |
42 |
|
54 |
|
return this.http.post<DivId>(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
|
55 |
|
//.map(res => <DivId> res.json())
|
56 |
|
.pipe(catchError(this.handleError));
|
57 |
|
}
|
|
43 |
return this.http.post<Entity>(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
|
|
44 |
//.map(res => <Entity> res.json())
|
|
45 |
.pipe(catchError(this.handleError));
|
|
46 |
}
|
58 |
47 |
|
59 |
|
getDivId(divId: string, helpContentUrl:string) {
|
60 |
|
return this.http.get<DivId>(helpContentUrl + 'div/'+divId)
|
61 |
|
//.map(res => <DivId> res.json())
|
62 |
|
.pipe(catchError(this.handleError));
|
63 |
|
}
|
|
48 |
updateEntity(entity: Entity, helpContentUrl:string) {
|
|
49 |
HelpContentService.removeNulls(entity);
|
64 |
50 |
|
65 |
|
getDivIdFull(divId: string, helpContentUrl:string) {
|
66 |
|
return this.http.get<DivId>(helpContentUrl + 'divFull/'+divId)
|
67 |
|
//.map(res => <DivId> res.json())
|
68 |
|
.pipe(catchError(this.handleError));
|
69 |
|
}
|
|
51 |
return this.http.post<Entity>(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
|
|
52 |
//.map(res => <Entity> res.json())
|
|
53 |
.pipe(catchError(this.handleError));
|
|
54 |
}
|
70 |
55 |
|
71 |
|
saveDivId(divId: DivId, helpContentUrl:string) {
|
72 |
|
HelpContentService.removeNulls(divId);
|
|
56 |
deleteEntities(ids : string[], helpContentUrl:string) {
|
|
57 |
return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
58 |
.pipe(catchError(this.handleError));
|
|
59 |
}
|
73 |
60 |
|
74 |
|
return this.http.post<DivId>(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
|
75 |
|
//.map(res => <DivId> res.json())
|
76 |
|
.pipe(catchError(this.handleError));
|
77 |
|
}
|
78 |
|
/*
|
79 |
|
getCommunitiesWithDivId(helpContentUrl:string) {
|
80 |
|
return this.http.get(helpContentUrl + 'community?div=true')
|
81 |
|
.map(res => <Array<Portal>> res.json())
|
82 |
|
.catch(this.handleError);
|
83 |
|
}
|
84 |
|
*/
|
85 |
|
getCommunityPagesWithDivId(portal_pid: string, helpContentUrl:string) {
|
86 |
|
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/pages?div=true')
|
87 |
|
//.map(res => <Array<Page>> res.json())
|
88 |
|
.pipe(catchError(this.handleError));
|
89 |
|
}
|
|
61 |
// toggleEntity(selectedCommunityId: string, id : string,status : boolean) {
|
|
62 |
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
63 |
// let options = new RequestOptions({headers: headers});
|
|
64 |
//
|
|
65 |
// return this.http.post(helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options)
|
|
66 |
// .catch(this.handleError);
|
|
67 |
// }
|
90 |
68 |
|
91 |
|
getCommunityDivHelpContents(portal_pid: string, helpContentUrl:string) {
|
92 |
|
return this.http.get<Array<DivHelpContent>>(helpContentUrl + 'divhelpcontent?portal='+portal_pid)
|
93 |
|
//.map(res => <Array<DivHelpContent>> res.json())
|
94 |
|
.pipe(catchError(this.handleError));
|
95 |
|
}
|
|
69 |
getCommunityEntities(pid: string, helpContentUrl:string) {
|
|
70 |
return this.http.get<Array<Entity>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/entities')
|
|
71 |
//.map(res => <Array<Entity>> res.json())
|
|
72 |
.pipe(catchError(this.handleError));
|
|
73 |
}
|
96 |
74 |
|
97 |
|
getDivHelpContent(id : string, helpContentUrl:string) {
|
98 |
|
return this.http.get<DivHelpContent>(helpContentUrl + 'divhelpcontent/' + id)
|
99 |
|
//.map(res => <DivHelpContent> res.json())
|
100 |
|
.pipe(catchError(this.handleError));
|
101 |
|
}
|
|
75 |
toggleEntities(pid: string, ids : string[],status : boolean, helpContentUrl:string) {
|
102 |
76 |
|
103 |
|
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) {
|
104 |
|
HelpContentService.removeNulls(divHelpContent);
|
|
77 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+pid+ '/entity/toggle?status='+ status.toString(),
|
|
78 |
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
79 |
//.map( res => <string[]> res.json())
|
|
80 |
.pipe(catchError(this.handleError));
|
|
81 |
}
|
105 |
82 |
|
106 |
|
return this.http.post<DivHelpContent>(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
|
107 |
|
//.map(res => <DivHelpContent> res.json())
|
108 |
|
.pipe(catchError(this.handleError));
|
109 |
|
}
|
|
83 |
// unused
|
|
84 |
toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) {
|
|
85 |
return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(),
|
|
86 |
CustomOptions.getAuthOptionsWithBody())
|
|
87 |
.pipe(catchError(this.handleError));
|
|
88 |
}
|
110 |
89 |
|
111 |
|
deleteDivIds(ids : string[], helpContentUrl:string) {
|
112 |
|
return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
113 |
|
.pipe(catchError(this.handleError));
|
114 |
|
}
|
|
90 |
// getDivIdsFull(page_id: string, helpContentUrl:string, pid: string = null) {
|
|
91 |
// let parameters: string = "";
|
|
92 |
// if(page_id || pid) {
|
|
93 |
// parameters = "?";
|
|
94 |
// if(page_id) {
|
|
95 |
// parameters += "&page="+page_id;
|
|
96 |
// }
|
|
97 |
// if(pid) {
|
|
98 |
// parameters += "&portal="+pid;
|
|
99 |
// }
|
|
100 |
// }
|
|
101 |
//
|
|
102 |
// return this.http.get<Array<DivId>>(helpContentUrl + 'div/full'+parameters)
|
|
103 |
// //.map(res => <Array<DivId>> res.json())
|
|
104 |
// .pipe(catchError(this.handleError));
|
|
105 |
// }
|
115 |
106 |
|
116 |
|
deleteDivHelpContents(ids : string[], helpContentUrl:string) {
|
117 |
|
return this.http.post(helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
118 |
|
.pipe(catchError(this.handleError));
|
119 |
|
}
|
|
107 |
// Replacing getDivIdsFull
|
|
108 |
getAllDivIdsFull(helpContentUrl:string) {
|
|
109 |
return this.http.get<Array<DivId>>(helpContentUrl + 'div/full')
|
|
110 |
//.map(res => <Array<DivId>> res.json())
|
|
111 |
.pipe(catchError(this.handleError));
|
|
112 |
}
|
120 |
113 |
|
121 |
|
toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
|
|
114 |
getDivIdsFullByPageAndPortal(page_id: string, helpContentUrl:string, pid: string) {
|
|
115 |
let parameters: string = "?&page="+page_id;
|
122 |
116 |
|
123 |
|
return this.http.post(helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
124 |
|
//.map( res => <string[]> res.json())
|
125 |
|
.pipe(catchError(this.handleError));
|
126 |
|
}
|
|
117 |
return this.http.get<Array<DivId>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters)
|
|
118 |
.pipe(catchError(this.handleError));
|
|
119 |
}
|
|
120 |
// End of replacing getDivIdsFull
|
127 |
121 |
|
128 |
|
getPagesWithDivIds(portal_pid: string, helpContentUrl:string) {
|
129 |
|
let parameters = (portal_pid ? "?portal="+portal_pid : "");
|
130 |
|
return this.http.get<Array<string>>(helpContentUrl + 'div/pages'+parameters)
|
131 |
|
//.map(res => <Map<string, Set<string>>> res.json())
|
132 |
|
.pipe(catchError(this.handleError));
|
133 |
|
}
|
|
122 |
// unused
|
|
123 |
getDivId(divId: string, helpContentUrl:string) {
|
|
124 |
return this.http.get<DivId>(helpContentUrl + 'div/'+divId)
|
|
125 |
//.map(res => <DivId> res.json())
|
|
126 |
.pipe(catchError(this.handleError));
|
|
127 |
}
|
134 |
128 |
|
135 |
|
getPages(helpContentUrl:string,pid:string,with_positions:boolean=null) {
|
136 |
|
let parameters: string = "";
|
137 |
|
if(pid || with_positions == true || with_positions == false) {
|
138 |
|
parameters = "?";
|
139 |
|
if(pid) {
|
140 |
|
parameters += "&pid="+pid;
|
141 |
|
}
|
142 |
|
if(with_positions == true || with_positions == false) {
|
143 |
|
parameters += "&with_positions="+with_positions;
|
144 |
|
}
|
145 |
|
}
|
146 |
|
return this.http.get<Array<Page>>(helpContentUrl + 'page'+parameters)
|
147 |
|
//.map(res => <Array<Page>> res.json())
|
148 |
|
.pipe(catchError(this.handleError));
|
149 |
|
}
|
|
129 |
getDivIdFull(divId: string, helpContentUrl:string, pid: string) {
|
|
130 |
return this.http.get<DivId>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full")
|
|
131 |
//.map(res => <DivId> res.json())
|
|
132 |
.pipe(catchError(this.handleError));
|
|
133 |
}
|
150 |
134 |
|
151 |
|
getPagesFull(helpContentUrl:string,pid:string) {
|
152 |
|
return this.http.get<Array<Page>>(helpContentUrl + 'pageFull'+(pid?("?pid="+pid):""))
|
153 |
|
//.map(res => <Array<Page>> res.json())
|
|
135 |
updateDivId(divId: DivId, helpContentUrl:string) {
|
|
136 |
HelpContentService.removeNulls(divId);
|
|
137 |
|
|
138 |
return this.http.post<DivId>(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
|
|
139 |
//.map(res => <DivId> res.json())
|
|
140 |
.pipe(catchError(this.handleError));
|
|
141 |
}
|
|
142 |
|
|
143 |
saveDivId(divId: DivId, helpContentUrl:string) {
|
|
144 |
HelpContentService.removeNulls(divId);
|
|
145 |
|
|
146 |
return this.http.post<DivId>(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
|
|
147 |
//.map(res => <DivId> res.json())
|
154 |
148 |
.pipe(catchError(this.handleError));
|
155 |
|
}
|
|
149 |
}
|
156 |
150 |
|
157 |
|
getPage(pageId:string, helpContentUrl:string) {
|
158 |
|
return this.http.get<Page>(helpContentUrl + 'page/'+pageId)
|
159 |
|
//.map(res => <Page> res.json())
|
160 |
|
.pipe(catchError(this.handleError));
|
161 |
|
}
|
|
151 |
deleteDivIds(ids : string[], helpContentUrl:string) {
|
|
152 |
return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
153 |
.pipe(catchError(this.handleError));
|
|
154 |
}
|
162 |
155 |
|
163 |
|
getPageByRoute(route:string, helpContentUrl:string) {
|
164 |
|
return this.http.get<Page>(helpContentUrl + 'page/?page_route='+route)
|
|
156 |
getPageIdsFromDivIds(pid: string, helpContentUrl:string) {
|
|
157 |
//let parameters = (pid ? "?portal="+pid : "");
|
|
158 |
return this.http.get<Array<string>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/pages')
|
|
159 |
//.map(res => <Map<string, Set<string>>> res.json())
|
|
160 |
.pipe(catchError(this.handleError));
|
|
161 |
}
|
|
162 |
|
|
163 |
/*
|
|
164 |
getCommunitiesWithDivId(helpContentUrl:string) {
|
|
165 |
return this.http.get(helpContentUrl + 'community?div=true')
|
|
166 |
.map(res => <Array<Portal>> res.json())
|
|
167 |
.catch(this.handleError);
|
|
168 |
}
|
|
169 |
*/
|
|
170 |
|
|
171 |
getCommunityDivHelpContents(pid: string, helpContentUrl:string) {
|
|
172 |
return this.http.get<Array<DivHelpContent>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent')
|
|
173 |
//.map(res => <Array<DivHelpContent>> res.json())
|
165 |
174 |
.pipe(catchError(this.handleError));
|
166 |
|
}
|
|
175 |
}
|
167 |
176 |
|
168 |
|
getCommunities( helpContentUrl:string) {
|
169 |
|
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType)
|
170 |
|
//.map(res => <Array<Portal>> res.json())
|
171 |
|
.pipe(catchError(this.handleError));
|
172 |
|
}
|
|
177 |
getDivHelpContent(id : string, helpContentUrl:string, pid: string) {
|
|
178 |
return this.http.get<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/' + id)
|
|
179 |
//.map(res => <DivHelpContent> res.json())
|
|
180 |
.pipe(catchError(this.handleError));
|
|
181 |
}
|
173 |
182 |
|
174 |
|
getCommunity(portal_pid: string, helpContentUrl:string) {
|
175 |
|
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid)
|
176 |
|
//.map(res => <Portal> res.json())
|
177 |
|
.pipe(catchError(this.handleError));
|
178 |
|
}
|
|
183 |
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) {
|
|
184 |
HelpContentService.removeNulls(divHelpContent);
|
179 |
185 |
|
180 |
|
getCommunitiesFull( helpContentUrl:string) {
|
181 |
|
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + 'Full')
|
182 |
|
//.map(res => <Array<Portal>> res.json())
|
183 |
|
.pipe(catchError(this.handleError));
|
184 |
|
}
|
|
186 |
return this.http.post<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent',
|
|
187 |
JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
|
|
188 |
//.map(res => <DivHelpContent> res.json())
|
|
189 |
.pipe(catchError(this.handleError));
|
|
190 |
}
|
185 |
191 |
|
186 |
|
getCommunityFull(portal_pid: string, helpContentUrl:string) {
|
187 |
|
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + 'Full/'+portal_pid)
|
188 |
|
//.map(res => <Portal> res.json())
|
189 |
|
.pipe(catchError(this.handleError));
|
190 |
|
}
|
|
192 |
deleteDivHelpContents(ids : string[], helpContentUrl:string, pid: string) {
|
|
193 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/delete',
|
|
194 |
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
195 |
.pipe(catchError(this.handleError));
|
|
196 |
}
|
191 |
197 |
|
192 |
|
saveCommunity(portal: Portal, helpContentUrl:string) {
|
193 |
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
194 |
|
// let options = new RequestOptions({headers: headers});
|
|
198 |
toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) {
|
195 |
199 |
|
196 |
|
HelpContentService.removeNulls(portal);
|
|
200 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(),
|
|
201 |
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
202 |
//.map( res => <string[]> res.json())
|
|
203 |
.pipe(catchError(this.handleError));
|
|
204 |
}
|
197 |
205 |
|
198 |
|
return this.http.post<Portal>(helpContentUrl + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
|
199 |
|
//.map(res => <Portal> res.json())
|
200 |
|
.pipe(catchError(this.handleError));
|
201 |
|
}
|
|
206 |
// unused
|
|
207 |
getPageHelpContents(helpContentUrl:string) {
|
|
208 |
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
|
|
209 |
//.map(res => <Array<PageHelpContent>> res.json())
|
|
210 |
.pipe(catchError(this.handleError));
|
|
211 |
}
|
202 |
212 |
|
203 |
|
updateCommunity(portal: Portal, helpContentUrl:string) {
|
204 |
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
205 |
|
// let options = new RequestOptions({headers: headers});
|
|
213 |
getCommunityPageHelpContents(pid: string, helpContentUrl:string) {
|
|
214 |
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent')
|
|
215 |
//.map(res => <Array<PageHelpContent>> res.json())
|
|
216 |
.pipe(catchError(this.handleError));
|
|
217 |
}
|
206 |
218 |
|
207 |
|
HelpContentService.removeNulls(portal);
|
|
219 |
getPageHelpContent(id : string, helpContentUrl:string, pid: string) {
|
|
220 |
return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id)
|
|
221 |
//.map(res => <PageHelpContent> res.json())
|
|
222 |
.pipe(catchError(this.handleError));
|
|
223 |
}
|
208 |
224 |
|
209 |
|
return this.http.post<Portal>(helpContentUrl + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
|
210 |
|
//.map(res => <Portal> res.json())
|
211 |
|
.pipe(catchError(this.handleError));
|
212 |
|
}
|
|
225 |
savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) {
|
|
226 |
HelpContentService.removeNulls(pageHelpContent);
|
213 |
227 |
|
214 |
|
deleteCommunities(ids : string[], helpContentUrl:string) {
|
215 |
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
216 |
|
// let options = new RequestOptions({headers: headers});
|
|
228 |
return this.http.post<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/save',
|
|
229 |
JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
|
|
230 |
//.map(res => <PageHelpContent> res.json())
|
|
231 |
.pipe(catchError(this.handleError));
|
|
232 |
}
|
217 |
233 |
|
218 |
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
219 |
|
.pipe(catchError(this.handleError));
|
220 |
|
}
|
|
234 |
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) {
|
|
235 |
HelpContentService.removeNulls(pageHelpContent);
|
221 |
236 |
|
222 |
|
getCommunityPages(portal_pid: string, params: string, helpContentUrl:string) {
|
223 |
|
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/pages'+params)
|
224 |
|
//.map(res => <Array<Page>> res.json())
|
225 |
|
.pipe(catchError(this.handleError));
|
226 |
|
}
|
|
237 |
return this.http.post<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid +'/pagehelpcontent/update',
|
|
238 |
JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
|
|
239 |
//.map(res => <PageHelpContent> res.json())
|
|
240 |
.pipe(catchError(this.handleError));
|
|
241 |
}
|
227 |
242 |
|
228 |
|
getEntities(helpContentUrl:string) {
|
229 |
|
return this.http.get<Array<Entity>>(helpContentUrl + 'entity')
|
230 |
|
//.map(res => <Array<Entity>> res.json())
|
231 |
|
.pipe(catchError(this.handleError));
|
232 |
|
}
|
|
243 |
deletePageHelpContents(ids : string[], helpContentUrl:string, pid: string) {
|
|
244 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete',
|
|
245 |
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
246 |
.pipe(catchError(this.handleError));
|
|
247 |
}
|
233 |
248 |
|
234 |
|
getCommunityEntities(portal_pid: string, helpContentUrl:string) {
|
235 |
|
return this.http.get<Array<Entity>>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/entities')
|
236 |
|
//.map(res => <Array<Entity>> res.json())
|
237 |
|
.pipe(catchError(this.handleError));
|
238 |
|
}
|
|
249 |
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) {
|
|
250 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(),
|
|
251 |
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
252 |
//.map( res => <string[]> res.json())
|
|
253 |
.pipe(catchError(this.handleError));
|
|
254 |
}
|
239 |
255 |
|
|
256 |
getCommunityPagesWithDivId(pid: string, helpContentUrl:string) {
|
|
257 |
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true')
|
|
258 |
//.map(res => <Array<Page>> res.json())
|
|
259 |
.pipe(catchError(this.handleError));
|
|
260 |
}
|
240 |
261 |
|
241 |
|
saveEntity(entity: Entity, helpContentUrl:string) {
|
242 |
|
HelpContentService.removeNulls(entity);
|
|
262 |
// getCommunityPages(pid: string, params: string, helpContentUrl:string) {
|
|
263 |
// return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'+params, CustomOptions.getAuthOptions())
|
|
264 |
// //.map(res => <Array<Page>> res.json())
|
|
265 |
// .pipe(catchError(this.handleError));
|
|
266 |
// }
|
243 |
267 |
|
244 |
|
return this.http.post<Entity>(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
|
245 |
|
//.map(res => <Entity> res.json())
|
246 |
|
.pipe(catchError(this.handleError));
|
247 |
|
}
|
|
268 |
// Replacing getCommunityPages
|
|
269 |
getCommunityPagesByType(pid: string, type: string, helpContentUrl:string) {
|
|
270 |
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'
|
|
271 |
+ (type ? '?page_type='+type : ''))
|
|
272 |
//.map(res => <Array<Page>> res.json())
|
|
273 |
.pipe(catchError(this.handleError));
|
|
274 |
}
|
|
275 |
// End of replacing getCommunityPages
|
248 |
276 |
|
249 |
|
updateEntity(entity: Entity, helpContentUrl:string) {
|
250 |
|
HelpContentService.removeNulls(entity);
|
|
277 |
// Replacing part of getPages (now getAllPages)
|
|
278 |
getCommunityPagesWithPositions(pid: string, helpContentUrl:string) {
|
|
279 |
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true')
|
|
280 |
//.map(res => <Array<Page>> res.json())
|
|
281 |
.pipe(catchError(this.handleError));
|
|
282 |
}
|
|
283 |
// End of replacing part of getPages (now getAllPages)
|
251 |
284 |
|
252 |
|
return this.http.post<Entity>(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
|
253 |
|
//.map(res => <Entity> res.json())
|
254 |
|
.pipe(catchError(this.handleError));
|
255 |
|
}
|
|
285 |
getAllPages(helpContentUrl:string) {//,pid:string,with_positions:boolean=null) {
|
|
286 |
// let parameters: string = "";
|
|
287 |
// if(pid || with_positions == true || with_positions == false) {
|
|
288 |
// parameters = "?";
|
|
289 |
// if(pid) {
|
|
290 |
// parameters += "&pid="+pid;
|
|
291 |
// }
|
|
292 |
// if(with_positions == true || with_positions == false) {
|
|
293 |
// parameters += "&with_positions="+with_positions;
|
|
294 |
// }
|
|
295 |
// }
|
|
296 |
return this.http.get<Array<Page>>(helpContentUrl + 'page')
|
|
297 |
//.map(res => <Array<Page>> res.json())
|
|
298 |
.pipe(catchError(this.handleError));
|
|
299 |
}
|
256 |
300 |
|
257 |
|
// toggleEntity(selectedCommunityId: string, id : string,status : boolean) {
|
258 |
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
259 |
|
// let options = new RequestOptions({headers: headers});
|
260 |
|
//
|
261 |
|
// return this.http.post(helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options)
|
262 |
|
// .catch(this.handleError);
|
263 |
|
// }
|
|
301 |
getAllPagesFull(helpContentUrl:string) {
|
|
302 |
return this.http.get<Array<Page>>(helpContentUrl + 'page/full')//+(pid?("?pid="+pid):""))
|
|
303 |
//.map(res => <Array<Page>> res.json())
|
|
304 |
.pipe(catchError(this.handleError));
|
|
305 |
}
|
264 |
306 |
|
265 |
|
toggleEntities(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) {
|
|
307 |
getPageByPortal(pageId:string, helpContentUrl:string, pid: string) {
|
|
308 |
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
|
|
309 |
//.map(res => <Page> res.json())
|
|
310 |
.pipe(catchError(this.handleError));
|
|
311 |
}
|
266 |
312 |
|
267 |
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
268 |
|
//.map( res => <string[]> res.json())
|
269 |
|
.pipe(catchError(this.handleError));
|
270 |
|
}
|
|
313 |
getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) {
|
|
314 |
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
|
|
315 |
.pipe(catchError(this.handleError));
|
|
316 |
}
|
271 |
317 |
|
272 |
|
deleteEntities(ids : string[], helpContentUrl:string) {
|
273 |
|
return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
274 |
|
.pipe(catchError(this.handleError));
|
275 |
|
}
|
|
318 |
savePage(page: Page, helpContentUrl:string) {
|
|
319 |
HelpContentService.removeNulls(page);
|
276 |
320 |
|
|
321 |
return this.http.post<Page>(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
|
322 |
//.map(res => <Page> res.json())
|
|
323 |
.pipe(catchError(this.handleError));
|
|
324 |
}
|
277 |
325 |
|
278 |
|
toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) {
|
279 |
|
return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), CustomOptions.getAuthOptionsWithBody())
|
280 |
|
.pipe(catchError(this.handleError));
|
281 |
|
}
|
|
326 |
updatePage(page: Page, helpContentUrl:string) {
|
282 |
327 |
|
283 |
|
savePage(page: Page, helpContentUrl:string) {
|
284 |
|
HelpContentService.removeNulls(page);
|
|
328 |
HelpContentService.removeNulls(page);
|
285 |
329 |
|
286 |
|
return this.http.post<Page>(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
287 |
|
//.map(res => <Page> res.json())
|
288 |
|
.pipe(catchError(this.handleError));
|
289 |
|
}
|
|
330 |
return this.http.post<Page>(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
|
331 |
//.map(res => <Page> res.json())
|
|
332 |
.pipe(catchError(this.handleError));
|
|
333 |
}
|
290 |
334 |
|
291 |
|
updatePage(page: Page, helpContentUrl:string) {
|
|
335 |
togglePages(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) {
|
292 |
336 |
|
293 |
|
HelpContentService.removeNulls(page);
|
|
337 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+'/page/toggle?status='+ status.toString(),
|
|
338 |
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
339 |
.pipe(catchError(this.handleError));
|
|
340 |
}
|
294 |
341 |
|
295 |
|
return this.http.post<Page>(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
296 |
|
//.map(res => <Page> res.json())
|
297 |
|
.pipe(catchError(this.handleError));
|
298 |
|
}
|
|
342 |
deletePages(ids : string[], helpContentUrl:string) {
|
299 |
343 |
|
300 |
|
togglePages(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) {
|
|
344 |
return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
345 |
.pipe(catchError(this.handleError));
|
|
346 |
}
|
301 |
347 |
|
302 |
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
303 |
|
.pipe(catchError(this.handleError));
|
304 |
|
}
|
|
348 |
// unused
|
|
349 |
getCommunities( helpContentUrl:string) {
|
|
350 |
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType)
|
|
351 |
//.map(res => <Array<Portal>> res.json())
|
|
352 |
.pipe(catchError(this.handleError));
|
|
353 |
}
|
305 |
354 |
|
306 |
|
deletePages(ids : string[], helpContentUrl:string) {
|
|
355 |
getCommunity(pid: string, helpContentUrl:string) {
|
|
356 |
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+pid)
|
|
357 |
//.map(res => <Portal> res.json())
|
|
358 |
.pipe(catchError(this.handleError));
|
|
359 |
}
|
307 |
360 |
|
308 |
|
return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
309 |
|
.pipe(catchError(this.handleError));
|
310 |
|
}
|
|
361 |
getCommunitiesFull( helpContentUrl:string) {
|
|
362 |
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '/full')
|
|
363 |
//.map(res => <Array<Portal>> res.json())
|
|
364 |
.pipe(catchError(this.handleError));
|
|
365 |
}
|
311 |
366 |
|
312 |
|
getPageHelpContents(helpContentUrl:string) {
|
313 |
|
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
|
314 |
|
//.map(res => <Array<PageHelpContent>> res.json())
|
315 |
|
.pipe(catchError(this.handleError));
|
316 |
|
}
|
|
367 |
getCommunityFull(portal_pid: string, helpContentUrl:string) {
|
|
368 |
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full')
|
|
369 |
//.map(res => <Portal> res.json())
|
|
370 |
.pipe(catchError(this.handleError));
|
|
371 |
}
|
317 |
372 |
|
318 |
|
getCommunityPageHelpContents(portal_pid: string, helpContentUrl:string) {
|
319 |
|
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent?portal='+portal_pid)
|
320 |
|
//.map(res => <Array<PageHelpContent>> res.json())
|
321 |
|
.pipe(catchError(this.handleError));
|
322 |
|
}
|
|
373 |
saveCommunity(portal: Portal, helpContentUrl:string) {
|
|
374 |
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
375 |
// let options = new RequestOptions({headers: headers});
|
323 |
376 |
|
324 |
|
getPageHelpContent(id : string, helpContentUrl:string) {
|
325 |
|
return this.http.get<PageHelpContent>(helpContentUrl + 'pagehelpcontent/' + id)
|
326 |
|
//.map(res => <PageHelpContent> res.json())
|
327 |
|
.pipe(catchError(this.handleError));
|
328 |
|
}
|
|
377 |
HelpContentService.removeNulls(portal);
|
329 |
378 |
|
330 |
|
savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
|
331 |
|
HelpContentService.removeNulls(pageHelpContent);
|
|
379 |
return this.http.post<Portal>(helpContentUrl + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
|
|
380 |
//.map(res => <Portal> res.json())
|
|
381 |
.pipe(catchError(this.handleError));
|
|
382 |
}
|
332 |
383 |
|
333 |
|
return this.http.post<PageHelpContent>(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
|
334 |
|
//.map(res => <PageHelpContent> res.json())
|
335 |
|
.pipe(catchError(this.handleError));
|
336 |
|
}
|
|
384 |
updateCommunity(portal: Portal, helpContentUrl:string) {
|
|
385 |
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
386 |
// let options = new RequestOptions({headers: headers});
|
337 |
387 |
|
338 |
|
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
|
339 |
|
HelpContentService.removeNulls(pageHelpContent);
|
|
388 |
HelpContentService.removeNulls(portal);
|
340 |
389 |
|
341 |
|
return this.http.post<PageHelpContent>(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
|
342 |
|
//.map(res => <PageHelpContent> res.json())
|
343 |
|
.pipe(catchError(this.handleError));
|
344 |
|
}
|
|
390 |
return this.http.post<Portal>(helpContentUrl + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
|
|
391 |
//.map(res => <Portal> res.json())
|
|
392 |
.pipe(catchError(this.handleError));
|
|
393 |
}
|
345 |
394 |
|
346 |
|
deletePageHelpContents(ids : string[], helpContentUrl:string) {
|
347 |
|
return this.http.post(helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
348 |
|
.pipe(catchError(this.handleError));
|
349 |
|
}
|
|
395 |
deleteCommunities(ids : string[], helpContentUrl:string) {
|
|
396 |
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
397 |
// let options = new RequestOptions({headers: headers});
|
350 |
398 |
|
351 |
|
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
|
352 |
|
return this.http.post(helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
353 |
|
//.map( res => <string[]> res.json())
|
354 |
|
.pipe(catchError(this.handleError));
|
355 |
|
}
|
|
399 |
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
400 |
.pipe(catchError(this.handleError));
|
|
401 |
}
|
356 |
402 |
|
357 |
|
private handleError(error: HttpErrorResponse) {
|
358 |
|
// in a real world app, we may send the error to some remote logging infrastructure
|
359 |
|
// instead of just logging it to the console
|
360 |
|
console.error(error);
|
361 |
|
return Observable.throw(error.error || 'Server error');
|
362 |
|
}
|
|
403 |
private handleError(error: HttpErrorResponse) {
|
|
404 |
// in a real world app, we may send the error to some remote logging infrastructure
|
|
405 |
// instead of just logging it to the console
|
|
406 |
console.error(error);
|
|
407 |
return Observable.throw(error.error || 'Server error');
|
|
408 |
}
|
363 |
409 |
|
364 |
410 |
// getDataProviders() {
|
365 |
411 |
// return this.http.get('https://beta.services.openaire.eu/search/v2/api/datasources?format=json').map(res => <any> res.json()).map(res => res.results).do(res => {console.log(res)}).catch(this.handleError);
|
1. help-content.service.ts:
a. Improve method names.
b. Change paths for community related methods to be in the form "/portalType/pid/..." (needed for authorization in service).
2. affiliations.component.ts: Replace "getPageByRoute()" with "getCommunityPageByRoute()".
3. divId-form.component.ts: No need to read "communityId" url param | Replace "getPages()" with "getAllPages()".
4. divIds.component.ts: Replace "getDivIdsFull()" with "getAllDivIdsFull()".
5. div-help-content-form.component.ts: Replace "getDivIdsFull()" with "getDivIdsFullByPageAndPortal()".
6. div-help-contents.component.ts: Replace "getPage()" with "getPageByPortal()" | In "deleteDivHelpContents()" and "toggleDivHelpContents()" add pid parameter.
7. edit-div-help-content.component.ts: Replace "getPage()" with "getPageByPortal()" | In "getDivHelpContent()", "getDivIdFull()" and "insertOrUpdateDivHelpContent()" add pid parameter.
8. new-div-help-content.component.ts: Replace "getPage()" with "getPageByPortal()" | In "insertOrUpdateDivHelpContent()" add pid parameter.
9. edit-page-help-content.component.ts: Replace "getPage()" with "getPageByPortal()" | In "getPageHelpContent()" and "updatePageHelpContent()" add pid parameter.
10 .new-page-help-content.component.ts: Replace "getPage()" with "getPageByPortal()" | In "savePageHelpContent()" add pid parameter.
11. page-help-content-form.component.ts: Replace "getPage()" with "getPageByPortal()" | Replace "getPages()" with "getCommunityPagesWithPositions()".
12. page-help-contents.component.ts:
a. Replace "getPage()" with "getPageByPortal()" OR "getCommunityPagesWithPositions()".
b. In "deletePageHelpContents()" and "togglePageHelpContents()" add pid parameter.
13. edit-htmlpage-content.component.ts: Replace "getPage()" with "getPageByPortal()".
14. pages.component.ts:
a. Replace "getCommunityPages()" with "getCommunityPagesByType()".
b. Replace "getPagesFull()" with "getAllPagesFull()".
c. Rename "getPagesFromDivIds()" to "getPageIdsFromDivIds()".