Skip to content

Commit

Permalink
Merge pull request #24 from ofcyln/calculation-logic
Browse files Browse the repository at this point in the history
Calculation logic
  • Loading branch information
ofcyln authored May 15, 2020
2 parents 6957869 + e618ce2 commit 189e26e
Show file tree
Hide file tree
Showing 16 changed files with 1,034 additions and 295 deletions.
6 changes: 4 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.scss"
"src/styles.scss",
"src/assets/scss/theme.scss"
],
"scripts": []
},
Expand Down Expand Up @@ -98,7 +99,8 @@
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.scss"
"src/styles.scss",
"src/assets/scss/theme.scss"
],
"scripts": []
}
Expand Down
658 changes: 458 additions & 200 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,39 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~9.1.6",
"@angular/animations": "^9.1.7",
"@angular/cdk": "^9.2.3",
"@angular/common": "~9.1.6",
"@angular/compiler": "~9.1.6",
"@angular/core": "~9.1.6",
"@angular/flex-layout": "^9.0.0-beta.29",
"@angular/forms": "~9.1.6",
"@angular/common": "^9.1.7",
"@angular/compiler": "^9.1.7",
"@angular/core": "^9.1.7",
"@angular/flex-layout": "^9.0.0-beta.30",
"@angular/forms": "^9.1.7",
"@angular/material": "^9.2.3",
"@angular/platform-browser": "~9.1.6",
"@angular/platform-browser-dynamic": "~9.1.6",
"@angular/router": "~9.1.6",
"@angular/service-worker": "~9.1.6",
"@angular/platform-browser": "^9.1.7",
"@angular/platform-browser-dynamic": "^9.1.7",
"@angular/router": "^9.1.7",
"@angular/service-worker": "^9.1.7",
"ngx-mask": "^9.0.2",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"tslib": "^1.13.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.5",
"@angular/cli": "~9.1.5",
"@angular/compiler-cli": "~9.1.6",
"@angular-devkit/build-angular": "^0.901.6",
"@angular/cli": "^9.1.6",
"@angular/compiler-cli": "^9.1.7",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"@types/node": "^12.12.39",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "^6.0.0",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "^7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
Expand Down
11 changes: 7 additions & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<main fxLayout="column"
<main fxFill
fxLayout="column"
fxLayoutAlign="start center"
fxFill>
<app-header class="w-100"></app-header>
[ngStyle]="{'overflow': 'hidden', 'height': '100%'}">
<app-header class="w-100"
[ngStyle]="{'z-index': '2', 'box-shadow': '0px 3px 9px -4px #333'}"></app-header>

<section>
<section [ngStyle]="{'overflow-y': 'auto', 'height': 'calc(100% - 64px)'}"
class="w-100">
<router-outlet></router-outlet>
</section>
</main>
5 changes: 4 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { NgModule } from '@angular/core';

import { environment } from '../environments/environment';

import { NgxMaskModule } from 'ngx-mask';

import { CoreModule } from './core/core.module';
import { CalculateComponent } from './components/calculate/calculate.component';
import { AppComponent } from './app.component';
Expand All @@ -22,7 +24,8 @@ import { ResultsComponent } from './components/calculate/results/results.compone
BrowserAnimationsModule,
CoreModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
HttpClientModule
HttpClientModule,
NgxMaskModule.forRoot(),
],
providers: [],
bootstrap: [ AppComponent ]
Expand Down
77 changes: 51 additions & 26 deletions src/app/components/calculate/calculate.component.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,82 @@
<article fxLayout="column"
fxLayoutAlign="center center">
<h2 class="margin-top-lg"
[ngStyle]="{'text-transform': 'uppercase'}"
[ngClass.lt-md]="'margin-top-sm'">Mortgage Expense Calculator</h2>
<h2 class="margin-top-md margin-bottom-sm"
[ngStyle]="{'text-transform': 'uppercase', 'font-size': '29px'}"
[ngStyle.lt-md]="{'font-size': '22px'}"
[ngClass.lt-md]="'margin-top-sm margin-bottom-zero'">Mortgage Expense Calculator</h2>

