Project

General

Profile

« Previous | Next » 

Revision 44862

Deposit: Use Autocomplete in search Organization| add access mode icos| Add access mode in search results & in pubs/data Landing pages

View differences:

modules/uoa-services-portal/trunk/portal-2/src/app/services/entitySearch.service.ts
22 22
          return this.parse(request,"oaf:project","project");
23 23
        });
24 24
      }
25
      searchByDepositType(keyword:string, DepositType:string):any {
26
        console.info("In searchOrganizationsforDeposit");
27

  
28
        let link = OpenaireProperties.getSearchResourcesAPIURL();
29

  
30
        let url = link+"?query=";
31
        if(keyword!= null && keyword != ''  ) {
32
          url += "((oaftype exact organization and deletedbyinference=false and "+
33
            "(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=*))"+
34
            " and ((organizationlegalname all "+'"'+keyword+'"'+") or (organizationlegalshortname all "+'"'+keyword+'"'+")) " +
35
            // "and " + this.quote(params) + " " +
36
            "and (collectedfromdatasourcename exact "+DepositType+")) "
37

  
38
        }
39

  
40
        url += "&page=0&size=10";
41
        url += "&format=json";
42

  
43
        // let url =  OpenaireProperties. getSearchAPIURLLast()+"projects?"+((keyword && keyword.length > 0)?("q=" +keyword):"")+((funderId && funderId.length > 0 )?"&fq=funderid exact " + '"'+funderId+ '"':"")+"&size=10&page=0&format=json";
44
        return this.http.get(url).toPromise()
45
        .then(request =>
46
          {
47
            request = request.json().results;
48
            console.log(request);
49
            return this.parse(request,"oaf:organization","organization");
50
          });
51
        }
25 52
    searchByType(keyword:string,type:string){
26 53
       if (type == "project"){
27 54
         return  this.searchEntity(keyword,"projects","oaf:project","project");
......
91 118

  
92 119

  
93 120
    }
94
    // private search (link,keyword,oafEntityType,type){
95
    //   let url = link+"?";
96
    //   if(keyword!= null && keyword != ''  ) {
97
    //       url += "q="+ keyword;
98
    //   }
99
    //
100
    //   url += "&page=0&size="+10+"&format=json";
101
    //   return this.http.get(url)
102
    //   .map(res => <any> res.json().results)
103
    //           .map(res => <any> this.parse(res,oafEntityType,type));
104
    //             //  .then(request =>
105
    //             //    {
106
    //             //      request = request.json().results;
107
    //             //      return this.parse(request,oafEntityType,type);
108
    //             //    });
109
    //
110
    //
111
    // }
121

  
112 122
    private parse(data: any,oafEntityType:string, type:string){
113 123
      var array:any =[]
114 124
      let length = Array.isArray(data) ? data.length : 1;
......
130 140
                    value.label = resData["fullname"];
131 141
              }
132 142
            }else if(resData["legalname"]){
143

  
133 144
              if(Array.isArray(resData["legalname"])) {
134 145
                    value.label = resData["legalname"][0];
135 146
              } else {
136 147
                    value.label = resData["legalname"];
137 148
              }
149

  
138 150
            }
139
             value.id = length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
151
             value.id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
152

  
140 153
             if(type=="project"){
141 154
                  value.projectAcronym = resData['acronym'];
142 155
                  value.projectName = value.label;
......
152 165
             }
153 166
              array.push(value);
154 167
        }
168
        console.info("Parsing results.... Size:"+array.length);
155 169

  
156 170
        return array;
157 171
    }
modules/uoa-services-portal/trunk/portal-2/src/app/services/publication.service.ts
64 64
            this.publicationInfo.embargoEndDate = data[0].embargoenddate;
65 65
        }
66 66

  
67
        this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""};
68
        if(data[0]['bestlicense'].hasOwnProperty("classid")) {
69
            this.publicationInfo.title.accessMode = data[0]['bestlicense'].classid;
70
        }
67 71
        if(data[1] != null) {
68
            this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""};
69 72

  
70 73
            if(Array.isArray(data[1])) {
71 74
                this.publicationInfo.title['name'] = data[1][0].content;
modules/uoa-services-portal/trunk/portal-2/src/app/services/dataset.service.ts
66 66
            }
67 67
            this.datasetInfo.embargoEndDate = data[0].embargoenddate;
68 68
        }
