-
Notifications
You must be signed in to change notification settings - Fork 17
ISSUE-100: Add lazy loading of modules #132
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
<at-navigation></at-navigation> | ||
<router-outlet></router-outlet> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { HttpModule } from '@angular/http'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { NgModule } from '@angular/core'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering what that CUSTOM_ELEMENTS_SCHEMA was even doing. I think that's for Polymer elements or something :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, i'm looking at cleaning that up as well. This has to do with how we're including the angular material modules. If we include them correctly, we'll get rid of these errors. |
||
import { MaterialModule } from '@angular/material'; | ||
|
||
import { | ||
Router | ||
} from '@angular/router'; | ||
|
||
// import { routing } from './app.routes'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { ProjectModule } from './project'; | ||
import { EmployeeModule } from './employee/'; | ||
import { CoreModule } from './core'; | ||
|
||
import 'hammerjs'; | ||
|
||
import { MaterialModule } from '@angular/material'; | ||
|
||
import { ExtHttpConfig } from './core/ExtHttpConfig'; | ||
|
||
import { AppRoutingModule } from './app-routing.module'; | ||
import { LoginComponent } from './core/login.component'; | ||
import { LoginRoutingModule } from './core/login-routing.module'; | ||
import { PageNotFoundComponent } from './core/not-found.component'; | ||
import { NavigationComponent } from './core/navigation.component'; | ||
import { TimesheetModule } from './timesheet/timesheet.module'; | ||
|
||
|
@@ -41,24 +31,18 @@ const extHttpConfig = { | |
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
MaterialModule, | ||
HttpModule, | ||
FormsModule, | ||
CoreModule.forRoot(extHttpConfig), | ||
EmployeeModule, | ||
ProjectModule, | ||
TimesheetModule, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I basically just gave up on this for now and included the timesheet module eagerly. |
||
LoginRoutingModule, | ||
AppRoutingModule, | ||
MaterialModule.forRoot(), | ||
], | ||
declarations: [ | ||
AppComponent, | ||
LoginComponent, | ||
PageNotFoundComponent, | ||
NavigationComponent, | ||
], | ||
bootstrap: [ AppComponent ], | ||
schemas: [ CUSTOM_ELEMENTS_SCHEMA ], | ||
}) | ||
export class AppModule { | ||
// Diagnostic only: inspect router configuration | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
CanActivate, | ||
Router | ||
} from '@angular/router'; | ||
|
||
import { IdentityService } from './identity.service'; | ||
|
||
@Injectable() | ||
export class AuthGuard implements CanActivate { | ||
constructor(private identityService: IdentityService, private router: Router) { } | ||
|
||
canActivate() { | ||
const isAuthenticated = this.identityService.user.authenticated; | ||
|
||
if (isAuthenticated) { | ||
return true; | ||
} else { | ||
// The original URL that the user intends to access is not stored by this approach. | ||
this.router.navigate(['/login']); | ||
return false; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,30 +2,43 @@ import { | |
NgModule, | ||
ModuleWithProviders | ||
} from '@angular/core'; | ||
import { HttpModule } from '@angular/http'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { MaterialModule } from '@angular/material'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import 'hammerjs'; | ||
|
||
import { IdentityService } from './identity.service'; | ||
import { LocalStorage } from './localStorage'; | ||
import { LoginService } from './login.service'; | ||
import { ResponseHandler } from './responseHandler.service'; | ||
import { ExtHttp } from './extHttp.service'; | ||
import { ExtHttpConfig } from './ExtHttpConfig'; | ||
import { AuthGuard } from './auth-guard.service'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
import { ProjectService } from '../project/project.service'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
BrowserAnimationsModule, | ||
HttpModule, | ||
], | ||
exports: [ | ||
CommonModule, | ||
FormsModule, | ||
BrowserAnimationsModule, | ||
HttpModule, | ||
], | ||
providers: [ | ||
ExtHttp, | ||
IdentityService, | ||
LocalStorage, | ||
LoginService, | ||
ResponseHandler, | ||
AuthGuard, | ||
ProjectService, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ProjectService is used outside of the project module. |
||
] | ||
}) | ||
export class CoreModule { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,8 @@ import { | |
} from '../core'; | ||
|
||
@Component({ | ||
selector: 'at-login', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed a bunch of selectors that don't do anything. They're routed directly via routers. |
||
templateUrl: './login.component.html', | ||
styleUrls: ['./login.component.scss'] | ||
styleUrls: ['./login.component.scss'], | ||
}) | ||
export class LoginComponent implements OnInit { | ||
error: boolean; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,43 @@ | ||
<div class="nav-toolbar"> | ||
<md-toolbar color="primary"> | ||
Angular Timesheets | ||
<div class="main-container"> | ||
<div class="nav-toolbar"> | ||
<md-toolbar color="primary"> | ||
<button md-icon-button (click)="sidenav.toggle()" *ngIf="user.authenticated"> | ||
<md-icon>menu</md-icon> | ||
</button> | ||
Angular Timesheets | ||
|
||
<span class="nav-fill-remaining"></span> | ||
<span class="nav-fill-remaining"></span> | ||
<ng-container *ngIf="user.authenticated"> | ||
<span>{{user?.name.first}} {{user?.name.last}}</span> | ||
<button md-icon-button [mdMenuTriggerFor]="menu"> | ||
<md-icon>more_vert</md-icon> | ||
</button> | ||
<md-menu #menu="mdMenu"> | ||
<button md-menu-item (click)="logout()"> | ||
<md-icon>exit_to_app</md-icon> | ||
<span>Logout</span> | ||
</button> | ||
</md-menu> | ||
</ng-container> | ||
</md-toolbar> | ||
</div> | ||
<md-sidenav-container class="side-nav-container"> | ||
<md-sidenav #sidenav class="side-nav-content" mode="side"> | ||
<ul class="side-nav-items"> | ||
<li class="side-nav-item"> | ||
<a routerLink="/projects">Projects</a> | ||
</li> | ||
<li class="side-nav-item"> | ||
<a routerLink="/timesheets">Timesheets</a> | ||
</li> | ||
<li class="side-nav-item"> | ||
<a routerLink="/employees">Employees</a> | ||
</li> | ||
</ul> | ||
</md-sidenav> | ||
|
||
<span>{{user.name.first}} {{user.name.last}}</span> | ||
<button md-icon-button [mdMenuTriggerFor]="menu"> | ||
<md-icon>more_vert</md-icon> | ||
</button> | ||
<md-menu #menu="mdMenu"> | ||
<button md-menu-item (click)="logout()"> | ||
<md-icon>exit_to_app</md-icon> | ||
<span>Logout</span> | ||
</button> | ||
</md-menu> | ||
</md-toolbar> | ||
</div> | ||
<div class="main-container"> | ||
<router-outlet></router-outlet> | ||
<div class="example-sidenav-content"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</md-sidenav-container> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<router-outlet></router-outlet> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { | ||
Component, | ||
OnInit | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './employee-root.component.html' | ||
}) | ||
export class EmployeeRootComponent implements OnInit { | ||
constructor() {} | ||
ngOnInit() {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<router-outlet></router-outlet> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were apparently using an old version of this.. 👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always pretty cool bumping deps, but was this why things were breaking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is about all that I can give you. angular/angular#15185 I believe it has to do with their approach to overriding the global Error object - https://github.com/angular/zone.js/blob/v0.8.5/CHANGELOG.md