-
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.
Initial Commit (Basic Framework and Dummy Data)
- Loading branch information
Showing
64 changed files
with
1,470 additions
and
75 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
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 { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { AuthPage } from './auth.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: AuthPage | ||
}, | ||
{ | ||
path: 'login', | ||
loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule) | ||
}, | ||
{ | ||
path: 'register', | ||
loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule) | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class AuthPageRoutingModule {} |
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,23 +1,20 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { IonicModule } from '@ionic/angular'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
import { HomePage } from './home.page'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { AuthPageRoutingModule } from './auth-routing.module'; | ||
|
||
import { AuthPage } from './auth.page'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule, | ||
RouterModule.forChild([ | ||
{ | ||
path: '', | ||
component: HomePage | ||
} | ||
]) | ||
AuthPageRoutingModule | ||
], | ||
declarations: [HomePage] | ||
declarations: [AuthPage] | ||
}) | ||
export class HomePageModule {} | ||
export class AuthPageModule {} |
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 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>auth</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content> | ||
|
||
</ion-content> |
Empty file.
12 changes: 6 additions & 6 deletions
12
src/app/home/home.page.spec.ts → src/app/auth/auth.page.spec.ts
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,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-auth', | ||
templateUrl: './auth.page.html', | ||
styleUrls: ['./auth.page.scss'], | ||
}) | ||
export class AuthPage implements OnInit { | ||
|
||
constructor() { } | ||
|
||
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,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class AuthService { | ||
private authenticated = true; | ||
private userId = 'u1'; | ||
|
||
get isAuthenticated() { | ||
return this.authenticated; | ||
} | ||
|
||
get getUserId() { | ||
return this.userId; | ||
} | ||
|
||
login() { | ||
this.authenticated = true; | ||
} | ||
|
||
logout() { | ||
this.authenticated = false; | ||
} | ||
|
||
constructor() { } | ||
} |
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,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { LoginPage } from './login.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: LoginPage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class LoginPageRoutingModule {} |
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,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { LoginPageRoutingModule } from './login-routing.module'; | ||
|
||
import { LoginPage } from './login.page'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
IonicModule, | ||
LoginPageRoutingModule | ||
], | ||
declarations: [LoginPage] | ||
}) | ||
export class LoginPageModule {} |
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,38 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title class="ion-text-center">Log in</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content> | ||
<form [formGroup]="form"> | ||
<ion-grid> | ||
<ion-row> | ||
<ion-col class="ion-text-center"> | ||
<p>Sign in to see the latest content</p> | ||
</ion-col> | ||
</ion-row> | ||
<ion-row class="ion-justify-content-center"> | ||
<ion-col size="6"> | ||
<ion-item> | ||
<ion-label class="ion-text-center" position="floating">Email/Username</ion-label> | ||
<ion-input type="text" formControlName="login"></ion-input> | ||
</ion-item> | ||
</ion-col> | ||
</ion-row> | ||
<ion-row class="ion-justify-content-center"> | ||
<ion-col size="6"> | ||
<ion-item> | ||
<ion-label class="ion-text-center" position="floating">Password</ion-label> | ||
<ion-input type="password" formControlName="password"></ion-input> | ||
</ion-item> | ||
</ion-col> | ||
</ion-row> | ||
<ion-row class="ion-text-center" style="padding-top: 10px;"> | ||
<ion-col> | ||
<ion-button type="submit" (click)="onLogin()">Log in</ion-button> | ||
</ion-col> | ||
</ion-row> | ||
</ion-grid> | ||
</form> | ||
</ion-content> |
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,24 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { LoginPage } from './login.page'; | ||
|
||
describe('LoginPage', () => { | ||
let component: LoginPage; | ||
let fixture: ComponentFixture<LoginPage>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ LoginPage ], | ||
imports: [IonicModule.forRoot()] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LoginPage); | ||
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,41 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormGroup, FormControl, Validators } from '@angular/forms'; | ||
import { AuthService } from '../auth.service'; | ||
import { Router } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app-login', | ||
templateUrl: './login.page.html', | ||
styleUrls: ['./login.page.scss'], | ||
}) | ||
export class LoginPage implements OnInit { | ||
form: FormGroup; | ||
|
||
constructor(private authService: AuthService, private router: Router) { } | ||
|
||
ngOnInit() { | ||
this.form = new FormGroup({ | ||
login: new FormControl(null, { | ||
updateOn: 'blur', | ||
validators: [Validators.required, Validators.maxLength(255)] | ||
}), | ||
password: new FormControl(null, { | ||
updateOn: 'blur', | ||
validators: [Validators.required, Validators.maxLength(255)] | ||
}) | ||
}); | ||
} | ||
|
||
onLogin() { | ||
if (!this.form.valid) { | ||
return; | ||
} | ||
|
||
const login = this.form.value.login; | ||
const password = this.form.value.password; | ||
|
||
this.authService.login(); | ||
this.form.reset(); | ||
this.router.navigateByUrl('/tabs/feed'); | ||
} | ||
} |
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,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { RegisterPage } from './register.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: RegisterPage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class RegisterPageRoutingModule {} |
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,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { RegisterPageRoutingModule } from './register-routing.module'; | ||
|
||
import { RegisterPage } from './register.page'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
IonicModule, | ||
RegisterPageRoutingModule | ||
], | ||
declarations: [RegisterPage] | ||
}) | ||
export class RegisterPageModule {} |
Oops, something went wrong.