-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62fae41
commit 33b157b
Showing
11 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class EmailRecord { | ||
email: string; | ||
message: string; | ||
title: string; | ||
successful: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
import { ViewHistoryComponent } from './view-history.component'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: ViewHistoryComponent | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule] | ||
}) | ||
export class ViewHistoryRoutingModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="container"> | ||
<h1 class="mat-h1 heading"> | ||
History of sent emails | ||
</h1> | ||
|
||
<ng-container *ngIf="emailRecords!.length else empty"> | ||
<div class="cards"> | ||
<mat-card class="card" *ngFor="let emailRecord of emailRecords"> | ||
<mat-card-header> | ||
<div mat-card-avatar> | ||
<mat-icon> | ||
{{ emailRecord.successful ? 'check' : 'close' }} | ||
</mat-icon> | ||
</div> | ||
<mat-card-title>{{ emailRecord.title }}</mat-card-title> | ||
<mat-card-subtitle>{{ emailRecord.email }}</mat-card-subtitle> | ||
</mat-card-header> | ||
<mat-card-content> | ||
<p> | ||
{{ emailRecord.message }} | ||
</p> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> | ||
</ng-container> | ||
</div> | ||
|
||
<ng-template #empty> | ||
<h4 class="mat-h2 title"> | ||
- No history for sent emails - | ||
</h4> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@import '../shared/_ui-tools.scss'; | ||
@import '../shared/variables'; | ||
|
||
:host { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
height: 100%; | ||
|
||
.container { | ||
@include flex-column-centered(); | ||
padding: 16px; | ||
} | ||
|
||
.heading { | ||
font-size: 36px; | ||
margin: 16px 0; | ||
} | ||
|
||
.title { | ||
font-size: 24px; | ||
margin: 16px 0; | ||
} | ||
|
||
.cards { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: column; | ||
|
||
padding: 32px; | ||
overflow: auto; | ||
|
||
.card { | ||
transition: all 150ms ease-in-out; | ||
margin: 8px; | ||
min-height: 100px; | ||
min-width: 500px; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
transform: scale(1.05); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ViewHistoryComponent } from './view-history.component'; | ||
|
||
describe('ViewHistoryComponent', () => { | ||
let component: ViewHistoryComponent; | ||
let fixture: ComponentFixture<ViewHistoryComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ViewHistoryComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ViewHistoryComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { EmailRecord } from 'src/models/email-record'; | ||
import { MailService } from 'src/services/mail.service'; | ||
|
||
@Component({ | ||
selector: 'app-view-history', | ||
templateUrl: './view-history.component.html', | ||
styleUrls: ['./view-history.component.scss'] | ||
}) | ||
export class ViewHistoryComponent implements OnInit { | ||
|
||
emailRecords: Array<EmailRecord> = []; | ||
|
||
constructor(private templateService: MailService) { } | ||
|
||
ngOnInit(): void { | ||
this.fetchHistory(); | ||
} | ||
|
||
fetchHistory(): void { | ||
this.templateService.getHistory().subscribe( | ||
(response: Array<EmailRecord>) => { this.handleSuccess(response) }, | ||
(response: HttpErrorResponse) => { this.handleFailure(response) } | ||
); | ||
} | ||
|
||
|
||
private handleSuccess(response: Array<EmailRecord>): void { | ||
this.emailRecords = response; | ||
} | ||
|
||
private handleFailure(response: HttpErrorResponse): void { | ||
console.error(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ViewHistoryComponent } from './view-history.component'; | ||
import { ViewHistoryRoutingModule } from './view-history-routing.module'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
|
||
@NgModule({ | ||
declarations: [ViewHistoryComponent], | ||
imports: [ | ||
CommonModule, | ||
ViewHistoryRoutingModule, | ||
MatCardModule, | ||
MatIconModule | ||
] | ||
}) | ||
export class ViewHistoryModule { } |