├── .editorconfig
├── .gitignore
├── .vscode
└── launch.json
├── README.md
├── angular.json
├── e2e
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.e2e.json
├── package-lock.json
├── package.json
├── src
├── app
│ ├── Models
│ │ ├── IAlert.ts
│ │ ├── OrderDetail.Model.ts
│ │ ├── OrderItem.Model.ts
│ │ ├── Product.Model.ts
│ │ ├── ProductDisplay.Model.ts
│ │ └── User.Models.ts
│ ├── Services
│ │ ├── Registration.Service.ts
│ │ ├── authentication.service.spec.ts
│ │ ├── authentication.service.ts
│ │ ├── order.service.spec.ts
│ │ ├── order.service.ts
│ │ ├── product.service.spec.ts
│ │ ├── product.service.ts
│ │ └── shared.service.ts
│ ├── admin
│ │ ├── admin.component.html
│ │ ├── admin.component.scss
│ │ ├── admin.component.spec.ts
│ │ └── admin.component.ts
│ ├── app-routing.module.ts
│ ├── app.component.html
│ ├── app.component.scss
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── customer.service.spec.ts
│ ├── customer.service.ts
│ ├── dashboard
│ │ ├── dashboard.component.html
│ │ ├── dashboard.component.scss
│ │ ├── dashboard.component.spec.ts
│ │ └── dashboard.component.ts
│ ├── datetime.service.spec.ts
│ ├── datetime.service.ts
│ ├── gaurd
│ │ ├── auth-guard.guard.spec.ts
│ │ └── auth-guard.guard.ts
│ ├── mycart
│ │ ├── mycart.component.html
│ │ ├── mycart.component.scss
│ │ ├── mycart.component.spec.ts
│ │ └── mycart.component.ts
│ ├── productdisplay
│ │ ├── productdisplay.component.html
│ │ ├── productdisplay.component.scss
│ │ ├── productdisplay.component.spec.ts
│ │ └── productdisplay.component.ts
│ └── profile
│ │ ├── profile.component.html
│ │ ├── profile.component.scss
│ │ ├── profile.component.spec.ts
│ │ └── profile.component.ts
├── assets
│ ├── .gitkeep
│ └── images
│ │ ├── DeepCart.PNG
│ │ └── DeepCart1.PNG
├── browserslist
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── karma.conf.js
├── main.ts
├── polyfills.ts
├── styles.scss
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
├── tsconfig.json
└── tslint.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://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 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.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 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | yarn-error.log
34 | testem.log
35 | /typings
36 |
37 | # System Files
38 | .DS_Store
39 | Thumbs.db
40 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 |
8 | {
9 | "type": "chrome",
10 | "request": "launch",
11 | "name": "Launch Chrome against localhost",
12 | "url": "http://localhost:4200",
13 | "webRoot": "${workspaceFolder}"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DeepCart
2 | This is the hard work of Deep and contributing this code for free for learning purpose.
3 | No has copy rights on this except code owner.
4 |
5 | I would request you to please subscribe , like and comment on my channel.
6 | The way I am hellping you ,please help me as well.
7 |
8 |
9 | Here are the video tutorials of this comeplete series.
10 |
11 | Lesson-1
12 | https://youtu.be/JjVyvy3ctFE
13 |
14 | Lesson-2
15 | https://youtu.be/SrmShkVhKhU
16 |
17 | Lesson-3
18 | https://youtu.be/wWknX6eaWjg
19 |
20 | Lesson-4
21 | https://youtu.be/CLqoEHt2aNk
22 |
23 | Lesson-5
24 | https://youtu.be/orRQrwPpbac
25 |
26 | Lesson-6
27 | https://youtu.be/qbGdKW-RWw0
28 |
29 | Lesson-7
30 | https://youtu.be/HeYsF01c5iw
31 |
32 | Lesson-8
33 | https://youtu.be/Oylx-hpaUDc
34 |
35 | Please , please subscribe my channel.Comment your views about my channel and social work of giving the source code.
36 |
37 |
38 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0.
39 |
40 | ## Development server
41 |
42 | 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.
43 |
44 | ## Code scaffolding
45 |
46 | 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`.
47 |
48 | ## Build
49 |
50 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
51 |
52 | ## Running unit tests
53 |
54 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
55 |
56 | ## Running end-to-end tests
57 |
58 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
59 |
60 | ## Further help
61 |
62 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
63 | # DeepCart
64 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "DeepCart": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {
12 | "@schematics/angular:component": {
13 | "styleext": "scss"
14 | }
15 | },
16 | "architect": {
17 | "build": {
18 | "builder": "@angular-devkit/build-angular:browser",
19 | "options": {
20 | "outputPath": "dist/DeepCart",
21 | "index": "src/index.html",
22 | "main": "src/main.ts",
23 | "polyfills": "src/polyfills.ts",
24 | "tsConfig": "src/tsconfig.app.json",
25 | "assets": [
26 | "src/favicon.ico",
27 | "src/assets"
28 | ],
29 | "styles": [
30 | "src/styles.scss"
31 | ],
32 | "scripts": []
33 | },
34 | "configurations": {
35 | "production": {
36 | "fileReplacements": [
37 | {
38 | "replace": "src/environments/environment.ts",
39 | "with": "src/environments/environment.prod.ts"
40 | }
41 | ],
42 | "optimization": true,
43 | "outputHashing": "all",
44 | "sourceMap": false,
45 | "extractCss": true,
46 | "namedChunks": false,
47 | "aot": true,
48 | "extractLicenses": true,
49 | "vendorChunk": false,
50 | "buildOptimizer": true
51 | }
52 | }
53 | },
54 | "serve": {
55 | "builder": "@angular-devkit/build-angular:dev-server",
56 | "options": {
57 | "browserTarget": "DeepCart:build"
58 | },
59 | "configurations": {
60 | "production": {
61 | "browserTarget": "DeepCart:build:production"
62 | }
63 | }
64 | },
65 | "extract-i18n": {
66 | "builder": "@angular-devkit/build-angular:extract-i18n",
67 | "options": {
68 | "browserTarget": "DeepCart:build"
69 | }
70 | },
71 | "test": {
72 | "builder": "@angular-devkit/build-angular:karma",
73 | "options": {
74 | "main": "src/test.ts",
75 | "polyfills": "src/polyfills.ts",
76 | "tsConfig": "src/tsconfig.spec.json",
77 | "karmaConfig": "src/karma.conf.js",
78 | "styles": [
79 | "styles.scss"
80 | ],
81 | "scripts": [],
82 | "assets": [
83 | "src/favicon.ico",
84 | "src/assets"
85 | ]
86 | }
87 | },
88 | "lint": {
89 | "builder": "@angular-devkit/build-angular:tslint",
90 | "options": {
91 | "tsConfig": [
92 | "src/tsconfig.app.json",
93 | "src/tsconfig.spec.json"
94 | ],
95 | "exclude": [
96 | "**/node_modules/**"
97 | ]
98 | }
99 | }
100 | }
101 | },
102 | "DeepCart-e2e": {
103 | "root": "e2e/",
104 | "projectType": "application",
105 | "architect": {
106 | "e2e": {
107 | "builder": "@angular-devkit/build-angular:protractor",
108 | "options": {
109 | "protractorConfig": "e2e/protractor.conf.js",
110 | "devServerTarget": "DeepCart:serve"
111 | }
112 | },
113 | "lint": {
114 | "builder": "@angular-devkit/build-angular:tslint",
115 | "options": {
116 | "tsConfig": "e2e/tsconfig.e2e.json",
117 | "exclude": [
118 | "**/node_modules/**"
119 | ]
120 | }
121 | }
122 | }
123 | }
124 | },
125 | "defaultProject": "DeepCart"
126 | }
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "deep-cart",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "^6.0.0",
15 | "@angular/common": "^6.0.0",
16 | "@angular/compiler": "^6.0.0",
17 | "@angular/core": "^6.0.0",
18 | "@angular/forms": "^6.0.0",
19 | "@angular/http": "^6.0.0",
20 | "@angular/platform-browser": "^6.0.0",
21 | "@angular/platform-browser-dynamic": "^6.0.0",
22 | "@angular/router": "^6.0.0",
23 | "@ng-bootstrap/ng-bootstrap": "^3.0.0",
24 | "bootstrap-scss": "^4.1.3",
25 | "core-js": "^2.5.4",
26 | "rxjs": "^6.0.0",
27 | "zone.js": "^0.8.26"
28 | },
29 | "devDependencies": {
30 | "@angular/compiler-cli": "^6.0.0",
31 | "@angular-devkit/build-angular": "~0.6.0",
32 | "typescript": "~2.7.2",
33 | "@angular/cli": "~6.0.0",
34 | "@angular/language-service": "^6.0.0",
35 | "@types/jasmine": "~2.8.6",
36 | "@types/jasminewd2": "~2.0.3",
37 | "@types/node": "~8.9.4",
38 | "codelyzer": "~4.2.1",
39 | "jasmine-core": "~2.99.1",
40 | "jasmine-spec-reporter": "~4.2.1",
41 | "karma": "~1.7.1",
42 | "karma-chrome-launcher": "~2.2.0",
43 | "karma-coverage-istanbul-reporter": "~1.4.2",
44 | "karma-jasmine": "~1.1.1",
45 | "karma-jasmine-html-reporter": "^0.2.2",
46 | "protractor": "~5.3.0",
47 | "ts-node": "~5.0.1",
48 | "tslint": "~5.9.1"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/app/Models/IAlert.ts:
--------------------------------------------------------------------------------
1 | export interface IAlert {
2 | id: number;
3 | type: string;
4 | message: string;
5 | }
--------------------------------------------------------------------------------
/src/app/Models/OrderDetail.Model.ts:
--------------------------------------------------------------------------------
1 |
2 | import { OrderItem } from "./OrderItem.Model";
3 |
4 | export interface OrderDetail
5 | {
6 | OrderID :number;
7 | CustomerId :number;
8 | CustomerName:string;
9 | DeliveryAddress:string;
10 | Phone:string;
11 | OrderPayMethod :string;
12 | PaymentRefrenceId :string;
13 | OrderItems:OrderItem[];
14 | }
--------------------------------------------------------------------------------
/src/app/Models/OrderItem.Model.ts:
--------------------------------------------------------------------------------
1 | export interface OrderItem
2 | {
3 | ID :number
4 | ProductID:number
5 | SellerID :number
6 | ProductName :string
7 | OrderedQuantity :number
8 | PerUnitPrice :number
9 | OrderID :number
10 | }
--------------------------------------------------------------------------------
/src/app/Models/Product.Model.ts:
--------------------------------------------------------------------------------
1 | export interface Product
2 | {
3 | Id:number;
4 | Name:string;
5 | Description:string;
6 | BillingAddress:string;
7 | UnitPrice:number;
8 | Category:string;
9 | Quantity:number;
10 | ImageFile:File;
11 | TC:string;
12 | SellerId:number;
13 | SellerName:string;
14 | }
--------------------------------------------------------------------------------
/src/app/Models/ProductDisplay.Model.ts:
--------------------------------------------------------------------------------
1 | import { ProductDisplay } from "./ProductDisplay.Model";
2 | import { Product } from "./Product.Model";
3 |
4 | export interface ProductDisplay
5 | {
6 | Category:string;
7 | Products:Product[];
8 | }
--------------------------------------------------------------------------------
/src/app/Models/User.Models.ts:
--------------------------------------------------------------------------------
1 | export interface Registration
2 | {
3 | Id:number;
4 | UserName:string;
5 | Password:string;
6 | Email:string;
7 | Role:string;
8 | Gender:string;
9 | Phone:string;
10 | }
--------------------------------------------------------------------------------
/src/app/Services/Registration.Service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient,HttpClientModule } from '@angular/common/http';
3 | import { Http, Response } from '@angular/http';
4 | import { Observable, of, throwError, pipe} from "rxjs"
5 | import { map, filter, catchError, mergeMap } from 'rxjs/operators';
6 |
7 |
8 |
9 | @Injectable({
10 | providedIn: 'root'
11 | })
12 | export class RegistrationService {
13 |
14 | public apiURL:string="http://localhost:50148/api/Registrations";
15 | constructor(private httpClient:HttpClient) { }
16 |
17 | RegisterUser (user:any)
18 | {
19 | return this.httpClient.post(this.apiURL,user)
20 | .pipe(
21 | map(res => res),
22 | catchError( this.errorHandler)
23 | );
24 | }
25 | errorHandler(error: Response) {
26 | console.log(error);
27 | return throwError(error);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/Services/authentication.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { AuthenticationService } from './authentication.service';
4 |
5 | describe('Services/AuthenticationServiceService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [AuthenticationService]
9 | });
10 | });
11 |
12 | it('should be created', inject([AuthenticationService], (service: AuthenticationService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/Services/authentication.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient,HttpClientModule, HttpHeaders } from '@angular/common/http';
3 | import { Http, Response } from '@angular/http';
4 | import { Observable, of, throwError, pipe} from "rxjs"
5 | import { map, filter, catchError, mergeMap } from 'rxjs/operators';
6 |
7 | @Injectable({
8 | providedIn: 'root'
9 | })
10 | export class AuthenticationService {
11 | public apiURL:string="http://localhost:50148/";
12 |
13 | constructor(private httpClient:HttpClient) { }
14 | // This tutorial is by DotNet Techy YouTube Channel
15 | // For more info about channel You can visit this link
16 | // https://www.youtube.com/c/dotnettechy
17 | ValidateUser (user:any)
18 | {
19 | var userData = "username=" + user.UserName + "&password=" + user.Password + "&grant_type=password";
20 | var reqHeader = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded','No-Auth':'True' });
21 |
22 | return this.httpClient.post(this.apiURL+ '/token',userData,{ headers: reqHeader })
23 | .pipe(
24 | map(res => res),
25 | catchError( this.errorHandler)
26 | );
27 | }
28 | getClaims ()
29 | {
30 | var reqHeader = new HttpHeaders({ 'Authorization':'Bearer '+this.getToken()});
31 | reqHeader.append('Content-Type', 'application/json');
32 | return this.httpClient.get(this.apiURL+ 'api/Users',{ headers: reqHeader })
33 | .pipe(
34 | map(res => res),
35 | catchError( this.errorHandler)
36 | );
37 | }
38 | public isAuthenticated(): boolean {
39 | return this.getToken() !== null;
40 | }
41 | storeToken(token: string) {
42 | localStorage.setItem("token", token);
43 | }
44 | getToken() {
45 | return localStorage.getItem("token");
46 | }
47 | removeToken() {
48 | return localStorage.removeItem("token");
49 | }
50 | storeRole(role: any) {
51 | this.removeRole();
52 | localStorage.setItem('role', JSON.stringify(role));
53 | }
54 | getRole() {
55 | // return localStorage.getItem("role");
56 | return JSON.parse(localStorage.getItem('role'));
57 | }
58 | removeRole() {
59 | return localStorage.removeItem("role");
60 | }
61 | errorHandler(error: Response) {
62 | console.log(error);
63 | return throwError(error);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/app/Services/order.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { Services\OrderService } from './services\order.service';
4 |
5 | describe('Services\OrderService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [Services\OrderService]
9 | });
10 | });
11 |
12 | it('should be created', inject([Services\OrderService], (service: Services\OrderService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/Services/order.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient,HttpClientModule, HttpHeaders } from '@angular/common/http';
3 | import { Http, Response } from '@angular/http';
4 | import { Observable, of, throwError, pipe} from "rxjs"
5 | import { map, filter, catchError, mergeMap } from 'rxjs/operators';
6 | import { AuthenticationService } from './authentication.service';
7 | import { OrderDetail } from '../Models/OrderDetail.Model';
8 |
9 | @Injectable({
10 | providedIn: 'root'
11 | })
12 | export class OrderService {
13 | public apiURL:string="http://localhost:50148/api/OrderDetails";
14 | constructor(private httpClient:HttpClient, private authService:AuthenticationService) { }
15 |
16 | PlaceOrder (orderDetail:OrderDetail)
17 | {
18 | var reqHeader = new HttpHeaders({ 'Authorization':'Bearer '+this.authService.getToken()});
19 | reqHeader.append('Content-Type', 'application/json');
20 |
21 | return this.httpClient.post(this.apiURL,orderDetail,{ headers: reqHeader })
22 | .pipe(
23 | map(res => res),
24 | catchError( this.errorHandler)
25 | );
26 | }
27 |
28 | errorHandler(error: Response) {
29 | console.log(error);
30 | return throwError(error);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/app/Services/product.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { Services\ProductService } from './services\product.service';
4 |
5 | describe('Services\ProductService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [Services\ProductService]
9 | });
10 | });
11 |
12 | it('should be created', inject([Services\ProductService], (service: Services\ProductService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/Services/product.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient,HttpClientModule, HttpHeaders } from '@angular/common/http';
3 | import { Http, Response } from '@angular/http';
4 | import { Observable, of, throwError, pipe} from "rxjs"
5 | import { map, filter, catchError, mergeMap } from 'rxjs/operators';
6 | import { AuthenticationService } from './authentication.service';
7 | import { Product } from '../Models/Product.Model';
8 |
9 | @Injectable({
10 | providedIn: 'root'
11 | })
12 | export class ProductService {
13 |
14 | public apiURL:string="http://localhost:50148/api/Products";
15 | constructor(private httpClient:HttpClient, private authService:AuthenticationService) { }
16 |
17 | saveProductInfo (product:any)
18 | {
19 | var reqHeader = new HttpHeaders({ 'Authorization':'Bearer '+this.authService.getToken()});
20 | reqHeader.append('Content-Type', 'application/json');
21 | const formData: FormData = new FormData();
22 | formData.append('UnitPrice', product['Price']);
23 | formData.append('Name', product.Name.toString());
24 | formData.append('SellerId', product.SellerId.toString());
25 | formData.append('SellerName', product.SellerName.toString());
26 | formData.append('Category', product.Category.toString());
27 | formData.append('TC', product['Conditions']);
28 | formData.append('Quantity', product.Quantity.toString());
29 | formData.append('Description', product.Description.toString());
30 | formData.append('Image', product['ImageFile']);
31 |
32 |
33 | return this.httpClient.post(this.apiURL,formData,{ headers: reqHeader })
34 | .pipe(
35 | map(res => res),
36 | catchError( this.errorHandler)
37 | );
38 | }
39 | getAllProducts ()
40 | {
41 | return this.httpClient.get(this.apiURL)
42 | .pipe(
43 | map(res => res),
44 | catchError( this.errorHandler)
45 | );
46 | }
47 | addProductToCart(prodcuts: any) {
48 | localStorage.setItem("product", JSON.stringify(prodcuts));
49 | }
50 | getProductFromCart() {
51 | //return localStorage.getItem("product");
52 | return JSON.parse(localStorage.getItem('product'));
53 | }
54 | removeAllProductFromCart() {
55 | return localStorage.removeItem("product");
56 | }
57 | errorHandler(error: Response) {
58 | console.log(error);
59 | return throwError(error);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/app/Services/shared.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { BehaviorSubject } from 'rxjs';
3 |
4 | @Injectable({
5 | providedIn: 'root'
6 | })
7 | export class SharedService {
8 |
9 | private currentCartCount = new BehaviorSubject(0);
10 | currentMessage = this.currentCartCount.asObservable();
11 |
12 | constructor() {
13 | }
14 | updateCartCount(count: number) {
15 | this.currentCartCount.next(count)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
You are in admin page.You are in admin page. You are in admin page.
6 | You are in admin page.
7 | You are in admin page.
8 | You are in admin page.
9 | You are in admin page.
10 | You are in admin page.
11 | You are in admin page.
12 | You are in admin page.
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/app/admin/admin.component.scss
--------------------------------------------------------------------------------
/src/app/admin/admin.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { AdminComponent } from './admin.component';
4 |
5 | describe('AdminComponent', () => {
6 | let component: AdminComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ AdminComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AdminComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-admin',
5 | templateUrl: './admin.component.html',
6 | styleUrls: ['./admin.component.scss']
7 | })
8 | export class AdminComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { ProfileComponent } from './profile/profile.component';
4 | import { authGuardGuard } from './gaurd/auth-guard.guard';
5 | import { AdminComponent } from './admin/admin.component';
6 | import { DashboardComponent } from './dashboard/dashboard.component';
7 | import { ProductdisplayComponent } from './productdisplay/productdisplay.component';
8 | import { MycartComponent } from './mycart/mycart.component';
9 |
10 | const routes: Routes = [
11 | {path:"",component:ProductdisplayComponent},
12 | {path:"profile",component:ProfileComponent,canActivate:[authGuardGuard]},
13 | {path:"dashboard",component:DashboardComponent,canActivate:[authGuardGuard]},
14 | {path:"admin",component:AdminComponent,canActivate:[authGuardGuard]},
15 | {path:"productdisplay",component:ProductdisplayComponent},
16 | {path:"mycart",component:MycartComponent},
17 | {path:"**",component:ProductdisplayComponent},
18 | ];
19 |
20 | @NgModule({
21 | imports: [RouterModule.forRoot(routes)],
22 | exports: [RouterModule]
23 | })
24 | export class AppRoutingModule { }
25 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Login & Signup
18 |
19 |
20 |
User Details
21 |
22 |
23 |
28 |
29 |
30 |
31 |
More
32 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
44 | Cart {{cartItemCount}}
45 | unread messages
46 |
47 |
48 |
49 | Admin
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
64 |
65 |
66 |
67 |
68 | Login
69 |
70 |
71 |
88 |
89 |
90 |
91 | Register
92 |
93 |
94 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/app/app.component.scss
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | imports: [
8 | RouterTestingModule
9 | ],
10 | declarations: [
11 | AppComponent
12 | ],
13 | }).compileComponents();
14 | }));
15 | it('should create the app', async(() => {
16 | const fixture = TestBed.createComponent(AppComponent);
17 | const app = fixture.debugElement.componentInstance;
18 | expect(app).toBeTruthy();
19 | }));
20 | it(`should have as title 'app'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app');
24 | }));
25 | it('should render title in a h1 tag', async(() => {
26 | const fixture = TestBed.createComponent(AppComponent);
27 | fixture.detectChanges();
28 | const compiled = fixture.debugElement.nativeElement;
29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
30 | }));
31 | });
32 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import {Input, Component, OnInit } from '@angular/core';
2 | import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';
3 | import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
4 | import { HttpClient,HttpClientModule } from '@angular/common/http';
5 | import { Registration } from './Models/User.Models';
6 | import {RegistrationService} from './Services/Registration.Service'
7 | import { AuthenticationService } from './Services/authentication.service';
8 | import { SharedService } from './Services/shared.service';
9 |
10 |
11 | @Component({
12 | selector: 'app-root',
13 | templateUrl: './app.component.html',
14 | styleUrls: ['./app.component.scss'],
15 | providers:[RegistrationService]
16 | })
17 | export class AppComponent implements OnInit {
18 | closeResult: string;
19 | registrationForm: FormGroup;
20 | loginForm:FormGroup;
21 | registrationInputs: Registration[];
22 | currentUser: Registration[];
23 | isLoggedIn:boolean=false;
24 |
25 | cartItemCount:number=0;
26 | approvalText:string="";
27 |
28 | @Input()
29 | public alerts: Array = [];
30 |
31 | message = "";
32 | public globalResponse: any;
33 |
34 | constructor(private sharedService:SharedService, private modalService: NgbModal,private fb: FormBuilder,private regService:RegistrationService ,private authService:AuthenticationService) {
35 |
36 | }
37 | ngOnInit()
38 | {
39 | this.sharedService.currentMessage.subscribe(msg => this.cartItemCount = msg);
40 | this.registrationForm = this.fb.group({
41 | UserName: ['', Validators.compose([Validators.required, Validators.minLength(3),Validators.maxLength(50)])],
42 | Password:['',Validators.compose([Validators.required, Validators.minLength(3),Validators.maxLength(50)])],
43 | Email:['',Validators.compose([Validators.required,Validators.email])],
44 | Role:['',Validators.required],
45 | Phone:['',Validators.required],
46 | Gender:['',''],
47 | });
48 | this.loginForm = this.fb.group({
49 | UserName: ['', [Validators.required]],
50 | Password:['',[Validators.required]],
51 | });
52 | }
53 |
54 | open(content) {
55 | this.alerts=[];
56 | this.modalService.open(content, {ariaLabelledBy: 'modal-basic-title',size: 'lg'}).result.then((result) => {
57 | this.closeResult = `Closed with: ${result}`;
58 | }, (reason) => {
59 | //this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
60 | });
61 | }
62 |
63 | private getDismissReason(reason: any): string {
64 | if (reason === ModalDismissReasons.ESC) {
65 | return 'by pressing ESC';
66 | } else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
67 | return 'by clicking on a backdrop';
68 | } else {
69 | return `with: ${reason}`;
70 | }
71 | }
72 | Login()
73 | {
74 | let user=this.loginForm.value;
75 | this.isLoggedIn=false;
76 | this.authService.removeToken();
77 | this.alerts=[];
78 | //console.log(user);
79 | this.authService.ValidateUser(user)
80 | .subscribe((result) => {
81 | this.globalResponse = result;
82 | },
83 | error => { //This is error part
84 | console.log(error.message);
85 | this.alerts.push({
86 | id: 2,
87 | type: 'danger',
88 | message: 'Either user name or password is incorrect.'
89 | });
90 | },
91 | () => {
92 | // This is Success part
93 | // console.log(this.globalResponse);
94 | this.authService.storeToken(this.globalResponse.access_token);
95 | this.alerts.push({
96 | id: 1,
97 | type: 'success',
98 | message: 'Login successful. Now you can close and proceed further.',
99 | });
100 | this.isLoggedIn=true;
101 | this.GetClaims();
102 |
103 | }
104 | )
105 | }
106 |
107 | OnRegister()
108 | {
109 | this.registrationInputs=this.registrationForm.value;
110 |
111 | console.log(this.registrationInputs);
112 | this.regService.RegisterUser(this.registrationInputs)
113 | .subscribe((result) => {
114 | this.globalResponse = result;
115 | },
116 | error => { //This is error part
117 | this.alerts.push({
118 | id: 2,
119 | type: 'danger',
120 | message: 'Registration failed with fallowing error:'+error,
121 | });
122 | },
123 | () => {
124 | // This is Success part
125 | this.alerts.push({
126 | id: 1,
127 | type: 'success',
128 | message: 'Registration successful.',
129 | });
130 |
131 | }
132 | )
133 | }
134 | public closeAlert(alert: IAlert) {
135 | const index: number = this.alerts.indexOf(alert);
136 | this.alerts.splice(index, 1);
137 | }
138 | GetClaims()
139 | {
140 | this.authService.getClaims()
141 | .subscribe((result) => {
142 | this.globalResponse = result;
143 | },
144 | error => { //This is error part
145 | console.log(error.message);
146 | },
147 | () => {
148 | // This is Success part
149 | // console.log(this.globalResponse );
150 | let a=this.globalResponse;
151 | this.currentUser=this.globalResponse;
152 | this.authService.storeRole(this.currentUser);
153 | }
154 | )
155 |
156 | }
157 | LogOut()
158 | {
159 | this.isLoggedIn=false;
160 | this.authService.removeToken();
161 | }
162 |
163 |
164 | }
165 | export interface IAlert {
166 | id: number;
167 | type: string;
168 | message: string;
169 | }
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import {NgbModule} from '@ng-bootstrap/ng-bootstrap'
4 | import { HttpClient,HttpClientModule } from '@angular/common/http';
5 | import {FormsModule,ReactiveFormsModule,Validators,FormControl,FormGroup,FormBuilder} from '@angular/forms';
6 |
7 | import { AppRoutingModule } from './app-routing.module';
8 | import { AppComponent } from './app.component';
9 | import { ProfileComponent } from './profile/profile.component';
10 | import { AdminComponent } from './admin/admin.component';
11 | import { DashboardComponent } from './dashboard/dashboard.component';
12 | import { ProductdisplayComponent } from './productdisplay/productdisplay.component';
13 | import { MycartComponent } from './mycart/mycart.component';
14 |
15 | @NgModule({
16 | declarations: [
17 | AppComponent,
18 | ProfileComponent,
19 | AdminComponent,
20 | DashboardComponent,
21 | ProductdisplayComponent,
22 | MycartComponent,
23 | ],
24 | imports: [
25 | BrowserModule,NgbModule,FormsModule,ReactiveFormsModule,HttpClientModule,
26 | AppRoutingModule
27 | ],
28 | providers: [],
29 | bootstrap: [AppComponent]
30 | })
31 | export class AppModule { }
32 |
--------------------------------------------------------------------------------
/src/app/customer.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { CustomerService } from './customer.service';
4 |
5 | describe('CustomerService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [CustomerService]
9 | });
10 | });
11 |
12 | it('should be created', inject([CustomerService], (service: CustomerService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/customer.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | @Injectable({
4 | providedIn: 'root'
5 | })
6 | export class CustomerService {
7 |
8 | constructor() { }
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Add Products
8 |
9 |
10 |
151 |
152 | {{ alert.message }}
153 |
154 |
155 |
156 |
157 |
158 | Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid.
159 | Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table
160 | craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl
161 | cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia
162 | yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean
163 | shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero
164 | sint qui sapiente accusamus tattooed echo park.
165 |
166 |
167 |
168 |
169 | Sed commodo, leo at suscipit dictum, quam est porttitor sapien, eget sodales nibh elit id diam. Nulla facilisi. Donec egestas ligula vitae odio interdum aliquet. Duis lectus turpis, luctus eget tincidunt eu, congue et odio. Duis pharetra et nisl at faucibus. Quisque luctus pulvinar arcu, et molestie lectus ultrices et. Sed diam urna, egestas ut ipsum vel, volutpat volutpat neque. Praesent fringilla tortor arcu. Vivamus faucibus nisl enim, nec tristique ipsum euismod facilisis. Morbi ut bibendum est, eu tincidunt odio. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris aliquet odio ac lorem aliquet ultricies in eget neque. Phasellus nec tortor vel tellus pulvinar feugiat.
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/app/dashboard/dashboard.component.scss
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DashboardComponent } from './dashboard.component';
4 |
5 | describe('DashboardComponent', () => {
6 | let component: DashboardComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DashboardComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DashboardComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit,Input } from '@angular/core';
2 | import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
3 | import { AuthenticationService } from '../Services/authentication.service';
4 | import { Product } from '../Models/Product.Model';
5 | import { ProductService } from '../Services/product.service';
6 | import { IAlert } from '../Models/IAlert';
7 |
8 | @Component({
9 | selector: 'app-dashboard',
10 | templateUrl: './dashboard.component.html',
11 | styleUrls: ['./dashboard.component.scss']
12 | })
13 | export class DashboardComponent implements OnInit {
14 |
15 | productForm: FormGroup;
16 | sellerName:string="";
17 | sellerId:number=0;
18 | productFormInputs: Product[];
19 | @Input()
20 | public alerts: Array = [];
21 | public globalResponse: any;
22 | productImage:File=null;
23 |
24 | constructor(private fb: FormBuilder,private authService:AuthenticationService,private productService:ProductService) { }
25 |
26 | ngOnInit() {
27 | this.productForm = this.fb.group({
28 | Name: ['', Validators.compose([Validators.required, Validators.minLength(3),Validators.maxLength(50)])],
29 | Description:['',Validators.compose([Validators.required, Validators.minLength(3),Validators.maxLength(50)])],
30 | Price:['',Validators.compose([Validators.required])],
31 | Category:['',Validators.required],
32 | Quantity:['',Validators.required],
33 | Address:['',Validators.required],
34 | image:['',Validators.required],
35 | Conditions:['',''],
36 |
37 | });
38 | this.GetSellerDetails();
39 | }
40 | GetSellerDetails()
41 | {
42 | let details=this.authService.getRole();
43 | // console.log(details);
44 | this.sellerId=details["Id"];
45 | this.sellerName=details["UserName"];
46 | }
47 | handleImageFile(file:FileList)
48 | {
49 | this.productImage=file.item(0);
50 | }
51 | OnSaveProduct()
52 | {
53 | let productFormInputs=this.productForm.value;
54 | productFormInputs.SellerId=this.sellerId;
55 | productFormInputs.SellerName=this.sellerName;
56 | productFormInputs.ImageFile=this.productImage;
57 |
58 | this.alerts=[];
59 | // console.log(productFormInputs);
60 | this.productService.saveProductInfo(productFormInputs)
61 | .subscribe((result) => {
62 | this.globalResponse = result;
63 | },
64 | error => { //This is error part
65 | console.log(error.message);
66 | this.alerts.push({
67 | id: 2,
68 | type: 'danger',
69 | message: 'Something went wrong while saving the product, Please try after sometime.'
70 | });
71 | },
72 | () => {
73 | // This is Success part
74 | // console.log(this.globalResponse);
75 | this.alerts.push({
76 | id: 1,
77 | type: 'success',
78 | message: 'Product has been saved successfully. Now you can add more prodcut , if you wish to.',
79 | });
80 |
81 | }
82 | )
83 | }
84 | public closeAlert(alert: IAlert) {
85 | const index: number = this.alerts.indexOf(alert);
86 | this.alerts.splice(index, 1);
87 | }
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/src/app/datetime.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { DatetimeService } from './datetime.service';
4 |
5 | describe('DatetimeService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [DatetimeService]
9 | });
10 | });
11 |
12 | it('should be created', inject([DatetimeService], (service: DatetimeService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/datetime.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | @Injectable({
4 | providedIn: 'root'
5 | })
6 | export class DatetimeService {
7 |
8 | constructor() { }
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/gaurd/auth-guard.guard.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async, inject } from '@angular/core/testing';
2 |
3 | import { Gaurd\authGuardGuard } from './gaurd\auth-guard.guard';
4 |
5 | describe('Gaurd\authGuardGuard', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [Gaurd\authGuardGuard]
9 | });
10 | });
11 |
12 | it('should ...', inject([Gaurd\authGuardGuard], (guard: Gaurd\authGuardGuard) => {
13 | expect(guard).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/gaurd/auth-guard.guard.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
3 | import { Observable } from 'rxjs';
4 | import {AuthenticationService} from '../Services/authentication.service'
5 |
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class authGuardGuard implements CanActivate {
10 |
11 | constructor(public auth: AuthenticationService, public router: Router) {}
12 | // This tutorial is by DotNet Techy YouTube Channel
13 | // For more info about channel You can visit this link
14 | // https://www.youtube.com/c/dotnettechy
15 |
16 | canActivate(): boolean {
17 | if (!this.auth.isAuthenticated()) {
18 | //this.router.navigate(['login']);
19 | console.log('You are not authrised to view this page')
20 | return false;
21 | }
22 | return true;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/app/mycart/mycart.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Items in your cart:
11 | Total value is: {{allTotal}}
12 | CheckOut
13 |
14 |
15 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | ★ Order Details ★
49 |
50 |
51 |
52 |
73 | Proceed to pay
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | Item Details
82 | Delivery Details
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | Name & Description
91 | Price
92 | Quantity
93 | Total For Item
94 |
95 |
96 |
97 | {{prod.Name}}
98 | {{prod.UnitPrice}}
99 | {{prod.Quantity}}
100 | {{prod.UnitPrice * prod.Quantity}}
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | Name
111 | Delivery Address
112 | Phone
113 | Email
114 | Message
115 |
116 |
117 |
118 | {{deliveryForm.value.UserName}}
119 | {{deliveryForm.value.DeliveryAddress}}
120 | {{deliveryForm.value.Phone}}
121 | {{deliveryForm.value.Email}}
122 | {{deliveryForm.value.Message}}
123 |
124 |
125 |
126 |
127 |
128 |
129 | Confirm Order
130 |
131 |
132 |
133 |
134 | {{ alert.message }}
135 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/src/app/mycart/mycart.component.scss:
--------------------------------------------------------------------------------
1 | .table td {
2 | text-align: center;
3 | }
--------------------------------------------------------------------------------
/src/app/mycart/mycart.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { MycartComponent } from './mycart.component';
4 |
5 | describe('MycartComponent', () => {
6 | let component: MycartComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ MycartComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(MycartComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/mycart/mycart.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
3 | import { Product } from '../Models/Product.Model';
4 | import { ProductService } from '../Services/product.service';
5 | import { IAlert } from '../Models/IAlert';
6 | import { OrderDetail } from '../Models/OrderDetail.Model';
7 | import { Registration } from '../Models/User.Models';
8 | import { AuthenticationService } from '../Services/authentication.service';
9 | import { OrderService } from '../Services/order.service';
10 | import { OrderItem } from '../Models/OrderItem.Model';
11 |
12 | @Component({
13 | selector: 'app-mycart',
14 | templateUrl: './mycart.component.html',
15 | styleUrls: ['./mycart.component.scss']
16 | })
17 | export class MycartComponent implements OnInit {
18 | dafualtQuantity:number=1;
19 | productAddedTocart:Product[];
20 | allTotal:number;
21 | currentUser: Registration[];
22 | orderDetail:OrderDetail;
23 | orderItem:OrderItem[];
24 |
25 | public globalResponse: any;
26 | public alerts: Array = [];
27 |
28 | deliveryForm:FormGroup;
29 |
30 |
31 | constructor(private productService:ProductService,private fb: FormBuilder,private authService:AuthenticationService,private orderService:OrderService)
32 | {
33 |
34 | }
35 |
36 | ngOnInit() {
37 | this.productAddedTocart=this.productService.getProductFromCart();
38 | for (let i in this.productAddedTocart) {
39 | this.productAddedTocart[i].Quantity=1;
40 | }
41 | this.productService.removeAllProductFromCart();
42 | this.productService.addProductToCart(this.productAddedTocart);
43 | this.calculteAllTotal(this.productAddedTocart);
44 |
45 | this.GetLoggedinUserDetails();
46 |
47 | this.deliveryForm = this.fb.group({
48 | UserName: ['', [Validators.required]],
49 | DeliveryAddress:['',[Validators.required]],
50 | Phone:['',[Validators.required]],
51 | Email:['',[Validators.required]],
52 | Message:['',[]],
53 | Amount:['',[Validators.required]],
54 |
55 | });
56 |
57 | this.deliveryForm.controls['UserName'].setValue(this.currentUser["UserName"]);
58 | this.deliveryForm.controls['Phone'].setValue(this.currentUser["Phone"]);
59 | this.deliveryForm.controls['Email'].setValue(this.currentUser["Email"]);
60 | this.deliveryForm.controls['Amount'].setValue(this.allTotal);
61 | }
62 | onAddQuantity(product:Product)
63 | {
64 | //Get Product
65 | this.productAddedTocart=this.productService.getProductFromCart();
66 | this.productAddedTocart.find(p=>p.Id==product.Id).Quantity = product.Quantity+1;
67 | //Find produc for which we want to update the quantity
68 | //let tempProd= this.productAddedTocart.find(p=>p.Id==product.Id);
69 | //tempProd.Quantity=tempProd.Quantity+1;
70 |
71 | //this.productAddedTocart=this.productAddedTocart.splice(this.productAddedTocart.indexOf(product), 1)
72 | //Push the product for cart
73 | // this.productAddedTocart.push(tempProd);
74 | this.productService.removeAllProductFromCart();
75 | this.productService.addProductToCart(this.productAddedTocart);
76 | this.calculteAllTotal(this.productAddedTocart);
77 | this.deliveryForm.controls['Amount'].setValue(this.allTotal);
78 |
79 | }
80 | onRemoveQuantity(product:Product)
81 | {
82 | this.productAddedTocart=this.productService.getProductFromCart();
83 | this.productAddedTocart.find(p=>p.Id==product.Id).Quantity = product.Quantity-1;
84 | this.productService.removeAllProductFromCart();
85 | this.productService.addProductToCart(this.productAddedTocart);
86 | this.calculteAllTotal(this.productAddedTocart);
87 | this.deliveryForm.controls['Amount'].setValue(this.allTotal);
88 |
89 | }
90 | calculteAllTotal(allItems:Product[])
91 | {
92 | let total=0;
93 | for (let i in allItems) {
94 | total= total+(allItems[i].Quantity *allItems[i].UnitPrice);
95 | }
96 | this.allTotal=total;
97 | }
98 |
99 | GetLoggedinUserDetails()
100 | {
101 | this.currentUser=this.authService.getRole();
102 |
103 | }
104 | ConfirmOrder()
105 | {
106 | const date: Date = new Date();
107 | var id=this.currentUser['Id'];
108 | var name=this.currentUser["UserName"];
109 | var day = date.getDate();
110 | var monthIndex = date.getMonth();
111 | var year = date.getFullYear();
112 | var minutes = date.getMinutes();
113 | var hours = date.getHours();
114 | var seconds = date.getSeconds();
115 | var dateTimeStamp=day.toString()+monthIndex.toString()+year.toString()+minutes.toString()+hours.toString()+seconds.toString();
116 | let orderDetail:any={};
117 |
118 | //Orderdetail is object which hold all the value, which needs to be saved into database
119 | orderDetail.CustomerId=this.currentUser['Id'];
120 | orderDetail.CustomerName=this.currentUser["UserName"];
121 | orderDetail.DeliveryAddress=this.deliveryForm.controls['DeliveryAddress'].value;
122 | orderDetail.Phone=this.deliveryForm.controls['Phone'].value;
123 |
124 | orderDetail.PaymentRefrenceId=id+"-"+name+dateTimeStamp;
125 | orderDetail.OrderPayMethod="Cash On Delivery";
126 |
127 | //Assigning the ordered item details
128 | this.orderItem=[];
129 | for (let i in this.productAddedTocart) {
130 | this.orderItem.push({
131 | ID:0,
132 | ProductID:this.productAddedTocart[i].Id,
133 | SellerID:this.productAddedTocart[i].SellerId,
134 | ProductName:this.productAddedTocart[i].Name,
135 | OrderedQuantity:this.productAddedTocart[i].Quantity,
136 | PerUnitPrice:this.productAddedTocart[i].UnitPrice,
137 | OrderID:0,
138 | }) ;
139 | }
140 | //So now compelte object of order is
141 | orderDetail.OrderItems=this.orderItem;
142 |
143 | this.orderService.PlaceOrder(orderDetail)
144 | .subscribe((result) => {
145 | this.globalResponse = result;
146 | },
147 | error => { //This is error part
148 | console.log(error.message);
149 | this.alerts.push({
150 | id: 2,
151 | type: 'danger',
152 | message: 'Something went wrong while placing the order, Please try after sometime.'
153 | });
154 | },
155 | () => {
156 | // This is Success part
157 | //console.log(this.globalResponse);
158 | this.alerts.push({
159 | id: 1,
160 | type: 'success',
161 | message: 'Order has been placed succesfully.',
162 | });
163 |
164 | }
165 | )
166 |
167 | }
168 | public closeAlert(alert: IAlert) {
169 | const index: number = this.alerts.indexOf(alert);
170 | this.alerts.splice(index, 1);
171 | }
172 |
173 | }
174 |
--------------------------------------------------------------------------------
/src/app/productdisplay/productdisplay.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{ alert.message }}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | {{prod.Name}}
19 |
20 |
21 | Price:{{prod.UnitPrice}}
22 |
23 |
24 | {{prod.Description}}
25 |
26 |
27 |
28 | Add to cart
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/app/productdisplay/productdisplay.component.scss:
--------------------------------------------------------------------------------
1 | .catheader
2 | {
3 | font-size: xx-large;
4 | font-style: italic;
5 | font-weight: bold;
6 | }
7 | .prodTable {
8 | border-radius: 25px;
9 | border: 2px solid #73AD21;
10 | padding: 20px;
11 | width: 250px;
12 | height: 200px;
13 | margin: 2em;
14 | }
15 | .after-prodTable {
16 | clear: left;
17 | }
18 |
19 | .box {
20 | float: left;
21 | width: 200px;
22 | height: 150px;
23 | margin: 1em;
24 | }
25 | .after-box {
26 | clear: left;
27 | }
--------------------------------------------------------------------------------
/src/app/productdisplay/productdisplay.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ProductdisplayComponent } from './productdisplay.component';
4 |
5 | describe('ProductdisplayComponent', () => {
6 | let component: ProductdisplayComponent;
7 | let fixture: ComponentFixture
;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ProductdisplayComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ProductdisplayComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/productdisplay/productdisplay.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, EventEmitter, Output,OnInit } from '@angular/core';
2 | import { ProductDisplay } from '../Models/ProductDisplay.Model';
3 |
4 | import { ProductService } from '../Services/product.service';
5 | import { Product } from '../Models/Product.Model';
6 | import { IAlert } from '../Models/IAlert';
7 | import { SharedService } from '../Services/shared.service';
8 |
9 | @Component({
10 | selector: 'app-productdisplay',
11 | templateUrl: './productdisplay.component.html',
12 | styleUrls: ['./productdisplay.component.scss'],
13 | providers:[ProductService]
14 | })
15 | export class ProductdisplayComponent implements OnInit {
16 |
17 | public alerts: Array = [];
18 | cartItemCount: number = 0;
19 | @Output() cartEvent = new EventEmitter();
20 | public globalResponse: any;
21 | yourByteArray:any;
22 | allProducts: ProductDisplay[];
23 | productAddedTocart:Product[];
24 | constructor(private productService:ProductService,private sharedService:SharedService) { }
25 |
26 | ngOnInit() {
27 | this.productService.getAllProducts()
28 | .subscribe((result) => {
29 | this.globalResponse = result;
30 | },
31 | error => { //This is error part
32 | console.log(error.message);
33 | },
34 | () => {
35 | // This is Success part
36 | console.log("Product fetched sucssesfully.");
37 | //console.log(this.globalResponse);
38 | this.allProducts=this.globalResponse;
39 | }
40 | )
41 |
42 | }
43 | OnAddCart(product:Product)
44 | {
45 | console.log(product);
46 |
47 | this.productAddedTocart=this.productService.getProductFromCart();
48 | if(this.productAddedTocart==null)
49 | {
50 | this.productAddedTocart=[];
51 | this.productAddedTocart.push(product);
52 | this.productService.addProductToCart(this.productAddedTocart);
53 | this.alerts.push({
54 | id: 1,
55 | type: 'success',
56 | message: 'Product added to cart.'
57 | });
58 | setTimeout(()=>{
59 | this.closeAlert(this.alerts);
60 | }, 3000);
61 |
62 | }
63 | else
64 | {
65 | let tempProduct=this.productAddedTocart.find(p=>p.Id==product.Id);
66 | if(tempProduct==null)
67 | {
68 | this.productAddedTocart.push(product);
69 | this.productService.addProductToCart(this.productAddedTocart);
70 | this.alerts.push({
71 | id: 1,
72 | type: 'success',
73 | message: 'Product added to cart.'
74 | });
75 | //setTimeout(function(){ }, 2000);
76 | setTimeout(()=>{
77 | this.closeAlert(this.alerts);
78 | }, 3000);
79 | }
80 | else
81 | {
82 | this.alerts.push({
83 | id: 2,
84 | type: 'warning',
85 | message: 'Product already exist in cart.'
86 | });
87 | setTimeout(()=>{
88 | this.closeAlert(this.alerts);
89 | }, 3000);
90 | }
91 |
92 | }
93 | //console.log(this.cartItemCount);
94 | this.cartItemCount=this.productAddedTocart.length;
95 | // this.cartEvent.emit(this.cartItemCount);
96 | this.sharedService.updateCartCount(this.cartItemCount);
97 | }
98 | public closeAlert(alert:any) {
99 | const index: number = this.alerts.indexOf(alert);
100 | this.alerts.splice(index, 1);
101 | }
102 | }
103 |
104 |
105 |
--------------------------------------------------------------------------------
/src/app/profile/profile.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
You are in profile page.You are in profile page. You are in profile page.
6 | You are in profile page.
7 | You are in profile page.
8 | You are in profile page.
9 | You are in profile page.
10 | You are in profile page.
11 | You are in profile page.
12 | You are in profile page.
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/app/profile/profile.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/app/profile/profile.component.scss
--------------------------------------------------------------------------------
/src/app/profile/profile.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ProfileComponent } from './profile.component';
4 |
5 | describe('ProfileComponent', () => {
6 | let component: ProfileComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ProfileComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ProfileComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/profile/profile.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-profile',
5 | templateUrl: './profile.component.html',
6 | styleUrls: ['./profile.component.scss']
7 | })
8 | export class ProfileComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/assets/images/DeepCart.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/assets/images/DeepCart.PNG
--------------------------------------------------------------------------------
/src/assets/images/DeepCart1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/assets/images/DeepCart1.PNG
--------------------------------------------------------------------------------
/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed
5 | > 0.5%
6 | last 2 versions
7 | Firefox ESR
8 | not dead
9 | # IE 9-11
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build ---prod` 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 | * In development mode, to ignore zone related error stack frames such as
11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
12 | * import the following file, but please comment it out in production mode
13 | * because it will have performance impact when throw error
14 | */
15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
16 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DeepGautamFullStack/DeepCart/5516a6292cee6ddc4e4fd97614798e914930a509/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DeepCart
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/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-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
--------------------------------------------------------------------------------
/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.log(err));
13 |
--------------------------------------------------------------------------------
/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 Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Web Animations `@angular/platform-browser/animations`
51 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
52 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
53 | **/
54 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
55 |
56 | /**
57 | * By default, zone.js will patch all possible macroTask and DomEvents
58 | * user can disable parts of macroTask/DomEvents patch by setting following flags
59 | */
60 |
61 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
62 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
63 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
64 |
65 | /*
66 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
67 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
68 | */
69 | // (window as any).__Zone_enable_cross_context_check = true;
70 |
71 | /***************************************************************************************************
72 | * Zone JS is required by default for Angular itself.
73 | */
74 | import 'zone.js/dist/zone'; // Included with Angular CLI.
75 |
76 |
77 |
78 | /***************************************************************************************************
79 | * APPLICATION IMPORTS
80 | */
81 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
3 |
4 | @import "../node_modules/bootstrap-scss/bootstrap";
--------------------------------------------------------------------------------
/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/dist/zone-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: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "types": []
7 | },
8 | "exclude": [
9 | "src/test.ts",
10 | "**/*.spec.ts"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "types": [
7 | "jasmine",
8 | "node"
9 | ]
10 | },
11 | "files": [
12 | "test.ts",
13 | "polyfills.ts"
14 | ],
15 | "include": [
16 | "**/*.spec.ts",
17 | "**/*.d.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2017",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-shadowed-variable": true,
69 | "no-string-literal": false,
70 | "no-string-throw": true,
71 | "no-switch-case-fall-through": true,
72 | "no-trailing-whitespace": true,
73 | "no-unnecessary-initializer": true,
74 | "no-unused-expression": true,
75 | "no-use-before-declare": true,
76 | "no-var-keyword": true,
77 | "object-literal-sort-keys": false,
78 | "one-line": [
79 | true,
80 | "check-open-brace",
81 | "check-catch",
82 | "check-else",
83 | "check-whitespace"
84 | ],
85 | "prefer-const": true,
86 | "quotemark": [
87 | true,
88 | "single"
89 | ],
90 | "radix": true,
91 | "semicolon": [
92 | true,
93 | "always"
94 | ],
95 | "triple-equals": [
96 | true,
97 | "allow-null-check"
98 | ],
99 | "typedef-whitespace": [
100 | true,
101 | {
102 | "call-signature": "nospace",
103 | "index-signature": "nospace",
104 | "parameter": "nospace",
105 | "property-declaration": "nospace",
106 | "variable-declaration": "nospace"
107 | }
108 | ],
109 | "unified-signatures": true,
110 | "variable-name": false,
111 | "whitespace": [
112 | true,
113 | "check-branch",
114 | "check-decl",
115 | "check-operator",
116 | "check-separator",
117 | "check-type"
118 | ],
119 | "no-output-on-prefix": true,
120 | "use-input-property-decorator": true,
121 | "use-output-property-decorator": true,
122 | "use-host-property-decorator": true,
123 | "no-input-rename": true,
124 | "no-output-rename": true,
125 | "use-life-cycle-interface": true,
126 | "use-pipe-transform-interface": true,
127 | "component-class-suffix": true,
128 | "directive-class-suffix": true
129 | }
130 | }
131 |
--------------------------------------------------------------------------------