Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
probsty committed Oct 29, 2023
2 parents dccca99 + c18bb90 commit c3eff88
Show file tree
Hide file tree
Showing 33 changed files with 335 additions and 116 deletions.
39 changes: 39 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,39 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Local: Attach to Local",
"type": "node",
"request": "attach",
"protocol": "inspector",
"port": 9229,
"sourceMaps": true,
"trace": true
},
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Remote",
"address": "localhost",
"port": 9229,
"localRoot": "${workspaceFolder}/dist",
"remoteRoot": "/usr/src/app/dist",
"protocol": "inspector",
"skipFiles": ["<node_internals>/**"]
},
{
"name": "Debug Jest tests",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}\\node_modules\\jest\\bin\\jest.js",
"args": ["--runInBand", "--no-cache"],
"runtimeArgs": ["--inspect-brk"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal"
}
]
}
3 changes: 3 additions & 0 deletions bank-advisor/angular.json
Expand Up @@ -84,5 +84,8 @@
}
}
}
},
"cli": {
"analytics": false
}
}
3 changes: 2 additions & 1 deletion bank-advisor/src/app/app-routing.module.ts
Expand Up @@ -2,9 +2,10 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { BigExpensesComponent } from './components/big-expenses/big-expenses.component';
import { RegularExpensesComponent } from './components/regular-expenses/regular-expenses.component';
import { AllExpensesComponent } from './components/all-expenses/all-expenses.component';

