clean up, satisfy tslint
This commit is contained in:
parent
60b8264f44
commit
3e42d44e83
@ -1,27 +1,28 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { ListComponent } from './list/list.component'
|
||||
import { ArticleComponent } from './article/article.component'
|
||||
import { ArticleComponent } from './article/article.component';
|
||||
import { ListComponent } from './list/list.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: '/list',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
{
|
||||
component: ListComponent,
|
||||
path: 'list',
|
||||
component: ListComponent
|
||||
},
|
||||
{
|
||||
component: ArticleComponent,
|
||||
path: 'article',
|
||||
component: ArticleComponent
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
exports: [RouterModule],
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
|
||||
export class AppRoutingModule { }
|
||||
|
@ -2,9 +2,9 @@ import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
styleUrls: ['./app.component.styl'],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.styl']
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'proovitoo';
|
||||
public title = 'Proovitöö';
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { ArticleComponent } from './article/article.component';
|
||||
import { ListComponent } from './list/list.component';
|
||||
import { CustomSortPipe } from './custom-sort.pipe';
|
||||
import { GenderPipe } from './gender.pipe';
|
||||
import { ListPaginateComponent } from './list-paginate/list-paginate.component';
|
||||
import { ListService } from './list.service';
|
||||
import { GenderPipe } from './gender.pipe';
|
||||
import { CustomSortPipe } from './custom-sort.pipe';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
import { ListComponent } from './list/list.component';
|
||||
|
||||
@NgModule({
|
||||
bootstrap: [AppComponent],
|
||||
declarations: [
|
||||
AppComponent,
|
||||
ArticleComponent,
|
||||
@ -29,6 +30,5 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
],
|
||||
providers: [
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs'
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ArticleService {
|
||||
private articleUrl = 'http://midaiganes.irw.ee/api/list/dad2ec5d';
|
||||
|
@ -6,15 +6,15 @@ import { IArticle } from '../article';
|
||||
|
||||
@Component({
|
||||
selector: 'app-article',
|
||||
styleUrls: ['./article.component.styl'],
|
||||
templateUrl: './article.component.html',
|
||||
styleUrls: ['./article.component.styl']
|
||||
})
|
||||
export class ArticleComponent implements OnInit {
|
||||
public article: IArticle;
|
||||
|
||||
constructor(private articleService: ArticleService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
public ngOnInit(): void {
|
||||
this.articleService.getArticle().subscribe((data) => this.article = data);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { Sort } from './sort'
|
||||
import { Sort } from './sort';
|
||||
|
||||
const sorter = new Sort();
|
||||
|
||||
@ -7,10 +7,10 @@ const sorter = new Sort();
|
||||
// I couldn't come up with a better way of doing it at the moment.
|
||||
|
||||
@Pipe({
|
||||
name: 'customSort'
|
||||
name: 'customSort',
|
||||
})
|
||||
export class CustomSortPipe implements PipeTransform {
|
||||
transform(value: Array<any>, field: string, direction: number): Array<any> {
|
||||
public transform(value: Array<any>, field: string, direction: number): Array<any> {
|
||||
if (direction === 0 || field == null) {
|
||||
return value;
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
// This is a simple pipe for formatting the gender
|
||||
|
||||
@Pipe({
|
||||
name: 'gender'
|
||||
name: 'gender',
|
||||
})
|
||||
export class GenderPipe implements PipeTransform {
|
||||
transform(value: string): string {
|
||||
public transform(value: string): string {
|
||||
return value === 'm' ? 'Mees' : 'Naine';
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
margin: 20px 0
|
||||
font-family: Booster
|
||||
font-weight: 900
|
||||
font-size: 16x
|
||||
font-size: 16px
|
||||
display: block
|
||||
|
||||
fa-icon, a
|
||||
|
@ -6,15 +6,15 @@ import { faChevronLeft } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-paginate',
|
||||
styleUrls: ['./list-paginate.component.styl'],
|
||||
templateUrl: './list-paginate.component.html',
|
||||
styleUrls: ['./list-paginate.component.styl']
|
||||
})
|
||||
export class ListPaginateComponent {
|
||||
@Input()
|
||||
page: number;
|
||||
public page: number;
|
||||
|
||||
@Input()
|
||||
pages: number;
|
||||
public pages: number;
|
||||
|
||||
public faChevronRight = faChevronRight;
|
||||
public faChevronLeft = faChevronLeft;
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs'
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// This is the service file for the API request
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ListService {
|
||||
private listUrl = 'http://midaiganes.irw.ee/api/list?limit=100';
|
||||
|
@ -31,8 +31,8 @@
|
||||
</ng-container>
|
||||
<ng-template #default_sort><fa-icon [icon]="faSort"></fa-icon></ng-template>
|
||||
</th>
|
||||
<th (click)="setSort('date')" class="clickable">Sünnikuupäev
|
||||
<ng-container *ngIf="sortBy === 'date';else default_sort">
|
||||
<th (click)="setSort('dob')" class="clickable">Sünnikuupäev
|
||||
<ng-container *ngIf="sortBy === 'dob';else default_sort">
|
||||
<ng-container [ngSwitch]="sortDir">
|
||||
<fa-icon *ngSwitchCase=-1 [icon]="faSortUp"></fa-icon>
|
||||
<fa-icon *ngSwitchCase=1 [icon]="faSortDown"></fa-icon>
|
||||
@ -57,7 +57,7 @@
|
||||
<td>{{ person.firstname }}</td>
|
||||
<td>{{ person.surname }}</td>
|
||||
<td>{{ person.sex | gender }}</td>
|
||||
<td>{{ person.date * 1000 | date:'yyyy.MM.dd'}}</td>
|
||||
<td>{{ person.dob }}</td>
|
||||
<td>{{ person.phone }}</td>
|
||||
</tr>
|
||||
<tr *ngIf="selected == person">
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Component, OnInit, SimpleChanges, Input } from '@angular/core';
|
||||
import { ListService } from '../list.service'
|
||||
import { Component, Input, OnInit, SimpleChanges } from '@angular/core';
|
||||
import { ListService } from '../list.service';
|
||||
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { IPerson } from '../person'
|
||||
import { IPerson, personalCodeStamper } from '../person';
|
||||
|
||||
import { faSort } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faSortUp } from '@fortawesome/free-solid-svg-icons';
|
||||
@ -13,8 +13,8 @@ import { faSortDown } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list',
|
||||
styleUrls: ['./list.component.styl'],
|
||||
templateUrl: './list.component.html',
|
||||
styleUrls: ['./list.component.styl']
|
||||
})
|
||||
export class ListComponent implements OnInit {
|
||||
public people: IPerson[];
|
||||
@ -33,7 +33,7 @@ export class ListComponent implements OnInit {
|
||||
|
||||
constructor(private route: ActivatedRoute, private listService: ListService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
public ngOnInit(): void {
|
||||
this.route.queryParams
|
||||
.subscribe((params) => {
|
||||
this.page = +(params.page || 1);
|
||||
@ -74,7 +74,11 @@ export class ListComponent implements OnInit {
|
||||
|
||||
private getList(): void {
|
||||
this.listService.getList().subscribe(
|
||||
(data) => this.people = data.list);
|
||||
(data) => {
|
||||
this.people = data.list;
|
||||
// Calculate date of birth from personal codes.
|
||||
this.people.forEach((p) => p.dob = personalCodeStamper(p.personal_code));
|
||||
});
|
||||
}
|
||||
|
||||
private selectPerson(person: IPerson): void {
|
||||
|
@ -3,8 +3,18 @@ export interface IPerson {
|
||||
firstname: string;
|
||||
surname: string;
|
||||
sex: string;
|
||||
date: Date;
|
||||
personal_code: number;
|
||||
dob: string;
|
||||
phone: string;
|
||||
image: string[];
|
||||
intro: string;
|
||||
}
|
||||
|
||||
export function personalCodeStamper(personalCode: number): string {
|
||||
const code = personalCode.toString();
|
||||
const gender = code.substring(0, 1);
|
||||
const year = (parseInt(gender, 10) < 5 ? '19' : '20') + code.substring(1, 3);
|
||||
const month = code.substring(3, 5);
|
||||
const day = code.substring(5, 7);
|
||||
return `${year}.${month}.${day}`;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Proovitoo</title>
|
||||
<title>Proovitöö</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
|
@ -9,4 +9,4 @@ if (environment.production) {
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
||||
.catch((err) => console.error(err));
|
||||
|
@ -57,7 +57,6 @@
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user