-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pmp-web): implement fetching data from api for single repository
Fix invalid property name at shared because API returns prsStatistics instead stat property.
- Loading branch information
1 parent
8e86766
commit 8ddf192
Showing
8 changed files
with
36 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ository/repository-statistics/data-access/src/lib/+state/repository-statistics.reducer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 14 additions & 31 deletions
45
.../repository-statistics/data-access/src/lib/services/repository-statistics-data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,26 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, of } from 'rxjs'; | ||
import { Observable } from 'rxjs'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { GetRepositoryStatisticsPayload } from '@pimp-my-pr/pmp-web/repository/domain'; | ||
import { RepositoryModel } from '@pimp-my-pr/shared/domain'; | ||
|
||
const mockedData: RepositoryModel = { | ||
// TODO mocked data for repository | ||
owner: 'valueadd', | ||
fullName: 'pimp-my-pr', | ||
name: 'pmp', | ||
pictureUrl: 'https://picsum.photos/id/1025/200/300', | ||
prsStatistics: [ | ||
{ | ||
author: { | ||
name: 'MockUser', | ||
avatarUrl: 'https://picsum.photos/id/237/200/300', | ||
id: 1231 | ||
}, | ||
commentsCount: 123, | ||
createdAt: '12/12/12', | ||
linesOfCodeToCheck: 3245, | ||
reviewCommentsCount: 234, | ||
id: 2345, | ||
timeWaiting: '124', | ||
title: '12414', | ||
url: 'https://picsum.photos/id/1050/200/300' | ||
} | ||
] | ||
}; | ||
import { IResponse, RepositoryStatistics } from '@pimp-my-pr/shared/domain'; | ||
import { urlFactory } from '@valueadd/typed-urls'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class RepositoryStatisticsDataService { | ||
readonly endpoints = { | ||
// TODO missing API url to get details about repository | ||
getRepositoryStatistics: '' | ||
getRepositoryStatistics: urlFactory<'repositoryId'>('/api/repository/:repositoryId', true) | ||
}; | ||
|
||
constructor(private http: HttpClient) {} | ||
|
||
getRepositoryStatistics(payload: GetRepositoryStatisticsPayload): Observable<RepositoryModel> { | ||
return of(mockedData); | ||
getRepositoryStatistics( | ||
payload: GetRepositoryStatisticsPayload | ||
): Observable<RepositoryStatistics> { | ||
return this.http | ||
.get<IResponse<RepositoryStatistics, null>>( | ||
this.endpoints.getRepositoryStatistics.url({ repositoryId: payload.id }) | ||
) | ||
.pipe(map((res: IResponse<RepositoryStatistics, null>) => res.data)); | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
...ory-statistics/feature/src/lib/repository-statistics/repository-statistics.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
<div class="repository-statistics__container"> | ||
<pmp-header-container | ||
*ngIf="repository$ | async" | ||
[avatarLabel]="(repository$ | async).name" | ||
[avatarUrl]="(repository$ | async).pictureUrl" | ||
label="Pull requests pending" | ||
></pmp-header-container> | ||
<!-- TODO missing property from API model --> | ||
<!-- TODO change 'comments' to 'reviewers' when property is ready --> | ||
<pmp-table-pr-statistic | ||
*ngIf="(repository$ | async)?.prsStatistics" | ||
[tableData]="(repository$ | async).prsStatistics" | ||
columnPropertyName="comments" | ||
(navigateItem)="onNavigateItem($event)" | ||
columnPropertyName="reviewers" | ||
></pmp-table-pr-statistic> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
} | ||
} | ||
|
||
.custom-column { | ||
.comments-column { | ||
color: rgba(0, 0, 0, 0.6); | ||
flex: unset; | ||
width: 96px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters