Revision 46951
Added by Argiro Kokogiannaki about 7 years ago
displayClaims.component.ts | ||
---|---|---|
84 | 84 |
selected=[]; |
85 | 85 |
deleteMessage:string = ""; |
86 | 86 |
showErrorMessage:boolean = false; |
87 |
userValidMessage:string = ""; |
|
87 | 88 |
|
88 | 89 |
//params for pagingFormatter to use when navigate to page |
89 | 90 |
params; |
... | ... | |
92 | 93 |
claimsDeleted:number = 0; |
93 | 94 |
|
94 | 95 |
getClaims () { |
96 |
if(!Session.isValidAndRemove()){ |
|
97 |
this.userValidMessage = "User session has expired. Please login again."; |
|
98 |
|
|
99 |
}else{ |
|
100 |
var token=Session.getUserJwt(); |
|
95 | 101 |
this.selected=[]; |
96 | 102 |
var types = ''; |
97 | 103 |
this.showErrorMessage = false; |
... | ... | |
99 | 105 |
types+=(types.length>0?'&':'')+"types="+type; |
100 | 106 |
} |
101 | 107 |
if(this.fetchBy =="Project" ){ |
102 |
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( |
|
108 |
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
|
103 | 109 |
data => { |
104 | 110 |
this.claims = data.data; |
105 | 111 |
this.resultsNum= data.total; |
... | ... | |
110 | 116 |
} |
111 | 117 |
); |
112 | 118 |
}else if(this.fetchBy =="User"){ |
113 |
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( |
|
119 |
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
|
114 | 120 |
data => { |
115 | 121 |
this.claims = data.data; |
116 | 122 |
this.resultsNum= data.total; |
... | ... | |
121 | 127 |
} |
122 | 128 |
); |
123 | 129 |
}else if(this.fetchBy =="Result"){ |
124 |
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( |
|
130 |
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
|
125 | 131 |
data => { |
126 | 132 |
this.claims = data.data; |
127 | 133 |
this.resultsNum= data.total; |
... | ... | |
132 | 138 |
} |
133 | 139 |
); |
134 | 140 |
}else if(this.fetchBy =="Context"){ |
135 |
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( |
|
141 |
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
|
136 | 142 |
data => { |
137 | 143 |
this.claims = data.data; |
138 | 144 |
this.resultsNum= null; |
... | ... | |
144 | 150 |
} |
145 | 151 |
); |
146 | 152 |
}else{ |
147 |
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types).subscribe( |
|
153 |
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
|
148 | 154 |
data => { |
149 | 155 |
this.claims = data.data; |
150 | 156 |
this.resultsNum = null; |
... | ... | |
157 | 163 |
); |
158 | 164 |
} |
159 | 165 |
} |
166 |
} |
|
160 | 167 |
|
161 | 168 |
goToClaim(claimId: number){ |
162 | 169 |
this._router.navigate( ['Claim', { id: claimId}] ); |
... | ... | |
381 | 388 |
} |
382 | 389 |
|
383 | 390 |
deleteById(id:string){ |
391 |
if(!Session.isValidAndRemove()){ |
|
392 |
this.userValidMessage = "User session has expired. Please login again."; |
|
384 | 393 |
|
394 |
}else{ |
|
395 |
var token=Session.getUserJwt(); |
|
385 | 396 |
console.log("Deleting claim with id:"+id); |
386 | 397 |
// this._claimService.deleteClaimById(id); |
387 |
this._claimService.deleteClaimById(id).subscribe( |
|
398 |
this._claimService.deleteClaimById(id,token).subscribe(
|
|
388 | 399 |
res => { |
389 | 400 |
console.log('Delete response'+res.code ); |
390 | 401 |
console.log("Deleted claim with id:"+ id); |
... | ... | |
407 | 418 |
|
408 | 419 |
|
409 | 420 |
}); |
421 |
} |
|
410 | 422 |
} |
411 | 423 |
batchDeleteById(ids:string[]){ |
424 |
if(!Session.isValidAndRemove()){ |
|
425 |
this.userValidMessage = "User session has expired. Please login again."; |
|
412 | 426 |
|
427 |
}else{ |
|
428 |
var token=Session.getUserJwt(); |
|
413 | 429 |
console.warn("Deleting claim with ids:"+ids); |
414 |
this._claimService.deleteBulk(ids).subscribe( |
|
430 |
this._claimService.deleteBulk(ids,token).subscribe(
|
|
415 | 431 |
res => { |
416 | 432 |
console.info('Delete response'+res.code ); |
417 | 433 |
console.warn("Deleted ids:"+ res.deletedIds); |
... | ... | |
442 | 458 |
this.deleteMessage=this.deleteMessage+'<div class = "alert alert-warning " >'+res.notFoundIds.length+' claim(s) couldn\'t be deleted.</div>'; |
443 | 459 |
} |
444 | 460 |
}); |
461 |
} |
|
445 | 462 |
} |
446 | 463 |
pageChange($event) { |
447 | 464 |
var page:number = +$event.value |
Also available in: Unified diff
Adding login token parameter in claim API requests | check for user session expiration before every API call| redirect to login page if needed | keep the current state and current url if needed