Fixed bug with admin routes never loading. Added basic library view.
This commit is contained in:
parent
3f8a4d7866
commit
79a23ac406
8 changed files with 31 additions and 6 deletions
|
|
@ -1,10 +1,17 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { AdminGuard } from '../_guards/admin.guard';
|
||||
import { UsersComponent } from './users/users.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{path: '**', component: UsersComponent, pathMatch: 'full'},
|
||||
{
|
||||
runGuardsAndResolvers: 'always',
|
||||
canActivate: [AdminGuard],
|
||||
children: [
|
||||
{path: '/users', component: UsersComponent}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LibraryComponent } from './library/library.component';
|
||||
import { AdminGuard } from './_guards/admin.guard';
|
||||
|
||||
const routes: Routes = [
|
||||
{path: '', component: HomeComponent},
|
||||
{
|
||||
path: 'admin',
|
||||
runGuardsAndResolvers: 'always',
|
||||
canActivate: [AdminGuard],
|
||||
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule)
|
||||
},
|
||||
{path: 'library', component: LibraryComponent},
|
||||
{path: '**', component: HomeComponent, pathMatch: 'full'}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,15 @@ import { JwtInterceptor } from './_interceptors/jwt.interceptor';
|
|||
import { UserLoginComponent } from './user-login/user-login.component';
|
||||
import { ToastrModule } from 'ngx-toastr';
|
||||
import { ErrorInterceptor } from './_interceptors/error.interceptor';
|
||||
import { LibraryComponent } from './library/library.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
HomeComponent,
|
||||
NavHeaderComponent,
|
||||
UserLoginComponent
|
||||
UserLoginComponent,
|
||||
LibraryComponent
|
||||
],
|
||||
imports: [
|
||||
HttpClientModule,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export class HomeComponent implements OnInit {
|
|||
|
||||
console.log('Registering: ', this.model);
|
||||
this.accountService.register(this.model).subscribe(resp => {
|
||||
this.router.navigateByUrl('/libraries');
|
||||
this.router.navigateByUrl('/library');
|
||||
}, err => {
|
||||
console.log('validation errors from interceptor', err);
|
||||
});
|
||||
|
|
|
|||
1
src/app/library/library.component.html
Normal file
1
src/app/library/library.component.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<p>library works!</p>
|
||||
0
src/app/library/library.component.scss
Normal file
0
src/app/library/library.component.scss
Normal file
15
src/app/library/library.component.ts
Normal file
15
src/app/library/library.component.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library',
|
||||
templateUrl: './library.component.html',
|
||||
styleUrls: ['./library.component.scss']
|
||||
})
|
||||
export class LibraryComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ export class UserLoginComponent implements OnInit {
|
|||
this.accountService.login(this.model).subscribe(user => {
|
||||
if (user) {
|
||||
this.loginForm.reset();
|
||||
this.router.navigateByUrl('/libraries');
|
||||
this.router.navigateByUrl('/library');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue