Skip to content

Commit

Permalink
Merge pull request #145 from sjimenez77/develop
Browse files Browse the repository at this point in the history
Linting updated to Angular 7
  • Loading branch information
sjimenez77 authored Nov 23, 2018
2 parents a911fa8 + be096b6 commit 1752cec
Show file tree
Hide file tree
Showing 27 changed files with 464 additions and 389 deletions.
15 changes: 10 additions & 5 deletions angular/e2e/dashboard.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { browser, by, protractor, $, element, ProtractorExpectedConditions } from 'protractor';
import {
browser,
by,
protractor,
$,
element,
ProtractorExpectedConditions,
} from 'protractor';

describe('basic e2e test with loading', function(): void {
let EC: ProtractorExpectedConditions = protractor.ExpectedConditions;
const EC: ProtractorExpectedConditions = protractor.ExpectedConditions;
describe('home', function(): void {
browser.get('/');
it('should load home page', function(): void {
expect(browser.getTitle()).toBe('My Thai Star');
// Waits for the element 'td-loading' to not be present on the dom.
browser.wait(EC.not(EC.presenceOf($('td-loading'))), 10000)
.then(() => {

browser.wait(EC.not(EC.presenceOf($('td-loading'))), 10000).then(() => {
// checks if elements were rendered
expect(element(by.id('homeCard')).isPresent()).toBe(true);
});
Expand Down
2 changes: 1 addition & 1 deletion angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as moment from 'moment';
animations: [fadeAnimation], // register the animation
})
export class AppComponent {
mobileSidenavOpened: boolean = false;
mobileSidenavOpened = false;
year: string = moment().format('YYYY');
constructor(
public router: Router,
Expand Down
4 changes: 2 additions & 2 deletions angular/src/app/book-table/shared/book-table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class BookTableService {
}

composeBooking(invitationData: any, type: number): BookingInfo {
let composedBooking: BookingInfo = {
const composedBooking: BookingInfo = {
booking: {
bookingDate: invitationData.bookingDate,
name: invitationData.name,
Expand All @@ -28,7 +28,7 @@ export class BookTableService {
};

if (type) {
composedBooking.invitedGuests = map(invitationData.invitedGuests, (email: string) => { return { email: email }; });
composedBooking.invitedGuests = map(invitationData.invitedGuests, (email: string) => ({ email: email }));
} else {
composedBooking.booking.assistants = invitationData.assistants;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import { TranslateService } from '@ngx-translate/core';
describe('OrderCockpitComponent', () => {
let component: OrderCockpitComponent;
// let fixture: ComponentFixture<OrderCockpitComponent>;
// tslint:disable-next-line:prefer-const
let http: HttpClient;
let priceCalculator: PriceCalculatorService;
let waiterCockpitService: WaiterCockpitService;
// tslint:disable-next-line:prefer-const
let translate: TranslateService;
// tslint:disable-next-line:prefer-const
let dialog: MatDialog;

// beforeEach(async(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import * as moment from 'moment';
styleUrls: ['./order-cockpit.component.scss'],
})
export class OrderCockpitComponent implements OnInit {

private pageable: Pageable = {
pageSize: 8,
pageNumber: 0,
// total: 1,
};
private sorting: any[] = [];

pageSize: number = 8;
pageSize = 8;

orders: OrderListView[];
totalOrders: number;
Expand All @@ -43,9 +42,11 @@ export class OrderCockpitComponent implements OnInit {
bookingToken: undefined,
};

constructor(private dialog: MatDialog,
constructor(
private dialog: MatDialog,
private translate: TranslateService,
private waiterCockpitService: WaiterCockpitService) { }
private waiterCockpitService: WaiterCockpitService,
) {}

ngOnInit(): void {
this.applyFilters();
Expand All @@ -67,10 +68,11 @@ export class OrderCockpitComponent implements OnInit {
}

applyFilters(): void {
this.waiterCockpitService.getOrders(this.pageable, this.sorting, this.filters)
this.waiterCockpitService
.getOrders(this.pageable, this.sorting, this.filters)
.subscribe((data: any) => {
if (!data) {
this.orders = [];
this.orders = [];
} else {
this.orders = data.content;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Component, OnInit, Inject } from '@angular/core';
import { IPageChangeEvent, ITdDataTableColumn, TdDataTableService } from '@covalent/core';
import {
IPageChangeEvent,
ITdDataTableColumn,
TdDataTableService,
} from '@covalent/core';
import { OrderView, BookingView } from '../../../shared/viewModels/interfaces';
import { WaiterCockpitService } from '../../shared/waiter-cockpit.service';
import { MAT_DIALOG_DATA } from '@angular/material';
Expand All @@ -13,11 +17,10 @@ import { LangChangeEvent } from '@ngx-translate/core';
styleUrls: ['./order-dialog.component.scss'],
})
export class OrderDialogComponent implements OnInit {
private fromRow = 1;
private currentPage = 1;

private fromRow: number = 1;
private currentPage: number = 1;

pageSize: number = 4;
pageSize = 4;

data: any;
datat: BookingView[] = [];
Expand All @@ -30,21 +33,24 @@ export class OrderDialogComponent implements OnInit {
filteredData: OrderView[] = this.datao;
totalPrice: number;

constructor(private _dataTableService: TdDataTableService,
constructor(
private _dataTableService: TdDataTableService,
private waiterCockpitService: WaiterCockpitService,
private translate: TranslateService,
@Inject(MAT_DIALOG_DATA) dialogData: any) {
@Inject(MAT_DIALOG_DATA) dialogData: any,
) {
this.data = dialogData.row;
}

ngOnInit(): void {

this.setTableHeaders();
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.setTableHeaders();
});

this.totalPrice = this.waiterCockpitService.getTotalPrice(this.data.orderLines);
this.totalPrice = this.waiterCockpitService.getTotalPrice(
this.data.orderLines,
);
this.datao = this.waiterCockpitService.orderComposer(this.data.orderLines);
this.datat.push(this.data.booking);
this.filter();
Expand All @@ -67,7 +73,12 @@ export class OrderDialogComponent implements OnInit {
{ name: 'orderLine.comment', label: res.commentsH },
{ name: 'extras', label: res.extrasH },
{ name: 'orderLine.amount', label: res.quantityH },
{ name: 'dish.price', label: res.priceH, numeric: true, format: (v: number) => v.toFixed(2) },
{
name: 'dish.price',
label: res.priceH,
numeric: true,
format: (v: number) => v.toFixed(2),
},
];
});
}
Expand All @@ -81,7 +92,11 @@ export class OrderDialogComponent implements OnInit {

filter(): void {
let newData: any[] = this.datao;
newData = this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize);
setTimeout(() => this.filteredData = newData);
newData = this._dataTableService.pageData(
newData,
this.fromRow,
this.currentPage * this.pageSize,
);
setTimeout(() => (this.filteredData = newData));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import { TranslateService } from '@ngx-translate/core';
describe('ReservationCockpitComponent', () => {
let component: ReservationCockpitComponent;
// let fixture: ComponentFixture<ReservationCockpitComponent>;
// tslint:disable-next-line:prefer-const
let http: HttpClient;
let priceCalculator: PriceCalculatorService;
let waiterCockpitService: WaiterCockpitService;
// tslint:disable-next-line:prefer-const
let translate: TranslateService;
// tslint:disable-next-line:prefer-const
let dialog: MatDialog;

// beforeEach(async(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Component, OnInit, Inject } from '@angular/core';
import { IPageChangeEvent, ITdDataTableColumn, TdDataTableService } from '@covalent/core';
import { FriendsInvite, ReservationView } from '../../../shared/viewModels/interfaces';
import {
IPageChangeEvent,
ITdDataTableColumn,
TdDataTableService,
} from '@covalent/core';
import {
FriendsInvite,
ReservationView,
} from '../../../shared/viewModels/interfaces';
import { MAT_DIALOG_DATA } from '@angular/material';
import { config } from '../../../config';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -12,11 +19,10 @@ import { LangChangeEvent } from '@ngx-translate/core';
styleUrls: ['./reservation-dialog.component.scss'],
})
export class ReservationDialogComponent implements OnInit {

datao: FriendsInvite[] = [];
fromRow: number = 1;
currentPage: number = 1;
pageSize: number = 4;
fromRow = 1;
currentPage = 1;
pageSize = 4;

data: any;
columnso: ITdDataTableColumn[] = [
Expand All @@ -29,9 +35,11 @@ export class ReservationDialogComponent implements OnInit {

filteredData: any[] = this.datao;

constructor(private _dataTableService: TdDataTableService,
constructor(
private _dataTableService: TdDataTableService,
private translate: TranslateService,
@Inject(MAT_DIALOG_DATA) dialogData: any) {
@Inject(MAT_DIALOG_DATA) dialogData: any,
) {
this.data = dialogData.row;
this.pageSizes = config.pageSizesDialog;
}
Expand All @@ -58,16 +66,21 @@ export class ReservationDialogComponent implements OnInit {
];
});

this.translate.get('cockpit.reservations.dialogTable').subscribe((res: any) => {
this.columnso = [
{ name: 'email', label: res.guestEmailH },
{ name: 'accepted', label: res.acceptanceH },
];
this.translate
.get('cockpit.reservations.dialogTable')
.subscribe((res: any) => {
this.columnso = [
{ name: 'email', label: res.guestEmailH },
{ name: 'accepted', label: res.acceptanceH },
];

if (this.data.booking.assistants) {
this.columnst.push({ name: 'booking.assistants', label: res.assistantsH });
}
});
if (this.data.booking.assistants) {
this.columnst.push({
name: 'booking.assistants',
label: res.assistantsH,
});
}
});
}

page(pagingEvent: IPageChangeEvent): void {
Expand All @@ -79,8 +92,11 @@ export class ReservationDialogComponent implements OnInit {

filter(): void {
let newData: any[] = this.datao;
newData = this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize);
setTimeout(() => this.filteredData = newData);
newData = this._dataTableService.pageData(
newData,
this.fromRow,
this.currentPage * this.pageSize,
);
setTimeout(() => (this.filteredData = newData));
}

}
54 changes: 40 additions & 14 deletions angular/src/app/cockpit-area/shared/waiter-cockpit.service.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { PriceCalculatorService } from '../../sidenav/shared/price-calculator.service';
import { BookingResponse, OrderResponse, OrderView, OrderViewResult } from '../../shared/viewModels/interfaces';
import {
BookingResponse,
OrderResponse,
OrderView,
OrderViewResult,
} from '../../shared/viewModels/interfaces';
import { map, cloneDeep } from 'lodash';
import { Pageable, Sort, FilterCockpit } from 'app/shared/backendModels/interfaces';
import {
Pageable,
Sort,
FilterCockpit,
} from 'app/shared/backendModels/interfaces';
import { HttpClient } from '@angular/common/http';
import { environment } from './../../../environments/environment';

@Injectable()
export class WaiterCockpitService {
private readonly getReservationsRestPath: string =
'bookingmanagement/v1/booking/search';
private readonly getOrdersRestPath: string =
'ordermanagement/v1/order/search';
private readonly filterOrdersRestPath: string =
'ordermanagement/v1/order/search';

private readonly getReservationsRestPath: string = 'bookingmanagement/v1/booking/search';
private readonly getOrdersRestPath: string = 'ordermanagement/v1/order/search';
private readonly filterOrdersRestPath: string = 'ordermanagement/v1/order/search';
constructor(
private http: HttpClient,
private priceCalculator: PriceCalculatorService,
) {}

constructor(private http: HttpClient,
private priceCalculator: PriceCalculatorService) { }

getOrders(pageable: Pageable, sorting: Sort[], filters: FilterCockpit): Observable<OrderResponse[]> {
getOrders(
pageable: Pageable,
sorting: Sort[],
filters: FilterCockpit,
): Observable<OrderResponse[]> {
let path: string;
filters.pageable = pageable;
filters.pageable.sort = sorting;
Expand All @@ -28,17 +45,27 @@ export class WaiterCockpitService {
delete filters.bookingToken;
path = this.getOrdersRestPath;
}
return this.http.post<OrderResponse[]>(`${environment.restServiceRoot}${path}`, filters);
return this.http.post<OrderResponse[]>(
`${environment.restServiceRoot}${path}`,
filters,
);
}

getReservations(pageable: Pageable, sorting: Sort[], filters: FilterCockpit): Observable<BookingResponse[]> {
getReservations(
pageable: Pageable,
sorting: Sort[],
filters: FilterCockpit,
): Observable<BookingResponse[]> {
filters.pageable = pageable;
filters.pageable.sort = sorting;
return this.http.post<BookingResponse[]>(`${environment.restServiceRoot}${this.getReservationsRestPath}`, filters);
return this.http.post<BookingResponse[]>(
`${environment.restServiceRoot}${this.getReservationsRestPath}`,
filters,
);
}

orderComposer(orderList: OrderView[]): OrderView[] {
let orders: OrderView[] = cloneDeep(orderList);
const orders: OrderView[] = cloneDeep(orderList);
map(orders, (o: OrderViewResult) => {
o.dish.price = this.priceCalculator.getPrice(o);
o.extras = map(o.extras, 'name').join(', ');
Expand All @@ -49,5 +76,4 @@ export class WaiterCockpitService {
getTotalPrice(orderLines: OrderView[]): number {
return this.priceCalculator.getTotalPrice(orderLines);
}

}
Loading

0 comments on commit 1752cec

Please sign in to comment.