Skip to content

Commit

Permalink
#114 replaced pages file with each page having it's own module so tha…
Browse files Browse the repository at this point in the history
…t lazy loading can be used. Still need to convert to using smart and dumb components, currently all components are containers. Also moved guards, services, and some components to a /core file
  • Loading branch information
Exilliar committed Feb 16, 2020
1 parent 91af047 commit 7c27e46
Show file tree
Hide file tree
Showing 73 changed files with 356 additions and 216 deletions.
22 changes: 22 additions & 0 deletions frontend/src/app/admin/admin-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

// Containers
import { AdminPageComponent } from './containers/admin-page/admin-page.component';
import { ViewTablePageComponent } from './containers/view-table-page/view-table-page.component';

const routes: Routes = [
{
path: '',
component: AdminPageComponent
}, {
path: 'viewTable/:uid',
component: ViewTablePageComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AdminRoutingModule { }
20 changes: 20 additions & 0 deletions frontend/src/app/admin/admin.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { MaterialModule } from 'src/app/material.module';

import { AdminRoutingModule } from './admin-routing.module';

// Containers
import { AdminPageComponent } from './containers/admin-page/admin-page.component';
import { ViewTablePageComponent } from './containers/view-table-page/view-table-page.component';

@NgModule({
declarations: [AdminPageComponent, ViewTablePageComponent],
imports: [
CommonModule,
AdminRoutingModule,
MaterialModule,
]
})
export class AdminModule { }
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { LoginComponent } from './login.component';
import { AdminPageComponent } from './admin-page.component';

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

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

beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
fixture = TestBed.createComponent(AdminPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ import {

import { Router } from '@angular/router';

import { UserService } from 'src/app/services/userService/user.service';
import { FilmDataService } from 'src/app/services/film-data/film-data.service';
import { AdminService } from 'src/app/services/admin/admin.service';
import { RolesService } from 'src/app/services/roles/roles.service';
import { UserService } from 'src/app/core/services/userService/user.service';
import { FilmDataService } from 'src/app/core/services/film-data/film-data.service';
import { AdminService } from 'src/app/core/services/admin/admin.service';
import { RolesService } from 'src/app/core/services/roles/roles.service';

import { User } from 'src/app/models/user.model';
import { Role } from 'src/app/models/role.model';
import { RawUser } from 'src/app/models/raw-user.model';
import { User } from 'src/app/core/models/user.model';
import { Role } from 'src/app/core/models/role.model';
import { RawUser } from 'src/app/core/models/raw-user.model';

@Component({
selector: 'app-admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.scss']
selector: 'app-admin-page',
templateUrl: './admin-page.component.html',
styleUrls: ['./admin-page.component.scss']
})
export class AdminComponent implements OnInit {

export class AdminPageComponent implements OnInit {
constructor(
private adminService: AdminService,
private snackBar: MatSnackBar,
Expand Down Expand Up @@ -203,7 +202,7 @@ export class AdminComponent implements OnInit {
}

viewTable(uid: string): void {
this.router.navigate(['/viewTable', uid])
this.router.navigate(['/admin/viewTable', uid])
}

applyFilter(filterValue: string): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ViewTablePageComponent } from './view-table-page.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import {

import { ActivatedRoute } from '@angular/router';

import { Film } from 'src/app/models/film.model';
import { Film } from 'src/app/core/models/film.model';

import { FilmDataService } from 'src/app/services/film-data/film-data.service';
import { FilmDataService } from 'src/app/core/services/film-data/film-data.service';

@Component({
selector: 'app-view-table',
templateUrl: './view-table.component.html',
styleUrls: ['./view-table.component.scss']
selector: 'app-view-table-page',
templateUrl: './view-table-page.component.html',
styleUrls: ['./view-table-page.component.scss']
})
export class ViewTableComponent implements OnInit {

export class ViewTablePageComponent implements OnInit {
constructor(
private filmDataService: FilmDataService,
private snackBar: MatSnackBar,
Expand Down Expand Up @@ -130,5 +129,4 @@ export class ViewTableComponent implements OnInit {
});
}
}

}
37 changes: 16 additions & 21 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

// Components
import { BluraysComponent } from './pages/blurays/blurays.component';
import { LoginComponent } from './pages/login/login.component';
import { RegisterComponent } from './pages/register/register.component';
import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component';
import { AdminComponent } from './pages/admin/admin.component';
import { PageNotFoundComponent } from './core/components/page-not-found/page-not-found.component';

// Guards
import { AuthGuard } from './guards/auth/auth.guard';
import { LoginGuard } from './guards/login/login.guard';
import { AdminGuard } from './guards/admin/admin.guard';
import { ViewTableComponent } from './pages/viewTable/view-table.component';
import { AuthGuard } from './core/guards/auth/auth.guard';
import { LoginGuard } from './core/guards/login/login.guard';
import { AdminGuard } from './core/guards/admin/admin.guard';

const routes: Routes = [
{
Expand All @@ -21,24 +16,24 @@ const routes: Routes = [
pathMatch: 'full'
}, {
path: 'login',
component: LoginComponent,
canActivate: [LoginGuard]
canActivate: [LoginGuard],
loadChildren: () =>
import('./login/login.module').then(m => m.LoginModule)
}, {
path: 'register',
component: RegisterComponent,
canActivate: [LoginGuard]
canActivate: [LoginGuard],
loadChildren: () =>
import('./register/register.module').then(m => m.RegisterModule)
}, {
path: 'blurays',
component: BluraysComponent,
canActivate: [AuthGuard]
canActivate: [AuthGuard],
loadChildren: () =>
import('./blurays/blurays.module').then(m => m.BluraysModule)
}, {
path: 'admin',
component: AdminComponent,
canActivate: [AuthGuard, AdminGuard]
}, {
path: 'viewTable/:uid',
component: ViewTableComponent,
canActivate: [AuthGuard, AdminGuard]
canActivate: [AuthGuard, AdminGuard],
loadChildren: () =>
import('./admin/admin.module').then(m => m.AdminModule)
}, {
path: '**',
component: PageNotFoundComponent
Expand Down
26 changes: 9 additions & 17 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,36 @@ import { environment } from '../environments/environment';

// Material modules
import { MaterialModule } from './material.module';
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";

// Firebase authentication
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth';

import { AuthGuard } from './guards/auth/auth.guard';
import { AuthService } from './services/authService/auth.service';
import { UserService } from './services/userService/user.service';
import { AuthGuard } from './core/guards/auth/auth.guard';
import { AuthService } from './core/services/authService/auth.service';
import { UserService } from './core/services/userService/user.service';

// Forms
import { ReactiveFormsModule } from '@angular/forms';
import { FormsModule } from '@angular/forms';

// Services
import { ThemeService } from './services/theme/theme.service';
import { ThemeService } from './core/services/theme/theme.service';

// Components
import { AddFilmDialogComponent } from './components/add-film-dialog/add-film-dialog.component';
import { BluraysComponent } from './pages/blurays/blurays.component';
import { HeaderComponent } from './components/header/header.component';
import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component';
import { LoginComponent } from './pages/login/login.component';
import { RegisterComponent } from './pages/register/register.component';
import { AdminComponent } from './pages/admin/admin.component';
import { ViewTableComponent } from './pages/viewTable/view-table.component';
import { AddFilmDialogComponent } from './core/components/add-film-dialog/add-film-dialog.component';
import { HeaderComponent } from './core/components/header/header.component';
import { PageNotFoundComponent } from './core/components/page-not-found/page-not-found.component';


@NgModule({
declarations: [
AppComponent,
BluraysComponent,
LoginComponent,
RegisterComponent,
AddFilmDialogComponent,
PageNotFoundComponent,
HeaderComponent,
AdminComponent,
ViewTableComponent
],
imports: [
BrowserModule,
Expand All @@ -70,6 +61,7 @@ import { ViewTableComponent } from './pages/viewTable/view-table.component';
ReactiveFormsModule,
FormsModule,
HttpModule,
BrowserAnimationsModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
],
providers: [AuthService, UserService, AuthGuard, ThemeService],
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/app/blurays/blurays-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

// Containers
import { BluraysPageComponent } from './containers/blurays-page/blurays-page.component';

const routes: Routes = [
{
path: '',
component: BluraysPageComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BluraysRoutingModule { }
19 changes: 19 additions & 0 deletions frontend/src/app/blurays/blurays.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { MaterialModule } from 'src/app/material.module';

import { BluraysRoutingModule } from './blurays-routing.module';

// Containers
import { BluraysPageComponent } from './containers/blurays-page/blurays-page.component';

@NgModule({
declarations: [BluraysPageComponent],
imports: [
CommonModule,
MaterialModule,
BluraysRoutingModule,
]
})
export class BluraysModule { }
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { RegisterComponent } from './register.component';
import { BluraysPageComponent } from './blurays-page.component';

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

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

beforeEach(() => {
fixture = TestBed.createComponent(RegisterComponent);
fixture = TestBed.createComponent(BluraysPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ import {
} from '@angular/material';
import {MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog';

import { Film } from 'src/app/models/film.model';
import { Film } from 'src/app/core/models/film.model';

import { UserService } from 'src/app/services/userService/user.service';
import { UserService } from 'src/app/core/services/userService/user.service';

import { FilmDataService } from 'src/app/services/film-data/film-data.service';
import { AdminService } from 'src/app/services/admin/admin.service';
import { FilmDataService } from 'src/app/core/services/film-data/film-data.service';
import { AdminService } from 'src/app/core/services/admin/admin.service';

import { AddFilmDialogComponent } from 'src/app/components/add-film-dialog/add-film-dialog.component';
import { AddFilmDialogComponent } from 'src/app/core/components/add-film-dialog/add-film-dialog.component';

@Component({
selector: 'app-blurays',
templateUrl: './blurays.component.html',
styleUrls: ['./blurays.component.scss']
selector: 'app-blurays-page',
templateUrl: './blurays-page.component.html',
styleUrls: ['./blurays-page.component.scss']
})
export class BluraysComponent implements OnInit {

export class BluraysPageComponent implements OnInit {
constructor(
private filmDataService: FilmDataService,
private userService: UserService,
Expand Down Expand Up @@ -215,4 +214,4 @@ export class BluraysComponent implements OnInit {
);
}
}
}
}
Loading

0 comments on commit 7c27e46

Please sign in to comment.