@ -1,9 +0,0 @@ | |||
//import { Routes, RouterModule } from '@angular/router'; | |||
//import { BasketComponent } from './basket.component'; | |||
//const routes: Routes = [ | |||
// { path: '', component: BasketComponent } | |||
//]; | |||
//export const routing = RouterModule.forChild(routes); |
@ -1,9 +0,0 @@ | |||
//import { Routes, RouterModule } from '@angular/router'; | |||
//import { CatalogComponent } from './catalog.component'; | |||
//const routes: Routes = [ | |||
// { path: '', component: CatalogComponent } | |||
//]; | |||
//export const routing = RouterModule.forChild(routes); |
@ -0,0 +1,59 @@ | |||
<div class="esh-orders-detail-header"> | |||
<ul class="container"> | |||
<li class="esh-orders-detail-header-back" routerLink="/orders">Back to list</li> | |||
</ul> | |||
</div> | |||
<div class="container esh-orders-detail-container"> | |||
<div class="row"> | |||
<div class="col-sm-3"> | |||
<span>ORDER NUMBER</span><br> | |||
<span>{{order.ordernumber}}</span> | |||
</div> | |||
<div class="col-sm-3"> | |||
<span>DATE</span><br> | |||
<span>{{order.date | date:'short'}}</span> | |||
</div> | |||
<div class="col-sm-3"> | |||
<span>TOTAL</span><br> | |||
<span>$ {{order.total}}</span> | |||
</div> | |||
<div class="col-sm-3"> | |||
<span>STATUS</span><br> | |||
<span>{{order.status}}</span> | |||
</div> | |||
</div> | |||
<div class="row esh-orders-detail-section"> | |||
<div class="col-sm-3"> | |||
<span>SHIPING ADDRESS</span><br> | |||
<span>{{order.street}}</span><br> | |||
<span>{{order.city}}</span><br> | |||
<span>{{order.country}}</span><br> | |||
</div> | |||
</div> | |||
<div> | |||
<div class="row esh-orders-detail-section"><div class="col-sm-3">ORDER DETAILS</div></div> | |||
<section> | |||
<table class="table"> | |||
<tbody> | |||
<tr *ngFor="let item of order.orderitems"> | |||
<td class="esh-orders-detail-column"><img class="esh-orders-detail-image" src="{{item.pictureurl}}"></td> | |||
<td class="esh-orders-detail-column">{{item.productname}}</td> | |||
<td class="esh-orders-detail-column">ROSLYN</td> | |||
<td class="esh-orders-detail-column">$ {{item.unitprice}}</td> | |||
<td class="esh-orders-detail-column">{{item.units}}</td> | |||
<td class="esh-orders-detail-column esh-orders-detail-total-value">$ {{item.units * item.unitprice}}</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
</section> | |||
</div> | |||
<div class="col-md-9 col-md-3"> | |||
</div> | |||
<div class="col-md-3"> | |||
<div class="esh-orders-detail-total"> | |||
<div class="esh-orders-detail-total-label"><span>TOTAL</span></div> | |||
<div class="esh-orders-detail-total-value"><span>$ 12.00</span></div> | |||
</div> | |||
</div> | |||
</div> |
@ -0,0 +1,86 @@ | |||
@import '../../_variables.scss'; | |||
.esh-orders-detail { | |||
min-height: 80vh; | |||
&-header { | |||
background-color: #00A69C; | |||
height: 63px; | |||
li { | |||
list-style: none; | |||
display: inline; | |||
opacity: 0.5; | |||
margin-top: 25px; | |||
margin-left: 10px; | |||
float: right; | |||
cursor: pointer; | |||
color: white; | |||
} | |||
li a { | |||
color: white; | |||
} | |||
&-back { | |||
float: left !important; | |||
margin-top: 20px !important; | |||
text-transform: uppercase; | |||
} | |||
li a:hover { | |||
text-decoration: none; | |||
} | |||
} | |||
&-container { | |||
min-height: 70vh; | |||
padding-top: 40px; | |||
margin-bottom: 30px; | |||
} | |||
&-container .table tbody tr:first-child td { | |||
border-top: none; | |||
} | |||
&-container .table tr { | |||
border-bottom: none; | |||
} | |||
&-section { | |||
margin-top: 50px; | |||
} | |||
&-container .table { | |||
margin-left: -7px; | |||
} | |||
&-total { | |||
margin-bottom: 5px; | |||
margin-left: 20px; | |||
text-align: left; | |||
} | |||
&-total-label { | |||
font-size: 14px; | |||
color: #404040; | |||
margin-top:10px; | |||
} | |||
&-total-value { | |||
font-size: 28px; | |||
color: #00a69c; | |||
text-align: left; | |||
} | |||
&-image { | |||
max-width: 210px; | |||
} | |||
&-column { | |||
max-width: 120px; | |||
padding: 8px; | |||
text-transform: uppercase; | |||
vertical-align: middle!important; | |||
} | |||
} |
@ -0,0 +1,31 @@ | |||
import { Component, OnInit } from '@angular/core'; | |||
import { OrdersService } from '../orders.service'; | |||
import { IOrder } from '../../shared/models/order.model'; | |||
import { ActivatedRoute } from '@angular/router'; | |||
@Component({ | |||
selector: 'esh-orders-detail .esh-orders-detail', | |||
styleUrls: ['./orders-detail.component.scss'], | |||
templateUrl: './orders-detail.component.html' | |||
}) | |||
export class OrdersDetailComponent implements OnInit { | |||
order = {}; // new order | |||
constructor(private service: OrdersService, private route: ActivatedRoute) { } | |||
ngOnInit() { | |||
this.route.params.subscribe(params => { | |||
let id = +params['id']; // (+) converts string 'id' to a number | |||
this.getOrder(id); | |||
}); | |||
} | |||
getOrder(id: number) { | |||
this.service.getOrder(id).subscribe(order => { | |||
this.order = order; | |||
console.log('order retrieved: ' + order.ordernumber); | |||
console.log(this.order); | |||
}); | |||
} | |||
} | |||
@ -0,0 +1,43 @@ | |||
<div class="esh-orders-header"> | |||
<ul class="container"> | |||
<li class="esh-orders-header-back" routerLink="/catalog">Back to list</li> | |||
</ul> | |||
</div> | |||
<div class="container esh-orders-container"> | |||
<div class="row"> | |||
<div class="col-md-12"> | |||
<section> | |||
<table class="table"> | |||
<thead> | |||
<tr> | |||
<th class="esh-orders-order-column"> | |||
ORDER NUMBER | |||
</th> | |||
<th> | |||
DATE | |||
</th> | |||
<th> | |||
TOTAL | |||
</th> | |||
<th> | |||
STATUS | |||
</th> | |||
<th></th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr *ngFor="let order of orders"> | |||
<td class="esh-orders-order-column">{{order.ordernumber}}</td> | |||
<td class="esh-orders-order-column">{{order.date | date:'short'}}</td> | |||
<td class="esh-orders-order-column">$ {{order.total}}</td> | |||
<td class="esh-orders-order-column">{{order.status}}</td> | |||
<td class="esh-orders-order-column"> | |||
<a class="esh-orders-order-link" routerLink="/orders/{{order.ordernumber}}">Detail</a> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
</section> | |||
</div> | |||
</div> | |||
</div> |
@ -0,0 +1,85 @@ | |||
@import '../_variables.scss'; | |||
.esh-orders { | |||
min-height: 80vh; | |||
&-header { | |||
background-color: #00A69C; | |||
height: 63px; | |||
li { | |||
list-style: none; | |||
display: inline; | |||
opacity: 0.5; | |||
margin-top: 25px; | |||
margin-left: 10px; | |||
float: right; | |||
cursor: pointer; | |||
color: white; | |||
} | |||
li a { | |||
color: white; | |||
} | |||
&-back { | |||
float: left !important; | |||
margin-top: 20px !important; | |||
text-transform: uppercase; | |||
} | |||
li a:hover { | |||
text-decoration: none; | |||
} | |||
} | |||
&-container { | |||
min-height: 70vh; | |||
padding-top: 40px; | |||
margin-bottom: 30px; | |||
min-width: 992px; | |||
} | |||
&-order-column { | |||
max-width: 120px; | |||
vertical-align: middle !important; | |||
} | |||
&-order-link { | |||
color: #83d01b; | |||
} | |||
&-order-image { | |||
max-width: 210px; | |||
} | |||
&-total-value { | |||
font-size: 20px; | |||
color: #00a69c; | |||
} | |||
&-total-label { | |||
font-size: 14px; | |||
color: #404040; | |||
margin-top: 10px; | |||
} | |||
&-totals { | |||
border-bottom:none!important; | |||
} | |||
} | |||
.table td { | |||
border-top: solid 1px #ddd; | |||
} | |||
.table thead th { | |||
border: none !important; | |||
} | |||
@ -0,0 +1,27 @@ | |||
import { Component, OnInit } from '@angular/core'; | |||
import { OrdersService } from './orders.service'; | |||
import { IOrder } from '../shared/models/order.model'; | |||
@Component({ | |||
selector: 'esh-orders .esh-orders', | |||
styleUrls: ['./orders.component.scss'], | |||
templateUrl: './orders.component.html' | |||
}) | |||
export class OrdersComponent implements OnInit { | |||
orders: IOrder[]; | |||
constructor(private service: OrdersService) { } | |||
ngOnInit() { | |||
this.getOrders(); | |||
} | |||
getOrders() { | |||
this.service.getOrders().subscribe(orders => { | |||
this.orders = orders; | |||
console.log('orders items retrieved: ' + orders.length); | |||
}); | |||
} | |||
} | |||
@ -0,0 +1,15 @@ | |||
import { NgModule } from '@angular/core'; | |||
import { BrowserModule } from '@angular/platform-browser'; | |||
import { SharedModule } from '../shared/shared.module'; | |||
import { OrdersComponent } from './orders.component'; | |||
import { OrdersDetailComponent } from './orders-detail/orders-detail.component'; | |||
import { OrdersService } from './orders.service'; | |||
import { Pager } from '../shared/components/pager/pager'; | |||
@NgModule({ | |||
imports: [BrowserModule, SharedModule], | |||
declarations: [OrdersComponent, OrdersDetailComponent], | |||
providers: [OrdersService] | |||
}) | |||
export class OrdersModule { } |
@ -0,0 +1,35 @@ | |||
import { Injectable } from '@angular/core'; | |||
import { Response } from '@angular/http'; | |||
import { DataService } from '../shared/services/data.service'; | |||
import { IOrder } from '../shared/models/order.model'; | |||
import 'rxjs/Rx'; | |||
import { Observable } from 'rxjs/Observable'; | |||
import 'rxjs/add/observable/throw'; | |||
import { Observer } from 'rxjs/Observer'; | |||
import 'rxjs/add/operator/map'; | |||
@Injectable() | |||
export class OrdersService { | |||
private ordersUrl: string = 'http://eshopcontainers:5102/api/v1/orders'; | |||
constructor(private service: DataService) { | |||
} | |||
getOrders(): Observable<IOrder[]> { | |||
let url = this.ordersUrl; | |||
return this.service.get(url).map((response: Response) => { | |||
return response.json(); | |||
}); | |||
} | |||
getOrder(id: number): Observable<IOrder> { | |||
let url = `${this.ordersUrl}/${id}`; | |||
return this.service.get(url).map((response: Response) => { | |||
return response.json(); | |||
}); | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
import {IOrderItem} from './orderItem.model'; | |||
export interface IOrder { | |||
ordernumber: number; | |||
date: Date; | |||
status: string; | |||
total: number; | |||
street?: string; | |||
city?: string; | |||
zipcode?: string; | |||
country?: string; | |||
orderitems?: IOrderItem[]; | |||
} |
@ -0,0 +1,6 @@ | |||
export interface IOrderItem { | |||
pictureurl: string; | |||
productname: string; | |||
unitprice: number; | |||
units: number; | |||
} |