From f70df9f7812aad042e70400407e51171ac2cee2c Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Fri, 19 Apr 2019 17:31:52 +0200
Subject: [PATCH 01/74] Updated to the latest spring
---
server/pom.xml | 2 +-
.../service/impl/AuthorityServiceImpl.java | 72 +++++++++----------
.../bfwg/service/impl/UserServiceImpl.java | 2 +-
3 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/server/pom.xml b/server/pom.xml
index 77c7e458e..62a2c8e13 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -14,7 +14,7 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.8.RELEASE
+ 2.1.4.RELEASE
diff --git a/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java b/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java
index 07801f97c..63ac1f5f2 100644
--- a/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java
+++ b/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java
@@ -1,36 +1,36 @@
-package com.bfwg.service.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.bfwg.model.Authority;
-import com.bfwg.repository.AuthorityRepository;
-import com.bfwg.service.AuthorityService;
-
-@Service
-public class AuthorityServiceImpl implements AuthorityService {
-
- @Autowired
- private AuthorityRepository authorityRepository;
-
- @Override
- public List findById(Long id) {
- // TODO Auto-generated method stub
-
- Authority auth = this.authorityRepository.findOne(id);
- List auths = new ArrayList<>();
- auths.add(auth);
- return auths;
- }
-
- @Override
- public List findByname(String name) {
- // TODO Auto-generated method stub
- Authority auth = this.authorityRepository.findByName(name);
- List auths = new ArrayList<>();
- auths.add(auth);
- return auths;
- }
-
-}
+package com.bfwg.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.bfwg.model.Authority;
+import com.bfwg.repository.AuthorityRepository;
+import com.bfwg.service.AuthorityService;
+
+@Service
+public class AuthorityServiceImpl implements AuthorityService {
+
+ @Autowired
+ private AuthorityRepository authorityRepository;
+
+ @Override
+ public List findById(Long id) {
+ // TODO Auto-generated method stub
+
+ Authority auth = this.authorityRepository.getOne(id);
+ List auths = new ArrayList<>();
+ auths.add(auth);
+ return auths;
+ }
+
+ @Override
+ public List findByname(String name) {
+ // TODO Auto-generated method stub
+ Authority auth = this.authorityRepository.findByName(name);
+ List auths = new ArrayList<>();
+ auths.add(auth);
+ return auths;
+ }
+
+}
diff --git a/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java b/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java
index 3e61de322..93c69c1f6 100644
--- a/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java
+++ b/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java
@@ -47,7 +47,7 @@ public User findByUsername(String username) throws UsernameNotFoundException {
@PreAuthorize("hasRole('ADMIN')")
public User findById(Long id) throws AccessDeniedException {
- User u = userRepository.findOne(id);
+ User u = userRepository.getOne(id);
return u;
}
From 6b17369ec1ec463cda80b5c1213538514ed13def Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Fri, 19 Apr 2019 19:39:56 +0200
Subject: [PATCH 02/74] Updated to angular 7
---
frontend/.angular-cli.json | 57 --------
frontend/.editorconfig | 2 +-
frontend/angular.json | 138 ++++++++++++++++++
frontend/karma.conf.js | 14 +-
frontend/package.json | 80 +++++-----
.../change-password.component.html | 8 +-
.../change-password.component.ts | 27 ++--
frontend/src/app/login/login.component.html | 8 +-
frontend/src/app/login/login.component.ts | 62 ++++----
frontend/src/app/service/api.service.ts | 25 ++--
frontend/src/app/service/auth.service.ts | 37 ++---
frontend/src/app/service/user.service.ts | 4 +-
frontend/src/app/signup/signup.component.html | 18 +--
frontend/src/app/signup/signup.component.ts | 5 +-
frontend/src/browserslist | 11 ++
frontend/src/index.html | 1 +
frontend/src/karma.conf.js | 32 ++++
frontend/src/main.ts | 1 +
frontend/src/polyfills.ts | 71 ++++-----
frontend/src/styles.css | 3 +
frontend/src/tsconfig.app.json | 2 -
frontend/src/tsconfig.spec.json | 6 +-
frontend/src/tslint.json | 17 +++
frontend/src/typings.d.ts | 5 -
frontend/tsconfig.json | 6 +-
frontend/tslint.json | 109 +++++---------
26 files changed, 413 insertions(+), 336 deletions(-)
delete mode 100644 frontend/.angular-cli.json
create mode 100644 frontend/angular.json
create mode 100644 frontend/src/browserslist
create mode 100644 frontend/src/karma.conf.js
create mode 100644 frontend/src/tslint.json
delete mode 100644 frontend/src/typings.d.ts
diff --git a/frontend/.angular-cli.json b/frontend/.angular-cli.json
deleted file mode 100644
index f266ffd30..000000000
--- a/frontend/.angular-cli.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
- "project": {
- "name": "angular-spring-starter"
- },
- "apps": [
- {
- "root": "src",
- "outDir": "../server/src/main/resources/static",
- "assets": [
- "assets",
- "favicon.ico"
- ],
- "index": "index.html",
- "main": "main.ts",
- "polyfills": "polyfills.ts",
- "test": "test.ts",
- "tsconfig": "tsconfig.app.json",
- "testTsconfig": "tsconfig.spec.json",
- "prefix": "app",
- "styles": [
- "styles.css"
- ],
- "scripts": [],
- "environmentSource": "environments/environment.ts",
- "environments": {
- "dev": "environments/environment.ts",
- "prod": "environments/environment.prod.ts"
- }
- }
- ],
- "e2e": {
- "protractor": {
- "config": "./protractor.conf.js"
- }
- },
- "lint": [
- {
- "project": "src/tsconfig.app.json"
- },
- {
- "project": "src/tsconfig.spec.json"
- },
- {
- "project": "e2e/tsconfig.e2e.json"
- }
- ],
- "test": {
- "karma": {
- "config": "./karma.conf.js"
- }
- },
- "defaults": {
- "styleExt": "css",
- "component": {}
- }
-}
diff --git a/frontend/.editorconfig b/frontend/.editorconfig
index 6e87a003d..e89330a61 100644
--- a/frontend/.editorconfig
+++ b/frontend/.editorconfig
@@ -1,4 +1,4 @@
-# Editor configuration, see http://editorconfig.org
+# Editor configuration, see https://editorconfig.org
root = true
[*]
diff --git a/frontend/angular.json b/frontend/angular.json
new file mode 100644
index 000000000..6660bf670
--- /dev/null
+++ b/frontend/angular.json
@@ -0,0 +1,138 @@
+{
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
+ "version": 1,
+ "newProjectRoot": "projects",
+ "projects": {
+ "testAngular": {
+ "root": "",
+ "sourceRoot": "src",
+ "projectType": "application",
+ "prefix": "app",
+ "schematics": {},
+ "architect": {
+ "build": {
+ "builder": "@angular-devkit/build-angular:browser",
+ "options": {
+ "outputPath": "dist/testAngular",
+ "index": "src/index.html",
+ "main": "src/main.ts",
+ "polyfills": "src/polyfills.ts",
+ "tsConfig": "src/tsconfig.app.json",
+ "assets": [
+ "src/favicon.ico",
+ "src/assets"
+ ],
+ "styles": [
+ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
+ "src/styles.css"
+ ],
+ "scripts": [],
+ "es5BrowserSupport": true
+ },
+ "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": "testAngular:build"
+ },
+ "configurations": {
+ "production": {
+ "browserTarget": "testAngular:build:production"
+ }
+ }
+ },
+ "extract-i18n": {
+ "builder": "@angular-devkit/build-angular:extract-i18n",
+ "options": {
+ "browserTarget": "testAngular: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": [
+ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
+ "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/**"
+ ]
+ }
+ }
+ }
+ },
+ "testAngular-e2e": {
+ "root": "e2e/",
+ "projectType": "application",
+ "prefix": "",
+ "architect": {
+ "e2e": {
+ "builder": "@angular-devkit/build-angular:protractor",
+ "options": {
+ "protractorConfig": "e2e/protractor.conf.js",
+ "devServerTarget": "testAngular:serve"
+ },
+ "configurations": {
+ "production": {
+ "devServerTarget": "testAngular:serve:production"
+ }
+ }
+ },
+ "lint": {
+ "builder": "@angular-devkit/build-angular:tslint",
+ "options": {
+ "tsConfig": "e2e/tsconfig.e2e.json",
+ "exclude": [
+ "**/node_modules/**"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "defaultProject": "testAngular"
+}
\ No newline at end of file
diff --git a/frontend/karma.conf.js b/frontend/karma.conf.js
index 84b4cd5ac..c3b764021 100644
--- a/frontend/karma.conf.js
+++ b/frontend/karma.conf.js
@@ -4,33 +4,31 @@
module.exports = function (config) {
config.set({
basePath: '',
- frameworks: ['jasmine', '@angular/cli'],
+ 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/cli/plugins/karma')
+ require('@angular-devkit/build-angular/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
- { pattern: './src/test.ts', watched: false }
+
],
preprocessors: {
- './src/test.ts': ['@angular/cli']
+
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
- reports: [ 'html', 'lcovonly' ],
+ dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
- angularCli: {
- environment: 'dev'
- },
+
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
diff --git a/frontend/package.json b/frontend/package.json
index 230115011..994e588c4 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,6 @@
{
- "name": "angular-spring-starter-ui",
- "version": "0.1.1",
- "license": "MIT",
+ "name": "test-angular",
+ "version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
@@ -12,45 +11,44 @@
},
"private": true,
"dependencies": {
- "@angular/animations": "5.0.2",
- "@angular/common": "5.0.2",
- "@angular/compiler": "5.0.2",
- "@angular/core": "5.0.2",
- "@angular/forms": "5.0.2",
- "@angular/http": "5.0.2",
- "@angular/material": "5.0.0-rc.1",
- "@angular/cdk": "5.0.0-rc.1",
- "@angular/platform-browser": "5.0.2",
- "@angular/platform-browser-dynamic": "5.0.2",
- "@angular/platform-server": "5.0.2",
- "@angular/router": "5.0.2",
- "@angular/flex-layout": "2.0.0-beta.10-4905443",
- "core-js": "2.5.1",
- "hammerjs": "2.0.8",
- "rxjs": "5.5.2",
- "zone.js": "0.8.18"
+ "@angular/animations": "~7.2.0",
+ "@angular/cdk": "~7.3.7",
+ "@angular/common": "~7.2.0",
+ "@angular/compiler": "~7.2.0",
+ "@angular/core": "~7.2.0",
+ "@angular/flex-layout": "^7.0.0-beta.24",
+ "@angular/forms": "~7.2.0",
+ "@angular/http": "^7.2.13",
+ "@angular/material": "^7.3.7",
+ "@angular/platform-browser": "~7.2.0",
+ "@angular/platform-browser-dynamic": "~7.2.0",
+ "@angular/router": "~7.2.0",
+ "core-js": "^2.5.4",
+ "hammerjs": "^2.0.8",
+ "rxjs": "^6.3.3",
+ "rxjs-compat": "^6.4.0",
+ "tslib": "^1.9.0",
+ "zone.js": "~0.8.26"
},
"devDependencies": {
- "@angular-devkit/core": "^0.6.3",
- "@angular/cli": "1.5.3",
- "@angular/compiler-cli": "5.0.2",
- "@angular/language-service": "5.0.2",
- "@types/hammerjs": "2.0.34",
- "@types/jasmine": "2.5.54",
- "@types/jasminewd2": "2.0.3",
- "@types/node": "6.0.90",
- "codelyzer": "3.2.2",
- "jasmine-core": "2.6.4",
- "jasmine-spec-reporter": "4.1.1",
- "karma": "1.7.1",
- "karma-chrome-launcher": "2.1.1",
- "karma-cli": "1.0.1",
- "karma-coverage-istanbul-reporter": "1.3.0",
- "karma-jasmine": "1.1.0",
- "karma-jasmine-html-reporter": "0.2.2",
- "protractor": "5.1.2",
- "ts-node": "3.0.6",
- "tslint": "5.7.0",
- "typescript": "2.4.2"
+ "@angular-devkit/build-angular": "~0.13.0",
+ "@angular/cli": "~7.3.8",
+ "@angular/compiler-cli": "~7.2.0",
+ "@angular/language-service": "~7.2.0",
+ "@types/node": "~8.9.4",
+ "@types/jasmine": "~2.8.8",
+ "@types/jasminewd2": "~2.0.3",
+ "codelyzer": "~4.5.0",
+ "jasmine-core": "~2.99.1",
+ "jasmine-spec-reporter": "~4.2.1",
+ "karma": "~4.0.0",
+ "karma-chrome-launcher": "~2.2.0",
+ "karma-coverage-istanbul-reporter": "~2.0.1",
+ "karma-jasmine": "~1.1.2",
+ "karma-jasmine-html-reporter": "^0.2.2",
+ "protractor": "~5.4.0",
+ "ts-node": "~7.0.0",
+ "tslint": "~5.11.0",
+ "typescript": "~3.2.2"
}
}
diff --git a/frontend/src/app/change-password/change-password.component.html b/frontend/src/app/change-password/change-password.component.html
index b080f4a6d..3ddd8c368 100644
--- a/frontend/src/app/change-password/change-password.component.html
+++ b/frontend/src/app/change-password/change-password.component.html
@@ -4,12 +4,12 @@
{{notification.msgBody}}
diff --git a/frontend/src/app/change-password/change-password.component.ts b/frontend/src/app/change-password/change-password.component.ts
index b08085c0f..f94bde810 100644
--- a/frontend/src/app/change-password/change-password.component.ts
+++ b/frontend/src/app/change-password/change-password.component.ts
@@ -1,8 +1,9 @@
-import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { AuthService } from 'app/service';
-import { Router } from '@angular/router';
-import { DisplayMessage } from '../shared/models/display-message';
+import {Component, OnInit} from '@angular/core';
+import {FormBuilder, FormGroup, Validators} from '@angular/forms';
+import {Router} from '@angular/router';
+import {DisplayMessage} from '../shared/models/display-message';
+import {AuthService} from '../service';
+import {mergeMap} from 'rxjs/operators';
@Component({
selector: 'app-change-password',
@@ -50,15 +51,13 @@ export class ChangePasswordComponent implements OnInit {
this.submitted = true;
this.authService.changePassowrd(this.form.value)
- // show me the animation
- .delay(1000)
- .mergeMap(() => this.authService.logout())
- .subscribe(() => {
- this.router.navigate(['/login', { msgType: 'success', msgBody: 'Success! Please sign in with your new password.'}]);
- }, error => {
- this.submitted = false;
- this.notification = { msgType: 'error', msgBody: 'Invalid old password.'};
- });
+ .pipe(mergeMap(() => this.authService.logout()))
+ .subscribe(() => {
+ this.router.navigate(['/login', {msgType: 'success', msgBody: 'Success! Please sign in with your new password.'}]);
+ }, error => {
+ this.submitted = false;
+ this.notification = {msgType: 'error', msgBody: 'Invalid old password.'};
+ });
}
diff --git a/frontend/src/app/login/login.component.html b/frontend/src/app/login/login.component.html
index 0a8ed29b9..1c1f00c41 100644
--- a/frontend/src/app/login/login.component.html
+++ b/frontend/src/app/login/login.component.html
@@ -15,12 +15,12 @@ {{title}}
{{notification.msgBody}}
diff --git a/frontend/src/app/login/login.component.ts b/frontend/src/app/login/login.component.ts
index 6fdf0d215..465cd7776 100644
--- a/frontend/src/app/login/login.component.ts
+++ b/frontend/src/app/login/login.component.ts
@@ -1,16 +1,10 @@
-import { Inject } from '@angular/core';
-import { Component, OnInit, OnDestroy } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { Router, ActivatedRoute } from '@angular/router';
-import { DisplayMessage } from '../shared/models/display-message';
-import { Subscription } from 'rxjs/Subscription';
-import {
- UserService,
- AuthService
-} from '../service';
-
-import { Observable } from 'rxjs/Observable';
-import { Subject } from 'rxjs/Subject';
+import {Component, OnDestroy, OnInit} from '@angular/core';
+import {FormBuilder, FormGroup, Validators} from '@angular/forms';
+import {ActivatedRoute, Router} from '@angular/router';
+import {DisplayMessage} from '../shared/models/display-message';
+import {AuthService, UserService} from '../service';
+import {Subject} from 'rxjs/Subject';
+import {takeUntil} from 'rxjs/operators';
@Component({
selector: 'app-login',
@@ -50,10 +44,10 @@ export class LoginComponent implements OnInit, OnDestroy {
ngOnInit() {
this.route.params
- .takeUntil(this.ngUnsubscribe)
- .subscribe((params: DisplayMessage) => {
- this.notification = params;
- });
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe((params: DisplayMessage) => {
+ this.notification = params;
+ });
// get return url from route parameters or default to '/'
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
this.form = this.formBuilder.group({
@@ -69,14 +63,14 @@ export class LoginComponent implements OnInit, OnDestroy {
onResetCredentials() {
this.userService.resetCredentials()
- .takeUntil(this.ngUnsubscribe)
- .subscribe(res => {
- if (res.result === 'success') {
- alert('Password has been reset to 123 for all accounts');
- } else {
- alert('Server error');
- }
- });
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe(res => {
+ if (res.result === 'success') {
+ alert('Password has been reset to 123 for all accounts');
+ } else {
+ alert('Server error');
+ }
+ });
}
repository() {
@@ -91,16 +85,14 @@ export class LoginComponent implements OnInit, OnDestroy {
this.submitted = true;
this.authService.login(this.form.value)
- // show me the animation
- .delay(1000)
- .subscribe(data => {
- this.userService.getMyInfo().subscribe();
- this.router.navigate([this.returnUrl]);
- },
- error => {
- this.submitted = false;
- this.notification = { msgType: 'error', msgBody: 'Incorrect username or password.' };
- });
+ .subscribe(data => {
+ this.userService.getMyInfo().subscribe();
+ this.router.navigate([this.returnUrl]);
+ },
+ error => {
+ this.submitted = false;
+ this.notification = {msgType: 'error', msgBody: 'Incorrect username or password.'};
+ });
}
diff --git a/frontend/src/app/service/api.service.ts b/frontend/src/app/service/api.service.ts
index 88c0ba980..6644307f5 100644
--- a/frontend/src/app/service/api.service.ts
+++ b/frontend/src/app/service/api.service.ts
@@ -1,9 +1,8 @@
-import { HttpClient, HttpHeaders, HttpResponse, HttpRequest, HttpEventType, HttpParams } from '@angular/common/http';
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/Rx';
-import 'rxjs/add/observable/throw';
-import { serialize } from 'app/shared/utilities/serialize';
+import {HttpClient, HttpHeaders, HttpRequest, HttpResponse} from '@angular/common/http';
+import {Injectable} from '@angular/core';
+import {serialize} from '../shared/utilities/serialize';
+import {Observable} from 'rxjs';
+import {catchError, filter, map} from 'rxjs/operators';
export enum RequestMethod {
Get = 'GET',
@@ -19,11 +18,12 @@ export enum RequestMethod {
export class ApiService {
headers = new HttpHeaders({
- 'Accept': 'application/json',
+ Accept: 'application/json',
'Content-Type': 'application/json'
});
- constructor( private http: HttpClient) { }
+ constructor(private http: HttpClient) {
+ }
get(path: string, args?: any): Observable {
const options = {
@@ -36,7 +36,7 @@ export class ApiService {
}
return this.http.get(path, options)
- .catch(this.checkError.bind(this));
+ .pipe(catchError(this.checkError.bind(this)));
}
post(path: string, body: any, customHeaders?: HttpHeaders): Observable {
@@ -57,10 +57,9 @@ export class ApiService {
withCredentials: true
});
- return this.http.request(req)
- .filter(response => response instanceof HttpResponse)
- .map((response: HttpResponse) => response.body)
- .catch(error => this.checkError(error));
+ return this.http.request(req).pipe(filter(response => response instanceof HttpResponse))
+ .pipe(map((response: HttpResponse) => response.body))
+ .pipe(catchError(error => this.checkError(error)));
}
// Display error if logged in, otherwise redirect to IDP
diff --git a/frontend/src/app/service/auth.service.ts b/frontend/src/app/service/auth.service.ts
index 0f0d97a14..4f5feb675 100644
--- a/frontend/src/app/service/auth.service.ts
+++ b/frontend/src/app/service/auth.service.ts
@@ -1,9 +1,9 @@
-import { Injectable } from '@angular/core';
-import { HttpHeaders } from '@angular/common/http';
-import { ApiService } from './api.service';
-import { UserService } from './user.service';
-import { ConfigService } from './config.service';
-import { Observable } from 'rxjs/Observable';
+import {Injectable} from '@angular/core';
+import {HttpHeaders} from '@angular/common/http';
+import {ApiService} from './api.service';
+import {UserService} from './user.service';
+import {ConfigService} from './config.service';
+import {map} from 'rxjs/operators';
@Injectable()
export class AuthService {
@@ -12,7 +12,8 @@ export class AuthService {
private apiService: ApiService,
private userService: UserService,
private config: ConfigService,
- ) { }
+ ) {
+ }
login(user) {
const loginHeaders = new HttpHeaders({
@@ -20,27 +21,29 @@ export class AuthService {
'Content-Type': 'application/x-www-form-urlencoded'
});
const body = `username=${user.username}&password=${user.password}`;
- return this.apiService.post(this.config.login_url, body, loginHeaders).map(() => {
- console.log("Login success");
+ return this.apiService.post(this.config.login_url, body, loginHeaders)
+ .pipe(map(() => {
+ console.log('Login success');
this.userService.getMyInfo().subscribe();
- });
+ }));
}
- signup(user){
+ signup(user) {
const signupHeaders = new HttpHeaders({
'Accept': 'application/json',
'Content-Type': 'application/json'
});
- return this.apiService.post(this.config.signup_url, JSON.stringify(user), signupHeaders).map(() =>{
- console.log("Sign up success");
- });
+ return this.apiService.post(this.config.signup_url, JSON.stringify(user), signupHeaders)
+ .pipe(map(() => {
+ console.log('Sign up success');
+ }));
}
-
+
logout() {
return this.apiService.post(this.config.logout_url, {})
- .map(() => {
+ .pipe(map(() => {
this.userService.currentUser = null;
- });
+ }));
}
changePassowrd(passwordChanger) {
diff --git a/frontend/src/app/service/user.service.ts b/frontend/src/app/service/user.service.ts
index a93c6935c..49acc29ae 100644
--- a/frontend/src/app/service/user.service.ts
+++ b/frontend/src/app/service/user.service.ts
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { Headers } from '@angular/http';
import { ApiService } from './api.service';
import { ConfigService } from './config.service';
+import {map} from 'rxjs/operators';
@Injectable()
export class UserService {
@@ -32,7 +33,8 @@ export class UserService {
}
getMyInfo() {
- return this.apiService.get(this.config.whoami_url).map(user => this.currentUser = user);
+ return this.apiService.get(this.config.whoami_url)
+ .pipe(map(user => this.currentUser = user));
}
getAll() {
diff --git a/frontend/src/app/signup/signup.component.html b/frontend/src/app/signup/signup.component.html
index bb7d3d3c9..d93852d57 100644
--- a/frontend/src/app/signup/signup.component.html
+++ b/frontend/src/app/signup/signup.component.html
@@ -15,22 +15,22 @@ {{ title }}
{{notification.msgBody}}
@@ -53,4 +53,4 @@ {{ title }}
-
\ No newline at end of file
+
diff --git a/frontend/src/app/signup/signup.component.ts b/frontend/src/app/signup/signup.component.ts
index 3754bb930..db59d22dd 100644
--- a/frontend/src/app/signup/signup.component.ts
+++ b/frontend/src/app/signup/signup.component.ts
@@ -11,6 +11,7 @@ import {
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
+import {takeUntil} from 'rxjs/operators';
@Component({
selector: 'app-signup',
@@ -50,7 +51,7 @@ export class SignupComponent implements OnInit, OnDestroy {
ngOnInit() {
this.route.params
- .takeUntil(this.ngUnsubscribe)
+ .pipe(takeUntil(this.ngUnsubscribe))
.subscribe((params: DisplayMessage) => {
this.notification = params;
});
@@ -81,8 +82,6 @@ export class SignupComponent implements OnInit, OnDestroy {
this.submitted = true;
this.authService.signup(this.form.value)
- // show me the animation
- .delay(1000)
.subscribe(data => {
console.log(data);
this.authService.login(this.form.value).subscribe(data =>{
diff --git a/frontend/src/browserslist b/frontend/src/browserslist
new file mode 100644
index 000000000..37371cb04
--- /dev/null
+++ b/frontend/src/browserslist
@@ -0,0 +1,11 @@
+# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
+# For additional information regarding the format and rule options, please see:
+# https://github.com/browserslist/browserslist#queries
+#
+# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
+
+> 0.5%
+last 2 versions
+Firefox ESR
+not dead
+not IE 9-11
\ No newline at end of file
diff --git a/frontend/src/index.html b/frontend/src/index.html
index 3fc85ee9f..234d83e38 100644
--- a/frontend/src/index.html
+++ b/frontend/src/index.html
@@ -16,6 +16,7 @@
+
Loading...
diff --git a/frontend/src/karma.conf.js b/frontend/src/karma.conf.js
new file mode 100644
index 000000000..ee2a48ad3
--- /dev/null
+++ b/frontend/src/karma.conf.js
@@ -0,0 +1,32 @@
+// 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/testAngular'),
+ reports: ['html', 'lcovonly', 'text-summary'],
+ fixWebpackSourcePaths: true
+ },
+ reporters: ['progress', 'kjhtml'],
+ port: 9876,
+ colors: true,
+ logLevel: config.LOG_INFO,
+ autoWatch: true,
+ browsers: ['Chrome'],
+ singleRun: false,
+ restartOnFileChange: true
+ });
+};
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index a9ca1caf8..ba2d80345 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -1,3 +1,4 @@
+import 'hammerjs';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
diff --git a/frontend/src/polyfills.ts b/frontend/src/polyfills.ts
index 622efa015..75d639398 100644
--- a/frontend/src/polyfills.ts
+++ b/frontend/src/polyfills.ts
@@ -11,64 +11,53 @@
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
- * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
+ * Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
-/** IE9, IE10 and IE11 requires all of the following polyfills. **/
-// import 'core-js/es6/symbol';
-// import 'core-js/es6/object';
-// import 'core-js/es6/function';
-// import 'core-js/es6/parse-int';
-// import 'core-js/es6/parse-float';
-// import 'core-js/es6/number';
-// import 'core-js/es6/math';
-// import 'core-js/es6/string';
-// import 'core-js/es6/date';
-// import 'core-js/es6/array';
-// import 'core-js/es6/regexp';
-// import 'core-js/es6/map';
-// import 'core-js/es6/set';
-
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
-/** IE10 and IE11 requires the following to support `@angular/animation`. */
-// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
-
-
-/** Evergreen browsers require these. **/
-import 'core-js/es6/reflect';
-import 'core-js/es7/reflect';
-
-
-
-/** ALL Firefox browsers require the following to support `@angular/animation`. **/
+/**
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
+ */
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
-
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ * because those flags need to be set before `zone.js` being loaded, and webpack
+ * will put import in the top of bundle, so user need to create a separate file
+ * in this directory (for example: zone-flags.ts), and put the following flags
+ * into that file, and then add the following code before importing zone.js.
+ * import './zone-flags.ts';
+ *
+ * The flags allowed in zone-flags.ts are listed here.
+ *
+ * The following flags will work for all browsers.
+ *
+ * (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
+ *
+ * (window as any).__Zone_enable_cross_context_check = true;
+ *
+ */
/***************************************************************************************************
- * Zone JS is required by Angular itself.
+ * Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
-
/***************************************************************************************************
* APPLICATION IMPORTS
*/
-
-/**
- * Date, currency, decimal and percent pipes.
- * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
- */
-// import 'intl'; // Run `npm install --save intl`.
-
-/***************************************************************************************************
- * MATERIAL 2
- */
-import 'hammerjs/hammer';
diff --git a/frontend/src/styles.css b/frontend/src/styles.css
index c21739f3b..374e253ca 100644
--- a/frontend/src/styles.css
+++ b/frontend/src/styles.css
@@ -4,3 +4,6 @@
body {
margin: 0;
}
+
+html, body { height: 100%; }
+body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
diff --git a/frontend/src/tsconfig.app.json b/frontend/src/tsconfig.app.json
index 5e2507db5..190fd300b 100644
--- a/frontend/src/tsconfig.app.json
+++ b/frontend/src/tsconfig.app.json
@@ -2,8 +2,6 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
- "module": "es2015",
- "baseUrl": "",
"types": []
},
"exclude": [
diff --git a/frontend/src/tsconfig.spec.json b/frontend/src/tsconfig.spec.json
index 510e3f1fd..de7733630 100644
--- a/frontend/src/tsconfig.spec.json
+++ b/frontend/src/tsconfig.spec.json
@@ -2,16 +2,14 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
- "module": "commonjs",
- "target": "es5",
- "baseUrl": "",
"types": [
"jasmine",
"node"
]
},
"files": [
- "test.ts"
+ "test.ts",
+ "polyfills.ts"
],
"include": [
"**/*.spec.ts",
diff --git a/frontend/src/tslint.json b/frontend/src/tslint.json
new file mode 100644
index 000000000..aa7c3eeb7
--- /dev/null
+++ b/frontend/src/tslint.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../tslint.json",
+ "rules": {
+ "directive-selector": [
+ true,
+ "attribute",
+ "app",
+ "camelCase"
+ ],
+ "component-selector": [
+ true,
+ "element",
+ "app",
+ "kebab-case"
+ ]
+ }
+}
diff --git a/frontend/src/typings.d.ts b/frontend/src/typings.d.ts
deleted file mode 100644
index ef5c7bd62..000000000
--- a/frontend/src/typings.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/* SystemJS module definition */
-declare var module: NodeModule;
-interface NodeModule {
- id: string;
-}
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index a35a8ee3a..b271fd9f3 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -1,19 +1,21 @@
{
"compileOnSave": false,
"compilerOptions": {
+ "baseUrl": "./",
"outDir": "./dist/out-tsc",
- "baseUrl": "src",
"sourceMap": true,
"declaration": false,
+ "module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
+ "importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
- "es2016",
+ "es2018",
"dom"
]
}
diff --git a/frontend/tslint.json b/frontend/tslint.json
index 9113f1368..868ecba0d 100644
--- a/frontend/tslint.json
+++ b/frontend/tslint.json
@@ -1,25 +1,20 @@
{
+ "extends": "tslint:recommended",
"rulesDirectory": [
- "node_modules/codelyzer"
+ "codelyzer"
],
"rules": {
- "callable-types": true,
- "class-name": true,
- "comment-format": [
+ "array-type": false,
+ "arrow-parens": false,
+ "deprecation": {
+ "severity": "warn"
+ },
+ "import-blacklist": [
true,
- "check-space"
+ "rxjs/Rx"
],
- "curly": true,
- "eofline": true,
- "forin": true,
- "import-blacklist": [true, "rxjs"],
- "import-spacing": true,
- "indent": [
- true,
- "spaces"
- ],
- "interface-over-type-literal": true,
- "label-position": true,
+ "interface-name": false,
+ "max-classes-per-file": false,
"max-line-length": [
true,
140
@@ -27,11 +22,16 @@
"member-access": false,
"member-ordering": [
true,
- "static-before-instance",
- "variables-before-functions"
+ {
+ "order": [
+ "static-field",
+ "instance-field",
+ "static-method",
+ "instance-method"
+ ]
+ }
],
- "no-arg": true,
- "no-bitwise": true,
+ "no-consecutive-blank-lines": false,
"no-console": [
true,
"debug",
@@ -40,66 +40,28 @@
"timeEnd",
"trace"
],
- "no-construct": true,
- "no-debugger": true,
- "no-duplicate-variable": true,
"no-empty": false,
- "no-empty-interface": true,
- "no-eval": true,
- "no-inferrable-types": [true, "ignore-params"],
- "no-shadowed-variable": true,
- "no-string-literal": false,
- "no-string-throw": true,
+ "no-inferrable-types": [
+ true,
+ "ignore-params"
+ ],
+ "no-non-null-assertion": true,
+ "no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
- "no-trailing-whitespace": true,
- "no-unused-expression": true,
"no-use-before-declare": true,
- "no-var-keyword": true,
- "object-literal-sort-keys": false,
- "one-line": [
+ "no-var-requires": false,
+ "object-literal-key-quotes": [
true,
- "check-open-brace",
- "check-catch",
- "check-else",
- "check-whitespace"
+ "as-needed"
],
- "prefer-const": true,
+ "object-literal-sort-keys": false,
+ "ordered-imports": false,
"quotemark": [
true,
"single"
],
- "radix": true,
- "semicolon": [
- "always"
- ],
- "triple-equals": [
- true,
- "allow-null-check"
- ],
- "typedef-whitespace": [
- true,
- {
- "call-signature": "nospace",
- "index-signature": "nospace",
- "parameter": "nospace",
- "property-declaration": "nospace",
- "variable-declaration": "nospace"
- }
- ],
- "typeof-compare": true,
- "unified-signatures": true,
- "variable-name": false,
- "whitespace": [
- true,
- "check-branch",
- "check-decl",
- "check-operator",
- "check-separator",
- "check-type"
- ],
-
- "directive-selector": [true, "attribute", "app", "camelCase"],
- "component-selector": [true, "element", "app", "kebab-case"],
+ "trailing-comma": false,
+ "no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
@@ -108,9 +70,6 @@
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
- "directive-class-suffix": true,
- "no-access-missing-member": true,
- "templates-use-public": true,
- "invoke-injectable": true
+ "directive-class-suffix": true
}
}
From 146d275f601c51d4a8ccb70045c1c63949bc1341 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Fri, 19 Apr 2019 19:40:27 +0200
Subject: [PATCH 03/74] Updated to angular 7
---
server/README.md | 2 +-
server/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/README.md b/server/README.md
index d49d91618..aaa0c991a 100644
--- a/server/README.md
+++ b/server/README.md
@@ -1,4 +1,4 @@
-# Angular4 Spring Boot JWT Starter
+# Angular7 Spring Boot JWT Starter
This sub-project is the backend server portion of the project.
**Make sure you have Maven and Java 1.7 or greater**
diff --git a/server/pom.xml b/server/pom.xml
index 62a2c8e13..9c99b82aa 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -9,7 +9,7 @@
jar
angular-spring-starter
- The backend server for Angular2 Spring Boot JWT Starter
+ The backend server for Angular7 Spring Boot JWT Starter
org.springframework.boot
From 1830b7fda6f15f7143d3fb2a454adee57e8febb9 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Fri, 19 Apr 2019 21:33:47 +0200
Subject: [PATCH 04/74] Updated to angular 7
---
frontend/src/index.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/frontend/src/index.html b/frontend/src/index.html
index 234d83e38..c3cb34efe 100644
--- a/frontend/src/index.html
+++ b/frontend/src/index.html
@@ -2,14 +2,14 @@
- Angular4 Spring Boot JWT Starter
+ Angular7 Spring Boot JWT Starter
-
-
-
+
+
+
From 25fd3a03bcc346f47139268a57f7284f3811b830 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sat, 20 Apr 2019 13:06:33 +0200
Subject: [PATCH 05/74] Updated to angular 7
---
frontend/karma.conf.js | 4 +-
frontend/package.json | 2 +-
.../src/app/admin/admin.component.spec.ts | 8 +-
frontend/src/app/admin/admin.component.ts | 5 +-
.../angular-material.module.ts | 94 ++++++++++++++
frontend/src/app/app-routing.module.ts | 31 +++--
frontend/src/app/app.component.scss | 4 +-
frontend/src/app/app.component.spec.ts | 66 +++++-----
frontend/src/app/app.module.ts | 98 +++++----------
.../change-password.component.html | 34 ++---
.../change-password.component.spec.ts | 21 ++--
.../api-card/api-card.component.html | 6 +-
.../api-card/api-card.component.scss | 2 +
.../component/api-card/api-card.component.ts | 6 +-
.../component/footer/footer.component.html | 8 +-
.../component/footer/footer.component.scss | 1 +
.../app/component/footer/footer.component.ts | 5 +-
.../component/github/github.component.html | 2 +-
.../app/component/github/github.component.ts | 5 +-
.../account-menu/account-menu.component.html | 4 +-
.../account-menu.component.spec.ts | 22 ++--
.../account-menu/account-menu.component.ts | 13 +-
.../component/header/header.component.html | 27 ++--
.../component/header/header.component.scss | 1 +
.../app/component/header/header.component.ts | 12 +-
.../app/forbidden/forbidden.component.spec.ts | 8 +-
.../src/app/forbidden/forbidden.component.ts | 5 +-
frontend/src/app/guard/admin.guard.spec.ts | 15 +--
frontend/src/app/guard/admin.guard.ts | 12 +-
frontend/src/app/guard/guest.guard.ts | 10 +-
frontend/src/app/guard/login.guard.ts | 10 +-
frontend/src/app/home/home.component.html | 46 +++----
frontend/src/app/home/home.component.scss | 2 +
frontend/src/app/home/home.component.spec.ts | 22 +---
frontend/src/app/home/home.component.ts | 42 +++----
frontend/src/app/login/login.component.html | 80 ++++++------
.../src/app/login/login.component.spec.ts | 22 ++--
.../app/not-found/not-found.component.spec.ts | 4 +-
.../src/app/not-found/not-found.component.ts | 5 +-
frontend/src/app/polyfills.ts | 22 ++--
frontend/src/app/service/api.service.ts | 6 +-
frontend/src/app/service/auth.service.ts | 10 +-
frontend/src/app/service/config.service.ts | 68 +++++-----
frontend/src/app/service/foo.service.ts | 10 +-
.../src/app/service/mocks/api.service.mock.ts | 11 +-
frontend/src/app/service/user.service.ts | 32 ++---
.../src/app/shared/utilities/loose-invalid.ts | 2 +-
.../src/app/shared/utilities/serialize.ts | 4 +-
frontend/src/app/signup/signup.component.html | 41 +++---
frontend/src/app/signup/signup.component.scss | 117 +++++++++---------
.../src/app/signup/signup.component.spec.ts | 49 +++++++-
frontend/src/app/signup/signup.component.ts | 53 ++++----
frontend/tsconfig.json | 2 +-
53 files changed, 630 insertions(+), 561 deletions(-)
create mode 100644 frontend/src/app/angular-material/angular-material.module.ts
diff --git a/frontend/karma.conf.js b/frontend/karma.conf.js
index c3b764021..25a1e0922 100644
--- a/frontend/karma.conf.js
+++ b/frontend/karma.conf.js
@@ -16,10 +16,10 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
-
+ {pattern: './src/test.ts', watched: false}
],
preprocessors: {
-
+ './src/test.ts': ['@angular-devkit/build-angular']
},
mime: {
'text/x-typescript': ['ts','tsx']
diff --git a/frontend/package.json b/frontend/package.json
index 994e588c4..406ac7253 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,5 +1,5 @@
{
- "name": "test-angular",
+ "name": "angular-spring-starter-ui",
"version": "0.0.0",
"scripts": {
"ng": "ng",
diff --git a/frontend/src/app/admin/admin.component.spec.ts b/frontend/src/app/admin/admin.component.spec.ts
index 4e4d04422..dd1f9c8ea 100644
--- a/frontend/src/app/admin/admin.component.spec.ts
+++ b/frontend/src/app/admin/admin.component.spec.ts
@@ -1,6 +1,6 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
-import { AdminComponent } from './admin.component';
+import {AdminComponent} from './admin.component';
describe('AdminComponent', () => {
let component: AdminComponent;
@@ -8,9 +8,9 @@ describe('AdminComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ AdminComponent ]
+ declarations: [AdminComponent]
})
- .compileComponents();
+ .compileComponents();
}));
beforeEach(() => {
diff --git a/frontend/src/app/admin/admin.component.ts b/frontend/src/app/admin/admin.component.ts
index d06c5fdbf..9a976a4a0 100644
--- a/frontend/src/app/admin/admin.component.ts
+++ b/frontend/src/app/admin/admin.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-admin',
@@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
})
export class AdminComponent implements OnInit {
- constructor() { }
+ constructor() {
+ }
ngOnInit() {
}
diff --git a/frontend/src/app/angular-material/angular-material.module.ts b/frontend/src/app/angular-material/angular-material.module.ts
new file mode 100644
index 000000000..75649f34b
--- /dev/null
+++ b/frontend/src/app/angular-material/angular-material.module.ts
@@ -0,0 +1,94 @@
+import {A11yModule} from '@angular/cdk/a11y';
+import {DragDropModule} from '@angular/cdk/drag-drop';
+import {PortalModule} from '@angular/cdk/portal';
+import {ScrollingModule} from '@angular/cdk/scrolling';
+import {CdkStepperModule} from '@angular/cdk/stepper';
+import {CdkTableModule} from '@angular/cdk/table';
+import {CdkTreeModule} from '@angular/cdk/tree';
+import {NgModule} from '@angular/core';
+import {
+ MatAutocompleteModule,
+ MatBadgeModule,
+ MatBottomSheetModule,
+ MatButtonModule,
+ MatButtonToggleModule,
+ MatCardModule,
+ MatCheckboxModule,
+ MatChipsModule,
+ MatDatepickerModule,
+ MatDialogModule,
+ MatDividerModule,
+ MatExpansionModule,
+ MatGridListModule,
+ MatIconModule,
+ MatInputModule,
+ MatListModule,
+ MatMenuModule,
+ MatNativeDateModule,
+ MatPaginatorModule,
+ MatProgressBarModule,
+ MatProgressSpinnerModule,
+ MatRadioModule,
+ MatRippleModule,
+ MatSelectModule,
+ MatSidenavModule,
+ MatSliderModule,
+ MatSlideToggleModule,
+ MatSnackBarModule,
+ MatSortModule,
+ MatStepperModule,
+ MatTableModule,
+ MatTabsModule,
+ MatToolbarModule,
+ MatTooltipModule,
+ MatTreeModule,
+} from '@angular/material';
+
+@NgModule({
+ exports: [
+ A11yModule,
+ CdkStepperModule,
+ CdkTableModule,
+ CdkTreeModule,
+ DragDropModule,
+ MatAutocompleteModule,
+ MatBadgeModule,
+ MatBottomSheetModule,
+ MatButtonModule,
+ MatButtonToggleModule,
+ MatCardModule,
+ MatCheckboxModule,
+ MatChipsModule,
+ MatStepperModule,
+ MatDatepickerModule,
+ MatDialogModule,
+ MatDividerModule,
+ MatExpansionModule,
+ MatGridListModule,
+ MatIconModule,
+ MatInputModule,
+ MatListModule,
+ MatMenuModule,
+ MatNativeDateModule,
+ MatPaginatorModule,
+ MatProgressBarModule,
+ MatProgressSpinnerModule,
+ MatRadioModule,
+ MatRippleModule,
+ MatSelectModule,
+ MatSidenavModule,
+ MatSliderModule,
+ MatSlideToggleModule,
+ MatSnackBarModule,
+ MatSortModule,
+ MatTableModule,
+ MatTabsModule,
+ MatToolbarModule,
+ MatTooltipModule,
+ MatTreeModule,
+ PortalModule,
+ ScrollingModule,
+ ]
+})
+export class AngularMaterialModule {
+}
diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index 6c2d5a18b..1693632e1 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -1,16 +1,14 @@
-import { NgModule } from '@angular/core';
-import { Routes, RouterModule } from '@angular/router';
-import { AppComponent } from './app.component';
-import { HomeComponent } from './home';
-import { LoginComponent } from './login';
-import { AdminComponent } from './admin';
-import { LoginGuard } from './guard';
-import { GuestGuard, AdminGuard } from './guard';
-import { NotFoundComponent } from './not-found';
-import { ChangePasswordComponent } from './change-password';
-import { ForbiddenComponent } from './forbidden';
-import { SignupComponent } from './signup';
-
+import {NgModule} from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+import {HomeComponent} from './home';
+import {LoginComponent} from './login';
+import {AdminComponent} from './admin';
+import {AdminGuard, GuestGuard, LoginGuard} from './guard';
+import {NotFoundComponent} from './not-found';
+import {ChangePasswordComponent} from './change-password';
+import {ForbiddenComponent} from './forbidden';
+import {SignupComponent} from './signup';
+
export const routes: Routes = [
{
path: '',
@@ -18,10 +16,10 @@ export const routes: Routes = [
pathMatch: 'full'
},
{
- path:'signup',
+ path: 'signup',
component: SignupComponent,
canActivate: [GuestGuard],
- pathMatch:'full'
+ pathMatch: 'full'
},
{
path: 'login',
@@ -57,4 +55,5 @@ export const routes: Routes = [
exports: [RouterModule],
providers: []
})
-export class AppRoutingModule { }
+export class AppRoutingModule {
+}
diff --git a/frontend/src/app/app.component.scss b/frontend/src/app/app.component.scss
index 5293b8db7..97b507122 100644
--- a/frontend/src/app/app.component.scss
+++ b/frontend/src/app/app.component.scss
@@ -1,7 +1,7 @@
:host {
display: block;
- color: rgba(0,0,0,.54);
- font-family: Roboto,"Helvetica Neue";
+ color: rgba(0, 0, 0, .54);
+ font-family: Roboto, "Helvetica Neue";
}
.content {
diff --git a/frontend/src/app/app.component.spec.ts b/frontend/src/app/app.component.spec.ts
index f5a514e27..7d03b25a3 100644
--- a/frontend/src/app/app.component.spec.ts
+++ b/frontend/src/app/app.component.spec.ts
@@ -1,45 +1,51 @@
-import { TestBed, async } from '@angular/core/testing';
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { RouterTestingModule } from '@angular/router/testing';
-import { AppComponent } from './app.component';
-import { HomeComponent } from './home';
-import { LoginComponent } from './login';
-import { MockApiService } from './service/mocks/api.service.mock';
+import {async, TestBed} from '@angular/core/testing';
+import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
+import {RouterTestingModule} from '@angular/router/testing';
+import {AppComponent} from './app.component';
+import {MockApiService} from './service/mocks/api.service.mock';
+import {ApiCardComponent, FooterComponent, GithubComponent, HeaderComponent} from './component';
-import { LoginGuard } from './guard';
-import { NotFoundComponent } from './not-found';
-import {
- ApiCardComponent,
- FooterComponent,
- GithubComponent,
-} from './component';
-import {
- MatToolbarModule,
- MatIconRegistry
-} from '@angular/material';
-
-
-import {
- ApiService,
- AuthService,
- UserService,
- FooService,
- ConfigService
-} from './service';
-
-import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import {ApiService, AuthService, ConfigService, FooService, UserService} from './service';
+import {MatIconRegistry} from '@angular/material';
+import {AngularMaterialModule} from './angular-material/angular-material.module';
+import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {HttpClientModule} from '@angular/common/http';
+import {AppRoutingModule} from './app-routing.module';
+import {HomeComponent} from './home';
+import {LoginComponent} from './login';
+import {NotFoundComponent} from './not-found';
+import {AccountMenuComponent} from './component/header/account-menu/account-menu.component';
+import {ChangePasswordComponent} from './change-password';
+import {ForbiddenComponent} from './forbidden';
+import {AdminComponent} from './admin';
+import {SignupComponent} from './signup';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
+ HeaderComponent,
FooterComponent,
+ ApiCardComponent,
+ HomeComponent,
+ GithubComponent,
+ LoginComponent,
+ NotFoundComponent,
+ AccountMenuComponent,
+ ChangePasswordComponent,
+ ForbiddenComponent,
+ AdminComponent,
+ SignupComponent
],
imports: [
+ AngularMaterialModule,
+ FormsModule,
+ ReactiveFormsModule,
+ HttpClientModule,
RouterTestingModule,
- MatToolbarModule
+ AppRoutingModule
],
providers: [
MatIconRegistry,
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index e492f88f9..eaae73fb5 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -1,51 +1,25 @@
-import { BrowserModule } from '@angular/platform-browser';
-import { NgModule, APP_INITIALIZER} from '@angular/core';
-import { FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { HttpModule } from '@angular/http';
-import { HttpClientModule } from '@angular/common/http';
-// material
-import {
- MatButtonModule,
- MatMenuModule,
- MatIconModule,
- MatToolbarModule,
- MatTooltipModule,
- MatCardModule,
- MatInputModule,
- MatIconRegistry,
- MatProgressSpinnerModule
-} from '@angular/material';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { FlexLayoutModule } from '@angular/flex-layout';
-import { AppComponent } from './app.component';
-import { AppRoutingModule } from './app-routing.module';
-import { HomeComponent } from './home';
-import { LoginComponent } from './login';
-import { LoginGuard, GuestGuard, AdminGuard } from './guard';
-import { NotFoundComponent } from './not-found';
-import { AccountMenuComponent } from './component/header/account-menu/account-menu.component';
-import {
- HeaderComponent,
- ApiCardComponent,
- FooterComponent,
- GithubComponent
-} from './component';
+import {BrowserModule} from '@angular/platform-browser';
+import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
+import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {HttpClientModule} from '@angular/common/http';
+import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
+import {FlexLayoutModule} from '@angular/flex-layout';
+import {AppComponent} from './app.component';
+import {AppRoutingModule} from './app-routing.module';
+import {HomeComponent} from './home';
+import {LoginComponent} from './login';
+import {AdminGuard, GuestGuard, LoginGuard} from './guard';
+import {NotFoundComponent} from './not-found';
+import {AccountMenuComponent} from './component/header/account-menu/account-menu.component';
+import {ApiCardComponent, FooterComponent, GithubComponent, HeaderComponent} from './component';
-import {
- ApiService,
- AuthService,
- UserService,
- FooService,
- ConfigService
-} from './service';
-import { ChangePasswordComponent } from './change-password/change-password.component';
-import { ForbiddenComponent } from './forbidden/forbidden.component';
-import { AdminComponent } from './admin/admin.component';
-import { SignupComponent } from './signup/signup.component';
-
-export function initUserFactory(userService: UserService) {
- return () => userService.initUser();
-}
+import {ApiService, AuthService, ConfigService, FooService, UserService} from './service';
+import {ChangePasswordComponent} from './change-password/change-password.component';
+import {ForbiddenComponent} from './forbidden/forbidden.component';
+import {AdminComponent} from './admin/admin.component';
+import {SignupComponent} from './signup/signup.component';
+import {AngularMaterialModule} from './angular-material/angular-material.module';
+import {MatIconRegistry} from '@angular/material';
@NgModule({
declarations: [
@@ -66,21 +40,14 @@ export function initUserFactory(userService: UserService) {
imports: [
BrowserAnimationsModule,
BrowserModule,
- FormsModule,
- ReactiveFormsModule,
- HttpModule,
HttpClientModule,
AppRoutingModule,
- MatMenuModule,
- MatTooltipModule,
- MatButtonModule,
- MatIconModule,
- MatInputModule,
- MatToolbarModule,
- MatCardModule,
- MatProgressSpinnerModule,
- FlexLayoutModule
+ FormsModule,
+ ReactiveFormsModule,
+ FlexLayoutModule,
+ AngularMaterialModule
],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
LoginGuard,
GuestGuard,
@@ -90,14 +57,9 @@ export function initUserFactory(userService: UserService) {
ApiService,
UserService,
ConfigService,
- MatIconRegistry,
- {
- 'provide': APP_INITIALIZER,
- 'useFactory': initUserFactory,
- 'deps': [UserService],
- 'multi': true
- }
+ MatIconRegistry
],
- bootstrap: [AppComponent]
+ bootstrap: [AppComponent],
})
-export class AppModule { }
+export class AppModule {
+}
diff --git a/frontend/src/app/change-password/change-password.component.html b/frontend/src/app/change-password/change-password.component.html
index 3ddd8c368..1be50dad4 100644
--- a/frontend/src/app/change-password/change-password.component.html
+++ b/frontend/src/app/change-password/change-password.component.html
@@ -1,18 +1,20 @@
-
- Change Your Password
- {{notification.msgBody}}
-
-
-
-
-
+
+ Change Your Password
+ {{notification.msgBody}}
+
+
+
+
+
diff --git a/frontend/src/app/change-password/change-password.component.spec.ts b/frontend/src/app/change-password/change-password.component.spec.ts
index 5fc506a8f..f0f34e091 100644
--- a/frontend/src/app/change-password/change-password.component.spec.ts
+++ b/frontend/src/app/change-password/change-password.component.spec.ts
@@ -1,16 +1,11 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-import { FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { RouterTestingModule } from '@angular/router/testing';
-import {
- ApiService,
- AuthService,
- UserService,
- ConfigService
-} from '../service';
-import { MockApiService } from '../service/mocks';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
+import {RouterTestingModule} from '@angular/router/testing';
+import {ApiService, AuthService, ConfigService, UserService} from '../service';
+import {MockApiService} from '../service/mocks';
-import { ChangePasswordComponent } from './change-password.component';
+import {ChangePasswordComponent} from './change-password.component';
describe('ChangePasswordComponent', () => {
let component: ChangePasswordComponent;
@@ -37,7 +32,7 @@ describe('ChangePasswordComponent', () => {
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
- .compileComponents();
+ .compileComponents();
}));
beforeEach(() => {
diff --git a/frontend/src/app/component/api-card/api-card.component.html b/frontend/src/app/component/api-card/api-card.component.html
index 1d4d0c739..11aea92b8 100644
--- a/frontend/src/app/component/api-card/api-card.component.html
+++ b/frontend/src/app/component/api-card/api-card.component.html
@@ -3,7 +3,7 @@
{{title}}
{{subTitle}}
-
+
{{content}}
@@ -11,9 +11,9 @@
diff --git a/frontend/src/app/component/api-card/api-card.component.scss b/frontend/src/app/component/api-card/api-card.component.scss
index 903036cc6..3cc288f47 100644
--- a/frontend/src/app/component/api-card/api-card.component.scss
+++ b/frontend/src/app/component/api-card/api-card.component.scss
@@ -5,11 +5,13 @@
mat-card {
text-align: left;
+
.response-success {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #3c763d;
}
+
.response-error {
background-color: #f2dede;
border-color: #ebccd1;
diff --git a/frontend/src/app/component/api-card/api-card.component.ts b/frontend/src/app/component/api-card/api-card.component.ts
index 8082a42f3..9a99cbf22 100644
--- a/frontend/src/app/component/api-card/api-card.component.ts
+++ b/frontend/src/app/component/api-card/api-card.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
+import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
@Component({
selector: 'app-api-card',
@@ -15,10 +15,10 @@ export class ApiCardComponent implements OnInit {
@Input() responseObj: any;
expand = false;
-
@Output() apiClick: EventEmitter = new EventEmitter();
- constructor() { }
+ constructor() {
+ }
ngOnInit() {
console.log(this.responseObj);
diff --git a/frontend/src/app/component/footer/footer.component.html b/frontend/src/app/component/footer/footer.component.html
index 80868676c..4afa3056c 100644
--- a/frontend/src/app/component/footer/footer.component.html
+++ b/frontend/src/app/component/footer/footer.component.html
@@ -1,9 +1,11 @@
-
+
+
Hand crafted with love by
Fan Jin
and our awesome
- contributors.
+ contributors.
-
+
diff --git a/frontend/src/app/component/footer/footer.component.scss b/frontend/src/app/component/footer/footer.component.scss
index a5f4583a1..b1b379f32 100644
--- a/frontend/src/app/component/footer/footer.component.scss
+++ b/frontend/src/app/component/footer/footer.component.scss
@@ -8,6 +8,7 @@
padding: 72px 24px;
box-sizing: border-box;
text-align: center;
+
a {
text-decoration: none;
cursor: auto;
diff --git a/frontend/src/app/component/footer/footer.component.ts b/frontend/src/app/component/footer/footer.component.ts
index da17d8242..e8cedec34 100644
--- a/frontend/src/app/component/footer/footer.component.ts
+++ b/frontend/src/app/component/footer/footer.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-footer',
@@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
})
export class FooterComponent implements OnInit {
- constructor() { }
+ constructor() {
+ }
ngOnInit() {
}
diff --git a/frontend/src/app/component/github/github.component.html b/frontend/src/app/component/github/github.component.html
index b7734afe7..494b94030 100644
--- a/frontend/src/app/component/github/github.component.html
+++ b/frontend/src/app/component/github/github.component.html
@@ -1,4 +1,4 @@
Want to help make this project awesome? Check out our repo.
-
+
GITHUB
diff --git a/frontend/src/app/component/github/github.component.ts b/frontend/src/app/component/github/github.component.ts
index e39ab1623..ad64c4ab1 100644
--- a/frontend/src/app/component/github/github.component.ts
+++ b/frontend/src/app/component/github/github.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-github',
@@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
})
export class GithubComponent implements OnInit {
- constructor() { }
+ constructor() {
+ }
ngOnInit() {
}
diff --git a/frontend/src/app/component/header/account-menu/account-menu.component.html b/frontend/src/app/component/header/account-menu/account-menu.component.html
index 833497595..073b00bf3 100644
--- a/frontend/src/app/component/header/account-menu/account-menu.component.html
+++ b/frontend/src/app/component/header/account-menu/account-menu.component.html
@@ -1,2 +1,2 @@
-
-
+
+
diff --git a/frontend/src/app/component/header/account-menu/account-menu.component.spec.ts b/frontend/src/app/component/header/account-menu/account-menu.component.spec.ts
index 8353da31d..3fb9b49cb 100644
--- a/frontend/src/app/component/header/account-menu/account-menu.component.spec.ts
+++ b/frontend/src/app/component/header/account-menu/account-menu.component.spec.ts
@@ -1,18 +1,10 @@
-import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { RouterTestingModule } from '@angular/router/testing';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
+import {RouterTestingModule} from '@angular/router/testing';
-import {
- AuthService,
- ConfigService,
- ApiService,
- UserService
-} from '../../../service';
-import {
- MockUserService,
- MockApiService
-} from '../../../service/mocks';
-import { AccountMenuComponent } from './account-menu.component';
+import {ApiService, AuthService, ConfigService, UserService} from '../../../service';
+import {MockApiService, MockUserService} from '../../../service/mocks';
+import {AccountMenuComponent} from './account-menu.component';
describe('AccountMenuComponent', () => {
let component: AccountMenuComponent;
@@ -38,7 +30,7 @@ describe('AccountMenuComponent', () => {
declarations: [AccountMenuComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
- .compileComponents();
+ .compileComponents();
}));
beforeEach(() => {
diff --git a/frontend/src/app/component/header/account-menu/account-menu.component.ts b/frontend/src/app/component/header/account-menu/account-menu.component.ts
index 509f4ed71..24cd87d51 100644
--- a/frontend/src/app/component/header/account-menu/account-menu.component.ts
+++ b/frontend/src/app/component/header/account-menu/account-menu.component.ts
@@ -1,10 +1,6 @@
-import { Component, OnInit, Input } from '@angular/core';
-import {
- ConfigService,
- AuthService,
- UserService
-} from '../../../service';
-import { Router } from '@angular/router';
+import {Component, OnInit} from '@angular/core';
+import {AuthService, ConfigService, UserService} from '../../../service';
+import {Router} from '@angular/router';
@Component({
selector: 'app-account-menu',
@@ -21,7 +17,8 @@ export class AccountMenuComponent implements OnInit {
private authService: AuthService,
private router: Router,
private userService: UserService
- ) {}
+ ) {
+ }
ngOnInit() {
this.user = this.userService.currentUser;
diff --git a/frontend/src/app/component/header/header.component.html b/frontend/src/app/component/header/header.component.html
index 10cf94926..50f022826 100644
--- a/frontend/src/app/component/header/header.component.html
+++ b/frontend/src/app/component/header/header.component.html
@@ -1,38 +1,37 @@
-
+
-
-
diff --git a/frontend/src/app/component/header/header.component.scss b/frontend/src/app/component/header/header.component.scss
index 122b0bd39..4854221ad 100644
--- a/frontend/src/app/component/header/header.component.scss
+++ b/frontend/src/app/component/header/header.component.scss
@@ -47,6 +47,7 @@
}
}
}
+
@media screen and (max-width: 600px) {
.greeting-hamburger {
display: block;
diff --git a/frontend/src/app/component/header/header.component.ts b/frontend/src/app/component/header/header.component.ts
index c74f6258b..0e02e7d5b 100644
--- a/frontend/src/app/component/header/header.component.ts
+++ b/frontend/src/app/component/header/header.component.ts
@@ -1,9 +1,6 @@
-import { Component, OnInit } from '@angular/core';
-import {
- UserService,
- AuthService
-} from '../../service';
-import { Router } from '@angular/router';
+import {Component, OnInit} from '@angular/core';
+import {AuthService, UserService} from '../../service';
+import {Router} from '@angular/router';
@Component({
selector: 'app-header',
@@ -16,7 +13,8 @@ export class HeaderComponent implements OnInit {
private userService: UserService,
private authService: AuthService,
private router: Router
- ) { }
+ ) {
+ }
ngOnInit() {
}
diff --git a/frontend/src/app/forbidden/forbidden.component.spec.ts b/frontend/src/app/forbidden/forbidden.component.spec.ts
index 792abc5fe..b30df0abc 100644
--- a/frontend/src/app/forbidden/forbidden.component.spec.ts
+++ b/frontend/src/app/forbidden/forbidden.component.spec.ts
@@ -1,6 +1,6 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
-import { ForbiddenComponent } from './forbidden.component';
+import {ForbiddenComponent} from './forbidden.component';
describe('ForbiddenComponent', () => {
let component: ForbiddenComponent;
@@ -8,9 +8,9 @@ describe('ForbiddenComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ ForbiddenComponent ]
+ declarations: [ForbiddenComponent]
})
- .compileComponents();
+ .compileComponents();
}));
beforeEach(() => {
diff --git a/frontend/src/app/forbidden/forbidden.component.ts b/frontend/src/app/forbidden/forbidden.component.ts
index 3dd20c084..336d28302 100644
--- a/frontend/src/app/forbidden/forbidden.component.ts
+++ b/frontend/src/app/forbidden/forbidden.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-forbidden',
@@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
})
export class ForbiddenComponent implements OnInit {
- constructor() { }
+ constructor() {
+ }
ngOnInit() {
}
diff --git a/frontend/src/app/guard/admin.guard.spec.ts b/frontend/src/app/guard/admin.guard.spec.ts
index e6ca05e02..11b73fa4f 100644
--- a/frontend/src/app/guard/admin.guard.spec.ts
+++ b/frontend/src/app/guard/admin.guard.spec.ts
@@ -1,11 +1,12 @@
-import { TestBed, async, inject } from '@angular/core/testing';
-import { Router } from '@angular/router';
-import { UserService } from '../service';
-import { AdminGuard } from './admin.guard';
-import { MockUserService } from '../service/mocks';
+import {inject, TestBed} from '@angular/core/testing';
+import {Router} from '@angular/router';
+import {UserService} from '../service';
+import {AdminGuard} from './admin.guard';
+import {MockUserService} from '../service/mocks';
export class RouterStub {
- navigate(commands?: any[], extras?: any) {}
+ navigate(commands?: any[], extras?: any) {
+ }
}
describe('AdminGuard', () => {
@@ -16,7 +17,7 @@ describe('AdminGuard', () => {
{
provide: Router,
useClass: RouterStub
- }
+ },
{
provide: UserService,
useClass: MockUserService
diff --git a/frontend/src/app/guard/admin.guard.ts b/frontend/src/app/guard/admin.guard.ts
index a3ec91e54..882a8f19f 100644
--- a/frontend/src/app/guard/admin.guard.ts
+++ b/frontend/src/app/guard/admin.guard.ts
@@ -1,11 +1,11 @@
-import { Injectable } from '@angular/core';
-import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
-import { UserService } from '../service';
-import { Observable } from 'rxjs/Observable';
+import {Injectable} from '@angular/core';
+import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
+import {UserService} from '../service';
@Injectable()
export class AdminGuard implements CanActivate {
- constructor(private router: Router, private userService: UserService) {}
+ constructor(private router: Router, private userService: UserService) {
+ }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
if (this.userService.currentUser) {
@@ -18,7 +18,7 @@ export class AdminGuard implements CanActivate {
} else {
console.log('NOT AN ADMIN ROLE');
- this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
+ this.router.navigate(['/login'], {queryParams: {returnUrl: state.url}});
return false;
}
}
diff --git a/frontend/src/app/guard/guest.guard.ts b/frontend/src/app/guard/guest.guard.ts
index f2c803799..531148d64 100644
--- a/frontend/src/app/guard/guest.guard.ts
+++ b/frontend/src/app/guard/guest.guard.ts
@@ -1,12 +1,12 @@
-import { Injectable } from '@angular/core';
-import { Router, CanActivate } from '@angular/router';
-import { UserService } from '../service';
-import { Observable } from 'rxjs/Observable';
+import {Injectable} from '@angular/core';
+import {CanActivate, Router} from '@angular/router';
+import {UserService} from '../service';
@Injectable()
export class GuestGuard implements CanActivate {
- constructor(private router: Router, private userService: UserService) {}
+ constructor(private router: Router, private userService: UserService) {
+ }
canActivate(): boolean {
if (this.userService.currentUser) {
diff --git a/frontend/src/app/guard/login.guard.ts b/frontend/src/app/guard/login.guard.ts
index b120c4fb0..36e061a77 100644
--- a/frontend/src/app/guard/login.guard.ts
+++ b/frontend/src/app/guard/login.guard.ts
@@ -1,12 +1,12 @@
-import { Injectable } from '@angular/core';
-import { Router, CanActivate } from '@angular/router';
-import { UserService } from '../service';
-import { Observable } from 'rxjs/Observable';
+import {Injectable} from '@angular/core';
+import {CanActivate, Router} from '@angular/router';
+import {UserService} from '../service';
@Injectable()
export class LoginGuard implements CanActivate {
- constructor(private router: Router, private userService: UserService) {}
+ constructor(private router: Router, private userService: UserService) {
+ }
canActivate(): boolean {
if (this.userService.currentUser) {
diff --git a/frontend/src/app/home/home.component.html b/frontend/src/app/home/home.component.html
index 0f2c3ec12..4155b8939 100644
--- a/frontend/src/app/home/home.component.html
+++ b/frontend/src/app/home/home.component.html
@@ -1,38 +1,38 @@
diff --git a/frontend/src/app/home/home.component.scss b/frontend/src/app/home/home.component.scss
index 719241031..b74e6d479 100644
--- a/frontend/src/app/home/home.component.scss
+++ b/frontend/src/app/home/home.component.scss
@@ -1,5 +1,6 @@
app-api-card {
margin: 0 50px 0 0;
+
&.last {
margin: 0 0 0 0;
}
@@ -12,6 +13,7 @@ app-github {
@media screen and (min-width: 600px) and (max-width: 1279px) {
app-api-card {
margin: 0 4px 0 0;
+
&.last {
margin: 0 0 0 0;
}
diff --git a/frontend/src/app/home/home.component.spec.ts b/frontend/src/app/home/home.component.spec.ts
index d4ce3a81f..1992cb200 100644
--- a/frontend/src/app/home/home.component.spec.ts
+++ b/frontend/src/app/home/home.component.spec.ts
@@ -1,21 +1,11 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-import { HomeComponent } from './home.component';
-import { ApiCardComponent, GithubComponent } from '../component';
-import { MockApiService } from '../service/mocks/api.service.mock';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+import {HomeComponent} from './home.component';
+import {ApiCardComponent, GithubComponent} from '../component';
+import {MockApiService} from '../service/mocks/api.service.mock';
-import {
- MatButtonModule,
- MatCardModule
-} from '@angular/material';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import {MatButtonModule, MatCardModule} from '@angular/material';
-import {
- ApiService,
- AuthService,
- UserService,
- FooService,
- ConfigService
-} from '../service';
+import {ApiService, AuthService, ConfigService, FooService, UserService} from '../service';
describe('HomeComponent', () => {
let component: HomeComponent;
diff --git a/frontend/src/app/home/home.component.ts b/frontend/src/app/home/home.component.ts
index 89d27cd11..e65b250cc 100644
--- a/frontend/src/app/home/home.component.ts
+++ b/frontend/src/app/home/home.component.ts
@@ -1,9 +1,5 @@
-import { Component, OnInit } from '@angular/core';
-import {
- FooService,
- ConfigService,
- UserService
-} from '../service';
+import {Component, OnInit} from '@angular/core';
+import {ConfigService, FooService, UserService} from '../service';
@Component({
selector: 'app-home',
@@ -15,11 +11,13 @@ export class HomeComponent implements OnInit {
fooResponse = {};
whoamIResponse = {};
allUserResponse = {};
+
constructor(
private config: ConfigService,
private fooService: FooService,
private userService: UserService
- ) { }
+ ) {
+ }
ngOnInit() {
}
@@ -27,25 +25,25 @@ export class HomeComponent implements OnInit {
makeRequest(path) {
if (path === this.config.foo_url) {
this.fooService.getFoo()
- .subscribe(res => {
- this.forgeResonseObj(this.fooResponse, res, path);
- }, err => {
- this.forgeResonseObj(this.fooResponse, err, path);
- });
+ .subscribe(res => {
+ this.forgeResonseObj(this.fooResponse, res, path);
+ }, err => {
+ this.forgeResonseObj(this.fooResponse, err, path);
+ });
} else if (path === this.config.whoami_url) {
this.userService.getMyInfo()
- .subscribe(res => {
- this.forgeResonseObj(this.whoamIResponse, res, path);
- }, err => {
- this.forgeResonseObj(this.whoamIResponse, err, path);
- });
+ .subscribe(res => {
+ this.forgeResonseObj(this.whoamIResponse, res, path);
+ }, err => {
+ this.forgeResonseObj(this.whoamIResponse, err, path);
+ });
} else {
this.userService.getAll()
- .subscribe(res => {
- this.forgeResonseObj(this.allUserResponse, res, path);
- }, err => {
- this.forgeResonseObj(this.allUserResponse, err, path);
- });
+ .subscribe(res => {
+ this.forgeResonseObj(this.allUserResponse, res, path);
+ }, err => {
+ this.forgeResonseObj(this.allUserResponse, err, path);
+ });
}
}
diff --git a/frontend/src/app/login/login.component.html b/frontend/src/app/login/login.component.html
index 1c1f00c41..dcc5bcddb 100644
--- a/frontend/src/app/login/login.component.html
+++ b/frontend/src/app/login/login.component.html
@@ -1,43 +1,45 @@
-
-
-
- Angular Spring Starter
-
-
-
- {{title}}
-
-
-
-
- {{notification.msgBody}}
-
-
-
-
- Reset Credentials
-
-
-
-
-
-
- Created by Fan Jin
- Click below to go to repository
- GitHub Repository
-
-
-
-
+
+
+
+ Angular Spring Starter
+
+
+
+ {{title}}
+
+
+
+
+ {{notification.msgBody}}
+
+
+
+
+ Reset Credentials
+
+
+
+
+
+
+
+ Created by Fan Jin
+ Click below to go to repository
+ GitHub Repository
+
+
+
+
diff --git a/frontend/src/app/login/login.component.spec.ts b/frontend/src/app/login/login.component.spec.ts
index c8e850249..a46fd24a5 100644
--- a/frontend/src/app/login/login.component.spec.ts
+++ b/frontend/src/app/login/login.component.spec.ts
@@ -1,17 +1,11 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-import { LoginComponent } from './login.component';
-import { RouterTestingModule } from '@angular/router/testing';
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { MockApiService } from '../service/mocks/api.service.mock';
-import { ReactiveFormsModule } from '@angular/forms';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+import {LoginComponent} from './login.component';
+import {RouterTestingModule} from '@angular/router/testing';
+import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
+import {MockApiService} from '../service/mocks/api.service.mock';
+import {ReactiveFormsModule} from '@angular/forms';
-import {
- ApiService,
- AuthService,
- UserService,
- FooService,
- ConfigService
-} from '../service';
+import {ApiService, AuthService, ConfigService, UserService} from '../service';
describe('LoginComponent', () => {
let component: LoginComponent;
@@ -22,7 +16,7 @@ describe('LoginComponent', () => {
declarations: [LoginComponent],
imports: [
ReactiveFormsModule,
- RouterTestingModule
+ RouterTestingModule,
],
providers: [
UserService,
diff --git a/frontend/src/app/not-found/not-found.component.spec.ts b/frontend/src/app/not-found/not-found.component.spec.ts
index 1acb86ee0..e04baa361 100644
--- a/frontend/src/app/not-found/not-found.component.spec.ts
+++ b/frontend/src/app/not-found/not-found.component.spec.ts
@@ -1,6 +1,6 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
-import { NotFoundComponent } from './not-found.component';
+import {NotFoundComponent} from './not-found.component';
describe('NotFoundComponent', () => {
let component: NotFoundComponent;
diff --git a/frontend/src/app/not-found/not-found.component.ts b/frontend/src/app/not-found/not-found.component.ts
index c18f379f1..1cccce293 100644
--- a/frontend/src/app/not-found/not-found.component.ts
+++ b/frontend/src/app/not-found/not-found.component.ts
@@ -1,10 +1,11 @@
-import { Component } from '@angular/core';
+import {Component} from '@angular/core';
@Component({
templateUrl: './not-found.component.html'
})
export class NotFoundComponent {
- constructor() { }
+ constructor() {
+ }
}
diff --git a/frontend/src/app/polyfills.ts b/frontend/src/app/polyfills.ts
index 622efa015..21605c0ad 100644
--- a/frontend/src/app/polyfills.ts
+++ b/frontend/src/app/polyfills.ts
@@ -43,19 +43,18 @@
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
-
-
-
-/** ALL Firefox browsers require the following to support `@angular/animation`. **/
-// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
-
-
-
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
-import 'zone.js/dist/zone'; // Included with Angular CLI.
+import 'zone.js/dist/zone'; // Included with Angular CLI.
+/***************************************************************************************************
+ * MATERIAL 2
+ */
+import 'hammerjs/hammer';
+
+/** ALL Firefox browsers require the following to support `@angular/animation`. **/
+// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
@@ -67,8 +66,3 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.
-
-/***************************************************************************************************
- * MATERIAL 2
- */
-import 'hammerjs/hammer';
diff --git a/frontend/src/app/service/api.service.ts b/frontend/src/app/service/api.service.ts
index 6644307f5..b421e1197 100644
--- a/frontend/src/app/service/api.service.ts
+++ b/frontend/src/app/service/api.service.ts
@@ -14,11 +14,13 @@ export enum RequestMethod {
Patch = 'PATCH'
}
-@Injectable()
+@Injectable({
+ providedIn: 'root'
+})
export class ApiService {
headers = new HttpHeaders({
- Accept: 'application/json',
+ 'Accept': 'application/json',
'Content-Type': 'application/json'
});
diff --git a/frontend/src/app/service/auth.service.ts b/frontend/src/app/service/auth.service.ts
index 4f5feb675..3a6f7f329 100644
--- a/frontend/src/app/service/auth.service.ts
+++ b/frontend/src/app/service/auth.service.ts
@@ -23,9 +23,9 @@ export class AuthService {
const body = `username=${user.username}&password=${user.password}`;
return this.apiService.post(this.config.login_url, body, loginHeaders)
.pipe(map(() => {
- console.log('Login success');
- this.userService.getMyInfo().subscribe();
- }));
+ console.log('Login success');
+ this.userService.getMyInfo().subscribe();
+ }));
}
signup(user) {
@@ -35,8 +35,8 @@ export class AuthService {
});
return this.apiService.post(this.config.signup_url, JSON.stringify(user), signupHeaders)
.pipe(map(() => {
- console.log('Sign up success');
- }));
+ console.log('Sign up success');
+ }));
}
logout() {
diff --git a/frontend/src/app/service/config.service.ts b/frontend/src/app/service/config.service.ts
index 3a4accb0c..e497fa4e8 100644
--- a/frontend/src/app/service/config.service.ts
+++ b/frontend/src/app/service/config.service.ts
@@ -1,65 +1,65 @@
-import { Injectable } from '@angular/core';
-import { environment } from '../../environments/environment';
+import {Injectable} from '@angular/core';
-@Injectable()
+@Injectable({
+ providedIn: 'root'
+})
export class ConfigService {
- private _api_url = '/api'
+ private _api_url = '/api';
+ private _user_url = this._api_url + '/user';
private _refresh_token_url = this._api_url + '/refresh';
- private _login_url = this._api_url + '/login';
-
- private _logout_url = this._api_url + '/logout';
-
- private _change_password_url = this._api_url + '/changePassword';
+ get refresh_token_url(): string {
+ return this._refresh_token_url;
+ }
- private _whoami_url = this._api_url + '/whoami';
+ private _login_url = this._api_url + '/login';
- private _user_url = this._api_url + '/user';
+ get login_url(): string {
+ return this._login_url;
+ }
- private _users_url = this._user_url + '/all';
+ private _logout_url = this._api_url + '/logout';
- private _reset_credentials_url = this._user_url + '/reset-credentials';
+ get logout_url(): string {
+ return this._logout_url;
+ }
- private _foo_url = this._api_url + '/foo';
-
- private _signup_url = this._api_url + '/signup';
+ private _change_password_url = this._api_url + '/changePassword';
- get reset_credentials_url(): string {
- return this._reset_credentials_url;
+ get change_password_url(): string {
+ return this._change_password_url;
}
- get refresh_token_url(): string {
- return this._refresh_token_url;
- }
+ private _whoami_url = this._api_url + '/whoami';
get whoami_url(): string {
- return this._whoami_url;
+ return this._whoami_url;
}
+ private _users_url = this._user_url + '/all';
+
get users_url(): string {
- return this._users_url;
+ return this._users_url;
}
- get login_url(): string {
- return this._login_url;
- }
+ private _reset_credentials_url = this._user_url + '/reset-credentials';
- get logout_url(): string {
- return this._logout_url;
+ get reset_credentials_url(): string {
+ return this._reset_credentials_url;
}
- get change_password_url(): string {
- return this._change_password_url;
- }
+ private _foo_url = this._api_url + '/foo';
get foo_url(): string {
- return this._foo_url;
+ return this._foo_url;
}
- get signup_url():string {
- return this._signup_url;
+ private _signup_url = this._api_url + '/signup';
+
+ get signup_url(): string {
+ return this._signup_url;
}
}
diff --git a/frontend/src/app/service/foo.service.ts b/frontend/src/app/service/foo.service.ts
index fc926f8dd..52316b966 100644
--- a/frontend/src/app/service/foo.service.ts
+++ b/frontend/src/app/service/foo.service.ts
@@ -1,7 +1,6 @@
-import { Injectable } from '@angular/core';
-import { Headers } from '@angular/http';
-import { ApiService } from './api.service';
-import { ConfigService } from './config.service';
+import {Injectable} from '@angular/core';
+import {ApiService} from './api.service';
+import {ConfigService} from './config.service';
@Injectable()
export class FooService {
@@ -9,7 +8,8 @@ export class FooService {
constructor(
private apiService: ApiService,
private config: ConfigService
- ) { }
+ ) {
+ }
getFoo() {
return this.apiService.get(this.config.foo_url);
diff --git a/frontend/src/app/service/mocks/api.service.mock.ts b/frontend/src/app/service/mocks/api.service.mock.ts
index b4da49fbd..99b39c61e 100644
--- a/frontend/src/app/service/mocks/api.service.mock.ts
+++ b/frontend/src/app/service/mocks/api.service.mock.ts
@@ -1,6 +1,6 @@
const MockObservable = {
mergeMap: (cb) => {
- return cb({ id: 123 });
+ return cb({id: 123});
},
toPromise: () => {
return new Promise((resolve, reject) => {
@@ -13,8 +13,13 @@ export class MockApiService {
get(path: string) {
return MockObservable;
}
- post(path: string, body) {}
- put(path: string, body) {}
+
+ post(path: string, body) {
+ }
+
+ put(path: string, body) {
+ }
+
anonGet(path: string) {
return MockObservable;
}
diff --git a/frontend/src/app/service/user.service.ts b/frontend/src/app/service/user.service.ts
index 49acc29ae..a54b41289 100644
--- a/frontend/src/app/service/user.service.ts
+++ b/frontend/src/app/service/user.service.ts
@@ -1,10 +1,11 @@
-import { Injectable } from '@angular/core';
-import { Headers } from '@angular/http';
-import { ApiService } from './api.service';
-import { ConfigService } from './config.service';
+import {Injectable} from '@angular/core';
+import {ApiService} from './api.service';
+import {ConfigService} from './config.service';
import {map} from 'rxjs/operators';
-@Injectable()
+@Injectable({
+ providedIn: 'root'
+})
export class UserService {
currentUser;
@@ -12,19 +13,20 @@ export class UserService {
constructor(
private apiService: ApiService,
private config: ConfigService
- ) { }
+ ) {
+ }
initUser() {
const promise = this.apiService.get(this.config.refresh_token_url).toPromise()
- .then(res => {
- if (res.access_token !== null) {
- return this.getMyInfo().toPromise()
- .then(user => {
- this.currentUser = user;
- });
- }
- })
- .catch(() => null);
+ .then(res => {
+ if (res.access_token !== null) {
+ return this.getMyInfo().toPromise()
+ .then(user => {
+ this.currentUser = user;
+ });
+ }
+ })
+ .catch(() => null);
return promise;
}
diff --git a/frontend/src/app/shared/utilities/loose-invalid.ts b/frontend/src/app/shared/utilities/loose-invalid.ts
index 73d7f6316..43ef2646b 100644
--- a/frontend/src/app/shared/utilities/loose-invalid.ts
+++ b/frontend/src/app/shared/utilities/loose-invalid.ts
@@ -1,3 +1,3 @@
-export function looseInvalid(a: string|number): boolean {
+export function looseInvalid(a: string | number): boolean {
return a === '' || a === null || a === undefined;
}
diff --git a/frontend/src/app/shared/utilities/serialize.ts b/frontend/src/app/shared/utilities/serialize.ts
index 6ab4e2c67..70865ebda 100644
--- a/frontend/src/app/shared/utilities/serialize.ts
+++ b/frontend/src/app/shared/utilities/serialize.ts
@@ -1,5 +1,5 @@
-import { HttpParams, HttpUrlEncodingCodec } from '@angular/common/http';
-import { looseInvalid } from './loose-invalid';
+import {HttpParams} from '@angular/common/http';
+import {looseInvalid} from './loose-invalid';
export function serialize(obj: any): HttpParams {
let params = new HttpParams();
diff --git a/frontend/src/app/signup/signup.component.html b/frontend/src/app/signup/signup.component.html
index d93852d57..e5d13aa7e 100644
--- a/frontend/src/app/signup/signup.component.html
+++ b/frontend/src/app/signup/signup.component.html
@@ -1,44 +1,38 @@
-
-
-
- Angular Spring Starter
-
-
-
- {{ title }}
-
-
+
+
+ {{ title }}
+
+
+ Angular Spring Starter
+
+
-
- {{notification.msgBody}}
-
-
-
-
Created by
Fan Jin
@@ -47,10 +41,7 @@ {{ title }}
Click below to go to repository
- GitHub Repository
-
+ GitHub Repository
-
-
diff --git a/frontend/src/app/signup/signup.component.scss b/frontend/src/app/signup/signup.component.scss
index e0b041081..adf75cd89 100644
--- a/frontend/src/app/signup/signup.component.scss
+++ b/frontend/src/app/signup/signup.component.scss
@@ -1,59 +1,58 @@
-.content {
- width: 100%;
- }
-
- mat-card {
- max-width: 350px;
- text-align: center;
- animation: fadein 1s;
- -o-animation: fadein 1s; /* Opera */
- -moz-animation: fadein 1s; /* Firefox */
- -webkit-animation: fadein 1s; /* Safari and Chrome */
-
- }
-
- mat-input-container {
- display: block;
- }
-
- mat-spinner {
- width: 25px;
- height: 25px;
- margin: 20px auto 0 auto;
- }
-
- button {
- display: block;
- width: 100%;
- }
-
- .error {
- color: #D50000;
- }
-
- .success {
- color: #8BC34A;
- }
-
-
- @media screen and (max-width: 599px) {
-
- .content {
- /* https://github.com/angular/flex-layout/issues/295 */
- display: block !important;
- }
-
- mat-card {
- /* https://github.com/angular/flex-layout/issues/295 */
- display: block !important;
- max-width: 999px;
- }
-
- }
-
- a {
- text-decoration: none;
- cursor: auto;
- color: #FFFFFF;
- }
-
\ No newline at end of file
+.content {
+ width: 100%;
+}
+
+mat-card {
+ max-width: 350px;
+ text-align: center;
+ animation: fadein 1s;
+ -o-animation: fadein 1s; /* Opera */
+ -moz-animation: fadein 1s; /* Firefox */
+ -webkit-animation: fadein 1s; /* Safari and Chrome */
+
+}
+
+mat-input-container {
+ display: block;
+}
+
+mat-spinner {
+ width: 25px;
+ height: 25px;
+ margin: 20px auto 0 auto;
+}
+
+button {
+ display: block;
+ width: 100%;
+}
+
+.error {
+ color: #D50000;
+}
+
+.success {
+ color: #8BC34A;
+}
+
+
+@media screen and (max-width: 599px) {
+
+ .content {
+ /* https://github.com/angular/flex-layout/issues/295 */
+ display: block !important;
+ }
+
+ mat-card {
+ /* https://github.com/angular/flex-layout/issues/295 */
+ display: block !important;
+ max-width: 999px;
+ }
+
+}
+
+a {
+ text-decoration: none;
+ cursor: auto;
+ color: #FFFFFF;
+}
diff --git a/frontend/src/app/signup/signup.component.spec.ts b/frontend/src/app/signup/signup.component.spec.ts
index 43e46a5d6..a88ed42ff 100644
--- a/frontend/src/app/signup/signup.component.spec.ts
+++ b/frontend/src/app/signup/signup.component.spec.ts
@@ -1,6 +1,21 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
-import { SignupComponent } from './signup.component';
+import {SignupComponent} from './signup.component';
+import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {AngularMaterialModule} from '../angular-material/angular-material.module';
+import {HttpClientModule} from '@angular/common/http';
+import {ApiService, AuthService, ConfigService, FooService, UserService} from '../service';
+import {AppRoutingModule} from '../app-routing.module';
+import {HomeComponent} from '../home';
+import {LoginComponent} from '../login';
+import {ChangePasswordComponent} from '../change-password';
+import {MockApiService} from '../service/mocks';
+import {AdminComponent} from '../admin';
+import {NotFoundComponent} from '../not-found';
+import {ForbiddenComponent} from '../forbidden';
+import {GithubComponent} from '../component/github';
+import {ApiCardComponent} from '../component/api-card';
+import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
describe('SignupComponent', () => {
let component: SignupComponent;
@@ -8,9 +23,35 @@ describe('SignupComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ SignupComponent ]
+ imports: [
+ BrowserAnimationsModule,
+ AngularMaterialModule,
+ FormsModule,
+ ReactiveFormsModule,
+ HttpClientModule,
+ AppRoutingModule],
+ declarations: [
+ SignupComponent,
+ HomeComponent,
+ LoginComponent,
+ ChangePasswordComponent,
+ AdminComponent,
+ NotFoundComponent,
+ ForbiddenComponent,
+ ApiCardComponent,
+ GithubComponent],
+ providers: [
+ {
+ provide: ApiService,
+ useClass: MockApiService
+ },
+ AuthService,
+ UserService,
+ FooService,
+ ConfigService
+ ]
})
- .compileComponents();
+ .compileComponents();
}));
beforeEach(() => {
diff --git a/frontend/src/app/signup/signup.component.ts b/frontend/src/app/signup/signup.component.ts
index db59d22dd..dd81358d7 100644
--- a/frontend/src/app/signup/signup.component.ts
+++ b/frontend/src/app/signup/signup.component.ts
@@ -1,16 +1,9 @@
-import { Inject } from '@angular/core';
-import { Component, OnInit, OnDestroy } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { Router, ActivatedRoute } from '@angular/router';
-import { DisplayMessage } from '../shared/models/display-message';
-import { Subscription } from 'rxjs/Subscription';
-import {
- UserService,
- AuthService
-} from '../service';
-
-import { Observable } from 'rxjs/Observable';
-import { Subject } from 'rxjs/Subject';
+import {Component, OnDestroy, OnInit} from '@angular/core';
+import {FormBuilder, FormGroup, Validators} from '@angular/forms';
+import {ActivatedRoute, Router} from '@angular/router';
+import {DisplayMessage} from '../shared/models/display-message';
+import {AuthService, UserService} from '../service';
+import {Subject} from 'rxjs/Subject';
import {takeUntil} from 'rxjs/operators';
@Component({
@@ -51,16 +44,16 @@ export class SignupComponent implements OnInit, OnDestroy {
ngOnInit() {
this.route.params
- .pipe(takeUntil(this.ngUnsubscribe))
- .subscribe((params: DisplayMessage) => {
- this.notification = params;
- });
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe((params: DisplayMessage) => {
+ this.notification = params;
+ });
// get return url from route parameters or default to '/'
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
this.form = this.formBuilder.group({
username: ['', Validators.compose([Validators.required, Validators.minLength(3), Validators.maxLength(64)])],
password: ['', Validators.compose([Validators.required, Validators.minLength(3), Validators.maxLength(32)])],
- firstname:[''],
+ firstname: [''],
lastname: ['']
});
}
@@ -82,18 +75,18 @@ export class SignupComponent implements OnInit, OnDestroy {
this.submitted = true;
this.authService.signup(this.form.value)
- .subscribe(data => {
- console.log(data);
- this.authService.login(this.form.value).subscribe(data =>{
- this.userService.getMyInfo().subscribe();
- })
- this.router.navigate([this.returnUrl]);
- },
- error => {
- this.submitted = false;
- console.log("Sign up error" + JSON.stringify(error));
- this.notification = { msgType: 'error', msgBody: error['error'].errorMessage };
- });
+ .subscribe(data => {
+ console.log(data);
+ this.authService.login(this.form.value).subscribe(() => {
+ this.userService.getMyInfo().subscribe();
+ });
+ this.router.navigate([this.returnUrl]);
+ },
+ error => {
+ this.submitted = false;
+ console.log('Sign up error' + JSON.stringify(error));
+ this.notification = {msgType: 'error', msgBody: error['error'].errorMessage};
+ });
}
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index b271fd9f3..ca345910b 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -1,7 +1,7 @@
{
"compileOnSave": false,
"compilerOptions": {
- "baseUrl": "./",
+ "baseUrl": "src",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
From f1ba616c1a59e550e16b4dd2717b22c47ba81b08 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 21 Apr 2019 07:53:17 +0200
Subject: [PATCH 06/74] Updated Readme
---
frontend/README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/frontend/README.md b/frontend/README.md
index ae19858e5..38796822f 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -1,7 +1,7 @@
-# Angular4 Spring Boot JWT Starter
-This sub-project is the frontend UI portion of the project and it was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0.
+# Angular7 Spring Boot JWT Starter
+This sub-project is the frontend UI portion of the project and it was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.8.
-**Make sure you also have NPM 3.1, Node 6.9.5 and angular-cli@1.0.0 globally installed**
+**Make sure you also have NPM 6.9.0, Node 10.15.3 and angular-cli@7.3.8 globally installed**
## File Structure
```
From 60c6f7e881754e7f708415126f9cc6e45b34fb2b Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 21 Apr 2019 08:11:41 +0200
Subject: [PATCH 07/74] Updated the readme and fixed the styling
---
frontend/angular.json | 3 +--
frontend/src/app/component/api-card/api-card.component.scss | 2 +-
server/README.md | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/frontend/angular.json b/frontend/angular.json
index 6660bf670..acbcf4737 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -23,7 +23,6 @@
"src/assets"
],
"styles": [
- "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
],
"scripts": [],
@@ -135,4 +134,4 @@
}
},
"defaultProject": "testAngular"
-}
\ No newline at end of file
+}
diff --git a/frontend/src/app/component/api-card/api-card.component.scss b/frontend/src/app/component/api-card/api-card.component.scss
index 3cc288f47..424fd48fe 100644
--- a/frontend/src/app/component/api-card/api-card.component.scss
+++ b/frontend/src/app/component/api-card/api-card.component.scss
@@ -38,7 +38,7 @@ mat-card {
mat-card-actions {
margin-bottom: 0;
- padding-bottom: 0;
+ padding-bottom: 8px;
}
pre {
diff --git a/server/README.md b/server/README.md
index aaa0c991a..adcbb04a2 100644
--- a/server/README.md
+++ b/server/README.md
@@ -1,7 +1,7 @@
# Angular7 Spring Boot JWT Starter
This sub-project is the backend server portion of the project.
-**Make sure you have Maven and Java 1.7 or greater**
+**Make sure you have Maven and Java 1.8 or greater**
```bash
# change directory to server
From cc13fc64f43dd03d8d0b0dc6a1f16b6965d2564c Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 21 Apr 2019 08:16:15 +0200
Subject: [PATCH 08/74] Updated the readme and fixed the styling
---
frontend/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/package.json b/frontend/package.json
index 406ac7253..97ebdfac0 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,6 +1,6 @@
{
"name": "angular-spring-starter-ui",
- "version": "0.0.0",
+ "version": "0.1.1",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
From 7a02a62407757105ebd7cf019c05239aed3560c8 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 21 Apr 2019 08:17:31 +0200
Subject: [PATCH 09/74] Updated the readme and fixed the styling
---
frontend/src/styles.css | 4 ----
1 file changed, 4 deletions(-)
diff --git a/frontend/src/styles.css b/frontend/src/styles.css
index 374e253ca..4e5a0a3f7 100644
--- a/frontend/src/styles.css
+++ b/frontend/src/styles.css
@@ -1,9 +1,5 @@
/* You can add global styles to this file, and also import other style files */
@import '~@angular/material/prebuilt-themes/pink-bluegrey.css';
-body {
- margin: 0;
-}
-
html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
From 28383cdf7a37626a8b2b9888ad8cb5a73709d9c8 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Mon, 22 Apr 2019 14:12:53 +0200
Subject: [PATCH 10/74] Updated the readme and fixed the styling
---
server/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/README.md b/server/README.md
index adcbb04a2..e8541388a 100644
--- a/server/README.md
+++ b/server/README.md
@@ -58,7 +58,7 @@ angular-spring-starter/server
│ │ │ │ └──UserService.java
│ │ │ └──Application.java * Application main enterance
│ │ └──recources
- │ │ ├──static * Angular2 frontend code will get built and served from here.
+ │ │ ├──static * Angular7 frontend code will get built and served from here.
│ │ ├──application.yml * application variables are configured here
│ │ ├──banner.txt * application banner :^)
│ │ └──import.sql * h2 database query(table creation)
From 547562659b627f83dececb34c0e230979e7902ad Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Wed, 1 May 2019 12:12:50 +0200
Subject: [PATCH 11/74] Renaming and refactoring
---
frontend/angular.json | 18 +++++++++---------
.../change-password.component.ts | 2 +-
frontend/src/app/service/auth.service.ts | 2 +-
frontend/src/karma.conf.js | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/frontend/angular.json b/frontend/angular.json
index acbcf4737..ac16f795b 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -3,7 +3,7 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
- "testAngular": {
+ "angular-spring-starter-ui": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
@@ -13,7 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
- "outputPath": "dist/testAngular",
+ "outputPath": "dist/angular-spring-starter-ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
@@ -58,18 +58,18 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
- "browserTarget": "testAngular:build"
+ "browserTarget": "angular-spring-starter-ui:build"
},
"configurations": {
"production": {
- "browserTarget": "testAngular:build:production"
+ "browserTarget": "angular-spring-starter-ui:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
- "browserTarget": "testAngular:build"
+ "browserTarget": "angular-spring-starter-ui:build"
}
},
"test": {
@@ -104,7 +104,7 @@
}
}
},
- "testAngular-e2e": {
+ "angular-spring-starter-ui-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
@@ -113,11 +113,11 @@
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
- "devServerTarget": "testAngular:serve"
+ "devServerTarget": "angular-spring-starter-ui:serve"
},
"configurations": {
"production": {
- "devServerTarget": "testAngular:serve:production"
+ "devServerTarget": "angular-spring-starter-ui:serve:production"
}
}
},
@@ -133,5 +133,5 @@
}
}
},
- "defaultProject": "testAngular"
+ "defaultProject": "angular-spring-starter-ui"
}
diff --git a/frontend/src/app/change-password/change-password.component.ts b/frontend/src/app/change-password/change-password.component.ts
index f94bde810..891046a24 100644
--- a/frontend/src/app/change-password/change-password.component.ts
+++ b/frontend/src/app/change-password/change-password.component.ts
@@ -50,7 +50,7 @@ export class ChangePasswordComponent implements OnInit {
this.notification = undefined;
this.submitted = true;
- this.authService.changePassowrd(this.form.value)
+ this.authService.changePassword(this.form.value)
.pipe(mergeMap(() => this.authService.logout()))
.subscribe(() => {
this.router.navigate(['/login', {msgType: 'success', msgBody: 'Success! Please sign in with your new password.'}]);
diff --git a/frontend/src/app/service/auth.service.ts b/frontend/src/app/service/auth.service.ts
index 3a6f7f329..ab9976540 100644
--- a/frontend/src/app/service/auth.service.ts
+++ b/frontend/src/app/service/auth.service.ts
@@ -46,7 +46,7 @@ export class AuthService {
}));
}
- changePassowrd(passwordChanger) {
+ changePassword(passwordChanger) {
return this.apiService.post(this.config.change_password_url, passwordChanger);
}
diff --git a/frontend/src/karma.conf.js b/frontend/src/karma.conf.js
index ee2a48ad3..d6841ec73 100644
--- a/frontend/src/karma.conf.js
+++ b/frontend/src/karma.conf.js
@@ -16,7 +16,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
- dir: require('path').join(__dirname, '../coverage/testAngular'),
+ dir: require('path').join(__dirname, '../coverage/angular-spring-starter-ui'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
From b2c304e6ed01d07d3ade72f5d5db4c110e721fac Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Wed, 1 May 2019 17:09:27 +0200
Subject: [PATCH 12/74] fixing conflicts
---
frontend/angular.json | 18 +++++++++---------
frontend/karma.conf.js | 6 +++---
.../change-password.component.ts | 2 +-
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/frontend/angular.json b/frontend/angular.json
index ac16f795b..acbcf4737 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -3,7 +3,7 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
- "angular-spring-starter-ui": {
+ "testAngular": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
@@ -13,7 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
- "outputPath": "dist/angular-spring-starter-ui",
+ "outputPath": "dist/testAngular",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
@@ -58,18 +58,18 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
- "browserTarget": "angular-spring-starter-ui:build"
+ "browserTarget": "testAngular:build"
},
"configurations": {
"production": {
- "browserTarget": "angular-spring-starter-ui:build:production"
+ "browserTarget": "testAngular:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
- "browserTarget": "angular-spring-starter-ui:build"
+ "browserTarget": "testAngular:build"
}
},
"test": {
@@ -104,7 +104,7 @@
}
}
},
- "angular-spring-starter-ui-e2e": {
+ "testAngular-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
@@ -113,11 +113,11 @@
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
- "devServerTarget": "angular-spring-starter-ui:serve"
+ "devServerTarget": "testAngular:serve"
},
"configurations": {
"production": {
- "devServerTarget": "angular-spring-starter-ui:serve:production"
+ "devServerTarget": "testAngular:serve:production"
}
}
},
@@ -133,5 +133,5 @@
}
}
},
- "defaultProject": "angular-spring-starter-ui"
+ "defaultProject": "testAngular"
}
diff --git a/frontend/karma.conf.js b/frontend/karma.conf.js
index 25a1e0922..d49cc253b 100644
--- a/frontend/karma.conf.js
+++ b/frontend/karma.conf.js
@@ -28,10 +28,10 @@ module.exports = function (config) {
dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
-
+
reporters: config.angularCli && config.angularCli.codeCoverage
- ? ['progress', 'coverage-istanbul']
- : ['progress', 'kjhtml'],
+ ? ['progress', 'coverage-istanbul']
+ : ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
diff --git a/frontend/src/app/change-password/change-password.component.ts b/frontend/src/app/change-password/change-password.component.ts
index 891046a24..f94bde810 100644
--- a/frontend/src/app/change-password/change-password.component.ts
+++ b/frontend/src/app/change-password/change-password.component.ts
@@ -50,7 +50,7 @@ export class ChangePasswordComponent implements OnInit {
this.notification = undefined;
this.submitted = true;
- this.authService.changePassword(this.form.value)
+ this.authService.changePassowrd(this.form.value)
.pipe(mergeMap(() => this.authService.logout()))
.subscribe(() => {
this.router.navigate(['/login', {msgType: 'success', msgBody: 'Success! Please sign in with your new password.'}]);
From d54afdbe36686499cef09ea15eeba4e96e82bc97 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Wed, 1 May 2019 17:11:22 +0200
Subject: [PATCH 13/74] fixing conflicts
---
frontend/src/karma.conf.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/src/karma.conf.js b/frontend/src/karma.conf.js
index d6841ec73..ee2a48ad3 100644
--- a/frontend/src/karma.conf.js
+++ b/frontend/src/karma.conf.js
@@ -16,7 +16,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
- dir: require('path').join(__dirname, '../coverage/angular-spring-starter-ui'),
+ dir: require('path').join(__dirname, '../coverage/testAngular'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
From b5461ae4afdaac6e806d134048e9fa678034d6b4 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Wed, 1 May 2019 17:19:22 +0200
Subject: [PATCH 14/74] updated
---
frontend/karma.conf.js | 6 +++---
frontend/src/app/service/auth.service.ts | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frontend/karma.conf.js b/frontend/karma.conf.js
index d49cc253b..25a1e0922 100644
--- a/frontend/karma.conf.js
+++ b/frontend/karma.conf.js
@@ -28,10 +28,10 @@ module.exports = function (config) {
dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
-
+
reporters: config.angularCli && config.angularCli.codeCoverage
- ? ['progress', 'coverage-istanbul']
- : ['progress', 'kjhtml'],
+ ? ['progress', 'coverage-istanbul']
+ : ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
diff --git a/frontend/src/app/service/auth.service.ts b/frontend/src/app/service/auth.service.ts
index ab9976540..3a6f7f329 100644
--- a/frontend/src/app/service/auth.service.ts
+++ b/frontend/src/app/service/auth.service.ts
@@ -46,7 +46,7 @@ export class AuthService {
}));
}
- changePassword(passwordChanger) {
+ changePassowrd(passwordChanger) {
return this.apiService.post(this.config.change_password_url, passwordChanger);
}
From a9c1de6f1c286fab0df18cbd6193dd0f809e6fc1 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Fri, 19 Apr 2019 19:39:56 +0200
Subject: [PATCH 15/74] Updated to angular 7
---
frontend/src/app/service/api.service.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/src/app/service/api.service.ts b/frontend/src/app/service/api.service.ts
index b421e1197..3d30a5d55 100644
--- a/frontend/src/app/service/api.service.ts
+++ b/frontend/src/app/service/api.service.ts
@@ -20,7 +20,7 @@ export enum RequestMethod {
export class ApiService {
headers = new HttpHeaders({
- 'Accept': 'application/json',
+ Accept: 'application/json',
'Content-Type': 'application/json'
});
From 698c1da085f5c7ce8f78c3dd21fd907e05620977 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sat, 20 Apr 2019 13:06:33 +0200
Subject: [PATCH 16/74] Updated to angular 7
---
frontend/src/app/service/api.service.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/src/app/service/api.service.ts b/frontend/src/app/service/api.service.ts
index 3d30a5d55..b421e1197 100644
--- a/frontend/src/app/service/api.service.ts
+++ b/frontend/src/app/service/api.service.ts
@@ -20,7 +20,7 @@ export enum RequestMethod {
export class ApiService {
headers = new HttpHeaders({
- Accept: 'application/json',
+ 'Accept': 'application/json',
'Content-Type': 'application/json'
});
From 0db562c29164d79d9ed39ddc4572d2559608a47f Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 22:36:01 +0200
Subject: [PATCH 17/74] feature/update
---
frontend/package.json | 70 +++++++++----------
.../service/impl/AuthorityServiceImpl.java | 6 +-
.../impl/CustomUserDetailsService.java | 18 +++--
.../bfwg/service/impl/UserServiceImpl.java | 14 ++--
4 files changed, 60 insertions(+), 48 deletions(-)
diff --git a/frontend/package.json b/frontend/package.json
index 97ebdfac0..35b65385d 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -11,44 +11,44 @@
},
"private": true,
"dependencies": {
- "@angular/animations": "~7.2.0",
- "@angular/cdk": "~7.3.7",
- "@angular/common": "~7.2.0",
- "@angular/compiler": "~7.2.0",
- "@angular/core": "~7.2.0",
- "@angular/flex-layout": "^7.0.0-beta.24",
- "@angular/forms": "~7.2.0",
- "@angular/http": "^7.2.13",
- "@angular/material": "^7.3.7",
- "@angular/platform-browser": "~7.2.0",
- "@angular/platform-browser-dynamic": "~7.2.0",
- "@angular/router": "~7.2.0",
- "core-js": "^2.5.4",
+ "@angular/animations": "~8.2.14",
+ "@angular/cdk": "~8.2.3",
+ "@angular/common": "~8.2.14",
+ "@angular/compiler": "~8.2.14",
+ "@angular/core": "~8.2.14",
+ "@angular/flex-layout": "^8.0.0-beta.27",
+ "@angular/forms": "~8.2.14",
+ "@angular/http": "^7.2.15",
+ "@angular/material": "^8.2.3",
+ "@angular/platform-browser": "~8.2.14",
+ "@angular/platform-browser-dynamic": "~8.2.14",
+ "@angular/router": "~8.2.14",
+ "core-js": "^3.6.0",
"hammerjs": "^2.0.8",
- "rxjs": "^6.3.3",
- "rxjs-compat": "^6.4.0",
- "tslib": "^1.9.0",
- "zone.js": "~0.8.26"
+ "rxjs": "^6.5.3",
+ "rxjs-compat": "^6.5.3",
+ "tslib": "^1.10.0",
+ "zone.js": "~0.10.2"
},
"devDependencies": {
- "@angular-devkit/build-angular": "~0.13.0",
- "@angular/cli": "~7.3.8",
- "@angular/compiler-cli": "~7.2.0",
- "@angular/language-service": "~7.2.0",
- "@types/node": "~8.9.4",
- "@types/jasmine": "~2.8.8",
- "@types/jasminewd2": "~2.0.3",
- "codelyzer": "~4.5.0",
- "jasmine-core": "~2.99.1",
+ "@angular-devkit/build-angular": "~0.803.21",
+ "@angular/cli": "~8.3.21",
+ "@angular/compiler-cli": "~8.2.14",
+ "@angular/language-service": "~8.2.14",
+ "@types/node": "~12.12.21",
+ "@types/jasmine": "~3.5.0",
+ "@types/jasminewd2": "~2.0.8",
+ "codelyzer": "~5.2.1",
+ "jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
- "karma": "~4.0.0",
- "karma-chrome-launcher": "~2.2.0",
- "karma-coverage-istanbul-reporter": "~2.0.1",
- "karma-jasmine": "~1.1.2",
- "karma-jasmine-html-reporter": "^0.2.2",
- "protractor": "~5.4.0",
- "ts-node": "~7.0.0",
- "tslint": "~5.11.0",
- "typescript": "~3.2.2"
+ "karma": "~4.4.1",
+ "karma-chrome-launcher": "~3.1.0",
+ "karma-coverage-istanbul-reporter": "~2.1.1",
+ "karma-jasmine": "~2.0.1",
+ "karma-jasmine-html-reporter": "^1.4.2",
+ "protractor": "~5.4.2",
+ "ts-node": "~8.5.4",
+ "tslint": "~5.20.1",
+ "typescript": "~3.7.4"
}
}
diff --git a/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java b/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java
index 63ac1f5f2..c9643b535 100644
--- a/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java
+++ b/server/src/main/java/com/bfwg/service/impl/AuthorityServiceImpl.java
@@ -11,8 +11,12 @@
@Service
public class AuthorityServiceImpl implements AuthorityService {
+ private final AuthorityRepository authorityRepository;
+
@Autowired
- private AuthorityRepository authorityRepository;
+ public AuthorityServiceImpl(AuthorityRepository authorityRepository) {
+ this.authorityRepository = authorityRepository;
+ }
@Override
public List findById(Long id) {
diff --git a/server/src/main/java/com/bfwg/service/impl/CustomUserDetailsService.java b/server/src/main/java/com/bfwg/service/impl/CustomUserDetailsService.java
index 95578bcd7..acfbde302 100644
--- a/server/src/main/java/com/bfwg/service/impl/CustomUserDetailsService.java
+++ b/server/src/main/java/com/bfwg/service/impl/CustomUserDetailsService.java
@@ -24,14 +24,18 @@ public class CustomUserDetailsService implements UserDetailsService {
protected final Log LOGGER = LogFactory.getLog(getClass());
- @Autowired
- private UserRepository userRepository;
+ private final UserRepository userRepository;
- @Autowired
- private PasswordEncoder passwordEncoder;
+ private final PasswordEncoder passwordEncoder;
+
+ private final AuthenticationManager authenticationManager;
@Autowired
- private AuthenticationManager authenticationManager;
+ public CustomUserDetailsService(UserRepository userRepository, PasswordEncoder passwordEncoder, AuthenticationManager authenticationManager) {
+ this.userRepository = userRepository;
+ this.passwordEncoder = passwordEncoder;
+ this.authenticationManager = authenticationManager;
+ }
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
@@ -49,7 +53,7 @@ public void changePassword(String oldPassword, String newPassword) {
String username = currentUser.getName();
if (authenticationManager != null) {
- LOGGER.debug("Re-authenticating user '"+ username + "' for password change request.");
+ LOGGER.debug("Re-authenticating user '" + username + "' for password change request.");
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, oldPassword));
} else {
@@ -58,7 +62,7 @@ public void changePassword(String oldPassword, String newPassword) {
return;
}
- LOGGER.debug("Changing password for user '"+ username + "'");
+ LOGGER.debug("Changing password for user '" + username + "'");
User user = (User) loadUserByUsername(username);
diff --git a/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java b/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java
index 93c69c1f6..2ac588d9d 100644
--- a/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java
+++ b/server/src/main/java/com/bfwg/service/impl/UserServiceImpl.java
@@ -21,14 +21,18 @@
@Service
public class UserServiceImpl implements UserService {
- @Autowired
- private UserRepository userRepository;
+ private final UserRepository userRepository;
- @Autowired
- private PasswordEncoder passwordEncoder;
+ private final PasswordEncoder passwordEncoder;
+
+ private final AuthorityService authService;
@Autowired
- private AuthorityService authService;
+ public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder, AuthorityService authService) {
+ this.userRepository = userRepository;
+ this.passwordEncoder = passwordEncoder;
+ this.authService = authService;
+ }
public void resetCredentials() {
List users = userRepository.findAll();
From a471500b40e0f216edfb94d9dd1c7234d5fa7999 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 22:50:56 +0200
Subject: [PATCH 18/74] updating the package.json
---
frontend/package.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/frontend/package.json b/frontend/package.json
index 35b65385d..5eb7d6055 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -32,12 +32,12 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.21",
- "@angular/cli": "~8.3.21",
+ "@angular/cli": "^8.3.21",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
- "@types/node": "~12.12.21",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.8",
+ "@types/node": "~12.12.21",
"codelyzer": "~5.2.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
From e97005de880e6796d1546004193b8edf3169a8b3 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 23:06:10 +0200
Subject: [PATCH 19/74] feature/update
---
frontend/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/package.json b/frontend/package.json
index 5eb7d6055..e5420a64c 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -49,6 +49,6 @@
"protractor": "~5.4.2",
"ts-node": "~8.5.4",
"tslint": "~5.20.1",
- "typescript": "~3.7.4"
+ "typescript": "^3.7.4"
}
}
From 55089c2ed211058349de47d3f7a27f2fc26ff174 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 23:14:50 +0200
Subject: [PATCH 20/74] update
---
frontend/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/package.json b/frontend/package.json
index e5420a64c..980dec5b7 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -49,6 +49,6 @@
"protractor": "~5.4.2",
"ts-node": "~8.5.4",
"tslint": "~5.20.1",
- "typescript": "^3.7.4"
+ "typescript": "^3.5.3"
}
}
From a630e6faca798c2d7b44606b5f41c0f1f79f91f1 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 23:22:49 +0200
Subject: [PATCH 21/74] feature/update
---
frontend/src/app/component/header/header.component.scss | 2 +-
frontend/src/app/polyfills.ts | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/frontend/src/app/component/header/header.component.scss b/frontend/src/app/component/header/header.component.scss
index 4854221ad..80180d40a 100644
--- a/frontend/src/app/component/header/header.component.scss
+++ b/frontend/src/app/component/header/header.component.scss
@@ -32,7 +32,7 @@
}
-/deep/ {
+::ng-deep {
.app-header-accountMenu.mat-menu-panel {
border-radius: 3px;
max-width: initial;
diff --git a/frontend/src/app/polyfills.ts b/frontend/src/app/polyfills.ts
index 21605c0ad..00ed34187 100644
--- a/frontend/src/app/polyfills.ts
+++ b/frontend/src/app/polyfills.ts
@@ -41,8 +41,7 @@
/** Evergreen browsers require these. **/
-import 'core-js/es6/reflect';
-import 'core-js/es7/reflect';
+import 'core-js/es/reflect';
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
From 3de40c1e613257e159c94fd8beae778d72af1302 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 23:30:09 +0200
Subject: [PATCH 22/74] feature/update
---
frontend/README.md | 6 +++---
frontend/src/index.html | 8 ++++----
server/README.md | 2 +-
server/pom.xml | 4 ++--
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/frontend/README.md b/frontend/README.md
index 38796822f..fe3dcf596 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -1,7 +1,7 @@
-# Angular7 Spring Boot JWT Starter
-This sub-project is the frontend UI portion of the project and it was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.8.
+# Angular 8 Spring Boot JWT Starter
+This sub-project is the frontend UI portion of the project and it was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.3.21.
-**Make sure you also have NPM 6.9.0, Node 10.15.3 and angular-cli@7.3.8 globally installed**
+**Make sure you also have NPM 6.9.0, Node 10.15.3 and angular-cli@8.3.21 globally installed**
## File Structure
```
diff --git a/frontend/src/index.html b/frontend/src/index.html
index c3cb34efe..04ddb6fcb 100644
--- a/frontend/src/index.html
+++ b/frontend/src/index.html
@@ -2,14 +2,14 @@
- Angular7 Spring Boot JWT Starter
+ Angular 8 Spring Boot JWT Starter
-
-
-
+
+
+
diff --git a/server/README.md b/server/README.md
index e8541388a..c37042e87 100644
--- a/server/README.md
+++ b/server/README.md
@@ -1,4 +1,4 @@
-# Angular7 Spring Boot JWT Starter
+# Angular 8 Spring Boot JWT Starter
This sub-project is the backend server portion of the project.
**Make sure you have Maven and Java 1.8 or greater**
diff --git a/server/pom.xml b/server/pom.xml
index 9c99b82aa..142204495 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -9,12 +9,12 @@
jar
angular-spring-starter
- The backend server for Angular7 Spring Boot JWT Starter
+ The backend server for Angular 8 Spring Boot JWT Starter
org.springframework.boot
spring-boot-starter-parent
- 2.1.4.RELEASE
+ 2.2.2.RELEASE
From 93f4c056da8c51298e32bdf2725136f1ab78ca97 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 23:38:04 +0200
Subject: [PATCH 23/74] feature/update
---
README.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 7ae5cb13e..95a142ab9 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,8 @@
-# Angular5 Spring Boot JWT Starter
-> An Angular full stack starter kit featuring [Angular 4](https://angular.io), [Router](https://angular.io/docs/ts/latest/guide/router.html), [Forms](https://angular.io/docs/ts/latest/guide/forms.html),
+# Angular 8 Spring Boot JWT Starter
+> An Angular full stack starter kit featuring [Angular 8](https://angular.io), [Router](https://angular.io/docs/ts/latest/guide/router.html), [Forms](https://angular.io/docs/ts/latest/guide/forms.html),
[Http](https://angular.io/docs/ts/latest/guide/server-communication.html),
[Services](https://gist.github.com/gdi2290/634101fec1671ee12b3e#_follow_@AngularClass_on_twitter),
[Spring boot](https://projects.spring.io/spring-boot/),
@@ -25,8 +25,8 @@
## Quick start
-**Make sure you have Maven and Java 1.7 or greater**
-**Make sure you also have NPM 3.1, Node 6.9.5 and angular-cli@1.0.0 globally installed**
+**Make sure you have Maven and Java 1.8 or greater**
+**Make sure you also have NPM 6.12.0, Node 12.13.0 and angular-cli@8.3.21 globally installed**
```bash
# clone our repo
# --depth 1 removes all but one .git commit history
From d590d932b4a0c1c592dd4af843bdd29e5f90c087 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Sun, 22 Dec 2019 23:44:27 +0200
Subject: [PATCH 24/74] feature/update
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 2ad772be8..695e0d7c4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,4 +2,4 @@ before_install: cd server
language: java
jdk:
- - oraclejdk8
+ - openjdk8
From 96062f7f58e64763dfb7761c54ed3832d56fcf09 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Mon, 23 Dec 2019 11:27:33 +0200
Subject: [PATCH 25/74] feature/update
---
server/src/main/resources/application.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml
index 9ed70d00f..cec2acbd2 100644
--- a/server/src/main/resources/application.yml
+++ b/server/src/main/resources/application.yml
@@ -1,5 +1,5 @@
app:
- name: anuglar2-spring-jwt
+ name: angular2-spring-jwt
jwt:
header: Authorization
From bee1fef4117e1aacdcc2985b5b53ccb847c1adf0 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Mon, 23 Dec 2019 11:30:17 +0200
Subject: [PATCH 26/74] feature/update
---
.../com/bfwg/config/WebSecurityConfig.java | 118 +++++++++---------
1 file changed, 57 insertions(+), 61 deletions(-)
diff --git a/server/src/main/java/com/bfwg/config/WebSecurityConfig.java b/server/src/main/java/com/bfwg/config/WebSecurityConfig.java
index 95b2dcc08..3d5a34597 100644
--- a/server/src/main/java/com/bfwg/config/WebSecurityConfig.java
+++ b/server/src/main/java/com/bfwg/config/WebSecurityConfig.java
@@ -1,5 +1,7 @@
package com.bfwg.config;
+import com.bfwg.security.auth.*;
+import com.bfwg.service.impl.CustomUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
@@ -15,12 +17,6 @@
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
-import com.bfwg.security.auth.AuthenticationFailureHandler;
-import com.bfwg.security.auth.AuthenticationSuccessHandler;
-import com.bfwg.security.auth.LogoutSuccess;
-import com.bfwg.security.auth.RestAuthenticationEntryPoint;
-import com.bfwg.security.auth.TokenAuthenticationFilter;
-import com.bfwg.service.impl.CustomUserDetailsService;
/**
* Created by fan.jin on 2016-10-19.
@@ -30,60 +26,60 @@
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
- @Value("${jwt.cookie}")
- private String TOKEN_COOKIE;
-
- @Bean
- public TokenAuthenticationFilter jwtAuthenticationTokenFilter() throws Exception {
- return new TokenAuthenticationFilter();
- }
-
- @Bean
- @Override
- public AuthenticationManager authenticationManagerBean() throws Exception {
- return super.authenticationManagerBean();
- }
-
- @Bean
- public PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-
- @Autowired
- private CustomUserDetailsService jwtUserDetailsService;
-
- @Autowired
- private RestAuthenticationEntryPoint restAuthenticationEntryPoint;
-
- @Autowired
- private LogoutSuccess logoutSuccess;
-
- @Autowired
- public void configureGlobal(AuthenticationManagerBuilder authenticationManagerBuilder)
- throws Exception {
- authenticationManagerBuilder.userDetailsService(jwtUserDetailsService)
- .passwordEncoder(passwordEncoder());
-
- }
-
- @Autowired
- private AuthenticationSuccessHandler authenticationSuccessHandler;
-
- @Autowired
- private AuthenticationFailureHandler authenticationFailureHandler;
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.csrf().ignoringAntMatchers("/api/login", "/api/signup")
- .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).and()
- .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
- .exceptionHandling().authenticationEntryPoint(restAuthenticationEntryPoint).and()
- .addFilterBefore(jwtAuthenticationTokenFilter(), BasicAuthenticationFilter.class)
- .authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/api/login")
- .successHandler(authenticationSuccessHandler).failureHandler(authenticationFailureHandler)
- .and().logout().logoutRequestMatcher(new AntPathRequestMatcher("/api/logout"))
- .logoutSuccessHandler(logoutSuccess).deleteCookies(TOKEN_COOKIE);
-
- }
+ private final CustomUserDetailsService jwtUserDetailsService;
+ private final RestAuthenticationEntryPoint restAuthenticationEntryPoint;
+ private final LogoutSuccess logoutSuccess;
+ private final AuthenticationSuccessHandler authenticationSuccessHandler;
+ private final AuthenticationFailureHandler authenticationFailureHandler;
+
+ @Value("${jwt.cookie}")
+ private String TOKEN_COOKIE;
+
+ @Autowired
+ public WebSecurityConfig(CustomUserDetailsService jwtUserDetailsService, RestAuthenticationEntryPoint restAuthenticationEntryPoint, LogoutSuccess logoutSuccess, AuthenticationSuccessHandler authenticationSuccessHandler, AuthenticationFailureHandler authenticationFailureHandler) {
+ this.jwtUserDetailsService = jwtUserDetailsService;
+ this.restAuthenticationEntryPoint = restAuthenticationEntryPoint;
+ this.logoutSuccess = logoutSuccess;
+ this.authenticationSuccessHandler = authenticationSuccessHandler;
+ this.authenticationFailureHandler = authenticationFailureHandler;
+ }
+
+ @Bean
+ public TokenAuthenticationFilter jwtAuthenticationTokenFilter() throws Exception {
+ return new TokenAuthenticationFilter();
+ }
+
+ @Bean
+ @Override
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Autowired
+ public void configureGlobal(AuthenticationManagerBuilder authenticationManagerBuilder)
+ throws Exception {
+ authenticationManagerBuilder.userDetailsService(jwtUserDetailsService)
+ .passwordEncoder(passwordEncoder());
+
+ }
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().ignoringAntMatchers("/api/login", "/api/signup")
+ .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).and()
+ .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
+ .exceptionHandling().authenticationEntryPoint(restAuthenticationEntryPoint).and()
+ .addFilterBefore(jwtAuthenticationTokenFilter(), BasicAuthenticationFilter.class)
+ .authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/api/login")
+ .successHandler(authenticationSuccessHandler).failureHandler(authenticationFailureHandler)
+ .and().logout().logoutRequestMatcher(new AntPathRequestMatcher("/api/logout"))
+ .logoutSuccessHandler(logoutSuccess).deleteCookies(TOKEN_COOKIE);
+
+ }
}
From 28595663815d4587a07fe82c62d65f8cea421344 Mon Sep 17 00:00:00 2001
From: Craig Stroberg
Date: Mon, 23 Dec 2019 11:52:38 +0200
Subject: [PATCH 27/74] feature/update
---
.../com/bfwg/config/WebSecurityConfig.java | 4 +-
.../bfwg/rest/AuthenticationController.java | 30 +++---
.../java/com/bfwg/rest/UserController.java | 97 ++++++++++---------
.../auth/AuthenticationSuccessHandler.java | 50 +++++-----
.../com/bfwg/security/auth/LogoutSuccess.java | 14 ++-
.../auth/TokenAuthenticationFilter.java | 4 +-
.../com/bfwg/service/AuthorityService.java | 7 +-
.../java/com/bfwg/service/UserService.java | 13 +--
.../service/impl/AuthorityServiceImpl.java | 25 ++---
.../bfwg/service/impl/UserServiceImpl.java | 17 ++--
10 files changed, 140 insertions(+), 121 deletions(-)
diff --git a/server/src/main/java/com/bfwg/config/WebSecurityConfig.java b/server/src/main/java/com/bfwg/config/WebSecurityConfig.java
index 3d5a34597..3aed827ee 100644
--- a/server/src/main/java/com/bfwg/config/WebSecurityConfig.java
+++ b/server/src/main/java/com/bfwg/config/WebSecurityConfig.java
@@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
@@ -31,12 +32,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final LogoutSuccess logoutSuccess;
private final AuthenticationSuccessHandler authenticationSuccessHandler;
private final AuthenticationFailureHandler authenticationFailureHandler;
-
@Value("${jwt.cookie}")
private String TOKEN_COOKIE;
@Autowired
- public WebSecurityConfig(CustomUserDetailsService jwtUserDetailsService, RestAuthenticationEntryPoint restAuthenticationEntryPoint, LogoutSuccess logoutSuccess, AuthenticationSuccessHandler authenticationSuccessHandler, AuthenticationFailureHandler authenticationFailureHandler) {
+ public WebSecurityConfig(@Lazy CustomUserDetailsService jwtUserDetailsService, RestAuthenticationEntryPoint restAuthenticationEntryPoint, LogoutSuccess logoutSuccess, @Lazy AuthenticationSuccessHandler authenticationSuccessHandler, AuthenticationFailureHandler authenticationFailureHandler) {
this.jwtUserDetailsService = jwtUserDetailsService;
this.restAuthenticationEntryPoint = restAuthenticationEntryPoint;
this.logoutSuccess = logoutSuccess;
diff --git a/server/src/main/java/com/bfwg/rest/AuthenticationController.java b/server/src/main/java/com/bfwg/rest/AuthenticationController.java
index 04fd30c3c..b0978f0dc 100644
--- a/server/src/main/java/com/bfwg/rest/AuthenticationController.java
+++ b/server/src/main/java/com/bfwg/rest/AuthenticationController.java
@@ -24,14 +24,12 @@
*/
@RestController
-@RequestMapping( value = "/api", produces = MediaType.APPLICATION_JSON_VALUE )
+@RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE)
public class AuthenticationController {
- @Autowired
- private CustomUserDetailsService userDetailsService;
+ private final TokenHelper tokenHelper;
- @Autowired
- TokenHelper tokenHelper;
+ private final CustomUserDetailsService userDetailsService;
@Value("${jwt.expires_in}")
private int EXPIRES_IN;
@@ -39,26 +37,32 @@ public class AuthenticationController {
@Value("${jwt.cookie}")
private String TOKEN_COOKIE;
+ @Autowired
+ public AuthenticationController(CustomUserDetailsService userDetailsService, TokenHelper tokenHelper) {
+ this.userDetailsService = userDetailsService;
+ this.tokenHelper = tokenHelper;
+ }
+
@RequestMapping(value = "/refresh", method = RequestMethod.GET)
public ResponseEntity> refreshAuthenticationToken(HttpServletRequest request, HttpServletResponse response) {
- String authToken = tokenHelper.getToken( request );
+ String authToken = tokenHelper.getToken(request);
if (authToken != null && tokenHelper.canTokenBeRefreshed(authToken)) {
// TODO check user password last update
String refreshedToken = tokenHelper.refreshToken(authToken);
- Cookie authCookie = new Cookie( TOKEN_COOKIE, ( refreshedToken ) );
- authCookie.setPath( "/" );
- authCookie.setHttpOnly( true );
- authCookie.setMaxAge( EXPIRES_IN );
+ Cookie authCookie = new Cookie(TOKEN_COOKIE, (refreshedToken));
+ authCookie.setPath("/");
+ authCookie.setHttpOnly(true);
+ authCookie.setMaxAge(EXPIRES_IN);
// Add cookie to response
- response.addCookie( authCookie );
+ response.addCookie(authCookie);
UserTokenState userTokenState = new UserTokenState(refreshedToken, EXPIRES_IN);
return ResponseEntity.ok(userTokenState);
} else {
UserTokenState userTokenState = new UserTokenState();
- return ResponseEntity.accepted().body(userTokenState);
+ return ResponseEntity.accepted().body(userTokenState);
}
}
@@ -67,7 +71,7 @@ public ResponseEntity> refreshAuthenticationToken(HttpServletRequest request,
public ResponseEntity> changePassword(@RequestBody PasswordChanger passwordChanger) {
userDetailsService.changePassword(passwordChanger.oldPassword, passwordChanger.newPassword);
Map result = new HashMap<>();
- result.put( "result", "success" );
+ result.put("result", "success");
return ResponseEntity.accepted().body(result);
}
diff --git a/server/src/main/java/com/bfwg/rest/UserController.java b/server/src/main/java/com/bfwg/rest/UserController.java
index 9328f6c3b..90ac3b5d2 100644
--- a/server/src/main/java/com/bfwg/rest/UserController.java
+++ b/server/src/main/java/com/bfwg/rest/UserController.java
@@ -1,10 +1,9 @@
package com.bfwg.rest;
-import static org.springframework.web.bind.annotation.RequestMethod.GET;
-import static org.springframework.web.bind.annotation.RequestMethod.POST;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.bfwg.exception.ResourceConflictException;
+import com.bfwg.model.User;
+import com.bfwg.model.UserRequest;
+import com.bfwg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -17,10 +16,13 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;
-import com.bfwg.exception.ResourceConflictException;
-import com.bfwg.model.User;
-import com.bfwg.model.UserRequest;
-import com.bfwg.service.UserService;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.springframework.web.bind.annotation.RequestMethod.GET;
+import static org.springframework.web.bind.annotation.RequestMethod.POST;
/**
* Created by fan.jin on 2016-10-15.
@@ -30,51 +32,54 @@
@RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE)
public class UserController {
- @Autowired
- private UserService userService;
+ private final UserService userService;
+ @Autowired
+ public UserController(UserService userService) {
+ this.userService = userService;
+ }
- @RequestMapping(method = GET, value = "/user/{userId}")
- public User loadById(@PathVariable Long userId) {
- return this.userService.findById(userId);
- }
+ @RequestMapping(method = GET, value = "/user/{userId}")
+ public User loadById(@PathVariable Long userId) {
+ return this.userService.findById(userId);
+ }
- @RequestMapping(method = GET, value = "/user/all")
- public List loadAll() {
- return this.userService.findAll();
- }
+ @RequestMapping(method = GET, value = "/user/all")
+ public List loadAll() {
+ return this.userService.findAll();
+ }
- @RequestMapping(method = GET, value = "/user/reset-credentials")
- public ResponseEntity