From daa97b3e23ceb355f30020239a86ef9b92c98be8 Mon Sep 17 00:00:00 2001 From: Rinat Arsaev Date: Fri, 30 Nov 2018 16:26:03 +0300 Subject: [PATCH] FE-708: Init (#1) --- .editorconfig | 13 -- .gitmodules | 4 + .prettierignore | 5 + .prettierrc | 8 + Dockerfile.sh | 25 +++ Jenkinsfile | 40 +++++ Makefile | 54 ++++++ README.md | 35 ++-- angular.json | 241 +++++++++++++-------------- build_utils | 1 + containerpilot.json | 13 ++ e2e/protractor.conf.js | 42 +++-- e2e/src/.gitkeep | 0 e2e/src/app.e2e-spec.ts | 14 -- e2e/src/app.po.ts | 11 -- e2e/tsconfig.e2e.json | 20 +-- nginx.conf | 15 ++ package-lock.json | 31 ++++ package.json | 13 +- src/app/app-routing.module.ts | 6 +- src/app/app.component.html | 22 +-- src/app/app.component.spec.ts | 35 ---- src/app/app.component.ts | 8 +- src/app/app.module.ts | 16 +- src/environments/environment.prod.ts | 2 +- src/environments/environment.ts | 2 +- src/index.html | 24 +-- src/karma.conf.js | 56 +++---- src/main.ts | 7 +- src/polyfills.ts | 11 +- src/styles.css | 1 - src/styles.scss | 11 ++ src/test.ts | 10 +- src/tsconfig.app.json | 15 +- src/tsconfig.spec.json | 23 +-- src/tslint.json | 14 +- tsconfig.json | 35 ++-- tslint.json | 182 ++++++-------------- 38 files changed, 524 insertions(+), 541 deletions(-) delete mode 100644 .editorconfig create mode 100644 .gitmodules create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100755 Dockerfile.sh create mode 100644 Jenkinsfile create mode 100644 Makefile create mode 160000 build_utils create mode 100644 containerpilot.json create mode 100644 e2e/src/.gitkeep delete mode 100644 e2e/src/app.e2e-spec.ts delete mode 100644 e2e/src/app.po.ts create mode 100644 nginx.conf delete mode 100644 src/app/app.component.spec.ts delete mode 100644 src/styles.css create mode 100644 src/styles.scss diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index e89330a6..00000000 --- a/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..ca5a761f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "build_utils"] + path = build_utils + url = git@github.com:rbkmoney/build_utils.git + branch = master diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..9f715730 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +package.json +package-lock.json +node_modules +dist +build_utils diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..5c7e756d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "printWidth": 160, + "singleQuote": true, + "useTabs": false, + "tabWidth": 4, + "semi": true, + "bracketSpacing": true +} diff --git a/Dockerfile.sh b/Dockerfile.sh new file mode 100755 index 00000000..7617d539 --- /dev/null +++ b/Dockerfile.sh @@ -0,0 +1,25 @@ +#!/bin/bash +cat < +COPY dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/vhosts.d/dashboard.conf +COPY containerpilot.json /etc/containerpilot.json +CMD /bin/containerpilot -config file:///etc/containerpilot.json /usr/sbin/nginx -g "daemon off;" +EXPOSE 8080 +LABEL base_image_tag=$BASE_IMAGE_TAG +LABEL build_image_tag=$BUILD_IMAGE_TAG +# A bit of magic to get a proper branch name +# even when the HEAD is detached (Hey Jenkins! +# BRANCH_NAME is available in Jenkins env). +LABEL branch=$( \ + if [ "HEAD" != $(git rev-parse --abbrev-ref HEAD) ]; then \ + echo $(git rev-parse --abbrev-ref HEAD); \ + elif [ -n "$BRANCH_NAME" ]; then \ + echo $BRANCH_NAME; \ + else \ + echo $(git name-rev --name-only HEAD); \ + fi) +LABEL commit=$(git rev-parse HEAD) +LABEL commit_number=$(git rev-list --count HEAD) +EOF diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..40ffe4bb --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,40 @@ +#!groovy + +build('dashboard', 'docker-host') { + checkoutRepo() + loadBuildUtils() + + def pipeDefault + def withWsCache + runStage('load pipeline') { + env.JENKINS_LIB = "build_utils/jenkins_lib" + pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy") + withWsCache = load("${env.JENKINS_LIB}/withWsCache.groovy") + } + + pipeDefault() { + runStage('init') { + withGithubSshCredentials { + sh 'make wc_init' + } + } + runStage('build') { + sh 'make wc_build' + } + runStage('build image') { + sh 'make build_image' + } + + try { + if (env.BRANCH_NAME == 'master') { + runStage('push image') { + sh 'make push_image' + } + } + } finally { + runStage('rm local image') { + sh 'make rm_local_image' + } + } + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..4b330603 --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +SUBMODULES = build_utils +SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) + +UTILS_PATH := build_utils +TEMPLATES_PATH := . + +# Name of the service +SERVICE_NAME := dashboard +# Service image default tag +SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD) +# The tag for service image to be pushed with +SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG) + +# Base image for the service +BASE_IMAGE_NAME := service-fe +BASE_IMAGE_TAG := 768cf0f40600e290060502e047dd2e86d4fd6020 + +BUILD_IMAGE_TAG := 1862224e600e34a9bd04327db7b3186fa4d31ceb + +GIT_SSH_COMMAND := +DOCKER_RUN_OPTS = -e GIT_SSH_COMMAND='$(GIT_SSH_COMMAND)' + +CALL_W_CONTAINER := init check lint test build clean submodules + +.PHONY: $(CALL_W_CONTAINER) + +all: build + +-include $(UTILS_PATH)/make_lib/utils_image.mk +-include $(UTILS_PATH)/make_lib/utils_container.mk + +$(SUBTARGETS): %/.git: % + git submodule update --init $< + touch $@ + +submodules: $(SUBTARGETS) + +init: + npm install + +build: check lint + npm run build + +clean: + rm -rf dist + +check: + npm run check + +lint: + npm run lint + +test: + npm run test \ No newline at end of file diff --git a/README.md b/README.md index eefad400..99f43941 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,26 @@ # Dashboard -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.1.0. +## Libraries + +- [Angular CLI](https://github.com/angular/angular-cli) + - Run `ng generate component component-name` to generate a new component (you can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`). + - To get more help use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). +- [Angular Material](https://material.angular.io/) +- [Prettier](https://prettier.io/) ## Development server -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. +1. Run `npm install` +1. Run `npm start` +1. Navigate to `http://localhost:8000/` -## Code scaffolding +## Production build -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. +1. Run `npm install` +1. Run `npm run build` +1. The build artifacts will be stored in the `dist/` directory. -## Build +## Tests -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). +- Run `npm run test` to execute the unit tests via [Karma](https://karma-runner.github.io). +- Run `npm run e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). diff --git a/angular.json b/angular.json index 466a3bc6..25131324 100644 --- a/angular.json +++ b/angular.json @@ -1,135 +1,118 @@ { - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "dashboard": { - "root": "", - "sourceRoot": "src", - "projectType": "application", - "prefix": "app", - "schematics": {}, - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/dashboard", - "index": "src/index.html", - "main": "src/main.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "src/tsconfig.app.json", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - }, - "configurations": { - "production": { - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "dashboard": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": ["src/favicon.ico", "src/assets"], + "styles": ["src/styles.scss"], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "dashboard:build" + }, + "configurations": { + "production": { + "browserTarget": "dashboard:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "dashboard:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.spec.json", + "karmaConfig": "src/karma.conf.js", + "styles": ["src/styles.scss"], + "scripts": [], + "assets": ["src/favicon.ico", "src/assets"] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"], + "exclude": ["**/node_modules/**"] + } } - ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "extractCss": true, - "namedChunks": false, - "aot": true, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true, - "budgets": [ - { - "type": "initial", - "maximumWarning": "2mb", - "maximumError": "5mb" + } + }, + "dashboard-e2e": { + "root": "e2e/", + "projectType": "application", + "prefix": "", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "dashboard:serve" + }, + "configurations": { + "production": { + "devServerTarget": "dashboard:serve:production" + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": "e2e/tsconfig.e2e.json", + "exclude": ["**/node_modules/**"] + } } - ] } - } - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "dashboard:build" - }, - "configurations": { - "production": { - "browserTarget": "dashboard:build:production" - } - } - }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "dashboard:build" - } - }, - "test": { - "builder": "@angular-devkit/build-angular:karma", - "options": { - "main": "src/test.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "src/tsconfig.spec.json", - "karmaConfig": "src/karma.conf.js", - "styles": [ - "src/styles.css" - ], - "scripts": [], - "assets": [ - "src/favicon.ico", - "src/assets" - ] - } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "src/tsconfig.app.json", - "src/tsconfig.spec.json" - ], - "exclude": [ - "**/node_modules/**" - ] - } } - } }, - "dashboard-e2e": { - "root": "e2e/", - "projectType": "application", - "prefix": "", - "architect": { - "e2e": { - "builder": "@angular-devkit/build-angular:protractor", - "options": { - "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "dashboard:serve" - }, - "configurations": { - "production": { - "devServerTarget": "dashboard:serve:production" - } - } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": "e2e/tsconfig.e2e.json", - "exclude": [ - "**/node_modules/**" - ] - } - } - } - } - }, - "defaultProject": "dashboard" -} \ No newline at end of file + "defaultProject": "dashboard" +} diff --git a/build_utils b/build_utils new file mode 160000 index 00000000..9b664082 --- /dev/null +++ b/build_utils @@ -0,0 +1 @@ +Subproject commit 9b664082ddc8ec8cdfbe7513d54e433d24198cc2 diff --git a/containerpilot.json b/containerpilot.json new file mode 100644 index 00000000..8d50b6d5 --- /dev/null +++ b/containerpilot.json @@ -0,0 +1,13 @@ +{ + "consul": "{{ .CONSUL_ADDR }}", + "services": [ + { + "name": "{{ .SERVICE_NAME }}", + "port": 8080, + "health": "/usr/bin/curl --silent --show-error --output /dev/null localhost:8080", + "poll": 1, + "ttl": 2, + "interfaces": ["inet6", "inet"] + } + ] +} diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js index 86776a39..532a8735 100644 --- a/e2e/protractor.conf.js +++ b/e2e/protractor.conf.js @@ -4,25 +4,23 @@ const { SpecReporter } = require('jasmine-spec-reporter'); exports.config = { - allScriptsTimeout: 11000, - specs: [ - './src/**/*.e2e-spec.ts' - ], - capabilities: { - 'browserName': 'chrome' - }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - onPrepare() { - require('ts-node').register({ - project: require('path').join(__dirname, './tsconfig.e2e.json') - }); - jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } -}; \ No newline at end of file + allScriptsTimeout: 11000, + specs: ['./src/**/*.e2e-spec.ts'], + capabilities: { + browserName: 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: require('path').join(__dirname, './tsconfig.e2e.json') + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/e2e/src/.gitkeep b/e2e/src/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts deleted file mode 100644 index b7535d67..00000000 --- a/e2e/src/app.e2e-spec.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { AppPage } from './app.po'; - -describe('workspace-project App', () => { - let page: AppPage; - - beforeEach(() => { - page = new AppPage(); - }); - - it('should display welcome message', () => { - page.navigateTo(); - expect(page.getTitleText()).toEqual('Welcome to dashboard!'); - }); -}); diff --git a/e2e/src/app.po.ts b/e2e/src/app.po.ts deleted file mode 100644 index 72e463a3..00000000 --- a/e2e/src/app.po.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { browser, by, element } from 'protractor'; - -export class AppPage { - navigateTo() { - return browser.get('/'); - } - - getTitleText() { - return element(by.css('app-root h1')).getText(); - } -} diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.e2e.json index a6dd6220..2eee41fa 100644 --- a/e2e/tsconfig.e2e.json +++ b/e2e/tsconfig.e2e.json @@ -1,13 +1,9 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/app", - "module": "commonjs", - "target": "es5", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] - } -} \ No newline at end of file + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "commonjs", + "target": "es5", + "types": ["jasmine", "jasminewd2", "node"] + } +} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..86795116 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 8080; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/package-lock.json b/package-lock.json index 294c418e..30d1525a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -149,6 +149,23 @@ "tslib": "^1.9.0" } }, + "@angular/cdk": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-7.1.0.tgz", + "integrity": "sha512-dY740pKcIRtKr6n6NomrgqfdEj988urTZ9I/bfJjxF5fdhnSjyhEvDlB55EHsrF+bTTZbZXRmv7AwOQ9GJnD9w==", + "requires": { + "parse5": "^5.0.0", + "tslib": "^1.7.1" + }, + "dependencies": { + "parse5": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==", + "optional": true + } + } + }, "@angular/cli": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/@angular/cli/-/cli-7.1.0.tgz", @@ -541,6 +558,14 @@ "integrity": "sha512-dgYCD4Kw6j14hPykprSkMJNCo05dKu+JroMR84/PA/J+weN39nAUj4+/TV4oElbRK2Mr/xtHzSkb259y3Rwm/Q==", "dev": true }, + "@angular/material": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@angular/material/-/material-7.1.0.tgz", + "integrity": "sha512-bgotNpSfGLjNZ1AcTyhs6XS7trF4I7UHwQmfa0l8y3Gf9plwErPDfQe2XqnayRyG9nTwHj9f1lQ45X5mr3/0/A==", + "requires": { + "tslib": "^1.7.1" + } + }, "@angular/platform-browser": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-7.1.0.tgz", @@ -7670,6 +7695,12 @@ "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", "dev": true }, + "prettier": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.2.tgz", + "integrity": "sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==", + "dev": true + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", diff --git a/package.json b/package.json index df1df6f0..e5e7fc71 100644 --- a/package.json +++ b/package.json @@ -3,19 +3,23 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve", - "build": "ng build", + "start": "ng serve --port 8000", + "build": "ng build --prod", "test": "ng test", "lint": "ng lint", - "e2e": "ng e2e" + "e2e": "ng e2e", + "prettier": "prettier \"**/*.{html,js,ts,css,md,json,prettierrc}\" --write", + "check": "prettier \"**/*.{html,js,ts,css,md,json,prettierrc}\" --list-different" }, "private": true, "dependencies": { "@angular/animations": "~7.1.0", + "@angular/cdk": "~7.1.0", "@angular/common": "~7.1.0", "@angular/compiler": "~7.1.0", "@angular/core": "~7.1.0", "@angular/forms": "~7.1.0", + "@angular/material": "~7.1.0", "@angular/platform-browser": "~7.1.0", "@angular/platform-browser-dynamic": "~7.1.0", "@angular/router": "~7.1.0", @@ -29,9 +33,9 @@ "@angular/cli": "~7.1.0", "@angular/compiler-cli": "~7.1.0", "@angular/language-service": "~7.1.0", - "@types/node": "~8.9.4", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", + "@types/node": "~8.9.4", "codelyzer": "~4.5.0", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", @@ -40,6 +44,7 @@ "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", + "prettier": "~1.15.2", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d425c6f5..1c202150 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,7 +4,7 @@ import { Routes, RouterModule } from '@angular/router'; const routes: Routes = []; @NgModule({ - imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/src/app/app.component.html b/src/app/app.component.html index 0f3d9d8b..059ec18c 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,21 +1 @@ - -
-

- Welcome to {{ title }}! -

- Angular Logo -
-

Here are some links to help you start:

- - - +

Welcome to {{ title }}!

diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index fc206d53..00000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - RouterTestingModule - ], - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have as title 'dashboard'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('dashboard'); - }); - - it('should render title in a h1 tag', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to dashboard!'); - }); -}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ab031c8a..db724436 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; @Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] }) export class AppComponent { - title = 'dashboard'; + title = 'dashboard'; } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2c3ba299..69d92094 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,18 +1,14 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; @NgModule({ - declarations: [ - AppComponent - ], - imports: [ - BrowserModule, - AppRoutingModule - ], - providers: [], - bootstrap: [AppComponent] + declarations: [AppComponent], + imports: [BrowserModule, BrowserAnimationsModule, AppRoutingModule], + providers: [], + bootstrap: [AppComponent] }) -export class AppModule { } +export class AppModule {} diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3612073b..5d083316 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,3 @@ export const environment = { - production: true + production: true }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7b4f817a..6b323087 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,7 +3,7 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false }; /* diff --git a/src/index.html b/src/index.html index 2f553d9f..802d6e5f 100644 --- a/src/index.html +++ b/src/index.html @@ -1,14 +1,16 @@ - + - - - Dashboard - + + + Dashboard + - - - - - - + + + + + + + + diff --git a/src/karma.conf.js b/src/karma.conf.js index ee9caa15..8c8deec6 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -1,31 +1,31 @@ // Karma configuration file, see link for more information // https://karma-runner.github.io/1.0/config/configuration-file.html -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - dir: require('path').join(__dirname, '../coverage'), - reports: ['html', 'lcovonly', 'text-summary'], - fixWebpackSourcePaths: true - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false - }); -}; \ No newline at end of file +module.exports = function(config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../coverage'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/src/main.ts b/src/main.ts index c7b673cf..0435bd2e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,8 +5,9 @@ import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; if (environment.production) { - enableProdMode(); + enableProdMode(); } -platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch(err => console.error(err)); diff --git a/src/polyfills.ts b/src/polyfills.ts index ee8b84da..b9a73c9a 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -59,11 +59,11 @@ * user can disable parts of macroTask/DomEvents patch by setting following flags */ - // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames +// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame +// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick +// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - /* +/* * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * with the following flag, it will bypass `zone.js` patch for IE/Edge */ @@ -72,8 +72,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. - +import 'zone.js/dist/zone'; // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS diff --git a/src/styles.css b/src/styles.css deleted file mode 100644 index 90d4ee00..00000000 --- a/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/src/styles.scss b/src/styles.scss new file mode 100644 index 00000000..b948608d --- /dev/null +++ b/src/styles.scss @@ -0,0 +1,11 @@ +@import '~@angular/material/theming'; + +@include mat-core(); + +$primary: mat-palette($mat-indigo); +$accent: mat-palette($mat-pink, A200, A100, A400); +$warn: mat-palette($mat-red); + +$theme: mat-light-theme($primary, $accent, $warn); + +@include angular-material-theme($theme); diff --git a/src/test.ts b/src/test.ts index 16317897..da9049dc 100644 --- a/src/test.ts +++ b/src/test.ts @@ -2,18 +2,12 @@ import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; declare const require: any; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 190fd300..65d32a36 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -1,11 +1,8 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/app", - "types": [] - }, - "exclude": [ - "test.ts", - "**/*.spec.ts" - ] + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "types": [] + }, + "exclude": ["test.ts", "**/*.spec.ts"] } diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json index de773363..5085225c 100644 --- a/src/tsconfig.spec.json +++ b/src/tsconfig.spec.json @@ -1,18 +1,9 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/spec", - "types": [ - "jasmine", - "node" - ] - }, - "files": [ - "test.ts", - "polyfills.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "types": ["jasmine", "node"] + }, + "files": ["test.ts", "polyfills.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] } diff --git a/src/tslint.json b/src/tslint.json index 52e2c1a5..615d2bcd 100644 --- a/src/tslint.json +++ b/src/tslint.json @@ -1,17 +1,7 @@ { "extends": "../tslint.json", "rules": { - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ] + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"] } } diff --git a/tsconfig.json b/tsconfig.json index b271fd9f..d4a216eb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,17 @@ { - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "module": "es2015", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "target": "es5", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2018", - "dom" - ] - } + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "module": "es2015", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": true, + "target": "es5", + "typeRoots": ["node_modules/@types"], + "lib": ["es2018", "dom"] + } } diff --git a/tslint.json b/tslint.json index 6ddb6b29..9f34516b 100644 --- a/tslint.json +++ b/tslint.json @@ -1,131 +1,55 @@ { - "rulesDirectory": [ - "node_modules/codelyzer" - ], - "rules": { - "arrow-return-shorthand": true, - "callable-types": true, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "deprecation": { - "severity": "warn" - }, - "eofline": true, - "forin": true, - "import-blacklist": [ - true, - "rxjs/Rx" - ], - "import-spacing": true, - "indent": [ - true, - "spaces" - ], - "interface-over-type-literal": true, - "label-position": true, - "max-line-length": [ - true, - 140 - ], - "member-access": false, - "member-ordering": [ - true, - { - "order": [ - "static-field", - "instance-field", - "static-method", - "instance-method" - ] - } - ], - "no-arg": true, - "no-bitwise": true, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-empty": false, - "no-empty-interface": true, - "no-eval": true, - "no-inferrable-types": [ - true, - "ignore-params" - ], - "no-misused-new": true, - "no-non-null-assertion": true, - "no-redundant-jsdoc": true, - "no-shadowed-variable": true, - "no-string-literal": false, - "no-string-throw": true, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unnecessary-initializer": true, - "no-unused-expression": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "prefer-const": true, - "quotemark": [ - true, - "single" - ], - "radix": true, - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "unified-signatures": true, - "variable-name": false, - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ], - "no-output-on-prefix": true, - "use-input-property-decorator": true, - "use-output-property-decorator": true, - "use-host-property-decorator": true, - "no-input-rename": true, - "no-output-rename": true, - "use-life-cycle-interface": true, - "use-pipe-transform-interface": true, - "component-class-suffix": true, - "directive-class-suffix": true - } + "rulesDirectory": ["node_modules/codelyzer"], + "rules": { + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "forin": true, + "import-blacklist": [true, "rxjs/Rx"], + "interface-over-type-literal": true, + "label-position": true, + "member-access": false, + "member-ordering": [ + true, + { + "order": ["static-field", "instance-field", "static-method", "instance-method"] + } + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [true, "ignore-params"], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "prefer-const": true, + "radix": true, + "triple-equals": [true, "allow-null-check"], + "unified-signatures": true, + "variable-name": false, + "no-output-on-prefix": true, + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true + } }