Skip to content

Commit

Permalink
Add routing
Browse files Browse the repository at this point in the history
  • Loading branch information
marvac committed Jan 12, 2019
1 parent 876ff95 commit 9d10abb
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 11 deletions.
3 changes: 0 additions & 3 deletions Client/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
<nav-menu></nav-menu>
<app-home></app-home>



5 changes: 4 additions & 1 deletion Client/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { AuthService } from './services/auth.service';
import { JwtHelperService } from '@auth0/angular-jwt';
import { Title } from '@angular/platform-browser';

@Component({
selector: 'app-root',
Expand All @@ -12,9 +13,11 @@ export class AppComponent implements OnInit {
private title = 'Friendster';
private jwtHelper = new JwtHelperService();

constructor(private authService: AuthService) { }
constructor(private authService: AuthService, private titleService: Title) { }

ngOnInit(): void {
this.titleService.setTitle(this.title);

const token = localStorage.getItem('token');
if (token) {
this.authService.decodedToken = this.jwtHelper.decodeToken(token);
Expand Down
12 changes: 10 additions & 2 deletions Client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ import { RegisterComponent } from './components/register/register.component';
import { ErrorInterceptorProvider } from './services/error.interceptor';
import { AlertifyService } from './services/alertify.service';
import { BsDropdownModule } from 'ngx-bootstrap';
import { MemberListComponent } from './components/member-list/member-list.component';
import { ListsComponent } from './components/lists/lists.component';
import { MessagesComponent } from './components/messages/messages.component';
import { RouterModule } from '@angular/router';

@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
HomeComponent,
RegisterComponent
RegisterComponent,
MemberListComponent,
ListsComponent,
MessagesComponent
],
imports: [
BrowserModule,
HttpClientModule,
FormsModule,
BsDropdownModule.forRoot()
BsDropdownModule.forRoot(),
RouterModule
],
providers: [
AuthService,
Expand Down
2 changes: 1 addition & 1 deletion Client/src/app/components/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h1>Find your friend</h1>
<p class="lead">Come on in to view your friends... All you need to do is sign up!</p>
<div class="text-center">
<button class="btn btn-primary btn-lg mr-2" (click)="startRegisterMode()">Register</button>
<button class="btn btn-info btn-lg">Learn more</button>
<button class="btn btn-default btn-lg">Learn more</button>
</div>
</div>
<div class="container" *ngIf="registerMode">
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions Client/src/app/components/lists/lists.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
lists works!
</p>
25 changes: 25 additions & 0 deletions Client/src/app/components/lists/lists.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ListsComponent } from './lists.component';

describe('ListsComponent', () => {
let component: ListsComponent;
let fixture: ComponentFixture<ListsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListsComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ListsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions Client/src/app/components/lists/lists.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-lists',
templateUrl: './lists.component.html',
styleUrls: ['./lists.component.css']
})
export class ListsComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
member-list works!
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { MemberListComponent } from './member-list.component';

describe('MemberListComponent', () => {
let component: MemberListComponent;
let fixture: ComponentFixture<MemberListComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MemberListComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(MemberListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions Client/src/app/components/member-list/member-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-member-list',
templateUrl: './member-list.component.html',
styleUrls: ['./member-list.component.css']
})
export class MemberListComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
Empty file.
3 changes: 3 additions & 0 deletions Client/src/app/components/messages/messages.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
messages works!
</p>
25 changes: 25 additions & 0 deletions Client/src/app/components/messages/messages.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { MessagesComponent } from './messages.component';

describe('MessagesComponent', () => {
let component: MessagesComponent;
let fixture: ComponentFixture<MessagesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MessagesComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(MessagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions Client/src/app/components/messages/messages.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-messages',
templateUrl: './messages.component.html',
styleUrls: ['./messages.component.css']
})
export class MessagesComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
5 changes: 1 addition & 4 deletions Client/src/app/components/nav-menu/nav-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">

<a class="navbar-brand" href="#">Friendster</a>

<ul class="navbar-nav mr-auto" *ngIf="isAuthenticated()">
Expand Down Expand Up @@ -30,9 +29,7 @@
<form #loginForm="ngForm" class="form-inline my-2 my-lg-0" (ngSubmit)="login()" *ngIf="!isAuthenticated()">
<input class="form-control mr-sm-2" type="text" name="username" placeholder="Username" required [(ngModel)]="model.username">
<input class="form-control mr-sm-2" type="password" name="password" placeholder="Password" required [(ngModel)]="model.password">
<button [disabled]="!loginForm.valid" class="btn btn-primary my-2 my-sm-0" type="submit">Login</button>
<button [disabled]="!loginForm.valid" class="btn btn-secondary my-2 my-sm-0" type="submit">Login</button>
</form>
</div>


</nav>
13 changes: 13 additions & 0 deletions Client/src/app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Routes } from '@angular/router';
import { HomeComponent } from './components/home/home.component';
import { MemberListComponent } from './components/member-list/member-list.component';
import { MessagesComponent } from './components/messages/messages.component';
import { ListsComponent } from './components/lists/lists.component';

export const appRoutes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'members', component: MemberListComponent },
{ path: 'messages', component: MessagesComponent },
{ path: 'lists', component: ListsComponent },
{ path: '**', redirectTo: 'home', pathMatch: 'full' }
]

0 comments on commit 9d10abb

Please sign in to comment.