Project

General

Profile

« Previous | Next » 

Revision 57548

[Connect]: Revert check if is Client. Added on UserInfo method.

View differences:

modules/uoa-connect-portal/trunk/src/app/my-communities/my-communities.component.ts
76 76
        if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
77 77
          this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect", this.properties.piwikSiteId).subscribe();
78 78
        }
79
        if (typeof document !== 'undefined') {
80
          this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
81
            this.user = user;
79
        this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
80
          this.user = user;
81
          if(this.user) {
82 82
            this.getCommunities();
83
            //this.getDivContents();
84
            //this.getPageContents();
85
          });
86
        }
83
          }
84
          //this.getDivContents();
85
          //this.getPageContents();
86
        });
87 87
      });
88 88
  }
89 89

  
......
110 110

  
111 111
    this._communitiesService.getCommunitiesState().subscribe(
112 112
      communitiesResults => {
113
        if(!communitiesResults){
113
        if (!communitiesResults) {
114 114
          return;
115 115
        }
116
        if(communitiesResults.length == 0) {
116
        if (communitiesResults.length == 0) {
117 117
          this.status = this.errorCodes.DONE;
118 118
          return;
119
        };
119
        }
120
        ;
120 121
        this.sort(communitiesResults);
121 122

  
122 123
        var subscribedLoading = communitiesResults.length;
modules/uoa-connect-portal/trunk/src/app/community/community.component.ts
77 77
  searchLinkToDataProviders: string = null;
78 78
  searchLinkToAdvancedPublications: string = null;
79 79
  shareInZenodoPage: string = null;
80
  public routerHelper:RouterHelper = new RouterHelper();
80
  public routerHelper: RouterHelper = new RouterHelper();
81 81
  private user: User;
82 82
  private loginCheck: boolean = false;
83 83

  
......
91 91
    private _piwikService: PiwikService,
92 92
    private config: ConfigurationService,
93 93
    private _communityService: CommunityService,
94
    private _searchCommunityDataprovidersService:SearchCommunityDataprovidersService,
94
    private _searchCommunityDataprovidersService: SearchCommunityDataprovidersService,
95 95
    private _searchCommunityProjectsService: SearchCommunityProjectsService,
96 96
    private _searchResearchResultsService: SearchResearchResultsService,
97 97
    private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
......
123 123
        this.url = data.envSpecific.baseLink + this._router.url;
124 124
        this.seoService.createLinkForCanonicalURL(this.url, false);
125 125
        this._meta.updateTag({content: this.url}, "property='og:url'");
126
        if (typeof document !== 'undefined') {
127
          this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
128
            this.user = user;
129
            this.loginCheck = true;
130
          });
131
        } else {
132
          this.user = null;
126
        this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
127
          this.user = user;
133 128
          this.loginCheck = true;
134
        }
129
        });
135 130
        if (this.communityId != null && this.communityId != '') {
136 131
          this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
137 132
            community => {
......
147 142
              this._meta.updateTag({content: community.title}, "property='og:title'");
148 143
              this._title.setTitle(community.title);
149 144
              if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
150
                this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.getSiteId(this.communityId,this.properties.environment)).subscribe();
145
                this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
151 146
              }
152 147
              if (this.community.zenodoCommunity) {
153 148
                this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity, null).subscribe(
......
181 176
              //console.log(community);
182 177
            });
183 178

  
184
            this.countResearchResults("publication");
185
            this.countResearchResults("dataset");
186
            this.countResearchResults("software");
187
            this.countResearchResults("other");
179
          this.countResearchResults("publication");
180
          this.countResearchResults("dataset");
181
          this.countResearchResults("software");
182
          this.countResearchResults("other");
188 183

  
189
            this._searchCommunityProjectsService.countTotalProjects(this.properties,  this.communityId ).subscribe(
190
              projectTotal => {
191
                this.projectTotal = projectTotal;
192
                //console.log(projectTotal);
193
              },
194
              error => {
195
                this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
196
              }
197
            );
184
          this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
185
            projectTotal => {
186
              this.projectTotal = projectTotal;
187
              //console.log(projectTotal);
188
            },
189
            error => {
190
              this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
191
            }
192
          );
198 193

  
199
            this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId ).subscribe(
200
              contentProviderTotal => {
201
                this.contentProviderTotal = contentProviderTotal;
202
                //console.log(contentProviderTotal);
203
              },
204
              error => {
205
                this.handleError("Error getting number of content providers for community with id: " + this.communityId, error);
206
              }
194
          this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
195
            contentProviderTotal => {
196
              this.contentProviderTotal = contentProviderTotal;
197
              //console.log(contentProviderTotal);
198
            },
199
            error => {
200
              this.handleError("Error getting number of content providers for community with id: " + this.communityId, error);
201
            }
207 202
          );
208 203

  
209 204
          // this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
......
228 223
  }
229 224

  
230 225
  public countResearchResults(resultType: string) {
231
    this._searchResearchResultsService.countTotalResults(resultType, this.properties,"&fq=communityid=" + this.communityId).subscribe(
226
    this._searchResearchResultsService.countTotalResults(resultType, this.properties, "&fq=communityid=" + this.communityId).subscribe(
232 227
      researchResultsTotal => {
233 228
        this.setTotal(resultType, researchResultsTotal);
234
        if(resultType == "publication") {
229
        if (resultType == "publication") {
235 230
          this.searchResearchResults(resultType, this.publicationTotal, this.publicationResults);
236 231
        }
237 232
      },
238 233
      error => {
239
        this.handleError("Error getting number of "+this.getEntityName(resultType, true, true)+" for community with id: " + this.communityId, error);
234
        this.handleError("Error getting number of " + this.getEntityName(resultType, true, true) + " for community with id: " + this.communityId, error);
240 235
      }
241 236
    );
242 237
  }
......
253 248
          this.showLoading = false;
254 249
        },
255 250
        error => {
256
          this.handleError("Error getting "+this.getEntityName(resultType, true, true)+" for community with id: " + this.communityId, error);
251
          this.handleError("Error getting " + this.getEntityName(resultType, true, true) + " for community with id: " + this.communityId, error);
257 252
        }
258 253
      );