69

  
69
        this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
70
        if(data[0]['bestlicense'].hasOwnProperty("classid")) {
71
            this.datasetInfo.title.accessMode = data[0]['bestlicense'].classid;
72
        }
70 73
        if(data[1] != null) {
71
            this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
72 74
            if(Array.isArray(data[1])) {
73 75
                this.datasetInfo.title['name'] = data[1][0].content;
74 76
            } else {
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/searchUtils/searchResult.component.ts
12 12
      <div *ngIf="status == errorCodes.NOT_AVAILABLE" class="alert alert-danger" role="alert">Service not available</div>
13 13

  
14 14
        <li *ngFor="let result of results">
15
            <h4>
15
            <h4 [class] = result.title.accessMode [title] = result.title.accessMode >
16 16
                <a href="{{result['title'].url}}">
17 17
                    <p *ngIf="result['title'].name != undefined && result['title'].name != ''"
18 18
                        [innerHTML]="result['title'].name">
modules/uoa-services-portal/trunk/portal-2/src/app/landingPages/showTitle.component.ts
4 4
@Component({
5 5
    selector: 'showTitle',
6 6
    template: `
7
        <h2 *ngIf="title != undefined">
7
        <h2 *ngIf="title != undefined" [class] = "title['accessMode']" [title] = "title['accessMode']" >
8 8
            <div *ngIf="title['url'] != undefined">
9 9
                <a class="custom-external" href="{{title['url']}}" target="_blank">
10 10
                    <div [innerHTML]="title['name']"></div>
......
15 15
            </div>
16 16
        </h2>
17 17
    `
18
    
18

  
19 19
    })
20 20

  
21 21
export class ShowTitleComponent {
modules/uoa-services-portal/trunk/portal-2/src/app/utils/entitiesAutoComplete.component.ts
25 25
          <div *ngIf = "keyword != null && keyword.length > 0  " class="suggestions" >
26 26
                <div *ngIf="showLoading" class="alert alert-info row-fluid " role="alert">Loading...  <span class="glyphicon glyphicon-repeat" aria-hidden="true"></span></div>
27 27
                <ul class="list-group" >
28
                    <li  *ngIf = "filtered.length > 0 " class="list-group-item"  >
28
                    <li  *ngIf = "numFilteredResults > 0 " class="list-group-item"  >
29 29
                        Select:
30 30
                    </li>
31 31
                    <li  class="list-group-item"   *ngFor=" let item of filtered | async">
......
35 35
          </div>
36 36
          <div class="messages">
37 37
            <div *ngIf="warningMessage.length > 0" class="alert alert-warning row-fluid " role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{{warningMessage}}</div>
38
            <div *ngIf="filtered.length == 0 && keyword.length >=3 " class="alert alert-info row-fluid " role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>No results found</div>
38
            <div *ngIf="numFilteredResults == 0 && keyword.length >=3 " class="alert alert-info row-fluid " role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>No results found</div>
39 39
          </div>
40 40
      </div>
41 41

  
......
70 70

  
71 71
    @Input() public funderId:string;
72 72
    @Input() public entityType:string ;
73
    @Input() public depositType:string ;
73 74

  
74 75
    constructor (private _search:EntitiesSearchService, private myElement: ElementRef) {
75 76

  
76 77

  
78

  
77 79
    }
78 80

  
79 81
    ngOnInit () {
82
      console.info("init deposit org" +this.entityType  +" "+this.depositType);
83

  
80 84
       if(this.entityType == "project" && this.funderId ){
81 85
        this.filtered  = this.searchTermStream
82 86
        .debounceTime(300).distinctUntilChanged()
......
86 90
            this.numFilteredResults = results.length;
87 91
            return   results;
88 92
        });
93
      }else if(this.entityType == "organization" && this.depositType ){
94
        console.info("init deposit org")
95
        this.filtered  = this.searchTermStream
96
        .debounceTime(300).distinctUntilChanged()
97
        .switchMap((term: string) => {
98
          var results = this._search.searchByDepositType(term, this.depositType);
99
          this.showLoading = false;
100
          this.numFilteredResults = results.length;
101
          console.info("deposit org::: Resuults"+results.length)
102

  
103
          return   results;
104
      });
105

  
89 106
      }else{
90 107

  
91 108
        this.filtered  = this.searchTermStream
......
96 113
          this.numFilteredResults = results.length;
97 114
          return   results;
98 115
      });
99
      //   this.filtered  =
100
      //   this.searchTermStream
101
      //   .debounceTime(300).distinctUntilChanged()
102
      //   .switchMap((term: string) => {
103
      //     var results = this._search.searchByType(term, this.entityType);
104
      //     this.showLoading = false;
105
      //     return   results;
106
      // });
107
      //
108 116

  
109
 //      .subscribe(term => this.wikipediaService.search(term).then(items => this.items = items));
110
 // // }
111 117
        this.getSelectedNameFromGivenId();
112 118
      }
