* add .vscode/ custom workspace settings to .gitignore

* ensure consistent single blank line between methods and single final newline

* remove unnecessary comments in app.component.html

* move interfaces to its own *.model.ts files

* change various variables to conform to camel case

Signed-off-by: mhatvan <markus_hatvan@aon.at>
This commit is contained in:
mhatvan 2019-08-27 23:24:01 +02:00
Родитель 465bc083b1
Коммит 16a9f0745b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 6DD396B45D5556CE
18 изменённых файлов: 85 добавлений и 79 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -291,6 +291,9 @@ paket-files/
.idea/ .idea/
*.sln.iml *.sln.iml
# VSCode custom workspace settings
.vscode/
# CodeRush # CodeRush
.cr/ .cr/

Просмотреть файл

@ -21,15 +21,15 @@
[key]="textAssets.id" [key]="textAssets.id"
[header]="textAssets.title" [header]="textAssets.title"
[description]="textAssets.shortDescription" [description]="textAssets.shortDescription"
[image]="GreyBox" [image]="greyBox"
> >
</app-grid-box> </app-grid-box>
</div> </div>
</div> </div>
<app-warning-message <app-warning-message
*ngIf="WarningMessageOpen" *ngIf="warningMessageOpen"
[text]="WarningMessageText" [text]="warningMessageText"
(WarningMessageOpen)="handleWarningClose($event)" (warningMessageOpen)="handleWarningClose($event)"
> >
</app-warning-message> </app-warning-message>
</main> </main>

Просмотреть файл

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { GridService, IGridTextItem } from './grid.service'; import { GridService } from './grid.service';
import { IGridTextItem } from './grid.model';
@Component({ @Component({
selector: 'app-grid', selector: 'app-grid',
@ -9,9 +10,9 @@ import { GridService, IGridTextItem } from './grid.service';
}) })
export class GridComponent implements OnInit { export class GridComponent implements OnInit {
GreyBox = require('../../../assets/GreyBox.svg') as string; greyBox = require('../../../assets/GreyBox.svg') as string;
WarningMessageText = 'Request to get grid text failed:'; warningMessageText = 'Request to get grid text failed:';
WarningMessageOpen = false; warningMessageOpen = false;
gridTextAssets: IGridTextItem[] = [ gridTextAssets: IGridTextItem[] = [
{ {
description: 'example1', description: 'example1',
@ -24,21 +25,23 @@ export class GridComponent implements OnInit {
id: 1 id: 1
} }
]; ];
constructor(private gridService: GridService) { } constructor(private gridService: GridService) { }
ngOnInit() { ngOnInit() {
this.gridService.getGridItems().subscribe( this.gridService.getGridItems().subscribe(
result => { (result: IGridTextItem[]) => {
this.gridTextAssets = result; this.gridTextAssets = result;
}, },
error => { error => {
this.WarningMessageOpen = true; this.warningMessageOpen = true;
this.WarningMessageText = `Request to get grid text failed: ${error}`; this.warningMessageText = `Request to get grid text failed: ${error}`;
} }
); );
} }
handleWarningClose(open: boolean) { handleWarningClose(open: boolean) {
this.WarningMessageOpen = open; this.warningMessageOpen = open;
this.WarningMessageText = ''; this.warningMessageText = '';
} }
} }

Просмотреть файл

@ -0,0 +1,5 @@
export interface IGridTextItem {
description: string;
header: string;
id: number;
}

Просмотреть файл

@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
import { IGridTextItem } from './grid.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -17,10 +18,3 @@ export class GridService {
return this.http.get<IGridTextItem[]>(this.listUrl); return this.http.get<IGridTextItem[]>(this.listUrl);
} }
} }
export interface IGridTextItem {
description: string;
header: string;
id: number;
}

Просмотреть файл

