├── .browserslistrc ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── db.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── components │ │ ├── home │ │ │ ├── home.component.css │ │ │ ├── home.component.html │ │ │ ├── home.component.spec.ts │ │ │ └── home.component.ts │ │ ├── nav-bar │ │ │ ├── nav-bar.component.css │ │ │ ├── nav-bar.component.html │ │ │ ├── nav-bar.component.spec.ts │ │ │ └── nav-bar.component.ts │ │ ├── product-add │ │ │ ├── product-add.component.css │ │ │ ├── product-add.component.html │ │ │ ├── product-add.component.spec.ts │ │ │ └── product-add.component.ts │ │ ├── product-edit │ │ │ ├── product-edit.component.css │ │ │ ├── product-edit.component.html │ │ │ ├── product-edit.component.spec.ts │ │ │ └── product-edit.component.ts │ │ └── products │ │ │ ├── products.component.css │ │ │ ├── products.component.html │ │ │ ├── products.component.spec.ts │ │ │ └── products.component.ts │ ├── model │ │ └── product.model.ts │ ├── services │ │ └── products.service.ts │ └── state │ │ └── product.state.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css └── test.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WebCatApp 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 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "web-cat-app": { 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/web-cat-app", 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": "web-cat-app:build" 73 | }, 74 | "configurations": { 75 | "production": { 76 | "browserTarget": "web-cat-app:build:production" 77 | } 78 | } 79 | }, 80 | "extract-i18n": { 81 | "builder": "@angular-devkit/build-angular:extract-i18n", 82 | "options": { 83 | "browserTarget": "web-cat-app: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": "web-cat-app:serve" 121 | }, 122 | "configurations": { 123 | "production": { 124 | "devServerTarget": "web-cat-app:serve:production" 125 | } 126 | } 127 | } 128 | } 129 | } 130 | }, 131 | "defaultProject": "web-cat-app", 132 | "cli": { 133 | "analytics": "dffac1ec-51a9-47c1-93d6-233efae567f4" 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /db.json: -------------------------------------------------------------------------------- 1 | { 2 | "products": [ 3 | { 4 | "id": 1, 5 | "name": "Computer", 6 | "price": 4300, 7 | "quantity": "99999", 8 | "selected": true, 9 | "available": true 10 | }, 11 | { 12 | "name": "p", 13 | "price": "90", 14 | "quantity": 0, 15 | "selected": true, 16 | "available": true, 17 | "id": 2 18 | }, 19 | { 20 | "id": 3, 21 | "name": "azerty", 22 | "price": 0, 23 | "quantity": 0, 24 | "selected": true, 25 | "available": true 26 | } 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 | }; -------------------------------------------------------------------------------- /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('web-cat-app 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/web-cat-app'), 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": "web-cat-app", 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 | "bootstrap": "^4.6.0", 23 | "concurrently": "^5.3.0", 24 | "font-awesome": "^4.7.0", 25 | "jquery": "^3.5.1", 26 | "json-server": "^0.16.3", 27 | "rxjs": "~6.6.0", 28 | "tslib": "^2.0.0", 29 | "zone.js": "~0.10.2" 30 | }, 31 | "devDependencies": { 32 | "@angular-devkit/build-angular": "~0.1100.6", 33 | "@angular/cli": "~11.0.6", 34 | "@angular/compiler-cli": "~11.0.6", 35 | "@types/jasmine": "~3.6.0", 36 | "@types/node": "^12.11.1", 37 | "codelyzer": "^6.0.0", 38 | "jasmine-core": "~3.6.0", 39 | "jasmine-spec-reporter": "~5.0.0", 40 | "karma": "~5.1.0", 41 | "karma-chrome-launcher": "~3.1.0", 42 | "karma-coverage": "~2.0.3", 43 | "karma-jasmine": "~4.0.0", 44 | "karma-jasmine-html-reporter": "^1.5.0", 45 | "protractor": "~7.0.0", 46 | "ts-node": "~8.3.0", 47 | "tslint": "~6.1.0", 48 | "typescript": "~4.0.2" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /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 | import {HomeComponent} from './components/home/home.component'; 5 | import {ProductAddComponent} from './components/product-add/product-add.component'; 6 | import {ProductEditComponent} from './components/product-edit/product-edit.component'; 7 | 8 | const routes: Routes = [ 9 | { path: "products", component:ProductsComponent}, 10 | { path: "newProduct", component:ProductAddComponent}, 11 | { path: "editProduct/:id", component:ProductEditComponent}, 12 | { path: "", component:HomeComponent}, 13 | ]; 14 | 15 | @NgModule({ 16 | imports: [RouterModule.forRoot(routes)], 17 | exports: [RouterModule] 18 | }) 19 | export class AppRoutingModule { } 20 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /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 'web-cat-app'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('web-cat-app'); 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('web-cat-app app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /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 = 'web-cat-app'; 10 | } 11 | -------------------------------------------------------------------------------- /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 { NavBarComponent } from './components/nav-bar/nav-bar.component'; 7 | import { ProductsComponent } from './components/products/products.component'; 8 | import { HomeComponent } from './components/home/home.component'; 9 | import {HttpClientModule} from '@angular/common/http'; 10 | import {FormsModule, ReactiveFormsModule} from '@angular/forms'; 11 | import { ProductAddComponent } from './components/product-add/product-add.component'; 12 | import { ProductEditComponent } from './components/product-edit/product-edit.component'; 13 | 14 | @NgModule({ 15 | declarations: [ 16 | AppComponent, 17 | NavBarComponent, 18 | ProductsComponent, 19 | HomeComponent, 20 | ProductAddComponent, 21 | ProductEditComponent 22 | ], 23 | imports: [ 24 | BrowserModule, 25 | AppRoutingModule, 26 | HttpClientModule, 27 | FormsModule, 28 | ReactiveFormsModule 29 | ], 30 | providers: [], 31 | bootstrap: [AppComponent] 32 | }) 33 | export class AppModule { } 34 | -------------------------------------------------------------------------------- /src/app/components/home/home.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/app/components/home/home.component.css -------------------------------------------------------------------------------- /src/app/components/home/home.component.html: -------------------------------------------------------------------------------- 1 |

home works!

2 | -------------------------------------------------------------------------------- /src/app/components/home/home.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HomeComponent } from './home.component'; 4 | 5 | describe('HomeComponent', () => { 6 | let component: HomeComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ HomeComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(HomeComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-home', 5 | templateUrl: './home.component.html', 6 | styleUrls: ['./home.component.css'] 7 | }) 8 | export class HomeComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/components/nav-bar/nav-bar.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/app/components/nav-bar/nav-bar.component.css -------------------------------------------------------------------------------- /src/app/components/nav-bar/nav-bar.component.html: -------------------------------------------------------------------------------- 1 | 27 | -------------------------------------------------------------------------------- /src/app/components/nav-bar/nav-bar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NavBarComponent } from './nav-bar.component'; 4 | 5 | describe('NavBarComponent', () => { 6 | let component: NavBarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ NavBarComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NavBarComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/nav-bar/nav-bar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-nav-bar', 5 | templateUrl: './nav-bar.component.html', 6 | styleUrls: ['./nav-bar.component.css'] 7 | }) 8 | export class NavBarComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/components/product-add/product-add.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/app/components/product-add/product-add.component.css -------------------------------------------------------------------------------- /src/app/components/product-add/product-add.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 7 |
8 |
Name is Required
9 |
10 | 11 |
12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 | 29 |
30 |
31 | -------------------------------------------------------------------------------- /src/app/components/product-add/product-add.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductAddComponent } from './product-add.component'; 4 | 5 | describe('ProductAddComponent', () => { 6 | let component: ProductAddComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductAddComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductAddComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/product-add/product-add.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {FormBuilder, FormGroup, Validators} from '@angular/forms'; 3 | import {ProductsService} from '../../services/products.service'; 4 | 5 | @Component({ 6 | selector: 'app-product-add', 7 | templateUrl: './product-add.component.html', 8 | styleUrls: ['./product-add.component.css'] 9 | }) 10 | export class ProductAddComponent implements OnInit { 11 | 12 | productFormGroup?:FormGroup; 13 | submitted:boolean=false; 14 | 15 | constructor(private fb:FormBuilder, private productsService:ProductsService) { } 16 | 17 | ngOnInit(): void { 18 | this.productFormGroup=this.fb.group({ 19 | name:["",Validators.required], 20 | price:[0,Validators.required], 21 | quantity:[0,Validators.required], 22 | selected:[true,Validators.required], 23 | available:[true,Validators.required], 24 | }); 25 | } 26 | 27 | onSaveProduct() { 28 | this.submitted=true; 29 | if(this.productFormGroup?.invalid) return; 30 | this.productsService.save(this.productFormGroup?.value) 31 | .subscribe(data=>{ 32 | alert("Success Saving product"); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/app/components/product-edit/product-edit.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/app/components/product-edit/product-edit.component.css -------------------------------------------------------------------------------- /src/app/components/product-edit/product-edit.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 6 |
7 |
8 | 9 | 11 |
12 |
Name is Required
13 |
14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 |
29 | 30 | 31 |
32 | 33 |
34 |
35 | -------------------------------------------------------------------------------- /src/app/components/product-edit/product-edit.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductEditComponent } from './product-edit.component'; 4 | 5 | describe('ProductEditComponent', () => { 6 | let component: ProductEditComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ ProductEditComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductEditComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/product-edit/product-edit.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {ActivatedRoute} from '@angular/router'; 3 | import {ProductsService} from '../../services/products.service'; 4 | import {FormBuilder, FormGroup, Validators} from '@angular/forms'; 5 | 6 | @Component({ 7 | selector: 'app-product-edit', 8 | templateUrl: './product-edit.component.html', 9 | styleUrls: ['./product-edit.component.css'] 10 | }) 11 | export class ProductEditComponent implements OnInit { 12 | productId:number; 13 | productFormGroup?:FormGroup; 14 | private submitted:boolean=false; 15 | constructor(private activatedRoute:ActivatedRoute, 16 | private productsService:ProductsService, 17 | private fb:FormBuilder) { 18 | this.productId=activatedRoute.snapshot.params.id; 19 | } 20 | 21 | ngOnInit(): void { 22 | this.productsService.getProduct(this.productId) 23 | .subscribe(product=>{ 24 | this.productFormGroup=this.fb.group({ 25 | id:[product.id,Validators.required], 26 | name:[product.name,Validators.required], 27 | price:[product.price,Validators.required], 28 | quantity:[product.quantity,Validators.required], 29 | selected:[product.selected,Validators.required], 30 | available:[product.available,Validators.required] 31 | }) 32 | }); 33 | } 34 | 35 | onUpdateProduct() { 36 | this.productsService.updateProduct(this.productFormGroup?.value) 37 | .subscribe(data=>{ 38 | alert("Success Product updated"); 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/app/components/products/products.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/app/components/products/products.component.css -------------------------------------------------------------------------------- /src/app/components/products/products.component.html: -------------------------------------------------------------------------------- 1 | 30 |
31 | 32 | 33 | Loading ..... 34 | 35 | 36 |
37 | {{result.errorMessage}} 38 |
39 |
40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 58 | 63 | 68 | 69 |
IDNamePriceQuantitySelectedAvailable
{{p.id}}{{p.name}}{{p.price}}{{p.quantity}}{{p.selected}}{{p.available}} 53 | 57 | 59 | 62 | 64 | 67 |
70 |
71 |
72 |
73 | 74 | 75 | -------------------------------------------------------------------------------- /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.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {ProductsService} from '../../services/products.service'; 3 | import {Product} from '../../model/product.model'; 4 | import {Observable, of} from 'rxjs'; 5 | import {catchError, map, startWith} from 'rxjs/operators'; 6 | import {AppDataState, DataStateEnum} from '../../state/product.state'; 7 | import {Router} from '@angular/router'; 8 | 9 | @Component({ 10 | selector: 'app-products', 11 | templateUrl: './products.component.html', 12 | styleUrls: ['./products.component.css'] 13 | }) 14 | export class ProductsComponent implements OnInit { 15 | products$:Observable> |null=null; 16 | readonly DataStateEnum=DataStateEnum; 17 | 18 | constructor(private productsService:ProductsService, private router:Router) { } 19 | 20 | ngOnInit(): void { 21 | } 22 | 23 | onGetAllProducts() { 24 | this.products$= this.productsService.getAllProducts().pipe( 25 | map(data=>{ 26 | console.log(data); 27 | return ({dataState:DataStateEnum.LOADED,data:data}) 28 | }), 29 | startWith({dataState:DataStateEnum.LOADING}), 30 | catchError(err=>of({dataState:DataStateEnum.ERROR, errorMessage:err.message})) 31 | ); 32 | } 33 | 34 | onGetSelectedProducts() { 35 | this.products$= this.productsService.getSelectedProducts().pipe( 36 | map(data=>{ 37 | console.log(data); 38 | return ({dataState:DataStateEnum.LOADED,data:data}) 39 | }), 40 | startWith({dataState:DataStateEnum.LOADING}), 41 | catchError(err=>of({dataState:DataStateEnum.ERROR, errorMessage:err.message})) 42 | ); 43 | } 44 | 45 | onGetAvailableProducts() { 46 | this.products$= this.productsService.getAvailableProducts().pipe( 47 | map(data=>{ 48 | console.log(data); 49 | return ({dataState:DataStateEnum.LOADED,data:data}) 50 | }), 51 | startWith({dataState:DataStateEnum.LOADING}), 52 | catchError(err=>of({dataState:DataStateEnum.ERROR, errorMessage:err.message})) 53 | ); 54 | } 55 | 56 | onSearch(dataForm: any) { 57 | this.products$= this.productsService.searchProducts(dataForm.keyword).pipe( 58 | map(data=>{ 59 | console.log(data); 60 | return ({dataState:DataStateEnum.LOADED,data:data}) 61 | }), 62 | startWith({dataState:DataStateEnum.LOADING}), 63 | catchError(err=>of({dataState:DataStateEnum.ERROR, errorMessage:err.message})) 64 | ); 65 | } 66 | 67 | onSelect(p: Product) { 68 | this.productsService.select(p) 69 | .subscribe(data=>{ 70 | p.selected=data.selected; 71 | }) 72 | } 73 | 74 | onDelete(p: Product) { 75 | let v=confirm("Etes vous sûre?"); 76 | if(v==true) 77 | this.productsService.deleteProduct(p) 78 | .subscribe(data=>{ 79 | this.onGetAllProducts(); 80 | }) 81 | } 82 | 83 | onNewProduct() { 84 | this.router.navigateByUrl("/newProduct"); 85 | } 86 | 87 | onEdit(p: Product) { 88 | this.router.navigateByUrl("/editProduct/"+p.id); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/app/model/product.model.ts: -------------------------------------------------------------------------------- 1 | export interface Product { 2 | id:number; 3 | name:string; 4 | price:number; 5 | quantity:number; 6 | selected:boolean; 7 | available:boolean; 8 | } 9 | -------------------------------------------------------------------------------- /src/app/services/products.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {HttpClient} from '@angular/common/http'; 3 | import {environment} from '../../environments/environment'; 4 | import {Observable} from 'rxjs'; 5 | import {Product} from '../model/product.model'; 6 | 7 | @Injectable({providedIn:"root"}) 8 | export class ProductsService { 9 | constructor(private http:HttpClient) { 10 | } 11 | 12 | getAllProducts():Observable{ 13 | //let host=(Math.random()>0.2)?environment.host:environment.unreachableHost; 14 | let host=environment.host; 15 | return this.http.get(host+"/products"); 16 | } 17 | getSelectedProducts():Observable{ 18 | let host=environment.host; 19 | return this.http.get(host+"/products?selected=true"); 20 | } 21 | getAvailableProducts():Observable{ 22 | let host=environment.host; 23 | return this.http.get(host+"/products?available=true"); 24 | } 25 | searchProducts(keyword:string):Observable{ 26 | let host=environment.host; 27 | return this.http.get(host+"/products?name_like="+keyword); 28 | } 29 | select(product:Product):Observable{ 30 | let host=environment.host; 31 | product.selected=!product.selected; 32 | return this.http.put(host+"/products/"+product.id,product); 33 | } 34 | deleteProduct(product:Product):Observable{ 35 | let host=environment.host; 36 | product.selected=!product.selected; 37 | return this.http.delete(host+"/products/"+product.id); 38 | } 39 | save(product:Product):Observable{ 40 | let host=environment.host; 41 | return this.http.post(host+"/products",product); 42 | } 43 | getProduct(id:number):Observable{ 44 | let host=environment.host; 45 | return this.http.get(host+"/products/"+id); 46 | } 47 | updateProduct(product:Product):Observable{ 48 | let host=environment.host; 49 | return this.http.put(host+"/products/"+product.id,product); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/app/state/product.state.ts: -------------------------------------------------------------------------------- 1 | export enum DataStateEnum { 2 | LOADING, 3 | LOADED, 4 | ERROR 5 | } 6 | 7 | export interface AppDataState { 8 | dataState:DataStateEnum, 9 | data?:T, 10 | errorMessage?:string 11 | } 12 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/assets/.gitkeep -------------------------------------------------------------------------------- /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 | host:"http://localhost:3000", 8 | unreachableHost:"http://localhost:8000" 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/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/angular11-app-products-model1/da803e509d76e2f2df08e6804ded8c12db1a200d/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WebCatApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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.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.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------