-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3081847
commit d533154
Showing
11 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
<div class="bg-info p-2 text-white"> | ||
<h3>Placeholder for Admin Features</h3> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col bg-dark text-white"> | ||
<a class="navbar-brand">SPORTS STORE</a> | ||
</div> | ||
</div> | ||
<div class="row mt-2"> | ||
<div class="col-3"> | ||
<div class="d-grid gap-2"> | ||
<button class="btn btn-outline-info btn-block" | ||
routerLink="/admin/main/products" routerLinkActive="active"> | ||
Products | ||
</button> | ||
<button class="btn btn-outline-info btn-block" | ||
routerLink="/admin/main/orders" routerLinkActive="active"> | ||
Orders | ||
</button> | ||
<button class="btn btn-outline-danger btn-block" | ||
(click)="logout()"> | ||
Logout | ||
</button> | ||
</div> | ||
</div> | ||
<div class="col-9"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import { Component } from "@angular/core"; | ||
import { Router } from "@angular/router"; | ||
import { AuthService } from "../model/auth.service"; | ||
|
||
@Component({ | ||
templateUrl: "admin.component.html" | ||
}) | ||
|
||
export class AdminComponent {} | ||
export class AdminComponent { | ||
|
||
constructor(private auth: AuthService, private router: Router) {} | ||
|
||
logout() { | ||
this.auth.clear(); | ||
this.router.navigateByUrl("/"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
template: `<div class="bg-info p-2 text-white"><h3>Order Table placeholder</h3></div>` | ||
}) | ||
|
||
export class OrderTableComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
template: `<div class="bg-info p-2 text-white"><h3>Product Editor placeholder</h3></div>` | ||
}) | ||
|
||
export class ProductEditorComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
template: `<div class="bg-info p-2 text-white"><h3>Product Table placeholder</h3></div>` | ||
}) | ||
|
||
export class ProductTableComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { Observable } from "rxjs"; | ||
import { Order } from "./order.model"; | ||
import { StaticDataSource } from "./static.datasource"; | ||
//import { StaticDataSource } from "./static.datasource"; | ||
import { RestDataSource } from "./rest.datasource"; | ||
|
||
@Injectable() | ||
export class OrderRepository { | ||
|
||
private orders: Order[] = []; | ||
private loaded: boolean = false; | ||
|
||
constructor(private dataSource: StaticDataSource) {} | ||
constructor(private dataSource: RestDataSource) {} | ||
|
||
loadOrders() { | ||
this.loaded = true; | ||
this.dataSource.getOrders().subscribe(o => { | ||
this.orders = o; | ||
}); | ||
} | ||
|
||
getOrders(): Order[] { | ||
if (!this.loaded) { | ||
this.loadOrders(); | ||
} | ||
return this.orders; | ||
} | ||
|
||
saveOrder(order: Order): Observable<Order> { | ||
return this.dataSource.saveOrder(order); | ||
} | ||
|
||
updateOrder(order: Order) { | ||
this.dataSource.updateOrder(order).subscribe(o => { | ||
this.orders.splice(this.orders.findIndex(o => o.id = order.id), 1, order); | ||
}) | ||
} | ||
|
||
deleteOrder(id: number) { | ||
this.dataSource.deleteOrder(id).subscribe(o => { | ||
this.orders.splice(this.orders.findIndex(o => o.id == id), 1); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters