├── src ├── assets │ └── .gitkeep ├── app │ ├── app.component.css │ ├── components │ │ └── products │ │ │ ├── products.component.css │ │ │ ├── products-list │ │ │ ├── products-list.component.css │ │ │ ├── prdouct-item │ │ │ │ ├── prdouct-item.component.css │ │ │ │ ├── prdouct-item.component.html │ │ │ │ ├── prdouct-item.component.ts │ │ │ │ └── prdouct-item.component.spec.ts │ │ │ ├── products-list.component.html │ │ │ ├── products-list.component.ts │ │ │ └── products-list.component.spec.ts │ │ │ ├── products-nav-bar │ │ │ ├── products-nav-bar.component.css │ │ │ ├── products-nav-bar.component.html │ │ │ ├── products-nav-bar.component.ts │ │ │ └── products-nav-bar.component.spec.ts │ │ │ ├── products.component.spec.ts │ │ │ ├── products.component.ts │ │ │ └── products.component.html │ ├── model │ │ └── product.model.ts │ ├── app.component.ts │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.module.ts │ ├── ngrx │ │ ├── products.reducer.ts │ │ ├── products.effects.ts │ │ └── products.actions.ts │ └── services │ │ └── product.service.ts ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── styles.css ├── index.html ├── main.ts ├── test.ts └── polyfills.ts ├── e2e ├── src │ ├── app.po.ts │ └── app.e2e-spec.ts ├── tsconfig.json └── protractor.conf.js ├── db.json ├── .editorconfig ├── tsconfig.app.json ├── tsconfig.spec.json ├── .browserslistrc ├── .gitignore ├── tsconfig.json ├── README.md ├── karma.conf.js ├── package.json ├── tslint.json └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/components/products/products.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/products-list.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/components/products/products-nav-bar/products-nav-bar.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/prdouct-item/prdouct-item.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular-ngrx-products-app-v2/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import "~font-awesome/css/font-awesome.min.css"; 3 | -------------------------------------------------------------------------------- /src/app/model/product.model.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface Product { 3 | id:number; 4 | name:string; 5 | price:number; 6 | quantity:number; 7 | selected:boolean; 8 | available:boolean; 9 | } 10 | -------------------------------------------------------------------------------- /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 = 'products-app-ngrx'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/prdouct-item/prdouct-item.component.html: -------------------------------------------------------------------------------- 1 | 2 | {{product.id}} 3 | {{product.name}} 4 | {{product.price}} 5 | {{product.quantity}} 6 | {{product.selected}} 7 | {{product.available}} 8 | 9 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | async navigateTo(): Promise { 5 | return browser.get(browser.baseUrl); 6 | } 7 | 8 | async getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/app/components/products/products-nav-bar/products-nav-bar.component.html: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /db.json: -------------------------------------------------------------------------------- 1 | { 2 | "products": [ 3 | {"id": 1,"name": "Computer","price": 60000,"quantity": 12,"selected": true,"available": true}, 4 | {"id": 2,"name": "Printer","price": 1200,"quantity": 10,"selected": true,"available": false}, 5 | {"id": 3,"name": "Smartphone","price": 2000,"quantity": 32,"selected": false,"available": true} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /e2e/tsconfig.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/e2e", 6 | "module": "commonjs", 7 | "target": "es2018", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.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/app/components/products/products-list/products-list.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
IDNamePriceQuantitySelectedAvailable
7 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ProductsAppNgrx 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/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import {ProductsComponent} from './components/products/products.component'; 4 | 5 | const routes: Routes = [ 6 | { 7 | path:"products", component:ProductsComponent 8 | } 9 | ]; 10 | 11 | @NgModule({ 12 | imports: [RouterModule.forRoot(routes)], 13 | exports: [RouterModule] 14 | }) 15 | export class AppRoutingModule { } 16 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/prdouct-item/prdouct-item.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, Input, OnInit} from '@angular/core'; 2 | import {Product} from '../../../../model/product.model'; 3 | 4 | @Component({ 5 | selector: 'app-prdouct-item', 6 | templateUrl: './prdouct-item.component.html', 7 | styleUrls: ['./prdouct-item.component.css'] 8 | }) 9 | export class PrdouctItemComponent implements OnInit { 10 | @Input() product:Product|null=null; 11 | constructor() { } 12 | 13 | ngOnInit(): void { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/products-list.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, Input, OnInit} from '@angular/core'; 2 | import {ProductsState} from '../../../ngrx/products.reducer'; 3 | 4 | @Component({ 5 | selector: 'app-products-list', 6 | templateUrl: './products-list.component.html', 7 | styleUrls: ['./products-list.component.css'] 8 | }) 9 | export class ProductsListComponent implements OnInit { 10 | 11 | @Input() state:ProductsState|null=null; 12 | 13 | constructor() { } 14 | 15 | ngOnInit(): void { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /.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 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', async () => { 12 | await page.navigateTo(); 13 | expect(await page.getTitleText()).toEqual('products-app-ngrx app is running!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /src/app/components/products/products.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductsComponent } from './products.component'; 4 | 5 | describe('ProductsComponent', () => { 6 | let component: ProductsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductsComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/products/products-nav-bar/products-nav-bar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {Store} from '@ngrx/store'; 3 | import {GetAllProductsAction, GetSelectedProductsAction} from '../../../ngrx/products.actions'; 4 | 5 | @Component({ 6 | selector: 'app-products-nav-bar', 7 | templateUrl: './products-nav-bar.component.html', 8 | styleUrls: ['./products-nav-bar.component.css'] 9 | }) 10 | export class ProductsNavBarComponent implements OnInit { 11 | 12 | constructor(private store:Store) { } 13 | 14 | ngOnInit(): void { 15 | } 16 | 17 | onGetAllProducts() { 18 | this.store.dispatch(new GetAllProductsAction({})) 19 | } 20 | 21 | onGetSelectedProducts() { 22 | this.store.dispatch(new GetSelectedProductsAction({})) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/app/components/products/products.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {Store} from '@ngrx/store'; 3 | import {Observable} from 'rxjs'; 4 | import {ProductsState, ProductsStateEnum} from '../../ngrx/products.reducer'; 5 | import {map} from 'rxjs/operators'; 6 | 7 | @Component({ 8 | selector: 'app-products', 9 | templateUrl: './products.component.html', 10 | styleUrls: ['./products.component.css'] 11 | }) 12 | export class ProductsComponent implements OnInit { 13 | productsState$:Observable|null=null; 14 | readonly ProductsStateEnum= ProductsStateEnum; 15 | constructor(private store:Store) { } 16 | 17 | ngOnInit(): void { 18 | this.productsState$=this.store.pipe( 19 | map((state)=> state.catalogState) 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 | host:"http://localhost:3000", 8 | unreachableHost:"http://localhost:3008" 9 | }; 10 | 11 | /* 12 | * For easier debugging in development mode, you can import the following file 13 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 14 | * 15 | * This import should be commented out in production mode because it will have a negative impact 16 | * on performance if an error is thrown. 17 | */ 18 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 19 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/products-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductsListComponent } from './products-list.component'; 4 | 5 | describe('ProductsListComponent', () => { 6 | let component: ProductsListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductsListComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductsListComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/products/products.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
Initial State
6 |
7 | 8 |
Loading...
9 |
10 | 11 |
{{state.errorMessage |json}}
12 |
13 | 14 | 15 | 16 |
17 |
18 | -------------------------------------------------------------------------------- /.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 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /src/app/components/products/products-list/prdouct-item/prdouct-item.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { PrdouctItemComponent } from './prdouct-item.component'; 4 | 5 | describe('PrdouctItemComponent', () => { 6 | let component: PrdouctItemComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ PrdouctItemComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(PrdouctItemComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/products/products-nav-bar/products-nav-bar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductsNavBarComponent } from './products-nav-bar.component'; 4 | 5 | describe('ProductsNavBarComponent', () => { 6 | let component: ProductsNavBarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductsNavBarComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductsNavBarComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /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: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /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": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "moduleResolution": "node", 16 | "importHelpers": true, 17 | "target": "es2015", 18 | "module": "es2020", 19 | "lib": [ 20 | "es2018", 21 | "dom" 22 | ] 23 | }, 24 | "angularCompilerOptions": { 25 | "strictInjectionParameters": true, 26 | "strictInputAccessModifiers": true, 27 | "strictTemplates": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 27 | 28 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | SELENIUM_PROMISE_MANAGER: false, 20 | baseUrl: 'http://localhost:4200/', 21 | framework: 'jasmine', 22 | jasmineNodeOpts: { 23 | showColors: true, 24 | defaultTimeoutInterval: 30000, 25 | print: function() {} 26 | }, 27 | onPrepare() { 28 | require('ts-node').register({ 29 | project: require('path').join(__dirname, './tsconfig.json') 30 | }); 31 | jasmine.getEnv().addReporter(new SpecReporter({ 32 | spec: { 33 | displayStacktrace: StacktraceOption.PRETTY 34 | } 35 | })); 36 | } 37 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProductsAppNgrx 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.0.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. Use the `--prod` flag for a production build. 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 [Protractor](http://www.protractortest.org/). 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 'products-app-ngrx'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('products-app-ngrx'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('products-app-ngrx app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import {HttpClientModule} from '@angular/common/http'; 7 | import { ProductsComponent } from './components/products/products.component'; 8 | import { ProductsNavBarComponent } from './components/products/products-nav-bar/products-nav-bar.component'; 9 | import {StoreModule} from '@ngrx/store'; 10 | import {EffectsModule} from '@ngrx/effects'; 11 | import {StoreDevtoolsModule} from '@ngrx/store-devtools'; 12 | import {productsReducer} from './ngrx/products.reducer'; 13 | import {ProductsEffects} from './ngrx/products.effects'; 14 | import { ProductsListComponent } from './components/products/products-list/products-list.component'; 15 | import { PrdouctItemComponent } from './components/products/products-list/prdouct-item/prdouct-item.component'; 16 | 17 | // @ts-ignore 18 | @NgModule({ 19 | declarations: [ 20 | AppComponent, 21 | ProductsComponent, 22 | ProductsNavBarComponent, 23 | ProductsListComponent, 24 | PrdouctItemComponent 25 | ], 26 | imports: [ 27 | BrowserModule, 28 | AppRoutingModule, 29 | HttpClientModule, 30 | StoreModule.forRoot({catalogState:productsReducer}), 31 | EffectsModule.forRoot([ProductsEffects]), 32 | StoreDevtoolsModule.instrument() 33 | ], 34 | providers: [], 35 | bootstrap: [AppComponent] 36 | }) 37 | export class AppModule { } 38 | -------------------------------------------------------------------------------- /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/products-app-ngrx'), 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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "products-app-ngrx", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "concurrently \"ng serve\" \"json-server --watch db.json\"", 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": "~11.0.6", 15 | "@angular/common": "~11.0.6", 16 | "@angular/compiler": "~11.0.6", 17 | "@angular/core": "~11.0.6", 18 | "@angular/forms": "~11.0.6", 19 | "@angular/platform-browser": "~11.0.6", 20 | "@angular/platform-browser-dynamic": "~11.0.6", 21 | "@angular/router": "~11.0.6", 22 | "@ngrx/effects": "^11.0.1", 23 | "@ngrx/store": "^11.0.1", 24 | "@ngrx/store-devtools": "^11.0.1", 25 | "bootstrap": "^4.6.0", 26 | "concurrently": "^6.0.0", 27 | "font-awesome": "^4.7.0", 28 | "jquery": "^3.5.1", 29 | "json-server": "^0.16.3", 30 | "rxjs": "~6.6.0", 31 | "tslib": "^2.0.0", 32 | "zone.js": "~0.10.2" 33 | }, 34 | "devDependencies": { 35 | "@angular-devkit/build-angular": "~0.1100.6", 36 | "@angular/cli": "~11.0.6", 37 | "@angular/compiler-cli": "~11.0.6", 38 | "@types/jasmine": "~3.6.0", 39 | "@types/node": "^12.11.1", 40 | "codelyzer": "^6.0.0", 41 | "jasmine-core": "~3.6.0", 42 | "jasmine-spec-reporter": "~5.0.0", 43 | "karma": "~5.1.0", 44 | "karma-chrome-launcher": "~3.1.0", 45 | "karma-coverage": "~2.0.3", 46 | "karma-jasmine": "~4.0.0", 47 | "karma-jasmine-html-reporter": "^1.5.0", 48 | "protractor": "~7.0.0", 49 | "ts-node": "~8.3.0", 50 | "tslint": "~6.1.0", 51 | "typescript": "~4.0.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/app/ngrx/products.reducer.ts: -------------------------------------------------------------------------------- 1 | import {Product} from '../model/product.model'; 2 | import {ProductsActions, ProductsActionsTypes} from './products.actions'; 3 | import {Action} from '@ngrx/store'; 4 | 5 | export enum ProductsStateEnum{ 6 | LOADING="Loading", 7 | LOADED="Loaded", 8 | ERROR="Error", 9 | INITIAL="Initial" 10 | } 11 | export interface ProductsState{ 12 | products:Product[], 13 | errorMessage:string, 14 | dataState:ProductsStateEnum 15 | } 16 | 17 | const initState:ProductsState={ 18 | products:[], 19 | errorMessage:"", 20 | dataState:ProductsStateEnum.INITIAL 21 | } 22 | 23 | export function productsReducer(state=initState, action:Action):ProductsState { 24 | switch (action.type) { 25 | case ProductsActionsTypes.GET_ALL_PRODUCTS: 26 | return {...state, dataState:ProductsStateEnum.LOADING } 27 | case ProductsActionsTypes.GET_ALL_PRODUCTS_SUCCESS: 28 | return {...state, dataState:ProductsStateEnum.LOADED, products:(action).payload} 29 | case ProductsActionsTypes.GET_ALL_PRODUCTS_ERROR: 30 | return {...state, dataState:ProductsStateEnum.ERROR, errorMessage:(action).payload} 31 | /* Get Selected Products*/ 32 | case ProductsActionsTypes.GET_SELECTED_PRODUCTS: 33 | return {...state, dataState:ProductsStateEnum.LOADING } 34 | case ProductsActionsTypes.GET_SELECTED_PRODUCTS_SUCCESS: 35 | return {...state, dataState:ProductsStateEnum.LOADED, products:(action).payload} 36 | case ProductsActionsTypes.GET_SELECTED_PRODUCTS_ERROR: 37 | return {...state, dataState:ProductsStateEnum.ERROR, errorMessage:(action).payload} 38 | default : return {...state} 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/app/ngrx/products.effects.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {ProductService} from '../services/product.service'; 3 | import {Actions, createEffect, ofType} from '@ngrx/effects'; 4 | import {Observable, of} from 'rxjs'; 5 | import {Action} from '@ngrx/store'; 6 | import { 7 | GetAllProductsActionError, 8 | GetAllProductsActionSuccess, GetSelectedProductsActionError, 9 | GetSelectedProductsActionSuccess, 10 | ProductsActions, 11 | ProductsActionsTypes 12 | } from './products.actions'; 13 | import {catchError, map, mergeMap} from 'rxjs/operators'; 14 | 15 | @Injectable() 16 | export class ProductsEffects { 17 | constructor(private productService:ProductService, private effectActions:Actions) { 18 | } 19 | 20 | getAllProductsEffect:Observable=createEffect( 21 | ()=>this.effectActions.pipe( 22 | ofType(ProductsActionsTypes.GET_ALL_PRODUCTS), 23 | mergeMap((action)=>{ 24 | return this.productService.getProducts() 25 | .pipe( 26 | map((products)=> new GetAllProductsActionSuccess(products)), 27 | catchError((err)=>of(new GetAllProductsActionError(err.message))) 28 | ) 29 | }) 30 | ) 31 | ); 32 | 33 | /* Get Selected Products*/ 34 | getSelectedProductsEffect:Observable=createEffect( 35 | ()=>this.effectActions.pipe( 36 | ofType(ProductsActionsTypes.GET_SELECTED_PRODUCTS), 37 | mergeMap((action)=>{ 38 | return this.productService.getSelectedProducts() 39 | .pipe( 40 | map((products)=> new GetSelectedProductsActionSuccess(products)), 41 | catchError((err)=>of(new GetSelectedProductsActionError(err.message))) 42 | ) 43 | }) 44 | ) 45 | ); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/app/services/product.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @author : Mohamed YOUSSFI, med@youssfi.net, 3 | * ENSET Mohammedia, Université Hassan II de Casablanca 4 | * 5 | */ 6 | import {Injectable} from '@angular/core'; 7 | import {HttpClient} from '@angular/common/http'; 8 | import {Observable} from 'rxjs'; 9 | import {environment} from '../../environments/environment'; 10 | import {Product} from '../model/product.model'; 11 | 12 | @Injectable({providedIn:"root"}) 13 | export class ProductService { 14 | 15 | constructor(private http:HttpClient) { 16 | } 17 | 18 | public getProducts():Observable{ 19 | let host=Math.random()>0.2?environment.host:environment.unreachableHost; 20 | //let host=environment.host; 21 | return this.http.get(host+"/products"); 22 | //return throwError("Not Implemented yet"); 23 | } 24 | public getSelectedProducts():Observable{ 25 | return this.http.get(environment.host+"/products?selected=true"); 26 | } 27 | public getAvailableProducts():Observable{ 28 | return this.http.get(environment.host+"/products?available=true"); 29 | } 30 | 31 | public searchProducts(name:string):Observable{ 32 | return this.http.get(environment.host+"/products?name_like="+name); 33 | } 34 | public setSelected(product:Product):Observable{ 35 | return this.http.put(environment.host+"/products/"+product.id,{...product,selected:!product.selected}); 36 | } 37 | public delete(id:number):Observable{ 38 | return this.http.delete(environment.host+"/products/"+id); 39 | } 40 | public save(product:Product):Observable{ 41 | return this.http.post(environment.host+"/products/",product); 42 | } 43 | public update(product:Product):Observable{ 44 | return this.http.put(environment.host+"/products/"+product.id,product); 45 | } 46 | public getProductById(id:number):Observable{ 47 | return this.http.get(environment.host+"/products/"+id); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/app/ngrx/products.actions.ts: -------------------------------------------------------------------------------- 1 | import {Action} from '@ngrx/store'; 2 | import {Product} from '../model/product.model'; 3 | 4 | export enum ProductsActionsTypes{ 5 | /* Get All products*/ 6 | GET_ALL_PRODUCTS="[Products] Get All products", 7 | GET_ALL_PRODUCTS_SUCCESS="[Products] Get All products Success", 8 | GET_ALL_PRODUCTS_ERROR="[Products] Get All products Error", 9 | 10 | /* Get Selected products*/ 11 | GET_SELECTED_PRODUCTS="[Products] Get Selected products", 12 | GET_SELECTED_PRODUCTS_SUCCESS="[Products] Get Selected products Success", 13 | GET_SELECTED_PRODUCTS_ERROR="[Products] Get Selected products Error", 14 | } 15 | 16 | export class GetAllProductsAction implements Action{ 17 | type: ProductsActionsTypes=ProductsActionsTypes.GET_ALL_PRODUCTS; 18 | constructor(public payload:any) { 19 | } 20 | } 21 | 22 | export class GetAllProductsActionSuccess implements Action{ 23 | type: ProductsActionsTypes=ProductsActionsTypes.GET_ALL_PRODUCTS_SUCCESS; 24 | constructor(public payload:Product[]) { 25 | } 26 | } 27 | 28 | export class GetAllProductsActionError implements Action{ 29 | type: ProductsActionsTypes=ProductsActionsTypes.GET_ALL_PRODUCTS_ERROR; 30 | constructor(public payload:string) { 31 | } 32 | } 33 | 34 | /* Get Selected Products Actions*/ 35 | 36 | export class GetSelectedProductsAction implements Action{ 37 | type: ProductsActionsTypes=ProductsActionsTypes.GET_SELECTED_PRODUCTS; 38 | constructor(public payload:any) { 39 | } 40 | } 41 | 42 | export class GetSelectedProductsActionSuccess implements Action{ 43 | type: ProductsActionsTypes=ProductsActionsTypes.GET_SELECTED_PRODUCTS_SUCCESS; 44 | constructor(public payload:Product[]) { 45 | } 46 | } 47 | 48 | export class GetSelectedProductsActionError implements Action{ 49 | type: ProductsActionsTypes=ProductsActionsTypes.GET_SELECTED_PRODUCTS_ERROR; 50 | constructor(public payload:string) { 51 | } 52 | } 53 | 54 | export type ProductsActions= 55 | GetAllProductsAction | GetAllProductsActionSuccess | GetAllProductsActionError 56 | | GetSelectedProductsAction | GetSelectedProductsActionSuccess | GetSelectedProductsActionError 57 | ; 58 | -------------------------------------------------------------------------------- /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/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "align": { 8 | "options": [ 9 | "parameters", 10 | "statements" 11 | ] 12 | }, 13 | "array-type": false, 14 | "arrow-return-shorthand": true, 15 | "curly": true, 16 | "deprecation": { 17 | "severity": "warning" 18 | }, 19 | "eofline": true, 20 | "import-blacklist": [ 21 | true, 22 | "rxjs/Rx" 23 | ], 24 | "import-spacing": true, 25 | "indent": { 26 | "options": [ 27 | "spaces" 28 | ] 29 | }, 30 | "max-classes-per-file": false, 31 | "max-line-length": [ 32 | true, 33 | 140 34 | ], 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-console": [ 47 | true, 48 | "debug", 49 | "info", 50 | "time", 51 | "timeEnd", 52 | "trace" 53 | ], 54 | "no-empty": false, 55 | "no-inferrable-types": [ 56 | true, 57 | "ignore-params" 58 | ], 59 | "no-non-null-assertion": true, 60 | "no-redundant-jsdoc": true, 61 | "no-switch-case-fall-through": true, 62 | "no-var-requires": false, 63 | "object-literal-key-quotes": [ 64 | true, 65 | "as-needed" 66 | ], 67 | "quotemark": [ 68 | true, 69 | "single" 70 | ], 71 | "semicolon": { 72 | "options": [ 73 | "always" 74 | ] 75 | }, 76 | "space-before-function-paren": { 77 | "options": { 78 | "anonymous": "never", 79 | "asyncArrow": "always", 80 | "constructor": "never", 81 | "method": "never", 82 | "named": "never" 83 | } 84 | }, 85 | "typedef": [ 86 | true, 87 | "call-signature" 88 | ], 89 | "typedef-whitespace": { 90 | "options": [ 91 | { 92 | "call-signature": "nospace", 93 | "index-signature": "nospace", 94 | "parameter": "nospace", 95 | "property-declaration": "nospace", 96 | "variable-declaration": "nospace" 97 | }, 98 | { 99 | "call-signature": "onespace", 100 | "index-signature": "onespace", 101 | "parameter": "onespace", 102 | "property-declaration": "onespace", 103 | "variable-declaration": "onespace" 104 | } 105 | ] 106 | }, 107 | "variable-name": { 108 | "options": [ 109 | "ban-keywords", 110 | "check-format", 111 | "allow-pascal-case" 112 | ] 113 | }, 114 | "whitespace": { 115 | "options": [ 116 | "check-branch", 117 | "check-decl", 118 | "check-operator", 119 | "check-separator", 120 | "check-type", 121 | "check-typecast" 122 | ] 123 | }, 124 | "component-class-suffix": true, 125 | "contextual-lifecycle": true, 126 | "directive-class-suffix": true, 127 | "no-conflicting-lifecycle": true, 128 | "no-host-metadata-property": true, 129 | "no-input-rename": true, 130 | "no-inputs-metadata-property": true, 131 | "no-output-native": true, 132 | "no-output-on-prefix": true, 133 | "no-output-rename": true, 134 | "no-outputs-metadata-property": true, 135 | "template-banana-in-box": true, 136 | "template-no-negated-async": true, 137 | "use-lifecycle-interface": true, 138 | "use-pipe-transform-interface": true, 139 | "directive-selector": [ 140 | true, 141 | "attribute", 142 | "app", 143 | "camelCase" 144 | ], 145 | "component-selector": [ 146 | true, 147 | "element", 148 | "app", 149 | "kebab-case" 150 | ] 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "products-app-ngrx": { 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/products-app-ngrx", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "tsconfig.app.json", 25 | "aot": true, 26 | "assets": [ 27 | "src/favicon.ico", 28 | "src/assets" 29 | ], 30 | "styles": [ 31 | "src/styles.css", 32 | "node_modules/bootstrap/dist/css/bootstrap.min.css" 33 | ], 34 | "scripts": [ 35 | "node_modules/jquery/dist/jquery.min.js", 36 | "node_modules/bootstrap/dist/js/bootstrap.min.js" 37 | ] 38 | }, 39 | "configurations": { 40 | "production": { 41 | "fileReplacements": [ 42 | { 43 | "replace": "src/environments/environment.ts", 44 | "with": "src/environments/environment.prod.ts" 45 | } 46 | ], 47 | "optimization": true, 48 | "outputHashing": "all", 49 | "sourceMap": false, 50 | "namedChunks": false, 51 | "extractLicenses": true, 52 | "vendorChunk": false, 53 | "buildOptimizer": true, 54 | "budgets": [ 55 | { 56 | "type": "initial", 57 | "maximumWarning": "500kb", 58 | "maximumError": "1mb" 59 | }, 60 | { 61 | "type": "anyComponentStyle", 62 | "maximumWarning": "2kb", 63 | "maximumError": "4kb" 64 | } 65 | ] 66 | } 67 | } 68 | }, 69 | "serve": { 70 | "builder": "@angular-devkit/build-angular:dev-server", 71 | "options": { 72 | "browserTarget": "products-app-ngrx:build" 73 | }, 74 | "configurations": { 75 | "production": { 76 | "browserTarget": "products-app-ngrx:build:production" 77 | } 78 | } 79 | }, 80 | "extract-i18n": { 81 | "builder": "@angular-devkit/build-angular:extract-i18n", 82 | "options": { 83 | "browserTarget": "products-app-ngrx:build" 84 | } 85 | }, 86 | "test": { 87 | "builder": "@angular-devkit/build-angular:karma", 88 | "options": { 89 | "main": "src/test.ts", 90 | "polyfills": "src/polyfills.ts", 91 | "tsConfig": "tsconfig.spec.json", 92 | "karmaConfig": "karma.conf.js", 93 | "assets": [ 94 | "src/favicon.ico", 95 | "src/assets" 96 | ], 97 | "styles": [ 98 | "src/styles.css" 99 | ], 100 | "scripts": [] 101 | } 102 | }, 103 | "lint": { 104 | "builder": "@angular-devkit/build-angular:tslint", 105 | "options": { 106 | "tsConfig": [ 107 | "tsconfig.app.json", 108 | "tsconfig.spec.json", 109 | "e2e/tsconfig.json" 110 | ], 111 | "exclude": [ 112 | "**/node_modules/**" 113 | ] 114 | } 115 | }, 116 | "e2e": { 117 | "builder": "@angular-devkit/build-angular:protractor", 118 | "options": { 119 | "protractorConfig": "e2e/protractor.conf.js", 120 | "devServerTarget": "products-app-ngrx:serve" 121 | }, 122 | "configurations": { 123 | "production": { 124 | "devServerTarget": "products-app-ngrx:serve:production" 125 | } 126 | } 127 | } 128 | } 129 | } 130 | }, 131 | "defaultProject": "products-app-ngrx", 132 | "cli": { 133 | "analytics": "8f27436a-24fa-43ef-844b-d0c9a24e2d7b" 134 | } 135 | } --------------------------------------------------------------------------------