-
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.
New features: -layout navbar -profile page -login page -registration …
…page -add new phrase
- Loading branch information
1 parent
0cf0872
commit 3a410d4
Showing
43 changed files
with
1,621 additions
and
169 deletions.
There are no files selected for viewing
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 { Injectable } from '@angular/core'; | ||
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; | ||
|
||
import { AuthService } from '../_services/auth.service'; | ||
import { CookiesService } from '../_services/cookies.service'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class AuthGuard implements CanActivate { | ||
constructor( | ||
private router: Router, | ||
private authenticationService: AuthService, private cookiesService: CookiesService | ||
) { } | ||
|
||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | ||
//const currentUser = this.authenticationService.currentUserValue; | ||
const currentUser = this.cookiesService.getCookie("userID"); | ||
if (currentUser) { | ||
// logged in so return true | ||
return true; | ||
} | ||
|
||
// not logged in so redirect to login page with the return url | ||
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } }); | ||
return false; | ||
} | ||
} |
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 @@ | ||
export class PhraseClass { | ||
private quote ?: string; | ||
private author ?: string; | ||
private datePublication ?: string; | ||
private contributor ?: string; | ||
private approved? : boolean; | ||
|
||
constructor(quote: string, author: string, datePublication: string, contributor: string, approved: boolean) { | ||
this.quote = quote; | ||
this.author = author; | ||
this.datePublication = datePublication; | ||
this.contributor = contributor; | ||
this.approved = approved; | ||
} | ||
} |
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,7 @@ | ||
export interface Phrase { | ||
quote: string; | ||
author: string; | ||
datePublication?: string; | ||
contributor?: string; | ||
approved: boolean; | ||
} |
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 @@ | ||
export class User { | ||
uid?: string; | ||
email?: string; | ||
authdata?: string; | ||
tokenJWT?: string; | ||
|
||
constructor(uid: string, email: string){ | ||
this.uid = uid; | ||
this.email = email; | ||
} | ||
} |
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,35 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { BehaviorSubject, Observable } from 'rxjs'; | ||
|
||
import { User } from '../_models/user'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class AuthService { | ||
userId!: string; | ||
email!: string; | ||
/*private currentUserSubject: BehaviorSubject<User>; | ||
constructor(){ | ||
this.currentUserSubject = new BehaviorSubject<User>(); | ||
} | ||
public get currentUserValue(): User { | ||
return this.currentUserSubject.value; | ||
}*/ | ||
|
||
setUserData(userId: string, email: string) { | ||
//this.currentUserSubject?.next(new User(userId, email)); | ||
this.userId = userId; | ||
this.email = email; | ||
} | ||
|
||
getUserID() { | ||
return this.userId; | ||
} | ||
|
||
clearUserData() { | ||
this.userId = ''; | ||
this.email = ''; | ||
} | ||
} |
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,29 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CookiesService { | ||
setCookie(cname: string, cvalue: string, exdays: number) { | ||
const d = new Date(); | ||
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); | ||
let expires = "expires=" + d.toUTCString(); | ||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; | ||
} | ||
|
||
getCookie(cname: string) { | ||
let name = cname + "="; | ||
let decodedCookie = decodeURIComponent(document.cookie); | ||
let ca = decodedCookie.split(';'); | ||
for (let i = 0; i < ca.length; i++) { | ||
let c = ca[i]; | ||
while (c.charAt(0) == ' ') { | ||
c = c.substring(1); | ||
} | ||
if (c.indexOf(name) == 0) { | ||
return c.substring(name.length, c.length); | ||
} | ||
} | ||
return ""; | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
<app-navbar></app-navbar> | ||
<router-outlet></router-outlet> |
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
Empty file.
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,89 @@ | ||
<nav class="navbar navbar-expand-lg fixed-top navbar-transparent" | ||
color-on-scroll="100" id="navbar-top"> | ||
<div class="container"> | ||
<div class="navbar-translate"> | ||
<a class="navbar-brand" placement="bottom" [routerLink]="['/']" | ||
target="_blank" tooltip="Designed and Coded by Creative Tim"> | ||
<span> DailyInspire• </span> | ||
</a> | ||
<button aria-controls="navigation-index" | ||
aria-label="Toggle navigation" class="navbar-toggler navbar-toggler" | ||
[attr.aria-expanded]="!isCollapsed" | ||
(click)="isCollapsed = !isCollapsed" id="navigation" type="button"> | ||
<span class="navbar-toggler-bar bar1"> </span> <span | ||
class="navbar-toggler-bar bar2"> </span> <span | ||
class="navbar-toggler-bar bar3"> </span> | ||
</button> | ||
</div> | ||
<div class="navbar-collapse justify-content-end" [collapse]="isCollapsed" id="navigation"> | ||
<div class="navbar-collapse-header"> | ||
<div class="row"> | ||
<div class="col-6 collapse-brand"> | ||
<a> DailyInspire• </a> | ||
</div> | ||
<div class="col-6 collapse-close text-right"> | ||
<button aria-controls="navigation-index" | ||
aria-label="Toggle navigation" class="navbar-toggler" | ||
[attr.aria-expanded]="!isCollapsed" | ||
(click)="setCollapsed()" id="navigation" | ||
type="button"> | ||
<i class="tim-icons icon-simple-remove"> </i> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item p-0"><a class="nav-link" | ||
href="https://twitter.com" placement="bottom" | ||
target="_blank" tooltip="Follow us on Twitter"> <i | ||
class="fa fa-twitter"> </i> | ||
<p class="d-lg-none d-xl-none">Twitter</p> | ||
</a></li> | ||
<li class="nav-item p-0"><a class="nav-link" | ||
href="https://www.facebook.com" placement="bottom" | ||
target="_blank" tooltip="Like us on Facebook"> <i | ||
class="fa fa-facebook-square"> </i> | ||
<p class="d-lg-none d-xl-none">Facebook</p> | ||
</a></li> | ||
<li class="nav-item p-0"><a class="nav-link" | ||
href="https://www.instagram.com" | ||
placement="bottom" target="_blank" tooltip="Follow us on Instagram"> | ||
<i class="fa fa-instagram"> </i> | ||
<p class="d-lg-none d-xl-none">Instagram</p> | ||
</a></li> | ||
<li class="dropdown nav-item" dropdown><a | ||
class="dropdown-toggle nav-link dropdown-toggle" | ||
data-toggle="dropdown" dropdownToggle href="javascript:void(0)"> | ||
<i class="fa fa-cogs d-lg-none d-xl-none"> </i> Menu | ||
</a> | ||
<div class="dropdown-menu dropdown-with-icons" *dropdownMenu> | ||
<a class="dropdown-item" [routerLink]="['/login']" *ngIf="!userLogged"> <i | ||
class="tim-icons fa fa-sign-in"> </i> Login | ||
</a> | ||
<a class="dropdown-item" [routerLink]="['/registration']" *ngIf="!userLogged"> <i | ||
class="tim-icons fa fa-user-plus"> </i> Registrati | ||
</a> | ||
<a class="dropdown-item" [routerLink]="['/historical']"> <i | ||
class="tim-icons icon-bullet-list-67"> </i> Storico | ||
</a> <a class="dropdown-item" [routerLink]="['/profile']" *ngIf="userLogged"> <i | ||
class="tim-icons icon-single-02"> </i> Profilo | ||
</a> | ||
<a class="dropdown-item" (click)="logout()" *ngIf="userLogged"> <i | ||
class="tim-icons fa fa-power-off"> </i> Logout | ||
</a> | ||
</div> | ||
</li> | ||
|
||
<!-- <li class="nav-item"> --> | ||
<!-- <a --> | ||
<!-- class="nav-link btn btn-default d-none d-lg-block" --> | ||
<!-- href="javascript:void(0)" --> | ||
<!-- (click)="testUpdate()" --> | ||
<!-- > --> | ||
<!-- <i class="tim-icons icon-cloud-download-93"> </i> Download --> | ||
<!-- </a> --> | ||
<!-- </li> --> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> |
Oops, something went wrong.