aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/todo-list-page
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline/ClientApp/src/app/todo-list-page')
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list-color-block.css7
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css39
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.html21
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts76
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts36
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list.service.spec.ts55
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts48
7 files changed, 0 insertions, 282 deletions
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-color-block.css b/Timeline/ClientApp/src/app/todo-list-page/todo-list-color-block.css
deleted file mode 100644
index 5e0d4ba9..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-color-block.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.color-block-open {
- background: red;
-}
-
-.color-block-closed {
- background: green;
-}
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css
deleted file mode 100644
index 754b786e..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css
+++ /dev/null
@@ -1,39 +0,0 @@
-.align-self-bottom {
- align-self: flex-end;
-}
-
-.item-box {
- display: flex;
- width: 100%;
- box-sizing: border-box;
-}
-
-.first-item-box {
- justify-content: space-between;
- padding: 0 0 5px 5px;
-}
-
-.non-first-item-box {
- padding: 5px;
-}
-
-.space {
- flex: 1 4 20px;
-}
-
-.sample-box {
- box-sizing: border-box;
- align-self: flex-start;
-}
-
-.sample-item {
- display: flex;
- align-items: center;
-}
-
-.sample-color-block {
- border-radius: 0.2em;
- width: 1em;
- height: 1em;
- margin-right: 2px;
-}
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.html b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.html
deleted file mode 100644
index 50180fe8..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<mat-progress-bar *ngIf="!isLoadCompleted" mode="indeterminate"></mat-progress-bar>
-
-<mat-list>
- <mat-list-item *ngFor="let item of items; let i = index" style="height:unset;">
- <div class="item-box" [class.first-item-box]="i === 0" [class.non-first-item-box]="i !== 0">
- <app-todo-item @itemEnter [class.align-self-bottom]="i === 0" [item]="item"></app-todo-item>
- <div class="space"></div>
- <div class="sample-box" *ngIf="i === 0">
- <div class="mat-caption sample-item">
- <span class="sample-color-block color-block-open"></span>
- <span> means working now.</span>
- </div>
- <div class="mat-caption sample-item">
- <span class="sample-color-block color-block-closed"></span>
- <span> means completed.</span>
- </div>
- <div class="mat-caption">click on item to see details.</div>
- </div>
- </div>
- </mat-list-item>
-</mat-list>
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts
deleted file mode 100644
index 5706bf51..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
-import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
-
-import { Observable, from } from 'rxjs';
-
-import { TodoListPageComponent } from './todo-list-page.component';
-import { TodoListService, TodoItem } from './todo-list.service';
-import { By } from '@angular/platform-browser';
-import { delay } from 'rxjs/operators';
-import { NoopAnimationsModule } from '@angular/platform-browser/animations';
-
-@Component({
- /* tslint:disable-next-line:component-selector*/
- selector: 'mat-progress-bar',
- template: ''
-})
-class MatProgressBarStubComponent {}
-
-function asyncArray<T>(data: T[]): Observable<T> {
- return from(data).pipe(delay(0));
-}
-
-describe('TodoListPageComponent', () => {
- let component: TodoListPageComponent;
- let fixture: ComponentFixture<TodoListPageComponent>;
-
- const mockTodoItems: TodoItem[] = [
- {
- number: 0,
- title: 'Test title 1',
- isClosed: true,
- detailUrl: 'test_url1'
- },
- {
- number: 1,
- title: 'Test title 2',
- isClosed: false,
- detailUrl: 'test_url2'
- }
- ];
-
- beforeEach(async(() => {
- const todoListService: jasmine.SpyObj<TodoListService> = jasmine.createSpyObj('TodoListService', ['getWorkItemList']);
-
- todoListService.getWorkItemList.and.returnValue(asyncArray(mockTodoItems));
-
- TestBed.configureTestingModule({
- declarations: [TodoListPageComponent, MatProgressBarStubComponent],
- imports: [NoopAnimationsModule],
- providers: [{ provide: TodoListService, useValue: todoListService }],
- schemas: [NO_ERRORS_SCHEMA]
- }).compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(TodoListPageComponent);
- component = fixture.componentInstance;
- });
-
- it('should create', () => {
- fixture.detectChanges();
- expect(component).toBeTruthy();
- });
-
- it('should show progress bar during loading', () => {
- fixture.detectChanges();
- expect(fixture.debugElement.query(By.css('mat-progress-bar'))).toBeTruthy();
- });
-
- it('should hide progress bar after loading', fakeAsync(() => {
- fixture.detectChanges();
- tick();
- fixture.detectChanges();
- expect(fixture.debugElement.query(By.css('mat-progress-bar'))).toBeFalsy();
- }));
-});
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts
deleted file mode 100644
index c62dd808..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-import { TodoListService, TodoItem } from './todo-list.service';
-import { trigger, transition, style, animate } from '@angular/animations';
-
-@Component({
- selector: 'app-todo-list-page',
- templateUrl: './todo-list-page.component.html',
- styleUrls: ['./todo-list-page.component.css', './todo-list-color-block.css'],
- animations: [
- trigger('itemEnter', [
- transition(':enter', [
- style({
- transform: 'translateX(-100%) translateX(-20px)'
- }),
- animate('400ms ease-out', style({
- transform: 'none'
- }))
- ])
- ])
- ]
-})
-export class TodoListPageComponent implements OnInit {
-
- items: TodoItem[] = [];
- isLoadCompleted = false;
-
- constructor(private todoService: TodoListService) {
- }
-
- ngOnInit() {
- this.todoService.getWorkItemList().subscribe({
- next: result => this.items.push(result),
- complete: () => { this.isLoadCompleted = true; }
- });
- }
-}
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.spec.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.spec.ts
deleted file mode 100644
index a2ad0cbd..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.spec.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
-
-import {
- TodoListService, IssueResponse, IssueResponseItem, TodoItem
-} from './todo-list.service';
-import { toArray } from 'rxjs/operators';
-
-
-describe('TodoListServiceService', () => {
- beforeEach(() => TestBed.configureTestingModule({
- imports: [HttpClientTestingModule]
- }));
-
- it('should be created', () => {
- const service: TodoListService = TestBed.get(TodoListService);
- expect(service).toBeTruthy();
- });
-
- it('should work well', () => {
- const service: TodoListService = TestBed.get(TodoListService);
-
- const baseUrl = service.baseUrl;
-
- const mockIssueList: IssueResponse = [{
- number: 1,
- title: 'Issue title 1',
- state: 'open',
- html_url: 'test_url1'
- }, {
- number: 2,
- title: 'Issue title 2',
- state: 'closed',
- html_url: 'test_url2',
- pull_request: {}
- }];
-
- const mockTodoItemList: TodoItem[] = [{
- number: 1,
- title: 'Issue title 1',
- isClosed: false,
- detailUrl: 'test_url1'
- }];
-
- service.getWorkItemList().pipe(toArray()).subscribe(data => {
- expect(data).toEqual(mockTodoItemList);
- });
-
- const httpController: HttpTestingController = TestBed.get(HttpTestingController);
-
- httpController.expectOne(request => request.url === baseUrl + '/issues' && request.params.get('state') === 'all').flush(mockIssueList);
-
- httpController.verify();
- });
-});
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts
deleted file mode 100644
index ffcbbc6f..00000000
--- a/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
-import { Observable, from } from 'rxjs';
-import { switchMap, map, filter } from 'rxjs/operators';
-
-export interface IssueResponseItem {
- number: number;
- title: string;
- state: string;
- html_url: string;
- pull_request?: any;
-}
-
-export type IssueResponse = IssueResponseItem[];
-
-export interface TodoItem {
- number: number;
- title: string;
- isClosed: boolean;
- detailUrl: string;
-}
-
-@Injectable({
- providedIn: 'root'
-})
-export class TodoListService {
-
- readonly baseUrl = 'https://api.github.com/repos/crupest/Timeline';
-
- constructor(private client: HttpClient) { }
-
- getWorkItemList(): Observable<TodoItem> {
- return this.client.get<IssueResponse>(`${this.baseUrl}/issues`, {
- params: {
- state: 'all'
- }
- }).pipe(
- switchMap(result => from(result)),
- filter(result => result.pull_request === undefined), // filter out pull requests.
- map(result => <TodoItem>{
- number: result.number,
- title: result.title,
- isClosed: result.state === 'closed',
- detailUrl: result.html_url
- })
- );
- }
-}