@ -7,6 +7,7 @@ import { FormControl, FormGroup } from '@angular/forms';
styleUrls: ['./list-form.component.css'] styleUrls: ['./list-form.component.css']
}) })
export class ListFormComponent implements OnInit { export class ListFormComponent implements OnInit {
listForm: FormGroup; listForm: FormGroup;
@Output() inputText = new EventEmitter<string>(); @Output() inputText = new EventEmitter<string>();

Просмотреть файл

@ -6,10 +6,11 @@
styleUrls: ['./list-item.component.css'] styleUrls: ['./list-item.component.css']
}) })
export class ListItemComponent implements OnInit { export class ListItemComponent implements OnInit {
// tslint:disable-next-line // tslint:disable-next-line:variable-name
@Input() _id: number; @Input() _id: number;
@Input() text: string; @Input() text: string;
@Output() deleteText = new EventEmitter<number>(); @Output() deleteText = new EventEmitter<number>();
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
@ -18,5 +19,4 @@ export class ListItemComponent implements OnInit {
onDeleteListItem() { onDeleteListItem() {
this.deleteText.emit(this._id); this.deleteText.emit(this._id);
} }
} }

Просмотреть файл

@ -16,9 +16,9 @@
</app-list-item> </app-list-item>
<app-warning-message <app-warning-message
*ngIf="WarningMessageOpen" *ngIf="warningMessageOpen"
[text]="WarningMessageText" [text]="warningMessageText"
(WarningMessageOpen)="handleWarningClose($event)" (warningMessageOpen)="handleWarningClose($event)"
></app-warning-message> ></app-warning-message>
</div> </div>
</main> </main>

Просмотреть файл

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ListService, IListItem } from './list.service'; import { ListService } from './list.service';
import { IListItem } from './list.model';
@Component({ @Component({
selector: 'app-list', selector: 'app-list',
@ -8,49 +9,51 @@ import { ListService, IListItem } from './list.service';
styleUrls: ['./list.component.css'] styleUrls: ['./list.component.css']
}) })
export class ListComponent implements OnInit { export class ListComponent implements OnInit {
listItems: IListItem[] = []; listItems: IListItem[] = [];
WarningMessageText = 'Request to get list items failed:'; warningMessageText = 'Request to get list items failed:';
WarningMessageOpen = false; warningMessageOpen = false;
constructor(private listService: ListService) { } constructor(private listService: ListService) { }
ngOnInit() { ngOnInit() {
this.listService.getListItems().subscribe( this.listService.getListItems().subscribe(
response => { (response: IListItem[]) => {
this.listItems = response; this.listItems = response;
}, },
error => { error => {
this.WarningMessageOpen = true; this.warningMessageOpen = true;
this.WarningMessageText = `Request to get list items failed: ${error}`; this.warningMessageText = `Request to get list items failed: ${error}`;
} }
); );
} }
handleAddListItem(inputText: string) { handleAddListItem(inputText: string) {
this.listService.addListItem(inputText).subscribe( this.listService.addListItem(inputText).subscribe(
(response) => { (response: IListItem) => {
this.listItems.splice(0, 0, response); this.listItems.splice(0, 0, response);
}, },
error => { error => {
this.WarningMessageOpen = true; this.warningMessageOpen = true;
this.WarningMessageText = `Request to add list item failed: ${error}`; this.warningMessageText = `Request to add list item failed: ${error}`;
} }
); );
} }
handleDeleteListItem(id: number) { handleDeleteListItem(id: number) {
this.listService.deleteListItem(id).subscribe( this.listService.deleteListItem(id).subscribe(
response => { (response: IListItem) => {
this.listItems = this.listItems.filter(item => item._id !== response._id); this.listItems = this.listItems.filter(item => item._id !== response._id);
}, },
error => { error => {
this.WarningMessageOpen = true; this.warningMessageOpen = true;
this.WarningMessageText = `Request to delete list item failed: ${error}`; this.warningMessageText = `Request to delete list item failed: ${error}`;
} }
); );
} }
handleWarningClose(open: boolean) { handleWarningClose(open: boolean) {
this.WarningMessageOpen = open; this.warningMessageOpen = open;
this.WarningMessageText = ''; this.warningMessageText = '';
} }
} }

Просмотреть файл

@ -0,0 +1,4 @@
export interface IListItem {
_id: number;
text: string;
}

Просмотреть файл

@ -3,11 +3,13 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
import { IListItem } from './list.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class ListService { export class ListService {
private listUrl = environment.endpoint.list; private listUrl = environment.endpoint.list;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
@ -22,9 +24,11 @@ export class ListService {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}) })
}; };
const body = JSON.stringify({ const body = JSON.stringify({
text: inputText text: inputText
}); });
return this.http.post<IListItem>(this.listUrl, body, httpOptions); return this.http.post<IListItem>(this.listUrl, body, httpOptions);
} }
@ -32,9 +36,3 @@ export class ListService {
return this.http.delete<IListItem>(`${environment.endpoint.list}/${id}`); return this.http.delete<IListItem>(`${environment.endpoint.list}/${id}`);
} }
} }
export interface IListItem {
_id: number;
text: string;
}

Просмотреть файл

