[frontend] Massive Refactoring: Move public pages to own module, move auth to own module

This commit is contained in:
Cathy Hu 2020-09-09 14:18:12 +02:00
parent 9091654cc0
commit ab9e8faf19
32 changed files with 164 additions and 54 deletions

View file

@ -1,25 +1,22 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { NotFoundComponent } from './shared/not-found/not-found.component'; import { NotFoundComponent } from './shared/not-found/not-found.component';
import { HomepageComponent } from './homepage/homepage.component';
import { LoginComponent } from './auth/login/login.component';
import { RegisterComponent } from './auth/register/register.component';
import { OrganizerspageComponent } from './organizerspage/organizerspage.component';
import { HoodspageComponent } from './hoodspage/hoodspage.component';
import { HoodpageComponent } from './hoodpage/hoodpage.component';
import { SharedModule } from './shared/shared.module'; import { SharedModule } from './shared/shared.module';
import { ConfirmComponent } from './auth/confirm/confirm.component';
import { EmailConfirmationComponent } from './platforms/email/email-confirmation/email-confirmation.component'; import { EmailConfirmationComponent } from './platforms/email/email-confirmation/email-confirmation.component';
import { EmailUnsubscribeComponent } from './platforms/email/email-unsubscribe/email-unsubscribe.component'; import { EmailUnsubscribeComponent } from './platforms/email/email-unsubscribe/email-unsubscribe.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component: HomepageComponent }, {
{ path: 'login', component: LoginComponent }, path: '',
{ path: 'register', component: RegisterComponent }, loadChildren: () =>
{ path: 'confirm', component: ConfirmComponent }, import('./public-pages/public-pages.module').then(
{ path: 'organizers', component: OrganizerspageComponent }, (m) => m.PublicPagesModule
{ path: 'hoods', component: HoodspageComponent }, ),
{ path: 'hoods/:id', component: HoodpageComponent }, },
{
path: '',
loadChildren: () => import('./auth/auth.module').then((m) => m.AuthModule),
},
{ path: 'hoods/:id/email-confirm', component: EmailConfirmationComponent }, { path: 'hoods/:id/email-confirm', component: EmailConfirmationComponent },
{ path: 'hoods/:id/email-unsubscribe', component: EmailUnsubscribeComponent }, { path: 'hoods/:id/email-unsubscribe', component: EmailUnsubscribeComponent },
{ {

View file

@ -2,4 +2,3 @@
<div class="content"> <div class="content">
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>
<app-footer></app-footer>

View file

@ -1,56 +1,29 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { SharedModule } from './shared/shared.module'; import { SharedModule } from './shared/shared.module';
import { HomepageComponent } from './homepage/homepage.component';
import { OrganizerspageComponent } from './organizerspage/organizerspage.component';
import { DashboardModule } from './dashboard/dashboard.module'; import { DashboardModule } from './dashboard/dashboard.module';
import { HoodpageComponent } from './hoodpage/hoodpage.component';
import { HoodspageComponent } from './hoodspage/hoodspage.component';
import { ApiModule } from './core/api/api.module'; import { ApiModule } from './core/api/api.module';
import { import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
HttpClientModule,
HTTP_INTERCEPTORS,
HttpClient,
} from '@angular/common/http';
import { BASE_PATH } from './core/api/variables'; import { BASE_PATH } from './core/api/variables';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { LoginComponent } from './auth/login/login.component';
import { RegisterComponent } from './auth/register/register.component';
import { ReactiveFormsModule } from '@angular/forms';
import { AuthTokenInterceptor } from './core/auth/auth-token.interceptor'; import { AuthTokenInterceptor } from './core/auth/auth-token.interceptor';
import { ConfirmComponent } from './auth/confirm/confirm.component';
import { ErrorInterceptor } from './core/auth/error.interceptor'; import { ErrorInterceptor } from './core/auth/error.interceptor';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MarkdownModule } from 'ngx-markdown'; import { PublicPagesModule } from './public-pages/public-pages.module';
import { PlatformsModule } from './platforms/platforms.module'; import { AuthModule } from './auth/auth.module';
import { FaqComponent } from './homepage/faq/faq.component';
@NgModule({ @NgModule({
declarations: [ declarations: [AppComponent],
AppComponent,
HomepageComponent,
OrganizerspageComponent,
HoodpageComponent,
HoodspageComponent,
LoginComponent,
RegisterComponent,
ConfirmComponent,
FaqComponent,
],
imports: [ imports: [
BrowserModule,
AppRoutingModule, AppRoutingModule,
SharedModule, SharedModule,
DashboardModule, DashboardModule,
PublicPagesModule,
AuthModule,
ApiModule, ApiModule,
HttpClientModule, HttpClientModule,
ReactiveFormsModule,
BrowserAnimationsModule, BrowserAnimationsModule,
PlatformsModule,
MarkdownModule.forRoot({ loader: HttpClient }),
], ],
providers: [ providers: [
{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }, { provide: BASE_PATH, useValue: environment.API_BASE_PATH },

View file

@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';
import { ConfirmComponent } from './confirm/confirm.component';
const routes: Routes = [
{
path: '',
children: [
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'confirm', component: ConfirmComponent },
],
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AuthRoutingModule {}

View file

@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { AuthRoutingModule } from './auth-routing.module';
import { ConfirmComponent } from './confirm/confirm.component';
import { RegisterComponent } from './register/register.component';
import { LoginComponent } from './login/login.component';
import { SharedModule } from '../shared/shared.module';
@NgModule({
declarations: [ConfirmComponent, LoginComponent, RegisterComponent],
imports: [AuthRoutingModule, SharedModule],
})
export class AuthModule {}

View file

@ -34,7 +34,7 @@
} }
.banner { .banner {
background: url("../../assets/hoods3.jpg"); background: url("../../../assets/hoods3.jpg");
background-size: 100%; background-size: 100%;
display: block; display: block;
width: 100%; width: 100%;
@ -72,7 +72,7 @@
} }
.banner2 { .banner2 {
background: url("../../assets/hoods3.jpg"); background: url("../../../assets/hoods3.jpg");
background-size: 100%; background-size: 100%;
display: block; display: block;
width: 100%; width: 100%;

View file

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { HoodsService, BodyHood } from '../core/api'; import { HoodsService, BodyHood } from '../../core/api';
import { first } from 'rxjs/operators'; import { first } from 'rxjs/operators';
@Component({ @Component({

View file

@ -28,7 +28,7 @@ h1 {
} }
.banner { .banner {
background: url("../../assets/hoods1.jpg"); background: url("../../../assets/hoods1.jpg");
background-size: 100%; background-size: 100%;
width: 100%; width: 100%;
} }

View file

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { HoodsService } from '../core/api/api/hoods.service'; import { HoodsService } from '../../core/api/api/hoods.service';
@Component({ @Component({
selector: 'app-hoodspage', selector: 'app-hoodspage',

View file

@ -0,0 +1,27 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomepageComponent } from './homepage/homepage.component';
import { PublicPagesComponent } from './public-pages.component';
import { OrganizerspageComponent } from './organizerspage/organizerspage.component';
import { HoodspageComponent } from './hoodspage/hoodspage.component';
import { HoodpageComponent } from './hoodpage/hoodpage.component';
const routes: Routes = [
{
path: '',
component: PublicPagesComponent,
children: [
{ path: '', component: HomepageComponent },
{ path: 'organizers', component: OrganizerspageComponent },
{ path: 'hoods', component: HoodspageComponent },
{ path: 'hoods/:id', component: HoodpageComponent },
],
},
];
@NgModule({
declarations: [],
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PublicPagesRoutingModule {}

View file

@ -0,0 +1,2 @@
<router-outlet></router-outlet>
<app-footer></app-footer>

View file

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PublicPagesComponent } from './public-pages.component';
describe('PublicPagesComponent', () => {
let component: PublicPagesComponent;
let fixture: ComponentFixture<PublicPagesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PublicPagesComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PublicPagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-public-pages',
templateUrl: './public-pages.component.html',
styleUrls: ['./public-pages.component.scss']
})
export class PublicPagesComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View file

@ -0,0 +1,37 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HomepageComponent } from './homepage/homepage.component';
import { HoodspageComponent } from './hoodspage/hoodspage.component';
import { HoodpageComponent } from './hoodpage/hoodpage.component';
import { OrganizerspageComponent } from './organizerspage/organizerspage.component';
import { FaqComponent } from './homepage/faq/faq.component';
import { SharedModule } from '../shared/shared.module';
import { PlatformsModule } from '../platforms/platforms.module';
import { MarkdownModule } from 'ngx-markdown';
import { HttpClient } from '@angular/common/http';
import { PublicPagesComponent } from './public-pages.component';
import { PublicPagesRoutingModule } from './public-pages-routing.module';
@NgModule({
declarations: [
HomepageComponent,
HoodspageComponent,
HoodpageComponent,
OrganizerspageComponent,
FaqComponent,
PublicPagesComponent,
],
imports: [
SharedModule,
PlatformsModule,
MarkdownModule.forRoot({ loader: HttpClient }),
PublicPagesRoutingModule,
],
exports: [
HomepageComponent,
HoodspageComponent,
HoodpageComponent,
OrganizerspageComponent,
],
})
export class PublicPagesModule {}

View file

@ -38,6 +38,7 @@ import { FooterComponent } from './footer/footer.component';
FormsModule, FormsModule,
CommonModule, CommonModule,
Ng2SearchPipeModule, Ng2SearchPipeModule,
RouterModule,
], ],
}) })
export class SharedModule {} export class SharedModule {}