├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── components │ │ ├── add-book │ │ │ ├── add-book.component.css │ │ │ ├── add-book.component.html │ │ │ ├── add-book.component.spec.ts │ │ │ └── add-book.component.ts │ │ ├── book-list │ │ │ ├── book-list.component.css │ │ │ ├── book-list.component.html │ │ │ ├── book-list.component.spec.ts │ │ │ └── book-list.component.ts │ │ └── edit-book │ │ │ ├── edit-book.component.css │ │ │ ├── edit-book.component.html │ │ │ ├── edit-book.component.spec.ts │ │ │ └── edit-book.component.ts │ ├── material.module.ts │ └── shared │ │ ├── book.service.ts │ │ └── book.ts ├── assets │ └── .gitkeep ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json └── tslint.json /.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 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # 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 | # angular-material7-firebase-crud-app 2 | Create Book inventory CRUD web app with Angular 7 framework using Angular Material 7, Firebase (AngularFire2) real-time NoSQL database. 3 | 4 | A book inventory CRUD web app in this app a user can do the following things. 5 | - Add a book 6 | - Read a book 7 | - Edit a book 8 | - Delete a book 9 | 10 | Step by step article on [Create Angular 7 Firebase 6 CRUD Web App with Angular Material 7](https://www.positronx.io/create-angular-7-firebase-crud-app-with-angular-material-7/) 11 | 12 | ## How to run the app? 13 | - Run `npm install` to install required dependencies. 14 | - Run `ng serve` to run the angular app 15 | 16 | ## Built with 17 | - Node 10.15.0 18 | - Angular 7.2.3 19 | - Firebase 6.0.2 20 | - Angular Material 7.3.7 21 | 22 | [Visit positronX.io to learn more about full stack software development](https://www.positronx.io/) 23 | 24 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-material7-firebase-crud-app": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/angular-material7-firebase-crud-app", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 27 | "src/styles.css" 28 | ], 29 | "scripts": [], 30 | "es5BrowserSupport": true 31 | }, 32 | "configurations": { 33 | "production": { 34 | "fileReplacements": [ 35 | { 36 | "replace": "src/environments/environment.ts", 37 | "with": "src/environments/environment.prod.ts" 38 | } 39 | ], 40 | "optimization": true, 41 | "outputHashing": "all", 42 | "sourceMap": false, 43 | "extractCss": true, 44 | "namedChunks": false, 45 | "aot": true, 46 | "extractLicenses": true, 47 | "vendorChunk": false, 48 | "buildOptimizer": true, 49 | "budgets": [ 50 | { 51 | "type": "initial", 52 | "maximumWarning": "2mb", 53 | "maximumError": "5mb" 54 | } 55 | ] 56 | } 57 | } 58 | }, 59 | "serve": { 60 | "builder": "@angular-devkit/build-angular:dev-server", 61 | "options": { 62 | "browserTarget": "angular-material7-firebase-crud-app:build" 63 | }, 64 | "configurations": { 65 | "production": { 66 | "browserTarget": "angular-material7-firebase-crud-app:build:production" 67 | } 68 | } 69 | }, 70 | "extract-i18n": { 71 | "builder": "@angular-devkit/build-angular:extract-i18n", 72 | "options": { 73 | "browserTarget": "angular-material7-firebase-crud-app:build" 74 | } 75 | }, 76 | "test": { 77 | "builder": "@angular-devkit/build-angular:karma", 78 | "options": { 79 | "main": "src/test.ts", 80 | "polyfills": "src/polyfills.ts", 81 | "tsConfig": "src/tsconfig.spec.json", 82 | "karmaConfig": "src/karma.conf.js", 83 | "styles": [ 84 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 85 | "src/styles.css" 86 | ], 87 | "scripts": [], 88 | "assets": [ 89 | "src/favicon.ico", 90 | "src/assets" 91 | ] 92 | } 93 | }, 94 | "lint": { 95 | "builder": "@angular-devkit/build-angular:tslint", 96 | "options": { 97 | "tsConfig": [ 98 | "src/tsconfig.app.json", 99 | "src/tsconfig.spec.json" 100 | ], 101 | "exclude": [ 102 | "**/node_modules/**" 103 | ] 104 | } 105 | } 106 | } 107 | }, 108 | "angular-material7-firebase-crud-app-e2e": { 109 | "root": "e2e/", 110 | "projectType": "application", 111 | "prefix": "", 112 | "architect": { 113 | "e2e": { 114 | "builder": "@angular-devkit/build-angular:protractor", 115 | "options": { 116 | "protractorConfig": "e2e/protractor.conf.js", 117 | "devServerTarget": "angular-material7-firebase-crud-app:serve" 118 | }, 119 | "configurations": { 120 | "production": { 121 | "devServerTarget": "angular-material7-firebase-crud-app:serve:production" 122 | } 123 | } 124 | }, 125 | "lint": { 126 | "builder": "@angular-devkit/build-angular:tslint", 127 | "options": { 128 | "tsConfig": "e2e/tsconfig.e2e.json", 129 | "exclude": [ 130 | "**/node_modules/**" 131 | ] 132 | } 133 | } 134 | } 135 | } 136 | }, 137 | "defaultProject": "angular-material7-firebase-crud-app" 138 | } -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 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', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to angular-material7-firebase-crud-app!'); 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 | navigateTo() { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-material7-firebase-crud-app", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~7.2.0", 15 | "@angular/cdk": "~7.3.7", 16 | "@angular/common": "~7.2.0", 17 | "@angular/compiler": "~7.2.0", 18 | "@angular/core": "~7.2.0", 19 | "@angular/fire": "^5.1.3", 20 | "@angular/forms": "~7.2.0", 21 | "@angular/material": "^7.3.7", 22 | "@angular/platform-browser": "~7.2.0", 23 | "@angular/platform-browser-dynamic": "~7.2.0", 24 | "@angular/router": "~7.2.0", 25 | "core-js": "^2.5.4", 26 | "firebase": "^6.0.4", 27 | "hammerjs": "^2.0.8", 28 | "rxjs": "~6.3.3", 29 | "tslib": "^1.9.0", 30 | "zone.js": "~0.8.26" 31 | }, 32 | "devDependencies": { 33 | "@angular-devkit/build-angular": "~0.13.0", 34 | "@angular/cli": "~7.3.9", 35 | "@angular/compiler-cli": "~7.2.0", 36 | "@angular/language-service": "~7.2.0", 37 | "@types/node": "~8.9.4", 38 | "@types/jasmine": "~2.8.8", 39 | "@types/jasminewd2": "~2.0.3", 40 | "codelyzer": "~4.5.0", 41 | "jasmine-core": "~2.99.1", 42 | "jasmine-spec-reporter": "~4.2.1", 43 | "karma": "~4.0.0", 44 | "karma-chrome-launcher": "~2.2.0", 45 | "karma-coverage-istanbul-reporter": "~2.0.1", 46 | "karma-jasmine": "~1.1.2", 47 | "karma-jasmine-html-reporter": "^0.2.2", 48 | "protractor": "~5.4.0", 49 | "ts-node": "~7.0.0", 50 | "tslint": "~5.11.0", 51 | "typescript": "~3.2.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | import { AddBookComponent } from './components/add-book/add-book.component'; 5 | import { BookListComponent } from './components/book-list/book-list.component'; 6 | import { EditBookComponent } from './components/edit-book/edit-book.component'; 7 | 8 | const routes: Routes = [ 9 | { path: '', pathMatch: 'full', redirectTo: 'add-book' }, 10 | { path: 'add-book', component: AddBookComponent }, 11 | { path: 'edit-book/:id', component: EditBookComponent }, 12 | { path: 'books-list', component: BookListComponent } 13 | ]; 14 | 15 | @NgModule({ 16 | imports: [RouterModule.forRoot(routes)], 17 | exports: [RouterModule] 18 | }) 19 | 20 | export class AppRoutingModule { } -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/angular-material7-firebase-crud-app/4e84b0fcd9daaff9f940dfdcc70662164e0e7139/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Book Store
4 | 5 | menu 6 | 7 |
8 | 9 | 10 | 11 | 13 | 14 | 15 | add Add Book 16 | 17 | 18 | format_list_bulleted View Books 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | 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.debugElement.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'angular-material7-firebase-crud-app'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.debugElement.componentInstance; 26 | expect(app.title).toEqual('angular-material7-firebase-crud-app'); 27 | }); 28 | 29 | it('should render title in a h1 tag', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.debugElement.nativeElement; 33 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular-material7-firebase-crud-app!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, ViewChild, HostListener, OnInit } from '@angular/core'; 2 | import { MatSidenav } from '@angular/material/sidenav'; 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.css'] 8 | }) 9 | 10 | export class AppComponent { 11 | opened = true; 12 | @ViewChild('sidenav') sidenav: MatSidenav; 13 | 14 | ngOnInit() { 15 | if (window.innerWidth < 768) { 16 | this.sidenav.fixedTopGap = 55; 17 | this.opened = false; 18 | } else { 19 | this.sidenav.fixedTopGap = 55; 20 | this.opened = true; 21 | } 22 | } 23 | 24 | @HostListener('window:resize', ['$event']) 25 | onResize(event) { 26 | if (event.target.innerWidth < 768) { 27 | this.sidenav.fixedTopGap = 55; 28 | this.opened = false; 29 | } else { 30 | this.sidenav.fixedTopGap = 55 31 | this.opened = true; 32 | } 33 | } 34 | 35 | isBiggerScreen() { 36 | const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 37 | if (width < 768) { 38 | return true; 39 | } else { 40 | return false; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | 3 | import { AppRoutingModule } from './app-routing.module'; 4 | 5 | import { AppComponent } from './app.component'; 6 | import { AddBookComponent } from './components/add-book/add-book.component'; 7 | import { EditBookComponent } from './components/edit-book/edit-book.component'; 8 | import { BookListComponent } from './components/book-list/book-list.component'; 9 | 10 | /* Angular material */ 11 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 12 | import { AngularMaterialModule } from './material.module'; 13 | import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 14 | 15 | /* Firebase */ 16 | import { AngularFireModule } from '@angular/fire'; 17 | import { AngularFireDatabaseModule } from '@angular/fire/database'; 18 | import { environment } from 'src/environments/environment'; 19 | 20 | /* Angular CRUD services */ 21 | import { BookService } from './shared/book.service'; 22 | 23 | /* Reactive form services in Angular 7 */ 24 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 25 | 26 | @NgModule({ 27 | declarations: [ 28 | AppComponent, 29 | AddBookComponent, 30 | EditBookComponent, 31 | BookListComponent 32 | ], 33 | imports: [ 34 | BrowserModule, 35 | AppRoutingModule, 36 | BrowserAnimationsModule, 37 | AngularMaterialModule, 38 | AngularFireModule.initializeApp(environment.firebaseConfig), 39 | AngularFireDatabaseModule, 40 | FormsModule, 41 | ReactiveFormsModule 42 | ], 43 | providers: [BookService], 44 | bootstrap: [AppComponent], 45 | schemas: [CUSTOM_ELEMENTS_SCHEMA] 46 | }) 47 | export class AppModule { } 48 | -------------------------------------------------------------------------------- /src/app/components/add-book/add-book.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/angular-material7-firebase-crud-app/4e84b0fcd9daaff9f940dfdcc70662164e0e7139/src/app/components/add-book/add-book.component.css -------------------------------------------------------------------------------- /src/app/components/add-book/add-book.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Add Book

