Skip to content

Commit 75e199a

Browse files
committed
Update Readme and Manifest
1 parent 3fcad1e commit 75e199a

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Cloud Apps Tutorials
22

33
This repository contains supporting code for the [Ex Libris Cloud Apps](https://developers.exlibrisgroup.com/cloudapps/) [tutorials](https://developers.exlibrisgroup.com/cloudapps/tutorials/).
4+
5+
## Contributions
6+
7+
Found a bug? See something we can do better? We are happy to take contributions. You can open an issue in Github, or even better, open a pull request.

cloudapp/src/app/parallel/parallel.component.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="loading-shade" *ngIf="loading">
22
<mat-progress-spinner
3-
mode="indeterminate"
3+
[mode]="showProgress ? 'determinate' : 'indeterminate'"
44
diameter="50"
5+
[value]="percentComplete"
56
>
67
</mat-progress-spinner>
78
</div>
@@ -14,11 +15,15 @@
1415
<mat-option [value]="30">30</mat-option>
1516
<mat-option [value]="40">40</mat-option>
1617
<mat-option [value]="50">50</mat-option>
18+
<mat-option [value]="100">100</mat-option>
1719
</mat-select>
1820
</mat-form-field>
19-
<p>
21+
<mat-checkbox [(ngModel)]="showProgress" labelPosition="before">Show progress</mat-checkbox>
22+
<div class="commands-container">
2023
<button mat-stroked-button type="button" color="primary" (click)="run()">Retrieve users</button>
21-
</p>
24+
<button mat-flat-button type="button" (click)="clear()">Clear</button>
25+
</div>
26+
2227
<ul>
2328
<li *ngFor="let user of users">
2429
<strong>{{ user.full_name }}</strong>: ${{ user.fees.value }}

cloudapp/src/app/parallel/parallel.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
display: flex;
1010
align-items: center;
1111
justify-content: center;
12+
}
13+
14+
mat-checkbox {
15+
display: block;
16+
margin-bottom: 20px;
1217
}

cloudapp/src/app/parallel/parallel.component.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { CloudAppRestService, RestErrorResponse } from '@exlibris/exl-cloudapp-angular-lib';
3-
import { mergeMap, map, catchError, switchMap } from 'rxjs/operators';
4-
import { from, of, forkJoin, Observable } from 'rxjs';
3+
import { map, catchError, switchMap, tap } from 'rxjs/operators';
4+
import { of, forkJoin, Observable } from 'rxjs';
55
import { AppService } from '../app.service';
66

77
@Component({
@@ -13,6 +13,8 @@ export class ParallelComponent implements OnInit {
1313
users: any[];
1414
num = 10;
1515
loading = false;
16+
processed = 0;
17+
showProgress = false;
1618

1719
constructor(
1820
private restService: CloudAppRestService,
@@ -30,14 +32,10 @@ export class ParallelComponent implements OnInit {
3032

3133
loadUsers() {
3234
this.loading = true;
35+
this.processed = 0;
3336
this.restService.call(`/users?limit=${this.num}`)
3437
.pipe(
35-
map(users=>
36-
this.addErrors(users.user)
37-
.map(user=>withErrorChecking(
38-
this.restService.call(`/users/${user.primary_id}?expand=fees`)
39-
))
40-
),
38+
map(users=>this.addErrors(users.user).map(user=>this.getUser(user))),
4139
switchMap(reqs=>forkJoin(reqs)),
4240
)
4341
.subscribe({
@@ -54,15 +52,28 @@ export class ParallelComponent implements OnInit {
5452
});
5553
}
5654

55+
clear() {
56+
this.users = [];
57+
}
58+
59+
getUser(user: any) {
60+
return this.restService.call(`/users/${user.primary_id}?expand=fees`).pipe(
61+
tap(()=>this.processed++),
62+
catchError(e => of(e)),
63+
)
64+
}
65+
5766
addErrors(users: any[]) {
5867
for (let i=0; i<Math.floor(users.length*.25); i++) {
5968
users.splice(getRandomInt(users.length-1), 0, { primary_id: getRandomInt(1000000) });
6069
};
6170
return users;
6271
}
72+
73+
get percentComplete() {
74+
return Math.round((this.processed/this.num)*100)
75+
}
6376
}
6477

6578
const getRandomInt = (max: number) => Math.floor(Math.random() * Math.floor(max));
66-
const isRestErrorResponse = (object: any): object is RestErrorResponse => 'error' in object;
67-
const withErrorChecking = (obs: Observable<any>): Observable<any> =>
68-
obs.pipe(catchError( e => of(e)));
79+
const isRestErrorResponse = (object: any): object is RestErrorResponse => 'error' in object;

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
"fullscreen": {
2727
"allow": true,
2828
"open": false
29-
}
29+
},
30+
"license": "https://github.com/ExLibrisGroup/cloudapp-tutorials/raw/tutorials/LICENSE"
3031
}

0 commit comments

Comments
 (0)