<div fxLayout="row"
fxLayoutAlign="center center"
class="margin-top-md"
[ngClass]="'margin-top-sm'">
<p fxFlex="0 1 80">
Buying a property is a big investment in our lives. Most people don't know what amount of money they need for the
expenses of a mortgage.
<p fxFlex="0 1 80"
[ngStyle]="{'line-height': '29px'}"
[ngStyle.lt-md]="{'font-size': '13px', 'line-height': '27px'}">
Buying a property is a big investment in our lives.
<br>
'Mortgage Expense Calculator' is an application to use of calculating estimated mortgage expenses when you buy a
Most people are not sure what amount of money they need to have upfront for buying a property with a mortgage.
<br>
'Mortgage Expense Calculator' is a web application to use of calculating estimated mortgage expenses when you buy a
property.
<br>
Simply enter the mortgage amount that you are going to get below and click the calculate button to see the
estimated expenses that you need for buying your property of dreams.
Simply enter the mortgage amount that you are going to get below and click the calculate button to see the estimated
expense amount that you need to have for buying your property of dreams.
</p>
</div>

<div class="margin-top-md"
[ngClass.lt-md]="'margin-top-sm'">
<mat-form-field>
<mat-form-field [ngStyle]="{'font-size': '24px'}"
[ngStyle.lt-md]="{'font-size': '20px'}">
<mat-label [style.fontSize.px]="20">Mortgage Amount</mat-label>

<label>
<input matInput
type="number"
[(ngModel)]="value"
inputmode="numeric"
pattern="[0-9]*">
</label>
<span matPrefix>€ &nbsp;</span>

<input matInput
type="tel"
inputmode="number"
pattern="[0-9]*"
mask="separator"
thousandSeparator=","
[(ngModel)]="value"
(keydown.enter)="setCalculationState()">

<button mat-button
*ngIf="value"
<button *ngIf="value"
mat-button
matSuffix
mat-icon-button
aria-label="Clear"
(click)="value=''">
(click)="value=null">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
</div>

<div class="margin-top-lg">
<button mat-raised-button
color="primary">CALCULATE</button>
<div class="margin-top-lg"
[ngClass.lt-md]="'margin-top-sm'">
<button *ngIf="!isCalculate"
mat-raised-button
color="primary"
(click)="setCalculationState()">CALCULATE
</button>
</div>

<app-results fxFill
<app-results *ngIf="isCalculate"
fxFill
fxLayout="row"
class="margin-top-lg margin-bottom-lg"
[mortgageValue]="value"
[calculateState]="isCalculate"
class="margin-bottom-lg"
fxLayoutAlign="center center"></app-results>

<button *ngIf="isCalculate"
mat-icon-button
color="primary"
class="margin-bottom-lg"
[ngClass.lt-md]="'margin-bottom-md'"
matTooltip="Clear page"
[matTooltipPosition]="'right'"
(click)="refreshPage()">
<mat-icon>refresh</mat-icon>
</button>
</article>

21 changes: 19 additions & 2 deletions src/app/components/calculate/calculate.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Component, Inject, OnInit } from '@angular/core';
import { DOCUMENT } from '@angular/common';

@Component({
selector: 'app-calculate',
Expand All @@ -7,11 +8,27 @@ import { Component, OnInit } from '@angular/core';
})
export class CalculateComponent implements OnInit {
value = null;
isCalculate = false;

constructor() {
constructor(@Inject(DOCUMENT) private doc: Document) {
}

ngOnInit(): void {
}

setCalculationState() {
const showCalculation = !this.isCalculate
&& this.value !== null
&& this.value !== undefined
&& this.value !== '';

if (showCalculation) {
this.isCalculate = true;
}
}

refreshPage() {
this.doc.defaultView.location.reload();
}

}
Loading

0 comments on commit 189e26e

Please sign in to comment.