259 254
    }
......
278 273
  }
279 274

  
280 275
  isManager() {
281
    if(!this.user) {
276
    if (!this.user) {
282 277
      return false;
283 278
    }
284 279
    var email = this.user.email;
......
327 322
  }
328 323

  
329 324
  private setActiveTab(entityType: string) {
330
    if(entityType == "other") {
325
    if (entityType == "other") {
331 326
      this.activeTab = "orp";
332 327
    } else {
333 328
      this.activeTab = entityType;
......
335 330
  }
336 331

  
337 332
  private setResults(entityType: string, results: Array<any>) {
338
    if(entityType == "publication") {
333
    if (entityType == "publication") {
339 334
      this.publicationResults = results;
340
    } else if(entityType == "dataset") {
335
    } else if (entityType == "dataset") {
341 336
      this.researchDataResults = results;
342
    } else if(entityType == "software") {
337
    } else if (entityType == "software") {
343 338
      this.softwareResults = results;
344
    } else if(entityType == "other") {
339
    } else if (entityType == "other") {
345 340
      this.orpResults = results;
346 341
    }
347 342
  }
348 343

  
349 344
  private setTotal(entityType: string, total: number) {
350
    if(entityType == "publication") {
345
    if (entityType == "publication") {
351 346
      this.publicationTotal = total;
352
    } else if(entityType == "dataset") {
347
    } else if (entityType == "dataset") {
353 348
      this.researchDataTotal = total;
354
    } else if(entityType == "software") {
349
    } else if (entityType == "software") {
355 350
      this.softwareTotal = total;
356
    } else if(entityType == "other") {
351
    } else if (entityType == "other") {
357 352
      this.orpTotal = total;
358 353
    }
359 354
  }
360 355

  
361
  private getEntityName (entityType:string, plural:boolean, full:boolean): string {
362
    if(entityType == "publication") {
356
  private getEntityName(entityType: string, plural: boolean, full: boolean): string {
357
    if (entityType == "publication") {
363 358
      return "publication" + (plural ? "s" : "");
364
    } else if(entityType == "dataset") {
359
    } else if (entityType == "dataset") {
365 360
      return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
366
    } else if(entityType == "software") {
361
    } else if (entityType == "software") {
367 362
      return "software";
368
    } else if(entityType == "other") {
363
    } else if (entityType == "other") {
369 364
      return (full ? ("other research product" + (plural ? "s" : "")) : "other");
370 365
    }
371 366
  }
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/subscribe.component.ts
66 66
  }
67 67

  
68 68
  public ngOnInit() {
69
    this.route.data
70
      .subscribe((data: { envSpecific: EnvProperties }) => {
71
        this.properties = data.envSpecific;
72
        if (typeof document !== 'undefined') {
73
          this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
74
            this.user = user;
75
            this.init();
76
          });
77
        } else {
78
          this.init();
79
        }
69
    this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
70
      this.properties = data.envSpecific;
71
      this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
72
        this.user = user;
73
        this.init();
80 74
      });
75
    });
76
    this.init();
81 77
  }
82 78

  
83 79
  private init() {
84 80
    if (!this.showNumbers) {
85
      let email = (this.user)?this.user.email:null;
81
      let email = (this.user) ? this.user.email : null;
86 82
      if (email == null) {
87 83
        this.subscribed = false;
88 84
      } else {
......
128 124
  }
129 125

  
130 126
  subscribe() {
131
    var email = (this.user)?this.user.email:null;
127
    var email = (this.user) ? this.user.email : null;
132 128
    if (email == null) {
133 129
      this.subscribed = false;
134 130
      // this.showLoginAlert = true;
......
190 186
  }
191 187

  
192 188
  unsubscribe() {
193
    var email = (this.user)?this.user.email:null;
189
    var email = (this.user) ? this.user.email : null;
194 190
    if (email == null) {
195 191
      this.subscribed = false;
196 192
    } else {
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts
95 95
      this.errorMessage = "";
96 96
      this.missingCommunityId = "";
97 97
      this.status = this.errorCodes.LOADING;
98
      if (typeof document !== 'undefined') {
99
        this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
100
          this.user = user;
101
          this.init();
102
        });
103
      } else {
98
      this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
99
        this.user = user;
104 100
        this.init();
105
      }
101
      });
102
      this.init();
106 103
    });
107 104
  }
108 105

  
modules/uoa-connect-portal/trunk/src/app/app.component.ts
94 94
          } catch (e) {
95 95
          }
96 96
        }
97
        if(this.isClient) {
98
          this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
99
            this.user = user;
100
            this.init();
101
          });
102
        } else {
103
          this.user = null;
97
        this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
98
          this.user = user;
104 99
          this.init();
105
        }
100
        });
101
        this.init();
106 102
      }, error => {
107 103
        console.log("App couldn't fetch properties");
108 104
        console.log(error);

Also available in: Unified diff