├── .editorconfig ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── LICENSE.md ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package.json ├── projects └── ng-dialog-router │ ├── README.md │ ├── karma.conf.js │ ├── ng-package.json │ ├── package.json │ ├── src │ ├── lib │ │ ├── dialog-resolver.service.spec.ts │ │ ├── dialog-resolver.service.ts │ │ ├── dialog-router.component.spec.ts │ │ ├── dialog-router.component.ts │ │ ├── dialog-router.module.ts │ │ └── models │ │ │ └── dialog-route-config.model.ts │ ├── public_api.ts │ └── test.ts │ ├── tsconfig.lib.json │ ├── tsconfig.spec.json │ └── tslint.json ├── src ├── app │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── child-a │ │ ├── child-a.component.html │ │ ├── child-a.component.scss │ │ ├── child-a.component.spec.ts │ │ └── child-a.component.ts │ ├── home │ │ ├── home.component.html │ │ ├── home.component.scss │ │ ├── home.component.spec.ts │ │ └── home.component.ts │ ├── routing │ │ ├── routes.ts │ │ └── routing.module.ts │ └── sample-dialog │ │ ├── sample-dialog.component.html │ │ ├── sample-dialog.component.scss │ │ ├── sample-dialog.component.spec.ts │ │ └── sample-dialog.component.ts ├── assets │ └── .gitkeep ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json ├── tslint.json └── yarn.lock /.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 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: agrgic16 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.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 | # profiling files 12 | chrome-profiler-events.json 13 | speed-measure-plugin.json 14 | 15 | # IDEs and editors 16 | /.idea 17 | .project 18 | .classpath 19 | .c9/ 20 | *.launch 21 | .settings/ 22 | *.sublime-workspace 23 | 24 | # IDE - VSCode 25 | .vscode/* 26 | !.vscode/settings.json 27 | !.vscode/tasks.json 28 | !.vscode/launch.json 29 | !.vscode/extensions.json 30 | .history/* 31 | 32 | # misc 33 | /.sass-cache 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | npm-debug.log 38 | yarn-error.log 39 | testem.log 40 | /typings 41 | 42 | # System Files 43 | .DS_Store 44 | Thumbs.db 45 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2019] [Ante Grgić] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ng-dialog-router 2 | 3 | A small angular library that allows you to configure instances of @angular/material's MatDialog as part of your routing configuration. 4 | 5 | ## Getting Started 6 | In your angular app, run `npm install ng-dialog-router --save` OR `yarn add ng-dialog-router` 7 | 8 | ### Prerequisites 9 | Starting from scratch, please do the following: 10 | - Generate Angular App Using [Angular CLI](https://cli.angular.io/) 11 | - Install Angular Material by running `npm install @angular/material --save` OR `yarn add @angular/material` 12 | - Install ng-dialog-router by running `npm install ng-dialog-router --save` OR `yarn add ng-dialog-router` 13 | - Finally, in src/styles.scss, import the Angular Material core styles as `@import "~@angular/material/prebuilt-themes/indigo-pink.css";` 14 | 15 | ### Usage 16 | 17 | #### Essentials 18 | ng-dialog-router simply uses an angular route resolver to convert your 19 | normal route configuration into one that is displayed in a dialog. 20 | 21 | It should be provided to the `dlgRef` resolve property. 22 | 23 | ```ts 24 | import { DialogResolverService } from 'ng-dialog-router'; 25 | import { SampleDialogComponent } from '../sample-dialog/sample-dialog.component'; 26 | 27 | const route = { 28 | path: '0', 29 | component: SampleDialogComponent, 30 | resolve: { dlgRef: DialogResolverService }, 31 | } 32 | ``` 33 | 34 | #### Managing the dialog config settings 35 | The typical angular material options can be passed to the `dlg` property of the route `data`. 36 | The Angular Material Dialog documentation can be found here [Angular Material Dialog](https://material.angular.io/components/dialog/overview). 37 | ```ts 38 | import { DialogResolverService, DialogRouteConfig } from 'ng-dialog-router'; 39 | import { SampleDialogComponent } from '../sample-dialog/sample-dialog.component'; 40 | 41 | const route = { 42 | path: '0', 43 | component: SampleDialogComponent, 44 | resolve: { dlgRef: DialogResolverService }, 45 | data: { 46 | dlg: { 47 | data: { name: 'Sample Dialog #a.0' }, 48 | position: { left: '0' }, 49 | width: '500px', 50 | } as DialogRouteConfig, 51 | }, 52 | } 53 | ``` 54 | 55 | #### Additional config settings provided by this library 56 | 57 | For best results, using the strongly typed `DialogRouteConfig` interface for the `route.data.dlg` property 58 | is recommended via the `as DialogRouteConfig` syntax. 59 | 60 | ##### `redirectPath: string[]` 61 | By default, when the dialog is closed it will redirect up one level in the url tree. 62 | So if we are at `/home/0/a` it will navigate back to `/home/0`. ng-dialog-router has an additional 63 | option to allow for a custom redirect path, in case we want the dialog to go back to `/home` 64 | upon closing via the property `redirectPath`. 65 | 66 | ```ts 67 | const route = { 68 | path: '0', 69 | component: SampleDialogComponent, 70 | resolve: { dlgRef: DialogResolverService }, 71 | data: { 72 | dlg: { 73 | data: { name: 'Sample Dialog #a.0' }, 74 | position: { left: '0' }, 75 | width: '500px', 76 | redirectPath: [ 'home' ], 77 | } as DialogRouteConfig, 78 | }, 79 | } 80 | ``` 81 | 82 | ### Full Usage Example (implemented in app's routing module) 83 | 84 | #### app/routing/routes.ts 85 | ```ts 86 | import { Routes } from '@angular/router'; 87 | import { DialogResolverService, DialogRouteConfig } from 'ng-dialog-router'; 88 | import { SampleDialogComponent } from '../sample-dialog/sample-dialog.component'; 89 | import { HomeComponent } from '../home/home.component'; 90 | 91 | export const routes: Routes = [ 92 | { 93 | path: 'home', 94 | component: HomeComponent, 95 | children: [ 96 | { 97 | path: '0', 98 | component: SampleDialogComponent, 99 | resolve: { dlgRef: DialogResolverService }, 100 | data: { 101 | dlg: { 102 | data: { name: 'Sample Dialog #a.0' }, 103 | position: { left: '0' }, 104 | redirectPath: ['home'], 105 | width: '500px', 106 | } as DialogRouteConfig, 107 | }, 108 | }, 109 | ], 110 | }, 111 | ]; 112 | ``` 113 | 114 | #### app/routing/routing.module.ts 115 | ```ts 116 | import { NgModule } from '@angular/core'; 117 | import { CommonModule } from '@angular/common'; 118 | import { RouterModule } from '@angular/router'; 119 | import { DialogRouterModule } from 'ng-dialog-router'; 120 | import { routes } from './routes'; 121 | 122 | @NgModule({ 123 | imports: [ 124 | CommonModule, 125 | RouterModule.forRoot(routes), 126 | DialogRouterModule, 127 | ], 128 | exports: [ 129 | RouterModule, 130 | DialogRouterModule, 131 | ] 132 | }) 133 | export class RoutingModule { } 134 | 135 | ``` 136 | 137 | ## Built With 138 | * [Angular CLI](https://cli.angular.io/) 139 | * [Angular Material](https://material.angular.io/) 140 | 141 | ## Versioning 142 | We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/agrgic16/ng-dialog-router/tags). 143 | 144 | ## Authors 145 | * **Ante Grgić** - *Initial work* - [GitHub](https://github.com/agrgic16) 146 | 147 | ## License 148 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 149 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "ng-dialog-router-app": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": { 12 | "@schematics/angular:component": { 13 | "style": "sass" 14 | } 15 | }, 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/ng-dialog-router", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "src/tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "src/styles.scss" 31 | ], 32 | "scripts": [], 33 | "es5BrowserSupport": true 34 | }, 35 | "configurations": { 36 | "production": { 37 | "fileReplacements": [ 38 | { 39 | "replace": "src/environments/environment.ts", 40 | "with": "src/environments/environment.prod.ts" 41 | } 42 | ], 43 | "optimization": true, 44 | "outputHashing": "all", 45 | "sourceMap": false, 46 | "extractCss": true, 47 | "namedChunks": false, 48 | "aot": true, 49 | "extractLicenses": true, 50 | "vendorChunk": false, 51 | "buildOptimizer": true, 52 | "budgets": [ 53 | { 54 | "type": "initial", 55 | "maximumWarning": "2mb", 56 | "maximumError": "5mb" 57 | } 58 | ] 59 | } 60 | } 61 | }, 62 | "serve": { 63 | "builder": "@angular-devkit/build-angular:dev-server", 64 | "options": { 65 | "browserTarget": "ng-dialog-router-app:build" 66 | }, 67 | "configurations": { 68 | "production": { 69 | "browserTarget": "ng-dialog-router-app:build:production" 70 | } 71 | } 72 | }, 73 | "extract-i18n": { 74 | "builder": "@angular-devkit/build-angular:extract-i18n", 75 | "options": { 76 | "browserTarget": "ng-dialog-router-app:build" 77 | } 78 | }, 79 | "test": { 80 | "builder": "@angular-devkit/build-angular:karma", 81 | "options": { 82 | "main": "src/test.ts", 83 | "polyfills": "src/polyfills.ts", 84 | "tsConfig": "src/tsconfig.spec.json", 85 | "karmaConfig": "src/karma.conf.js", 86 | "styles": [ 87 | "src/styles.scss" 88 | ], 89 | "scripts": [], 90 | "assets": [ 91 | "src/favicon.ico", 92 | "src/assets" 93 | ] 94 | } 95 | }, 96 | "lint": { 97 | "builder": "@angular-devkit/build-angular:tslint", 98 | "options": { 99 | "tsConfig": [ 100 | "src/tsconfig.app.json", 101 | "src/tsconfig.spec.json" 102 | ], 103 | "exclude": [ 104 | "**/node_modules/**" 105 | ] 106 | } 107 | } 108 | } 109 | }, 110 | "ng-dialog-router-app-e2e": { 111 | "root": "e2e/", 112 | "projectType": "application", 113 | "prefix": "", 114 | "architect": { 115 | "e2e": { 116 | "builder": "@angular-devkit/build-angular:protractor", 117 | "options": { 118 | "protractorConfig": "e2e/protractor.conf.js", 119 | "devServerTarget": "ng-dialog-router-app:serve" 120 | }, 121 | "configurations": { 122 | "production": { 123 | "devServerTarget": "ng-dialog-router-app:serve:production" 124 | } 125 | } 126 | }, 127 | "lint": { 128 | "builder": "@angular-devkit/build-angular:tslint", 129 | "options": { 130 | "tsConfig": "e2e/tsconfig.e2e.json", 131 | "exclude": [ 132 | "**/node_modules/**" 133 | ] 134 | } 135 | } 136 | } 137 | }, 138 | "ng-dialog-router": { 139 | "root": "projects/ng-dialog-router", 140 | "sourceRoot": "projects/ng-dialog-router/src", 141 | "projectType": "library", 142 | "prefix": "lib", 143 | "architect": { 144 | "build": { 145 | "builder": "@angular-devkit/build-ng-packagr:build", 146 | "options": { 147 | "tsConfig": "projects/ng-dialog-router/tsconfig.lib.json", 148 | "project": "projects/ng-dialog-router/ng-package.json" 149 | } 150 | }, 151 | "test": { 152 | "builder": "@angular-devkit/build-angular:karma", 153 | "options": { 154 | "main": "projects/ng-dialog-router/src/test.ts", 155 | "tsConfig": "projects/ng-dialog-router/tsconfig.spec.json", 156 | "karmaConfig": "projects/ng-dialog-router/karma.conf.js" 157 | } 158 | }, 159 | "lint": { 160 | "builder": "@angular-devkit/build-angular:tslint", 161 | "options": { 162 | "tsConfig": [ 163 | "projects/ng-dialog-router/tsconfig.lib.json", 164 | "projects/ng-dialog-router/tsconfig.spec.json" 165 | ], 166 | "exclude": [ 167 | "**/node_modules/**" 168 | ] 169 | } 170 | } 171 | } 172 | } 173 | }, 174 | "defaultProject": "ng-dialog-router-app" 175 | } -------------------------------------------------------------------------------- /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 ng-dialog-router!'); 14 | }); 15 | 16 | it('should navigate to a dialog route', () => { 17 | page.navigateToDialog0(); 18 | expect(page.getDialog0TitleText()).toEqual('sample-dialog works!'); 19 | }); 20 | 21 | afterEach(async () => { 22 | // Assert that there are no errors emitted from the browser 23 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 24 | expect(logs).not.toContain(jasmine.objectContaining({ 25 | level: logging.Level.SEVERE, 26 | })); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /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 | navigateToDialog0() { 13 | return browser.get(`${browser.baseUrl}/home/0`); 14 | } 15 | 16 | getDialog0TitleText() { 17 | return element(by.css('h3')).getText() as Promise; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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": "ng-dialog-router-app", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "author": { 6 | "name": "Ante Grgić", 7 | "email": "ante16@gmail.com" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/agrgic16/ng-dialog-router" 12 | }, 13 | "keywords": [ 14 | "angular", 15 | "@angular", 16 | "@angular/material", 17 | "angular/router", 18 | "ng", 19 | "dialog", 20 | "modal", 21 | "router", 22 | "routing", 23 | "material", 24 | "mat-dialog", 25 | "ng-dialog-router" 26 | ], 27 | "scripts": { 28 | "ng": "ng", 29 | "start": "ng serve", 30 | "build": "ng build", 31 | "build_lib": "ng build ng-dialog-router", 32 | "copy_readme": "cp README.md dist/ng-dialog-router", 33 | "npm_pack": "cd dist/ng-dialog-router && npm pack", 34 | "package": "npm run build_lib && npm run copy_readme && npm run npm_pack", 35 | "test": "ng test", 36 | "lint": "ng lint", 37 | "e2e": "ng e2e" 38 | }, 39 | "private": true, 40 | "dependencies": { 41 | "@angular/animations": "^7.2.5", 42 | "@angular/cdk": "^7.3.2", 43 | "@angular/common": "~7.2.0", 44 | "@angular/compiler": "~7.2.0", 45 | "@angular/core": "~7.2.0", 46 | "@angular/forms": "~7.2.0", 47 | "@angular/material": "^7.3.2", 48 | "@angular/platform-browser": "~7.2.0", 49 | "@angular/platform-browser-dynamic": "~7.2.0", 50 | "@angular/router": "~7.2.0", 51 | "core-js": "^2.5.4", 52 | "tslib": "^1.9.0", 53 | "zone.js": "~0.8.26" 54 | }, 55 | "devDependencies": { 56 | "@angular-devkit/build-angular": "~0.13.0", 57 | "@angular-devkit/build-ng-packagr": "~0.13.0", 58 | "@angular/cli": "~7.3.1", 59 | "@angular/compiler-cli": "~7.2.0", 60 | "@angular/language-service": "~7.2.0", 61 | "@types/jasmine": "~2.8.8", 62 | "@types/jasminewd2": "~2.0.3", 63 | "@types/node": "~8.9.4", 64 | "codelyzer": "~4.5.0", 65 | "jasmine-core": "~2.99.1", 66 | "jasmine-spec-reporter": "~4.2.1", 67 | "karma": "~3.1.1", 68 | "karma-chrome-launcher": "~2.2.0", 69 | "karma-coverage-istanbul-reporter": "~2.0.1", 70 | "karma-jasmine": "~1.1.2", 71 | "karma-jasmine-html-reporter": "^0.2.2", 72 | "ng-packagr": "^4.2.0", 73 | "protractor": "~5.4.0", 74 | "ts-node": "~7.0.0", 75 | "tsickle": ">=0.34.0", 76 | "tslib": "^1.9.0", 77 | "tslint": "~5.11.0", 78 | "typescript": "~3.2.2" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/README.md: -------------------------------------------------------------------------------- 1 | # DialogRouter -------------------------------------------------------------------------------- /projects/ng-dialog-router/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/ng-dialog-router'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "../../dist/ng-dialog-router", 4 | "lib": { 5 | "entryFile": "src/public_api.ts" 6 | } 7 | } -------------------------------------------------------------------------------- /projects/ng-dialog-router/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-dialog-router", 3 | "version": "0.0.6", 4 | "license": "MIT", 5 | "author": { 6 | "name": "Ante Grgić", 7 | "email": "ante16@gmail.com" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/agrgic16/ng-dialog-router" 12 | }, 13 | "keywords": [ 14 | "angular", 15 | "@angular", 16 | "@angular/material", 17 | "angular/router", 18 | "ng", 19 | "dialog", 20 | "modal", 21 | "router", 22 | "routing", 23 | "material", 24 | "mat-dialog", 25 | "ng-dialog-router" 26 | ], 27 | "peerDependencies": { 28 | "@angular/animations": "^7.2.5", 29 | "@angular/cdk": "^7.3.2", 30 | "@angular/common": "^7.2.5", 31 | "@angular/core": "^7.2.5", 32 | "@angular/forms": "^7.2.6", 33 | "@angular/material": "^7.3.2", 34 | "@angular/platform-browser-dynamic": "~7.2.0", 35 | "@angular/platform-browser": "~7.2.0", 36 | "@angular/router": "^7.2.5", 37 | "rxjs": "^6.4.0" 38 | } 39 | } -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/lib/dialog-resolver.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { DialogResolverService } from './dialog-resolver.service'; 4 | import { MatDialogModule } from '@angular/material'; 5 | import { RouterTestingModule } from '@angular/router/testing'; 6 | 7 | describe('DialogResolverService', () => { 8 | beforeEach(() => TestBed.configureTestingModule({ 9 | imports: [ 10 | MatDialogModule, 11 | RouterTestingModule.withRoutes([]), 12 | ], 13 | providers: [ 14 | DialogResolverService, 15 | ], 16 | })); 17 | 18 | it('should be created', () => { 19 | const service: DialogResolverService = TestBed.get(DialogResolverService); 20 | expect(service).toBeTruthy(); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/lib/dialog-resolver.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { MatDialog, MatDialogRef } from '@angular/material'; 3 | import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; 4 | import { tap, takeUntil, take, mapTo } from 'rxjs/operators'; 5 | import { DialogRouteConfig } from './models/dialog-route-config.model'; 6 | 7 | @Injectable() 8 | export class DialogResolverService implements Resolve> { 9 | dialogRef: MatDialogRef; 10 | constructor(public dialog: MatDialog, public router: Router) { } 11 | 12 | resolve(nextRoute: ActivatedRouteSnapshot, routerState: RouterStateSnapshot) { 13 | let redirect: string[]; 14 | let cfg: DialogRouteConfig; 15 | let replace: boolean; 16 | const { data } = nextRoute; 17 | if (!!data && !!data.dlg) { 18 | const { redirectPath, replaceUrl, ...dlgCfg } = data.dlg as DialogRouteConfig; 19 | redirect = redirectPath; 20 | cfg = dlgCfg; 21 | replace = replaceUrl; 22 | } else { 23 | const { redirectPath, replaceUrl, ...dlgCfg } = { } as DialogRouteConfig; 24 | redirect = redirectPath; 25 | cfg = dlgCfg; 26 | replace = replaceUrl; 27 | } 28 | 29 | const navigateAfterClose = redirect || routerState.url.split('/').filter(p => !nextRoute.url.map(u => u.path).includes(p) && p !== ''); 30 | this.dialogRef = this.dialog.open(nextRoute.routeConfig.component, { ...cfg, closeOnNavigation: true }); 31 | this.dialogRef.afterClosed().pipe( 32 | tap(() => this.router.navigate(navigateAfterClose, {replaceUrl: replace})), 33 | take(1), 34 | ).subscribe(); 35 | 36 | return this.dialogRef.afterOpened().pipe( 37 | mapTo(this.dialogRef), 38 | takeUntil(this.dialogRef.afterClosed()), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/lib/dialog-router.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { DialogRouterComponent } from './dialog-router.component'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | 6 | describe('DialogRouterComponent', () => { 7 | let component: DialogRouterComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ DialogRouterComponent ], 13 | imports: [ RouterTestingModule.withRoutes([]) ] 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(DialogRouterComponent); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/lib/dialog-router.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | template: '', 5 | }) 6 | export class DialogRouterComponent { } 7 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/lib/dialog-router.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 3 | import { MatDialogModule } from '@angular/material/dialog'; 4 | import { RouterModule } from '@angular/router'; 5 | import { DialogRouterComponent } from './dialog-router.component'; 6 | import { DialogResolverService } from './dialog-resolver.service'; 7 | 8 | const dialogOutlet = { 9 | path: 'dialog-outlet', 10 | component: DialogRouterComponent, 11 | }; 12 | 13 | @NgModule({ 14 | declarations: [ 15 | DialogRouterComponent, 16 | ], 17 | imports: [ 18 | BrowserAnimationsModule, 19 | MatDialogModule, 20 | RouterModule.forChild([dialogOutlet]), 21 | ], 22 | providers: [ 23 | DialogResolverService, 24 | ] 25 | }) 26 | export class DialogRouterModule { } 27 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/lib/models/dialog-route-config.model.ts: -------------------------------------------------------------------------------- 1 | import { MatDialogConfig } from '@angular/material'; 2 | 3 | export class DialogRouteConfig extends MatDialogConfig { 4 | redirectPath?: string[]; 5 | replaceUrl?: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/public_api.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Public API Surface of dialog-router 3 | */ 4 | 5 | export * from './lib/dialog-resolver.service'; 6 | export * from './lib/dialog-router.component'; 7 | export * from './lib/dialog-router.module'; 8 | export * from './lib/models/dialog-route-config.model'; 9 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'core-js/es7/reflect'; 4 | import 'zone.js/dist/zone'; 5 | import 'zone.js/dist/zone-testing'; 6 | import { getTestBed } from '@angular/core/testing'; 7 | import { 8 | BrowserDynamicTestingModule, 9 | platformBrowserDynamicTesting 10 | } from '@angular/platform-browser-dynamic/testing'; 11 | 12 | declare const require: any; 13 | 14 | // First, initialize the Angular testing environment. 15 | getTestBed().initTestEnvironment( 16 | BrowserDynamicTestingModule, 17 | platformBrowserDynamicTesting() 18 | ); 19 | // Then we find all the tests. 20 | const context = require.context('./', true, /\.spec\.ts$/); 21 | // And load the modules. 22 | context.keys().map(context); 23 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/lib", 5 | "target": "es2015", 6 | "module": "es2015", 7 | "moduleResolution": "node", 8 | "declaration": true, 9 | "sourceMap": true, 10 | "inlineSources": true, 11 | "emitDecoratorMetadata": true, 12 | "experimentalDecorators": true, 13 | "importHelpers": true, 14 | "types": [], 15 | "lib": [ 16 | "dom", 17 | "es2018" 18 | ] 19 | }, 20 | "angularCompilerOptions": { 21 | "annotateForClosureCompiler": true, 22 | "skipTemplateCodegen": true, 23 | "strictMetadataEmit": true, 24 | "fullTemplateTypeCheck": true, 25 | "strictInjectionParameters": true, 26 | "enableResourceInlining": true 27 | }, 28 | "exclude": [ 29 | "src/test.ts", 30 | "**/*.spec.ts" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/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 | "src/test.ts" 12 | ], 13 | "include": [ 14 | "**/*.spec.ts", 15 | "**/*.d.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /projects/ng-dialog-router/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "lib", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "lib", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | Welcome to {{ title }}! 5 |

