Project

General

Profile

« Previous | Next » 

Revision 56750

Linking:
Basket Limit:
set to 100
don't allow to add more through search forms
don't allow more in bulk
Bulk - access mode and date: fix getting info from csv
Add margins
Display claims; remove showLatestClaims attribute

Landing pub - HelpeTexts: remove doule quote and helper

View differences:

bulkClaim.component.ts
16 16
    <div class="uk-animation uk-text-center" style=" ">
17 17
      <form class=" ">
18 18

  
19
        <div class="uk-grid">
20
          <div class="uk-width-expand">
19
        <div>
20
          <div>
21 21
            <!--div class="uk-text-lead">Upload a DOI csv file <helper  div="link-result-bulk" tooltip=true ></helper></div>
22 22
            <label for="exampleInputFile">Select a file: </label-->
23 23
            <div class="js-upload" uk-form-custom>
......
31 31

  
32 32

  
33 33
            <div *ngIf="showReport" uk-alert class="uk-alert uk-alert-primary" role="alert">
34
              <a class="uk-alert-close uk-icon uk-close"  ><svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg" data-svg="close-icon"><line fill="none" stroke="#000" stroke-width="1.1" x1="1" y1="1" x2="13" y2="13"></line><line fill="none" stroke="#000" stroke-width="1.1" x1="13" y1="1" x2="1" y2="13"></line></svg></a>
35
              <div>Uploaded file contains {{allIds.length}} {{((allIds.length == 1) ? 'DOI' : 'DOIs')}}.
34
              <a class="uk-alert-close uk-icon uk-close">
35
                <svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"
36
                     data-svg="close-icon">
37
                  <line fill="none" stroke="#000" stroke-width="1.1" x1="1" y1="1" x2="13" y2="13"></line>
38
                  <line fill="none" stroke="#000" stroke-width="1.1" x1="13" y1="1" x2="1" y2="13"></line>
39
                </svg>
40
              </a>
41
              <div>Uploaded file contains <span
42
                class="uk-text-bold">{{allIds.length}} {{((allIds.length == 1) ? 'DOI' : 'DOIs')}}</span>.
36 43
                <span
37
                  *ngIf="allIds.length > 0">{{foundIds.length}} {{((foundIds.length == 1) ? 'result was' : 'results were')}} succefully  fetched from CrossRef and Datacite.</span>
44
                  *ngIf="exceedsLimit">
45
                  <div class="uk-text-danger">Basket exceeds  the size limit.</div>
46
                  <span *ngIf="allIds.length > 0 && foundIds.length > 0">Only </span>
47
                  <span *ngIf="allIds.length > 0 && foundIds.length == 0">No results added.</span>
48
                   </span>
49
                <span
50
                  *ngIf="allIds.length > 0 && foundIds.length > 0">{{foundIds.length}} {{((foundIds.length == 1) ? 'result was' : 'results were')}} succefully  fetched from 
51
                  <span class="uk-text-bold">CrossRef</span>{{ ' and ' }}<span
52
                    class="uk-text-bold">Datacite</span>.</span>
53

  
38 54
              </div>
39 55
              <div
40 56
                *ngIf="duplicateIds.length > 0">{{duplicateIds.length | number}} duplicate DOIs in {{((duplicateIds.length == 1) ? 'line' : 'lines')}} {{duplicateIdsRow}}.
41 57
              </div>
42
              <div *ngIf="notFoundIds.length > 0">Couldn't be found:
58
              <div *ngIf="notFoundIds.length > 0">Couldn't be fetched:
43 59
                <ul class="">
44 60
                  <li *ngFor="let id of notFoundIds; let i = index">"{{id}}" in line {{notFoundIdsRow[i]}}</li>
45 61
                </ul>
......
50 66
                </ul>
51 67
              </div>
52 68
              <div
53
                *ngIf="allIds.length == 0 || foundIds.length == 0"> Please make sure that the uploaded file, is a csv file with the proper format.
69
                *ngIf="allIds.length == 0 || (foundIds.length == 0 && !exceedsLimit)"> Please make sure that the uploaded file, is a csv file with the proper format.
54 70
              </div>
55 71

  
56 72
            </div>
57 73
            <div *ngIf="errorMessage.length > 0 " class="uk-alert uk-alert-danger" role="alert">
58
              <a class="uk-alert-close uk-icon uk-close"  ><svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg" data-svg="close-icon"><line fill="none" stroke="#000" stroke-width="1.1" x1="1" y1="1" x2="13" y2="13"></line><line fill="none" stroke="#000" stroke-width="1.1" x1="13" y1="1" x2="1" y2="13"></line></svg></a>
74
              <a class="uk-alert-close uk-icon uk-close">
75
                <svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"
76
                     data-svg="close-icon">
77
                  <line fill="none" stroke="#000" stroke-width="1.1" x1="1" y1="1" x2="13" y2="13"></line>
78
                  <line fill="none" stroke="#000" stroke-width="1.1" x1="13" y1="1" x2="1" y2="13"></line>
79
                </svg>
80
              </a>
59 81
              {{errorMessage}}</div>
60 82

  
61 83
          </div>
......
82 104

  
83 105
  allIds: string[] = [];
84 106
  foundIds: string[] = [];
107
  existedIds: string[] = [];
85 108
  duplicateIds: string[] = [];
86 109
  duplicateIdsRow: number[] = [];
87 110
  notFoundIds: string[] = [];
......
94 117
  enableUpload: boolean = true;
95 118
  @Input() localStoragePrefix: string = "";
96 119
  exceedsLimit = false;
97
  limit = 150;
