-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ne-peer/feat/manage
[feat -> master] scaffolding manage feature
- Loading branch information
Showing
14 changed files
with
2,700 additions
and
2,553 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.message { | ||
padding: 10vh; | ||
font-size: 22px; | ||
color: #aaa; | ||
} | ||
|
||
.dd-text-small { | ||
font-size: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p class="lead text-center"> | ||
Hello <span class="text-success">{{user?.name}}</span> !! | ||
<br> | ||
<span class="dd-text-small">Your id is <span class="text-success">{{user?.id}}</span> .</span> | ||
</p> | ||
|
||
<p class="lead text-center message"> | ||
Sorry, this feature is work in progress. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ExistComponent } from './exist.component'; | ||
|
||
describe('ExistComponent', () => { | ||
let component: ExistComponent; | ||
let fixture: ComponentFixture<ExistComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ExistComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ExistComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Router, CanActivate, RouterStateSnapshot, ActivatedRoute } from '@angular/router'; | ||
import { AuthGuardService } from '../../../services/web/auth-guard.service'; | ||
import { LocalStorage } from '@ngx-pwa/local-storage'; | ||
import { User } from '../../../models/store/user'; | ||
|
||
@Component({ | ||
selector: 'app-exist', | ||
templateUrl: './exist.component.html', | ||
styleUrls: ['./exist.component.css'], | ||
providers: [AuthGuardService] | ||
}) | ||
export class ExistComponent implements OnInit { | ||
|
||
private user: User; | ||
|
||
constructor(private authGuard: AuthGuardService, private acRouter: ActivatedRoute, private router: Router, protected localStorage: LocalStorage) { } | ||
|
||
ngOnInit() { | ||
const loggedIn: boolean = this.authGuard.canActivate(this.acRouter.snapshot, this.router.routerState.snapshot); | ||
|
||
this.localStorage.getItem('user').subscribe(user => this.user = user); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export class User { | ||
|
||
constructor( | ||
public id: string, | ||
public name: string | ||
) { } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
|
||
import { AuthGuardService } from './auth-guard.service'; | ||
|
||
describe('AuthGuardService', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [AuthGuardService] | ||
}); | ||
}); | ||
|
||
it('should be created', inject([AuthGuardService], (service: AuthGuardService) => { | ||
expect(service).toBeTruthy(); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; | ||
import { LocalStorage } from '@ngx-pwa/local-storage'; | ||
|
||
@Injectable() | ||
export class AuthGuardService implements CanActivate { | ||
|
||
private loggedIn: boolean; | ||
|
||
constructor(private router: Router, protected localStorage: LocalStorage) { } | ||
|
||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { | ||
|
||
this.localStorage.getItem('user').subscribe(user => { | ||
if (user === null) { | ||
// not logged in so redirect to login page with the return url | ||
this.router.navigate(['/oauth'], { queryParams: { returnUrl: state.url } }); | ||
this.loggedIn = false; | ||
} | ||
|
||
this.loggedIn = true; | ||
}); | ||
|
||
return this.loggedIn; | ||
} | ||
|
||
} |