Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'account-menu',
styleUrls: ['../styles/account-menu.css'],
styleUrls: ['./account-menu.component.css'],
template: `
<div class="account">
<span class="welcome" *ngIf="user">
Expand Down
8 changes: 4 additions & 4 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CoursesComponent } from './components/courses';
import { RegisterComponent } from './components/sign-in';
import { SignInComponent } from './components/sign-in';
import { catalogComponent } from './catalog/catalog.component';
import { RegisterComponent } from './users/register.component';
import { SignInComponent } from './users/sign-in.component';

const routes: Routes = [
{ path: 'catalog', component: CoursesComponent, },
{ path: 'catalog', component: catalogComponent, },
{ path: 'users/register', component: RegisterComponent, },
{ path: 'users/sign-in', component: SignInComponent, },
{ path: '', redirectTo: '/catalog', pathMatch: 'full' },
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule, FormsModule } from '@angular/forms'

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './components/app';
import { NavBarComponent } from './components/nav-bar';
import { CoursesComponent } from "./components/courses";
import { RegisterComponent } from "./components/sign-in";
import { SignInComponent } from "./components/sign-in";
import { LoadingComponent } from "./components/loading-spinner";
import { DataRepositoryService } from "./services/data-repository"
import { AccountMenuComponent } from "./components/account-menu";
import { AppComponent } from './app.component';
import { NavBarComponent } from './nav-bar.component';
import { catalogComponent } from "./catalog/catalog.component";
import { RegisterComponent } from "./users/register.component";
import { SignInComponent } from "./users/sign-in.component";
import { LoadingComponent } from "./components/loading-spinner.component";
import { DataRepositoryService } from "./services/data-repository.service"
import { AccountMenuComponent } from "./account-menu.component";

@NgModule({
declarations: [
AppComponent,
NavBarComponent,
CoursesComponent,
catalogComponent,
RegisterComponent,
SignInComponent,
LoadingComponent,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
1. filename best practice.
2. folder best practice
-->
<div class="departments">
<button (click)="applyFilter('CH')">Charms</button>
<button (click)="applyFilter('PO')">Potions</button>
Expand Down Expand Up @@ -35,4 +39,4 @@
</tr>
</tbody>
</table>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component } from '@angular/core';

import { DataRepositoryService } from "../services/data-repository"
import { IClass } from '../services/class.model';
import { DataRepositoryService } from "../services/data-repository.service"
import { IClass } from './class.model';

@Component({
styleUrls: ['../styles/catalog.css'],
templateUrl: '../templates/catalog.html'
styleUrls: ['./catalog.component.css'],
templateUrl: './catalog.component.html'
})
export class CoursesComponent {
export class catalogComponent {
classes: IClass[] = [];
visibleClasses: IClass[] = [];

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component } from '@angular/core';

import { DataRepositoryService } from "../services/data-repository";
import { DataRepositoryService } from "../app/services/data-repository.service";

@Component({
selector: 'nav-bar',
styleUrls: [`../styles/nav-bar.css`],
styleUrls: [`./nav-bar.component.css`],
template: `
<div class="nav-bar">
<img class="logo" src="/assets/images/whitebeard-logo.png" alt="Whitebeard Logo" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@angular/core';
import { Observable, Subject, EMPTY, throwError, timer } from 'rxjs';


import { IUser } from '../services/user.model';
import { IClass, ICourse } from '../services/class.model';
import { IUser } from '../users/user.model';
import { IClass, ICourse } from '../catalog/class.model';

@Injectable()
export class DataRepositoryService {
Expand Down
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions src/app/users/register.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Component } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router'

import { DataRepositoryService } from '../services/data-repository.service'
import { IUser } from './user.model';



@Component({
styleUrls: ['./register.component.css'],
templateUrl: './register.component.html'
})

export class RegisterComponent {
registerForm: FormGroup;
firstName: FormControl;
lastName: FormControl;
email: FormControl;
password: FormControl;
saving: boolean = false;

constructor(private router: Router, private dataRepository: DataRepositoryService) {
this.firstName = new FormControl('', Validators.required);
this.lastName = new FormControl('', Validators.required);
this.email = new FormControl('', Validators.required);
this.password = new FormControl('', Validators.required);

this.registerForm = new FormGroup({
firstName: this.firstName,
lastName: this.lastName,
email: this.email,
password: this.password
});
}


registerUser(user: IUser) {
this.saving = true;
this.dataRepository.saveUser(user)
.subscribe({
error: () => this.saving = false,
complete: () => this.router.navigate(['/catalog'])
});
}

cancel() {
this.router.navigate(['/']);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Component } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router'
import { DataRepositoryService } from '../services/data-repository.service'

import { DataRepositoryService } from '../services/data-repository'
import { IUser } from '../services/user.model';

@Component({
styles: [`
Expand Down Expand Up @@ -93,44 +91,3 @@ export class SignInComponent {
}
}

@Component({
styleUrls: ['../styles/register.css'],
templateUrl: '../templates/register.html'
})

export class RegisterComponent {
registerForm: FormGroup;
firstName: FormControl;
lastName: FormControl;
email: FormControl;
password: FormControl;
saving: boolean = false;

constructor(private router: Router, private dataRepository: DataRepositoryService) {
this.firstName = new FormControl('', Validators.required);
this.lastName = new FormControl('', Validators.required);
this.email = new FormControl('', Validators.required);
this.password = new FormControl('', Validators.required);

this.registerForm = new FormGroup({
firstName: this.firstName,
lastName: this.lastName,
email: this.email,
password: this.password
});
}


registerUser(user: IUser) {
this.saving = true;
this.dataRepository.saveUser(user)
.subscribe({
error: () => this.saving = false,
complete: () => this.router.navigate(['/catalog'])
});
}

cancel() {
this.router.navigate(['/']);
}
}
File renamed without changes.