├── .dockerignore ├── .editorconfig ├── .github ├── workflow │ └── ci-workflow.yml └── workflows │ └── ci-workflow.yml ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .vscode └── settings.json ├── Dockerfile ├── README.md ├── angular.json ├── browserslist ├── cypress.json ├── cypress ├── fixtures │ ├── example.json │ └── users.json ├── integration │ └── first-test.spec.js └── plugins │ └── index.js ├── cypress_env.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.scss-theme.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── config.service.ts │ ├── core │ │ ├── actions │ │ │ ├── auth.actions.ts │ │ │ ├── index.ts │ │ │ └── settings.action.ts │ │ ├── animations │ │ │ ├── animation.service.spec.ts │ │ │ ├── animation.service.ts │ │ │ └── route.animations.ts │ │ ├── auth │ │ │ ├── auth-guard.service.spec.ts │ │ │ ├── auth-guard.service.ts │ │ │ └── auth.module.ts │ │ ├── components │ │ │ ├── content-wrapper │ │ │ │ ├── content-wrapper.component.html │ │ │ │ ├── content-wrapper.component.scss │ │ │ │ ├── content-wrapper.component.spec.ts │ │ │ │ └── content-wrapper.component.ts │ │ │ ├── footer │ │ │ │ ├── footer.component.html │ │ │ │ ├── footer.component.scss │ │ │ │ ├── footer.component.spec.ts │ │ │ │ └── footer.component.ts │ │ │ ├── navbar │ │ │ │ ├── navbar.component.html │ │ │ │ ├── navbar.component.scss │ │ │ │ ├── navbar.component.spec.ts │ │ │ │ └── navbar.component.ts │ │ │ ├── notifications │ │ │ │ ├── notifications.component.html │ │ │ │ ├── notifications.component.scss │ │ │ │ ├── notifications.component.spec.ts │ │ │ │ └── notifications.component.ts │ │ │ ├── page-not-found │ │ │ │ ├── page-not-found.component.html │ │ │ │ ├── page-not-found.component.scss │ │ │ │ ├── page-not-found.component.spec.ts │ │ │ │ └── page-not-found.component.ts │ │ │ ├── pl-table │ │ │ │ ├── pl-table.component.html │ │ │ │ ├── pl-table.component.scss │ │ │ │ ├── pl-table.component.spec.ts │ │ │ │ └── pl-table.component.ts │ │ │ └── sidenav │ │ │ │ ├── sidenav.component.html │ │ │ │ ├── sidenav.component.scss │ │ │ │ ├── sidenav.component.spec.ts │ │ │ │ └── sidenav.component.ts │ │ ├── configuration │ │ │ └── route-state.serializer.ts │ │ ├── contants │ │ │ └── root-paths.ts │ │ ├── core.module.ts │ │ ├── http-interceptors │ │ │ ├── http-error.interceptor.ts │ │ │ └── http-token.interceptor.ts │ │ ├── models │ │ │ ├── article.ts │ │ │ └── error.model.ts │ │ ├── module-import.guard.ts │ │ ├── services │ │ │ ├── authentication.service.spec.ts │ │ │ ├── authentication.service.ts │ │ │ ├── icon.service.spec.ts │ │ │ ├── icon.service.ts │ │ │ ├── local-storage.service.spec.ts │ │ │ ├── local-storage.service.ts │ │ │ ├── logger.service.ts │ │ │ ├── sidenav.service.spec.ts │ │ │ ├── sidenav.service.ts │ │ │ ├── standings.service.spec.ts │ │ │ └── standings.service.ts │ │ └── states │ │ │ └── settings.state.ts │ ├── features │ │ ├── about │ │ │ ├── about-routing.module.ts │ │ │ ├── about.component.html │ │ │ ├── about.component.scss │ │ │ ├── about.component.spec.ts │ │ │ ├── about.component.ts │ │ │ ├── about.module.ts │ │ │ ├── components │ │ │ │ ├── address-one │ │ │ │ │ ├── address-one.component.html │ │ │ │ │ ├── address-one.component.scss │ │ │ │ │ ├── address-one.component.spec.ts │ │ │ │ │ └── address-one.component.ts │ │ │ │ └── address-two │ │ │ │ │ ├── address-two.component.html │ │ │ │ │ ├── address-two.component.scss │ │ │ │ │ ├── address-two.component.spec.ts │ │ │ │ │ └── address-two.component.ts │ │ │ └── states │ │ │ │ └── about.state.ts │ │ ├── admin │ │ │ └── admin.module.ts │ │ ├── article │ │ │ ├── article.module.ts │ │ │ └── helpers │ │ │ │ ├── article-list │ │ │ │ ├── article-list.component.html │ │ │ │ ├── article-list.component.scss │ │ │ │ ├── article-list.component.spec.ts │ │ │ │ └── article-list.component.ts │ │ │ │ ├── article-meta │ │ │ │ ├── article-meta.component.html │ │ │ │ ├── article-meta.component.scss │ │ │ │ ├── article-meta.component.spec.ts │ │ │ │ └── article-meta.component.ts │ │ │ │ └── article-preview │ │ │ │ ├── article-preview.component.html │ │ │ │ ├── article-preview.component.scss │ │ │ │ ├── article-preview.component.spec.ts │ │ │ │ └── article-preview.component.ts │ │ ├── forum │ │ │ └── forum.module.ts │ │ ├── home │ │ │ ├── home-routing.module.ts │ │ │ ├── home.component.html │ │ │ ├── home.component.scss │ │ │ ├── home.component.spec.ts │ │ │ ├── home.component.ts │ │ │ └── home.module.ts │ │ ├── profile │ │ │ ├── profile-routing.module.ts │ │ │ ├── profile.component.html │ │ │ ├── profile.component.scss │ │ │ ├── profile.component.spec.ts │ │ │ ├── profile.component.ts │ │ │ ├── profile.module.ts │ │ │ └── states │ │ │ │ └── profile.state.ts │ │ └── settings │ │ │ ├── settings-routing.module.ts │ │ │ ├── settings.component.html │ │ │ ├── settings.component.scss │ │ │ ├── settings.component.spec.ts │ │ │ ├── settings.component.ts │ │ │ └── settings.module.ts │ └── shared │ │ ├── components │ │ ├── big-input │ │ │ ├── big-input.component.html │ │ │ ├── big-input.component.scss │ │ │ ├── big-input.component.spec.ts │ │ │ └── big-input.component.ts │ │ ├── favorite-button │ │ │ ├── favorite-button.component.html │ │ │ ├── favorite-button.component.scss │ │ │ ├── favorite-button.component.spec.ts │ │ │ └── favorite-button.component.ts │ │ ├── follow-button │ │ │ ├── follow-button.component.html │ │ │ ├── follow-button.component.scss │ │ │ ├── follow-button.component.spec.ts │ │ │ └── follow-button.component.ts │ │ └── show-errors │ │ │ ├── show-errors.component.html │ │ │ ├── show-errors.component.scss │ │ │ ├── show-errors.component.spec.ts │ │ │ └── show-errors.component.ts │ │ ├── directives │ │ └── show-authed.directive.ts │ │ ├── material.module.ts │ │ ├── services │ │ ├── validation.service.spec.ts │ │ └── validation.service.ts │ │ ├── shared.module.ts │ │ └── utils │ │ └── common.ts ├── assets │ ├── .gitkeep │ ├── i18n │ │ ├── en.json │ │ └── no.json │ └── icons │ │ └── aston-villa-logo.svg ├── environments │ ├── environment.ci.ts │ ├── environment.hmr.ts │ ├── environment.prod.ts │ ├── environment.test.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss ├── styles │ ├── app-loading.scss │ ├── colors.scss │ ├── overrides-material.scss │ ├── reset-theme.scss │ ├── spinner.scss │ └── variables.scss ├── test.ts └── themes │ ├── dark-theme.scss │ ├── default-theme.scss │ └── villa-blue-theme.scss ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .git 3 | .gitignore 4 | -------------------------------------------------------------------------------- /.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/workflow/ci-workflow.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions docs 2 | # https://help.github.com/en/articles/about-github-actions 3 | # https://help.github.com/en/articles/workflow-syntax-for-github-actions 4 | name: CI 5 | 6 | on: [push] 7 | 8 | jobs: 9 | build: 10 | 11 | # Machine environment: 12 | # https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions#ubuntu-1804-lts 13 | # We specify the Node.js version manually below, and use versioned Chrome from Puppeteer. 14 | runs-on: ubuntu-18.04 15 | 16 | steps: 17 | - uses: actions/checkout@v1 18 | - name: Use Node.js 12.8 19 | uses: actions/setup-node@v1 20 | with: 21 | node-version: 12.8 22 | - name: Install dependencies 23 | run: npm install 24 | - name: Lint 25 | run: npm run lint 26 | - name: Build 27 | run: npm run build -- --prod 28 | - name: Test 29 | run: npm test -- --configuration=test 30 | - name: E2E 31 | run: npm run e2e -- --configuration=test 32 | -------------------------------------------------------------------------------- /.github/workflows/ci-workflow.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions docs 2 | # https://help.github.com/en/articles/about-github-actions 3 | # https://help.github.com/en/articles/workflow-syntax-for-github-actions 4 | name: CI 5 | 6 | on: [push] 7 | 8 | jobs: 9 | build: 10 | 11 | # Machine environment: 12 | # https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions#ubuntu-1804-lts 13 | # We specify the Node.js version manually below, and use versioned Chrome from Puppeteer. 14 | runs-on: ubuntu-18.04 15 | 16 | steps: 17 | - uses: actions/checkout@v1 18 | - name: Use Node.js 12.8 19 | uses: actions/setup-node@v1 20 | with: 21 | node-version: 12.8 22 | - name: Install dependencies 23 | run: npm install 24 | - name: Lint 25 | run: npm run lint 26 | - name: Build 27 | run: npm run build -- --prod 28 | - name: Test 29 | run: npm test -- --configuration=test 30 | - name: E2E 31 | run: npm run e2e -- --configuration=test 32 | -------------------------------------------------------------------------------- /.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 | # Only exists if Bazel was run 9 | /bazel-out 10 | 11 | # dependencies 12 | /node_modules 13 | 14 | # profiling files 15 | chrome-profiler-events*.json 16 | speed-measure-plugin*.json 17 | 18 | # IDEs and editors 19 | /.idea 20 | .project 21 | .classpath 22 | .c9/ 23 | *.launch 24 | .settings/ 25 | *.sublime-workspace 26 | 27 | # IDE - VSCode 28 | .vscode/* 29 | !.vscode/settings.json 30 | !.vscode/tasks.json 31 | !.vscode/launch.json 32 | !.vscode/extensions.json 33 | .history/* 34 | 35 | # misc 36 | /.sass-cache 37 | /connect.lock 38 | /coverage 39 | /libpeerconnection.log 40 | npm-debug.log 41 | yarn-error.log 42 | testem.log 43 | /typings 44 | 45 | # System Files 46 | .DS_Store 47 | Thumbs.db 48 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | package-lock.json 3 | *.html -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": false, 3 | "printWidth": 80, 4 | "tabWidth": 2, 5 | "singleQuote": true, 6 | "trailingComma": "none", 7 | "semi": true 8 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.autoSave": "afterDelay" 3 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # base image 2 | FROM node:12.2.0 3 | 4 | # install chrome for protractor tests 5 | RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - 6 | RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' 7 | RUN apt-get update && apt-get install -yq google-chrome-stable 8 | 9 | # set working directory 10 | WORKDIR /app 11 | 12 | # add `/app/node_modules/.bin` to $PATH 13 | ENV PATH /app/node_modules/.bin:$PATH 14 | 15 | # install and cache app dependencies 16 | COPY package.json /app/package.json 17 | RUN npm install 18 | RUN npm install -g @angular/cli@7.3.9 19 | 20 | # add app 21 | COPY . /app 22 | 23 | # start app 24 | CMD ng serve --host 0.0.0.0 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Aston Villa - Norwegian Fans 2 | 3 | by [@mathisGarberg](https://twitter.com/MathGarb) 4 | 5 | ## Table of Content 6 | 7 | - [Live Demo] 8 | - [Getting Started] 9 | 10 | ## Initial setup 11 | * Run `git clone ...` 12 | * Run `npm install` in the `./angular-material-starter` folder 13 | * Install Angular CLI version 8.0, `npm install -g @angular/cli --latest` 14 | 15 | ## Deployment 16 | 17 | ## Learning Materials 18 | * [Blog post about the ultimate Angular folder structure]() 19 | * [Blog post about clean code principles you should adapt to your Angular project]() 20 | 21 | 22 | ## How to run 23 | 24 | When startin the application please use `npm start`, this triggers `ng serve --open --port 50000. 25 | 26 | ## Tips for developers 27 | 28 | We've been using VS Code to deveop, and would like to recommend the following plugins. 29 | 30 | ## End to end testing 31 | 32 | ### **Step 1** - Start dev server and cypress 33 | 34 | Run the following command `npm run e2e:dev`, this will open two windows. One compiles and runs Angular. the other runs Cypress. Wait for the angular application 35 | to finish compiling before you continue. 36 | 37 | ![cypress 1](./wiki/images/cypress-1.PNG) 38 | 39 | ### **Step 2** - Run tests 40 | 41 | ![cypress 3](./wiki/gifs/angular-material-starter.gif) 42 | 43 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.0. 44 | 45 | ## Code scaffolding 46 | 47 | Run `ng build` to execute the unit tests via [Karma](https://karma-runner.github.io) 48 | 49 | ## Furhter help 50 | 51 | To get more help on the Angular CLI, use `ng help` or check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md) 52 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-material-starter": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "changeDetection": "OnPush", 11 | "style": "scss" 12 | } 13 | }, 14 | "root": "", 15 | "sourceRoot": "src", 16 | "prefix": "app", 17 | "architect": { 18 | "build": { 19 | "builder": "@angular-devkit/build-angular:browser", 20 | "options": { 21 | "outputPath": "dist/angular-material-starter", 22 | "index": "src/index.html", 23 | "main": "src/main.ts", 24 | "polyfills": "src/polyfills.ts", 25 | "tsConfig": "tsconfig.app.json", 26 | "aot": false, 27 | "assets": [ 28 | "src/favicon.ico", 29 | "src/assets" 30 | ], 31 | "styles": [ 32 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 33 | "src/styles.scss" 34 | ], 35 | "scripts": [] 36 | }, 37 | "configurations": { 38 | "production": { 39 | "fileReplacements": [ 40 | { 41 | "replace": "src/environments/environment.ts", 42 | "with": "src/environments/environment.prod.ts" 43 | } 44 | ], 45 | "optimization": true, 46 | "outputHashing": "all", 47 | "sourceMap": false, 48 | "extractCss": true, 49 | "namedChunks": false, 50 | "aot": true, 51 | "extractLicenses": true, 52 | "vendorChunk": false, 53 | "buildOptimizer": true, 54 | "budgets": [ 55 | { 56 | "type": "bundle", 57 | "name": "polyfills", 58 | "baseline": "150kb", 59 | "maximumWarning": "50kb", 60 | "maximumError": "100kb" 61 | }, 62 | { 63 | "type": "bundle", 64 | "name": "styles", 65 | "baseline": "280kb", 66 | "maximumWarning": "50kb", 67 | "maximumError": "100kb" 68 | }, 69 | { 70 | "type": "bundle", 71 | "name": "main", 72 | "baseline": "1024kb", 73 | "maximumWarning": "100kb", 74 | "maximumError": "250kb" 75 | } 76 | ] 77 | }, 78 | "test": { 79 | "fileReplacements": [ 80 | { 81 | "replace": "src/environments/environment.ts", 82 | "with": "src/environments/environment.test.ts" 83 | } 84 | ] 85 | }, 86 | "ci": { 87 | "fileReplacements": [ 88 | { 89 | "replace": "src/environments/environment.ts", 90 | "with": "src/environments/environment.ci.ts" 91 | } 92 | ] 93 | } 94 | } 95 | }, 96 | "serve": { 97 | "builder": "@angular-devkit/build-angular:dev-server", 98 | "options": { 99 | "browserTarget": "angular-material-starter:build" 100 | }, 101 | "configurations": { 102 | "production": { 103 | "browserTarget": "angular-material-starter:build:production" 104 | }, 105 | "test": { 106 | "browserTarget": "angular-material-starter:build:test" 107 | }, 108 | "ci": { 109 | "browserTarget": "angular-material-starter:build:ci" 110 | } 111 | } 112 | }, 113 | "extract-i18n": { 114 | "builder": "@angular-devkit/build-angular:extract-i18n", 115 | "options": { 116 | "browserTarget": "angular-material-starter:build" 117 | } 118 | }, 119 | "test": { 120 | "builder": "@angular-devkit/build-angular:karma", 121 | "options": { 122 | "main": "src/test.ts", 123 | "polyfills": "src/polyfills.ts", 124 | "tsConfig": "tsconfig.spec.json", 125 | "karmaConfig": "karma.conf.js", 126 | "assets": [ 127 | "src/favicon.ico", 128 | "src/assets" 129 | ], 130 | "styles": [ 131 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 132 | "src/styles.scss" 133 | ], 134 | "scripts": [] 135 | }, 136 | "configurations": { 137 | "test": { 138 | "fileReplacements": [ 139 | { 140 | "replace": "src/environments/environment.ts", 141 | "with": "src/environments/environment.test.ts" 142 | } 143 | ] 144 | } 145 | } 146 | }, 147 | "ci": { 148 | "builder": "@angular-devkit/build-angular:karma", 149 | "options": { 150 | "main": "src/test.ts", 151 | "polyfills": "src/polyfills.ts", 152 | "tsConfig": "tsconfig.spec.json", 153 | "karmaConfig": "karma.conf.js", 154 | "assets": [ 155 | "src/favicon.ico", 156 | "src/assets" 157 | ], 158 | "styles": [ 159 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 160 | "src/styles.scss" 161 | ], 162 | "scripts": [] 163 | }, 164 | "configurations": { 165 | "ci": { 166 | "fileReplacements": [ 167 | { 168 | "replace": "src/environments/environment.ts", 169 | "with": "src/environments/environment.ci.ts" 170 | } 171 | ] 172 | } 173 | } 174 | }, 175 | "lint": { 176 | "builder": "@angular-devkit/build-angular:tslint", 177 | "options": { 178 | "tsConfig": [ 179 | "tsconfig.app.json", 180 | "tsconfig.spec.json", 181 | "e2e/tsconfig.json" 182 | ], 183 | "exclude": [ 184 | "**/node_modules/**" 185 | ] 186 | } 187 | }, 188 | "e2e": { 189 | "builder": "@angular-devkit/build-angular:protractor", 190 | "options": { 191 | "protractorConfig": "e2e/protractor.conf.js", 192 | "devServerTarget": "angular-material-starter:serve" 193 | }, 194 | "configurations": { 195 | "production": { 196 | "devServerTarget": "angular-material-starter:serve:production" 197 | } 198 | } 199 | } 200 | } 201 | } 202 | }, 203 | "defaultProject": "angular-material-starter" 204 | } 205 | -------------------------------------------------------------------------------- /browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:4200", 3 | "video": false, 4 | "chromeWebSecurity": false, 5 | "username": "mk", 6 | "password": "qwerty" 7 | } 8 | -------------------------------------------------------------------------------- /cypress/fixtures/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Using fixtures to represent data", 3 | "email": "hello@cypress.io", 4 | "body": "Fixtures are a great way to mock data for responses to routes" 5 | } -------------------------------------------------------------------------------- /cypress/fixtures/users.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "firstName":"Michael", 3 | "lastName":"K", 4 | "username":"mk", 5 | "password":"qwerty", 6 | "id":1 7 | }] 8 | -------------------------------------------------------------------------------- /cypress/integration/first-test.spec.js: -------------------------------------------------------------------------------- 1 | describe("First test", () => { 2 | it("should visit login page", () => { 3 | cy.visit("/profile"); 4 | // cy.get('#text').type('Mathis'); 5 | // cy.get('#username').type(Cypress.config('username')); 6 | // cy.get('#password').type(Cypress.config('password')); 7 | cy.get('#text').type(Cypress.config('username')); 8 | cy.get('.submit-btn').click(); 9 | cy.url().should('include', '/profile'); 10 | cy.fixture('users').then((users) => { 11 | localStorage.setItem( 12 | 'users', 13 | JSON.stringify(users) 14 | ); 15 | }); 16 | }); 17 | 18 | 19 | // describe('Login Page', () => { 20 | // beforeEach(() => { 21 | // // Start server to listen to routes. 22 | // cy.server(); 23 | 24 | // // The ** wildcard character sequence matches a partial path. 25 | // // We listen for POSTs where the URL ends with /authenticate. 26 | // // Alias the route with 'as()' to find it later. 27 | // cy.route('POST', **/authenticate').as('authenticate'); 28 | // }); 29 | 30 | // it('user can log in', function () { 31 | 32 | // cy.visit("/login"); 33 | // cy.get('#username').type(Cypress.config('username')); 34 | // cy.get('#password').type(Cypress.config('password')); 35 | 36 | // // When we submit the form an async XHR call is made. 37 | // cy.get('.btn-primary').click(); 38 | 39 | // // We wait until the call with the alias authenticate is resolved. 40 | // cy.wait('@authenticate'); 41 | 42 | // // If we don't wait the assertion is false. 43 | // cy.get('h1').should('contain', 'Hi Michael'); 44 | // }); 45 | // }); 46 | }); 47 | -------------------------------------------------------------------------------- /cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example plugins/index.js can be used to load plugins 3 | // 4 | // You can change the location of this file or turn off loading 5 | // the plugins file with the 'pluginsFile' configuration option. 6 | // 7 | // You can read more here: 8 | // https://on.cypress.io/plugins-guide 9 | // *********************************************************** 10 | 11 | // This function is called when a project is opened or re-opened (e.g. due to 12 | // the project's config changing) 13 | 14 | module.exports = (on, config) => { 15 | // `on` is used to hook into various events Cypress emits 16 | // `config` is the resolved Cypress config 17 | } 18 | -------------------------------------------------------------------------------- /cypress_env.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth_login_uri": "", 3 | "auth_logout_url": "", 4 | "auth_password": "", 5 | "auth_return_url": "", 6 | "auth_openid_configuration": "" 7 | } 8 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | 'browserName': 'chrome' 17 | }, 18 | directConnect: true, 19 | baseUrl: 'http://localhost:4200/', 20 | framework: 'jasmine', 21 | jasmineNodeOpts: { 22 | showColors: true, 23 | defaultTimeoutInterval: 30000, 24 | print: function() {} 25 | }, 26 | onPrepare() { 27 | require('ts-node').register({ 28 | project: require('path').join(__dirname, './tsconfig.json') 29 | }); 30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 31 | } 32 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to angular-material-starter!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/angular-material-starter'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-material-starter", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve --open --port 50000", 7 | "start:prod": "npm run build:prod && npm run server", 8 | "build": "ng build", 9 | "build:prod": "ng build --prod", 10 | "test": "ng lint && ng test", 11 | "watch": "ng test --configuration=test --browsers ChromeHeadless --watch", 12 | "lint": "ng lint", 13 | "format:write": "prettier projects/**/*.{ts,json,md,scss} --write", 14 | "format:test": "prettier projects/**/*.{ts,json,md,scss} --list-different", 15 | "release": "standard-version && git push --follow-tags origin master", 16 | "analyze": "npm run build:prod -- --stats-json && webpack-bundle-analyzer ./dist/angular-ngrx-material-starter/stats-es2015.json", 17 | "e2e": "run-p --race e2e:runtests e2e:runserver", 18 | "e2e:runtests": "cypress run --reporter teamcity", 19 | "e2e:runserver": "http-server ../dist -a localhost -p 50000 -silent -c-1", 20 | "e2e: dev": "start ng serve --port 50000 && start cypress open", 21 | "hmr": "ng serve --configuration hmr --port 50000", 22 | "cypress": "concurrently \"ng serve\" \"cypress open\"", 23 | "e2e:dev": "start ng serve --port 50000 && start cypress open" 24 | }, 25 | "husky": { 26 | "hooks": { 27 | "pre-push": "pretty-quick --staged && ng lint" 28 | } 29 | }, 30 | "private": true, 31 | "dependencies": { 32 | "@angular/animations": "^8.2.14", 33 | "@angular/cdk": "~8.2.3", 34 | "@angular/common": "^8.2.14", 35 | "@angular/compiler": "^8.2.14", 36 | "@angular/core": "^8.2.14", 37 | "@angular/flex-layout": "^8.0.0-beta.27", 38 | "@angular/forms": "^8.2.14", 39 | "@angular/http": "^7.2.16", 40 | "@angular/material": "^8.2.3", 41 | "@angular/platform-browser": "^8.2.14", 42 | "@angular/platform-browser-dynamic": "^8.2.14", 43 | "@angular/platform-server": "^8.2.14", 44 | "@angular/router": "^8.2.14", 45 | "@fortawesome/angular-fontawesome": "^0.5.0", 46 | "@fortawesome/fontawesome-free": "^5.13.0", 47 | "@fortawesome/fontawesome-svg-core": "^1.2.28", 48 | "@fortawesome/free-brands-svg-icons": "^5.12.1", 49 | "@fortawesome/free-solid-svg-icons": "^5.13.0", 50 | "@markpieszak/ng-application-insights": "^8.0.1", 51 | "@ngxs/devtools-plugin": "^3.6.1", 52 | "@ngxs/form-plugin": "^3.6.2", 53 | "@ngxs/hmr-plugin": "^3.6.2", 54 | "@ngxs/logger-plugin": "^3.6.2", 55 | "@ngxs/router-plugin": "^3.6.2", 56 | "@ngxs/schematics": "0.0.1-alpha.5", 57 | "@ngxs/storage-plugin": "^3.6.2", 58 | "@ngxs/store": "^3.6.2", 59 | "@sentry/browser": "^5.15.4", 60 | "ajv": "^6.11.0", 61 | "browser-detect": "^0.2.28", 62 | "file-saver": "^2.0.2", 63 | "hammerjs": "^2.0.8", 64 | "http-server": "^0.12.1", 65 | "ngx-bar-rating": "^1.1.0", 66 | "promise-polyfill": "8.1.3", 67 | "rxjs": "~6.5.5", 68 | "subsink": "^1.0.1", 69 | "tslib": "^1.11.1", 70 | "zone.js": "~0.9.1" 71 | }, 72 | "devDependencies": { 73 | "@angular-devkit/build-angular": "~0.803.26", 74 | "@angular/cli": "~9.1.0", 75 | "@angular/compiler-cli": "^8.2.14", 76 | "@angular/language-service": "~9.0.5", 77 | "@types/jasmine": "~3.5.10", 78 | "@types/jasminewd2": "~2.0.3", 79 | "@types/node": "^13.11.0", 80 | "codelyzer": "^5.2.2", 81 | "concurrently": "^5.1.0", 82 | "cypress": "^4.0.2", 83 | "cypress": "^4.3.0", 84 | "husky": "^4.2.3", 85 | "jasmine-core": "~3.5.0", 86 | "jasmine-spec-reporter": "~5.0.1", 87 | "karma": "~4.4.1", 88 | "karma-chrome-launcher": "~3.1.0", 89 | "karma-coverage-istanbul-reporter": "~2.1.1", 90 | "karma-jasmine": "~3.1.1", 91 | "karma-jasmine-html-reporter": "^1.5.3", 92 | "npm-run-all": "^4.1.5", 93 | "prettier": "^2.0.2", 94 | "protractor": "~5.4.3", 95 | "ts-node": "~8.8.1", 96 | "tslint": "~5.20.1", 97 | "tslint-teamcity-reporter": "^3.2.2", 98 | "typescript": "^3.5.3" 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule, PreloadAllModules } from '@angular/router'; 3 | 4 | 5 | const routes: Routes = [ 6 | { 7 | path: '', 8 | redirectTo: 'about', 9 | pathMatch: 'full' 10 | }, 11 | // { 12 | // path: 'about', 13 | // loadChildren: () => 14 | // import('./features/about/about.module').then(m => m.AboutModule) 15 | // }, 16 | // { 17 | // path: '**', 18 | // redirectTo: 'about' 19 | // } 20 | ]; 21 | 22 | @NgModule({ 23 | // useHash supports github.io demo page, remove in your app 24 | imports: [ 25 | RouterModule.forRoot(routes, { 26 | // useHash: true, 27 | scrollPositionRestoration: 'enabled', 28 | preloadingStrategy: PreloadAllModules 29 | }) 30 | ], 31 | exports: [RouterModule] 32 | }) 33 | export class AppRoutingModule { } 34 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | .mat-app-background { 2 | height: 100%; 3 | width: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/app.component.scss-theme.scss: -------------------------------------------------------------------------------- 1 | @import '~@angular/material/theming'; 2 | 3 | @mixin app-component-theme($theme) { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /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 | import { NavbarComponent } from '@core/components/navbar/navbar.component'; 5 | import { ContentWrapperComponent } from './core/components/content-wrapper/content-wrapper.component'; 6 | import { SharedModule } from '@shared/shared.module'; 7 | import { SidenavComponent } from './core/components/sidenav/sidenav.component'; 8 | import { FooterComponent } from './core/components/footer/footer.component'; 9 | import { PlTableComponent } from './core/components/pl-table/pl-table.component'; 10 | import { AppInsightsService } from '@markpieszak/ng-application-insights'; 11 | import { Store, NgxsModule } from '@ngxs/store'; 12 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 13 | import { HttpClientTestingModule } from '@angular/common/http/testing'; 14 | 15 | describe('AppComponent', () => { 16 | beforeEach(async(() => { 17 | TestBed.configureTestingModule({ 18 | imports: [ 19 | RouterTestingModule, 20 | SharedModule, 21 | NgxsModule.forRoot(), 22 | NoopAnimationsModule, 23 | HttpClientTestingModule 24 | ], 25 | declarations: [ 26 | AppComponent, 27 | NavbarComponent, 28 | SidenavComponent, 29 | ContentWrapperComponent, 30 | FooterComponent, 31 | PlTableComponent 32 | ], 33 | providers: [ 34 | AppInsightsService, 35 | Store, 36 | ] 37 | }).compileComponents(); 38 | })); 39 | 40 | it('should create the app', () => { 41 | const fixture = TestBed.createComponent(AppComponent); 42 | const app = fixture.debugElement.componentInstance; 43 | expect(app).toBeTruthy(); 44 | }); 45 | 46 | // it(`should have as title 'angular-material-starter'`, () => { 47 | // const fixture = TestBed.createComponent(AppComponent); 48 | // const app = fixture.debugElement.componentInstance; 49 | // expect(app.title).toEqual('angular-material-starter'); 50 | // }); 51 | 52 | // it('should render title in a h1 tag', () => { 53 | // const fixture = TestBed.createComponent(AppComponent); 54 | // fixture.detectChanges(); 55 | // const compiled = fixture.debugElement.nativeElement; 56 | // expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular-material-starter!'); 57 | // }); 58 | }); 59 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import browser from 'browser-detect'; 2 | import { Component, OnInit, OnDestroy } from '@angular/core'; 3 | 4 | // rxjs 5 | import { Observable } from 'rxjs'; 6 | import { SubSink } from 'subsink'; 7 | 8 | // ngxs 9 | import { Store, Select } from '@ngxs/store'; 10 | import { Navigate } from '@ngxs/router-plugin'; 11 | 12 | import { environment as env } from '@env'; 13 | import { AppInsightsService } from '@markpieszak/ng-application-insights'; 14 | import { SettingsState, SettingsStateModel } from './core/states/settings.state'; 15 | import { SidenavService } from './core/services/sidenav.service'; 16 | import { ChangeThemeAction } from './core/actions/settings.action'; 17 | import { IconService } from './core/services/icon.service'; 18 | 19 | // import { SidenavService } from '@core/services'; 20 | 21 | // states and actions 22 | 23 | // icons 24 | // 25 | 26 | @Component({ 27 | selector: 'app-root', 28 | templateUrl: './app.component.html', 29 | styleUrls: ['./app.component.scss'] 30 | }) 31 | export class AppComponent implements OnInit, OnDestroy { 32 | isProd = env.production; 33 | year = new Date().getFullYear(); 34 | // version = env.versions.app; 35 | 36 | languages = ['en', 'no']; 37 | 38 | navigation = [ 39 | { link: 'about', label: 'About' }, 40 | // { link: 'feature-list', label: 'News' }, 41 | // { link: 'examples', label: 'Forum' } 42 | ]; 43 | 44 | navigationSideMenu = [ 45 | ...this.navigation, 46 | { link: 'settings', label: 'Settings' } 47 | ]; 48 | 49 | isAuthenticated$: Observable; 50 | 51 | theme$: Observable = this.store.select(state => state.settings.selectedTheme); 52 | @Select(SettingsState.getEffectiveTheme) selectedTheme$: Observable; 53 | 54 | private subs = new SubSink(); 55 | 56 | title = 'angular-material-starter'; 57 | 58 | constructor( 59 | private appInsight: AppInsightsService, 60 | private sidenavService: SidenavService, 61 | private store: Store, 62 | private iconService: IconService 63 | ) {} 64 | 65 | private static isIEorEdgeOrSafari() { 66 | return ['ie', 'edge', 'safari'].includes(browser().name); 67 | } 68 | 69 | ngOnInit(): void { 70 | this.iconService.init(); 71 | 72 | this.selectedTheme$.subscribe(console.log); 73 | 74 | this.store.dispatch(new ChangeThemeAction('app-dark-theme')); 75 | } 76 | 77 | // onLoginClick() { 78 | // this.store.dispatch(authLogin()); 79 | // } 80 | 81 | // onLogoutClick() { 82 | // this.store.dispatch(authLogout()); 83 | // } 84 | 85 | ngOnDestroy(): void { 86 | this.subs.unsubscribe(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule, LOCALE_ID, CUSTOM_ELEMENTS_SCHEMA, APP_INITIALIZER, ErrorHandler, Injectable } from '@angular/core'; 3 | 4 | import localeNb from '@angular/common/locales/nb'; 5 | import { registerLocaleData } from '@angular/common'; 6 | 7 | import * as Sentry from '@sentry/browser'; 8 | 9 | // modules 10 | import { CoreModule } from '@core/core.module'; 11 | import { SharedModule } from '@shared/shared.module'; 12 | import { MaterialModule } from '@shared/material.module'; 13 | 14 | // states 15 | // import { UserState } from '@core/states/user.state'; 16 | 17 | import { AppRoutingModule } from './app-routing.module'; 18 | import { AppComponent } from './app.component'; 19 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 20 | 21 | import { HomeModule } from './features/home/home.module'; 22 | import { AboutModule } from './features/about/about.module'; 23 | import { ProfileModule } from './features/profile/profile.module'; 24 | 25 | // import { SidenavService } from '@core/services/sidenav.service'; 26 | 27 | import { ConfigService } from '@app/config.service'; 28 | import { SettingsModule } from './features/settings/settings.module'; 29 | 30 | export function initializeApp(appInitService: ConfigService) { 31 | return (): Promise => { 32 | return appInitService.Init(); 33 | } 34 | } 35 | 36 | 37 | registerLocaleData(localeNb); 38 | 39 | Sentry.init({ 40 | dsn: 'https://ec12a75c643b47a6b5a881cec08c374d@sentry.io/1889115' 41 | }); 42 | 43 | @Injectable() 44 | export class SentryErrorHandler implements ErrorHandler { 45 | constructor() {} 46 | handleError(error) { 47 | const eventId = Sentry.captureException(error.originalError || error); 48 | Sentry.showReportDialog({ eventId }); 49 | } 50 | } 51 | 52 | @NgModule({ 53 | declarations: [ 54 | AppComponent 55 | ], 56 | imports: [ 57 | // core & shared 58 | CoreModule, 59 | SharedModule, 60 | 61 | // hot-loaded features 62 | HomeModule, 63 | AboutModule, 64 | ProfileModule, 65 | SettingsModule, 66 | 67 | // angular 68 | BrowserModule, 69 | BrowserAnimationsModule, 70 | 71 | // app 72 | AppRoutingModule, 73 | ], 74 | providers: [ 75 | ConfigService, 76 | { 77 | provide: APP_INITIALIZER, 78 | useFactory: initializeApp, 79 | deps: [ConfigService], 80 | multi: true 81 | }, 82 | { provide: LOCALE_ID, useValue: 'nb' }, 83 | // { provide: ErrorHandler, useClass: SentryErrorHandler } 84 | ], 85 | bootstrap: [AppComponent], 86 | schemas: [CUSTOM_ELEMENTS_SCHEMA] 87 | }) 88 | export class AppModule { } 89 | -------------------------------------------------------------------------------- /src/app/config.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | 5 | export class ConfigService { 6 | constructor() { } 7 | 8 | Init() { 9 | return new Promise((resolve, reject) => { 10 | console.log('AppInitService.init() called'); 11 | // do your initialisation stuff here 12 | setTimeout(() => { 13 | console.log('AppInitService Finished'); 14 | resolve(); 15 | }, 500); 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/app/core/actions/auth.actions.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/core/actions/auth.actions.ts -------------------------------------------------------------------------------- /src/app/core/actions/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/core/actions/index.ts -------------------------------------------------------------------------------- /src/app/core/actions/settings.action.ts: -------------------------------------------------------------------------------- 1 | export class ChangeThemeAction { 2 | public static readonly type = '[Settings] Change theme'; 3 | constructor(public changeTheme: string) { } 4 | } 5 | 6 | export class ChangeAutoNightMode { 7 | public static readonly type = '[Settings] Change Auto Night Mode'; 8 | constructor(public changeTheme: string) {} 9 | } 10 | -------------------------------------------------------------------------------- /src/app/core/animations/animation.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AnimationService } from './animation.service'; 4 | 5 | describe('AnimationService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: AnimationService = TestBed.get(AnimationService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/core/animations/animation.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class AnimationService { 7 | 8 | constructor() { } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/core/animations/route.animations.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/core/animations/route.animations.ts -------------------------------------------------------------------------------- /src/app/core/auth/auth-guard.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthGuardService } from './auth-guard.service'; 4 | 5 | describe('AuthGuardService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: AuthGuardService = TestBed.get(AuthGuardService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/core/auth/auth-guard.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class AuthGuardService { 7 | 8 | constructor() { } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/core/auth/auth.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | 5 | 6 | @NgModule({ 7 | declarations: [], 8 | imports: [ 9 | CommonModule 10 | ] 11 | }) 12 | export class AuthModule { } 13 | -------------------------------------------------------------------------------- /src/app/core/components/content-wrapper/content-wrapper.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 | 7 | 8 | 9 |
10 | -------------------------------------------------------------------------------- /src/app/core/components/content-wrapper/content-wrapper.component.scss: -------------------------------------------------------------------------------- 1 | .container { 2 | display: grid; 3 | grid-template-columns: auto 1fr auto; 4 | grid-column-gap: .5rem; 5 | margin: 0 .5rem; 6 | 7 | .left-content { 8 | min-width: 14rem; 9 | } 10 | 11 | .mid-content { 12 | // flex: 1 0 auto; 13 | margin-top: 64px; 14 | overflow: hidden; 15 | height: 100%; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/app/core/components/content-wrapper/content-wrapper.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { ContentWrapperComponent } from './content-wrapper.component'; 3 | import { PlTableComponent } from '../pl-table/pl-table.component'; 4 | import { SharedModule } from '@shared/shared.module'; 5 | import { HttpClientTestingModule } from '@angular/common/http/testing'; 6 | 7 | describe('ContentWrapperComponent', () => { 8 | let component: ContentWrapperComponent; 9 | let fixture: ComponentFixture; 10 | 11 | beforeEach(async(() => { 12 | TestBed.configureTestingModule({ 13 | declarations: [ ContentWrapperComponent, PlTableComponent ], 14 | imports: [ SharedModule, HttpClientTestingModule ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(ContentWrapperComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/app/core/components/content-wrapper/content-wrapper.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-content-wrapper', 5 | templateUrl: './content-wrapper.component.html', 6 | styleUrls: ['./content-wrapper.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class ContentWrapperComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/core/components/footer/footer.component.html: -------------------------------------------------------------------------------- 1 | 44 | -------------------------------------------------------------------------------- /src/app/core/components/footer/footer.component.scss: -------------------------------------------------------------------------------- 1 | .footer { 2 | flex: 0 0 auto; 3 | padding: 0 15px; 4 | text-align: center; 5 | } 6 | -------------------------------------------------------------------------------- /src/app/core/components/footer/footer.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { SharedModule } from '@shared/shared.module'; 3 | import { FooterComponent } from './footer.component'; 4 | 5 | describe('FooterComponent', () => { 6 | let component: FooterComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ FooterComponent ], 12 | imports: [ SharedModule ] 13 | }) 14 | .compileComponents(); 15 | })); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(FooterComponent); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/app/core/components/footer/footer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-footer', 5 | templateUrl: './footer.component.html', 6 | styleUrls: ['./footer.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class FooterComponent implements OnInit { 10 | 11 | today: number = Date.now(); 12 | 13 | constructor() { } 14 | 15 | ngOnInit() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/app/core/components/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | 35 |
36 | 37 |
38 | 39 | 47 | 48 | 49 | 50 | 51 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 |
64 | -------------------------------------------------------------------------------- /src/app/core/components/navbar/navbar.component.scss: -------------------------------------------------------------------------------- 1 | @import '../../../../styles/variables'; 2 | 3 | // .toolbar { 4 | // position: fixed; 5 | // width: 100%; 6 | // display: flex; 7 | // z-index: 10; 8 | 9 | // fa-icon { 10 | // font-size: 24px; 11 | // } 12 | // } 13 | 14 | .main-header { 15 | display: flex; 16 | justify-content: space-between; 17 | 18 | &__content-left { 19 | display: flex; 20 | align-items: center; 21 | } 22 | 23 | &__content-mid { 24 | font-size: 1.25rem; 25 | } 26 | 27 | border-bottom: solid 1px rgba(0,0,0,.12); 28 | } 29 | -------------------------------------------------------------------------------- /src/app/core/components/navbar/navbar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { SharedModule } from '@shared/shared.module'; 3 | import { NavbarComponent } from './navbar.component'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | 6 | describe('NavbarComponent', () => { 7 | let component: NavbarComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ NavbarComponent ], 13 | imports: [ SharedModule, RouterTestingModule ] 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(NavbarComponent); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/core/components/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy, Input, ViewChild } from '@angular/core'; 2 | import { SidenavService } from '@app/core/services/sidenav.service'; 3 | import { Observable } from 'rxjs'; 4 | 5 | 6 | @Component({ 7 | selector: 'app-navbar', 8 | templateUrl: './navbar.component.html', 9 | styleUrls: ['./navbar.component.scss'], 10 | changeDetection: ChangeDetectionStrategy.OnPush 11 | }) 12 | export class NavbarComponent implements OnInit { 13 | @Input() public isActivated: boolean; 14 | 15 | stickyHeader$: Observable; 16 | 17 | constructor( 18 | private sidenavService: SidenavService, 19 | // private userService: UserService 20 | ) { } 21 | 22 | ngOnInit() { 23 | // this.userService.currentUser.subscribe( 24 | // (userData) => { 25 | // this.currentUser = userData; 26 | // } 27 | // ); 28 | } 29 | 30 | toggleSideMenu(): void { 31 | this.sidenavService.toggleSideMenu(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/app/core/components/notifications/notifications.component.html: -------------------------------------------------------------------------------- 1 |

notifications works!

2 | -------------------------------------------------------------------------------- /src/app/core/components/notifications/notifications.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/core/components/notifications/notifications.component.scss -------------------------------------------------------------------------------- /src/app/core/components/notifications/notifications.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NotificationsComponent } from './notifications.component'; 4 | 5 | describe('NotificationsComponent', () => { 6 | let component: NotificationsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ NotificationsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NotificationsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/core/components/notifications/notifications.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-notifications', 5 | templateUrl: './notifications.component.html', 6 | styleUrls: ['./notifications.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class NotificationsComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/core/components/page-not-found/page-not-found.component.html: -------------------------------------------------------------------------------- 1 |

page-not-found works!

2 | -------------------------------------------------------------------------------- /src/app/core/components/page-not-found/page-not-found.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/core/components/page-not-found/page-not-found.component.scss -------------------------------------------------------------------------------- /src/app/core/components/page-not-found/page-not-found.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { PageNotFoundComponent } from './page-not-found.component'; 4 | 5 | describe('PageNotFoundComponent', () => { 6 | let component: PageNotFoundComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ PageNotFoundComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(PageNotFoundComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/core/components/page-not-found/page-not-found.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-page-not-found', 5 | templateUrl: './page-not-found.component.html', 6 | styleUrls: ['./page-not-found.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class PageNotFoundComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/core/components/pl-table/pl-table.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Neste premier league match

3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 29 | 30 |
No.TeamPlayedPtsWinsDrawsLosesGFGA
31 |
32 | -------------------------------------------------------------------------------- /src/app/core/components/pl-table/pl-table.component.scss: -------------------------------------------------------------------------------- 1 | .sticky-card { 2 | position: sticky; 3 | top: 2rem; 4 | margin-top: 67px; 5 | 6 | h4 { 7 | text-transform: uppercase; 8 | } 9 | 10 | #standings-title { 11 | display: flex; 12 | align-items: center; 13 | font-weight: bold; 14 | } 15 | 16 | .efl-picture { 17 | // content: url("/assets/images/efl-logo.svg"); 18 | width: 60px; 19 | height: 60px; 20 | } 21 | 22 | .first-place { 23 | background: rgba(84, 167, 89, 0.8); 24 | } 25 | 26 | .second-place { 27 | background: rgba(84, 167, 89, 0.6); 28 | } 29 | 30 | .third-place { 31 | background: rgba(84, 167, 89, 0.4); 32 | } 33 | 34 | .relegation-place { 35 | background: rgba(212, 111, 106, 0.6); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/app/core/components/pl-table/pl-table.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { SharedModule } from '@shared/shared.module'; 3 | import { PlTableComponent } from './pl-table.component'; 4 | import { HttpClientTestingModule } from '@angular/common/http/testing'; 5 | 6 | describe('PlTableComponent', () => { 7 | let component: PlTableComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ PlTableComponent ], 13 | imports: [ SharedModule, HttpClientTestingModule ] 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(PlTableComponent); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/core/components/pl-table/pl-table.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | import { StandingsService } from '../../services/standings.service'; 3 | 4 | import { MatTableDataSource, MatSort } from '@angular/material'; 5 | import { Observable } from 'rxjs'; 6 | import { map } from 'rxjs/operators'; 7 | 8 | interface PLTableResultItem { 9 | leaguePosition: number; 10 | teamName: string; 11 | numGames: number; 12 | points: number; 13 | } 14 | 15 | @Component({ 16 | selector: 'app-pl-table', 17 | templateUrl: './pl-table.component.html', 18 | styleUrls: ['./pl-table.component.scss'], 19 | changeDetection: ChangeDetectionStrategy.OnPush 20 | }) 21 | export class PlTableComponent implements OnInit { 22 | 23 | teams$: Observable; 24 | 25 | constructor(private standingsService: StandingsService) { } 26 | 27 | ngOnInit() { 28 | this.standingsService.getStandings() 29 | // .pipe(map(r => r.participants)) 30 | .subscribe(console.log); 31 | } 32 | 33 | setRowColor (position): String { 34 | 35 | switch (position) { 36 | 37 | case '1': { 38 | return 'first-place'; 39 | } 40 | 41 | case '2': { 42 | return 'second-place'; 43 | } 44 | 45 | case '3': { 46 | return 'third-place'; 47 | } 48 | 49 | case '22': 50 | case '23': 51 | case '24': { 52 | return 'relegation-place'; 53 | } 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/app/core/components/sidenav/sidenav.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 10 | {{item.label}} 11 | 12 | 13 |
14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /src/app/core/components/sidenav/sidenav.component.scss: -------------------------------------------------------------------------------- 1 | .sidenav-container { 2 | // height: 100%; 3 | // width: 100%; 4 | 5 | position: absolute; 6 | top: 4rem; 7 | left: 0; 8 | right: 0; 9 | bottom: 0; 10 | // display: flex; 11 | // flex-direction: column; 12 | } 13 | 14 | .sidenav { 15 | border-right: 1px solid #000; 16 | } 17 | -------------------------------------------------------------------------------- /src/app/core/components/sidenav/sidenav.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { SidenavComponent } from './sidenav.component'; 3 | import { SharedModule } from '@app/shared/shared.module'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 6 | 7 | describe('SidenavComponent', () => { 8 | let component: SidenavComponent; 9 | let fixture: ComponentFixture; 10 | 11 | beforeEach(async(() => { 12 | TestBed.configureTestingModule({ 13 | declarations: [ SidenavComponent ], 14 | imports: [ SharedModule, RouterTestingModule, NoopAnimationsModule ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(SidenavComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/app/core/components/sidenav/sidenav.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy, ViewChild } from '@angular/core'; 2 | import { MatSidenav } from '@angular/material'; 3 | import { SidenavService } from '@app/core/services/sidenav.service'; 4 | import { Observable } from 'rxjs'; 5 | 6 | @Component({ 7 | selector: 'app-sidenav', 8 | templateUrl: './sidenav.component.html', 9 | styleUrls: ['./sidenav.component.scss'], 10 | changeDetection: ChangeDetectionStrategy.OnPush 11 | }) 12 | export class SidenavComponent implements OnInit { 13 | 14 | navigation = [ 15 | { link: 'about', label: 'About' }, 16 | // { link: 'feature-list', label: 'News' }, 17 | // { link: 'examples', label: 'Forum' } 18 | ]; 19 | 20 | navigationSideMenu = [ 21 | ...this.navigation, 22 | { link: 'settings', label: 'Settings' } 23 | ]; 24 | 25 | stickyHeader$: Observable; 26 | 27 | theme$: Observable; 28 | 29 | @ViewChild('sidemenu', { static: false }) sideMenu: MatSidenav; 30 | 31 | constructor(private sidenavService: SidenavService) { } 32 | 33 | ngOnInit(): void { 34 | this.sidenavService.setSideMenu(this.sideMenu); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/app/core/configuration/route-state.serializer.ts: -------------------------------------------------------------------------------- 1 | import { Params, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'; 2 | import { RouterStateSerializer } from '@ngxs/router-plugin'; 3 | 4 | export interface RouterStateParams { 5 | url: string; 6 | params: Params; 7 | queryParams: Params; 8 | } 9 | 10 | // Make the router snapshot to { url, params, queryParams } 11 | export class CustomRouterStateSerializer implements RouterStateSerializer { 12 | serialize(routerState: RouterStateSnapshot): RouterStateParams { 13 | const { 14 | url, 15 | root: { queryParams } 16 | } = routerState; 17 | 18 | let { root: route } = routerState; 19 | let params = route.params; 20 | 21 | while (route.firstChild) { 22 | route = route.firstChild; 23 | params = { ...params, ...route.params }; 24 | } 25 | 26 | return { url, params, queryParams }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/app/core/contants/root-paths.ts: -------------------------------------------------------------------------------- 1 | export const rootPaths = { 2 | settings: 'settings', 3 | about: 'about' 4 | } 5 | -------------------------------------------------------------------------------- /src/app/core/core.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { ContentWrapperComponent } from './components/content-wrapper/content-wrapper.component'; 4 | import { NavbarComponent } from './components/navbar/navbar.component'; 5 | import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component'; 6 | import { SidenavComponent } from './components/sidenav/sidenav.component'; 7 | import { PlTableComponent } from './components/pl-table/pl-table.component'; 8 | 9 | import { RouterModule } from '@angular/router'; 10 | 11 | // state management 12 | import { NgxsModule, StateContext } from '@ngxs/store'; 13 | import { NgxsRouterPluginModule, RouterStateSerializer } from '@ngxs/router-plugin'; 14 | import { NgxsReduxDevtoolsPluginModule } from '@ngxs/devtools-plugin'; 15 | import { NgxsStoragePluginModule, StorageOption } from '@ngxs/storage-plugin'; 16 | import { NgxsFormPluginModule } from '@ngxs/form-plugin'; 17 | 18 | import { environment } from '@env'; 19 | 20 | import { MaterialModule } from '@shared/material.module'; 21 | import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; 22 | 23 | import { AuthModule } from './auth/auth.module'; 24 | 25 | import { ApplicationInsightsModule, AppInsightsService } from '@markpieszak/ng-application-insights'; 26 | import { NotificationsComponent } from './components/notifications/notifications.component'; 27 | 28 | // states 29 | import { SettingsState } from './states/settings.state'; 30 | import { FooterComponent } from './components/footer/footer.component'; 31 | import { HttpClientModule } from '@angular/common/http'; 32 | 33 | 34 | @NgModule({ 35 | declarations: [ 36 | ContentWrapperComponent, 37 | NavbarComponent, 38 | PageNotFoundComponent, 39 | SidenavComponent, 40 | PlTableComponent, 41 | NotificationsComponent, 42 | FooterComponent, 43 | ], 44 | imports: [ 45 | CommonModule, 46 | 47 | MaterialModule, 48 | FontAwesomeModule, 49 | 50 | RouterModule, 51 | HttpClientModule, 52 | 53 | AuthModule, 54 | // store 55 | NgxsModule.forRoot([ 56 | SettingsState 57 | ], 58 | { developmentMode: !environment.production } 59 | ), 60 | NgxsFormPluginModule.forRoot(), 61 | NgxsRouterPluginModule.forRoot(), 62 | NgxsReduxDevtoolsPluginModule.forRoot(), 63 | NgxsStoragePluginModule.forRoot(), 64 | 65 | ApplicationInsightsModule.forRoot({ instrumentationKeySetLater: true }), 66 | ], 67 | providers: [ 68 | AppInsightsService, 69 | ], 70 | exports: [ 71 | NavbarComponent, 72 | SidenavComponent, 73 | ContentWrapperComponent 74 | ] 75 | }) 76 | export class CoreModule { } 77 | -------------------------------------------------------------------------------- /src/app/core/http-interceptors/http-error.interceptor.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Injector, ErrorHandler } from '@angular/core'; 2 | import { 3 | HttpEvent, 4 | HttpInterceptor, 5 | HttpHandler, 6 | HttpRequest, 7 | HttpErrorResponse 8 | } from '@angular/common/http'; 9 | import { Observable } from 'rxjs'; 10 | import { tap } from 'rxjs/operators'; 11 | 12 | /** Passes HttpErrorResponse to application-wide error handler */ 13 | @Injectable() 14 | export class HttpErrorInterceptor implements HttpInterceptor { 15 | constructor(private injector: Injector) {} 16 | 17 | intercept( 18 | request: HttpRequest, 19 | next: HttpHandler 20 | ): Observable> { 21 | return next.handle(request).pipe( 22 | tap({ 23 | error: (err: any) => { 24 | if (err instanceof HttpErrorResponse) { 25 | const appErrorHandler = this.injector.get(ErrorHandler); 26 | appErrorHandler.handleError(err); 27 | } 28 | } 29 | }) 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/app/core/http-interceptors/http-token.interceptor.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/core/http-interceptors/http-token.interceptor.ts -------------------------------------------------------------------------------- /src/app/core/models/article.ts: -------------------------------------------------------------------------------- 1 | export class Article { 2 | id: number; 3 | title: string; 4 | description: string; 5 | body: string; 6 | tagList: string[]; 7 | createdAt: string; 8 | updatedAt: string; 9 | favorited: boolean; 10 | favoritesCount: number; 11 | } 12 | -------------------------------------------------------------------------------- /src/app/core/models/error.model.ts: -------------------------------------------------------------------------------- 1 | export interface Errors { 2 | errors: {[key: string]: string}; 3 | } 4 | -------------------------------------------------------------------------------- /src/app/core/module-import.guard.ts: -------------------------------------------------------------------------------- 1 | export function throwIfAlreadyLoaded(parentModule: any, moduleName: string) { 2 | if (parentModule) { 3 | throw new Error(`${moduleName} has already been loaded. Import ${moduleName} modules in the AppModule only.`); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/app/core/services/authentication.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthenticationService } from './authentication.service'; 4 | 5 | describe('AuthenticationService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: AuthenticationService = TestBed.get(AuthenticationService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/core/services/authentication.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class AuthenticationService { 7 | 8 | constructor() { } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/core/services/icon.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { IconService } from './icon.service'; 4 | 5 | describe('IconService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: IconService = TestBed.get(IconService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/core/services/icon.service.ts: -------------------------------------------------------------------------------- 1 | import { DomSanitizer } from '@angular/platform-browser'; 2 | import { Injectable } from '@angular/core'; 3 | import { MatIconRegistry } from '@angular/material/icon'; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | export class IconService { 9 | 10 | constructor( 11 | private matIconRegistry: MatIconRegistry, 12 | private domSanitizer: DomSanitizer 13 | ) { } 14 | 15 | init(): void { 16 | this.matIconRegistry.addSvgIcon('avfc_logo', this.domSanitizer.bypassSecurityTrustResourceUrl('../../assets/icons/aston-villa-logo.svg')); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/app/core/services/local-storage.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { LocalStorageService } from './local-storage.service'; 4 | 5 | describe('LocalStorageService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: LocalStorageService = TestBed.get(LocalStorageService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/core/services/local-storage.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class LocalStorageService { 7 | 8 | constructor() { } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/core/services/logger.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple logger system with the possibility of registering custom outputs. 3 | * 4 | * 4 different log levels are provided, with corresponding methods: 5 | * - debug : for debug information 6 | * - info : for informative status of the application (success, ...) 7 | * - warning : for non-critical errors that do not prevent normal application behavior 8 | * - error : for critical errors that prevent normal application behavior 9 | * 10 | * Example usage: 11 | * ``` 12 | * import { Logger } from 'app/core/logger.service'; 13 | * 14 | * const log = new Logger('myFile'); 15 | * ... 16 | * log.debug('something happened'); 17 | * ``` 18 | * 19 | * To disable debug and info logs in production, add this snippet to your root component: 20 | * ``` 21 | * export class AppComponent implements OnInit { 22 | * ngOnInit() { 23 | * if (environment.production) { 24 | * Logger.enableProductionMode(); 25 | * } 26 | * ... 27 | * } 28 | * } 29 | * 30 | * If you want to process logs through other outputs than console, you can add LogOutput functions to Logger.outputs. 31 | */ 32 | 33 | /** 34 | * The possible log levels. 35 | * LogLevel.Off is never emitted and only used with Logger.level property to disable logs. 36 | */ 37 | export enum LogLevel { 38 | Off = 0, 39 | Error, 40 | Warning, 41 | Info, 42 | Debug 43 | } 44 | 45 | /** 46 | * Log output handler function. 47 | */ 48 | export type LogOutput = (source: string, level: LogLevel, ...objects: any[]) => void; 49 | 50 | export class Logger { 51 | 52 | /** 53 | * Current logging level. 54 | * Set it to LogLevel.Off to disable logs completely. 55 | */ 56 | static level = LogLevel.Debug; 57 | 58 | /** 59 | * Additional log outputs. 60 | */ 61 | static outputs: LogOutput[] = []; 62 | 63 | /** 64 | * Enables production mode. 65 | * Sets logging level to LogLevel.Warning. 66 | */ 67 | static enableProductionMode() { 68 | Logger.level = LogLevel.Warning; 69 | } 70 | 71 | constructor( 72 | private source?: string 73 | ) {} 74 | 75 | /** 76 | * Logs messages or objects with the debug level. 77 | * Works the same as console.log(). 78 | */ 79 | debug(...objects: any[]) { 80 | this.log(console.log, LogLevel.Debug, objects); 81 | } 82 | 83 | /** 84 | * Logs messages or objects with the info level. 85 | * Works the same as console.log(). 86 | */ 87 | info(...objects: any[]) { 88 | this.log(console.info, LogLevel.Info, objects); 89 | } 90 | 91 | /** 92 | * Logs messages or objects with the warning level. 93 | * Works the same as console.log(). 94 | */ 95 | warn(...objects: any[]) { 96 | this.log(console.warn, LogLevel.Warning, objects); 97 | } 98 | 99 | /** 100 | * Logs messages or objects with the error level. 101 | * Works the same as console.log(). 102 | */ 103 | error(...objects: any[]) { 104 | this.log(console.error, LogLevel.Error, objects); 105 | } 106 | 107 | private log(func: Function, level: LogLevel, objects: any[]) { 108 | if (level <= Logger.level) { 109 | const log = this.source ? ['[' + this.source + ']'].concat(objects) : objects; 110 | func.apply(console, log); 111 | Logger.outputs.forEach((output) => 112 | output.apply(output, [this.source, level].concat(objects))); 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/app/core/services/sidenav.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { SharedModule } from '@shared/shared.module'; 3 | import { SidenavService } from './sidenav.service'; 4 | 5 | describe('SidenavService', () => { 6 | 7 | 8 | beforeEach(async(() => { 9 | TestBed.configureTestingModule({ 10 | imports: [ SharedModule ] 11 | }) 12 | .compileComponents(); 13 | })); 14 | 15 | it('should be created', () => { 16 | const service: SidenavService = TestBed.get(SidenavService); 17 | expect(service).toBeTruthy(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /src/app/core/services/sidenav.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { MatSidenav } from '@angular/material/sidenav'; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class SidenavService { 8 | private sideMenu: MatSidenav; 9 | 10 | public setSideMenu(sidenav: MatSidenav) { 11 | this.sideMenu = sidenav; 12 | } 13 | 14 | public toggleSideMenu(): void { 15 | if (!this.sideMenu) { 16 | return; 17 | } 18 | this.sideMenu.toggle(); 19 | } 20 | 21 | public openSideMenu(): void { 22 | if (!this.sideMenu) { 23 | return; 24 | } 25 | this.sideMenu.open(); 26 | } 27 | 28 | public closeSideMenu(): void { 29 | this.sideMenu.close(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/app/core/services/standings.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { HttpClientTestingModule } from '@angular/common/http/testing'; 3 | import { StandingsService } from './standings.service'; 4 | 5 | describe('StandingsService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({ 7 | imports: [ HttpClientTestingModule ] 8 | })); 9 | 10 | it('should be created', () => { 11 | const service: StandingsService = TestBed.get(StandingsService); 12 | expect(service).toBeTruthy(); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /src/app/core/services/standings.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { shareReplay } from 'rxjs/operators'; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class StandingsService { 10 | 11 | constructor(private http: HttpClient) { } 12 | 13 | getStandings(): Observable { 14 | return this.http.get(`https://vglive.no/api/vg/tournaments/seasons/1941/standings?type=live-changes`) 15 | .pipe(shareReplay(1)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/app/core/states/settings.state.ts: -------------------------------------------------------------------------------- 1 | import { State, Action, Selector, StateContext } from '@ngxs/store'; 2 | import { ChangeThemeAction, ChangeAutoNightMode } from '../actions/settings.action'; 3 | import { OverlayContainer } from '@angular/cdk/overlay'; 4 | 5 | export interface SettingsStateModel { 6 | selectedTheme: string; 7 | } 8 | 9 | @State({ 10 | name: 'settings', 11 | defaults: { 12 | selectedTheme: 'hello world' 13 | } 14 | }) 15 | export class SettingsState { 16 | constructor(private overlayContainer: OverlayContainer) {} 17 | 18 | @Selector() 19 | public static getState(state: SettingsStateModel) { 20 | return state; 21 | } 22 | 23 | @Selector() 24 | public static getEffectiveTheme(state: SettingsStateModel) { 25 | return state.selectedTheme; 26 | } 27 | 28 | @Action(ChangeAutoNightMode) 29 | public changeAutoNightMode({patchState}: StateContext) { 30 | 31 | } 32 | 33 | @Action(ChangeThemeAction) 34 | public changeTheme({ patchState }: StateContext, action: ChangeThemeAction) { 35 | const classList = this.overlayContainer.getContainerElement() 36 | .classList; 37 | 38 | const toRemove = Array.from(classList).filter((item: string) => item.includes('-theme')); 39 | 40 | if (toRemove.length) { 41 | classList.remove(...toRemove); 42 | } 43 | classList.add(action.changeTheme); 44 | 45 | patchState({ 46 | selectedTheme: action.changeTheme 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/app/features/about/about-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | import { AboutComponent } from './about.component'; 5 | 6 | const routes: Routes = [ 7 | { 8 | path: 'about', 9 | component: AboutComponent 10 | }, 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forChild(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class AboutRoutingModule { } 18 | -------------------------------------------------------------------------------- /src/app/features/about/about.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Change About Me Section

3 | 4 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /src/app/features/about/about.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/about/about.component.scss -------------------------------------------------------------------------------- /src/app/features/about/about.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { SharedModule } from '@shared/shared.module'; 3 | import { AboutComponent } from './about.component'; 4 | 5 | describe('AboutComponent', () => { 6 | let component: AboutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ AboutComponent ], 12 | imports: [ SharedModule ] 13 | }) 14 | .compileComponents(); 15 | })); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(AboutComponent); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/app/features/about/about.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy, ViewChild, ElementRef, AfterViewInit } from '@angular/core'; 2 | import { Validators, FormBuilder, FormGroup, FormControl } from '@angular/forms'; 3 | import { Observable } from 'rxjs'; 4 | import { filter } from 'rxjs/operators'; 5 | 6 | @Component({ 7 | selector: 'app-about', 8 | templateUrl: './about.component.html', 9 | styleUrls: ['./about.component.scss'], 10 | changeDetection: ChangeDetectionStrategy.OnPush 11 | }) 12 | export class AboutComponent implements OnInit, AfterViewInit { 13 | 14 | aboutForm: FormGroup; 15 | formValueChanged$: Observable; 16 | 17 | @ViewChild('usernameControl', { static: false }) private usernameControl: ElementRef; 18 | 19 | constructor(private formBuilder: FormBuilder) { } 20 | 21 | ngOnInit(): void { 22 | this.buildForm(); 23 | 24 | this.formValueChanged$ = this.aboutForm.valueChanges.pipe( 25 | filter(aboutForm => aboutForm.autoSave) 26 | ); 27 | } 28 | 29 | ngAfterViewInit(): void { 30 | setTimeout(() => { 31 | if (this.usernameControl) { 32 | this.usernameControl.nativeElement.focus(); 33 | } 34 | }); 35 | } 36 | 37 | buildForm(): void { 38 | this.aboutForm = this.formBuilder.group({ 39 | autoSave: new FormControl(false), 40 | username: new FormControl('', [Validators.required]), 41 | email: new FormControl('', [Validators.required]), 42 | addressOne: new FormGroup({ 43 | street: new FormControl(''), 44 | zipCode: new FormControl('') 45 | }), 46 | addressTwo: new FormGroup({ 47 | street: new FormControl(''), 48 | zipCode: new FormControl('') 49 | }) 50 | }); 51 | } 52 | 53 | get addressOneForm() { 54 | return this.aboutForm.get('addressOne'); 55 | } 56 | 57 | get addressTwoForm() { 58 | return this.aboutForm.get('addressOne'); 59 | } 60 | 61 | onSubmit(): void { 62 | if (this.aboutForm.valid) { 63 | // this.saveForm(); 64 | } 65 | } 66 | 67 | resetForm(): void { 68 | this.aboutForm.reset(); 69 | this.aboutForm.clearValidators(); 70 | this.aboutForm.clearAsyncValidators(); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/app/features/about/about.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | import { AboutRoutingModule } from './about-routing.module'; 5 | import { AboutComponent } from './about.component'; 6 | import { SharedModule } from '@shared/shared.module'; 7 | import { AddressOneComponent } from './components/address-one/address-one.component'; 8 | import { AddressTwoComponent } from './components/address-two/address-two.component'; 9 | 10 | import { AboutState } from './states/about.state'; 11 | import { NgxsModule } from '@ngxs/store'; 12 | 13 | 14 | @NgModule({ 15 | declarations: [ 16 | AboutComponent, 17 | AddressOneComponent, 18 | AddressTwoComponent, 19 | ], 20 | imports: [ 21 | CommonModule, 22 | AboutRoutingModule, 23 | SharedModule, 24 | NgxsModule.forFeature([AboutState]) 25 | ] 26 | }) 27 | export class AboutModule { } 28 | -------------------------------------------------------------------------------- /src/app/features/about/components/address-one/address-one.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
-------------------------------------------------------------------------------- /src/app/features/about/components/address-one/address-one.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/about/components/address-one/address-one.component.scss -------------------------------------------------------------------------------- /src/app/features/about/components/address-one/address-one.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { ReactiveFormsModule, FormsModule } from '@angular/forms'; 3 | import { AddressOneComponent } from './address-one.component'; 4 | import { SharedModule } from '@shared/shared.module'; 5 | 6 | describe('AddressOneComponent', () => { 7 | let component: AddressOneComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ AddressOneComponent ], 13 | imports: [ 14 | ReactiveFormsModule, 15 | FormsModule, 16 | SharedModule 17 | ] 18 | }) 19 | .compileComponents(); 20 | })); 21 | 22 | beforeEach(() => { 23 | fixture = TestBed.createComponent(AddressOneComponent); 24 | component = fixture.componentInstance; 25 | // fixture.detectChanges(); 26 | }); 27 | 28 | it('should create', () => { 29 | expect(component).toBeTruthy(); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/features/about/components/address-one/address-one.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core'; 2 | import { FormGroup } from '@angular/forms'; 3 | 4 | @Component({ 5 | selector: 'app-address-one', 6 | templateUrl: './address-one.component.html', 7 | styleUrls: ['./address-one.component.scss'], 8 | changeDetection: ChangeDetectionStrategy.OnPush 9 | }) 10 | export class AddressOneComponent implements OnInit { 11 | @Input() addressOneForm: FormGroup; 12 | 13 | constructor() { } 14 | 15 | ngOnInit() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/app/features/about/components/address-two/address-two.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
-------------------------------------------------------------------------------- /src/app/features/about/components/address-two/address-two.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/about/components/address-two/address-two.component.scss -------------------------------------------------------------------------------- /src/app/features/about/components/address-two/address-two.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { ReactiveFormsModule, FormsModule, FormBuilder } from '@angular/forms'; 3 | import { AddressTwoComponent } from './address-two.component'; 4 | import { SharedModule } from '@shared/shared.module'; 5 | 6 | describe('AddressTwoComponent', () => { 7 | let component: AddressTwoComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ AddressTwoComponent ], 13 | imports: [ 14 | ReactiveFormsModule, 15 | FormsModule, 16 | SharedModule 17 | ] 18 | }) 19 | .compileComponents(); 20 | })); 21 | 22 | beforeEach(() => { 23 | fixture = TestBed.createComponent(AddressTwoComponent); 24 | component = fixture.componentInstance; 25 | // fixture.detectChanges(); 26 | }); 27 | 28 | it('should create', () => { 29 | expect(component).toBeTruthy(); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/features/about/components/address-two/address-two.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core'; 2 | import { FormGroup } from '@angular/forms'; 3 | 4 | @Component({ 5 | selector: 'app-address-two', 6 | templateUrl: './address-two.component.html', 7 | styleUrls: ['./address-two.component.scss'], 8 | changeDetection: ChangeDetectionStrategy.OnPush 9 | }) 10 | export class AddressTwoComponent implements OnInit { 11 | @Input() addressTwoForm: FormGroup; 12 | 13 | constructor() { } 14 | 15 | ngOnInit() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/app/features/about/states/about.state.ts: -------------------------------------------------------------------------------- 1 | import { State } from '@ngxs/store'; 2 | 3 | export interface AboutStateModel { 4 | newAboutForm: any; 5 | } 6 | 7 | @State({ 8 | name: 'about', 9 | defaults: { 10 | newAboutForm: { 11 | model: undefined, 12 | dirty: false, 13 | status: '', 14 | errors: {} 15 | } 16 | } 17 | }) 18 | export class AboutState { 19 | 20 | constructor() {} 21 | 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/app/features/admin/admin.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { SharedModule } from '@app/shared/shared.module'; 3 | 4 | 5 | 6 | @NgModule({ 7 | declarations: [], 8 | imports: [ 9 | SharedModule 10 | ] 11 | }) 12 | export class AdminModule { } 13 | -------------------------------------------------------------------------------- /src/app/features/article/article.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { ArticlePreviewComponent } from './helpers/article-preview/article-preview.component'; 4 | import { ArticleListComponent } from './helpers/article-list/article-list.component'; 5 | import { ArticleMetaComponent } from './helpers/article-meta/article-meta.component'; 6 | 7 | 8 | 9 | @NgModule({ 10 | declarations: [ArticlePreviewComponent, ArticleListComponent, ArticleMetaComponent], 11 | imports: [ 12 | CommonModule 13 | ] 14 | }) 15 | export class ArticleModule { } 16 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-list/article-list.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-list/article-list.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/article/helpers/article-list/article-list.component.scss -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-list/article-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { ArticlePreviewComponent } from '../article-preview/article-preview.component'; 3 | import { ArticleListComponent } from './article-list.component'; 4 | 5 | describe('ArticleListComponent', () => { 6 | let component: ArticleListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ArticleListComponent, ArticlePreviewComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ArticleListComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-list/article-list.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-article-list', 5 | templateUrl: './article-list.component.html', 6 | styleUrls: ['./article-list.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class ArticleListComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-meta/article-meta.component.html: -------------------------------------------------------------------------------- 1 |

article-meta works!

2 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-meta/article-meta.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/article/helpers/article-meta/article-meta.component.scss -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-meta/article-meta.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ArticleMetaComponent } from './article-meta.component'; 4 | 5 | describe('ArticleMetaComponent', () => { 6 | let component: ArticleMetaComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ArticleMetaComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ArticleMetaComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-meta/article-meta.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-article-meta', 5 | templateUrl: './article-meta.component.html', 6 | styleUrls: ['./article-meta.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class ArticleMetaComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-preview/article-preview.component.html: -------------------------------------------------------------------------------- 1 |

article-preview works!

2 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-preview/article-preview.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/article/helpers/article-preview/article-preview.component.scss -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-preview/article-preview.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ArticlePreviewComponent } from './article-preview.component'; 4 | 5 | describe('ArticlePreviewComponent', () => { 6 | let component: ArticlePreviewComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ArticlePreviewComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ArticlePreviewComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/article/helpers/article-preview/article-preview.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-article-preview', 5 | templateUrl: './article-preview.component.html', 6 | styleUrls: ['./article-preview.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class ArticlePreviewComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/features/forum/forum.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | 5 | 6 | @NgModule({ 7 | declarations: [], 8 | imports: [ 9 | CommonModule 10 | ] 11 | }) 12 | export class ForumModule { } 13 | -------------------------------------------------------------------------------- /src/app/features/home/home-routing.module.ts: -------------------------------------------------------------------------------- 1 | 2 | import { NgModule } from '@angular/core'; 3 | import { Routes, RouterModule } from '@angular/router'; 4 | import { HomeComponent } from './home.component'; 5 | // import { HomeAuthResolver } from './home-auth-resolver.service'; 6 | 7 | const routes: Routes = [ 8 | { 9 | path: '', 10 | component: HomeComponent, 11 | // resolve: { 12 | // isAuthenticated: HomeAuthResolver 13 | // } 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [RouterModule.forChild(routes)], 19 | exports: [RouterModule] 20 | }) 21 | export class HomeRoutingModule {} 22 | -------------------------------------------------------------------------------- /src/app/features/home/home.component.html: -------------------------------------------------------------------------------- 1 |

home works!

2 | -------------------------------------------------------------------------------- /src/app/features/home/home.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/home/home.component.scss -------------------------------------------------------------------------------- /src/app/features/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/features/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-home', 5 | templateUrl: './home.component.html', 6 | styleUrls: ['./home.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class HomeComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/features/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { HomeComponent } from './home.component'; 3 | import { HomeRoutingModule } from './home-routing.module'; 4 | import { SharedModule } from '@shared/shared.module'; 5 | 6 | @NgModule({ 7 | declarations: [HomeComponent], 8 | imports: [ 9 | SharedModule, 10 | HomeRoutingModule 11 | ] 12 | }) 13 | export class HomeModule { } 14 | -------------------------------------------------------------------------------- /src/app/features/profile/profile-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | import { ProfileComponent } from './profile.component'; 5 | 6 | const routes: Routes = [ 7 | { 8 | path: 'profile', 9 | component: ProfileComponent 10 | }, 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forChild(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class ProfileRoutingModule { } 18 | -------------------------------------------------------------------------------- /src/app/features/profile/profile.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 |

NGXS form sync with a store demo 🚀

7 |
8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 |
16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /src/app/features/profile/profile.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/profile/profile.component.scss -------------------------------------------------------------------------------- /src/app/features/profile/profile.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { ProfileComponent } from './profile.component'; 3 | import { ReactiveFormsModule, FormsModule } from '@angular/forms'; 4 | import { SharedModule } from '@shared/shared.module'; 5 | import { NgxsModule } from '@ngxs/store'; 6 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 7 | 8 | 9 | describe('ProfileComponent', () => { 10 | let component: ProfileComponent; 11 | let fixture: ComponentFixture; 12 | 13 | beforeEach(async(() => { 14 | TestBed.configureTestingModule({ 15 | declarations: [ ProfileComponent ], 16 | imports: [ 17 | ReactiveFormsModule, 18 | FormsModule, 19 | SharedModule, 20 | NgxsModule.forRoot(), 21 | NoopAnimationsModule 22 | ] 23 | }) 24 | .compileComponents(); 25 | })); 26 | 27 | beforeEach(() => { 28 | fixture = TestBed.createComponent(ProfileComponent); 29 | component = fixture.componentInstance; 30 | fixture.detectChanges(); 31 | }); 32 | 33 | it('should create', () => { 34 | expect(component).toBeTruthy(); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /src/app/features/profile/profile.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | import { FormGroup, FormControl, FormBuilder } from '@angular/forms'; 3 | import { ProfileState } from './states/profile.state'; 4 | import { Observable } from 'rxjs'; 5 | import { Select } from '@ngxs/store'; 6 | 7 | @Component({ 8 | selector: 'app-profile', 9 | templateUrl: './profile.component.html', 10 | styleUrls: ['./profile.component.scss'], 11 | changeDetection: ChangeDetectionStrategy.OnPush 12 | }) 13 | export class ProfileComponent implements OnInit { 14 | @Select(ProfileState.details) details$: Observable; 15 | @Select(ProfileState.name) text$: Observable; 16 | 17 | newProfileForm: FormGroup; 18 | 19 | constructor(private formBuilder: FormBuilder) { 20 | this.buildForm(); 21 | 22 | this.details$.subscribe(console.log); 23 | this.text$.subscribe(console.log); 24 | } 25 | 26 | onSubmit() { 27 | // 28 | console.log(this.newProfileForm.value); 29 | } 30 | 31 | ngOnInit(): void { 32 | } 33 | 34 | buildForm(): void { 35 | this.newProfileForm = this.formBuilder.group({ 36 | text: new FormControl(null) 37 | }); 38 | } 39 | 40 | // UpdateFormStatus({ status, path }) - Update the form status 41 | // UpdateFormValue({ value, path, propertyPath? }) - Update the form value (or optionally an inner property value) 42 | // UpdateFormDirty({ dirty, path }) - Update the form dirty status 43 | // SetFormDisabled(path) - Set the form to disabled 44 | // SetFormEnabled(path) - Set the form to enabled 45 | // SetFormDirty(path) - Set the form to dirty (shortcut for UpdateFormDirty) 46 | // SetFormPristine(path) - Set the form to pristine (shortcut for UpdateFormDirty) 47 | } 48 | -------------------------------------------------------------------------------- /src/app/features/profile/profile.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { ProfileComponent } from './profile.component'; 4 | import { NgxsModule } from '@ngxs/store'; 5 | import { ProfileState } from './states/profile.state'; 6 | import { ProfileRoutingModule } from './profile-routing.module'; 7 | import { SharedModule } from '@app/shared/shared.module'; 8 | import { NgxsFormPluginModule } from '@ngxs/form-plugin'; 9 | 10 | 11 | @NgModule({ 12 | declarations: [ProfileComponent], 13 | imports: [ 14 | ProfileRoutingModule, 15 | SharedModule, 16 | NgxsModule.forFeature([ProfileState]), 17 | NgxsFormPluginModule 18 | ] 19 | }) 20 | export class ProfileModule { } 21 | -------------------------------------------------------------------------------- /src/app/features/profile/states/profile.state.ts: -------------------------------------------------------------------------------- 1 | import { State, Action, Selector, StateContext, Store } from '@ngxs/store'; 2 | 3 | export interface ProfileStateModel { 4 | details: any; 5 | } 6 | 7 | @State({ 8 | name: 'form', 9 | defaults: { 10 | details: { 11 | model: [], 12 | dirty: false, 13 | status: '', 14 | errors: {} 15 | } 16 | } 17 | }) 18 | export class ProfileState { 19 | constructor(private store: Store) {} 20 | 21 | @Selector() 22 | static details(state: any) { 23 | return state.details; 24 | } 25 | @Selector() 26 | static text(state: any) { 27 | return state.details.model.text; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/app/features/settings/settings-routing.module.ts: -------------------------------------------------------------------------------- 1 | 2 | import { NgModule } from '@angular/core'; 3 | import { RouterModule, Routes } from '@angular/router'; 4 | // import { AuthGuard } from '../core'; 5 | import { SettingsComponent } from './settings.component'; 6 | 7 | const routes: Routes = [ 8 | { 9 | path: 'settings', 10 | component: SettingsComponent, 11 | // canActivate: [AuthGuard] 12 | } 13 | ]; 14 | 15 | @NgModule({ 16 | imports: [RouterModule.forChild(routes)], 17 | exports: [RouterModule] 18 | }) 19 | export class SettingsRoutingModule {} 20 | -------------------------------------------------------------------------------- /src/app/features/settings/settings.component.html: -------------------------------------------------------------------------------- 1 |

settings works!

2 | -------------------------------------------------------------------------------- /src/app/features/settings/settings.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/features/settings/settings.component.scss -------------------------------------------------------------------------------- /src/app/features/settings/settings.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { SettingsComponent } from './settings.component'; 4 | 5 | describe('SettingsComponent', () => { 6 | let component: SettingsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ SettingsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(SettingsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/features/settings/settings.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-settings', 5 | templateUrl: './settings.component.html', 6 | styleUrls: ['./settings.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class SettingsComponent implements OnInit { 10 | 11 | themes = [ 12 | { value: 'DEFAULT-THEME', label: 'blue' }, 13 | { value: 'LIGHT-THEME', label: 'light' }, 14 | { value: 'NATURE-THEME', label: 'nature' }, 15 | { value: 'BLACK-THEME', label: 'dark' } 16 | ]; 17 | 18 | constructor() { } 19 | 20 | ngOnInit() { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/app/features/settings/settings.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { SettingsComponent } from './settings.component'; 3 | 4 | import { SharedModule } from '@shared/shared.module'; 5 | import { SettingsRoutingModule } from './settings-routing.module'; 6 | 7 | @NgModule({ 8 | declarations: [SettingsComponent], 9 | imports: [ 10 | SharedModule, 11 | SettingsRoutingModule 12 | ] 13 | }) 14 | export class SettingsModule { } 15 | -------------------------------------------------------------------------------- /src/app/shared/components/big-input/big-input.component.html: -------------------------------------------------------------------------------- 1 |

big-input works!

2 | -------------------------------------------------------------------------------- /src/app/shared/components/big-input/big-input.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/shared/components/big-input/big-input.component.scss -------------------------------------------------------------------------------- /src/app/shared/components/big-input/big-input.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { BigInputComponent } from './big-input.component'; 4 | 5 | describe('BigInputComponent', () => { 6 | let component: BigInputComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ BigInputComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(BigInputComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/big-input/big-input.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-big-input', 5 | templateUrl: './big-input.component.html', 6 | styleUrls: ['./big-input.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class BigInputComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/shared/components/favorite-button/favorite-button.component.html: -------------------------------------------------------------------------------- 1 |

favorite-button works!

2 | -------------------------------------------------------------------------------- /src/app/shared/components/favorite-button/favorite-button.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/shared/components/favorite-button/favorite-button.component.scss -------------------------------------------------------------------------------- /src/app/shared/components/favorite-button/favorite-button.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { FavoriteButtonComponent } from './favorite-button.component'; 4 | 5 | describe('FavoriteButtonComponent', () => { 6 | let component: FavoriteButtonComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ FavoriteButtonComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(FavoriteButtonComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/favorite-button/favorite-button.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-favorite-button', 5 | templateUrl: './favorite-button.component.html', 6 | styleUrls: ['./favorite-button.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class FavoriteButtonComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/shared/components/follow-button/follow-button.component.html: -------------------------------------------------------------------------------- 1 |

follow-button works!

2 | -------------------------------------------------------------------------------- /src/app/shared/components/follow-button/follow-button.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/shared/components/follow-button/follow-button.component.scss -------------------------------------------------------------------------------- /src/app/shared/components/follow-button/follow-button.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { FollowButtonComponent } from './follow-button.component'; 4 | 5 | describe('FollowButtonComponent', () => { 6 | let component: FollowButtonComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ FollowButtonComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(FollowButtonComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/follow-button/follow-button.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-follow-button', 5 | templateUrl: './follow-button.component.html', 6 | styleUrls: ['./follow-button.component.scss'], 7 | changeDetection: ChangeDetectionStrategy.OnPush 8 | }) 9 | export class FollowButtonComponent implements OnInit { 10 | 11 | constructor() { } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/shared/components/show-errors/show-errors.component.html: -------------------------------------------------------------------------------- 1 |

show-errors works!

2 | -------------------------------------------------------------------------------- /src/app/shared/components/show-errors/show-errors.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/app/shared/components/show-errors/show-errors.component.scss -------------------------------------------------------------------------------- /src/app/shared/components/show-errors/show-errors.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ShowErrorsComponent } from './show-errors.component'; 4 | 5 | describe('ShowErrorsComponent', () => { 6 | let component: ShowErrorsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ShowErrorsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ShowErrorsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/show-errors/show-errors.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input } from '@angular/core'; 2 | 3 | import { Errors } from '@core/models/error.model'; 4 | 5 | @Component({ 6 | selector: 'app-show-errors', 7 | templateUrl: './show-errors.component.html' 8 | }) 9 | export class ShowErrorsComponent { 10 | formattedErrors: Array = []; 11 | 12 | @Input() 13 | set errors(errorList: Errors) { 14 | this.formattedErrors = Object.keys(errorList.errors || {}) 15 | .map(key => `${key} ${errorList.errors[key]}`); 16 | } 17 | 18 | get errorList() { return this.formattedErrors; } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/app/shared/directives/show-authed.directive.ts: -------------------------------------------------------------------------------- 1 | 2 | import { 3 | Directive, 4 | Input, 5 | OnInit, 6 | TemplateRef, 7 | ViewContainerRef 8 | } from '@angular/core'; 9 | 10 | // import { UserService } from '@core'; 11 | 12 | @Directive({ selector: '[appShowAuthed]' }) 13 | export class ShowAuthedDirective implements OnInit { 14 | constructor( 15 | private templateRef: TemplateRef, 16 | // private userService: UserService, 17 | private viewContainer: ViewContainerRef 18 | ) {} 19 | 20 | condition: boolean; 21 | 22 | ngOnInit() { 23 | // this.userService.isAuthenticated.subscribe( 24 | // (isAuthenticated) => { 25 | // if (isAuthenticated && this.condition || !isAuthenticated && !this.condition) { 26 | // this.viewContainer.createEmbeddedView(this.templateRef); 27 | // } else { 28 | // this.viewContainer.clear(); 29 | // } 30 | // } 31 | // ); 32 | } 33 | 34 | @Input() set appShowAuthed(condition: boolean) { 35 | this.condition = condition; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/app/shared/material.module.ts: -------------------------------------------------------------------------------- 1 | import {A11yModule} from '@angular/cdk/a11y'; 2 | import {DragDropModule} from '@angular/cdk/drag-drop'; 3 | import {ScrollingModule} from '@angular/cdk/scrolling'; 4 | import {CdkStepperModule} from '@angular/cdk/stepper'; 5 | import {CdkTableModule} from '@angular/cdk/table'; 6 | import {CdkTreeModule} from '@angular/cdk/tree'; 7 | import {NgModule} from '@angular/core'; 8 | import { 9 | MatAutocompleteModule, 10 | MatBadgeModule, 11 | MatBottomSheetModule, 12 | MatButtonModule, 13 | MatButtonToggleModule, 14 | MatCardModule, 15 | MatCheckboxModule, 16 | MatChipsModule, 17 | MatDatepickerModule, 18 | MatDialogModule, 19 | MatDividerModule, 20 | MatExpansionModule, 21 | MatGridListModule, 22 | MatIconModule, 23 | MatInputModule, 24 | MatListModule, 25 | MatMenuModule, 26 | MatNativeDateModule, 27 | MatPaginatorModule, 28 | MatProgressBarModule, 29 | MatProgressSpinnerModule, 30 | MatRadioModule, 31 | MatRippleModule, 32 | MatSelectModule, 33 | MatSidenavModule, 34 | MatSliderModule, 35 | MatSlideToggleModule, 36 | MatSnackBarModule, 37 | MatSortModule, 38 | MatStepperModule, 39 | MatTableModule, 40 | MatTabsModule, 41 | MatToolbarModule, 42 | MatTooltipModule, 43 | MatTreeModule, 44 | ErrorStateMatcher, 45 | ShowOnDirtyErrorStateMatcher, 46 | } from '@angular/material'; 47 | @NgModule({ 48 | exports: [ 49 | A11yModule, 50 | CdkStepperModule, 51 | CdkTableModule, 52 | CdkTreeModule, 53 | DragDropModule, 54 | MatAutocompleteModule, 55 | MatBadgeModule, 56 | MatBottomSheetModule, 57 | MatButtonModule, 58 | MatButtonToggleModule, 59 | MatCardModule, 60 | MatCheckboxModule, 61 | MatChipsModule, 62 | MatStepperModule, 63 | MatDatepickerModule, 64 | MatDialogModule, 65 | MatDividerModule, 66 | MatExpansionModule, 67 | MatGridListModule, 68 | MatIconModule, 69 | MatInputModule, 70 | MatListModule, 71 | MatMenuModule, 72 | MatNativeDateModule, 73 | MatPaginatorModule, 74 | MatProgressBarModule, 75 | MatProgressSpinnerModule, 76 | MatRadioModule, 77 | MatRippleModule, 78 | MatSelectModule, 79 | MatSidenavModule, 80 | MatSliderModule, 81 | MatSlideToggleModule, 82 | MatSnackBarModule, 83 | MatSortModule, 84 | MatTableModule, 85 | MatTabsModule, 86 | MatToolbarModule, 87 | MatTooltipModule, 88 | MatTreeModule, 89 | ScrollingModule, 90 | ], 91 | providers: [ 92 | { provide: ErrorStateMatcher, useClass: ShowOnDirtyErrorStateMatcher }, 93 | ] 94 | }) 95 | export class MaterialModule {} -------------------------------------------------------------------------------- /src/app/shared/services/validation.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ValidationService } from './validation.service'; 4 | 5 | describe('ValidationService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: ValidationService = TestBed.get(ValidationService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/shared/services/validation.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class ValidationService { 7 | 8 | constructor() { } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/shared/shared.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { BigInputComponent } from './components/big-input/big-input.component'; 4 | import { MaterialModule } from './material.module'; 5 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 6 | 7 | import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; 8 | import { library } from '@fortawesome/fontawesome-svg-core'; 9 | import { 10 | faBars, 11 | faUserCircle, 12 | faPowerOff, 13 | faCog, 14 | faPlayCircle, 15 | faRocket, 16 | faPlus, 17 | faEdit, 18 | faTrash, 19 | faTimes, 20 | faCaretUp, 21 | faCaretDown, 22 | faExclamationTriangle, 23 | faFilter, 24 | faTasks, 25 | faCheck, 26 | faSquare, 27 | faLanguage, 28 | faPaintBrush, 29 | faLightbulb, 30 | faWindowMaximize, 31 | faStream, 32 | faBook 33 | } from '@fortawesome/free-solid-svg-icons'; 34 | import { 35 | faGithub, 36 | faMediumM, 37 | faTwitter, 38 | faInstagram, 39 | faYoutube 40 | } from '@fortawesome/free-brands-svg-icons'; 41 | import { FlexLayoutModule } from '@angular/flex-layout'; 42 | import { ShowErrorsComponent } from './components/show-errors/show-errors.component'; 43 | import { FavoriteButtonComponent } from './components/favorite-button/favorite-button.component'; 44 | import { FollowButtonComponent } from './components/follow-button/follow-button.component'; 45 | import { ShowAuthedDirective } from './directives/show-authed.directive'; 46 | 47 | library.add( 48 | faBars, 49 | faUserCircle, 50 | faPowerOff, 51 | faCog, 52 | faRocket, 53 | faPlayCircle, 54 | faGithub, 55 | faMediumM, 56 | faTwitter, 57 | faInstagram, 58 | faYoutube, 59 | faPlus, 60 | faEdit, 61 | faTrash, 62 | faTimes, 63 | faCaretUp, 64 | faCaretDown, 65 | faExclamationTriangle, 66 | faFilter, 67 | faTasks, 68 | faCheck, 69 | faSquare, 70 | faLanguage, 71 | faPaintBrush, 72 | faLightbulb, 73 | faWindowMaximize, 74 | faStream, 75 | faBook 76 | ); 77 | 78 | @NgModule({ 79 | declarations: [ 80 | BigInputComponent, 81 | ShowErrorsComponent, 82 | FavoriteButtonComponent, 83 | FollowButtonComponent, 84 | ShowAuthedDirective 85 | ], 86 | imports: [ 87 | MaterialModule, 88 | CommonModule, 89 | FontAwesomeModule, 90 | FlexLayoutModule, 91 | ], 92 | exports: [ 93 | MaterialModule, 94 | FontAwesomeModule, 95 | ReactiveFormsModule, 96 | FormsModule, 97 | FlexLayoutModule, 98 | ] 99 | }) 100 | export class SharedModule { } 101 | -------------------------------------------------------------------------------- /src/app/shared/utils/common.ts: -------------------------------------------------------------------------------- 1 | export function functionA() { 2 | return 'A'; 3 | } 4 | 5 | export function functionB() { 6 | return 'B'; 7 | } 8 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/assets/i18n/en.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/assets/i18n/en.json -------------------------------------------------------------------------------- /src/assets/i18n/no.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/assets/i18n/no.json -------------------------------------------------------------------------------- /src/assets/icons/aston-villa-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 11 | 13 | 14 | 17 | 20 | 22 | 28 | 34 | 38 | 45 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/environments/environment.ci.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.hmr.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false, 3 | hmr: true, 4 | featureToggles: {} 5 | } 6 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.test.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false 3 | } 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false 3 | }; 4 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AngularMaterialStarter 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 69 | 70 | 71 | 72 |
73 | 78 |
79 |
80 | 81 | 82 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import 'hammerjs'; 2 | import { enableProdMode } from '@angular/core'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | import { AppModule } from './app/app.module'; 6 | import { environment } from './environments/environment'; 7 | 8 | if (environment.production) { 9 | enableProdMode(); 10 | } 11 | 12 | platformBrowserDynamic().bootstrapModule(AppModule) 13 | .catch(err => console.error(err)); 14 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | @import "~ngx-bar-rating/themes/br-default-theme"; 2 | 3 | @import '~@angular/material/theming'; 4 | 5 | $custom-typography: mat-typography-config( 6 | $font-family: 'Open Sans, Arial, sans-serif' 7 | ); 8 | 9 | @include mat-core($custom-typography); 10 | 11 | @import './themes/default-theme'; 12 | @import './themes/dark-theme'; 13 | 14 | @mixin custom-components-theme($theme) { 15 | // component 1 16 | // component 2 17 | } 18 | 19 | .app-default-theme { 20 | @include angular-material-theme($app-default-theme); 21 | @include mat-toolbar-theme($app-default-toolbar-theme); 22 | } 23 | 24 | .app-dark-theme { 25 | @include angular-material-theme($app-dark-theme); 26 | @include mat-toolbar-theme($app-dark-toolbar-theme); 27 | } 28 | 29 | body { 30 | margin: 0; 31 | font-family: Roboto, 'Helvetica Neue', 'sans-serif'; 32 | } 33 | -------------------------------------------------------------------------------- /src/styles/app-loading.scss: -------------------------------------------------------------------------------- 1 | .app-loading { 2 | .logo { 3 | width: 64px; 4 | height: 64px; 5 | background: url(./assets/logo.png) center center no-repeat; 6 | background-size: cover; 7 | } 8 | } -------------------------------------------------------------------------------- /src/styles/colors.scss: -------------------------------------------------------------------------------- 1 | $black-100-color: #000000; 2 | $black-90-color: #141414; 3 | $black-80-color: #1E1E1F; 4 | $black-70-color: #2A2A2B; 5 | $black-60-color: #343436; 6 | $black-50-color: #39393B; 7 | $black-40-color: #464648; 8 | $black-30-color: #515151; 9 | $black-20-color: #6A6A6E; 10 | $black-10-color: #EDEDED; 11 | 12 | $white-100-color: #FFFFFF; 13 | $white-95-color: #EBEBEB; 14 | $white-90-color: #C1C1C7; 15 | $white-80-color: #949599; 16 | $white-70-color: #C2C2C3; 17 | $white-50-color: #898989; 18 | $white-20-color: #505052; 19 | 20 | $success-color: #AACD87; 21 | $warning-color: #FFEB9B; 22 | $error-color: #E63C37; 23 | 24 | $yellow-light-color: #FFEB9B; 25 | $yellow-black-color: #FFB900; 26 | $ice-yellow-color: #FFCD00; 27 | 28 | $black-text-color: #1A1A1A; 29 | $black-link-hover-background-color: #C0C0C0; 30 | 31 | $yellow-color: #FFEB9B; 32 | $orange-color: #F48C53; 33 | $purple-color: #8D4693; 34 | $green-color: #3AAF82; 35 | $blue-color: #668CF9; 36 | $red-color: #E63C37; 37 | $apricot-peach-color: #F9C5A9; 38 | $alto: #DDDDDD; 39 | $gray: #8C8C8C; 40 | $pale-slate: #CAC9CA; 41 | $outer-space: #323639; 42 | $abbey: #525659; 43 | $marine-color: rgba(102, 140, 249, 0.2); 44 | 45 | $success-border-color: $green-color; 46 | $warning-border-color: $orange-color; 47 | $warning-background-color: $apricot-peach-color; 48 | 49 | $checkbox-color: $green-color; 50 | $disabled-text-color: $white-80-color; 51 | 52 | $button-disabled-font-color: $gray; 53 | $button-disabled-color: $alto; 54 | 55 | $menu-border: #E9E9E9; -------------------------------------------------------------------------------- /src/styles/overrides-material.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathisGarberg/angular-ngxs-and-material-starter/c67c8e6445d3feb3cf025ce94f555771b37e42c8/src/styles/overrides-material.scss -------------------------------------------------------------------------------- /src/styles/reset-theme.scss: -------------------------------------------------------------------------------- 1 | @import '.~@angular/material/theming'; 2 | 3 | @mixin app-reset-theme($theme) { 4 | 5 | } -------------------------------------------------------------------------------- /src/styles/spinner.scss: -------------------------------------------------------------------------------- 1 | @mixin ellipsisAnimation($left, $left3, $left4, $animationName, $animationTime) { 2 | @for $i from 1 through 4 { 3 | div:nth-child(#{$i}) { 4 | @if $i == 1 or $i == 2 { 5 | left: $left1 + px; 6 | animation: $animationName + $i $animationTime + s infinite; 7 | } 8 | @else if ($i == 3) { 9 | left: $left3 + px; 10 | animation: $animationName + 2 $animationTime + s infinite; 11 | } 12 | @else if ($i == 4) { 13 | left: $left4 + px; 14 | animation: $animationName + 3 $animationTime + s infinite; 15 | } 16 | } 17 | } 18 | } 19 | 20 | /** 21 | * spinner prints out a spinner with 4 bullets 22 | * @parameters 23 | * name: name 24 | * ellipsis-size: size of the bullets 25 | * left1: first 2 bullets uses left1 26 | * left2: for third bullet 27 | * left3: for second bullets 28 | * animationTime: how fast things animate 29 | **/ 30 | 31 | @mixin spinner($name, $ellipsis-size, $left1, $left2, $left3, $animationTime) { 32 | div { 33 | position: absolute; 34 | width: $ellipsis-size; 35 | height: $ellipsis-size; 36 | border-radius: 50; 37 | background: #000000; 38 | animation-timing-function: cubic-bezier(0, 1, 1, 0); 39 | } 40 | @include ellipsisAnimation($left1, $left2, $left3, $name, $animationTime); 41 | } 42 | 43 | @mixin ellipsis-keyFrame($name, $value) { 44 | @keyframes #{$name + 1} { 45 | 0% { 46 | transform: scale(0); 47 | } 48 | 100% { 49 | transform: scale(1); 50 | } 51 | } 52 | 53 | @keyframes #{$name + 3} { 54 | 0% { 55 | transform: scale(1); 56 | } 57 | 100% { 58 | transform: scale(0); 59 | } 60 | } 61 | @keyframes #{$name + 2} { 62 | 0% { 63 | transform: translate(0, 0); 64 | } 65 | 100% { 66 | transform: translate($value + px, 0); 67 | } 68 | } 69 | } 70 | 71 | .spinner-container { 72 | width: 100%; 73 | text-align: center; 74 | } 75 | 76 | .spinner-ellipsis-11px { 77 | display: inline-block; 78 | position: relative; 79 | width: 64px; 80 | height: 11px; 81 | @include spinner(spinner-ellipsis-11px, 11, 6, 26, 45, .6); 82 | } 83 | 84 | @include ellipsis-keyFrame(spinner-ellipsis-11px, 19); 85 | 86 | .spinner-ellipsis-7px { 87 | display: inline-block; 88 | position: relative; 89 | width: 38px; 90 | height: 7px; 91 | 92 | @include spinner(spinner-ellipsis-7px, 6, 6, 18, 28, .7) 93 | } 94 | 95 | @include ellipsis-keyFrame(spinner-ellipsis-7px, 10); 96 | 97 | .spinner-ellipsis-3px { 98 | display: inline-block; 99 | position: relative; 100 | width: 23px; 101 | height: 4px; 102 | 103 | @include spinner(spinner-ellipsis-3px, 3, 4, 10, 16, .8); 104 | } 105 | 106 | @include ellipsis-keyFrame(spinner-ellipsis-3px, 7); -------------------------------------------------------------------------------- /src/styles/variables.scss: -------------------------------------------------------------------------------- 1 | @import '~@angular/material/theming'; 2 | 3 | $toolbar-breakpoint: 600px; 4 | 5 | $fa-font-path: '~@fortawesome/fontawesome-free-webfonts/webfonts'; 6 | 7 | $link-hover-decoration: none; 8 | $label-margin-bottom: 0; 9 | 10 | $grid-breakpoints: ( 11 | xs: 0, 12 | sm: 576px, 13 | md: 768px, 14 | lg: 992px, 15 | xl: 1200px 16 | ); 17 | 18 | $success-colors: mat-palette($mat-green, 400); 19 | $warning-colors: mat-palette($mat-amber, 400); 20 | 21 | $black: #171717; 22 | $black-light: #333333; 23 | $gray-dark: #606060; 24 | $gray: #aaaaaa; 25 | $gray-light: #dddddd; 26 | $gray-light2: #ececec; 27 | $gray-light3: #dadada; 28 | $gray-light4: #ecedec; 29 | $white: #ffffff; 30 | $yellow-dark: #e7a800; 31 | $yellow: #ffcc00; 32 | $yellow-soft: #ffeb9b; 33 | $red: #cc0000; 34 | $red-bright: #E63C37; 35 | $green: #009900; 36 | 37 | $white-hover: rgba(255,255,255,.5); 38 | $background: #f5f5f5; 39 | $text-black: rgba(23,23,23,.9); 40 | $text-white: rgba(255,255,255,.9); 41 | 42 | $phone-width: 768px; 43 | $form-width: 20.25rem; 44 | 45 | $z-index-focused-link: 1; 46 | $z-index-feedback-link: 2; 47 | $z-index-skipto-link: 3; 48 | 49 | $large-screen: '1599px'; 50 | $tablet-screen: '979px'; 51 | $mobile-screen: '767px'; 52 | -------------------------------------------------------------------------------- /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/themes/dark-theme.scss: -------------------------------------------------------------------------------- 1 | $app-custom-dark-color: ( 2 | 50: #e0e0e0, 3 | 100: #b3b3b3, 4 | 200: #808080, 5 | 300: #4d4d4d, 6 | 400: #262626, 7 | 500: #424242, 8 | 600: #000000, 9 | 700: #000000, 10 | 800: #000000, 11 | 900: #000000, 12 | A100: #a6a6a6, 13 | A200: #8c8c8c, 14 | A400: #737373, 15 | A700: #666666, 16 | contrast: ( 17 | 50: #000000, 18 | 100: #000000, 19 | 200: #000000, 20 | 300: #ffffff, 21 | 400: #ffffff, 22 | 500: #ffffff, 23 | 600: #ffffff, 24 | 700: #ffffff, 25 | 800: #ffffff, 26 | 900: #ffffff, 27 | A100: #000000, 28 | A200: #000000, 29 | A400: #ffffff, 30 | A700: #ffffff 31 | ) 32 | ); 33 | 34 | 35 | $app-dark-primary: mat-palette($mat-amber); 36 | $app-dark-accent: mat-palette($mat-amber, A400, A100, A700); 37 | $app-dark-warn: mat-palette($mat-red); 38 | 39 | $app-dark-theme: mat-dark-theme( 40 | $app-dark-primary, 41 | $app-dark-accent, 42 | $app-dark-warn 43 | ); 44 | 45 | $app-dark-toolbar-primary: mat-palette($app-custom-dark-color); 46 | $app-dark-toolbar-theme: mat-dark-theme( 47 | $app-dark-toolbar-primary, 48 | $app-dark-accent 49 | ); -------------------------------------------------------------------------------- /src/themes/default-theme.scss: -------------------------------------------------------------------------------- 1 | $app-custom-accent: ( 2 | 50 : #e0e0e0, 3 | 100 : #b3b3b3, 4 | 200 : #808080, 5 | 300 : #4d4d4d, 6 | 400 : #262626, 7 | 500 : #000000, 8 | 600 : #000000, 9 | 700 : #000000, 10 | 800 : #000000, 11 | 900 : #000000, 12 | A100 : #a6a6a6, 13 | A200 : #8c8c8c, 14 | A400 : #737373, 15 | A700 : #666666, 16 | contrast: ( 17 | 50 : #000000, 18 | 100 : #000000, 19 | 200 : #000000, 20 | 300 : #ffffff, 21 | 400 : #ffffff, 22 | 500 : #ffffff, 23 | 600 : #ffffff, 24 | 700 : #ffffff, 25 | 800 : #ffffff, 26 | 900 : #ffffff, 27 | A100 : #000000, 28 | A200 : #000000, 29 | A400 : #ffffff, 30 | A700 : #ffffff, 31 | ) 32 | ); 33 | 34 | $toolbar-primary-color: ( 35 | 50: #ffffff, 36 | 100: #ffffff, 37 | 200: #ffffff, 38 | 300: #ffffff, 39 | 400: #ffffff, 40 | 500: #ffffff, 41 | 600: #ffffff, 42 | 700: #ffffff, 43 | 800: #ffffff, 44 | 900: #ffffff, 45 | A100: #ffffff, 46 | A200: #ffffff, 47 | A400: #ffffff, 48 | A700: #ffffff, 49 | contrast: ( 50 | 50: #000000, 51 | 100: #000000, 52 | 200: #000000, 53 | 300: #000000, 54 | 400: #000000, 55 | 500: #000000, 56 | 600: #000000, 57 | 700: #000000, 58 | 800: #000000, 59 | 900: #000000, 60 | A100: #000000, 61 | A200: #000000, 62 | A400: #000000, 63 | A700: #000000 64 | ) 65 | ); 66 | 67 | $app-default-primary: mat-palette($mat-amber); 68 | $app-default-accent: mat-palette($app-custom-accent); 69 | $app-default-warn: mat-palette($mat-red); 70 | 71 | $app-default-theme: mat-light-theme( 72 | $app-default-primary, 73 | $app-default-accent, 74 | $app-default-warn 75 | ); 76 | 77 | $app-default-toolbar-primary: mat-palette($toolbar-primary-color); 78 | $app-default-toolbar-theme: mat-light-theme($app-default-toolbar-primary, $app-default-accent); 79 | -------------------------------------------------------------------------------- /src/themes/villa-blue-theme.scss: -------------------------------------------------------------------------------- 1 | $villa-custom-accent: ( 2 | 50 : #e0e0e0, 3 | 100 : #b3b3b3, 4 | 200 : #808080, 5 | 300 : #4d4d4d, 6 | 400 : #262626, 7 | 500 : #000000, 8 | 600 : #000000, 9 | 700 : #000000, 10 | 800 : #000000, 11 | 900 : #000000, 12 | A100 : #a6a6a6, 13 | A200 : #8c8c8c, 14 | A400 : #737373, 15 | A700 : #666666, 16 | contrast: ( 17 | 50 : #000000, 18 | 100 : #000000, 19 | 200 : #000000, 20 | 300 : #ffffff, 21 | 400 : #ffffff, 22 | 500 : #ffffff, 23 | 600 : #ffffff, 24 | 700 : #ffffff, 25 | 800 : #ffffff, 26 | 900 : #ffffff, 27 | A100 : #000000, 28 | A200 : #000000, 29 | A400 : #ffffff, 30 | A700 : #ffffff, 31 | ) 32 | ); 33 | 34 | $toolbar-primary-color: ( 35 | 50: #ffffff, 36 | 100: #ffffff, 37 | 200: #ffffff, 38 | 300: #ffffff, 39 | 400: #ffffff, 40 | 500: #ffffff, 41 | 600: #ffffff, 42 | 700: #ffffff, 43 | 800: #ffffff, 44 | 900: #ffffff, 45 | A100: #ffffff, 46 | A200: #ffffff, 47 | A400: #ffffff, 48 | A700: #ffffff, 49 | contrast: ( 50 | 50: #000000, 51 | 100: #000000, 52 | 200: #000000, 53 | 300: #000000, 54 | 400: #000000, 55 | 500: #000000, 56 | 600: #000000, 57 | 700: #000000, 58 | 800: #000000, 59 | 900: #000000, 60 | A100: #000000, 61 | A200: #000000, 62 | A400: #000000, 63 | A700: #000000 64 | ) 65 | ); 66 | 67 | // $villa-default-primary: mat-palette($mat-amber); 68 | // $villa-default-accent: mat-palette($villa-custom-accent); 69 | // $villa-default-warn: mat-palette($mat-red); 70 | 71 | // $villa-default-theme: mat-light-theme( 72 | // $villa-default-primary, 73 | // $villa-default-accent, 74 | // $villa-default-warn 75 | // ); 76 | 77 | // $villa-default-toolbar-primary: mat-palette($toolbar-primary-color); 78 | // $villa-default-toolbar-theme: mat-light-theme($villa-default-toolbar-primary, $villa-default-accent); 79 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.ts" 13 | ], 14 | "exclude": [ 15 | "src/test.ts", 16 | "src/**/*.spec.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ], 21 | "paths": { 22 | "@app/*": [ 23 | "src/app/*" 24 | ], 25 | "@core/*": [ 26 | "src/app/core/*" 27 | ], 28 | "@shared/*": [ 29 | "src/app/shared/*" 30 | ], 31 | "@env": [ 32 | "src/environments/environment" 33 | ], 34 | }, 35 | }, 36 | "angularCompilerOptions": { 37 | "fullTemplateTypeCheck": true, 38 | "strictInjectionParameters": true 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "rulesDirectory": ["node_modules/codelyzer"], 4 | "rules": { 5 | "arrow-return-shorthand": true, 6 | "callable-types": true, 7 | "class-name": true, 8 | "comment-format": [true, "check-space"], 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "forin": true, 13 | "import-blacklist": [true, "rxjs/Rx", ["rxjs/(?!operators|testing)"]], 14 | "interface-over-type-literal": true, 15 | "label-position": true, 16 | "member-access": false, 17 | "member-ordering": [ 18 | true, 19 | { 20 | "order": [ 21 | "static-field", 22 | "instance-field", 23 | "static-method", 24 | "instance-method" 25 | ] 26 | } 27 | ], 28 | "no-arg": true, 29 | "no-bitwise": true, 30 | "no-construct": true, 31 | "no-debugger": true, 32 | "no-duplicate-super": true, 33 | "no-empty": false, 34 | "no-empty-interface": true, 35 | "no-eval": true, 36 | "no-inferrable-types": [true, "ignore-params"], 37 | "no-misused-new": true, 38 | "no-non-null-assertion": true, 39 | "no-shadowed-variable": true, 40 | "no-string-literal": false, 41 | "no-string-throw": true, 42 | "no-switch-case-fall-through": true, 43 | "no-unnecessary-initializer": true, 44 | "no-unused-expression": true, 45 | "no-var-keyword": true, 46 | "object-literal-sort-keys": false, 47 | "prefer-const": true, 48 | "quotemark": [true, "single"], 49 | "radix": true, 50 | "triple-equals": [true, "allow-null-check"], 51 | "unified-signatures": true, 52 | "variable-name": false, 53 | "whitespace": [ 54 | true, 55 | "check-branch", 56 | "check-decl", 57 | "check-operator", 58 | "check-separator", 59 | "check-type" 60 | ], 61 | "no-output-on-prefix": true, 62 | "no-input-rename": true, 63 | "no-output-rename": true, 64 | "use-life-cycle-interface": true, 65 | "use-pipe-transform-interface": true, 66 | "component-class-suffix": true, 67 | "directive-class-suffix": true 68 | } 69 | } 70 | --------------------------------------------------------------------------------