Project

General

Profile

« Previous | Next » 

Revision 60908

[Aggragator | Trunk]: Add numbers on home page

View differences:

modules/uoa-aggregator-portal/trunk/src/app/home/home.module.ts
25 25
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
26 26
import {IconsService} from "../openaireLibrary/utils/icons/icons.service";
27 27
import {arrow_right, book, cog, database, earth} from "../openaireLibrary/utils/icons/icons";
28
import {NumbersModule} from "../openaireLibrary/sharedComponents/numbers/numbers.module";
28 29

  
29 30
@NgModule({
30 31
  imports: [
......
37 38
    HomeRoutingModule,
38 39
    HelperModule,
39 40
    ErrorMessagesModule,
40
    SEOServiceModule,  EntitiesSelectionModule, QuickSelectionsModule, IconsModule
41
    SEOServiceModule, EntitiesSelectionModule, QuickSelectionsModule, IconsModule, NumbersModule
41 42
  ],
42 43
  declarations: [
43 44
    HomeComponent
modules/uoa-aggregator-portal/trunk/src/app/home/home.component.html
148 148
  </div>
149 149
</div>
150 150
<div class="uk-section uk-padding-remove-bottom">
151
  <div class="uk-container uk-text-center uk-margin-medium-bottom">
152
    <div class="uk-margin-medium uk-flex-center">
153
      <div class="uk-first-column">
154
        <div class="uk-panel">
155
          <h3 class="uk-margin uk-text-center">
156
            Our growing <span class="uk-text-bold">Community</span>
157
          </h3>
158
          <div class="uk-margin-large-top uk-container uk-margin-bottom uk-text-center">
159
            <div class="uk-grid uk-flex uk-flex-center">
160
              <div *ngIf="fundersSize" class="uk-width-1-3@m">
161
                <h3>
162
                  <a [routerLink]="properties.searchLinkToProjects" class="uk-text-bold number">
163
                    {{fundersSize.number|number}}<span class="number-size">{{fundersSize.size}}</span>
164
                  </a>
165
                </h3>
166
                <div class="uk-text-uppercase uk-text-large">Funders</div>
167
              </div>
168
              <div *ngIf="datasourcesSize" class="uk-width-1-3@m">
169
                <h3>
170
                  <a [routerLink]="properties.searchLinkToDataProviders" class="uk-text-bold number">
171
                    {{datasourcesSize.number|number}}<span class="number-size">{{datasourcesSize.size}}</span>
172
                  </a>
173
                </h3>
174
                <div class="uk-text-uppercase uk-text-large">Content providers</div>
175
              </div>
176
              <div *ngIf="projectsSize" class="uk-width-1-3@m">
177
                <h3>
178
                  <a [routerLink]="properties.searchLinkToProjects" class="uk-text-bold number">
179
                    {{projectsSize.number|number}}<span class="number-size">{{projectsSize.size}}</span>
180
                  </a>
181
                </h3>
182
                <div class="uk-text-uppercase uk-text-large">Projects</div>
183
              </div>
184
            </div>
185
          </div>
186
        </div>
187
      </div>
188
    </div>
189
  </div>
190
  <div class="numbers-background uk-section">
191
    <div class="uk-container">
192
      <div class="uk-grid uk-margin-auto-left uk-margin-auto-right uk-grid-large uk-flex uk-flex-center" uk-grid>
193
        <div *ngIf="publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
194
          <div class="number-width">
195
            <a class="number uk-text-bold uk-margin-bottom" [routerLink]="properties.searchLinkToResults"
196
               [queryParams]="{type: 'publications', qf: false}">
197
              {{publicationsSize.count|number}} </a>
198
            <div class="uk-text-uppercase uk-flex uk-flex-middle">
199
              <icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" customClass="portal-color"></icon>
200
              <span>publications</span>
201
            </div>
202
          </div>
203
        </div>
204
        <div *ngIf="datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
205
          <div class="number-width">
206
            <a class="number uk-text-bold uk-margin-bottom"
207
               [routerLink]="properties.searchLinkToResults"
208
               [queryParams]="{type: 'datasets', qf: false}">{{datasetsSize.count|number}} </a>
209

  
210
            <div class="uk-text-uppercase uk-flex uk-flex-middle">
211
              <icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right"
212
                    customClass="portal-color"></icon>
213
              <span>research data</span>
214
            </div>
215
          </div>
216
        </div>
217
        <div *ngIf="softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
218
          <div class="number-width">
219
            <a class="number uk-text-bold uk-margin-bottom" [routerLink]="properties.searchLinkToResults"
220
               [queryParams]="{type: 'software', qf: false}">
221
              {{softwareSize.count|number}} </a>
222
            <div class="uk-text-uppercase uk-flex uk-flex-middle">
223
              <icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" customClass="portal-color"></icon>
224
              <span>software</span>
225
            </div>
226
          </div>
227
        </div>
228
        <div *ngIf="otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
229
          <div class="number-width">
230
            <a class="number uk-text-bold  uk-margin-bottom" [routerLink]="properties.searchLinkToResults"
231
               [queryParams]="{type: 'other', qf: false}">{{otherSize.count|number}} </a>
232
            <div class="uk-text-uppercase uk-flex uk-flex-middle">
233
              <icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" customClass="portal-color"></icon>
234
              <span>other research products</span>
235
            </div>
236
          </div>
237
        </div>
238
      </div>
239
    </div>
240
  </div>
151
  <h3 class="uk-text-center uk-margin-medium-bottom">Our growing <span class="uk-text-bold">Community</span></h3>
152
  <numbers #numbersComponent [defaultInit]="false" backgroundClass="numbers-background"></numbers>
241 153
</div>
242 154
<!--<helper *ngIf="pageContents && pageContents['left'] && pageContents['left'].length > 0"-->
243 155
<!--        [texts]="pageContents['left']"></helper>-->
modules/uoa-aggregator-portal/trunk/src/app/home/home.component.ts
1
import {Component} from '@angular/core';
1
import {Component, ViewChild} from '@angular/core';
2 2
import {Subscription} from 'rxjs';
3 3
import {ActivatedRoute, Router} from '@angular/router';
4 4
import {Location} from '@angular/common';
5 5
import "rxjs/add/observable/zip";
6
import {Title, Meta}                  from '@angular/platform-browser';
6
import {Meta, Title} from '@angular/platform-browser';
7 7
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
8
import {  SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
9
import {  SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
10
import {  SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
11
import {  RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
12
import {  SearchFields} from '../openaireLibrary/utils/properties/searchFields';
13
import {  NumberUtils} from '../openaireLibrary/utils/number-utils.class';
8
import {SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
9
import {SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
10
import {SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
11
import {RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
12
import {SearchFields} from '../openaireLibrary/utils/properties/searchFields';
14 13

  
15
import {  RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
16
import { EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
17
import { ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
14
import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
15
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
16
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
18 17
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
19
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service';
18
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
20 19
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
21 20
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
22 21
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
......
26 25
import {portalProperties} from "../../environments/environment-aggregator";
27 26
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
28 27
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
28
import {NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
29 29

  
30 30
@Component({
31 31
  selector: 'home',
......
58 58
  showOrganizations: boolean = portalProperties.entities.organization.isEnabled;
59 59
  showProjects: boolean = portalProperties.entities.project.isEnabled;
60 60
  showDataProviders: boolean = portalProperties.entities.datasource.isEnabled;
61
  properties: EnvProperties;
61
  properties: EnvProperties = properties;
62 62
  public readMore: boolean = false;
63 63

  
64 64
  subs: Subscription[] = [];
......
77 77
  customFilter:SearchCustomFilter= null;
78 78
  aggregatorId;
79 79
  aggregator:AggregatorInfo;
80
  @ViewChild('numbersComponent') numbersComponent: NumbersComponent;
81
  
80 82
  constructor (
81 83
    private route: ActivatedRoute,
82 84
    private _router: Router,
......
109 111
    }));
110 112
  }
111 113

  
112
  public getKeys(obj: {}) {
113
    return Object.keys(obj);
114
  }
115

  
116
  createRange(number){
117
    var items: number[] = [];
118
    for(var i = 1; i <= number; i++){
119
      items.push(i);
120
    }
121
    return items;
122
  }
123

  
124 114
  public ceil(num: number) {
125 115
    return Math.ceil(num);
126 116
  }
127 117

  
128 118
  public ngOnInit() {
129
    this.properties = properties;
130 119
    this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink+this._router.url, false);
131 120
    this.getPageContents();
132

  
133 121
    if(this.properties!=null){
134 122
      var url = this.properties.domain + this.properties.baseLink+this._router.url;
135 123
      this._meta.updateTag({content:url},"property='og:url'");
......
145 133

  
146 134
              showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
147 135
            }
148
            this.showPublications = showEntity["publication"];
149
            this.showDatasets = showEntity["dataset"];
150
            this.showSoftware = showEntity["software"];
151
            this.showOrp = showEntity["orp"];
152
            this.showProjects = showEntity["project"];
153
            this.showDataProviders = showEntity["datasource"];
154
            this.showOrganizations = showEntity["organization"];
136
            this.showPublications = !!showEntity["publication"];
137
            this.showDatasets = !!showEntity["dataset"];
138
            this.showSoftware = !!showEntity["software"];
139
            this.showOrp = !!showEntity["orp"];
140
            this.showProjects = !!showEntity["project"];
141
            this.showDataProviders = !!showEntity["datasource"];
142
            this.showOrganizations = !!showEntity["organization"];
155 143
            if(this.showPublications){
156 144
              this.resultTypes.values.push({name: "Publications" , id:"publications",selected:true, number:0});
157 145
            }
......
164 152
            if(this.showOrp){
165 153
              this.resultTypes.values.push({name: "Other research products" , id:"other",selected:true, number:0});
166 154
            }
167
            this.getNumbers();
155
            this.numbersComponent.init(false, false, this.showPublications, this.showDatasets,
156
              this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders,
157
              StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId ))));
168 158
          }
169 159
        },
170 160
        error => {
......
180 170
    }
181 171
  }
182 172

  
183
  private getNumbers() {
184
    let refineQuery = null
185
    if(this.customFilter){
186
      refineQuery= "&fq="+StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId )));
187
    }
188
    if(this.showPublications){
189
      this.subs.push(this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties, refineQuery).subscribe(
190
        data => {
191
          if(data && data != null && data > 0 ){
192
            this.publicationsSize = NumberUtils.roundNumber(data);
193

  
194
          }
195
        },
196
        err => {
197
          //console.log(err);
198
          this.handleError("Error getting number of publications", err);
199
        }
200
      ));
201
    }
202
    if(this.showDatasets){
203
      this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties, refineQuery).subscribe(
204
        data => {
205
          if(data && data != null && data > 0 ){
206
            this.datasetsSize = NumberUtils.roundNumber(data);
207
          }
208
        },
209
        err => {
210
          //console.log(err);
211
          this.handleError("Error getting number of research data", err);
212
        }
213
      ));
214
      /*this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties, refineQuery).subscribe(
215
        data => {
216
          if(data && data != null && data > 0 ){
217
            this.datasetsLinkedSize = NumberUtils.roundNumber(data);
218
          }
219
        },
220
        err => {
221
          //console.log(err);
222
          this.handleError("Error getting number of linkedresearch data", err);
223
        }
224
      ));*/
225

  
226
    }
227
    if (this.showSoftware) {
228
      this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties, refineQuery).subscribe(
229
        data => {
230
          if (data && data > 0) {
231
            this.softwareSize = NumberUtils.roundNumber(data);
232
          }else{
233
            this.showSoftware = false;
234
          }
235
        },
236
        err => {
237
          this.handleError("Error getting number of software data", err);
238
        }
239
      ));
240
    /*  this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties, refineQuery).subscribe(
241
        data => {
242
          if(data && data != null && data > 0 ){
243
            this.softwareLinkedSize = NumberUtils.roundNumber(data);
244
          }
245
        },
246
        err => {
247
          //console.log(err);
248
          this.handleError("Error getting number of linked software", err);
249
        }
250
      ));*/
251
    }
252
    if (this.showOrp) {
253
      this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties, refineQuery).subscribe(
254
        data => {
255
          if (data && data > 0) {
256
            this.otherSize = NumberUtils.roundNumber(data);
257
          }else{
258
            this.showOrp = false;
259
          }
260
        },
261
        err => {
262
          this.handleError("Error getting number of software data", err);
263
        }
264
      ));
