Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b3bf1a
commit aec0311
Showing
18 changed files
with
192 additions
and
8 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
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 { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
|
||
const appRoutes: Routes = [ | ||
{ | ||
path: '', | ||
redirectTo: '/login', | ||
pathMatch: 'full' | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forRoot( | ||
appRoutes | ||
) | ||
], | ||
exports: [ | ||
RouterModule | ||
], | ||
}) | ||
export class AppRoutingModule { } |
File renamed without changes.
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,10 @@ | ||
import { OpaqueToken } from '@angular/core'; | ||
|
||
export let APP_CONFIG = new OpaqueToken('app.config'); | ||
|
||
export const CONFIG = { | ||
// apiEndpoint: 'http://192.168.1.106:1337', | ||
apiEndpoint: 'http://gymcheadmin/api', | ||
// imagesEndpoint: 'http://192.168.1.106:1337/images', | ||
imagesEndpoint: 'http://gymcheadmin/api/images', | ||
}; |
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,35 @@ | ||
import { Inject, Injectable } from '@angular/core'; | ||
import { Headers, Http } from '@angular/http'; | ||
|
||
import 'rxjs/add/operator/toPromise'; | ||
|
||
import { APP_CONFIG } from '../app.config'; | ||
|
||
@Injectable() | ||
export class AuthenticationService { | ||
private headers = new Headers({'Content-Type': 'application/json'}); | ||
|
||
constructor( | ||
private http: Http, @Inject(APP_CONFIG) private config) { } | ||
|
||
signIn(authUser): Promise<any> { | ||
return this.http | ||
.post(this.config.apiEndpoint + '/admin/auth/signin', JSON.stringify(authUser), {headers: this.headers}) | ||
.toPromise() | ||
.then(() => console.log('login successful')) | ||
.catch(this.handleError); | ||
} | ||
|
||
signOut(): Promise<any> { | ||
return this.http | ||
.get(this.config.apiEndpoint + '/admin/auth/signout', {headers: this.headers}) | ||
.toPromise() | ||
.then(response => response) | ||
.catch(this.handleError); | ||
} | ||
|
||
private handleError(error: any): Promise<any> { | ||
console.error('An error occurred', error); | ||
return Promise.reject(error); | ||
} | ||
} |
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 '@ngrx/core/add/operator/select'; | ||
import {compose} from '@ngrx/core/compose'; | ||
// import {storeLogger} from 'ngrx-store-logger'; | ||
import { combineReducers } from '@ngrx/store'; | ||
|
||
import userReducer from './user/user.reducer'; | ||
import {User} from './user/user.model'; | ||
|
||
export interface AppState { | ||
admin: User; | ||
} | ||
|
||
// uncomment the storeLogger import and this line | ||
// and comment out the other export default line to turn on | ||
// the store logger to see the actions as they flow through the store | ||
// turned this off by default as i found the logger kinda noisy | ||
|
||
// export default compose(storeLogger(), combineReducers)({ | ||
|
||
export default compose(combineReducers)({ | ||
user: userReducer, | ||
}); |
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 {Injectable} from '@angular/core'; | ||
import {Action} from '@ngrx/store'; | ||
import {User} from './user.model'; | ||
|
||
@Injectable() | ||
export class UserActions { | ||
static LOAD_USER = 'LOAD_USER'; | ||
static CLEAR_USER = 'CLEAR_USER'; | ||
|
||
loadUser(user: User): Action { | ||
return { | ||
type: UserActions.LOAD_USER, | ||
payload: user | ||
}; | ||
} | ||
|
||
clearUser(): Action { | ||
return { | ||
type: UserActions.CLEAR_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 { | ||
id: string; | ||
email: string; | ||
name: string; | ||
profileImage: string; | ||
lastSignInAt: string; | ||
updatedAt: 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,27 @@ | ||
import { Action } from '@ngrx/store'; | ||
|
||
import { User } from './user.model'; | ||
import { UserActions } from './user.actions'; | ||
|
||
const initialState: User = { | ||
id: null, | ||
email: null, | ||
name: null, | ||
profileImage: null, | ||
lastSignInAt: null, | ||
updatedAt: null | ||
}; | ||
|
||
export default function reducer(state = initialState, action: Action) { | ||
switch (action.type) { | ||
case UserActions.LOAD_USER: { | ||
return action.payload; | ||
} | ||
case UserActions.CLEAR_USER: { | ||
return initialState; | ||
} | ||
default: { | ||
return state; | ||
} | ||
} | ||
} |
Empty file.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import "./sass/variables.sass" | ||
|
||
|
||
@import "../node_modules/bulma/bulma.sass" |
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