Skip to content

Commit

Permalink
feat(pmp): replace generic table with more specific one
Browse files Browse the repository at this point in the history
  • Loading branch information
Sikora00 authored and wjanaszek committed Jan 27, 2020
1 parent 31147fd commit 1a75eb7
Show file tree
Hide file tree
Showing 58 changed files with 284 additions and 338 deletions.
77 changes: 40 additions & 37 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,42 +608,11 @@
}
}
},
"pmp-web-shared-ui-table": {
"projectType": "library",
"root": "libs/pmp-web/shared/ui-table",
"sourceRoot": "libs/pmp-web/shared/ui-table/src",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"libs/pmp-web/shared/ui-table/tsconfig.lib.json",
"libs/pmp-web/shared/ui-table/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**", "!libs/pmp-web/shared/ui-table/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/pmp-web/shared/ui-table/jest.config.js",
"tsConfig": "libs/pmp-web/shared/ui-table/tsconfig.spec.json",
"setupFile": "libs/pmp-web/shared/ui-table/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/angular:component": {
"styleext": "scss"
}
}
},
"pmp-web-user-users-statistics-feature": {
"projectType": "library",
"root": "libs/pmp-web/user/users-statistics/feature",
"sourceRoot": "libs/pmp-web/user/users-statistics/feature/src",
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -703,7 +672,7 @@
"projectType": "library",
"root": "libs/pmp-web/user/data-access",
"sourceRoot": "libs/pmp-web/user/data-access/src",
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -734,7 +703,7 @@
"projectType": "library",
"root": "libs/pmp-web/user/domain",
"sourceRoot": "libs/pmp-web/user/domain/src",
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -765,7 +734,7 @@
"projectType": "library",
"root": "libs/pmp-web/repository/data-access-repository-statistics",
"sourceRoot": "libs/pmp-web/repository/data-access-repository-statistics/src",
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -825,7 +794,7 @@
"projectType": "library",
"root": "libs/pmp-web/user/single-user-statistics/data-access",
"sourceRoot": "libs/pmp-web/user/single-user-statistics/data-access/src",
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -859,7 +828,7 @@
"projectType": "library",
"root": "libs/pmp-web/repository/repositories-statistics/feature",
"sourceRoot": "libs/pmp-web/repository/repositories-statistics/feature/src",
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -888,6 +857,40 @@
"styleext": "scss"
}
}
},
"pmp-web-shared-ui-statistics-overview-table": {
"projectType": "library",
"root": "libs/pmp-web/shared/ui-statistics-overview-table",
"sourceRoot": "libs/pmp-web/shared/ui-statistics-overview-table/src",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"libs/pmp-web/shared/ui-statistics-overview-table/tsconfig.lib.json",
"libs/pmp-web/shared/ui-statistics-overview-table/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**",
"!libs/pmp-web/shared/ui-statistics-overview-table/**"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/pmp-web/shared/ui-statistics-overview-table/jest.config.js",
"tsConfig": "libs/pmp-web/shared/ui-statistics-overview-table/tsconfig.spec.json",
"setupFile": "libs/pmp-web/shared/ui-statistics-overview-table/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/angular:component": {
"styleext": "scss"
}
}
}
},
"cli": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor
} from '@nestjs/common';
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { Response } from 'express';
import { Response as VAResponse } from '@pimp-my-pr/pmp-api/shared/domain';

