diff --git a/Shopify-Cart.rar b/Shopify-Cart.rar new file mode 100644 index 0000000..381e2d3 Binary files /dev/null and b/Shopify-Cart.rar differ diff --git a/Shopify-Cart/src/main/resources/application.properties b/Shopify-Cart/src/main/resources/application.properties index 884da9a..448603d 100644 --- a/Shopify-Cart/src/main/resources/application.properties +++ b/Shopify-Cart/src/main/resources/application.properties @@ -1,6 +1,6 @@ server.port=8002 -spring.datasource.url=jdbc:mysql://10.3.117.22:3306/Shopify_DB?createDatabaseIfNotExist=true +spring.datasource.url=jdbc:mysql://10.3.117.30:3306/Shopify_DB?createDatabaseIfNotExist=true spring.datasource.username=testuser1 spring.datasource.password=PASSWORD123 diff --git a/ShopifyUI/proxy.conf.json b/ShopifyUI/proxy.conf.json index 033abd2..0cd07fa 100644 --- a/ShopifyUI/proxy.conf.json +++ b/ShopifyUI/proxy.conf.json @@ -1,14 +1,14 @@ { "/api1": { - "target": "http://10.3.117.22:8001", + "target": "http://10.3.117.30:8001", "secure": false }, "/api2": { - "target": "http://10.3.117.22:8002", + "target": "http://10.3.117.30:8002", "secure": false }, "/api3": { - "target": "http://10.3.117.22:8003", + "target": "http://10.3.117.30:8004", "secure": false } } \ No newline at end of file diff --git a/ShopifyUI/src/app/app-routing.module.ts b/ShopifyUI/src/app/app-routing.module.ts index 87ba8af..cd7ebf8 100644 --- a/ShopifyUI/src/app/app-routing.module.ts +++ b/ShopifyUI/src/app/app-routing.module.ts @@ -6,6 +6,7 @@ import { SignUpComponent } from './auth/sign-up/sign-up.component'; import { AdminComponent } from './components/admin/admin.component'; import { CartComponent } from './components/cart/cart.component'; import { HomeComponent } from './components/home/home.component'; +import { OrdersComponent } from './components/orders/orders.component'; import { PaymentsComponent } from './components/payments/payments.component'; import { ProductDetailComponent } from './components/product-detail/product-detail.component'; import { ProductsComponent } from './components/products/products.component'; @@ -17,6 +18,7 @@ const routes: Routes = [ { path: 'products', component: ProductsComponent}, { path: 'products/:product_id', component: ProductDetailComponent}, { path: 'cart/:user_id', component: CartComponent, canActivate:[AuthGuardService] }, + { path: 'orders/:user_id', component: OrdersComponent, canActivate:[AuthGuardService] }, { path: 'payment', component: PaymentsComponent, canActivate: [AuthGuardService]}, { path: 'login', component: LoginComponent}, { path: 'signup', component: SignUpComponent}, diff --git a/ShopifyUI/src/app/auth/login/login.component.html b/ShopifyUI/src/app/auth/login/login.component.html index 1d315c3..3cef7b6 100644 --- a/ShopifyUI/src/app/auth/login/login.component.html +++ b/ShopifyUI/src/app/auth/login/login.component.html @@ -4,10 +4,10 @@

Shopify

- Home +
- Products +
diff --git a/ShopifyUI/src/app/auth/sign-up/sign-up.component.html b/ShopifyUI/src/app/auth/sign-up/sign-up.component.html index 3eb70b5..9c4cf48 100644 --- a/ShopifyUI/src/app/auth/sign-up/sign-up.component.html +++ b/ShopifyUI/src/app/auth/sign-up/sign-up.component.html @@ -4,10 +4,10 @@

Shopify

- Home +
- Products +
diff --git a/ShopifyUI/src/app/components/cart/cart.component.html b/ShopifyUI/src/app/components/cart/cart.component.html index 2a5dbcd..94369d8 100644 --- a/ShopifyUI/src/app/components/cart/cart.component.html +++ b/ShopifyUI/src/app/components/cart/cart.component.html @@ -20,9 +20,9 @@

- - - + + +
@@ -87,10 +87,11 @@
-
+

Total : Rs {{totalPrice}}

-
+
-
\ No newline at end of file +
+