@ -1,5 +1,5 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { IMasterDetailText } from '../master-detail.service'; import { IMasterDetailText } from '../master-detail.model';
@Component({ @Component({
selector: 'app-master-detail-page', selector: 'app-master-detail-page',
@ -9,6 +9,7 @@ import { IMasterDetailText } from '../master-detail.service';
export class MasterDetailPageComponent implements OnInit { export class MasterDetailPageComponent implements OnInit {
@Input() textSampleData: IMasterDetailText; @Input() textSampleData: IMasterDetailText;
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
@ -23,5 +24,4 @@ export class MasterDetailPageComponent implements OnInit {
id: 0 id: 0
}; };
} }
} }

Просмотреть файл

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MasterDetailService, IMasterDetailText } from './master-detail.service'; import { MasterDetailService } from './master-detail.service';
import { IMasterDetailText } from './master-detail.model';
@Component({ @Component({
selector: 'app-master-detail', selector: 'app-master-detail',
@ -9,9 +10,9 @@ import { MasterDetailService, IMasterDetailText } from './master-detail.service'
}) })
export class MasterDetailComponent implements OnInit { export class MasterDetailComponent implements OnInit {
GreyAvatar = require('../../../assets/GreyAvatar.svg') as string; greyAvatar = require('../../../assets/GreyAvatar.svg') as string;
WarningMessageText = 'Request to get master detail text failed:'; warningMessageText = 'Request to get master detail text failed:';
WarningMessageOpen = false; warningMessageOpen = false;
currentDisplayTabIndex = 0; currentDisplayTabIndex = 0;
masterDetailText: IMasterDetailText[] = []; masterDetailText: IMasterDetailText[] = [];
@ -19,12 +20,12 @@ export class MasterDetailComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.masterDetailService.getMasterDetailItems().subscribe( this.masterDetailService.getMasterDetailItems().subscribe(
result => { (result: IMasterDetailText[]) => {
this.masterDetailText = result; this.masterDetailText = result;
}, },
error => { error => {
this.WarningMessageOpen = true; this.warningMessageOpen = true;
this.WarningMessageText = `Request to get master detail text failed: ${error}`; this.warningMessageText = `Request to get master detail text failed: ${error}`;
} }
); );
} }
@ -32,10 +33,9 @@ export class MasterDetailComponent implements OnInit {
handleDisplayTabClick(id: number) { handleDisplayTabClick(id: number) {
this.currentDisplayTabIndex = id; this.currentDisplayTabIndex = id;
} }
handleWarningClose(open: boolean) { handleWarningClose(open: boolean) {
this.WarningMessageOpen = open; this.warningMessageOpen = open;
this.WarningMessageText = ''; this.warningMessageText = '';
} }
} }

Просмотреть файл

@ -0,0 +1,10 @@
export interface IMasterDetailText {
title: string;
id: number;
status: string;
orderDate: string;
shipTo: string;
orderTotal: number;
shortDescription: string;
longDescription: string;
}

Просмотреть файл

@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
import { IMasterDetailText } from './master-detail.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -17,14 +18,3 @@ export class MasterDetailService {
return this.http.get<IMasterDetailText[]>(this.listUrl); return this.http.get<IMasterDetailText[]>(this.listUrl);
} }
} }
export interface IMasterDetailText {
title: string;
id: number;
status: string;
orderDate: string;
shipTo: string;
orderTotal: number;
shortDescription: string;
longDescription: string;
}

Просмотреть файл

@ -1,11 +1,5 @@
<!--The content below is only a placeholder and can be replaced.--> <app-nav-bar></app-nav-bar>
<!-- header -->
<app-nav-bar></app-nav-bar>
<router-outlet></router-outlet> <router-outlet></router-outlet>
<!-- footer -->
<app-footer></app-footer> <app-footer></app-footer>

Просмотреть файл

@ -6,5 +6,6 @@
styleUrls: ['./app.component.css'] styleUrls: ['./app.component.css']
}) })
export class AppComponent { export class AppComponent {
title = 'wts.AngularDefault'; title = 'wts.AngularDefault';
} }

Просмотреть файл

@ -9,7 +9,7 @@ export class WarningMessageComponent implements OnInit {
open = false; open = false;
@Input() text = ''; @Input() text = '';
@Output() WarningMessageOpen = new EventEmitter<boolean>(); @Output() warningMessageOpen = new EventEmitter<boolean>();
constructor() { } constructor() { }
@ -19,6 +19,6 @@ export class WarningMessageComponent implements OnInit {
onWarningClose() { onWarningClose() {
this.text = ''; this.text = '';
this.open = false; this.open = false;
this.WarningMessageOpen.emit(this.open); this.warningMessageOpen.emit(this.open);
} }
} }