@Injectable()
export class ResponseTransformInterceptor<T>
implements NestInterceptor<T, Response<T>> {
intercept(
context: ExecutionContext,
next: CallHandler
): Observable<Response<T>> {
return next
.handle()
.pipe(map(data => VAResponse.createSuccessFullResponse(data)));
export class ResponseTransformInterceptor<T> implements NestInterceptor<T, Response<T>> {
intercept(context: ExecutionContext, next: CallHandler): Observable<Response<T>> {
return next.handle().pipe(map(data => VAResponse.createSuccessFullResponse(data)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { PrDataService } from '@pimp-my-pr/pmp-api/api-service/repository/data-a
import { GetPrChangesQuery } from '../get-pr-changes.query';

@QueryHandler(GetPrChangesQuery)
export class GetPrChangesHandler
implements IQueryHandler<GetPrChangesQuery, PrChanges> {
export class GetPrChangesHandler implements IQueryHandler<GetPrChangesQuery, PrChanges> {
constructor(private prRepository: PrDataService) {}

async execute(query: GetPrChangesQuery): Promise<PrChanges> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { RepositoryDataService } from '@pimp-my-pr/pmp-api/api-service/repositor
import { GetRepositoryPrsQuery } from '../get-repository-prs.query';

@QueryHandler(GetRepositoryPrsQuery)
export class GetRepositoryPrsHandler
implements IQueryHandler<GetRepositoryPrsQuery, PrModel[]> {
export class GetRepositoryPrsHandler implements IQueryHandler<GetRepositoryPrsQuery, PrModel[]> {
constructor(private repositoryRepository: RepositoryDataService) {}

async execute(query: GetRepositoryPrsQuery): Promise<PrModel[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import { Injectable } from '@nestjs/common';
import { QueryBus } from '@nestjs/cqrs';
import {
PrChanges,
PrDetailsModel,
PrModel,
PrStatisticsReadModel,
PrWithChangesReadModel,
RepositoryModel,
RepositoryPrsStatisticsReadModel
RepositoryModel
} from '@pimp-my-pr/pmp-api/api-service/repository/domain';
import { GetPrChangesQuery } from '../queries/get-pr-changes.query';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export class GithubAuthInterceptor {

intercept(req: AxiosRequestConfig): AxiosRequestConfig {
req.headers = {
Authorization:
'token ' + this.pmpApiServiceConfigService.getGithubToken(),
Authorization: 'token ' + this.pmpApiServiceConfigService.getGithubToken(),
...req.headers
};
return req;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { BaseRepositoryStatisticsReadModel } from './base-repository-statistics.

export class RepositoryStatisticsReadModel extends BaseRepositoryStatisticsReadModel {
owner: string;
pictureUrl: string;

constructor(repository: RepositoryModel, prs: PrWithChangesReadModel[]) {
super(repository, prs);
this.owner = repository.owner;
this.pictureUrl = repository.pictureUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { PrWithChangesReadModel } from './pr-with-changes.read-model';
import { UserModel } from '../models/user.model';

export class RepositoryUserStatisticsReadModel extends BaseRepositoryStatisticsReadModel {
avatarUrl: string;

constructor(userModel: UserModel, prsModel: PrWithChangesReadModel[]) {
super(userModel, prsModel);
this.avatarUrl = userModel.avatarUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ export class PmpApiServiceConfigService {
}

getRepositoryOwner(): string {
return this.configService.get<string>(
CONFIG_NAMESPACE + '.repositoryOwner'
);
return this.configService.get<string>(CONFIG_NAMESPACE + '.repositoryOwner');
}

getRepositoryTitle(): string {
return this.configService.get<string>(
CONFIG_NAMESPACE + '.repositoryTitle'
);
return this.configService.get<string>(CONFIG_NAMESPACE + '.repositoryTitle');
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Module } from '@nestjs/common';
import {
pmpApiServiceConfig,
PmpApiServiceConfigService
} from './configs/pmp-api-service.config';
import { pmpApiServiceConfig, PmpApiServiceConfigService } from './configs/pmp-api-service.config';
import { ConfigModule } from '@nestjs/config';

@Module({
Expand Down
4 changes: 1 addition & 3 deletions libs/pmp-api/shared/domain/src/lib/base/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ export class Response<T, E> implements IResponse<T, E> {
return res;
}

public static createErrorResponse<E>(
error: HttpException
): Response<null, E> {
public static createErrorResponse<E>(error: HttpException): Response<null, E> {
const res = new Response<null, E>();
res.data = null;
res.error = error.message.message || error.message.error || null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"extends": "../../../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "pimpMyPr", "camelCase"],
"component-selector": [true, "element", "pimp-my-pr", "kebab-case"]
"component-selector": [true, "element", "pmp", "kebab-case"]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<pmp-table
<pmp-statistics-overview-table
(navigateToItem)="onNavigateToRepository($event)"
[tableConfig]="tableConfig"
></pmp-table>
[data]="repositoryStatisticsCollection$ | async"
></pmp-statistics-overview-table>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
align-items: center;
}

pmp-table {
pmp-statistics-overview-table {
width: 80%;
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
OnDestroy,
OnInit
} from '@angular/core';
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { RepositoryStatisticsFacade } from '@pimp-my-pr/pmp-web/repository/data-access-repository-statistics';
import { RepositoryStatistics } from '@pimp-my-pr/shared/domain';
import { TableConfig } from '@pimp-my-pr/pmp-web/shared/domain';
import { untilDestroyed } from 'ngx-take-until-destroy';
import { RepositoriesStatisticsPresenter } from './repositories-statistics.presenter';
import { Observable } from 'rxjs';

@Component({
selector: 'pimp-my-pr-repositories-statistics',
selector: 'pmp-repositories-statistics',
templateUrl: './repositories-statistics.component.html',
styleUrls: ['./repositories-statistics.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [RepositoriesStatisticsPresenter]
})
export class RepositoriesStatisticsComponent implements OnInit, OnDestroy {
tableConfig: TableConfig<RepositoryStatistics[]>;
repositoryStatisticsCollection$: Observable<RepositoryStatistics[]> = this
.repositoryStatisticsFacade.repositoryStatisticsCollection$;

constructor(
private cdr: ChangeDetectorRef,
private repositoryStatisticsFacade: RepositoryStatisticsFacade,
private repositoriesStatisticsPresenter: RepositoriesStatisticsPresenter
) {}

ngOnDestroy(): void {}

ngOnInit(): void {
this.repositoryStatisticsFacade.repositoryStatisticsCollection$
.pipe(untilDestroyed(this))
.subscribe(repositoryStatistics => {
this.tableConfig = this.repositoriesStatisticsPresenter.initTableConfig(
repositoryStatistics
);
this.cdr.markForCheck();
});
this.repositoryStatisticsFacade.getRepositoryStatisticsCollection();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,6 @@ import { Router } from '@angular/router';
export class RepositoriesStatisticsPresenter {
constructor(private router: Router) {}

initTableConfig(data: RepositoryStatistics[]): TableConfig<RepositoryStatistics[]> {
return {
columns: [
{ name: 'repository', property: 'name', label: 'Repository' },
{
name: 'pendingPrs',
property: 'pendingPrs',
label: 'Pending PR',
isOrderColumn: true
},
{
name: 'sumOfHoursPrsWaiting',
property: 'sumOfHoursPrsWaiting',
label: 'Sum of time PR waiting'
},
{
name: 'linesOfCodeToCheck',
property: 'linesOfCodeToCheck',
label: 'To check [lines of code]'
},
{
name: 'longestPrLinesOfCode',
property: 'longestPrLinesOfCode',
label: 'Longest PR [lines of code]'
}
],
data: data
};
}

navigateToRepository(repositoryId: number): void {
this.router.navigate(['repositories', repositoryId]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RepositoriesStatisticsComponent } from './containers/repositories-statistics/repositories-statistics.component';
import { PmpWebRepositoryRepositoriesStatisticsRoutingModule } from './pmp-web-repository-repositories-statistics-routing.module';
import { PmpWebSharedUiTableModule } from '@pimp-my-pr/pmp-web/shared/ui-table';
import { PmpWebRepositoryStatisticsDataAccessModule } from '@pimp-my-pr/pmp-web/repository/data-access-repository-statistics';
import { PmpWebSharedUiStatisticsOverviewTableModule } from '@pimp-my-pr/pmp-web/shared/ui-statistics-overview-table';

@NgModule({
imports: [
CommonModule,
PmpWebRepositoryStatisticsDataAccessModule,
PmpWebRepositoryRepositoriesStatisticsRoutingModule,
PmpWebSharedUiTableModule
PmpWebSharedUiStatisticsOverviewTableModule
],
declarations: [RepositoriesStatisticsComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"extends": "../../../../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "pimpMyPr", "camelCase"],
"component-selector": [true, "element", "pimp-my-pr", "kebab-case"]
"component-selector": [true, "element", "pmp", "kebab-case"]
}
}
Loading

0 comments on commit 1a75eb7

Please sign in to comment.