* 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/
*.sln.iml
# VSCode custom workspace settings
.vscode/
# CodeRush
.cr/

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

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

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

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { GridService, IGridTextItem } from './grid.service';
import { GridService } from './grid.service';
import { IGridTextItem } from './grid.model';
@Component({
selector: 'app-grid',
@ -9,9 +10,9 @@ import { GridService, IGridTextItem } from './grid.service';
})
export class GridComponent implements OnInit {
GreyBox = require('../../../assets/GreyBox.svg') as string;
WarningMessageText = 'Request to get grid text failed:';
WarningMessageOpen = false;
greyBox = require('../../../assets/GreyBox.svg') as string;
warningMessageText = 'Request to get grid text failed:';
warningMessageOpen = false;
gridTextAssets: IGridTextItem[] = [
{
description: 'example1',
@ -24,21 +25,23 @@ export class GridComponent implements OnInit {
id: 1
}
];
constructor(private gridService: GridService) { }
ngOnInit() {
this.gridService.getGridItems().subscribe(
result => {
(result: IGridTextItem[]) => {
this.gridTextAssets = result;
},
error => {
this.WarningMessageOpen = true;
this.WarningMessageText = `Request to get grid text failed: ${error}`;
this.warningMessageOpen = true;
this.warningMessageText = `Request to get grid text failed: ${error}`;
}
);
}
handleWarningClose(open: boolean) {
this.WarningMessageOpen = open;
this.WarningMessageText = '';
this.warningMessageOpen = open;
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 { environment } from '../../../environments/environment';
import { IGridTextItem } from './grid.model';
@Injectable({
providedIn: 'root'
@ -17,10 +18,3 @@ export class GridService {
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']
})
export class ListFormComponent implements OnInit {
listForm: FormGroup;
@Output() inputText = new EventEmitter<string>();

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

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

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

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

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

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ListService, IListItem } from './list.service';
import { ListService } from './list.service';
import { IListItem } from './list.model';
@Component({
selector: 'app-list',
@ -8,49 +9,51 @@ import { ListService, IListItem } from './list.service';
styleUrls: ['./list.component.css']
})
export class ListComponent implements OnInit {
listItems: IListItem[] = [];
WarningMessageText = 'Request to get list items failed:';
WarningMessageOpen = false;
warningMessageText = 'Request to get list items failed:';
warningMessageOpen = false;
constructor(private listService: ListService) { }
ngOnInit() {
this.listService.getListItems().subscribe(
response => {
(response: IListItem[]) => {
this.listItems = response;
},
error => {
this.WarningMessageOpen = true;
this.WarningMessageText = `Request to get list items failed: ${error}`;
this.warningMessageOpen = true;
this.warningMessageText = `Request to get list items failed: ${error}`;
}
);
}
handleAddListItem(inputText: string) {
this.listService.addListItem(inputText).subscribe(
(response) => {
(response: IListItem) => {
this.listItems.splice(0, 0, response);
},
error => {
this.WarningMessageOpen = true;
this.WarningMessageText = `Request to add list item failed: ${error}`;
this.warningMessageOpen = true;
this.warningMessageText = `Request to add list item failed: ${error}`;
}
);
}
handleDeleteListItem(id: number) {
this.listService.deleteListItem(id).subscribe(
response => {
(response: IListItem) => {
this.listItems = this.listItems.filter(item => item._id !== response._id);
},
error => {
this.WarningMessageOpen = true;
this.WarningMessageText = `Request to delete list item failed: ${error}`;
this.warningMessageOpen = true;
this.warningMessageText = `Request to delete list item failed: ${error}`;
}
);
}
handleWarningClose(open: boolean) {
this.WarningMessageOpen = open;
this.WarningMessageText = '';
this.warningMessageOpen = open;
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 { environment } from '../../../environments/environment';
import { IListItem } from './list.model';
@Injectable({
providedIn: 'root'
})
export class ListService {
private listUrl = environment.endpoint.list;
constructor(private http: HttpClient) { }
@ -22,9 +24,11 @@ export class ListService {
'Content-Type': 'application/json'
})
};
const body = JSON.stringify({
text: inputText
});
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}`);
}
}
export interface IListItem {
_id: number;
text: string;
}

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

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

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

@ -1,6 +1,7 @@
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({
selector: 'app-master-detail',
@ -9,9 +10,9 @@ import { MasterDetailService, IMasterDetailText } from './master-detail.service'
})
export class MasterDetailComponent implements OnInit {
GreyAvatar = require('../../../assets/GreyAvatar.svg') as string;
WarningMessageText = 'Request to get master detail text failed:';
WarningMessageOpen = false;
greyAvatar = require('../../../assets/GreyAvatar.svg') as string;
warningMessageText = 'Request to get master detail text failed:';
warningMessageOpen = false;
currentDisplayTabIndex = 0;
masterDetailText: IMasterDetailText[] = [];
@ -19,12 +20,12 @@ export class MasterDetailComponent implements OnInit {
ngOnInit() {
this.masterDetailService.getMasterDetailItems().subscribe(
result => {
(result: IMasterDetailText[]) => {
this.masterDetailText = result;
},
error => {
this.WarningMessageOpen = true;
this.WarningMessageText = `Request to get master detail text failed: ${error}`;
this.warningMessageOpen = true;
this.warningMessageText = `Request to get master detail text failed: ${error}`;
}
);
}
@ -32,10 +33,9 @@ export class MasterDetailComponent implements OnInit {
handleDisplayTabClick(id: number) {
this.currentDisplayTabIndex = id;
}
handleWarningClose(open: boolean) {
this.WarningMessageOpen = open;
this.WarningMessageText = '';
this.warningMessageOpen = open;
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 { environment } from '../../../environments/environment';
import { IMasterDetailText } from './master-detail.model';
@Injectable({
providedIn: 'root'
@ -17,14 +18,3 @@ export class MasterDetailService {
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.-->
<!-- header -->
<app-nav-bar></app-nav-bar>
<app-nav-bar></app-nav-bar>
<router-outlet></router-outlet>
<!-- footer -->
<app-footer></app-footer>

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

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

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

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