Skip to content

Commit

Permalink
feat(pmp-web): single user statistics component init with mocked data
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianzaorski authored and MaciejSikorski committed Jan 17, 2020
1 parent 507b59b commit 12023d1
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 2 deletions.
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@
"sourceRoot": "libs/pmp-web/user/single-user-statistics/feature/src",
"projectType": "library",
"schematics": {},
"prefix": "pimp-my-pr",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div class="user-component__container">
<pmp-navbar class="navbar"></pmp-navbar>
<pmp-sidebar class="sidebar"></pmp-sidebar>
<router-outlet></router-outlet>
<div class="router-outlet__wrapper">
<router-outlet></router-outlet>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@
overflow-x: hidden;
box-shadow: 0 1px 2px rgb(0, 0, 0, 0.2);
}

.router-outlet__wrapper {
position: absolute;
left: 60px;
top: 64px;
right: 0;
}
7 changes: 7 additions & 0 deletions libs/pmp-web/user/shell/src/lib/shell-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ const routes: Routes = [
import('@pimp-my-pr/pmp-web/user/users-statistics/feature').then(
m => m.PmpWebUserUsersStatisticsFeatureModule
)
},
{
path: 'statistics',
loadChildren: () =>
import('@pimp-my-pr/pmp-web/user/single-user-statistics/feature').then(
m => m.PmpWebUserSingleUserStatisticsFeatureModule
)
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './lib/pmp-web-user-single-user-statistics-feature';
export * from './lib/pmp-web-user-single-user-statistics-feature.module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="user-statistics">
<div *ngFor="let repo of mockedData">
{{ repo.repository.name }}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:host {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SingleUserStatisticsComponent } from './single-user-statistics.component';

describe('SingleUserStatisticsComponent', () => {
let component: SingleUserStatisticsComponent;
let fixture: ComponentFixture<SingleUserStatisticsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [SingleUserStatisticsComponent]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SingleUserStatisticsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { first } from 'rxjs/operators';

const mockedData = [
{
repository: { name: 'java', picture: '' },
data: [
{
title: 'crud users',
id: '#1',
waitingTime: '35 hours',
codeLines: 540,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
},
{
title: 'crud comments',
id: '#3',
waitingTime: '28 hours',
codeLines: 20,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
},
{
title: 'unit tests for users',
id: '#4',
waitingTime: '4 hours',
codeLines: 145,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
},
{
title: 'unit tests for comments',
id: '#5',
waitingTime: '34 minutes',
codeLines: 4,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
}
]
},
{
repository: { name: 'php', picture: '' },
data: [
{
title: 'crud users',
id: '#1',
waitingTime: '35 hours',
codeLines: 540,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
},
{
title: 'crud comments',
id: '#3',
waitingTime: '28 hours',
codeLines: 20,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
},
{
title: 'unit tests for users',
id: '#4',
waitingTime: '4 hours',
codeLines: 145,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
},
{
title: 'unit tests for comments',
id: '#5',
waitingTime: '34 minutes',
codeLines: 4,
author: { name: 'Filip Chajzer', picture: '' },
comments: []
}
]
}
];

@Component({
// tslint:disable-next-line:component-selector
selector: 'pimp-my-pr-single-user-statistics',
templateUrl: './single-user-statistics.component.html',
styleUrls: ['./single-user-statistics.component.scss']
})
export class SingleUserStatisticsComponent implements OnInit {
mockedData = mockedData;
user: string | null;

constructor(private route: ActivatedRoute) {}

ngOnInit(): void {
this.readRouteUserId();
}

private readRouteUserId(): void {
this.route.params.pipe(first()).subscribe(params => (this.user = params.id));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PmpWebUserSingleUserStatisticsRoutingModule } from './pmp-web-user-single-user-statistics-routing.module';
import { SingleUserStatisticsComponent } from './containers/single-user-statistics/single-user-statistics.component';

@NgModule({
imports: [CommonModule, PmpWebUserSingleUserStatisticsRoutingModule],
declarations: [SingleUserStatisticsComponent]
})
export class PmpWebUserSingleUserStatisticsFeatureModule {}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { SingleUserStatisticsComponent } from './containers/single-user-statistics/single-user-statistics.component';

const routes: Routes = [
{
path: ':id',
component: SingleUserStatisticsComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class PmpWebUserSingleUserStatisticsRoutingModule {}

0 comments on commit 12023d1

Please sign in to comment.