Skip to content

Commit

Permalink
group-summary.component.html i małe zmiany na backendzie
Browse files Browse the repository at this point in the history
  • Loading branch information
JanisBe committed Dec 15, 2023
1 parent 2857fde commit c9a2123
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 41 deletions.
23 changes: 23 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

158 changes: 143 additions & 15 deletions .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.

28 changes: 14 additions & 14 deletions .run/KomornikBackend.run.xml
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>
2 changes: 2 additions & 0 deletions src/main/frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {ForgotPasswordComponent} from "./component/common/forgot-password/forgot
import {DashboardComponent} from "./component/dashboard/dashboard/dashboard.component";
import {authGuard} from "./auth/auth.guard";
import {IconPickerComponent} from "./component/common/icon-picker/icon-picker.component";
import {GroupSummaryComponent} from "./component/group/group-summary/group-summary.component";

const routes: Routes = [
{path: 'login', component: LoginComponent},
Expand All @@ -27,6 +28,7 @@ const routes: Routes = [
{path: 'user/add', component: AddUserComponent, canActivate: [authGuard]},
{path: 'forgot-password', component: ForgotPasswordComponent, canActivate: [authGuard]},
{path: 'group/details/:groupId', component: AddGroupComponent, canActivate: [authGuard]},
{path: 'group/summary/:groupId', component: GroupSummaryComponent, canActivate: [authGuard]},
{path: 'group/list', component: AllGroupsComponent, canActivate: [authGuard]},
{path: 'group/add', component: AddGroupComponent, canActivate: [authGuard]},
{path: 'expense/details/:expenseId', component: AddExpenseComponent, canActivate: [authGuard]},
Expand Down
5 changes: 2 additions & 3 deletions src/main/frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {GroupModule} from "./component/group/group.module";
import {UserModule} from "./component/user/user.module";
import {ForgotPasswordComponent} from './component/common/forgot-password/forgot-password.component';
import {DashboardComponent} from './component/dashboard/dashboard/dashboard.component';
import {MyGroupsComponent} from "./component/dashboard/my-groups/my-groups.component";
import {IconPickerComponent} from './component/common/icon-picker/icon-picker.component';

registerLocaleData(myLocalePl);
Expand All @@ -46,7 +45,6 @@ registerLocaleData(myLocalePl);
ConfirmationComponent,
ForgotPasswordComponent,
DashboardComponent,
MyGroupsComponent,
IconPickerComponent
],
imports: [
Expand Down Expand Up @@ -87,4 +85,5 @@ registerLocaleData(myLocalePl);
],
bootstrap: [AppComponent]
})
export class AppModule { }
export class AppModule {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<mat-label>Nazwa kategorii</mat-label>
<mat-icon (click)="pickIcon()" matPrefix>{{ categoryIconName }}</mat-icon>
<input class="form-control"
formControlName="name"
formControlName="categoryName"
id="name"
matInput
type="text">
Expand Down
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.
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);
}
}
9 changes: 7 additions & 2 deletions src/main/frontend/src/app/component/group/group.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ import {MatChipsModule} from "@angular/material/chips";
import {AllGroupsComponent} from "./all-groups/all-groups.component";
import {AddGroupComponent} from "./add-group/add-group.component";
import {MatCardModule} from "@angular/material/card";
import {GroupSummaryComponent} from './group-summary/group-summary.component';
import {MyGroupsComponent} from "./my-groups/my-groups.component";


@NgModule({
declarations: [
AllGroupsComponent,
AddGroupComponent
AddGroupComponent,
GroupSummaryComponent,
MyGroupsComponent
],
exports: [
AllGroupsComponent
AllGroupsComponent,
MyGroupsComponent
],
imports: [
CommonModule,
Expand Down
Loading

0 comments on commit c9a2123

Please sign in to comment.