├── src ├── assets │ └── .gitkeep ├── app │ ├── app.component.css │ ├── features │ │ └── admin │ │ │ └── pages │ │ │ ├── navi │ │ │ ├── navi.component.css │ │ │ ├── navi.component.html │ │ │ ├── navi.component.spec.ts │ │ │ └── navi.component.ts │ │ │ ├── login │ │ │ ├── login.component.css │ │ │ ├── login.component.html │ │ │ ├── login.component.ts │ │ │ └── login.component.spec.ts │ │ │ ├── product │ │ │ ├── product.component.css │ │ │ ├── product.component.spec.ts │ │ │ ├── product.component.html │ │ │ └── product.component.ts │ │ │ ├── category │ │ │ ├── category.component.css │ │ │ ├── category.component.html │ │ │ ├── category.component.spec.ts │ │ │ └── category.component.ts │ │ │ ├── cart-summary │ │ │ ├── cart-summary.component.css │ │ │ ├── cart-summary.component.html │ │ │ ├── cart-summary.component.spec.ts │ │ │ └── cart-summary.component.ts │ │ │ ├── product-add │ │ │ ├── product-add.component.css │ │ │ ├── product-add.component.spec.ts │ │ │ ├── product-add.component.ts │ │ │ └── product-add.component.html │ │ │ └── product-detail │ │ │ ├── product-detail.component.css │ │ │ ├── product-detail.component.html │ │ │ ├── product-detail.component.spec.ts │ │ │ └── product-detail.component.ts │ ├── core │ │ ├── models │ │ │ ├── loginModel.ts │ │ │ ├── tokenModel.ts │ │ │ ├── categoryListModel.ts │ │ │ ├── productAddModel.ts │ │ │ └── productDetailModel.ts │ │ ├── services │ │ │ ├── auth.service.spec.ts │ │ │ ├── product.service.spec.ts │ │ │ ├── category.service.spec.ts │ │ │ ├── category.service.ts │ │ │ ├── auth.service.ts │ │ │ └── product.service.ts │ │ ├── interceptors │ │ │ ├── auth.interceptor.spec.ts │ │ │ └── auth.interceptor.ts │ │ └── store │ │ │ ├── cart-reducer.ts │ │ │ └── cart-actions.ts │ ├── app.component.ts │ ├── app.component.html │ ├── app-routing.module.ts │ ├── app.component.spec.ts │ └── app.module.ts ├── favicon.ico ├── styles.css ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── index.html ├── main.ts ├── test.ts └── polyfills.ts ├── .vscode ├── extensions.json ├── launch.json └── tasks.json ├── .editorconfig ├── tsconfig.app.json ├── tsconfig.spec.json ├── .browserslistrc ├── .gitignore ├── tsconfig.json ├── README.md ├── package.json ├── karma.conf.js └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/navi/navi.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/login/login.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product/product.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/category/category.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/cart-summary/cart-summary.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-add/product-add.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-detail/product-detail.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/login/login.component.html: -------------------------------------------------------------------------------- 1 |

login works!

