Project

General

Profile

« Previous | Next » 

Revision 57548

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

View differences:

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
  }

Also available in: Unified diff