265
    }
266
    if(this.showProjects){
267
      this.subs.push(this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties, refineQuery).subscribe(
268
        data => {
269

  
270

  
271
          if(data[0] && data[0] > 0 ){
272
            this.projectsSize = NumberUtils.roundNumber(data[0]);
273
          }
274
          if(data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values ){
275
            this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
276
          }
277

  
278
        },
279
        err => {
280
          //console.log(err);
281
          this.handleError("Error getting 'funder' field results of projects", err);
282
        }));
283
    }
284
    if(this.showDataProviders){
285
      this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders("", this.properties, refineQuery).subscribe(
286
        data => {
287
          if(data && data != null && data > 0 ){
288
            this.datasourcesSize = NumberUtils.roundNumber(data);
289
          }
290

  
291
        },
292
        err => {
293
          //console.log(err);
294
          this.handleError("Error getting number of content providers", err);
295
        }
296
      ));
297
    }
298
  }
299

  
300 173
  private handleError(message: string, error) {
301 174
    console.error("Home Page: "+message, error);
302 175
  }
modules/uoa-aggregator-portal/trunk/src/assets/portal-custom.css
46 46
}
47 47

  
48 48
.numbers-background {
49
    background: transparent url('numbers_background_pattern.svg') 0 0  repeat-x padding-box;
49
    background: transparent url('numbers_background_pattern.svg') repeat-x center bottom;
50 50
}
51 51
.number {
52 52
    color: #1d1d1d;

Also available in: Unified diff