113 119

  
modules/uoa-services-portal/trunk/portal-2/src/app/deposit/deposit.component.ts
34 34
                <h3>Locate data provider via your institution</h3>
35 35

  
36 36
                <form>
37
                  <div class="form-group  form-inline">
37 38
                    <div class="input-group">
39
                      <entities-autocomplete [entityType]="'organization'" [depositType]=compatibility   [selectedValue]=selectedId [showSelected]=true
40
                      [placeHolderMessage] = "'Search for Organizations'" [title] = "Organizations"  [multipleSelections]=false
41
                      (selectedValueChanged)="valueChanged($event)"    ></entities-autocomplete>
42
                    </div>
43
                    <button class="btn btn-default" type="submit" (click)="organizationSelected(selectedId)" >Next</button>
44
                  </div>
45
                    <!--div class="input-group">
38 46
                        <span class="input-group-addon" id="sizing-addon2">Filter</span>
39 47
                        <span>
40 48
                            <input type="text" class="form-control" placeholder="Type keywords..." aria-describedby="sizing-addon2"  [(ngModel)]="keyword"  name="keyword" >
......
42 50
                        <span class="input-group-btn">
43 51
                            <button (click)="keywordChanged()"  type="submit" class="btn btn-default">SELECT</button>
44 52
                        </span>
53

  
45 54
                    </div>
55

  
46 56
                    <div>
47 57
                          <ul class="list-group" >
48 58
                              <li class="list-group-item" *ngIf="status == errorCodes.LOADING">
......
64 74
                                  <a style="cursor:pointer;" (click)="organizationSelected(item.id)">{{item.name}}</a>
65 75
                              </li>
66 76
                          </ul>
67
                    </div>
77
                    </div-->
68 78
                </form>
69 79
            </div>
70 80
        </div>
......
85 95

  
86 96
    public status: number;
87 97
    public errorCodes:ErrorCodes = new ErrorCodes();
98
    public selectedId = "";
88 99

  
89 100
    constructor (private _router: Router,
90 101
                 private _searchOrganizationsService: SearchOrganizationsService) {
......
122 133
    }
123 134

  
124 135
    organizationSelected(id: string) {
125
        if(this.requestFor == "Publications") {
126
            this._router.navigate( ['deposit-publications-result'], { queryParams: { "organizationId": id } } );
127
        } else if(this.requestFor == "Datasets") {
128
            console.info("call deposit result for datasets")
129
            this._router.navigate( ['deposit-datasets-result'], { queryParams: { "organizationId": id } } );
136
      if(id && id.length > 0){
137

  
138

  
139
          if(this.requestFor == "Publications") {
140
              this._router.navigate( ['deposit-publications-result'], { queryParams: { "organizationId": id } } );
141
          } else if(this.requestFor == "Datasets") {
142
              console.info("call deposit result for datasets")
143
              this._router.navigate( ['deposit-datasets-result'], { queryParams: { "organizationId": id } } );
144
          }
130 145
        }
131 146
    }
147

  
148
    valueChanged($event){
149
      this.selectedId = $event.value;
150
    }
132 151
}
modules/uoa-services-portal/trunk/portal-2/src/index.html
23 23
      .search-form {margin:5px;  }
24 24
      .clickable { cursor:pointer; }
25 25

  
26
      .OPEN {
27
          background: rgba(0, 0, 0, 0) url("/assets/openAccess.png") no-repeat scroll right center;
28
          padding-right: 18px;
29
      }
30

  
31
      .EMBARGO, .CLOSED, .RESTRICTED {
32
          background: rgba(0, 0, 0, 0) url("/assets/closedAccess.png") no-repeat scroll right center;
33
          padding-right: 18px;
34
      }
26 35
    </style>
27 36

  
28 37
    <base href="/">

Also available in: Unified diff