-
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.
group-summary.component.html i małe zmiany na backendzie
- Loading branch information
Showing
16 changed files
with
260 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
158 changes: 143 additions & 15 deletions
158
.idea/dataSources/69262c9e-87ed-4002-a486-6f25b1ad436a.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="KomornikBackend" type="SpringBootApplicationConfigurationType" | ||
factoryName="Spring Boot"> | ||
<module name="komornik"/> | ||
<option name="SPRING_BOOT_MAIN_CLASS" value="pl.janis.komornik.Komornik"/> | ||
<extension name="coverage"> | ||
<pattern> | ||
<option name="PATTERN" value="com.example.demo.*"/> | ||
<option name="ENABLED" value="true"/> | ||
</pattern> | ||
</extension> | ||
<method v="2"> | ||
<option name="Make" enabled="true"/> | ||
</method> | ||
</configuration> | ||
<configuration default="false" name="KomornikBackend" type="SpringBootApplicationConfigurationType" | ||
factoryName="Spring Boot"> | ||
<module name="komornik"/> | ||
<option name="SPRING_BOOT_MAIN_CLASS" value="pl.janis.komornik.Komornik"/> | ||
<extension name="coverage"> | ||
<pattern> | ||
<option name="PATTERN" value="com.example.demo.*"/> | ||
<option name="ENABLED" value="true"/> | ||
</pattern> | ||
</extension> | ||
<method v="2"> | ||
<option name="Make" enabled="true"/> | ||
</method> | ||
</configuration> | ||
</component> |
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
11 changes: 11 additions & 0 deletions
11
src/main/frontend/src/app/component/group/group-summary/group-summary.component.html
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,11 @@ | ||
<div *ngFor="let expense of expenses | keyvalue: reverseKeyOrder"> | ||
<div> | ||
<p>date: {{ expense.key | date:'shortDate':'':'pl' }}</p> | ||
<div *ngFor="let ex of expense.value"> | ||
<p>dokładnie to: {{ ex.date | date:'shortDate':'':'pl' }} i {{ ex.description }}</p> | ||
<div *ngFor="let debt of ex.debt"> | ||
<p>{{ debt.from.name }} -> {{ debt.to.name }} = {{ debt.amount }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Empty file.
50 changes: 50 additions & 0 deletions
50
src/main/frontend/src/app/component/group/group-summary/group-summary.component.ts
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,50 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {ActivatedRoute} from "@angular/router"; | ||
import {ExpenseService} from "../../../service/expense.service"; | ||
import {Expense} from "../../../model/expense"; | ||
import {KeyValue} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'group-summary', | ||
templateUrl: './group-summary.component.html', | ||
styleUrl: './group-summary.component.scss' | ||
}) | ||
export class GroupSummaryComponent implements OnInit { | ||
groupId: number; | ||
expenses: Map<string, Expense[]> = new Map<string, Expense[]>(); | ||
|
||
constructor(private expenseService: ExpenseService, | ||
private route: ActivatedRoute | ||
) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.groupId = this.route.snapshot.params['groupId']; | ||
this.expenseService.findAllByGroupId(this.groupId).subscribe(expenses => { | ||
this.expenses = this.groupByDate(expenses); | ||
console.log(this.expenses); | ||
}); | ||
|
||
} | ||
|
||
groupByDate(objects: Expense[]): Map<string, Expense[]> { | ||
return objects.reduce((groupedMap, currentObject) => { | ||
// Extract the date in a format that represents the day (YYYY-MM-DD) | ||
const dateKey = currentObject.date.toString().split('T')[0]; | ||
|
||
// Check if there's already a group for the current day | ||
if (!groupedMap.has(dateKey)) { | ||
groupedMap.set(dateKey, []); | ||
} | ||
|
||
// Add the current object to the group | ||
groupedMap.get(dateKey)!.unshift(currentObject); | ||
|
||
return groupedMap; | ||
}, new Map<string, Expense[]>()); | ||
} | ||
|
||
reverseKeyOrder = (a: KeyValue<string, Expense[]>, b: KeyValue<string, Expense[]>): number => { | ||
return a.key > b.key ? -1 : (b.key > a.key ? 1 : 0); | ||
} | ||
} |
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
Oops, something went wrong.