2 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engindemirog/etrade/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/app/core/models/loginModel.ts: -------------------------------------------------------------------------------- 1 | export interface LoginModel{ 2 | email:string; 3 | password:string; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/core/models/tokenModel.ts: -------------------------------------------------------------------------------- 1 | export interface TokenModel{ 2 | token:string; 3 | expiration:string; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/core/models/categoryListModel.ts: -------------------------------------------------------------------------------- 1 | export interface CategoryListModel{ 2 | categoryId:number; 3 | categoryName:string; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/navi/navi.component.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /src/app/core/models/productAddModel.ts: -------------------------------------------------------------------------------- 1 | export default interface ProductAddModel{ 2 | categoryId: number 3 | productName: string 4 | unitPrice: number 5 | unitsInStock: number 6 | quantityPerUnit: string 7 | } 8 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/cart-summary/cart-summary.component.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /src/app/core/models/productDetailModel.ts: -------------------------------------------------------------------------------- 1 | export default interface ProductDetailModel{ 2 | productId: number 3 | categoryName: string 4 | productName: string 5 | unitPrice: number 6 | unitsInStock: number 7 | quantityPerUnit: string 8 | } 9 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/category/category.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'etrade'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | 6 |
7 |
8 | 9 |
10 |
11 |
12 | 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Etrade 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/app/core/services/auth.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthService } from './auth.service'; 4 | 5 | describe('AuthService', () => { 6 | let service: AuthService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(AuthService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/core/services/product.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductService } from './product.service'; 4 | 5 | describe('ProductService', () => { 6 | let service: ProductService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(ProductService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/core/services/category.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { CategoryService } from './category.service'; 4 | 5 | describe('CategoryService', () => { 6 | let service: CategoryService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(CategoryService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-detail/product-detail.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | {{product.productName}} 5 | 6 | {{product.categoryName}} 7 | 8 | {{product.unitPrice}} 9 | 10 | 11 |
12 | 13 |

Ürün bulunamadı

14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/app/core/interceptors/auth.interceptor.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthInterceptor } from './auth.interceptor'; 4 | 5 | describe('AuthInterceptor', () => { 6 | beforeEach(() => TestBed.configureTestingModule({ 7 | providers: [ 8 | AuthInterceptor 9 | ] 10 | })); 11 | 12 | it('should be created', () => { 13 | const interceptor: AuthInterceptor = TestBed.inject(AuthInterceptor); 14 | expect(interceptor).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/app/core/store/cart-reducer.ts: -------------------------------------------------------------------------------- 1 | import ProductAddModel from "../models/productAddModel"; 2 | import { CartActions, CartActionTypes } from "./cart-actions"; 3 | 4 | export let initialState : ProductAddModel[]=[]; 5 | 6 | export function cartReducer(state=initialState,action:CartActions){ 7 | switch (action.type) { 8 | case CartActionTypes.ADD_PRODUCT: 9 | return [...state,action.payload] 10 | case CartActionTypes.REMOVE_PRODUCT: 11 | let product = action.payload; 12 | return state.filter((p)=>p.productName!=product.productName) 13 | default: 14 | return state; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/app/core/services/category.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient } from '@angular/common/http'; 2 | import { Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs/internal/Observable'; 4 | import { CategoryListModel } from '../models/categoryListModel'; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class CategoryService { 10 | apiUrl:string ="http://localhost:5026/api/Categories/getall"; 11 | 12 | constructor(private httpClient : HttpClient) { } 13 | 14 | getAll():Observable{ 15 | return this.httpClient.get(this.apiUrl); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /src/app/core/services/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient } from '@angular/common/http'; 2 | import { Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import { LoginModel } from '../models/loginModel'; 5 | import { TokenModel } from '../models/tokenModel'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class AuthService { 11 | apiUrl:string ="http://localhost:5026/api/auth/"; 12 | constructor(private httpClient:HttpClient) { } 13 | 14 | login(loginModel:LoginModel):Observable{ 15 | return this.httpClient.post(this.apiUrl+"login",loginModel); 16 | } 17 | 18 | isAuthenticated(){ 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/app/core/store/cart-actions.ts: -------------------------------------------------------------------------------- 1 | import { Action } from "@ngrx/store"; 2 | import ProductAddModel from "../models/productAddModel"; 3 | 4 | 5 | export enum CartActionTypes{ 6 | ADD_PRODUCT ="ADD_PRODUCT", 7 | REMOVE_PRODUCT="REMOVE_PRODUCT" 8 | } 9 | 10 | export class AddProduct implements Action{ 11 | readonly type: string = CartActionTypes.ADD_PRODUCT; 12 | 13 | constructor(public payload:ProductAddModel){ 14 | 15 | } 16 | 17 | } 18 | 19 | export class RemoveProduct implements Action{ 20 | readonly type: string = CartActionTypes.REMOVE_PRODUCT; 21 | 22 | constructor(public payload:ProductAddModel){ 23 | 24 | } 25 | 26 | } 27 | 28 | export type CartActions = AddProduct | RemoveProduct 29 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/login/login.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { AuthService } from 'src/app/core/services/auth.service'; 3 | 4 | @Component({ 5 | selector: 'app-login', 6 | templateUrl: './login.component.html', 7 | styleUrls: ['./login.component.css'] 8 | }) 9 | export class LoginComponent implements OnInit { 10 | 11 | constructor(private authService:AuthService) { } 12 | 13 | ngOnInit(): void { 14 | this.authService.login({email:"engin@engin.com",password:"12345"}) 15 | .subscribe(data=>{ 16 | localStorage.setItem("token",data.token) 17 | },responseError=>{ 18 | console.log(responseError.error) 19 | }) 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /src/app/core/interceptors/auth.interceptor.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { 3 | HttpRequest, 4 | HttpHandler, 5 | HttpEvent, 6 | HttpInterceptor 7 | } from '@angular/common/http'; 8 | import { Observable } from 'rxjs'; 9 | 10 | @Injectable() 11 | export class AuthInterceptor implements HttpInterceptor { 12 | 13 | constructor() {} 14 | 15 | intercept(request: HttpRequest, next: HttpHandler): Observable> { 16 | 17 | let token = localStorage.getItem("token"); 18 | let newRequest : HttpRequest; 19 | newRequest = request.clone({ 20 | headers:request.headers.set("Authorization","Bearer "+token) 21 | }) 22 | return next.handle(newRequest); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/navi/navi.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NaviComponent } from './navi.component'; 4 | 5 | describe('NaviComponent', () => { 6 | let component: NaviComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ NaviComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NaviComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ LoginComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(LoginComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product/product.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductComponent } from './product.component'; 4 | 5 | describe('ProductComponent', () => { 6 | let component: ProductComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/category/category.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CategoryComponent } from './category.component'; 4 | 5 | describe('CategoryComponent', () => { 6 | let component: CategoryComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ CategoryComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CategoryComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-add/product-add.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductAddComponent } from './product-add.component'; 4 | 5 | describe('ProductAddComponent', () => { 6 | let component: ProductAddComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductAddComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductAddComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/cart-summary/cart-summary.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CartSummaryComponent } from './cart-summary.component'; 4 | 5 | describe('CartSummaryComponent', () => { 6 | let component: CartSummaryComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ CartSummaryComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CartSummaryComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/cart-summary/cart-summary.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Store } from '@ngrx/store'; 3 | import ProductAddModel from 'src/app/core/models/productAddModel'; 4 | import { RemoveProduct } from 'src/app/core/store/cart-actions'; 5 | 6 | @Component({ 7 | selector: 'app-cart-summary', 8 | templateUrl: './cart-summary.component.html', 9 | styleUrls: ['./cart-summary.component.css'] 10 | }) 11 | export class CartSummaryComponent implements OnInit { 12 | cart :ProductAddModel[] 13 | constructor(private store:Store) { } 14 | 15 | ngOnInit(): void { 16 | this.store.select("cartReducer").subscribe(state=>this.cart = state) 17 | } 18 | 19 | removeFromCart(product:ProductAddModel){ 20 | this.store.dispatch(new RemoveProduct(product)) 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-detail/product-detail.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductDetailComponent } from './product-detail.component'; 4 | 5 | describe('ProductDetailComponent', () => { 6 | let component: ProductDetailComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductDetailComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductDetailComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/navi/navi.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {MenuItem} from 'primeng/api'; 3 | 4 | @Component({ 5 | selector: 'app-navi', 6 | templateUrl: './navi.component.html', 7 | styleUrls: ['./navi.component.css'] 8 | }) 9 | export class NaviComponent implements OnInit { 10 | 11 | items: MenuItem[]; 12 | activeItem: MenuItem; 13 | 14 | ngOnInit() { 15 | this.items = [ 16 | {label: 'Home', icon: 'pi pi-fw pi-home'}, 17 | {label: 'Calendar', icon: 'pi pi-fw pi-calendar'}, 18 | {label: 'Edit', icon: 'pi pi-fw pi-pencil'}, 19 | {label: 'Documentation', icon: 'pi pi-fw pi-file'}, 20 | {label: 'Settings', icon: 'pi pi-fw pi-cog'} 21 | ]; 22 | 23 | this.activeItem = this.items[3]; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().map(context); 27 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-detail/product-detail.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { ActivatedRoute } from '@angular/router'; 3 | import ProductDetailModel from 'src/app/core/models/productDetailModel'; 4 | import { ProductService } from 'src/app/core/services/product.service'; 5 | 6 | @Component({ 7 | selector: 'app-product-detail', 8 | templateUrl: './product-detail.component.html', 9 | styleUrls: ['./product-detail.component.css'] 10 | }) 11 | export class ProductDetailComponent implements OnInit { 12 | 13 | product:ProductDetailModel 14 | 15 | constructor(private activatedRoute:ActivatedRoute 16 | , private productService:ProductService) { } 17 | 18 | ngOnInit(): void { 19 | this.activatedRoute.params.subscribe(params=>{ 20 | this.productService.getById(params["id"]).subscribe(data=>{ 21 | this.product = data; 22 | }) 23 | }) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/category/category.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | import { CategoryListModel } from 'src/app/core/models/categoryListModel'; 4 | import { CategoryService } from 'src/app/core/services/category.service'; 5 | 6 | @Component({ 7 | selector: 'app-category', 8 | templateUrl: './category.component.html', 9 | styleUrls: ['./category.component.css'] 10 | }) 11 | export class CategoryComponent implements OnInit { 12 | 13 | categories: CategoryListModel[]; 14 | selectedCategory: CategoryListModel; 15 | 16 | constructor(private categoryService:CategoryService, private router:Router) { } 17 | 18 | ngOnInit(): void { 19 | this.categoryService.getAll().subscribe(data=>{ 20 | this.categories = data; 21 | }) 22 | } 23 | 24 | selectCategory(){ 25 | this.router.navigateByUrl("/products/category/"+this.selectedCategory.categoryId) 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": false, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2017", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product/product.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 | 6 | 7 | 8 | Id 9 | Name 10 | Category Name 11 | Quantity 12 | Unit Price 13 | Units In Stock 14 | 15 | 16 | 17 | 18 | 19 | {{product.productId}} 20 | {{product.productName}} 21 | {{product.categoryName}} 22 | {{product.quantityPerUnit}} 23 | {{product.unitPrice}} 24 | {{product.unitsInStock}} 25 | Sepete ekle 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { LoginComponent } from './features/admin/pages/login/login.component'; 4 | import { ProductAddComponent } from './features/admin/pages/product-add/product-add.component'; 5 | import { ProductDetailComponent } from './features/admin/pages/product-detail/product-detail.component'; 6 | import { ProductComponent } from './features/admin/pages/product/product.component'; 7 | 8 | const routes: Routes = [ 9 | {path:"", pathMatch:"full", component:ProductComponent}, 10 | {path:"products", component:ProductComponent}, 11 | {path:"products/category/:categoryid", component:ProductComponent}, 12 | {path:"productdetail/:id", component:ProductDetailComponent}, 13 | {path:"productadd", component:ProductAddComponent}, 14 | {path:"login", component:LoginComponent} 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [RouterModule.forRoot(routes)], 19 | exports: [RouterModule] 20 | }) 21 | export class AppRoutingModule { } 22 | -------------------------------------------------------------------------------- /src/app/core/services/product.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient } from '@angular/common/http'; 2 | import { Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import ProductAddModel from '../models/productAddModel'; 5 | import ProductDetailModel from '../models/productDetailModel'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class ProductService { 11 | apiUrl:string ="http://localhost:5026/api/Products/"; 12 | //http://localhost:5026/api/Products/getallbycategory/2 13 | constructor(private httpClient : HttpClient) { } 14 | 15 | getAll():Observable{ 16 | return this.httpClient.get>(this.apiUrl+"getall"); 17 | } 18 | 19 | getById(id:number):Observable{ 20 | return this.httpClient.get(this.apiUrl+"getbyid/"+id); 21 | } 22 | 23 | getByCategory(categoryid:number){ 24 | return this.httpClient.get(this.apiUrl+"getallbycategory/"+categoryid); 25 | } 26 | 27 | add(product:ProductAddModel){ 28 | return this.httpClient.post(this.apiUrl+"add",product) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Etrade 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.6. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'etrade'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('etrade'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement as HTMLElement; 33 | expect(compiled.querySelector('.content span')?.textContent).toContain('etrade app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product/product.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { ActivatedRoute } from '@angular/router'; 3 | import { Store } from '@ngrx/store'; 4 | import { ProductService } from 'src/app/core/services/product.service'; 5 | import { AddProduct, CartActionTypes } from 'src/app/core/store/cart-actions'; 6 | 7 | @Component({ 8 | selector: 'app-product', 9 | templateUrl: './product.component.html', 10 | styleUrls: ['./product.component.css'] 11 | }) 12 | export class ProductComponent implements OnInit { 13 | products: any = [] 14 | isLoading: boolean = true 15 | 16 | constructor(private productService: ProductService, 17 | private activatedRoute: ActivatedRoute, 18 | private store:Store) { } 19 | 20 | ngOnInit(): void { 21 | 22 | this.activatedRoute.params.subscribe(params => { 23 | if (params["categoryid"]) { 24 | this.productService.getByCategory(params["categoryid"]).subscribe(data => { 25 | this.isLoading = true 26 | this.products = data; 27 | this.isLoading = false 28 | }) 29 | } else { 30 | this.productService.getAll().subscribe(data => { 31 | this.isLoading = true 32 | this.products = data; 33 | this.isLoading = false 34 | }) 35 | } 36 | }) 37 | 38 | 39 | } 40 | 41 | addToCart(product){ 42 | this.store.dispatch(new AddProduct(product)) 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "etrade", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "~13.2.0", 14 | "@angular/cdk": "^13.3.0", 15 | "@angular/common": "~13.2.0", 16 | "@angular/compiler": "~13.2.0", 17 | "@angular/core": "~13.2.0", 18 | "@angular/forms": "~13.2.0", 19 | "@angular/platform-browser": "~13.2.0", 20 | "@angular/platform-browser-dynamic": "~13.2.0", 21 | "@angular/router": "~13.2.0", 22 | "@ngrx/store": "^13.1.0", 23 | "@ngrx/store-devtools": "^13.1.0", 24 | "bootstrap": "^5.1.3", 25 | "jquery": "^3.6.0", 26 | "primeicons": "^5.0.0", 27 | "primeng": "^13.3.0", 28 | "rxjs": "~7.5.0", 29 | "tslib": "^2.3.0", 30 | "zone.js": "~0.11.4" 31 | }, 32 | "devDependencies": { 33 | "@angular-devkit/build-angular": "~13.2.6", 34 | "@angular/cli": "~13.2.6", 35 | "@angular/compiler-cli": "~13.2.0", 36 | "@types/jasmine": "~3.10.0", 37 | "@types/node": "^12.11.1", 38 | "jasmine-core": "~4.0.0", 39 | "karma": "~6.3.0", 40 | "karma-chrome-launcher": "~3.1.0", 41 | "karma-coverage": "~2.1.0", 42 | "karma-jasmine": "~4.0.0", 43 | "karma-jasmine-html-reporter": "~1.7.0", 44 | "typescript": "~4.5.2" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/etrade'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-add/product-add.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; 3 | import { ConfirmationService } from 'primeng/api'; 4 | import { ProductService } from 'src/app/core/services/product.service'; 5 | import {MessageService} from 'primeng/api'; 6 | 7 | @Component({ 8 | selector: 'app-product-add', 9 | templateUrl: './product-add.component.html', 10 | styleUrls: ['./product-add.component.css'], 11 | providers:[ConfirmationService,MessageService] 12 | }) 13 | export class ProductAddComponent implements OnInit { 14 | 15 | productAddForm: FormGroup; 16 | 17 | constructor(private formBuilder: FormBuilder, 18 | private productService: ProductService, 19 | private confirmationService: ConfirmationService, 20 | private messageService: MessageService) { } 21 | 22 | ngOnInit(): void { 23 | this.createProductAddForm(); 24 | } 25 | 26 | createProductAddForm() { 27 | this.productAddForm = this.formBuilder.group({ 28 | productName: ["", [Validators.required, Validators.minLength(2)]], 29 | unitPrice: ["", Validators.required], 30 | unitsInStock: ["", Validators.required], 31 | categoryId: ["", Validators.required], 32 | quantityPerUnit: ["", Validators.required] 33 | }) 34 | } 35 | 36 | add() { 37 | this.confirmationService.confirm({ 38 | message: 'Are you sure that you want to perform this action?', 39 | accept: () => { 40 | if (this.productAddForm.valid) { 41 | this.productService.add(this.productAddForm.value).subscribe(data => { 42 | this.messageService.add({severity:'success', summary: 'Başarılı!', detail: 'Ürün eklendi'}); 43 | }) 44 | } else { 45 | this.messageService.add({severity:'error', summary: 'Hata!', detail: 'Form geçersiz'}); 46 | } 47 | } 48 | }); 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/app/features/admin/pages/product-add/product-add.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
Ürün ekle
6 |
7 |
8 |
9 |
10 | 11 |
12 | 14 |
15 |
16 |
17 | 18 |
19 | 21 |
22 |
23 |
24 | 25 |
26 | 28 |
29 |
30 |
31 | 32 |
33 | 35 |
36 |
37 |
38 | 39 |
40 | 42 |
43 |
44 |
45 |
46 | 49 |
50 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import {HttpClientModule, HTTP_INTERCEPTORS} from "@angular/common/http" 4 | import { FormsModule,ReactiveFormsModule } from '@angular/forms'; 5 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; 6 | 7 | import { AppRoutingModule } from './app-routing.module'; 8 | import { AppComponent } from './app.component'; 9 | import { ProductComponent } from './features/admin/pages/product/product.component'; 10 | import { NaviComponent } from './features/admin/pages/navi/navi.component'; 11 | import { CategoryComponent } from './features/admin/pages/category/category.component'; 12 | 13 | import {TabMenuModule} from 'primeng/tabmenu'; 14 | import {TableModule} from 'primeng/table'; 15 | import {ProgressSpinnerModule} from 'primeng/progressspinner'; 16 | import {ListboxModule} from 'primeng/listbox'; 17 | import {CardModule} from 'primeng/card'; 18 | import {ConfirmDialogModule} from 'primeng/confirmdialog'; 19 | import {ToastModule} from 'primeng/toast'; 20 | 21 | import { ProductDetailComponent } from './features/admin/pages/product-detail/product-detail.component'; 22 | import { ProductAddComponent } from './features/admin/pages/product-add/product-add.component'; 23 | import { LoginComponent } from './features/admin/pages/login/login.component'; 24 | import { AuthInterceptor } from './core/interceptors/auth.interceptor'; 25 | import { StoreModule } from '@ngrx/store'; 26 | import { cartReducer } from './core/store/cart-reducer'; 27 | import { CartSummaryComponent } from './features/admin/pages/cart-summary/cart-summary.component'; 28 | 29 | @NgModule({ 30 | declarations: [ 31 | AppComponent, 32 | ProductComponent, 33 | NaviComponent, 34 | CategoryComponent, 35 | ProductDetailComponent, 36 | ProductAddComponent, 37 | LoginComponent, 38 | CartSummaryComponent 39 | 40 | ], 41 | imports: [ 42 | BrowserModule, 43 | AppRoutingModule, 44 | TabMenuModule, 45 | TableModule, 46 | HttpClientModule, 47 | ProgressSpinnerModule, 48 | ListboxModule, 49 | FormsModule, 50 | CardModule, 51 | ReactiveFormsModule, 52 | ConfirmDialogModule, 53 | BrowserAnimationsModule, 54 | ToastModule, 55 | StoreModule.forRoot({cartReducer:cartReducer}) 56 | ], 57 | providers: [ 58 | {provide:HTTP_INTERCEPTORS,useClass:AuthInterceptor, multi:true} 59 | ], 60 | bootstrap: [AppComponent] 61 | }) 62 | export class AppModule { } 63 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes recent versions of Safari, Chrome (including 12 | * Opera), Edge on the desktop, and iOS and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | /*************************************************************************************************** 46 | * Zone JS is required by default for Angular itself. 47 | */ 48 | import 'zone.js'; // Included with Angular CLI. 49 | 50 | 51 | /*************************************************************************************************** 52 | * APPLICATION IMPORTS 53 | */ 54 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "etrade": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:application": { 10 | "strict": true 11 | } 12 | }, 13 | "root": "", 14 | "sourceRoot": "src", 15 | "prefix": "app", 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/etrade", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "./node_modules/bootstrap/dist/css/bootstrap.min.css", 31 | "node_modules/primeng/resources/themes/saga-blue/theme.css", 32 | "node_modules/primeng/resources/primeng.min.css", 33 | "node_modules/primeicons/primeicons.css", 34 | "src/styles.css" 35 | ], 36 | "scripts": [ 37 | "./node_modules/jquery/dist/jquery.min.js", 38 | "./node_modules/bootstrap/dist/js/bootstrap.min.js" 39 | ] 40 | }, 41 | "configurations": { 42 | "production": { 43 | "budgets": [ 44 | { 45 | "type": "initial", 46 | "maximumWarning": "500kb", 47 | "maximumError": "1mb" 48 | }, 49 | { 50 | "type": "anyComponentStyle", 51 | "maximumWarning": "2kb", 52 | "maximumError": "4kb" 53 | } 54 | ], 55 | "fileReplacements": [ 56 | { 57 | "replace": "src/environments/environment.ts", 58 | "with": "src/environments/environment.prod.ts" 59 | } 60 | ], 61 | "outputHashing": "all" 62 | }, 63 | "development": { 64 | "buildOptimizer": false, 65 | "optimization": false, 66 | "vendorChunk": true, 67 | "extractLicenses": false, 68 | "sourceMap": true, 69 | "namedChunks": true 70 | } 71 | }, 72 | "defaultConfiguration": "production" 73 | }, 74 | "serve": { 75 | "builder": "@angular-devkit/build-angular:dev-server", 76 | "configurations": { 77 | "production": { 78 | "browserTarget": "etrade:build:production" 79 | }, 80 | "development": { 81 | "browserTarget": "etrade:build:development" 82 | } 83 | }, 84 | "defaultConfiguration": "development" 85 | }, 86 | "extract-i18n": { 87 | "builder": "@angular-devkit/build-angular:extract-i18n", 88 | "options": { 89 | "browserTarget": "etrade:build" 90 | } 91 | }, 92 | "test": { 93 | "builder": "@angular-devkit/build-angular:karma", 94 | "options": { 95 | "main": "src/test.ts", 96 | "polyfills": "src/polyfills.ts", 97 | "tsConfig": "tsconfig.spec.json", 98 | "karmaConfig": "karma.conf.js", 99 | "assets": [ 100 | "src/favicon.ico", 101 | "src/assets" 102 | ], 103 | "styles": [ 104 | "src/styles.css" 105 | ], 106 | "scripts": [] 107 | } 108 | } 109 | } 110 | } 111 | }, 112 | "defaultProject": "etrade" 113 | } 114 | --------------------------------------------------------------------------------