120
  @Input() basketLimit ;
98 121

  
99 122
  constructor(private _searchCrossrefService: SearchCrossrefService, private _searchDataciteService: SearchDataciteService) {
100 123
    this.filesToUpload = [];
......
123 146
      this.exceedsLimit = false;
124 147
      let invalid_rows = 0;
125 148
      this.duplicateIds = [];
149
      this.existedIds = [];
126 150
      this.allIds = [];
127 151
      this.foundIds = [];
128 152
      this.noValidIds = [];
129 153
      this.results.slice(0, this.results.length);
130 154
      this.notFoundIds = [];
131

  
132
      if (rows.length + this.results.length > this.limit) {
155
      if (rows.length + this.results.length > this.basketLimit) {
133 156
        this.exceedsLimit = true;
134
        UIkit.notification({
135
          message: 'Your basket exceeds the number of allowed results (150)',
136
          status: 'warning',
137
          timeout: 1500,
138
          pos: 'top-center'
139
        });
140 157

  
141 158
      }
142
      for (let i = 0; i < ((rows.length > this.limit - this.results.length) ? (this.limit - this.results.length) : rows.length); i++) {
159
      let currentLength = this.results.length;
160
      for (let i = 0; i < ( rows.length); i++) {
143 161
        if (rows[i] && rows[i] != null) {
144 162
          const values = rows[i].split(',');
145 163

  
......
147 165
          if (DOI.isValidDOI(id)) {
148 166
            let accessMode = (values[1] != undefined) ? BulkClaimComponent.removeDoubleQuotes(values[1]) : "OPEN";
149 167
            accessMode = (BulkClaimComponent.validateAccessMode(accessMode) ? accessMode : "OPEN");
150
            let embargoDate = (values[2] != undefined) ? BulkClaimComponent.removeDoubleQuotes(values[2]) : Dates.getDateToday();
151
            embargoDate = (Dates.isValidDate(embargoDate) ? embargoDate : Dates.getDateToday());
168
            let embargoDate = (values[2] != undefined) ? Dates.getDateFromString(BulkClaimComponent.removeDoubleQuotes(values[2])) : Dates.getDateToday();
152 169
            if (this.allIds.indexOf(id) > -1) {
153 170
              this.duplicateIds.push(id);
154 171
              this.duplicateIdsRow.push(i + 1);
155 172
            } else {
156 173
              this.allIds.push(id);
157
              this.fetchResult(id, accessMode, embargoDate, i + 1);
174
              if (currentLength < this.basketLimit){
175
                currentLength++;
176
                this.fetchResult(id, accessMode, Dates.getDateToString(embargoDate), i + 1);
177
              }
158 178
            }
159 179
          } else {
160 180
            this.noValidIds.push(id);
......
165 185
        }
166 186

  
167 187
      }
168
      if (rows.length == 0 || rows.length == invalid_rows || rows.length == (invalid_rows + this.noValidIds.length) || this.limit == this.results.length) {
188
      if (rows.length == 0 || rows.length == invalid_rows || rows.length == (invalid_rows + this.noValidIds.length) || this.basketLimit <= this.results.length) {
169 189
        this.endOfFetching();
170 190
      }
171 191

  
172 192
    }, (error) => {
173 193
      this.enableUpload = true;
174
      console.log(error);
175 194
      this.loading.close();
176
      //this.errorMessage = "An error occured while uploading...";
195
      this.errorMessage = "An error occured.";
177 196
      BulkClaimComponent.handleError("Error uploading file", error);
178 197
    });
179 198
  }
......
224 243
    this._searchCrossrefService.searchCrossrefByDOIs([id], this.properties.searchCrossrefAPIURL, true).subscribe(
225 244
      data => {
226 245

  
227
        const result = data[1][0];
246
        const result:ClaimEntity = data[1][0];
228 247
        if (data[1].length > 0) {
229 248
          this.foundIds.push(id);
230
          result["embargoEndDate"] = date;
249
          result.result.accessRights = accessMode;
250
          result.result.embargoEndDate = date;
231 251
          if(!this.isSelected(result)){
232 252
            this.results.push(result);
253
          }else{
254
            this.existedIds.push(id);
233 255
          }
234 256
          this.endOfFetching();
235 257
        } else {
......
255 277
          var result = items[1][0];
256 278

  
257 279
          this.foundIds.push(id);
258
          result["embargoEndDate"] = date;
280
          result.result.accessRights = accessMode;
281
          result.result.embargoEndDate = date;
259 282
          if(!this.isSelected(result)){
260 283
            this.results.push(result);
284
          }else{
285
            this.existedIds.push(id);
261 286
          }
262 287
        } else {
263 288
          this.notFoundIds.push(id);
......
276 301
  }
277 302

  
278 303
  endOfFetching() {
279
    if (this.limit == this.results.length) {
280
      this.enableUpload = true;
281
      this.loading.close();
282
      return;
283
    }
284
    if (this.allIds.length == this.foundIds.length + this.notFoundIds.length) {
304
    // if (this.basketLimit <= this.results.length) {
305
    //   this.enableUpload = true;
306
    //   this.loading.close();
307
    //   return;
308
    // }
309
    // console.log(this.allIds.length+" "+this.foundIds.length +" "+ this.notFoundIds.length+" "+this.existedIds.length + " " + this.results.length);
310
    if (this.allIds.length == this.foundIds.length + this.notFoundIds.length || this.basketLimit <= (this.results.length+this.existedIds.length+this.notFoundIds.length)) {
285 311
      this.showReport = true;
286 312
      this.enableUpload = true;
287 313
      this.loading.close();

Also available in: Unified diff