Project

General

Profile

« Previous | Next » 

Revision 45701

Complete the seperation in modules for lazy routes

View differences:

modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/utils/exportCSV.component.ts
1
import {Component, Input} from '@angular/core';
2

  
3
@Component({
4
    selector: 'export',
5
    template: `
6
        <a *ngIf="data != undefined && data != null && data.export != undefined && data.export != null"
7
            (click)="downloadCSV(data, filename)">
8
                {{linkname}}
9
        </a>
10

  
11
        <p *ngIf="data == undefined || data == null || data.export == undefined || data.export == null">
12
            {{linkname}}
13
        </p>
14
    `
15

  
16
    })
17

  
18
export class ExportCSVComponent {
19
    stockData : any =
20
        {
21
            "columnNames":
22
                ["Symbol", "Company", "Price"],
23
            "export":
24
/*
25
                [
26
                    {
27
                        Symbol: "AAPL",
28
                        Company: "Apple Inc.",
29
                        Price: "132.54"
30
                    },
31
                    {
32
                        Symbol: "INTC",
33
                        Company: "Intel Corporation",
34
                        Price: "33.45"
35
                    },
36
                    {
37
                        Symbol: "GOOG",
38
                        Company: "Google Inc",
39
                        Price: "554.52"
40
                    },
41
                ],
42
*/
43

  
44
                [
45
                    [
46
                        "AAPL",
47
                        "Apple Inc.",
48
                        "132.54"
49
                    ],
50
                    [
51
                        "INTC",
52
                        "Intel Corporation",
53
                        "33.45"
54
                    ],
55
                    [
56
                        "GOOG",
57
                        "Google Inc",
58
                        "554.52"
59
                    ],
60
                ],
61

  
62

  
63
            "columnDelimiter": ',',
64
            "lineDelimiter": '\n'
65
        };
66

  
67
    @Input() data: any = this.stockData;
68
    @Input() filename: string;
69
    @Input() linkname: string = "Download CSV";
70

  
71
    constructor () {
72
        console.info('export constructor');
73
    }
74

  
75
    ngOnInit() {
76
    }
77

  
78
    public static convertArrayOfObjectsToCSV(args) {
79
        console.info("convertArrayOfObjectsToCSV");
80

  
81
        var result, ctr, keys, columnDelimiter, lineDelimiter, data;
82

  
83
        data = args.export || null;
84

  
85
        if (data == null || !data.length) {
86
            return null;
87
        }
88

  
89
        columnDelimiter = args.columnDelimiter || ',';
90
        lineDelimiter = args.lineDelimiter || '\n';
91

  
92
        //keys = Object.keys(data[0]);
93
        keys = args.columnNames;
94

  
95
        result = '';
96
        result += keys.join(columnDelimiter);
97
        result += lineDelimiter;
98
/*
99
        data.forEach(function(item) {
100
            ctr = 0;
101
            keys.forEach(function(key) {
102
                if (ctr > 0) result += columnDelimiter;
103
                result += item[key];
104
                ctr++;
105
            });
106
            result += lineDelimiter;
107
        });
108
*/
109

  
110
        for(let line of data) {
111
            ctr = 0;
112
            for(let column of line) {
113
                if (ctr > 0) result += columnDelimiter;
114
                result += column;
115
                ctr++;
116
            }
117
            result += lineDelimiter;
118
        }
119

  
120
        return result;
121
    }
122

  
123
    public static downloadCSV(data: any, filenameArg: string) {
124
        console.info("downloadCSV");
125

  
126
        var encodedData, filename, link;
127

  
128
        var csv = this.convertArrayOfObjectsToCSV(data);
129
        if (csv == null) return;
130

  
131
        filename = filenameArg || 'export.csv';
132

  
133
        if (!csv.match(/^data:text\/csv/i)) {
134
            csv = 'data:text/csv;charset=utf-8,' + csv;
135
        }
136
        encodedData = encodeURI(csv);
137

  
138
        //link = document.createElement('a');
139
        link = document.getElementsByTagName('a');
140
        link[0].setAttribute('href', encodedData);
141
        link[0].setAttribute('download', filename);
142
        //document.body.appendChild(link);
143
        link[0].click();
144
        //document.body.removeChild(link);
145
    }
146
}
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/utils/utils.module.ts
1
import { NgModule }            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {ModalModule}  from './modal/modal.module';
6

  
7
// import {pagingFormatterNoLoad} from './pagingFormatterNoLoad.component';
8
import {ProjectTitleFormatter} from './projectTitleFormatter.component';
9
import {PublicationTitleFormatter} from './publicationTitleFormatter.component';
10
// import {PagingFormatter} from './pagingFormatter.component';
11
import {StaticAutoCompleteComponent} from './staticAutoComplete.component';
12
// import {EntitiesAutocompleteComponent} from './entitiesAutoComplete.component';
13
import {ShowDataProvidersComponent} from './showDataProviders.component';
14
import {ExportCSVComponent} from './exportCSV.component';
15
// import {IFrameComponent} from './iframe.component';
16
// import {AltMetricsComponent} from './altmetrics.component';
17

  
18
// import {SafeHtmlPipe} from './pipes/safeHTML.pipe';
19

  
20
// import {AlertModal} from './modal/alert';
21
// import {ModalLoading} from './modal/loading.component';
22

  
23
@NgModule({
24
  imports: [
25
    CommonModule, FormsModule, ModalModule
26
  ],
27
  declarations: [
28
    // pagingFormatterNoLoad,
29
    ProjectTitleFormatter,
30
    PublicationTitleFormatter,
31
    // PagingFormatter,
32
    StaticAutoCompleteComponent,
33
    //  EntitiesAutocompleteComponent,
34
    ShowDataProvidersComponent,
35
    ExportCSVComponent,
36
    // IFrameComponent,
37
    // SafeHtmlPipe,
38
    // AltMetricsComponent
39

  
40
  ],
41
  exports: [
42
      // pagingFormatterNoLoad,
43
      ProjectTitleFormatter,
44
      PublicationTitleFormatter,
45
      // PagingFormatter,
46
      // AlertModal, ModalLoading,
47
      StaticAutoCompleteComponent,
48
      // EntitiesAutocompleteComponent,
49
      ShowDataProvidersComponent,
50
      ExportCSVComponent,
51
      // IFrameComponent,
52
      // SafeHtmlPipe,
53
      // AltMetricsComponent
54

  
55
    ]
56
})
57
export class UtilsModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/utils/staticAutoComplete.component.ts
1
import {Component, ElementRef, Input, Output, EventEmitter} from '@angular/core';
2
import {Value} from '../searchPages/searchUtils/searchHelperClasses.class';
3
import {ISVocabulariesService} from '../services/ISVocabularies.service';
4
import {RefineFieldResultsService} from '../services/refineFieldResults.service';
5
//Usage example
6
//<static-autocomplete [(filtered)] =filtered [(selected)] =selected placeHolderMessage = "Search for countries" title = "Countries:" (keywordChange)="keywordChanged($event)"></static-autocomplete>
7

  
8
@Component({
9
    selector: 'static-autocomplete',
10
    styleUrls:  ['autoComplete.component.css'],
11
    host: {
12
       '(document:click)': 'handleClick($event)',
13
   },
14
    template: `
15
        <span class="custom-autocomplete uk-width-1-1">
16
            <span   *ngIf = "showSelected && selectedValue != ''">
17
              <span  class="uk-alert-default" data-uk-alert=""  *ngFor="let item of selected"  [title]="showItem(item)"> <span >{{truncate(showItem(item),14)}} </span>
18
                <span (click)="remove(item)" aria-hidden="true" title="Remove selection" > <i class="uk-icon-remove clickable"></i> </span>
19
              </span>
20
            </span>
21
            <input *ngIf = "showInput" type="text" class="auto-complete-input validate filter-input input-sm form-control  " [placeholder]=placeHolderMessage [(ngModel)]=keyword (keyup)=filter()   >
22
            <!--span *ngIf="showLoading" class="uk-alert uk-alert-primary" data-uk-alert=""> <i class="uk-icon-spinner"></i> Loading... </span>
23
            <span *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" data-uk-alert=""> {{warningMessage}} <a href="" class="uk-alert-close uk-close"></a></span-->
24
            <div  *ngIf="focus && showInput"  class="uk-dropdown" aria-expanded="true" style="display:block" >
25
                  <ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results" >
26
                      <li>
27
                      <span *ngIf="showLoading" class="uk-alert uk-alert-primary" data-uk-alert=""> <i class="uk-icon-spinner"></i> Loading... </span>
28
                      <span *ngIf="filtered.length > 0"  >  {{results}} results found:</span>
29
                      <span *ngIf="filtered.length == 0" class="uk-alert uk-alert-info" data-uk-alert=""> No results found</span>
30
                      </li>
31
                      <li    *ngFor=" let item of filtered">
32
                          <a (click)="select(item)"  [title]="showItem(item)">{{truncate(showItem(item),19)}}</a>
33
                      </li>
34
                  </ul>
35
            </div>
36
        </span>
37

  
38
        `
39
})
40
export class StaticAutoCompleteComponent {
41
    @Input() placeHolderMessage = "Search for entries";
42
    @Input() title = "Autocomplete";
43
    @Output() addItem = new EventEmitter(); // when selected list  changes update parent component
44
    @Output() selectedValueChanged = new EventEmitter(); // when changed  a method for filtering will be called
45
    @Output() listUpdated = new EventEmitter(); // when changed  a method for filtering will be called
46
    @Input() public list = []; // the entries resulted after filtering function
47
    @Input() public filtered = []; // the entries resulted after filtering function
48
    @Input() public selected = []; // the entries selected from user
49
    @Input() public keywordlimit = 3; // the minimum length of keyword
50
    @Input() public showSelected = true; // the minimum length of keyword
51
    @Input() public multipleSelections:boolean = true;
52
    @Input() public allowDuplicates:boolean = false;
53
    @Input() public selectedValue:string = '';
54
    @Input() public vocabularyId:string ;
55
    @Input() public fieldName:string ;
56
    @Input() public entityName:string ;
57

  
58
    @Input() public keyword = '';
59
    @Input() public type = 'search' //search, result, context, project
60
    public warningMessage = "";
61
    public infoMessage = "";
62
    public showLoading:boolean = false;
63
    public tries = 0;
64
    public showInput = true;
65
    public sub;
66
    public done = false;
67
    public results = 0;
68
    public focus:boolean  = false;
69
    constructor ( private _vocabulariesService: ISVocabulariesService,private _refineService: RefineFieldResultsService, private myElement: ElementRef) {
70
    }
71
    ngOnDestroy(){
72
      if(this.sub && this.sub != undefined){
73
        this.sub.unsubscribe();
74
      }
75
    }
76
    ngOnInit () {
77
      if(this.list == undefined || this.list.length == 0){
78
        this.showLoading = true;
79

  
80
        console.log("getVocabulary id: "+ this.vocabularyId + " for entity: "+ this.entityName);
81
       if(this.vocabularyId){
82
        // this.list = this._vocabulariesService.getVocabularyByType(this.vocabularyId, this.entityName);
83
        // this.afterListFetchedActions();
84
        this.sub = this._vocabulariesService.getVocabularyByType(this.vocabularyId, this.entityName).subscribe(
85
            data => {
86
                this.list  = data;
87
                this.afterListFetchedActions();
88

  
89
            },
90
            err => {
91
                console.log(err);
92
                this.warningMessage = "An Error occured..."
93
            }
94
        );
95
      }else if(this.fieldName && this.entityName){
96
        // this.list = this._refineService.getRefineFieldResultsByFieldName(this.fieldName,this.entityName);
97
        this.sub = this._refineService.getRefineFieldResultsByFieldName(this.fieldName,this.entityName).subscribe(
98
            data => {
99
                this.list  = data;
100
                this.afterListFetchedActions();
101

  
102
            },
103
            err => {
104
                console.log(err);
105
                this.warningMessage = "An Error occured..."
106
            }
107
        );
108
      }else{
109
        this.showLoading = false;
110

  
111
      }
112
    }else{
113
      this.afterListFetchedActions();
114
    }
115

  
116
    }
117
    public updateList(list){ // used in claim context autocomplete
118
      this.list = list;
119
      this.afterListFetchedActions()
120
    }
121
    private afterListFetchedActions(){
122
      this.showLoading = false;
123
      this.getSelectedNameFromGivenId();
124
      this.listUpdated.emit({
125
          value: this.list
126
      });
127
      if(this.list == null || this.list.length == 0 ){
128
        this.warningMessage = "There are no results";
129
        return;
130
      }
131
      this.done = true;
132
      if(this.keyword != ""){
133
        this.filter();
134
      }
135

  
136
    }
137
    filter() {
138
      this.focus = true;
139
      if(this.done){
140
        this.infoMessage = "";
141
        this.filtered = [];
142
        if(this.keyword == ""){
143
          var cut = 10;
144
          if(this.list.length < 5){
145
            cut = this.list.length;
146
          }
147
          this.results = this.list.length;
148
          this.filtered =this.list.slice(0, cut);
149
          this.tries = 0;
150
          this.warningMessage = "";
151
        // } else if(this.keyword && this.keyword.length < this.keywordlimit){
152
        //   this.tries++;
153
        //   if(this.tries == this.keywordlimit -1 ){
154
        //     this.warningMessage = "Type at least " + this.keywordlimit + " characters";
155
        //     this.tries = 0;
156
        //   }
157
        }else{
158
          this.tries = 0;
159
          this.warningMessage = "";
160
           this.filtered = this.list.filter(function(el){
161
              return el.label.toLowerCase().indexOf(this.keyword.toLowerCase()) > -1;
162
          }.bind(this));
163
          var cut = 10;
164
          if(this.filtered .length < 5){
165
            cut = this.list.length;
166
          }
167
          this.results = this.filtered.length;
168
           this.filtered =this.filtered.slice(0, cut);
169
        }
170
      }
171
    }
172
    remove(item:any){
173
      var index:number =this.checkIfExists(item,this.selected);
174
      console.info("try to remove: index = "+index + " length: "+this.selected.length);
175
       if (index > -1) {
176
          this.selected.splice(index, 1);
177
      }
178
      console.info("after remove: length: "+this.selected.length);
179
      if(!this.multipleSelections && this.selected.length == 0 ){
180
        console.info("no multiselections ");
181

  
182
        this.showInput = true;
183
        this.selectedValue = "";
184
        this.selectedValueChanged.emit({
185
            value: this.selectedValue
186
        });
187

  
188

  
189
      }
190
    }
191
    select(item:any){
192
      // console.log("select"+this.selected.length  + item.id + " "+ item.label);
193

  
194
        if(this.multipleSelections){
195
          var index:number =this.checkIfExists(item,this.selected);
196
           if (index > -1 && !this.allowDuplicates) {
197
              this.keyword = "";
198
              this.filtered.splice(0, this.filtered.length);
199
              return;
200
          }
201
          else{
202
              this.selected.push(item);
203
              this.keyword = "";
204
              this.filtered.splice(0, this.filtered.length);
205
              this.addItem.emit({
206
                  value: item
207
              });
208
          }
209
      }else{
210
        this.selected.splice(0, this.selected.length);
211
        this.selected.push(item);
212
        this.filtered.splice(0, this.filtered.length);
213
        this.keyword = "";
214
        this.showInput = false;
215
        this.selectedValue = item.id;
216
        this.selectedValueChanged.emit({
217
            value: this.selectedValue
218
        });
219

  
220
      }
221
      console.log("selected"+this.selected.length  );
222

  
223
    }
224
    private checkIfExists(item:any,list):number{
225

  
226
       if(item.concept && item.concept.id ){
227

  
228
        for (var _i = 0; _i < list.length; _i++) {
229
            let itemInList = list[_i];
230
            if(item.concept.id == itemInList.concept.id){
231
                 return _i;
232
            }
233
         }
234
      }else if(item.id){
235
        for (var _i = 0; _i < list.length; _i++) {
236
            let itemInList = list[_i];
237
             if(item.id == itemInList.id){
238
                 return _i;
239
            }
240
         }
241
      }
242
      return -1;
243

  
244
    }
245
    showItem(item:any):string{
246

  
247
     if (item.name){ //search
248
         return item.name;
249
      }else if( item.concept && item.concept.label){ //context
250
         return item.concept.label;
251
      }else if (item.label){ //simple
252
         return item.label;
253
      }
254

  
255
    }
256
    truncate(str:string, size:number):string{
257
      if(str == null){return "";}
258
      return (str.length > size)?str.substr(0,size)+'...':str;
259
    }
260
    private getSelectedNameFromGivenId(){
261
      if(this.list == null ){
262
        return;
263
      }
264
      for( var i = 0; i < this.list.length; i++){
265
        if(this.list[i].id == this.selectedValue){
266
          this.selectedValue = this.list[i].label;
267
          this.selected.push(this.list[i]);
268
          this.showInput = false;
269
        }
270
      }
271
    }
272

  
273
    handleClick(event){
274
     var clickedComponent = event.target;
275
     var inside = false;
276
     do {
277
         if (clickedComponent === this.myElement.nativeElement) {
278
             inside = true;
279
         }
280
        clickedComponent = clickedComponent.parentNode;
281
     } while (clickedComponent);
282
      if(!inside){
283
          this.focus =false;
284
          this.filtered.splice(0, this.filtered.length);
285
      }
286
  }
287

  
288
}
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/services/ISVocabularies.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class';
5
import 'rxjs/add/observable/of';
6
import 'rxjs/add/operator/do';
7
import 'rxjs/add/operator/share';
8
import { CacheService  } from '../shared/cache.service';
9

  
10
@Injectable()
11
export class ISVocabulariesService {
12
    // private api ="https://beta.services.openaire.eu/provision/mvc/vocabularies/";
13
    // private api = "http://api.openaire.eu/vocabularies/"
14
    private api = "http://dev.openaire.research-infrastructures.eu/vocabularies/";
15
    constructor(private http: Http, public _cache: CacheService) {}
16

  
17
    getVocabularyByType(field:string,entity:string):any{
18
      console.log("getVocabulary field: "+ field + " for entity: "+ entity);
19
      var file = "";
20
      var vocabulary = "";
21
      if( field == "lang"){
22
          // file="languages.json";
23
          // return this.getVocabularyFromFile(file);
24
          vocabulary = "dnet:languages.json";
25
          return this.getVocabularyFromService(vocabulary);
26
      }else if ( field == "type" && (entity == "publication")){
27
        // file = "publicationTypes.json";
28
        // return this.getVocabularyFromFile(file);
29
        vocabulary = "dnet:publication_resource.json";
30
        return this.getVocabularyFromService(vocabulary);
31

  
32
      }else if ( field == "type" && (entity == "dataset")){
33
        // file = "dnet:dataCite_resource.json";
34
        // return this.getVocabularyFromFile(file);
35
        vocabulary = "dnet:dataCite_resource.json";
36
        return this.getVocabularyFromService(vocabulary);
37

  
38
      }else if( field == "access" && (entity == "publication" || entity == "dataset")){
39
        // file= "accessMode.json";
40
        // return this.getVocabularyFromFile(file);
41
        vocabulary = "dnet:access_modes.json";
42
        return this.getVocabularyFromService(vocabulary);
43

  
44
      } else if( (field == "datasourcetype") && (entity == "dataprovider")){
45
        // file = "dataProviderType.json";
46
        //   return this.getVocabularyFromFile(file);
47
          vocabulary = "dnet:datasource_typologies.json";
48
          return this.getVocabularyFromService(vocabulary);
49

  
50
      } else if( field == "compatibility" && (entity == "dataprovider")){
51
        // file = "dataProviderCompatibility.json";
52
        //   return this.getVocabularyFromFile(file);
53
          vocabulary = "dnet:datasourceCompatibilityLevel.json";
54
          return this.getVocabularyFromService(vocabulary);
55

  
56
      } else if( field == "country" ){
57
        // file = "countries.json";
58
        //   return this.getVocabularyFromFile(file);
59
          vocabulary = "dnet:countries.json";
60
          return this.getVocabularyFromService(vocabulary);
61

  
62
      }
63
      return null;
64

  
65
    }
66
    // getVocabularyFromFile (file:string):AutoCompleteValue[] {
67
    //        var lang = JSON.parse(JSON.stringify(require('../utils/vocabularies/'+file)));
68
    //       return  this.parse(lang["terms"]);
69
    // }
70
    getVocabularyFromService (vocabularyName:string):any {
71
        let url = this.api + vocabularyName;
72
        console.log(url);
73
        let key = url;
74
        if (this._cache.has(key)) {
75
          return Observable.of(this._cache.get(key));
76
        }
77
        // return this.http.get(url).toPromise()
78
        // .then(request =>
79
        //   {
80
        //     request = request.json()['terms'];
81
        //     var results:AutoCompleteValue[] = this.parse(request);
82
        //     console.log("Get vocabulary : "+ vocabularyName+ " - get " +results.length+ "results");
83
        //     return results;
84
        //   });
85
        return this.http.get(url)
86
                    .do(res => console.log(res))
87
                    .map(res => <any> res.json())
88
                    .map(res => res['terms'])
89
                    .do(res => console.log(res))
90
                    .map(res => this.parse(res))
91
                    .do(res => console.log(res))
92
                    .catch(this.handleError)
93
                    .do(res => {
94
                      this._cache.set(key, res);
95
                    });
96

  
97
    }
98

  
99
    parse (data: any):AutoCompleteValue[] {
100
        var array:AutoCompleteValue[] =[]
101
        for(var i = 0; i < data.length; i++){
102
          var value:AutoCompleteValue =  new AutoCompleteValue();
103
          value.id = data[i].code;
104
          value.label = data[i].englishName;
105
          array.push(value);
106
        }
107

  
108
        return array;
109

  
110
    }
111
private handleError (error: Response) {
112
      // in a real world app, we may send the error to some remote logging infrastructure
113
      // instead of just logging it to the console
114
      console.log(error);
115
      return Observable.throw(error  || 'Server error');
116
    }
117
}
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/services/services.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
6

  
7
//Services
8
// import { DatasetService} from './dataset.service';
9
import { OpenaireProjectsService } from './openaireProjects.service';
10
// import { OrganizationService} from './organization.service';
11
// import { PersonService} from './person.service';
12
// import { ProjectService} from './project.service';
13
// import { PublicationService} from './publication.service';
14
// import { MetricsService } from './metrics.service';
15
import { SearchCrossrefService } from './searchCrossref.service';
16
import { SearchDataciteService } from './searchDatacite.service';
17
import { SearchOrcidService } from './searchOrcid.service';
18
import {SearchPublicationsService} from './searchPublications.service';
19
// import {DataProviderService} from './dataProvider.service';
20
import {SearchDataprovidersService} from './searchDataproviders.service';
21
import {SearchDatasetsService} from './searchDatasets.service';
22
import {SearchOrganizationsService} from './searchOrganizations.service';
23
import {SearchPeopleService} from './searchPeople.service';
24
import {SearchProjectsService} from './searchProjects.service';
25
// import {EntitiesSearchService} from './entitySearch.service';
26

  
27
import {ISVocabulariesService} from './ISVocabularies.service';
28
import {RefineFieldResultsService} from './refineFieldResults.service'
29
// import {ReportsService} from './reports.service'
30

  
31
import {LoginService} from './login.service';
32

  
33

  
34
@NgModule({
35
  imports: [
36
    CommonModule, FormsModule
37
  ],
38
  declarations: [
39
  ],
40
  providers:[
41
    // DatasetService,
42
     OpenaireProjectsService,
43
    //  OrganizationService,
44
    // PersonService,
45
    //  ProjectService,  PublicationService,
46
    // MetricsService,
47
    SearchCrossrefService, SearchCrossrefService, SearchDataciteService,
48
    SearchOrcidService, SearchPublicationsService, SearchDataprovidersService,
49
    // DataProviderService,
50
    SearchProjectsService, SearchDatasetsService,
51
    SearchOrganizationsService, SearchPeopleService, ISVocabulariesService,
52
    RefineFieldResultsService,
53
    // EntitiesSearchService,
54
    LoginService,
55
    // ReportsService
56
],
57
  exports: [
58
    ]
59
})
60
export class ServicesModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/search-routing.module.ts
1
import { NgModule } from '@angular/core';
2
import { RouterModule } from '@angular/router';
3
import { SearchComponent } from './find/search.component';
4
import { SearchPublicationsComponent } from './simple/searchPublications.component';
5
import { SearchDataprovidersComponent } from './simple/searchDataproviders.component';
6
import { SearchProjectsComponent } from './simple/searchProjects.component';
7
import { SearchDatasetsComponent } from './simple/searchDatasets.component';
8
import { SearchOrganizationsComponent } from './simple/searchOrganizations.component';
9
import { SearchPeopleComponent } from './simple/searchPeople.component';
10
import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component';
11
import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component';
12
import { AdvancedSearchProjectsComponent } from './advanced/advancedSearchProjects.component';
13
import { AdvancedSearchDatasetsComponent } from './advanced/advancedSearchDatasets.component';
14
import { AdvancedSearchPeopleComponent } from './advanced/advancedSearchPeople.component';
15
import { AdvancedSearchOrganizationsComponent } from './advanced/advancedSearchOrganizations.component';
16
import { SearchCompatibleDataprovidersComponent } from './dataProviders/compatibleDataProviders.component';
17
import { SearchEntityRegistriesComponent } from './dataProviders/entityRegistries.component';
18

  
19
@NgModule({
20
  imports: [
21
    RouterModule.forChild([
22
    { path: 'search/data-providers', component: SearchCompatibleDataprovidersComponent},
23
    { path: 'search/entity-registries', component: SearchEntityRegistriesComponent},
24
    { path: 'search/find', component: SearchComponent },
25
    // { path: 'search', component: SearchComponent },
26
    { path: 'search/find/publications', component: SearchPublicationsComponent },
27
  	{ path: 'search/find/dataproviders', component: SearchDataprovidersComponent },
28
  	{ path: 'search/find/projects', component: SearchProjectsComponent },
29
  	{ path: 'search/find/datasets', component: SearchDatasetsComponent },
30
  	{ path: 'search/find/organizations', component: SearchOrganizationsComponent },
31
  	{ path: 'search/find/people', component: SearchPeopleComponent },
32
  	{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
33
  	{ path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent },
34
  	{ path: 'search/advanced/projects', component: AdvancedSearchProjectsComponent },
35
  	{ path: 'search/advanced/datasets', component: AdvancedSearchDatasetsComponent },
36
  	{ path: 'search/advanced/people', component: AdvancedSearchPeopleComponent },
37
  	{ path: 'search/advanced/organizations', component: AdvancedSearchOrganizationsComponent },
38

  
39
    ])
40
  ]
41
})
42
export class SearchRoutingModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/search.module.ts
1
// import { NgModule}            from '@angular/core';
2
// import { CommonModule }        from '@angular/common';
3
// import { FormsModule }         from '@angular/forms';
4
//
5
// import {UtilsModule} from '../utils/utils.module';
6
// import {ServicesModule} from '../services/services.module';
7
//
8
//
9
// import {Filter, Value} from './searchUtils/searchHelperClasses.class';
10
// import {SearchResult}     from '../utils/entities/searchResult';
11
//
12
//
13
// import {AdvancedSearchPageComponent} from './searchUtils/advancedSearchPage.component';
14
//
15
// // import {BrowseEntitiesComponent} from './searchUtils/browseEntities.component';
16
// // import {BrowseStatisticComponent} from './searchUtils/browseStatistic.component';
17
//
18
// // import {SearchResultComponent} from './searchUtils/searchResult.component';
19
//  import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.component';
20
// // import { SearchPublicationsComponent } from './simple/searchPublications.component';
21
// import { SearchDataprovidersComponent } from './simple/searchDataproviders.component';
22
// import { SearchProjectsComponent } from './simple/searchProjects.component';
23
// // import {SearchDatasetsComponent} from './simple/searchDatasets.component';
24
// import {SearchOrganizationsComponent} from './simple/searchOrganizations.component';
25
// import {SearchPeopleComponent} from './simple/searchPeople.component';
26
//
27
// // import {SearchComponent} from './find/search.component';
28
// import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatibleDataProviders.component';
29
// import {SearchEntityRegistriesComponent} from './dataProviders/entityRegistries.component';
30
// import {DatasourceTableViewComponent} from './dataProviders/datasourceTableView.component';
31
// //Advanced
32
// import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component';
33
// import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component';
34
// import { AdvancedSearchProjectsComponent } from './advanced/advancedSearchProjects.component';
35
// import { AdvancedSearchDatasetsComponent } from './advanced/advancedSearchDatasets.component';
36
// import { AdvancedSearchPeopleComponent } from './advanced/advancedSearchPeople.component';
37
// import { AdvancedSearchOrganizationsComponent } from './advanced/advancedSearchOrganizations.component';
38
//
39
// import {SearchResultsModule} from './searchUtils/searchResults.module';
40
// import { SearchRoutingModule } from './search-routing.module';
41
// import{SearchDatasetsAndPublicationsComponentModule} from './simple/searchDatasetsAndPublications.module'
42
//
43
// @NgModule({
44
//   imports: [
45
//     CommonModule, FormsModule,
46
//     UtilsModule,
47
//     ServicesModule,
48
//     SearchRoutingModule, SearchResultsModule,SearchDatasetsAndPublicationsComponentModule
49
//
50
//   ],
51
//   declarations: [
52
//
53
//     AdvancedSearchPageComponent,
54
//
55
//     AdvancedSearchFormComponent,
56
//      AdvancedSearchPublicationsComponent, AdvancedSearchDataProvidersComponent, AdvancedSearchProjectsComponent,
57
//     AdvancedSearchDatasetsComponent, AdvancedSearchPeopleComponent, AdvancedSearchOrganizationsComponent,
58
//     SearchDataprovidersComponent,
59
//     // SearchComponent,
60
//     SearchProjectsComponent,
61
//     SearchCompatibleDataprovidersComponent,
62
//     SearchEntityRegistriesComponent,
63
//     DatasourceTableViewComponent,
64
//      SearchOrganizationsComponent,
65
//     SearchPeopleComponent,
66
//     BrowseEntitiesComponent,
67
//     BrowseStatisticComponent
68
// ],
69
//
70
//   providers:[
71
//     // SearchPublicationsService
72
//   ],
73
//   exports: [
74
//       // SearchAllComponent,
75
//       AdvancedSearchPublicationsComponent,
76
//       AdvancedSearchDataProvidersComponent,
77
//       AdvancedSearchProjectsComponent,
78
//       // SearchPublicationsComponent,
79
//       SearchProjectsComponent,
80
//       SearchDataprovidersComponent,
81
//       // SearchDatasetsComponent,
82
//       SearchOrganizationsComponent,
83
//       SearchPeopleComponent,
84
//       // SearchComponent,
85
//       SearchCompatibleDataprovidersComponent,
86
//       SearchEntityRegistriesComponent,
87
//       // SearchResultComponent,
88
//       BrowseEntitiesComponent,
89
//       BrowseStatisticComponent
90
//     ]
91
// })
92
// export class SearchModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/commonSimpleSearch.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {UtilsModule} from '../utils/utils.module';
6
import {ServicesModule} from '../services/services.module';
7

  
8

  
9
import {Filter, Value} from './searchUtils/searchHelperClasses.class';
10
import {SearchResult}     from '../utils/entities/searchResult';
11

  
12

  
13
  import {SearchPageComponent} from './searchUtils/searchPage.component';
14
import {SearchFormComponent} from './searchUtils/searchForm.component';
15
 
16
 import {SearchFilterComponent} from './searchUtils/searchFilter.component';
17

  
18

  
19
import {SearchResultsModule} from './searchUtils/searchResults.module';
20
import { SearchRoutingModule } from './search-routing.module';
21

  
22
@NgModule({
23
  imports: [
24
    CommonModule, FormsModule,
25

  
26
    SearchResultsModule
27

  
28
  ],
29
  declarations: [
30

  
31
    SearchPageComponent,
32
    SearchFormComponent,
33
    SearchFilterComponent,
34

  
35
],
36

  
37
  providers:[
38
   ],
39
  exports: [
40
    SearchPageComponent,
41
    SearchFormComponent,
42
    SearchFilterComponent,
43
     ]
44
})
45
export class CommonSimpleSearchModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/simple/searchDatasetsAndPublications.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5

  
6

  
7

  
8
import { SearchPublicationsComponent } from './searchPublications.component';
9

  
10
import {SearchDatasetsComponent} from './searchDatasets.component';
11

  
12

  
13

  
14
@NgModule({
15
  imports: [
16
    CommonModule, FormsModule,
17

  
18

  
19
  ],
20
  declarations: [
21

  
22

  
23

  
24
    SearchPublicationsComponent,
25

  
26
    SearchDatasetsComponent,
27

  
28
],
29

  
30
  providers:[
31
  ],
32
  exports: [
33

  
34
       SearchPublicationsComponent,
35

  
36
       SearchDatasetsComponent,
37

  
38
    ]
39
})
40
export class SearchDatasetsAndPublicationsComponentModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/test/test.component.ts
1 1
import {Component, ElementRef} from '@angular/core';
2 2
import { Subject } from 'rxjs/Subject';
3 3
import {Observable}       from 'rxjs/Observable';
4
import {OpenaireProjectsService} from '../services/openaireProjects.service';
5
import {SearchProjectsService} from '../services/searchProjects.service';
6

  
7
import {SearchPublicationsService} from '../services/searchPublications.service';
8
import {SearchDatasetsService} from '../services/searchDatasets.service';
9
import {ReportsService} from '../services/reports.service';
10

  
11

  
12
import {ISVocabulariesService} from '../services/ISVocabularies.service';
13
import {Dates} from '../utils/string-utils.class';
14
import {SafeHtmlPipe} from '../utils/pipes/safeHTML.pipe';
15

  
4
 
16 5
import {SearchFields} from '../utils/properties/searchFields';
17 6

  
18 7
@Component({
19 8
    selector: 'test',
20 9
    template: `
21
   
22
    <!--div *ngIf="ready"-->
23
        <i-frame [url]=charturl width="30%" height="250"></i-frame>
24
    <!--/div-->
25
 <div style ="width:80%; height:250px;" >
26 10

  
27
 <div>
28
 <div class="container" >
29
          <div class="title">
30
              Welcome
31
          </div>
32
          <div class="panel-body">
33
              <div class="row">
34
                  <div class="input-field col s12">
35
                      <input [(ngModel)]="user.email" id="email"
36
                          type="email" class="validate">
37
                      <label for="email">Email</label>
38
                  </div>
39
              </div>
40 11

  
41
              <div class="row">
42
                  <div class="input-field col s12">
43
                      <input [(ngModel)]="user.password" id="password"
44
                          type="password" class="validate">
45
                      <label for="password">Password</label>
46
                  </div>
47
              </div>
48

  
49
               <button (click)="login()"
50
                  class="btn waves-effect waves-light"
51
                  type="submit" name="action">Login</button>
52
          </div>
53
      </div>
54
      <button (click)="downloadfile()"
55
         class="btn waves-effect waves-light"
56
         type="submit" name="action">DOWNLOAD</button>
57
     </div>
58
     <altmetrics id="10.7717/peerj.1150" type="doi"></altmetrics>
59

  
60 12
`
61 13

  
62 14
})
63 15
export class TestComponent {
64
  public doi="10.7717/peerj.1150";
65
  altmetrics='<div data-badge-popover="right" data-badge-type="donut" data-doi="'+this.doi+'" class="altmetric-embed"> </div>';
66
  public lan; public countries;
67
  public types;
68
  public projectId:string = "arc_________::000dc863f894b1664a9d5f868b7bde9f";
69
  public charturl =('https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"corda_______::2c37878a0cede85dbbd1081bb9b4a2f8", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}');
70 16

  
71
  public url =('http://vaggelas.athenarc.gr/stats/merge.php?com=query&data=[{"table":"project_stats_monthly","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"id","agg":"sum"},"group":"month","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":0,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"untitled","yaxisheaders":["sum of views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"id","values":["'+this.projectId+'"],"to":"-1"}]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true');
72
// public url = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}';
73
  public user:{password:string,email:string} = {password:"",email:""};
74
  constructor(private _projectService: OpenaireProjectsService,private _searchProjectsService:SearchProjectsService,private _searchPubService:SearchPublicationsService,private _searchDataService:SearchDatasetsService, private _vocabulariesService: ISVocabulariesService, private _reportsService: ReportsService) {
75
    // if (typeof document !== 'undefined') {
76
    //    let yourModule = require('../utils/altmetrics.js');
77
    //  }
17
  constructor() {
18

  
78 19
   }
79
public ready:boolean = false;
80 20

  
21

  
81 22
  ngOnInit() {
82
    // this.lan = this._vocabulariesService.getLanguages();
83
    this.lan = this._vocabulariesService.getVocabularyFromService("dnet:languages.json");
84
    this.countries = this._vocabulariesService.getVocabularyFromService("dnet:countries.json");
85
    var year ="1000";
86
    console.info(year+" "+ Dates.isValidYear(year));
87
    year ="600a.j";
88
    console.info(year+" "+ Dates.isValidYear(year));
89
    year ="qw000";
90
    console.info(year+" "+ Dates.isValidYear(year));
91
    year ="00444";
92
    console.info(year+" "+ Dates.isValidYear(year));
93
    year ="1998...";
94
    console.info(year+" "+ Dates.isValidYear(year));
95
    year ="2017";
96
    console.info(year+" "+ Dates.isValidYear(year));
97
    year ="3000";
98
    console.info(year+" "+ Dates.isValidYear(year));
99
    year ="3020";
100
    console.info(year+" "+ Dates.isValidYear(year));
101
    if( typeof localStorage !== 'undefined') {
102 23

  
103
      this.user.email = localStorage.getItem("email");
104
      this.user.password = localStorage.getItem("password");
105 24
    }
106
    // //&collectedFrom=openaire____::4a39de251a65e801bb88d3e75b47623f&cl=and
107
    // this._searchDataService.searchDatasets('&fq=collectedfromdatasourceid exact "openaire____::fdb035c8b3e0540a8d9a561a6c44f4de"' ,"&refine=true&fields=resulthostingdatasourceid", 1, 0, ["resulthostingdatasourceid"]).subscribe(
108
    //     data => {
109
    //
110
    //         console.info("done" +data[0]);
111
    //
112
    //     },
113
    //     err => {
114
    //         console.log(err)
115
    //
116
    //     }
117
    // );
118
    // this._searchPubService.searchPublications('&fq=collectedfromdatasourceid exact "openaire____::fdb035c8b3e0540a8d9a561a6c44f4de"',"&refine=true&fields=resulthostingdatasourceid" , 1, 0, ["resulthostingdatasourceid"]).subscribe(
119
    //     data => {
120
    //
121
    //         console.info("done" +data[0]);
122
    //
123
    //     },
124
    //     err => {
125
    //         console.log(err)
126
    //
127
    //     }
128
    // );
129
    // this._searchProjectsService.getProjectsforDataProvider("openaire____::db600878200645bd752cf7fd96a37df5",1,10).subscribe(
130
    //     data => {
131
    //
132
    //         console.info("done" +data[0]);
133
    //
134
    //     },
135
    //     err => {
136
    //         console.log(err)
137
    //
138
    //     }
139
    // );
140
    // console.info("do the test");
141
    // this.test();
142
    // console.info("after the test");
143 25

  
144
  }
26

  
145 27
  test(){
146 28
    var  sf:SearchFields  = new SearchFields();
147 29
    console.info("~~~RESULT");
......
174 56

  
175 57
 }
176 58

  
177
  login(){
178
    localStorage.setItem("email",this.user.email);
179
    localStorage.setItem("password",this.user.password);
180
    console.info("Save email/ password in local Storage. Email is:" + localStorage.getItem("email"));
181 59

  
182
  }
183 60

  
184
  //On the component
185
//http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22"
186
downloadfile(){
187
  this._reportsService.downloadHTMLFile("http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=html&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22")
188
      .subscribe(data => window.open(window.URL.createObjectURL(data)),
189
                  error => console.log("Error downloading the file."),
190
                  () => console.log('Completed file download.'));
191
  }
61

  
192 62
}
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/searchUtils/searchDownload.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {SearchDownloadComponent} from './searchDownload.component';
6

  
7
@NgModule({
8
  imports: [
9
    CommonModule, FormsModule
10
  ],
11
  declarations: [
12
    SearchDownloadComponent
13
],
14

  
15
  providers:[
16
  ],
17
  exports: [
18
    SearchDownloadComponent
19

  
20
    ]
21
})
22
export class SearchDownloadModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/simple/searchDatasets.component.ts
15 15
    selector: 'search-datasets',
16 16
    template: `
17 17

  
18
    <!--search-page pageTitle="Search Datasets" type="datasets" [(filters)] = "filters"
18
    <search-page pageTitle="Search Datasets" type="datasets" [(filters)] = "filters"
19 19
                 [(results)] = "results"   [(searchUtils)] = "searchUtils"
20 20
                 [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"
21 21
                 [csvParams]="csvParams" csvPath="datasets">
22
    </search-page-->
22
    </search-page>
23 23
    `
24 24
})
25 25

  
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/landingPages/organization/organization.component.ts
9 9
import { SearchDataprovidersService } from '../../services/searchDataproviders.service';
10 10

  
11 11
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
12
import {ExportCSVComponent} from '../../utils/exportCSV.component';
13 12

  
14 13
@Component({
15 14
    selector: 'organization',
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/test/test.module.ts
5 5
import { TestRoutingModule } from './test-routing.module';
6 6

  
7 7

  
8
import {UtilsModule} from '../utils/utils.module';
9
import {ServicesModule} from '../services/services.module';
10

  
11

  
8
 
12 9
@NgModule({
13 10
  imports: [
14 11
    SharedModule,
15 12
    TestRoutingModule,
16
    UtilsModule,
17
    ServicesModule    
13

  
18 14
  ],
19 15
  declarations: [
20 16
    TestComponent
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/test/test-routing.module.ts
6 6
@NgModule({
7 7
  imports: [
8 8
    RouterModule.forChild([
9
      { path: 'test', component: TestComponent},
9
      { path: '', component: TestComponent},
10 10

  
11 11
    ])
12 12
  ]
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import{ CompatibleDataProvidersRoutingModule} from './compatibleDataProviders-routing.module';
6
import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component';
7

  
8
import {SearchResultsModule } from '../searchUtils/searchResults.module';
9

  
10
import {DataProvidersServiceModule} from '../../services/dataProvidersService.module';
11
import {SearchFormModule} from  '../searchUtils/searchForm.module';
12
import {SearchPageModule} from '../searchUtils/searchPage.module';
13
@NgModule({
14
  imports: [
15
    CommonModule, FormsModule,
16
    DataProvidersServiceModule,
17
     SearchFormModule, SearchResultsModule, CompatibleDataProvidersRoutingModule, SearchPageModule
18

  
19
  ],
20
  declarations: [
21
    SearchCompatibleDataprovidersComponent
22
   ],
23
  providers:[
24
    ],
25
  exports: [
26
    SearchCompatibleDataprovidersComponent
27
     ]
28
})
29
export class CompatibleDataProvidersModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts
1
import { NgModule } from '@angular/core';
2
import { RouterModule } from '@angular/router';
3

  
4
import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component';
5

  
6
@NgModule({
7
  imports: [
8
    RouterModule.forChild([
9
     	{ path: '', component: SearchCompatibleDataprovidersComponent }
10

  
11
    ])
12
  ]
13
})
14
export class CompatibleDataProvidersRoutingModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/utils/exportCSV.class.ts
1

  
2

  
3

  
4
export class ExportCSVComponent {
5
    stockData : any =
6
        {
7
            "columnNames":
8
                ["Symbol", "Company", "Price"],
9
            "export":
10
/*
11
                [
12
                    {
13
                        Symbol: "AAPL",
14
                        Company: "Apple Inc.",
15
                        Price: "132.54"
16
                    },
17
                    {
18
                        Symbol: "INTC",
19
                        Company: "Intel Corporation",
20
                        Price: "33.45"
21
                    },
22
                    {
23
                        Symbol: "GOOG",
24
                        Company: "Google Inc",
25
                        Price: "554.52"
26
                    },
27
                ],
28
*/
29

  
30
                [
31
                    [
32
                        "AAPL",
33
                        "Apple Inc.",
34
                        "132.54"
35
                    ],
36
                    [
37
                        "INTC",
38
                        "Intel Corporation",
39
                        "33.45"
40
                    ],
41
                    [
42
                        "GOOG",
43
                        "Google Inc",
44
                        "554.52"
45
                    ],
46
                ],
47

  
48

  
49
            "columnDelimiter": ',',
50
            "lineDelimiter": '\n'
51
        };
52

  
53
     data: any = this.stockData;
54
     filename: string;
55
     linkname: string = "Download CSV";
56

  
57
    constructor () {
58
        console.info('export constructor');
59
    }
60

  
61
    ngOnInit() {
62
    }
63

  
64
    public static convertArrayOfObjectsToCSV(args) {
65
        console.info("convertArrayOfObjectsToCSV");
66

  
67
        var result, ctr, keys, columnDelimiter, lineDelimiter, data;
68

  
69
        data = args.export || null;
70

  
71
        if (data == null || !data.length) {
72
            return null;
73
        }
74

  
75
        columnDelimiter = args.columnDelimiter || ',';
76
        lineDelimiter = args.lineDelimiter || '\n';
77

  
78
        //keys = Object.keys(data[0]);
79
        keys = args.columnNames;
80

  
81
        result = '';
82
        result += keys.join(columnDelimiter);
83
        result += lineDelimiter;
84
/*
85
        data.forEach(function(item) {
86
            ctr = 0;
87
            keys.forEach(function(key) {
88
                if (ctr > 0) result += columnDelimiter;
89
                result += item[key];
90
                ctr++;
91
            });
92
            result += lineDelimiter;
93
        });
94
*/
95

  
96
        for(let line of data) {
97
            ctr = 0;
98
            for(let column of line) {
99
                if (ctr > 0) result += columnDelimiter;
100
                result += column;
101
                ctr++;
102
            }
103
            result += lineDelimiter;
104
        }
105

  
106
        return result;
107
    }
108

  
109
    public static downloadCSV(data: any, filenameArg: string) {
110
        console.info("downloadCSV");
111

  
112
        var encodedData, filename, link;
113

  
114
        var csv = this.convertArrayOfObjectsToCSV(data);
115
        if (csv == null) return;
116

  
117
        filename = filenameArg || 'export.csv';
118

  
119
        if (!csv.match(/^data:text\/csv/i)) {
120
            csv = 'data:text/csv;charset=utf-8,' + csv;
121
        }
122
        encodedData = encodeURI(csv);
123

  
124
        //link = document.createElement('a');
125
        link = document.getElementsByTagName('a');
126
        link[0].setAttribute('href', encodedData);
127
        link[0].setAttribute('download', filename);
128
        //document.body.appendChild(link);
129
        link[0].click();
130
        //document.body.removeChild(link);
131
    }
132
}
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts
1
import { NgModule } from '@angular/core';
2
import { RouterModule } from '@angular/router';
3

  
4
import{SearchEntityRegistriesComponent} from './entityRegistries.component';
5

  
6
@NgModule({
7
  imports: [
8
    RouterModule.forChild([
9
     	{ path: '', component: SearchEntityRegistriesComponent }
10

  
11
    ])
12
  ]
13
})
14
export class EntityRegistriesRoutingModule { }
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts
7 7
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
8 8
import {SearchFields} from '../../utils/properties/searchFields';
9 9
import {SearchPageComponent } from '../searchUtils/searchPage.component';
10
import {ExportCSVComponent} from '../../utils/exportCSV.component';
10
import {ExportCSVComponent} from '../../utils/exportCSV.class';
11 11
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
12 12

  
13 13
@Component({
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/app.module.ts
8 8
import { AppRoutingModule } from './app-routing.module';
9 9
import { AppComponent, XLargeDirective } from './app.component';
10 10

  
11
// custom modules::
12
// import {SearchModule} from './searchPages/search.module';
13
// import {DepoditModule} from './deposit/deposit.module';
14
// import {LandingModule} from './landingPages/landing.module';
15 11
import {SharedComponentsModule} from './sharedComponents/sharedComponents.module'; //navbar
16
// import {UtilsModule} from './utils/utils.module';
17
// import {TestModule} from './test/test.module';
18
// import { HomeModule } from './home/home.module';
12

  
19 13
import { ErrorModule } from './error/error.module';
14
import { CacheService } from './shared/cache.service';
20 15

  
21
// import {ServicesModule} from './services/services.module';
22 16

  
23 17
@NgModule({
24 18
  declarations: [ AppComponent, XLargeDirective ],
25 19
  imports: [
26
    //MaterialModule.forRoot(),
27 20
    SharedModule,
28
    // HomeModule,
29
    // SearchModule,
30
    // DepoditModule,
31
    // LandingModule,
21

  
32 22
    SharedComponentsModule,
33
    // UtilsModule,
34
    // ServicesModule,
35
    // TestModule,
36 23
    AppRoutingModule,
37 24
    ErrorModule
38
  ], exports:[]
25
  ], exports:[], providers:[CacheService]
39 26
})
40 27
export class AppModule {
41 28
}
modules/uoa-services-portal/branches/lazy-routes/portal-2/src/app/utils/staticAutoComplete/ISVocabularies.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {AutoCompleteValue} from '../../searchPages/searchUtils/searchHelperClasses.class';
5
import 'rxjs/add/observable/of';
6
import 'rxjs/add/operator/do';
7
import 'rxjs/add/operator/share';
8
import { CacheService  } from '../../shared/cache.service';
9

  
10
@Injectable()
11
export class ISVocabulariesService {
12
    // private api ="https://beta.services.openaire.eu/provision/mvc/vocabularies/";
13
    // private api = "http://api.openaire.eu/vocabularies/"
14
    private api = "http://dev.openaire.research-infrastructures.eu/vocabularies/";
15
    constructor(private http: Http, public _cache: CacheService) {}
16

  
17
    getVocabularyByType(field:string,entity:string):any{
18
      console.log("getVocabulary field: "+ field + " for entity: "+ entity);
19
      var file = "";
20
      var vocabulary = "";
21
      if( field == "lang"){
22
          // file="languages.json";
23
          // return this.getVocabularyFromFile(file);
24
          vocabulary = "dnet:languages.json";
25
          return this.getVocabularyFromService(vocabulary);
26
      }else if ( field == "type" && (entity == "publication")){
27
        // file = "publicationTypes.json";
28
        // return this.getVocabularyFromFile(file);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff