Revision 50117
Added by Konstantina Galouni over 6 years ago
help-content.service.ts | ||
---|---|---|
5 | 5 |
import { Http, Response, Headers, RequestOptions } from '@angular/http'; |
6 | 6 |
import { Observable } from 'rxjs/Rx'; |
7 | 7 |
import { Page } from "../domain/page"; |
8 |
import {PageHelpContent} from "../domain/page-help-content"; |
|
8 |
import { PageHelpContent } from "../domain/page-help-content"; |
|
9 |
import { Community } from "../domain/community"; |
|
10 |
import { Entity } from "../domain/entity"; |
|
9 | 11 |
|
12 |
|
|
10 | 13 |
@Injectable() |
11 | 14 |
export class HelpContentService { |
12 | 15 |
|
... | ... | |
29 | 32 |
.catch(this.handleError); |
30 | 33 |
} |
31 | 34 |
|
35 |
getCommunities() { |
|
36 |
return this.http.get(this._helpContentUrl + 'community') |
|
37 |
.map(res => <Array<Community>> res.json()) |
|
38 |
.catch(this.handleError); |
|
39 |
} |
|
40 |
|
|
41 |
getCommunityPages(community_id: string) { |
|
42 |
return this.http.get(this._helpContentUrl + 'community/'+community_id+'/pages') |
|
43 |
.map(res => <Array<Page>> res.json()) |
|
44 |
.catch(this.handleError); |
|
45 |
} |
|
46 |
|
|
47 |
getEntities() { |
|
48 |
return this.http.get(this._helpContentUrl + 'entity') |
|
49 |
.map(res => <Array<Entity>> res.json()) |
|
50 |
.catch(this.handleError); |
|
51 |
} |
|
52 |
|
|
53 |
getCommunityEntities(community_id: string) { |
|
54 |
return this.http.get(this._helpContentUrl + 'community/'+community_id+'/entities') |
|
55 |
.map(res => <Array<Entity>> res.json()) |
|
56 |
.catch(this.handleError); |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
saveEntity(entity: Entity) { |
|
61 |
let headers = new Headers({'Content-Type': 'application/json'}); |
|
62 |
let options = new RequestOptions({headers: headers}); |
|
63 |
|
|
64 |
HelpContentService.removeNulls(entity); |
|
65 |
|
|
66 |
return this.http.post(this._helpContentUrl + 'entity/save', JSON.stringify(entity), options) |
|
67 |
.map(res => <Entity> res.json()) |
|
68 |
.catch(this.handleError); |
|
69 |
} |
|
70 |
|
|
71 |
updateEntity(entity: Entity) { |
|
72 |
let headers = new Headers({'Content-Type': 'application/json'}); |
|
73 |
let options = new RequestOptions({headers: headers}); |
|
74 |
|
|
75 |
HelpContentService.removeNulls(entity); |
|
76 |
|
|
77 |
return this.http.post(this._helpContentUrl + 'entity/update', JSON.stringify(entity), options) |
|
78 |
.map(res => <Entity> res.json()) |
|
79 |
.catch(this.handleError); |
|
80 |
} |
|
81 |
|
|
82 |
toggleEntity(selectedCommunityId: string, id : string,status : boolean) { |
|
83 |
let headers = new Headers({'Content-Type': 'application/json'}); |
|
84 |
let options = new RequestOptions({headers: headers}); |
|
85 |
|
|
86 |
return this.http.post(this._helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options) |
|
87 |
.catch(this.handleError); |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
deleteEntities(ids : string[]) { |
|
92 |
let headers = new Headers({'Content-Type': 'application/json'}); |
|
93 |
let options = new RequestOptions({headers: headers}); |
|
94 |
|
|
95 |
return this.http.post(this._helpContentUrl + 'entity/delete',JSON.stringify(ids), options) |
|
96 |
.catch(this.handleError); |
|
97 |
} |
|
98 |
|
|
99 |
|
|
100 |
toggleEntityOfPage(pageId: string, entityId : string,status : boolean) { |
|
101 |
let headers = new Headers({'Content-Type': 'application/json'}); |
|
102 |
let options = new RequestOptions({headers: headers}); |
|
103 |
|
|
104 |
return this.http.post(this._helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), options) |
|
105 |
.catch(this.handleError); |
|
106 |
} |
|
107 |
|
|
32 | 108 |
savePage(page: Page) { |
33 |
console.log("savePage",page); |
|
34 | 109 |
let headers = new Headers({'Content-Type': 'application/json'}); |
35 | 110 |
let options = new RequestOptions({headers: headers}); |
36 | 111 |
|
37 | 112 |
HelpContentService.removeNulls(page); |
38 | 113 |
|
39 |
return this.http.post(this._helpContentUrl + 'page', JSON.stringify(page), options) |
|
114 |
return this.http.post(this._helpContentUrl + 'page/save', JSON.stringify(page), options)
|
|
40 | 115 |
.map(res => <Page> res.json()) |
41 | 116 |
.catch(this.handleError); |
42 | 117 |
} |
... | ... | |
47 | 122 |
|
48 | 123 |
HelpContentService.removeNulls(page); |
49 | 124 |
|
50 |
return this.http.put(this._helpContentUrl + 'page', JSON.stringify(page), options)
|
|
125 |
return this.http.post(this._helpContentUrl + 'page/update', JSON.stringify(page), options)
|
|
51 | 126 |
.map(res => <Page> res.json()) |
52 | 127 |
.catch(this.handleError); |
53 | 128 |
} |
54 | 129 |
|
130 |
togglePage(selectedCommunityId: string, id : string,status : boolean) { |
|
131 |
let headers = new Headers({'Content-Type': 'application/json'}); |
|
132 |
let options = new RequestOptions({headers: headers}); |
|
133 |
|
|
134 |
return this.http.post(this._helpContentUrl + 'community/'+selectedCommunityId+'/page/toggle?status='+ status.toString()+'&pageId='+id.toString(), options) |
|
135 |
.catch(this.handleError); |
|
136 |
} |
|
137 |
|
|
138 |
|
|
55 | 139 |
deletePages(ids : string[]) { |
56 | 140 |
let headers = new Headers({'Content-Type': 'application/json'}); |
57 | 141 |
let options = new RequestOptions({headers: headers}); |
... | ... | |
66 | 150 |
.catch(this.handleError); |
67 | 151 |
} |
68 | 152 |
|
153 |
getCommunityPageHelpContents(community_id: string) { |
|
154 |
return this.http.get(this._helpContentUrl + 'pagehelpcontent/community/'+community_id) |
|
155 |
.map(res => <Array<PageHelpContent>> res.json()) |
|
156 |
.catch(this.handleError); |
|
157 |
} |
|
158 |
|
|
69 | 159 |
getPageHelpContent(id : string) { |
70 | 160 |
return this.http.get(this._helpContentUrl + 'pagehelpcontent/' + id) |
71 | 161 |
.map(res => <PageHelpContent> res.json()) |
... | ... | |
108 | 198 |
let options = new RequestOptions({headers: headers}); |
109 | 199 |
|
110 | 200 |
return this.http.post(this._helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), options) |
111 |
.map( res => <string[]> res.json()) |
|
201 |
//.map( res => <string[]> res.json())
|
|
112 | 202 |
.catch(this.handleError); |
113 | 203 |
} |
114 | 204 |
|
... | ... | |
118 | 208 |
console.error(error); |
119 | 209 |
return Observable.throw(error.json().error || 'Server error'); |
120 | 210 |
} |
121 |
|
|
122 |
} |
|
211 |
|
|
212 |
} |
Also available in: Unified diff
Admin Portal configured according to OpenAIRE