Skip to content

Commit f11bbd9

Browse files
committed
feat(notifications): UX changes to match API endpoint changes.
1 parent 55e3e71 commit f11bbd9

File tree

15 files changed

+61
-27
lines changed

15 files changed

+61
-27
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { IPagination } from '../../../core';
22
import { Notification } from '../notification.entity';
3+
import { ApiModelProperty } from '@nestjs/swagger';
34

45
export class NotificationList implements IPagination<Notification> {
6+
@ApiModelProperty({ type: Notification, isArray: true })
57
readonly items: Notification[];
8+
@ApiModelProperty({ type: Number, readOnly: true })
69
readonly total: number;
710
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { IPagination } from '../../../core';
22
import { Subscription } from '../subscription.entity';
3+
import { ApiModelProperty } from '@nestjs/swagger';
34

45
export class SubscriptionList implements IPagination<Subscription> {
6+
@ApiModelProperty({ type: Subscription, isArray: true })
57
readonly items: Subscription[];
8+
@ApiModelProperty({ type: Number, readOnly: true })
69
readonly total: number;
710
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { IPagination } from '../../../core';
22
import { Cluster } from '../cluster.entity';
3+
import { ApiModelProperty } from '@nestjs/swagger';
34

45
export class ClusterList implements IPagination<Cluster> {
6+
@ApiModelProperty({ type: Cluster, isArray: true })
57
readonly items: Cluster[];
8+
@ApiModelProperty({ type: Number, readOnly: true })
69
readonly total: number;
710
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { IPagination } from '../../core';
22
import { Project } from '../project.entity';
3+
import { ApiModelProperty } from '@nestjs/swagger';
34

45
export class ProjectList implements IPagination<Project> {
6+
@ApiModelProperty({ type: Project, isArray: true })
57
readonly items: Project[];
8+
@ApiModelProperty({ type: Number, readOnly: true })
69
readonly total: number;
710
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { IPagination } from '../../../core'
22
import { Profile } from '../profile.entity';
3+
import { ApiModelProperty } from '@nestjs/swagger';
34

45
export class ProfileList implements IPagination<Profile> {
6+
@ApiModelProperty({ type: Profile, isArray: true })
57
readonly items: Profile[];
8+
@ApiModelProperty({ type: Number, readOnly: true })
69
readonly total: number;
710
}

apps/webapp/src/assets/data/notifications.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[
2-
[
1+
{
2+
"items": [
33
{
44
"id": 9,
55
"title": "title for sumo3 2",
@@ -127,5 +127,5 @@
127127
"updatedAt": "2018-12-09T06:00:41.401Z"
128128
}
129129
],
130-
9
131-
]
130+
"total": 9
131+
}

apps/webapp/src/assets/data/notifications.user.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[
2-
[
1+
{
2+
"items": [
33
{
44
"id": 9,
55
"title": "title for sumo3 2",
@@ -71,5 +71,5 @@
7171
"updatedAt": "2018-12-09T06:00:41.401Z"
7272
}
7373
],
74-
5
75-
]
74+
"total": 9
75+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[
2-
[
1+
{
2+
"items": [
33
{
44
"id": 13,
55
"endpoint": "https://fcm.googleapis.com/fcm/send/c8eq7G-b2mc:APA91bFp2Gof...",
@@ -11,5 +11,5 @@
1111
"updatedAt": "2018-11-21T18:50:45.325Z"
1212
}
1313
],
14-
1
15-
]
14+
"total": 1
15+
}

libs/admin/src/lib/services/notification.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Injectable } from '@angular/core';
2-
import { HttpClient } from '@angular/common/http';
2+
import { HttpClient, HttpParams } from '@angular/common/http';
33
import { Observable } from 'rxjs';
44
import { catchError, finalize, map, retry } from 'rxjs/operators';
5-
import { EntityService } from '@ngx-starter-kit/shared';
5+
import { EntityService, IPagination } from '@ngx-starter-kit/shared';
66
import { environment } from '@env/environment';
77
import { AppNotification } from '@ngx-starter-kit/notifications';
88

@@ -19,13 +19,14 @@ export class NotificationService extends EntityService<AppNotification> {
1919
}
2020

2121
getAll(): Observable<AppNotification[]> {
22+
const params = new HttpParams().set('order', 'ASC').set('read', 'false');
2223
this.loadingSubject.next(true);
23-
return this.httpClient.get<[AppNotification[], number]>(`${this.baseUrl}/${this.entityPath}`).pipe(
24+
return this.httpClient.get<IPagination<AppNotification>>(`${this.baseUrl}/${this.entityPath}`, { params }).pipe(
2425
retry(3), // retry a failed request up to 3 times
2526
catchError(this.handleError),
2627
finalize(() => this.loadingSubject.next(false)),
2728
// return without count
28-
map(data => data[0]),
29+
map(data => data.items),
2930
);
3031
}
3132

libs/admin/src/lib/services/subscription.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Observable } from 'rxjs';
44
import { catchError, finalize, map, retry } from 'rxjs/operators';
5-
import { EntityService } from '@ngx-starter-kit/shared';
5+
import { EntityService, IPagination } from '@ngx-starter-kit/shared';
66
import { environment } from '@env/environment';
77
import { Subscription } from '../models/subscription.model';
88

@@ -20,12 +20,12 @@ export class SubscriptionService extends EntityService<Subscription> {
2020

2121
getAll(): Observable<Subscription[]> {
2222
this.loadingSubject.next(true);
23-
return this.httpClient.get<[Subscription[], number]>(`${this.baseUrl}/${this.entityPath}`).pipe(
23+
return this.httpClient.get<IPagination<Subscription>>(`${this.baseUrl}/${this.entityPath}`).pipe(
2424
retry(3), // retry a failed request up to 3 times
2525
catchError(this.handleError),
2626
finalize(() => this.loadingSubject.next(false)),
2727
// return without count
28-
map(data => data[0]),
28+
map(data => data.items),
2929
);
3030
}
3131
}

0 commit comments

Comments
 (0)