4 | 5 |
6 | 7 | 8 |
9 |
10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | You must provide abook name 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | You must provide a 10 digit ISBN 27 | 28 | 29 | Only numbers are allowed 30 | 31 | 32 | Your ISBN must be 10 digit 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | You must provide an author name 41 | 42 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 51 | Publication date is required 52 | 53 | 54 |
55 |
56 | 57 | 58 | 59 |
60 | 61 | 62 | Binding type 63 | 64 | {{bindingType}} 65 | 66 | 67 | Binding type is required 68 | 69 | 70 | 71 | 72 |
73 | Available in stock: 74 | 75 | Yes 76 | No 77 | 78 |
79 | 80 | 81 | 82 | 83 | 85 | {{lang.name}} 86 | cancel 87 | 88 | 91 | 92 | 93 | info 94 | 95 | 96 |
97 |
98 | 99 | 100 | 101 |
102 |
103 | 104 | 105 |
106 |
107 |
108 |
109 |
110 | -------------------------------------------------------------------------------- /src/app/components/add-book/add-book.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AddBookComponent } from './add-book.component'; 4 | 5 | describe('AddBookComponent', () => { 6 | let component: AddBookComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ AddBookComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(AddBookComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/add-book/add-book.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ViewChild } from '@angular/core'; 2 | import { COMMA, ENTER } from '@angular/cdk/keycodes'; 3 | import { MatChipInputEvent } from '@angular/material'; 4 | import { BookService } from './../../shared/book.service'; 5 | import { FormGroup, FormBuilder, Validators } from "@angular/forms"; 6 | 7 | export interface Language { 8 | name: string; 9 | } 10 | 11 | @Component({ 12 | selector: 'app-add-book', 13 | templateUrl: './add-book.component.html', 14 | styleUrls: ['./add-book.component.css'] 15 | }) 16 | export class AddBookComponent implements OnInit { 17 | visible = true; 18 | selectable = true; 19 | removable = true; 20 | addOnBlur = true; 21 | languageArray: Language[] = []; 22 | @ViewChild('chipList') chipList; 23 | @ViewChild('resetBookForm') myNgForm; 24 | readonly separatorKeysCodes: number[] = [ENTER, COMMA]; 25 | selectedBindingType: string; 26 | bookForm: FormGroup; 27 | BindingType: any = ['Paperback', 'Case binding', 'Perfect binding', 'Saddle stitch binding', 'Spiral binding']; 28 | 29 | ngOnInit() { 30 | this.bookApi.GetBookList(); 31 | this.submitBookForm(); 32 | } 33 | 34 | constructor( 35 | public fb: FormBuilder, 36 | private bookApi: BookService 37 | ) { } 38 | 39 | /* Remove dynamic languages */ 40 | remove(language: Language): void { 41 | const index = this.languageArray.indexOf(language); 42 | if (index >= 0) { 43 | this.languageArray.splice(index, 1); 44 | } 45 | } 46 | 47 | /* Reactive book form */ 48 | submitBookForm() { 49 | this.bookForm = this.fb.group({ 50 | book_name: ['', [Validators.required]], 51 | isbn_10: ['', [Validators.required]], 52 | author_name: ['', [Validators.required]], 53 | publication_date: ['', [Validators.required]], 54 | binding_type: ['', [Validators.required]], 55 | in_stock: ['Yes'], 56 | languages: [this.languageArray] 57 | }) 58 | } 59 | 60 | /* Get errors */ 61 | public handleError = (controlName: string, errorName: string) => { 62 | return this.bookForm.controls[controlName].hasError(errorName); 63 | } 64 | 65 | /* Add dynamic languages */ 66 | add(event: MatChipInputEvent): void { 67 | const input = event.input; 68 | const value = event.value; 69 | // Add language 70 | if ((value || '').trim() && this.languageArray.length < 5) { 71 | this.languageArray.push({ name: value.trim() }) 72 | } 73 | // Reset the input value 74 | if (input) { 75 | input.value = ''; 76 | } 77 | } 78 | 79 | /* Date */ 80 | formatDate(e) { 81 | var convertDate = new Date(e.target.value).toISOString().substring(0, 10); 82 | this.bookForm.get('publication_date').setValue(convertDate, { 83 | onlyself: true 84 | }) 85 | } 86 | 87 | /* Reset form */ 88 | resetForm() { 89 | this.languageArray = []; 90 | this.bookForm.reset(); 91 | Object.keys(this.bookForm.controls).forEach(key => { 92 | this.bookForm.controls[key].setErrors(null) 93 | }); 94 | } 95 | 96 | /* Submit book */ 97 | submitBook() { 98 | if (this.bookForm.valid){ 99 | this.bookApi.AddBook(this.bookForm.value) 100 | this.resetForm(); 101 | } 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /src/app/components/book-list/book-list.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/angular-material7-firebase-crud-app/4e84b0fcd9daaff9f940dfdcc70662164e0e7139/src/app/components/book-list/book-list.component.css -------------------------------------------------------------------------------- /src/app/components/book-list/book-list.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Book List

4 | 5 |
6 | 7 | 8 |

There is no data added yet!

9 | 10 | 11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 49 | 50 |
Book ID {{element.$key}} Book Name {{element.book_name}} Author Name {{element.author_name}} Publication Date {{element.publication_date}} In Stock {{element.in_stock}} Action 42 | 44 | 45 |
51 | 52 | 53 |
54 |
-------------------------------------------------------------------------------- /src/app/components/book-list/book-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { BookListComponent } from './book-list.component'; 4 | 5 | describe('BookListComponent', () => { 6 | let component: BookListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ BookListComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(BookListComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/book-list/book-list.component.ts: -------------------------------------------------------------------------------- 1 | import { Book } from './../../shared/book'; 2 | import { Component, ViewChild } from '@angular/core'; 3 | import { MatPaginator, MatTableDataSource } from '@angular/material'; 4 | import { BookService } from './../../shared/book.service'; 5 | 6 | @Component({ 7 | selector: 'app-book-list', 8 | templateUrl: './book-list.component.html', 9 | styleUrls: ['./book-list.component.css'] 10 | }) 11 | 12 | export class BookListComponent { 13 | 14 | dataSource: MatTableDataSource; 15 | @ViewChild(MatPaginator) paginator: MatPaginator; 16 | BookData: any = []; 17 | displayedColumns: any[] = [ 18 | '$key', 19 | 'book_name', 20 | 'author_name', 21 | 'publication_date', 22 | 'in_stock', 23 | 'action' 24 | ]; 25 | 26 | constructor(private bookApi: BookService){ 27 | this.bookApi.GetBookList() 28 | .snapshotChanges().subscribe(books => { 29 | books.forEach(item => { 30 | let a = item.payload.toJSON(); 31 | a['$key'] = item.key; 32 | this.BookData.push(a as Book) 33 | }) 34 | /* Data table */ 35 | this.dataSource = new MatTableDataSource(this.BookData); 36 | /* Pagination */ 37 | setTimeout(() => { 38 | this.dataSource.paginator = this.paginator; 39 | }, 0); 40 | }) 41 | } 42 | 43 | /* Delete */ 44 | deleteBook(index: number, e){ 45 | if(window.confirm('Are you sure?')) { 46 | const data = this.dataSource.data; 47 | data.splice((this.paginator.pageIndex * this.paginator.pageSize) + index, 1); 48 | this.dataSource.data = data; 49 | this.bookApi.DeleteBook(e.$key) 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/app/components/edit-book/edit-book.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/angular-material7-firebase-crud-app/4e84b0fcd9daaff9f940dfdcc70662164e0e7139/src/app/components/edit-book/edit-book.component.css -------------------------------------------------------------------------------- /src/app/components/edit-book/edit-book.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Edit Book

4 | 5 |
6 | 7 | 8 |
9 |
10 | 11 |
12 | 13 | 14 | 15 | 16 | You must provide abook name 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | You must provide a 10 digit ISBN 26 | 27 | 28 | Only numbers are allowed 29 | 30 | 31 | Your ISBN must be 10 digit 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | You must provide an author name 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | Publication date is required 51 | 52 | 53 |
54 |
55 | 56 | 57 |
58 | 59 | 60 | Binding type 61 | 62 | {{bindingType}} 63 | 64 | 65 | Binding type is required 66 | 67 | 68 | 69 | 70 |
71 | Available in stock: 72 | 73 | Yes 74 | No 75 | 76 |
77 | 78 | 79 | 80 | 81 | 83 | {{lang.name}} 84 | cancel 85 | 86 | 89 | 90 | 91 | info 92 | 93 | 94 |
95 |
96 | 97 | 98 | 99 |
100 |
101 | 102 | 103 |
104 |
105 |
106 |
107 |
108 | -------------------------------------------------------------------------------- /src/app/components/edit-book/edit-book.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { EditBookComponent } from './edit-book.component'; 4 | 5 | describe('EditBookComponent', () => { 6 | let component: EditBookComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ EditBookComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(EditBookComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/edit-book/edit-book.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ViewChild } from '@angular/core'; 2 | import { ActivatedRoute, Router } from "@angular/router"; 3 | import { Location } from '@angular/common'; 4 | import { COMMA, ENTER } from '@angular/cdk/keycodes'; 5 | import { MatChipInputEvent } from '@angular/material'; 6 | import { BookService } from './../../shared/book.service'; 7 | import { FormGroup, FormBuilder, Validators } from "@angular/forms"; 8 | 9 | export interface Language { 10 | name: string; 11 | } 12 | 13 | @Component({ 14 | selector: 'app-edit-book', 15 | templateUrl: './edit-book.component.html', 16 | styleUrls: ['./edit-book.component.css'] 17 | }) 18 | 19 | export class EditBookComponent implements OnInit { 20 | visible = true; 21 | selectable = true; 22 | removable = true; 23 | addOnBlur = true; 24 | languageArray: Language[] = []; 25 | @ViewChild('chipList') chipList; 26 | readonly separatorKeysCodes: number[] = [ENTER, COMMA]; 27 | selectedBindingType: string; 28 | editBookForm: FormGroup; 29 | BindingType: any = ['Paperback', 'Case binding', 'Perfect binding', 'Saddle stitch binding', 'Spiral binding']; 30 | 31 | ngOnInit() { 32 | this.updateBookForm(); 33 | } 34 | 35 | constructor( 36 | public fb: FormBuilder, 37 | private location: Location, 38 | private bookApi: BookService, 39 | private actRoute: ActivatedRoute, 40 | private router: Router 41 | ) { 42 | var id = this.actRoute.snapshot.paramMap.get('id'); 43 | this.bookApi.GetBook(id).valueChanges().subscribe(data => { 44 | this.languageArray = data.languages; 45 | this.editBookForm.setValue(data); 46 | }) 47 | } 48 | 49 | /* Update form */ 50 | updateBookForm(){ 51 | this.editBookForm = this.fb.group({ 52 | book_name: ['', [Validators.required]], 53 | isbn_10: ['', [Validators.required]], 54 | author_name: ['', [Validators.required]], 55 | publication_date: ['', [Validators.required]], 56 | binding_type: ['', [Validators.required]], 57 | in_stock: ['Yes'], 58 | languages: [''] 59 | }) 60 | } 61 | 62 | /* Add language */ 63 | add(event: MatChipInputEvent): void { 64 | var input: any = event.input; 65 | var value: any = event.value; 66 | // Add language 67 | if ((value || '').trim() && this.languageArray.length < 5) { 68 | this.languageArray.push({name: value.trim()}); 69 | } 70 | // Reset the input value 71 | if (input) { 72 | input.value = ''; 73 | } 74 | } 75 | 76 | /* Remove language */ 77 | remove(language: any): void { 78 | const index = this.languageArray.indexOf(language); 79 | if (index >= 0) { 80 | this.languageArray.splice(index, 1); 81 | } 82 | } 83 | 84 | /* Get errors */ 85 | public handleError = (controlName: string, errorName: string) => { 86 | return this.editBookForm.controls[controlName].hasError(errorName); 87 | } 88 | 89 | /* Date */ 90 | formatDate(e) { 91 | var convertDate = new Date(e.target.value).toISOString().substring(0, 10); 92 | this.editBookForm.get('publication_date').setValue(convertDate, { 93 | onlyself: true 94 | }) 95 | } 96 | 97 | /* Go to previous page */ 98 | goBack(){ 99 | this.location.back(); 100 | } 101 | 102 | /* Submit book */ 103 | updateBook() { 104 | var id = this.actRoute.snapshot.paramMap.get('id'); 105 | if(window.confirm('Are you sure you wanna update?')){ 106 | this.bookApi.UpdateBook(id, this.editBookForm.value); 107 | this.router.navigate(['books-list']); 108 | } 109 | } 110 | 111 | } -------------------------------------------------------------------------------- /src/app/material.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | import { 5 | MatButtonModule, 6 | MatToolbarModule, 7 | MatIconModule, 8 | MatBadgeModule, 9 | MatSidenavModule, 10 | MatListModule, 11 | MatGridListModule, 12 | MatFormFieldModule, 13 | MatInputModule, 14 | MatSelectModule, 15 | MatRadioModule, 16 | MatDatepickerModule, 17 | MatNativeDateModule, 18 | MatChipsModule, 19 | MatTooltipModule, 20 | MatTableModule, 21 | MatPaginatorModule 22 | } from '@angular/material'; 23 | 24 | @NgModule({ 25 | imports: [ 26 | CommonModule, 27 | MatButtonModule, 28 | MatToolbarModule, 29 | MatIconModule, 30 | MatSidenavModule, 31 | MatBadgeModule, 32 | MatListModule, 33 | MatGridListModule, 34 | MatFormFieldModule, 35 | MatInputModule, 36 | MatSelectModule, 37 | MatRadioModule, 38 | MatDatepickerModule, 39 | MatNativeDateModule, 40 | MatChipsModule, 41 | MatTooltipModule, 42 | MatTableModule, 43 | MatPaginatorModule 44 | ], 45 | exports: [ 46 | MatButtonModule, 47 | MatToolbarModule, 48 | MatIconModule, 49 | MatSidenavModule, 50 | MatBadgeModule, 51 | MatListModule, 52 | MatGridListModule, 53 | MatInputModule, 54 | MatFormFieldModule, 55 | MatSelectModule, 56 | MatRadioModule, 57 | MatDatepickerModule, 58 | MatChipsModule, 59 | MatTooltipModule, 60 | MatTableModule, 61 | MatPaginatorModule 62 | ], 63 | providers: [ 64 | MatDatepickerModule, 65 | ] 66 | }) 67 | 68 | export class AngularMaterialModule { } -------------------------------------------------------------------------------- /src/app/shared/book.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Book } from './book'; 3 | import { AngularFireDatabase, AngularFireList, AngularFireObject } from '@angular/fire/database'; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | 9 | export class BookService { 10 | booksRef: AngularFireList; 11 | bookRef: AngularFireObject; 12 | 13 | constructor(private db: AngularFireDatabase) {} 14 | 15 | /* Create book */ 16 | AddBook(book: Book) { 17 | this.booksRef.push({ 18 | book_name: book.book_name, 19 | isbn_10: book.isbn_10, 20 | author_name: book.author_name, 21 | publication_date: book.publication_date, 22 | binding_type: book.binding_type, 23 | in_stock: book.in_stock, 24 | languages: book.languages 25 | }) 26 | .catch(error => { 27 | this.errorMgmt(error); 28 | }) 29 | } 30 | 31 | /* Get book */ 32 | GetBook(id: string) { 33 | this.bookRef = this.db.object('books-list/' + id); 34 | return this.bookRef; 35 | } 36 | 37 | /* Get book list */ 38 | GetBookList() { 39 | this.booksRef = this.db.list('books-list'); 40 | return this.booksRef; 41 | } 42 | 43 | /* Update book */ 44 | UpdateBook(id, book: Book) { 45 | this.bookRef.update({ 46 | book_name: book.book_name, 47 | isbn_10: book.isbn_10, 48 | author_name: book.author_name, 49 | publication_date: book.publication_date, 50 | binding_type: book.binding_type, 51 | in_stock: book.in_stock, 52 | languages: book.languages 53 | }) 54 | .catch(error => { 55 | this.errorMgmt(error); 56 | }) 57 | } 58 | 59 | /* Delete book */ 60 | DeleteBook(id: string) { 61 | this.bookRef = this.db.object('books-list/' + id); 62 | this.bookRef.remove() 63 | .catch(error => { 64 | this.errorMgmt(error); 65 | }) 66 | } 67 | 68 | // Error management 69 | private errorMgmt(error) { 70 | console.log(error) 71 | } 72 | } -------------------------------------------------------------------------------- /src/app/shared/book.ts: -------------------------------------------------------------------------------- 1 | export interface Book { 2 | $key: string; 3 | book_name: string; 4 | isbn_10: number; 5 | author_name: string 6 | publication_date: Date; 7 | binding_type: string; 8 | in_stock: string; 9 | languages: Array; 10 | } 11 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/angular-material7-firebase-crud-app/4e84b0fcd9daaff9f940dfdcc70662164e0e7139/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | firebaseConfig: { 4 | apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 5 | authDomain: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 6 | databaseURL: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 7 | projectId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 8 | storageBucket: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 9 | messagingSenderId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 10 | appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /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 | firebaseConfig: { 8 | apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 9 | authDomain: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 10 | databaseURL: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 11 | projectId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 12 | storageBucket: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 13 | messagingSenderId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 14 | appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 15 | } 16 | }; 17 | 18 | /* 19 | * For easier debugging in development mode, you can import the following file 20 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 21 | * 22 | * This import should be commented out in production mode because it will have a negative impact 23 | * on performance if an error is thrown. 24 | */ 25 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 26 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/angular-material7-firebase-crud-app/4e84b0fcd9daaff9f940dfdcc70662164e0e7139/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularMaterial7FirebaseCrudApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage/angular-material7-firebase-crud-app'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import 'hammerjs'; 2 | import { enableProdMode } from '@angular/core'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | import { AppModule } from './app/app.module'; 6 | import { environment } from './environments/environment'; 7 | 8 | if (environment.production) { 9 | enableProdMode(); 10 | } 11 | 12 | platformBrowserDynamic().bootstrapModule(AppModule) 13 | .catch(err => console.error(err)); 14 | -------------------------------------------------------------------------------- /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 | /** IE10 and 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.ts'; 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__BLACK_LISTED_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 | @import "~@angular/material/prebuilt-themes/indigo-pink.css"; 2 | 3 | html, 4 | body { 5 | height: 100%; 6 | } 7 | 8 | body { 9 | margin: 0; 10 | font-family: 'Roboto', sans-serif; 11 | } 12 | 13 | .header { 14 | justify-content: space-between; 15 | } 16 | 17 | .user-profile { 18 | margin-left: 15px; 19 | } 20 | 21 | .mat-sidenav-container { 22 | height: 100%; 23 | display: flex; 24 | flex: 1 1 auto; 25 | } 26 | 27 | .mat-nav-list .mat-list-item { 28 | font-size: 15px; 29 | } 30 | 31 | .nav-tool-items { 32 | display: inline-block; 33 | margin-right: 13px; 34 | } 35 | 36 | .user-profile { 37 | margin-left: 15px; 38 | cursor: pointer; 39 | } 40 | 41 | .hamburger { 42 | visibility: hidden !important; 43 | } 44 | 45 | .mat-sidenav, 46 | .mat-sidenav-content { 47 | padding: 15px; 48 | } 49 | 50 | .mat-list-item.active { 51 | background: rgba(0, 0, 0, .04); 52 | } 53 | 54 | .mat-sidenav-content { 55 | padding: 25px 40px 0; 56 | } 57 | 58 | .mat-sidenav { 59 | background-color: #F2F2F2; 60 | width: 250px; 61 | } 62 | 63 | .header { 64 | position: sticky; 65 | position: -webkit-sticky; 66 | top: 0; 67 | z-index: 1000; 68 | } 69 | 70 | mat-sidenav mat-icon { 71 | margin-right: 12px; 72 | } 73 | 74 | .hamburger { 75 | margin-top: 5px; 76 | cursor: pointer; 77 | } 78 | 79 | .mat-radio-button, 80 | .mat-radio-group { 81 | margin-right: 25px; 82 | } 83 | 84 | .controlers-wrapper>* { 85 | width: 100%; 86 | padding: 0; 87 | } 88 | 89 | .misc-bottom-padding { 90 | margin: 8px 0 10px; 91 | } 92 | 93 | .misc-bottom-padding mat-label { 94 | margin-right: 15px; 95 | } 96 | 97 | mat-radio-group mat-radio-button { 98 | margin-left: 5px; 99 | } 100 | 101 | .button-wrapper button { 102 | margin-right: 5px; 103 | } 104 | 105 | table.mat-table, 106 | table { 107 | width: 100%; 108 | } 109 | 110 | .inner-wrapper { 111 | padding: 15px 0 130px; 112 | width: 100%; 113 | } 114 | 115 | .inner-wrapper mat-card { 116 | display: inline-block; 117 | margin: 0 6% 0 0; 118 | vertical-align: top; 119 | width: 44%; 120 | } 121 | 122 | .full-wrapper { 123 | width: 100%; 124 | } 125 | 126 | .multiple-items { 127 | position: relative; 128 | } 129 | 130 | .multiple-items .tooltip-info { 131 | right: 0; 132 | top: 7px; 133 | cursor: pointer; 134 | color: #a1a7c7; 135 | position: absolute; 136 | font-size: 20px; 137 | } 138 | 139 | body .push-right { 140 | margin-right: 10px; 141 | } 142 | 143 | .no-data { 144 | text-align: center; 145 | padding-top: 30px; 146 | color: #6c75a9; 147 | } 148 | 149 | .button-wrapper { 150 | margin: 20px 0 0 0; 151 | } 152 | 153 | 154 | @media (max-width: 1024px) { 155 | 156 | .inner-wrapper mat-card { 157 | width: 100%; 158 | } 159 | 160 | .mat-sidenav-content { 161 | padding: 20px 20px 0; 162 | } 163 | 164 | .misc-bottom-padding mat-label { 165 | display: block; 166 | padding-bottom: 10px; 167 | } 168 | 169 | .mat-sidenav { 170 | width: 230px; 171 | } 172 | 173 | .mat-nav-list .mat-list-item { 174 | font-size: 14px; 175 | } 176 | } 177 | 178 | @media (max-width: 767px) { 179 | .nav-tool-items { 180 | margin-right: 0; 181 | } 182 | 183 | .hamburger { 184 | visibility: visible !important; 185 | } 186 | } 187 | html, body { height: 100%; } 188 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 189 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "array-type": false, 8 | "arrow-parens": false, 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "import-blacklist": [ 13 | true, 14 | "rxjs/Rx" 15 | ], 16 | "interface-name": false, 17 | "max-classes-per-file": false, 18 | "max-line-length": [ 19 | true, 20 | 140 21 | ], 22 | "member-access": false, 23 | "member-ordering": [ 24 | true, 25 | { 26 | "order": [ 27 | "static-field", 28 | "instance-field", 29 | "static-method", 30 | "instance-method" 31 | ] 32 | } 33 | ], 34 | "no-consecutive-blank-lines": false, 35 | "no-console": [ 36 | true, 37 | "debug", 38 | "info", 39 | "time", 40 | "timeEnd", 41 | "trace" 42 | ], 43 | "no-empty": false, 44 | "no-inferrable-types": [ 45 | true, 46 | "ignore-params" 47 | ], 48 | "no-non-null-assertion": true, 49 | "no-redundant-jsdoc": true, 50 | "no-switch-case-fall-through": true, 51 | "no-use-before-declare": true, 52 | "no-var-requires": false, 53 | "object-literal-key-quotes": [ 54 | true, 55 | "as-needed" 56 | ], 57 | "object-literal-sort-keys": false, 58 | "ordered-imports": false, 59 | "quotemark": [ 60 | true, 61 | "single" 62 | ], 63 | "trailing-comma": false, 64 | "no-output-on-prefix": true, 65 | "use-input-property-decorator": true, 66 | "use-output-property-decorator": true, 67 | "use-host-property-decorator": true, 68 | "no-input-rename": true, 69 | "no-output-rename": true, 70 | "use-life-cycle-interface": true, 71 | "use-pipe-transform-interface": true, 72 | "component-class-suffix": true, 73 | "directive-class-suffix": true 74 | } 75 | } 76 | --------------------------------------------------------------------------------