\ No newline at end of file diff --git a/ShopifyUI/src/app/components/home/home.component.html b/ShopifyUI/src/app/components/home/home.component.html index 45117f6..253c7f2 100644 --- a/ShopifyUI/src/app/components/home/home.component.html +++ b/ShopifyUI/src/app/components/home/home.component.html @@ -20,9 +20,9 @@

- - - + + +
diff --git a/ShopifyUI/src/app/components/orders/orders.component.css b/ShopifyUI/src/app/components/orders/orders.component.css index e69de29..326e375 100644 --- a/ShopifyUI/src/app/components/orders/orders.component.css +++ b/ShopifyUI/src/app/components/orders/orders.component.css @@ -0,0 +1,43 @@ +.orders { + margin: 0px auto; +} + +.orderHeading h1 { + font-size: 3em; +} +.order{ + color: #1B4F72; + padding: 12px; + border: 1px solid lightgray; +} + +.data { + overflow-x: hidden; + overflow-y: scroll; + height: 520px; + border: 1px solid lightgray; +} + +.dataheading { + overflow-x: hidden; + overflow-y: scroll; + background-color: #1B4F72; + padding: 12px; +} + +.nd { + background-color: #F39C12; + padding: 6px; + border-radius: 20px; + color: white; +} + +.d { + background-color: #27AE60; + color: white; +} + +.dc { + background-color: #E74C3C; + color: white; +} \ No newline at end of file diff --git a/ShopifyUI/src/app/components/orders/orders.component.html b/ShopifyUI/src/app/components/orders/orders.component.html index 66000b4..db2e0c1 100644 --- a/ShopifyUI/src/app/components/orders/orders.component.html +++ b/ShopifyUI/src/app/components/orders/orders.component.html @@ -1 +1,70 @@ -

orders works!

+ +

+
+
+

MY ORDERS

+
+
+

+
+
+
+
Order Id
+
Order Number
+
Product Name
+
Quantity
+
Price
+
Order Status
+
+
+
+
+
+
+
+
{{o.id}}
+
{{o.orderNumber}}
+
{{o.productName}}
+
{{o.quantity}}
+
{{o.price}}
+
{{o.status}}
+
{{o.status}}
+
{{o.status}}
+
+
+
+
+


\ No newline at end of file diff --git a/ShopifyUI/src/app/components/orders/orders.component.ts b/ShopifyUI/src/app/components/orders/orders.component.ts index 1f2f704..e333665 100644 --- a/ShopifyUI/src/app/components/orders/orders.component.ts +++ b/ShopifyUI/src/app/components/orders/orders.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import { Order } from 'src/app/model/order.model'; +import { CartService } from 'src/app/service/cart.service'; +import { OrderService } from 'src/app/service/order.service'; @Component({ selector: 'app-orders', @@ -7,9 +10,37 @@ import { Component, OnInit } from '@angular/core'; }) export class OrdersComponent implements OnInit { - constructor() { } + uid:any = 0; + username:any=''; + authcode:any=''; + cartNo: number = 0; + orders: Order[]; + constructor(private cartService: CartService, private orderService:OrderService) { } ngOnInit(): void { + this.username = window.sessionStorage.getItem("username"); + this.authcode = window.sessionStorage.getItem("authcode"); + if (this.authcode !== null) { + this.uid = window.sessionStorage.getItem("user_id"); + } + this.cartService.getCartByUser(this.uid).subscribe(data1 => { + this.cartNo = data1.length; + }) + this.orderService.getOrderByUser(this.uid).subscribe(data => { + this.orders = data; + console.log(this.orders) + }) } + onLogout() { + if (this.authcode != null) { + this.authcode = null; + this.username = null; + window.sessionStorage.removeItem("username"); + window.sessionStorage.removeItem("user_id"); + window.sessionStorage.removeItem("authcode"); + window.sessionStorage.removeItem("isLoggedIn"); + this.cartNo = 0; + } + } } diff --git a/ShopifyUI/src/app/components/payments/payments.component.html b/ShopifyUI/src/app/components/payments/payments.component.html index 9961503..d6fcd51 100644 --- a/ShopifyUI/src/app/components/payments/payments.component.html +++ b/ShopifyUI/src/app/components/payments/payments.component.html @@ -43,6 +43,6 @@

- +
\ No newline at end of file diff --git a/ShopifyUI/src/app/components/payments/payments.component.ts b/ShopifyUI/src/app/components/payments/payments.component.ts index 6836d88..b80a099 100644 --- a/ShopifyUI/src/app/components/payments/payments.component.ts +++ b/ShopifyUI/src/app/components/payments/payments.component.ts @@ -1,6 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; import { Cart } from 'src/app/model/cart.model'; +import { Order } from 'src/app/model/order.model'; import { CartService } from 'src/app/service/cart.service'; +import { OrderService } from 'src/app/service/order.service'; @Component({ selector: 'app-payments', @@ -9,17 +12,20 @@ import { CartService } from 'src/app/service/cart.service'; }) export class PaymentsComponent implements OnInit { - uid:number = 1; + uid:any = 0; cartNo: number = 0; cartItems: Cart[] = []; totalPrice: number = 0; username:any = ''; authcode:any = ''; - constructor(private cartService: CartService) { } + constructor(private cartService: CartService,private orderService: OrderService, private route:Router) { } ngOnInit(): void { this.username = window.sessionStorage.getItem("username"); this.authcode = window.sessionStorage.getItem("authcode"); + if (this.authcode !== null) { + this.uid = window.sessionStorage.getItem("user_id"); + } this.cartService.getCartByUser(this.uid).subscribe(data1 => { this.cartNo = data1.length; this.cartItems=data1; @@ -30,6 +36,15 @@ export class PaymentsComponent implements OnInit { }) } + addOrder() { + let order:Order = { + status: "Not Delivered" + } + this.orderService.postOrder(this.uid,order).subscribe(data => { + }) + this.route.navigateByUrl("/orders/" + this.uid); + } + onLogout() { if (this.authcode != null) { this.authcode = null; diff --git a/ShopifyUI/src/app/components/product-detail/product-detail.component.html b/ShopifyUI/src/app/components/product-detail/product-detail.component.html index d3ab0d6..6f20d2b 100644 --- a/ShopifyUI/src/app/components/product-detail/product-detail.component.html +++ b/ShopifyUI/src/app/components/product-detail/product-detail.component.html @@ -20,9 +20,9 @@

- - - + + +
@@ -95,7 +95,7 @@

Submit Your Review


-
+
diff --git a/ShopifyUI/src/app/components/product-detail/product-detail.component.ts b/ShopifyUI/src/app/components/product-detail/product-detail.component.ts index cd00d44..a05bac9 100644 --- a/ShopifyUI/src/app/components/product-detail/product-detail.component.ts +++ b/ShopifyUI/src/app/components/product-detail/product-detail.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { Cart } from 'src/app/model/cart.model'; import { Product } from 'src/app/model/product.model'; import { Review } from 'src/app/model/review.model'; @@ -26,7 +26,7 @@ export class ProductDetailComponent implements OnInit { reviewForm: FormGroup; username:any=''; authcode:any=''; - constructor(private actRouter:ActivatedRoute, private productService:ProductService, private cartService:CartService,private reviewService:ReviewService) { + constructor(private actRouter:ActivatedRoute, private productService:ProductService, private cartService:CartService,private reviewService:ReviewService, private route: Router) { this.reviewForm = new FormGroup({ reviewText : new FormControl(''), rating : new FormControl(''), @@ -70,17 +70,22 @@ export class ProductDetailComponent implements OnInit { } addToCart(discountedPrice: number) { - console.log("addtocart") - let cartData:Cart = { - quantity : this.quantity, - price: discountedPrice - } - console.log(cartData) - this.cartService.postCart(cartData,this.uid,this.pid).subscribe(data => { - this.cartService.getCartByUser(this.uid).subscribe(data1 => { - this.cartNo = data1.length; + if (this.authcode != null) { + console.log("addtocart") + let cartData:Cart = { + quantity : this.quantity, + price: discountedPrice + } + console.log(cartData) + this.cartService.postCart(cartData,this.uid,this.pid).subscribe(data => { + this.cartService.getCartByUser(this.uid).subscribe(data1 => { + this.cartNo = data1.length; + }) }) - }) + } + else { + this.route.navigateByUrl("/login") + } } onReviewFormSubmit() { @@ -119,6 +124,7 @@ export class ProductDetailComponent implements OnInit { window.sessionStorage.removeItem("authcode"); window.sessionStorage.removeItem("isLoggedIn"); this.cartNo = 0; + this.route.navigateByUrl("/home"); } } } diff --git a/ShopifyUI/src/app/components/products/products.component.html b/ShopifyUI/src/app/components/products/products.component.html index d24d1f7..612ad5c 100644 --- a/ShopifyUI/src/app/components/products/products.component.html +++ b/ShopifyUI/src/app/components/products/products.component.html @@ -20,9 +20,9 @@

- - - + + +
diff --git a/ShopifyUI/src/app/components/products/products.component.ts b/ShopifyUI/src/app/components/products/products.component.ts index 56f830b..c4ae75e 100644 --- a/ShopifyUI/src/app/components/products/products.component.ts +++ b/ShopifyUI/src/app/components/products/products.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; import { Cart } from 'src/app/model/cart.model'; import { Product } from 'src/app/model/product.model'; import { CartService } from 'src/app/service/cart.service'; @@ -20,7 +21,7 @@ export class ProductsComponent implements OnInit { uid:any = 0; username:any=''; authcode:any=''; - constructor(private productService: ProductService,private cartService: CartService) { + constructor(private productService: ProductService,private cartService: CartService, private route: Router) { this.searchForm = new FormGroup({ prodName: new FormControl('') }) @@ -54,15 +55,20 @@ export class ProductsComponent implements OnInit { addToCart(discountedPrice: number,pid:number) { console.log("addtocart") - let cartData:Cart = { - quantity : 1, - price: discountedPrice - } - this.cartService.postCart(cartData,this.uid,pid).subscribe(data => { - this.cartService.getCartByUser(this.uid).subscribe(data1 => { - this.cartNo = data1.length; + if (this.authcode != null) { + let cartData:Cart = { + quantity : 1, + price: discountedPrice + } + this.cartService.postCart(cartData,this.uid,pid).subscribe(data => { + this.cartService.getCartByUser(this.uid).subscribe(data1 => { + this.cartNo = data1.length; + }) }) - }) + } + else { + this.route.navigateByUrl("/login"); + } } onLogout() { diff --git a/ShopifyUI/src/app/components/userprofile/userprofile.component.css b/ShopifyUI/src/app/components/userprofile/userprofile.component.css index cea9660..a06c881 100644 --- a/ShopifyUI/src/app/components/userprofile/userprofile.component.css +++ b/ShopifyUI/src/app/components/userprofile/userprofile.component.css @@ -1,8 +1,3 @@ -.activeBtn { - background-color: #1B4F72; - color: white; -} - .container { margin: 0px auto; } diff --git a/ShopifyUI/src/app/components/userprofile/userprofile.component.html b/ShopifyUI/src/app/components/userprofile/userprofile.component.html index 1c9d4a9..d63d15b 100644 --- a/ShopifyUI/src/app/components/userprofile/userprofile.component.html +++ b/ShopifyUI/src/app/components/userprofile/userprofile.component.html @@ -20,9 +20,9 @@

- - - + + +
diff --git a/ShopifyUI/src/app/model/order.model.ts b/ShopifyUI/src/app/model/order.model.ts index e69de29..eade3dc 100644 --- a/ShopifyUI/src/app/model/order.model.ts +++ b/ShopifyUI/src/app/model/order.model.ts @@ -0,0 +1,11 @@ +export class Order { + id?: number; + quantity?: number; + price?: number; + status?: string; + orderNumber?: number; + userId?: number; + productId?: number; + username?: string; + productName?: string; +} \ No newline at end of file diff --git a/ShopifyUI/src/app/service/order.service.ts b/ShopifyUI/src/app/service/order.service.ts index c20ec33..d6127a3 100644 --- a/ShopifyUI/src/app/service/order.service.ts +++ b/ShopifyUI/src/app/service/order.service.ts @@ -1,9 +1,24 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { Order } from '../model/order.model'; @Injectable({ providedIn: 'root' }) export class OrderService { - constructor() { } + path:String = "http://localhost:59279/api3"; + + constructor(private httpClient:HttpClient) { } + + public postOrder(uid:number, order:Order): Observable { + let order_post_api = this.path + "/order/" + uid; + return this.httpClient.post(order_post_api,order); + } + + public getOrderByUser(uid:number): Observable { + let order_get_api = this.path + "/order/" + uid; + return this.httpClient.get(order_get_api); + } } diff --git a/ShopifyUI/src/styles.css b/ShopifyUI/src/styles.css index 2971ba9..c51fdda 100644 --- a/ShopifyUI/src/styles.css +++ b/ShopifyUI/src/styles.css @@ -94,4 +94,10 @@ body { background-color: #1B4F72; color: white; padding-top: 10px; +} + +/* For Dropdown */ +.activeBtn { + background-color: #1B4F72; + color: white; } \ No newline at end of file