This repository was archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#33 cms page
- Loading branch information
Showing
34 changed files
with
375 additions
and
473 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
import { UserService } from './core'; | ||
|
||
import { User } from '../../common/entities'; | ||
|
||
@Component({ | ||
selector: 'app', | ||
templateUrl: 'app.component.html' | ||
}) | ||
|
||
export class AppComponent implements OnInit { | ||
|
||
constructor() {} | ||
constructor( | ||
private userService: UserService | ||
) {} | ||
|
||
public ngOnInit() { | ||
this.getMe(); | ||
} | ||
|
||
private getMe() { | ||
this.userService.getMe().subscribe((user: User) => { | ||
|
||
}, (error: Error) => { | ||
|
||
public ngOnInit() {} | ||
}); | ||
} | ||
} |
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,11 @@ | ||
<section class="footer"> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque, nulla magni vel molestias nihil asperiores non omnis qui ab modi id voluptatem voluptatibus consectetur cum, minima ullam quo tempora temporibus. | ||
</p> | ||
</section> | ||
<section class="footer-credit"> | ||
<p> | ||
© 2018 Copyright | ||
Made by: <a href="https://github.com/UltraRangers">[email protected]</a> | ||
</p> | ||
</section> |
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,13 @@ | ||
@import '../../../stylesheets/palette.scss'; | ||
|
||
section.footer { | ||
padding: 20px; | ||
color: white; | ||
background-color: $primary-color; | ||
} | ||
|
||
section.footer-credit { | ||
padding: 20px; | ||
color: white; | ||
background-color: $primary-color-dark; | ||
} |
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,14 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'cms-footer', | ||
templateUrl: 'cms-footer.component.html', | ||
styleUrls: ['cms-footer.component.scss'] | ||
}) | ||
|
||
export class CmsFooterComponent implements OnInit { | ||
|
||
public constructor() { } | ||
|
||
public ngOnInit() { } | ||
} |
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 @@ | ||
<header></header> |
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 @@ | ||
@import '../../../stylesheets/palette.scss'; | ||
|
||
header { | ||
display: block; | ||
width: 100%; | ||
height: 70px; | ||
background-color: $primary-color; | ||
} |
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,14 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'cms-header', | ||
templateUrl: 'cms-header.component.html', | ||
styleUrls: ['cms-header.component.scss'] | ||
}) | ||
|
||
export class CmsHeaderComponent implements OnInit { | ||
|
||
public constructor() { } | ||
|
||
public ngOnInit() { } | ||
} |
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 { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
|
||
import { CurrentUserGuard } from '../core'; | ||
|
||
import { CmsComponent } from './cms.component'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: CmsComponent, | ||
canActivate: [CurrentUserGuard], | ||
children: [] | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule] | ||
}) | ||
export class CmsRoutingModule { } | ||
|
||
export const routedComponents = [ | ||
CmsComponent | ||
]; |
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 @@ | ||
<section class="logo"> | ||
<div class="overlay"></div> | ||
<p>LOGO</p> | ||
</section> | ||
<mat-list role="list"> | ||
<a mat-list-item routerLink="/cms" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">Home</a> | ||
<a mat-list-item (click)="onClickLogout()">Logout</a> | ||
</mat-list> |
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,26 @@ | ||
@import '../../../stylesheets/palette.scss'; | ||
|
||
.logo { | ||
position: relative; | ||
width: 100%; | ||
height: 240px; | ||
background-color: $primary-color; | ||
|
||
p { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
color: white; | ||
} | ||
} | ||
|
||
mat-list { | ||
a { | ||
text-decoration: none; | ||
cursor: pointer; | ||
} | ||
a.active, a:hover { | ||
background-color: rgba($color: #000000, $alpha: 0.2); | ||
} | ||
} |
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,22 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
import { UserService } from '../../core'; | ||
|
||
@Component({ | ||
selector: 'cms-sidenav', | ||
templateUrl: 'cms-sidenav.component.html', | ||
styleUrls: ['cms-sidenav.component.scss'] | ||
}) | ||
|
||
export class CmsSidenavComponent implements OnInit { | ||
|
||
public constructor( | ||
private userService: UserService | ||
) { } | ||
|
||
public ngOnInit() { } | ||
|
||
public onClickLogout() { | ||
this.userService.logout(); | ||
} | ||
} |
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,12 @@ | ||
<mat-sidenav-container class="sidenav-container"> | ||
<mat-sidenav #sidenav mode="side" opened="true"> | ||
<cms-sidenav></cms-sidenav> | ||
</mat-sidenav> | ||
<mat-sidenav-content> | ||
<cms-header></cms-header> | ||
<section class="cms-container"> | ||
<router-outlet></router-outlet> | ||
</section> | ||
<cms-footer></cms-footer> | ||
</mat-sidenav-content> | ||
</mat-sidenav-container> |
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,19 @@ | ||
.sidenav-container { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
background: white; | ||
} | ||
|
||
mat-sidenav { | ||
width: 240px; | ||
box-shadow: 3px 0 6px rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
section.cms-container { | ||
width: 90%; | ||
min-height: 100vh; | ||
margin: 0 auto; | ||
} |
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,13 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'cms', | ||
templateUrl: 'cms.component.html', | ||
styleUrls: ['cms.component.scss'] | ||
}) | ||
export class CmsComponent implements OnInit { | ||
|
||
public constructor() { } | ||
|
||
public ngOnInit() { } | ||
} |
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,26 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { SharedModule } from '../shared'; | ||
|
||
import { CmsRoutingModule, routedComponents } from './cms-routing.module'; | ||
|
||
import { CmsFooterComponent } from './cms-footer/cms-footer.component'; | ||
import { CmsHeaderComponent } from './cms-header/cms-header.component'; | ||
import { CmsSidenavComponent } from './cms-sidenav/cms-sidenav.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
SharedModule, | ||
CmsRoutingModule | ||
], | ||
exports: [], | ||
declarations: [ | ||
routedComponents, | ||
CmsFooterComponent, | ||
CmsHeaderComponent, | ||
CmsSidenavComponent | ||
], | ||
providers: [] | ||
}) | ||
export class CmsModule { } |
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,24 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; | ||
|
||
import { User } from '../../../../common/entities'; | ||
import { UserService } from '../services/user.service'; | ||
|
||
@Injectable() | ||
export class CurrentUserGuard implements CanActivate { | ||
|
||
public constructor( | ||
private userService: UserService, | ||
private router: Router | ||
) { } | ||
|
||
public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | ||
return this.userService.currentUser$.map((user: User) => { | ||
if (!user) { | ||
this.router.navigate(['/']); | ||
} | ||
return !!user; | ||
}) | ||
.take(1); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// core modules | ||
export * from './core.module'; | ||
|
||
export * from './guards/current-user.guard'; | ||
|
||
// core services | ||
export * from './services/api.service'; | ||
export * from './services/user.service'; |
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,5 @@ | ||
import { createRouteParamDecorator } from '@nestjs/common'; | ||
|
||
export const CurrentUser = createRouteParamDecorator((data, request) => { | ||
return request.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,10 @@ | ||
import { CanActivate, ExecutionContext, Guard } from '@nestjs/common'; | ||
import { Observable } from 'rxjs/Observable'; | ||
|
||
@Guard() | ||
export class AccessTokenGuard implements CanActivate { | ||
|
||
public canActivate(request, context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> { | ||
return request.user ? true : false; | ||
} | ||
} |
Oops, something went wrong.