├── .angular-cli.json ├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── e2e ├── app.e2e-spec.ts ├── app.po.ts └── tsconfig.e2e.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── protractor.conf.js ├── src ├── app │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── dashboard │ │ ├── cards │ │ │ ├── abstract-dashboard-card.ts │ │ │ ├── dashboard-card.ts │ │ │ ├── dashboard-cards-spawner │ │ │ │ ├── dashboard-cards-spawner.component.html │ │ │ │ ├── dashboard-cards-spawner.component.scss │ │ │ │ ├── dashboard-cards-spawner.component.spec.ts │ │ │ │ └── dashboard-cards-spawner.component.ts │ │ │ └── dashboard-users │ │ │ │ ├── dashboard-users.component.html │ │ │ │ ├── dashboard-users.component.scss │ │ │ │ ├── dashboard-users.component.spec.ts │ │ │ │ └── dashboard-users.component.ts │ │ ├── dashboard.module.ts │ │ ├── dashboard │ │ │ ├── dashboard.component.html │ │ │ ├── dashboard.component.scss │ │ │ ├── dashboard.component.spec.ts │ │ │ └── dashboard.component.ts │ │ ├── routing │ │ │ └── dashboard-routing.module.ts │ │ └── services │ │ │ └── dashboard-cards │ │ │ ├── dashboard-cards.service.spec.ts │ │ │ └── dashboard-cards.service.ts │ ├── home │ │ ├── home.component.html │ │ ├── home.component.scss │ │ ├── home.component.spec.ts │ │ └── home.component.ts │ ├── navbar │ │ ├── navbar.component.html │ │ ├── navbar.component.scss │ │ ├── navbar.component.spec.ts │ │ └── navbar.component.ts │ └── routing │ │ └── routing.module.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── typings.d.ts ├── tsconfig.json └── tslint.json /.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "angular-dashboard" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": [ 11 | "assets", 12 | "favicon.ico" 13 | ], 14 | "index": "index.html", 15 | "main": "main.ts", 16 | "polyfills": "polyfills.ts", 17 | "test": "test.ts", 18 | "tsconfig": "tsconfig.app.json", 19 | "testTsconfig": "tsconfig.spec.json", 20 | "prefix": "app", 21 | "styles": [ 22 | "styles.scss" 23 | ], 24 | "scripts": [], 25 | "environmentSource": "environments/environment.ts", 26 | "environments": { 27 | "dev": "environments/environment.ts", 28 | "prod": "environments/environment.prod.ts" 29 | } 30 | } 31 | ], 32 | "e2e": { 33 | "protractor": { 34 | "config": "./protractor.conf.js" 35 | } 36 | }, 37 | "lint": [ 38 | { 39 | "project": "src/tsconfig.app.json", 40 | "exclude": "**/node_modules/**" 41 | }, 42 | { 43 | "project": "src/tsconfig.spec.json", 44 | "exclude": "**/node_modules/**" 45 | }, 46 | { 47 | "project": "e2e/tsconfig.e2e.json", 48 | "exclude": "**/node_modules/**" 49 | } 50 | ], 51 | "test": { 52 | "karma": { 53 | "config": "./karma.conf.js" 54 | } 55 | }, 56 | "defaults": { 57 | "styleExt": "scss", 58 | "component": {} 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | # System Files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular Dashboard 2 | 3 | ## Tutorial Link 4 | To view the tutorial visit [Creating a Responsive Dashboard in Angular 5 From Scratch](https://medium.com/@nima_ap/creating-a-responsive-dashboard-in-angular-5-from-scratch-147f6a493d9e) 5 | 6 | ## Demo Route 7 | `http://localhost:4200/#/dashboard` 8 | 9 | ## Development server 10 | 11 | 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. 12 | 13 | ## Code scaffolding 14 | 15 | 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`. 16 | 17 | ## Build 18 | 19 | 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. 20 | 21 | ## Running unit tests 22 | 23 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 24 | 25 | ## Running end-to-end tests 26 | 27 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 28 | 29 | ## Further help 30 | 31 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 32 | -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('angular-dashboard App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "jasminewd2", 11 | "node" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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/cli'], 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/cli/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | reports: [ 'html', 'lcovonly' ], 20 | fixWebpackSourcePaths: true 21 | }, 22 | angularCli: { 23 | environment: 'dev' 24 | }, 25 | reporters: ['progress', 'kjhtml'], 26 | port: 9876, 27 | colors: true, 28 | logLevel: config.LOG_INFO, 29 | autoWatch: true, 30 | browsers: ['Chrome'], 31 | singleRun: false 32 | }); 33 | }; 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-dashboard", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "repository": "https://github.com/nima200/angular-dashboard.git", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "ng serve", 9 | "build": "ng build --prod", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/animations": "^5.1.2", 17 | "@angular/cdk": "^5.0.2", 18 | "@angular/common": "^5.0.0", 19 | "@angular/compiler": "^5.0.0", 20 | "@angular/core": "^5.0.0", 21 | "@angular/flex-layout": "^2.0.0-beta.12", 22 | "@angular/forms": "^5.0.0", 23 | "@angular/http": "^5.0.0", 24 | "@angular/material": "^5.0.2", 25 | "@angular/platform-browser": "^5.0.0", 26 | "@angular/platform-browser-dynamic": "^5.0.0", 27 | "@angular/router": "^5.0.0", 28 | "core-js": "^2.4.1", 29 | "rxjs": "^5.5.2", 30 | "zone.js": "^0.8.14" 31 | }, 32 | "devDependencies": { 33 | "@angular/cli": "~6.2.4", 34 | "@angular/compiler-cli": "^5.0.0", 35 | "@angular/language-service": "^5.0.0", 36 | "@types/jasmine": "~2.5.53", 37 | "@types/jasminewd2": "~2.0.2", 38 | "@types/node": "~6.0.60", 39 | "codelyzer": "^4.0.1", 40 | "jasmine-core": "~2.6.2", 41 | "jasmine-spec-reporter": "~4.1.0", 42 | "karma": "~1.7.0", 43 | "karma-chrome-launcher": "~2.1.1", 44 | "karma-cli": "~1.0.1", 45 | "karma-coverage-istanbul-reporter": "^1.2.1", 46 | "karma-jasmine": "~1.1.0", 47 | "karma-jasmine-html-reporter": "^0.2.2", 48 | "protractor": "~5.1.2", 49 | "ts-node": "~3.2.0", 50 | "tslint": "~5.7.0", 51 | "typescript": "~2.4.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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 | './e2e/**/*.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: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nima200/angular-dashboard/225605af357a3254b69351c41beee2d9f2332395/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'app'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('app'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /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.scss'] 7 | }) 8 | export class AppComponent { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import {BrowserModule} from '@angular/platform-browser'; 2 | import {NgModule} from '@angular/core'; 3 | 4 | 5 | import {AppComponent} from './app.component'; 6 | import {NavbarComponent} from './navbar/navbar.component'; 7 | import {RoutingModule} from './routing/routing.module'; 8 | import {MatToolbarModule} from '@angular/material'; 9 | import {HomeComponent} from './home/home.component'; 10 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; 11 | 12 | 13 | @NgModule({ 14 | declarations: [ 15 | AppComponent, 16 | NavbarComponent, 17 | HomeComponent 18 | ], 19 | imports: [ 20 | /* Angular Material Modules */ 21 | BrowserModule, 22 | BrowserAnimationsModule, 23 | MatToolbarModule, 24 | RoutingModule, 25 | ], 26 | providers: [], 27 | bootstrap: [AppComponent] 28 | }) 29 | export class AppModule { } 30 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/abstract-dashboard-card.ts: -------------------------------------------------------------------------------- 1 | export abstract class AbstractDashboardCard { 2 | constructor(private _name: string, 3 | private _routerLink: string, 4 | private _iconClass: string, 5 | private _col: string, 6 | private _row: string, 7 | private _color: string) { 8 | } 9 | 10 | get name(): string { 11 | return this._name; 12 | } 13 | 14 | get routerLink(): string { 15 | return this._routerLink; 16 | } 17 | 18 | get iconClass(): string { 19 | return this._iconClass; 20 | } 21 | 22 | get col(): string { 23 | return this._col; 24 | } 25 | 26 | get row(): string { 27 | return this._row; 28 | } 29 | 30 | get color(): string { 31 | return this._color; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-card.ts: -------------------------------------------------------------------------------- 1 | import {InjectionToken} from '@angular/core'; 2 | import {Observable} from 'rxjs/Observable'; 3 | 4 | export class DashboardCard { 5 | static metadata: any = { 6 | NAME: new InjectionToken('name'), 7 | ROUTERLINK: new InjectionToken('routerLink'), 8 | ICONCLASS: new InjectionToken('iconClass'), 9 | COLS: new InjectionToken>('cols'), 10 | ROWS: new InjectionToken>('rows'), 11 | COLOR: new InjectionToken('color') 12 | }; 13 | 14 | constructor(private _input: { 15 | name: { 16 | key: InjectionToken, 17 | value: string 18 | }, 19 | routerLink: { 20 | key: InjectionToken, 21 | value: string 22 | }, 23 | iconClass: { 24 | key: InjectionToken, 25 | value: string 26 | }, 27 | cols: { 28 | key: InjectionToken>, 29 | value: Observable 30 | }, 31 | rows: { 32 | key: InjectionToken>, 33 | value: Observable 34 | }, 35 | color: { 36 | key: InjectionToken, 37 | value: string 38 | } 39 | }, private _component: any) { 40 | } 41 | 42 | get input(): { 43 | name: { 44 | key: InjectionToken; 45 | value: string 46 | }; 47 | routerLink: { 48 | key: InjectionToken; 49 | value: string 50 | }; 51 | iconClass: { 52 | key: InjectionToken; 53 | value: string 54 | }; 55 | cols: { 56 | key: InjectionToken>; 57 | value: Observable 58 | }; 59 | rows: { 60 | key: InjectionToken>; 61 | value: Observable 62 | }; 63 | color: { 64 | key: InjectionToken; 65 | value: string 66 | } 67 | } { 68 | return this._input; 69 | } 70 | 71 | get component(): any { 72 | return this._component; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-cards-spawner/dashboard-cards-spawner.component.html: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-cards-spawner/dashboard-cards-spawner.component.scss: -------------------------------------------------------------------------------- 1 | :host { 2 | height: 100%; 3 | width: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-cards-spawner/dashboard-cards-spawner.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {DashboardCardsSpawnerComponent} from './dashboard-cards-spawner.component'; 4 | 5 | describe('DashboardCardsSpawnerComponent', () => { 6 | let component: DashboardCardsSpawnerComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [DashboardCardsSpawnerComponent] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DashboardCardsSpawnerComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-cards-spawner/dashboard-cards-spawner.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, ComponentFactoryResolver, Injector, Input, OnInit, ViewChild, ViewContainerRef} from '@angular/core'; 2 | import {DashboardCard} from '../dashboard-card'; 3 | 4 | @Component({ 5 | selector: 'app-dashboard-cards-spawner', 6 | templateUrl: './dashboard-cards-spawner.component.html', 7 | styleUrls: ['./dashboard-cards-spawner.component.scss'] 8 | }) 9 | export class DashboardCardsSpawnerComponent implements OnInit { 10 | @ViewChild('spawn', {read: ViewContainerRef}) container; 11 | 12 | constructor(private resolver: ComponentFactoryResolver) { 13 | } 14 | 15 | @Input() set card(data: DashboardCard) { 16 | if (!data) { 17 | return; 18 | } 19 | const inputProviders = Object.keys(data.input).map((inputName) => { 20 | return {provide: data.input[inputName].key, useValue: data.input[inputName].value, deps: []}; 21 | }); 22 | const injector = Injector.create(inputProviders, this.container.parentInjector); 23 | const factory = this.resolver.resolveComponentFactory(data.component); 24 | const component = factory.create(injector); 25 | this.container.insert(component.hostView); 26 | } 27 | 28 | ngOnInit() { 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-users/dashboard-users.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{name}} 4 | 5 | 6 |

content

7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-users/dashboard-users.component.scss: -------------------------------------------------------------------------------- 1 | :host { 2 | height: 100%; 3 | width: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-users/dashboard-users.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {DashboardUsersComponent} from './dashboard-users.component'; 4 | 5 | describe('DashboardUsersComponent', () => { 6 | let component: DashboardUsersComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [DashboardUsersComponent] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DashboardUsersComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/dashboard/cards/dashboard-users/dashboard-users.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, Injector, OnInit} from '@angular/core'; 2 | import {DashboardCard} from '../dashboard-card'; 3 | import {AbstractDashboardCard} from '../abstract-dashboard-card'; 4 | 5 | @Component({ 6 | selector: 'app-dashboard-users', 7 | templateUrl: './dashboard-users.component.html', 8 | styleUrls: ['./dashboard-users.component.scss'] 9 | }) 10 | export class DashboardUsersComponent extends AbstractDashboardCard implements OnInit { 11 | 12 | constructor(private injector: Injector) { 13 | super(injector.get(DashboardCard.metadata.NAME), 14 | injector.get(DashboardCard.metadata.ROUTERLINK), 15 | injector.get(DashboardCard.metadata.ICONCLASS), 16 | injector.get(DashboardCard.metadata.COLS), 17 | injector.get(DashboardCard.metadata.ROWS), 18 | injector.get(DashboardCard.metadata.COLOR)); 19 | } 20 | 21 | ngOnInit() { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.module.ts: -------------------------------------------------------------------------------- 1 | import {NgModule} from '@angular/core'; 2 | import {CommonModule} from '@angular/common'; 3 | import {DashboardComponent} from './dashboard/dashboard.component'; 4 | import {DashboardRoutingModule} from './routing/dashboard-routing.module'; 5 | import {DashboardCardsService} from './services/dashboard-cards/dashboard-cards.service'; 6 | import {DashboardUsersComponent} from './cards/dashboard-users/dashboard-users.component'; 7 | import {DashboardCardsSpawnerComponent} from './cards/dashboard-cards-spawner/dashboard-cards-spawner.component'; 8 | import { 9 | MatButtonModule, MatCardModule, MatGridListModule, MatIconModule, MatListModule, MatSidenavModule, 10 | MatTooltipModule 11 | } from '@angular/material'; 12 | import {FlexLayoutModule} from '@angular/flex-layout'; 13 | 14 | @NgModule({ 15 | imports: [ 16 | CommonModule, 17 | MatGridListModule, 18 | MatButtonModule, 19 | MatCardModule, 20 | MatListModule, 21 | MatIconModule, 22 | MatTooltipModule, 23 | MatSidenavModule, 24 | FlexLayoutModule, 25 | DashboardRoutingModule 26 | ], 27 | declarations: [DashboardComponent, DashboardUsersComponent, DashboardCardsSpawnerComponent], 28 | providers: [DashboardCardsService] 29 | }) 30 | export class DashboardModule { 31 | } 32 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard/dashboard.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nima200/angular-dashboard/225605af357a3254b69351c41beee2d9f2332395/src/app/dashboard/dashboard/dashboard.component.scss -------------------------------------------------------------------------------- /src/app/dashboard/dashboard/dashboard.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {DashboardComponent} from './dashboard.component'; 4 | 5 | describe('DashboardfComponent', () => { 6 | let component: DashboardComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [DashboardComponent] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DashboardComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from '@angular/core'; 2 | import {DashboardCard} from '../cards/dashboard-card'; 3 | import {Observable} from 'rxjs/Observable'; 4 | import {DashboardCardsService} from '../services/dashboard-cards/dashboard-cards.service'; 5 | import {ObservableMedia} from '@angular/flex-layout'; 6 | import 'rxjs/add/operator/map'; 7 | import 'rxjs/add/operator/startWith'; 8 | import {DashboardUsersComponent} from '../cards/dashboard-users/dashboard-users.component'; 9 | 10 | @Component({ 11 | selector: 'app-dashboard', 12 | templateUrl: './dashboard.component.html', 13 | styleUrls: ['./dashboard.component.scss'], 14 | entryComponents: [DashboardUsersComponent] 15 | }) 16 | export class DashboardComponent implements OnInit { 17 | 18 | cards: DashboardCard[] = []; 19 | cols: Observable; 20 | cols_big: Observable; 21 | cols_sml: Observable; 22 | 23 | constructor(private cardsService: DashboardCardsService, 24 | private observableMedia: ObservableMedia) { 25 | this.cardsService.cards.subscribe(cards => { 26 | this.cards = cards; 27 | }); 28 | } 29 | 30 | ngOnInit() { 31 | /* Grid column map */ 32 | const cols_map = new Map([ 33 | ['xs', 1], 34 | ['sm', 4], 35 | ['md', 8], 36 | ['lg', 10], 37 | ['xl', 18] 38 | ]); 39 | /* Big card column span map */ 40 | const cols_map_big = new Map([ 41 | ['xs', 1], 42 | ['sm', 4], 43 | ['md', 4], 44 | ['lg', 4], 45 | ['xl', 4] 46 | ]); 47 | /* Small card column span map */ 48 | const cols_map_sml = new Map([ 49 | ['xs', 1], 50 | ['sm', 2], 51 | ['md', 2], 52 | ['lg', 2], 53 | ['xl', 2] 54 | ]); 55 | let start_cols: number; 56 | let start_cols_big: number; 57 | let start_cols_sml: number; 58 | cols_map.forEach((cols, mqAlias) => { 59 | if (this.observableMedia.isActive(mqAlias)) { 60 | start_cols = cols; 61 | } 62 | }); 63 | cols_map_big.forEach((cols_big, mqAlias) => { 64 | if (this.observableMedia.isActive(mqAlias)) { 65 | start_cols_big = cols_big; 66 | } 67 | }); 68 | cols_map_sml.forEach((cols_sml, mqAliast) => { 69 | if (this.observableMedia.isActive(mqAliast)) { 70 | start_cols_sml = cols_sml; 71 | } 72 | }); 73 | this.cols = this.observableMedia.asObservable() 74 | .map(change => { 75 | return cols_map.get(change.mqAlias); 76 | }).startWith(start_cols); 77 | this.cols_big = this.observableMedia.asObservable() 78 | .map(change => { 79 | return cols_map_big.get(change.mqAlias); 80 | }).startWith(start_cols_big); 81 | this.cols_sml = this.observableMedia.asObservable() 82 | .map(change => { 83 | return cols_map_sml.get(change.mqAlias); 84 | }).startWith(start_cols_sml); 85 | this.createCards(); 86 | } 87 | 88 | createCards(): void { 89 | this.cardsService.addCard( 90 | new DashboardCard( 91 | { 92 | name: { 93 | key: DashboardCard.metadata.NAME, 94 | value: 'users' 95 | }, 96 | routerLink: { 97 | key: DashboardCard.metadata.ROUTERLINK, 98 | value: '/dashboard/users' 99 | }, 100 | iconClass: { 101 | key: DashboardCard.metadata.ICONCLASS, 102 | value: 'fa-users' 103 | }, 104 | cols: { 105 | key: DashboardCard.metadata.COLS, 106 | value: this.cols_big 107 | }, 108 | rows: { 109 | key: DashboardCard.metadata.ROWS, 110 | value: this.cols_big 111 | }, 112 | color: { 113 | key: DashboardCard.metadata.COLOR, 114 | value: 'blue' 115 | } 116 | }, DashboardUsersComponent /* Reference to the component we'd like to spawn */ 117 | ) 118 | ); 119 | this.cardsService.addCard( 120 | new DashboardCard( 121 | { 122 | name: { 123 | key: DashboardCard.metadata.NAME, 124 | value: 'users' 125 | }, 126 | routerLink: { 127 | key: DashboardCard.metadata.ROUTERLINK, 128 | value: '/dashboard/users' 129 | }, 130 | iconClass: { 131 | key: DashboardCard.metadata.ICONCLASS, 132 | value: 'fa-users' 133 | }, 134 | cols: { 135 | key: DashboardCard.metadata.COLS, 136 | value: this.cols_big 137 | }, 138 | rows: { 139 | key: DashboardCard.metadata.ROWS, 140 | value: this.cols_sml 141 | }, 142 | color: { 143 | key: DashboardCard.metadata.COLOR, 144 | value: 'blue' 145 | } 146 | }, DashboardUsersComponent 147 | ) 148 | ); 149 | this.cardsService.addCard( 150 | new DashboardCard( 151 | { 152 | name: { 153 | key: DashboardCard.metadata.NAME, 154 | value: 'users' 155 | }, 156 | routerLink: { 157 | key: DashboardCard.metadata.ROUTERLINK, 158 | value: '/dashboard/users' 159 | }, 160 | iconClass: { 161 | key: DashboardCard.metadata.ICONCLASS, 162 | value: 'fa-users' 163 | }, 164 | cols: { 165 | key: DashboardCard.metadata.COLS, 166 | value: this.cols_sml 167 | }, 168 | rows: { 169 | key: DashboardCard.metadata.ROWS, 170 | value: this.cols_sml 171 | }, 172 | color: { 173 | key: DashboardCard.metadata.COLOR, 174 | value: 'blue' 175 | } 176 | }, DashboardUsersComponent 177 | ) 178 | ); 179 | this.cardsService.addCard( 180 | new DashboardCard( 181 | { 182 | name: { 183 | key: DashboardCard.metadata.NAME, 184 | value: 'users' 185 | }, 186 | routerLink: { 187 | key: DashboardCard.metadata.ROUTERLINK, 188 | value: '/dashboard/users' 189 | }, 190 | iconClass: { 191 | key: DashboardCard.metadata.ICONCLASS, 192 | value: 'fa-users' 193 | }, 194 | cols: { 195 | key: DashboardCard.metadata.COLS, 196 | value: this.cols_sml 197 | }, 198 | rows: { 199 | key: DashboardCard.metadata.ROWS, 200 | value: this.cols_sml 201 | }, 202 | color: { 203 | key: DashboardCard.metadata.COLOR, 204 | value: 'blue' 205 | } 206 | }, DashboardUsersComponent 207 | ) 208 | ); 209 | this.cardsService.addCard( 210 | new DashboardCard( 211 | { 212 | name: { 213 | key: DashboardCard.metadata.NAME, 214 | value: 'users' 215 | }, 216 | routerLink: { 217 | key: DashboardCard.metadata.ROUTERLINK, 218 | value: '/dashboard/users' 219 | }, 220 | iconClass: { 221 | key: DashboardCard.metadata.ICONCLASS, 222 | value: 'fa-users' 223 | }, 224 | cols: { 225 | key: DashboardCard.metadata.COLS, 226 | value: this.cols_big 227 | }, 228 | rows: { 229 | key: DashboardCard.metadata.ROWS, 230 | value: this.cols_sml 231 | }, 232 | color: { 233 | key: DashboardCard.metadata.COLOR, 234 | value: 'blue' 235 | } 236 | }, DashboardUsersComponent 237 | ) 238 | ); 239 | this.cardsService.addCard( 240 | new DashboardCard( 241 | { 242 | name: { 243 | key: DashboardCard.metadata.NAME, 244 | value: 'users' 245 | }, 246 | routerLink: { 247 | key: DashboardCard.metadata.ROUTERLINK, 248 | value: '/dashboard/users' 249 | }, 250 | iconClass: { 251 | key: DashboardCard.metadata.ICONCLASS, 252 | value: 'fa-users' 253 | }, 254 | cols: { 255 | key: DashboardCard.metadata.COLS, 256 | value: this.cols_big 257 | }, 258 | rows: { 259 | key: DashboardCard.metadata.ROWS, 260 | value: this.cols_sml 261 | }, 262 | color: { 263 | key: DashboardCard.metadata.COLOR, 264 | value: 'blue' 265 | } 266 | }, DashboardUsersComponent 267 | ) 268 | ); 269 | this.cardsService.addCard( 270 | new DashboardCard( 271 | { 272 | name: { 273 | key: DashboardCard.metadata.NAME, 274 | value: 'users' 275 | }, 276 | routerLink: { 277 | key: DashboardCard.metadata.ROUTERLINK, 278 | value: '/dashboard/users' 279 | }, 280 | iconClass: { 281 | key: DashboardCard.metadata.ICONCLASS, 282 | value: 'fa-users' 283 | }, 284 | cols: { 285 | key: DashboardCard.metadata.COLS, 286 | value: this.cols_big 287 | }, 288 | rows: { 289 | key: DashboardCard.metadata.ROWS, 290 | value: this.cols_sml 291 | }, 292 | color: { 293 | key: DashboardCard.metadata.COLOR, 294 | value: 'blue' 295 | } 296 | }, DashboardUsersComponent 297 | ) 298 | ); 299 | this.cardsService.addCard( 300 | new DashboardCard( 301 | { 302 | name: { 303 | key: DashboardCard.metadata.NAME, 304 | value: 'users' 305 | }, 306 | routerLink: { 307 | key: DashboardCard.metadata.ROUTERLINK, 308 | value: '/dashboard/users' 309 | }, 310 | iconClass: { 311 | key: DashboardCard.metadata.ICONCLASS, 312 | value: 'fa-users' 313 | }, 314 | cols: { 315 | key: DashboardCard.metadata.COLS, 316 | value: this.cols_sml 317 | }, 318 | rows: { 319 | key: DashboardCard.metadata.ROWS, 320 | value: this.cols_sml 321 | }, 322 | color: { 323 | key: DashboardCard.metadata.COLOR, 324 | value: 'blue' 325 | } 326 | }, DashboardUsersComponent 327 | ) 328 | ); 329 | this.cardsService.addCard( 330 | new DashboardCard( 331 | { 332 | name: { 333 | key: DashboardCard.metadata.NAME, 334 | value: 'users' 335 | }, 336 | routerLink: { 337 | key: DashboardCard.metadata.ROUTERLINK, 338 | value: '/dashboard/users' 339 | }, 340 | iconClass: { 341 | key: DashboardCard.metadata.ICONCLASS, 342 | value: 'fa-users' 343 | }, 344 | cols: { 345 | key: DashboardCard.metadata.COLS, 346 | value: this.cols_sml 347 | }, 348 | rows: { 349 | key: DashboardCard.metadata.ROWS, 350 | value: this.cols_sml 351 | }, 352 | color: { 353 | key: DashboardCard.metadata.COLOR, 354 | value: 'blue' 355 | } 356 | }, DashboardUsersComponent 357 | ) 358 | ); 359 | this.cardsService.addCard( 360 | new DashboardCard( 361 | { 362 | name: { 363 | key: DashboardCard.metadata.NAME, 364 | value: 'users' 365 | }, 366 | routerLink: { 367 | key: DashboardCard.metadata.ROUTERLINK, 368 | value: '/dashboard/users' 369 | }, 370 | iconClass: { 371 | key: DashboardCard.metadata.ICONCLASS, 372 | value: 'fa-users' 373 | }, 374 | cols: { 375 | key: DashboardCard.metadata.COLS, 376 | value: this.cols_sml 377 | }, 378 | rows: { 379 | key: DashboardCard.metadata.ROWS, 380 | value: this.cols_sml 381 | }, 382 | color: { 383 | key: DashboardCard.metadata.COLOR, 384 | value: 'blue' 385 | } 386 | }, DashboardUsersComponent 387 | ) 388 | ); 389 | this.cardsService.addCard( 390 | new DashboardCard( 391 | { 392 | name: { 393 | key: DashboardCard.metadata.NAME, 394 | value: 'users' 395 | }, 396 | routerLink: { 397 | key: DashboardCard.metadata.ROUTERLINK, 398 | value: '/dashboard/users' 399 | }, 400 | iconClass: { 401 | key: DashboardCard.metadata.ICONCLASS, 402 | value: 'fa-users' 403 | }, 404 | cols: { 405 | key: DashboardCard.metadata.COLS, 406 | value: this.cols_sml 407 | }, 408 | rows: { 409 | key: DashboardCard.metadata.ROWS, 410 | value: this.cols_sml 411 | }, 412 | color: { 413 | key: DashboardCard.metadata.COLOR, 414 | value: 'blue' 415 | } 416 | }, DashboardUsersComponent 417 | ) 418 | ); 419 | this.cardsService.addCard( 420 | new DashboardCard( 421 | { 422 | name: { 423 | key: DashboardCard.metadata.NAME, 424 | value: 'users' 425 | }, 426 | routerLink: { 427 | key: DashboardCard.metadata.ROUTERLINK, 428 | value: '/dashboard/users' 429 | }, 430 | iconClass: { 431 | key: DashboardCard.metadata.ICONCLASS, 432 | value: 'fa-users' 433 | }, 434 | cols: { 435 | key: DashboardCard.metadata.COLS, 436 | value: this.cols_sml 437 | }, 438 | rows: { 439 | key: DashboardCard.metadata.ROWS, 440 | value: this.cols_sml 441 | }, 442 | color: { 443 | key: DashboardCard.metadata.COLOR, 444 | value: 'blue' 445 | } 446 | }, DashboardUsersComponent 447 | ) 448 | ); 449 | this.cardsService.addCard( 450 | new DashboardCard( 451 | { 452 | name: { 453 | key: DashboardCard.metadata.NAME, 454 | value: 'users' 455 | }, 456 | routerLink: { 457 | key: DashboardCard.metadata.ROUTERLINK, 458 | value: '/dashboard/users' 459 | }, 460 | iconClass: { 461 | key: DashboardCard.metadata.ICONCLASS, 462 | value: 'fa-users' 463 | }, 464 | cols: { 465 | key: DashboardCard.metadata.COLS, 466 | value: this.cols_sml 467 | }, 468 | rows: { 469 | key: DashboardCard.metadata.ROWS, 470 | value: this.cols_sml 471 | }, 472 | color: { 473 | key: DashboardCard.metadata.COLOR, 474 | value: 'blue' 475 | } 476 | }, DashboardUsersComponent 477 | ) 478 | ); 479 | } 480 | 481 | } 482 | -------------------------------------------------------------------------------- /src/app/dashboard/routing/dashboard-routing.module.ts: -------------------------------------------------------------------------------- 1 | import {NgModule} from '@angular/core'; 2 | import {RouterModule, Routes} from '@angular/router'; 3 | import {DashboardComponent} from '../dashboard/dashboard.component'; 4 | 5 | const routes: Routes = [ 6 | { 7 | path: '', 8 | component: DashboardComponent 9 | }, 10 | { 11 | path: '**', 12 | redirectTo: '' 13 | } 14 | ]; 15 | 16 | @NgModule({ 17 | imports: [ 18 | RouterModule.forChild(routes) 19 | ], 20 | declarations: [], 21 | exports: [RouterModule] 22 | }) 23 | export class DashboardRoutingModule { 24 | } 25 | -------------------------------------------------------------------------------- /src/app/dashboard/services/dashboard-cards/dashboard-cards.service.spec.ts: -------------------------------------------------------------------------------- 1 | import {inject, TestBed} from '@angular/core/testing'; 2 | 3 | import {DashboardCardsService} from './dashboard-cards.service'; 4 | 5 | describe('DashboardCardsService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [DashboardCardsService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([DashboardCardsService], (service: DashboardCardsService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /src/app/dashboard/services/dashboard-cards/dashboard-cards.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {BehaviorSubject} from 'rxjs/BehaviorSubject'; 3 | import {DashboardCard} from '../../cards/dashboard-card'; 4 | 5 | @Injectable() 6 | export class DashboardCardsService { 7 | 8 | constructor() { 9 | } 10 | 11 | private _cards: BehaviorSubject = new BehaviorSubject([]); 12 | 13 | addCard(card: DashboardCard): void { 14 | this._cards.next(this._cards.getValue().concat(card)); 15 | } 16 | 17 | get cards(): BehaviorSubject { 18 | return this._cards; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/app/home/home.component.html: -------------------------------------------------------------------------------- 1 |

Navigate to /dashboard for demo!

2 | -------------------------------------------------------------------------------- /src/app/home/home.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nima200/angular-dashboard/225605af357a3254b69351c41beee2d9f2332395/src/app/home/home.component.scss -------------------------------------------------------------------------------- /src/app/home/home.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, 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 | 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/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.scss'] 7 | }) 8 | export class HomeComponent implements OnInit { 9 | 10 | constructor() { 11 | } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Angular Dashboard

3 |
4 | -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nima200/angular-dashboard/225605af357a3254b69351c41beee2d9f2332395/src/app/navbar/navbar.component.scss -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {NavbarComponent} from './navbar.component'; 4 | 5 | describe('NavbarComponent', () => { 6 | let component: NavbarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | 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/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-navbar', 5 | templateUrl: './navbar.component.html', 6 | styleUrls: ['./navbar.component.scss'] 7 | }) 8 | export class NavbarComponent implements OnInit { 9 | 10 | constructor() { 11 | } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/routing/routing.module.ts: -------------------------------------------------------------------------------- 1 | import {NgModule} from '@angular/core'; 2 | import {RouterModule, Routes} from '@angular/router'; 3 | import {HomeComponent} from '../home/home.component'; 4 | 5 | const routes: Routes = [ 6 | { 7 | path: '', 8 | pathMatch: 'full', 9 | redirectTo: 'home' 10 | }, 11 | { 12 | path: 'home', 13 | component: HomeComponent 14 | }, 15 | { 16 | path: 'dashboard', 17 | loadChildren: 'app/dashboard/dashboard.module#DashboardModule' 18 | }, 19 | { 20 | path: '**', 21 | redirectTo: 'home' 22 | } 23 | ]; 24 | 25 | @NgModule({ 26 | imports: [ 27 | RouterModule.forRoot(routes, {useHash: true}) 28 | ], 29 | declarations: [], 30 | exports: [RouterModule] 31 | }) 32 | export class RoutingModule { 33 | } 34 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nima200/angular-dashboard/225605af357a3254b69351c41beee2d9f2332395/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nima200/angular-dashboard/225605af357a3254b69351c41beee2d9f2332395/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularDashboard 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Required to support Web Animations `@angular/platform-browser/animations`. 51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 52 | **/ 53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 54 | 55 | 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js/dist/zone'; // Included with Angular CLI. 61 | 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | @import '~@angular/material/prebuilt-themes/pink-bluegrey.css'; 2 | 3 | .mat-drawer-container { 4 | background: #939393; 5 | } 6 | 7 | mat-card-actions { 8 | margin-left: 24px !important; 9 | } 10 | 11 | .dash-tooltip-class { 12 | font-size: 16px; 13 | } 14 | -------------------------------------------------------------------------------- /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/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | import { getTestBed } from '@angular/core/testing'; 10 | import { 11 | BrowserDynamicTestingModule, 12 | platformBrowserDynamicTesting 13 | } from '@angular/platform-browser-dynamic/testing'; 14 | 15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 16 | declare const __karma__: any; 17 | declare const require: any; 18 | 19 | // Prevent Karma from running prematurely. 20 | __karma__.loaded = function () {}; 21 | 22 | // First, initialize the Angular testing environment. 23 | getTestBed().initTestEnvironment( 24 | BrowserDynamicTestingModule, 25 | platformBrowserDynamicTesting() 26 | ); 27 | // Then we find all the tests. 28 | const context = require.context('./', true, /\.spec\.ts$/); 29 | // And load the modules. 30 | context.keys().map(context); 31 | // Finally, start Karma to run the tests. 32 | __karma__.start(); 33 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | }, 13 | "files": [ 14 | "test.ts" 15 | ], 16 | "include": [ 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ], 14 | "lib": [ 15 | "es2017", 16 | "dom" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs", 22 | "rxjs/Rx" 23 | ], 24 | "import-spacing": true, 25 | "indent": [ 26 | true, 27 | "spaces" 28 | ], 29 | "interface-over-type-literal": true, 30 | "label-position": true, 31 | "max-line-length": [ 32 | true, 33 | 140 34 | ], 35 | "member-access": false, 36 | "member-ordering": [ 37 | true, 38 | { 39 | "order": [ 40 | "static-field", 41 | "instance-field", 42 | "static-method", 43 | "instance-method" 44 | ] 45 | } 46 | ], 47 | "no-arg": true, 48 | "no-bitwise": true, 49 | "no-console": [ 50 | true, 51 | "debug", 52 | "info", 53 | "time", 54 | "timeEnd", 55 | "trace" 56 | ], 57 | "no-construct": true, 58 | "no-debugger": true, 59 | "no-duplicate-super": true, 60 | "no-empty": false, 61 | "no-empty-interface": true, 62 | "no-eval": true, 63 | "no-inferrable-types": [ 64 | true, 65 | "ignore-params" 66 | ], 67 | "no-misused-new": true, 68 | "no-non-null-assertion": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "typeof-compare": true, 111 | "unified-signatures": true, 112 | "variable-name": false, 113 | "whitespace": [ 114 | true, 115 | "check-branch", 116 | "check-decl", 117 | "check-operator", 118 | "check-separator", 119 | "check-type" 120 | ], 121 | "directive-selector": [ 122 | true, 123 | "attribute", 124 | "app", 125 | "camelCase" 126 | ], 127 | "component-selector": [ 128 | true, 129 | "element", 130 | "app", 131 | "kebab-case" 132 | ], 133 | "no-output-on-prefix": true, 134 | "use-input-property-decorator": true, 135 | "use-output-property-decorator": true, 136 | "use-host-property-decorator": true, 137 | "no-input-rename": true, 138 | "no-output-rename": true, 139 | "use-life-cycle-interface": true, 140 | "use-pipe-transform-interface": true, 141 | "component-class-suffix": true, 142 | "directive-class-suffix": true 143 | } 144 | } 145 | --------------------------------------------------------------------------------