6 | Angular Logo 7 |
8 | home 9 | 10 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agrgic16/ng-dialog-router/2a764ee91177c44a0e38e41f34d738084a13e347/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | imports: [ 12 | RouterTestingModule.withRoutes([]), 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 'ng-dialog-router'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.debugElement.componentInstance; 26 | expect(app.title).toEqual('ng-dialog-router'); 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 ng-dialog-router!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'ng-dialog-router'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { MatDialogModule } from '@angular/material/dialog'; 4 | 5 | import { AppComponent } from './app.component'; 6 | import { RoutingModule } from './routing/routing.module'; 7 | import { SampleDialogComponent } from './sample-dialog/sample-dialog.component'; 8 | import { HomeComponent } from './home/home.component'; 9 | import { ChildAComponent } from './child-a/child-a.component'; 10 | 11 | @NgModule({ 12 | declarations: [ 13 | AppComponent, 14 | SampleDialogComponent, 15 | HomeComponent, 16 | ChildAComponent, 17 | ], 18 | imports: [ 19 | BrowserModule, 20 | RoutingModule, 21 | MatDialogModule, 22 | ], 23 | bootstrap: [ 24 | AppComponent, 25 | ] 26 | }) 27 | export class AppModule { } 28 | -------------------------------------------------------------------------------- /src/app/child-a/child-a.component.html: -------------------------------------------------------------------------------- 1 |

2 | child-a works! 3 |

4 | -------------------------------------------------------------------------------- /src/app/child-a/child-a.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agrgic16/ng-dialog-router/2a764ee91177c44a0e38e41f34d738084a13e347/src/app/child-a/child-a.component.scss -------------------------------------------------------------------------------- /src/app/child-a/child-a.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ChildAComponent } from './child-a.component'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | import { MatDialogModule } from '@angular/material'; 6 | 7 | describe('ChildAComponent', () => { 8 | let component: ChildAComponent; 9 | let fixture: ComponentFixture; 10 | 11 | beforeEach(async(() => { 12 | TestBed.configureTestingModule({ 13 | imports: [ RouterTestingModule, MatDialogModule ], 14 | declarations: [ ChildAComponent ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(ChildAComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/app/child-a/child-a.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-child-a', 5 | templateUrl: './child-a.component.html', 6 | styleUrls: ['./child-a.component.scss'] 7 | }) 8 | export class ChildAComponent implements OnInit { 9 | dialogRoutes = [ 10 | ['0'], 11 | ['1'], 12 | ['2'], 13 | ['3'], 14 | ['4'], 15 | ['5'], 16 | ]; 17 | constructor() { } 18 | 19 | ngOnInit() { 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/app/home/home.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/home/home.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agrgic16/ng-dialog-router/2a764ee91177c44a0e38e41f34d738084a13e347/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 | import { RouterTestingModule } from '@angular/router/testing'; 5 | import { MatDialogModule } from '@angular/material'; 6 | 7 | describe('HomeComponent', () => { 8 | let component: HomeComponent; 9 | let fixture: ComponentFixture; 10 | 11 | beforeEach(async(() => { 12 | TestBed.configureTestingModule({ 13 | imports: [ RouterTestingModule, MatDialogModule ], 14 | declarations: [ HomeComponent ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(HomeComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /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 | dialogRoutes = [ 10 | ['a', '0'], 11 | ['0'], 12 | ['1'], 13 | ['2'], 14 | ['3'], 15 | ['4'], 16 | ['5'], 17 | ]; 18 | constructor() { } 19 | 20 | ngOnInit() { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/app/routing/routes.ts: -------------------------------------------------------------------------------- 1 | import { DialogResolverService, DialogRouteConfig } from 'ng-dialog-router'; 2 | import { Routes } from '@angular/router'; 3 | import { MatDialogConfig } from '@angular/material'; 4 | import { SampleDialogComponent } from '../sample-dialog/sample-dialog.component'; 5 | import { HomeComponent } from '../home/home.component'; 6 | import { ChildAComponent } from '../child-a/child-a.component'; 7 | 8 | export const routes: Routes = [ 9 | { 10 | path: 'home', 11 | component: HomeComponent, 12 | children: [ 13 | { 14 | path: 'a', 15 | component: ChildAComponent, 16 | children: [ 17 | { 18 | path: '0', 19 | component: SampleDialogComponent, 20 | resolve: { dlgRef: DialogResolverService }, 21 | data: { 22 | dlg: { 23 | data: { name: 'Sample Dialog #a.0' }, 24 | position: { left: '0' }, 25 | redirectPath: ['home'], 26 | width: '500px', 27 | } as DialogRouteConfig, 28 | }, 29 | }, 30 | ], 31 | }, 32 | { 33 | resolve: { dlgRef: DialogResolverService }, 34 | path: '0', 35 | component: SampleDialogComponent, 36 | }, 37 | { 38 | resolve: { dlgRef: DialogResolverService }, 39 | path: '1', 40 | component: SampleDialogComponent, 41 | data: { dlg: { width: '500px', data: { name: 'Sample Dialog #0 extra' }, position: { right: '0' } } as MatDialogConfig } 42 | }, 43 | { 44 | resolve: { dlgRef: DialogResolverService }, 45 | path: '2', 46 | component: SampleDialogComponent, 47 | data: { dlg: { width: '1000px', data: { name: 'Sample Dialog #2' }, replaceUrl: true } as MatDialogConfig } 48 | }, 49 | { 50 | resolve: { dlgRef: DialogResolverService }, 51 | path: '3', 52 | component: SampleDialogComponent, 53 | data: { dlg: { width: '1000px', data: { name: 'Sample Dialog #3' } } as MatDialogConfig } 54 | }, 55 | { 56 | resolve: { dlgRef: DialogResolverService }, 57 | path: '4', 58 | component: SampleDialogComponent, 59 | data: { dlg: { width: '1000px', data: { name: 'Sample Dialog #4' } } as MatDialogConfig } 60 | }, 61 | { 62 | resolve: { dlgRef: DialogResolverService }, 63 | path: '5', 64 | component: SampleDialogComponent, 65 | data: { dlg: { width: '1000px', data: { name: 'Sample Dialog #5' }, replaceUrl: true } as MatDialogConfig } 66 | } 67 | ], 68 | } 69 | ]; 70 | -------------------------------------------------------------------------------- /src/app/routing/routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { RouterModule } from '@angular/router'; 4 | import { DialogRouterModule } from 'ng-dialog-router'; 5 | import { routes } from './routes'; 6 | 7 | @NgModule({ 8 | imports: [ 9 | CommonModule, 10 | RouterModule.forRoot(routes), 11 | DialogRouterModule, 12 | ], 13 | exports: [ 14 | RouterModule, 15 | DialogRouterModule, 16 | ] 17 | }) 18 | export class RoutingModule { } 19 | -------------------------------------------------------------------------------- /src/app/sample-dialog/sample-dialog.component.html: -------------------------------------------------------------------------------- 1 |

2 | sample-dialog works! 3 |

4 |

Name: {{data | json}}

-------------------------------------------------------------------------------- /src/app/sample-dialog/sample-dialog.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agrgic16/ng-dialog-router/2a764ee91177c44a0e38e41f34d738084a13e347/src/app/sample-dialog/sample-dialog.component.scss -------------------------------------------------------------------------------- /src/app/sample-dialog/sample-dialog.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { SampleDialogComponent } from './sample-dialog.component'; 4 | import { MAT_DIALOG_DATA } from '@angular/material'; 5 | import { RouterTestingModule } from '@angular/router/testing'; 6 | 7 | describe('SampleDialogComponent', () => { 8 | let component: SampleDialogComponent; 9 | let fixture: ComponentFixture; 10 | 11 | beforeEach(async(() => { 12 | TestBed.configureTestingModule({ 13 | declarations: [ SampleDialogComponent ], 14 | imports: [ RouterTestingModule ], 15 | providers: [ 16 | { provide: MAT_DIALOG_DATA, useValue: { name: 'test dialog #1' } } 17 | ] 18 | }) 19 | .compileComponents(); 20 | })); 21 | 22 | beforeEach(() => { 23 | fixture = TestBed.createComponent(SampleDialogComponent); 24 | component = fixture.componentInstance; 25 | fixture.detectChanges(); 26 | }); 27 | 28 | it('should create', () => { 29 | expect(component).toBeTruthy(); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/sample-dialog/sample-dialog.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, Optional } from '@angular/core'; 2 | import { MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | import { ActivatedRoute } from '@angular/router'; 4 | 5 | @Component({ 6 | selector: 'app-sample-dialog', 7 | templateUrl: './sample-dialog.component.html', 8 | styleUrls: ['./sample-dialog.component.scss'], 9 | }) 10 | export class SampleDialogComponent { 11 | constructor(@Optional() @Inject(MAT_DIALOG_DATA) public data: any, public route: ActivatedRoute) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agrgic16/ng-dialog-router/2a764ee91177c44a0e38e41f34d738084a13e347/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 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agrgic16/ng-dialog-router/2a764ee91177c44a0e38e41f34d738084a13e347/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NgDialogRouter 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage/ng-dialog-router'), 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 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 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.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import "~@angular/material/prebuilt-themes/indigo-pink.css"; -------------------------------------------------------------------------------- /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 | "paths": { 22 | "ng-dialog-router": [ 23 | "dist/ng-dialog-router" 24 | ], 25 | "ng-dialog-router/*": [ 26 | "dist/ng-dialog-router/*" 27 | ] 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------