const routes: Routes = [
{ path: '', redirectTo: 'matches', pathMatch: 'full' },
{ path: '', component: AllExpensesComponent },
{ path: 'big-expenses', component: BigExpensesComponent },
{ path: 'regular-expenses', component: RegularExpensesComponent },
{ path: '**', redirectTo: 'matches', pathMatch: 'full' },
Expand Down
12 changes: 8 additions & 4 deletions bank-advisor/src/app/app.component.html
Expand Up @@ -16,9 +16,13 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<button class="nav-link active" (click)="setBigTransactions()">
Big expeses
</button>
<a
class="nav-link"
routerLink="/big-expenses"
routerLinkActive="active"
ariaCurrentWhenActive="page"
>Big expenses</a
>
</li>
<li class="nav-item">
<a
Expand Down Expand Up @@ -58,4 +62,4 @@
<div>
<app-all-expenses></app-all-expenses>
</div>
<router-outlet></router-outlet>
<div><router-outlet></router-outlet></div>
@@ -1,12 +1,5 @@
<div class="margin-x">
<app-big-expenses
*ngIf="this.route === 'bigTransactions'"
[bigTransactions]="bigTransactions"
></app-big-expenses>
<app-regular-expenses
[regularTransactions]="regularTransactions"
></app-regular-expenses>
<app-contract-expenses
[contractTransactions]="contractTransactions"
></app-contract-expenses>
<!--<app-big-expenses></app-big-expenses>
<app-regular-expenses></app-regular-expenses>
<app-contract-expenses></app-contract-expenses>-->
</div>
Expand Up @@ -3,6 +3,7 @@ import { User } from '../../models/user.interface';
import { Account } from '../../models/account.interface';
import { Transaction } from '../../models/transaction.interface';
import { formatDate } from '../../util/date.util';
import { DataService } from '../../services/data.service';

@Component({
selector: 'app-all-expenses',
Expand All @@ -17,7 +18,7 @@ export class AllExpensesComponent {
contractTransactions: Transaction[] = [];
route: string | null = '';

constructor() {
constructor(dataService: DataService) {
this.route = localStorage.getItem('route');
this.user = {
userId: '1',
Expand Down Expand Up @@ -83,6 +84,8 @@ export class AllExpensesComponent {
} as Account;
this.requestValuesFromDevPortal();
this.filterTransactionsIntoGroups(this.account);
dataService.setUser(this.user);
dataService.setAccount(this.account);
}

requestValuesFromDevPortal() {}
Expand Down
@@ -1,17 +1,4 @@
.text-orange {
border-color: orange;
}

.text-red {
border-color: red;
}

.red {
fill: red;
color: red;
background-color: red;
}

.bg-grey {
background-color: grey;
.margin-x {
margin-left: 15%;
margin-right: 15%;
}
@@ -1,42 +1,45 @@
<h1 class="display-5">Big expenses</h1>
<p>
Those are the transactions, which have a big spending amount. You should
analyze what you are spending your money on.
</p>
<div class="margin-x">
<h1 class="display-5">Big expenses</h1>
<p>
Those are the transactions, which have a big spending amount. You should
analyze what you are spending your money on.
</p>

<ul *ngFor="let bigTransaction of this.bigTransactions" class="list-group">
<li class="d-flex align-items-center justify-content-center mb-2 rounded">
<div class="card mb-3 w-100 border border-success rounded">
<div class="row g-0">
<div class="col-md-2 bg-light">
<p class="text-center align-text-middle fw-bold mt-4 h5">
{{ bigTransaction.amount }} CHF
</p>
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">{{ bigTransaction.description }}</h5>
<p class="card-text">
You bought a
{{ bigTransaction.description }} at {{ bigTransaction.location }}.
<ul *ngFor="let bigTransaction of bigTransactions" class="list-group">
<li class="d-flex align-items-center justify-content-center mb-2 rounded">
<div class="card mb-3 w-100 border border-success rounded">
<div class="row g-0">
<div class="col-md-2 bg-light">
<p class="text-center align-text-middle fw-bold mt-4 h5">
{{ bigTransaction.amount }} CHF
</p>
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">{{ bigTransaction.description }}</h5>
<p class="card-text">
You bought a
{{ bigTransaction.description }} at
{{ bigTransaction.location }}.
</p>
</div>
</div>
<div class="col-md-2 bg-light p-1">
<p class="text-center align-text-middle mt-4">
Bought at the {{ bigTransaction.timeStamp }}
</p>
</div>
</div>
<div class="col-md-2 bg-light p-1">
<p class="text-center align-text-middle mt-4">
Bought at the {{ bigTransaction.timeStamp }}
</p>
</div>
</div>
</div>
</li>
</ul>
<div class="card mb-3 w-100 border border-success rounded bg-success">
<div class="row g-0">
<div>
<div class="card-body">
<h5 class="card-title">Test</h5>
<p class="card-text">Test</p>
</li>
</ul>
<div class="card mb-3 w-100 border border-success rounded bg-success">
<div class="row g-0">
<div>
<div class="card-body">
<h5 class="card-title">Test</h5>
<p class="card-text">Test</p>
</div>
</div>
</div>
</div>
Expand Down
@@ -1,11 +1,24 @@
import { Component, Input } from '@angular/core';
import { Transaction } from '../../models/transaction.interface';
import { User } from '../../models/user.interface';
import { Account } from '../../models/account.interface';
import { DataService } from '../../services/data.service';

@Component({
selector: 'app-big-expenses',
templateUrl: './big-expenses.component.html',
styleUrls: ['./big-expenses.component.css'],
})
export class BigExpensesComponent {
@Input() bigTransactions: Transaction[] = [];
private user: User = {} as User;
private account: Account = {} as Account;
bigTransactions: Transaction[] = [];

constructor(dataService: DataService) {
this.user = dataService.getUser();
this.account = dataService.getAccount();
this.bigTransactions = this.account.transactions.filter((t) => {
return t.amount > 300;
});
}
}
@@ -0,0 +1,4 @@
.margin-x {
margin-left: 15%;
margin-right: 15%;
}
@@ -1,11 +1,24 @@
import { Component, Input } from '@angular/core';
import { Transaction } from 'src/app/models/transaction.interface';
import { User } from '../../models/user.interface';
import { Account } from '../../models/account.interface';
import { DataService } from '../../services/data.service';

@Component({
selector: 'app-contract-expenses',
templateUrl: './contract-expenses.component.html',
styleUrls: ['./contract-expenses.component.css'],
})
export class ContractExpensesComponent {
@Input() contractTransactions: Transaction[] = [];
private user: User = {} as User;
private account: Account = {} as Account;
contractTransactions: Transaction[] = [];

constructor(dataService: DataService) {
this.user = dataService.getUser();
this.account = dataService.getAccount();
this.contractTransactions = this.account.transactions.filter(
(t) => t.standingOrder
);
}
}
@@ -0,0 +1,4 @@
.margin-x {
margin-left: 15%;
margin-right: 15%;
}
@@ -1,11 +1,34 @@
import { Component, Input } from '@angular/core';
import { Transaction } from 'src/app/models/transaction.interface';
import { DataService } from '../../services/data.service';
import { Account } from '../../models/account.interface';
import { User } from '../../models/user.interface';

@Component({
selector: 'app-regular-expenses',
templateUrl: './regular-expenses.component.html',
styleUrls: ['./regular-expenses.component.css'],
})
export class RegularExpensesComponent {
@Input() regularTransactions: Transaction[] = [];
private user: User = {} as User;
private account: Account = {} as Account;
regularTransactions: Transaction[] = [];

constructor(dataService: DataService) {
this.user = dataService.getUser();
this.account = dataService.getAccount();
const transactionCounts: { [key: string]: number } = {};

this.account.transactions.forEach((t) => {
if (transactionCounts[t.location]) {
transactionCounts[t.location]++;
} else {
transactionCounts[t.location] = 1;
}
});

this.regularTransactions = this.account.transactions.filter(
(t) => transactionCounts[t.location] > 2
);
}
}
27 changes: 27 additions & 0 deletions bank-advisor/src/app/services/data.service.ts
@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import { User } from '../models/user.interface';
import { Account } from '../models/account.interface';

@Injectable({
providedIn: 'root',
})
export class DataService {
private sharedUser: User = {} as User;
private sharedAccount: Account = {} as Account;

setUser(user: User) {
this.sharedUser = user;
}

setAccount(account: Account) {
this.sharedAccount = account;
}

getUser() {
return this.sharedUser;
}

getAccount() {
return this.sharedAccount;
}
}
2 changes: 1 addition & 1 deletion bank-advisor/src/index.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<title>BankAdvisor</title>
<base href="/" />
<base href="./" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link
Expand Down
1 change: 1 addition & 0 deletions bank-dating/src/app/app-routing.module.ts
Expand Up @@ -14,5 +14,6 @@ const routes: Routes = [
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: []
})
export class AppRoutingModule {}
2 changes: 1 addition & 1 deletion bank-dating/src/app/app.component.html
Expand Up @@ -7,7 +7,7 @@
<app-side-nav></app-side-nav>
</div>
<div class="col-10">
<router-outlet [user]="user"></router-outlet>
<router-outlet></router-outlet>
</div>
</div>
</div>
Expand Down

0 comments on commit c3eff88

Please sign in to comment.