Project

General

Profile

« Previous | Next » 

Revision 59352

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()".

View differences:

modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/helpcontent/page-help-content-form.component.ts
49 49
                 if(!this.pageId) {
50 50
                     this.myForm.valueChanges.subscribe(value => {
51 51
                         let pageId = value.page;
52
                         this._helpContentService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(page => {
52
                         this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(page => {
53 53
                            this.setPlacements(page);
54 54
                         });
55 55
                     });
56 56
                 }
57
                 this._helpContentService.getPages(this.properties.adminToolsAPIURL, this.communityPid, true).subscribe(
57
                 this._helpContentService.getCommunityPagesWithPositions(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
58 58
                   pages => {
59 59
                       this.availablePages = pages;
60 60
                       this.showLoading = false;
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/helpcontent/edit-page-help-content.component.ts
84 84
    }
85 85

  
86 86
    private getPage(pageId: string) {
87
      this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
87
      this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
88 88
        page => {
89 89
          // if( (this.communityPid == 'openaire' && !page.openaire)
90 90
          //   || (this.communityPid == 'connect' && !page.connect)
......
109 109
        this.errorMessage = "";
110 110
        this.updateErrorMessage = "";
111 111

  
112
        this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL).subscribe(
112
        this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
113 113
          pageHelpContent => {
114 114
            if(this.pageId && this.pageId != pageHelpContent.page) {
115 115
              this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} });
......
140 140
            this.updateErrorMessage = "";
141 141

  
142 142
            let pageHelpContent : PageHelpContent = this.formComponent.myForm.value;
143
            this._helpContentService.updatePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL).subscribe(
143
            this._helpContentService.updatePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
144 144
                _ => {
145 145
                  if(this.pageId) {
146 146
                    this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId  } } );
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/helpcontent/page-help-contents.component.ts
103 103
        this.updateErrorMessage = "";
104 104
        this.errorMessage = "";
105 105

  
106
        this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
106
        this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
107 107
            page => {
108 108
                // if( (this.selectedCommunityPid == 'openaire' && !page.openaire)
109 109
                //     || (this.selectedCommunityPid == 'connect' && !page.connect)
......
128 128
        this.errorMessage = "";
129 129

  
130 130
        //this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe(
131
        this._helpService.getPages(this.properties.adminToolsAPIURL, community_pid, true).subscribe(
131
        this._helpService.getCommunityPagesWithPositions(community_pid, this.properties.adminToolsAPIURL).subscribe(
132 132
          pages => {
133 133
              this.pages = pages;
134 134
              this.getPageHelpContents(this.selectedCommunityPid);
......
232 232
        this.showLoading = true;
233 233
        this.updateErrorMessage = "";
234 234

  
235
        this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL).subscribe(
235
        this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
236 236
            _ => {
237 237
              this.deletePageHelpContentsFromArray(this.selectedPageContents);
238 238
              this.showLoading = false;
......
267 267
      } else {
268 268
        this.updateErrorMessage = "";
269 269

  
270
        this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe(
270
        this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
271 271
            () => {
272 272
                for(let id of ids) {
273 273
                    let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/helpcontent/new-page-help-content.component.ts
64 64
    }
65 65

  
66 66
  private getPage(pageId: string) {
67
    this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
67
    this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
68 68
      page => {
69 69
        // if( (this.communityPid == 'openaire' && !page.openaire)
70 70
        //   || (this.communityPid == 'connect' && !page.connect)
......
94 94

  
95 95
            let pageHelpContent : PageHelpContent = this.formComponent.myForm.value;
96 96

  
97
            this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL).subscribe(
97
            this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
98 98
                _ => {
99 99
                  if(this.pageId) {
100 100
                    this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId  } } );
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/divhelpcontent/div-help-content-form.component.ts
116 116
        //this.showLoading = true;
117 117
        this.errorMessage = '';
118 118

  
119
        this._helpContentService.getDivIdsFull(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
119
        this._helpContentService.getDivIdsFullByPageAndPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
120 120
            divs => {
121 121
              this.availableDivs = divs;
122 122
              this.pageId = pageId;
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/divhelpcontent/div-help-contents.component.ts
90 90
        this.showLoading = true;
91 91
        this.updateErrorMessage = "";
92 92
        this.errorMessage = "";
93
        this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
93
        this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
94 94
            page => {
95 95
              // if( (this.selectedCommunityPid == 'openaire' && !page.openaire)
96 96
              //   || (this.selectedCommunityPid == 'connect' && !page.connect)
......
218 218
        this.showLoading = true;
219 219
        this.updateErrorMessage = "";
220 220

  
221
        this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL).subscribe(
221
        this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
222 222
            _ => {
223 223
              this.deleteDivHelpContentsFromArray(this.selectedDivContents);
224 224
              this.showLoading = false;
......
253 253
      } else {
254 254
        this.updateErrorMessage = "";
255 255

  
256
        this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe(
256
        this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
257 257
            () => {
258 258
                for(let id of ids) {
259 259
                    let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/divhelpcontent/edit-div-help-content.component.ts
80 80
    }
81 81

  
82 82
    private getPage(pageId: string) {
83
      this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
83
      this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
84 84
        page => {
85 85
          // if( (this.communityPid == 'openaire' && !page.openaire)
86 86
          //   || (this.communityPid == 'connect' && !page.connect)
......
104 104
        this.errorMessage = "";
105 105
        this.updateErrorMessage = "";
106 106

  
107
        this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL).subscribe(
107
        this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
108 108
            divHelpContent => {
109 109
              if(this.pageId) {
110 110
                this.getPage(this.pageId);
......
122 122
      } else {
123 123
        this.showLoading = true;
124 124

  
125
        this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL).subscribe(
125
        this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
126 126
          div => {
127 127
            this.formComponent.selectedDiv = div;
128 128

  
......
155 155

  
156 156
            let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
157 157

  
158
            this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe(
158
            this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
159 159
                _ => {
160 160
                  if(this.pageId) {
161 161
                    this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId  } } );
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/divhelpcontent/new-div-help-content.component.ts
62 62
    }
63 63

  
64 64
    private getPage(pageId: string) {
65
      this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
65
      this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
66 66
        page => {
67 67
          // if( (this.communityPid == 'openaire' && !page.openaire)
68 68
          //   || (this.communityPid == 'connect' && !page.connect)
......
89 89

  
90 90
            let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
91 91

  
92
            this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe(
92
            this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
93 93
                _ => {
94 94
                  if(this.pageId) {
95 95
                    this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId  } } );
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts
86 86
      if(!Session.isLoggedIn()){
87 87
        this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl":  this.router.url} });
88 88
      } else {
89
        this._helpContentService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
89
        this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
90 90
          page => {
91 91
            this.pageName = page.name;
92 92
            this.getHtmlPageContent(communityId, page.route);
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/divId/divId-form.component.ts
36 36
      this.route.data
37 37
        .subscribe((data: { envSpecific: EnvProperties }) => {
38 38
           this.properties = data.envSpecific;
39
           this.route.queryParams.subscribe(params => {
40
             this.selectedCommunityPid = params['communityId'];
41
           });
39
           // this.route.queryParams.subscribe(params => {
40
           //   this.selectedCommunityPid = params['communityId'];
41
           // });
42 42
         });
43 43
    }
44 44

  
......
53 53
        this.showLoading = true;
54 54
        this.errorMessage = "";
55 55

  
56
        this._helpContentService.getPages(this.properties.adminToolsAPIURL,this.selectedCommunityPid).subscribe(
56
        this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(
57 57
          pages => {
58 58
            //this.allPages = allPages;
59 59
            for(let page of pages) {
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/divId/divIds.component.ts
81 81
        this.updateErrorMessage = "";
82 82
        this.errorMessage = "";
83 83

  
84
        this._helpContentService.getDivIdsFull(null, this.properties.adminToolsAPIURL).subscribe(
84
        this._helpContentService.getAllDivIdsFull(this.properties.adminToolsAPIURL).subscribe(
85 85
            divIds => {
86 86
                this.divIds = divIds;
87 87
                this.checkboxes = [];
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/affiliations/affiliations.component.ts
94 94
  }
95 95

  
96 96
  getOrganizationsPageId() {
97
    this._helpContentService.getPageByRoute("/organizations", this.properties.adminToolsAPIURL).subscribe(
97
    this._helpContentService.getCommunityPageByRoute("/organizations", this.properties.adminToolsAPIURL, this.communityId).subscribe(
98 98
      pages => {
99 99
        if(pages && pages[0]) {
100 100
          this.organizationsPageId = pages[0]._id;
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/pages/page/pages.component.ts
104 104
        parameters = '?page_type=' + this.pagesType;
105 105
      }
106 106
      if (community_pid) {
107
        this._helpContentService.getCommunityPages(community_pid, parameters, this.properties.adminToolsAPIURL).subscribe(
107
        this._helpContentService.getCommunityPagesByType(community_pid, this.pagesType, this.properties.adminToolsAPIURL).subscribe(
108 108
          pages => {
109 109
            this.pagesReturned(pages);
110 110
            //if(!this.pagesType || this.pagesType == "link") {
......
116 116
          error => this.handleError('System error retrieving pages', error)
117 117
        );
118 118
      } else {
119
        this._helpContentService.getPagesFull(this.properties.adminToolsAPIURL, null).subscribe(
119
        this._helpContentService.getAllPagesFull(this.properties.adminToolsAPIURL).subscribe(
120 120
          pages => {
121 121
            this.pagesReturned(pages);
122 122
            this.showLoading = false;
......
131 131
    if (!Session.isLoggedIn()) {
132 132
      this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
133 133
    } else {
134
      this._helpContentService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe(
134
      this._helpContentService.getPageIdsFromDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe(
135 135
        pages => {
136 136
          this.pageWithDivIds = pages;
137 137
          this.showLoading = false;
modules/uoa-admin-portal/branches/use-UoaAdminToolsLibrary/src/app/services/help-content.service.ts
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);

Also available in: Unified diff