From 8ec987f46b4ef3ff1ce23d9942662a74e162689d Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 20 Mar 2025 09:58:32 -0400 Subject: need-list search embedded in normal display with better feedback --- .../components/need-list/need-list.component.css | 2 +- .../components/need-list/need-list.component.html | 23 ++++----- .../components/need-list/need-list.component.ts | 60 +++++++++++----------- 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index bbc3f2c..88bdfbe 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -15,7 +15,7 @@ li, div { } -#search-form { +#search-container { background-color: #d9d9d9; padding: 10px 20px 20px 20px; border: 2px solid #000; diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 36c12d0..504deb9 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,25 +1,20 @@

Needs List

-
-
+
+
-
+
-
-

Search Results:

-
- - {{need.name}} - - - -
-
-
  • + +

    Search Results({{needs.length - searchResults.length}} needs filtered):

    +

    All Needs

    +

    No Results Found

    + +
  • {{need.name}} diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 25f05d6..f5d7855 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { NgForm } from '@angular/forms'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; @@ -19,12 +20,16 @@ export class NeedListComponent { ) {} refresh() { - this.cupboardService.getNeeds().subscribe(n => this.needs = n) + this.cupboardService.getNeeds().subscribe(n => { + this.needs = n; + this.searchResults = this.needs; + }); + + console.log(this.searchResults); } ngOnInit(): void { this.refresh() - this.close(); } @@ -42,20 +47,13 @@ export class NeedListComponent { } } - private updateSearchStatus(text: string) { - let element = document.getElementById('search-status'); - if (element) { - element.innerHTML = text; - } - } - open() { this.hideElement(document.getElementById('search-button')); - this.showElement(document.getElementById('search-form')); + this.showElement(document.getElementById('search-container')); } close() { - this.hideElement(document.getElementById('search-form')); + this.hideElement(document.getElementById('search-container')); this.showElement(document.getElementById('search-button')); this.hideElement(document.getElementById('search-status')); } @@ -69,24 +67,28 @@ export class NeedListComponent { if (this.searchDelay) { clearTimeout(this.searchDelay); } + if (form) { + this.searchDelay = setTimeout(() => { + + if (form) { + const currentSearchValue = form.search; //latest value of the search + this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { + this.searchResults = n; + console.log(currentSearchValue, this.searchResults); + this.showElement(document.getElementById('search-results')); + this.showElement(document.getElementById('search-status')); + }); + } + }, 250); + } else { + //user has cleared the search bar, we can skip the timeout for a 1/4 second faster response + //clear timeout to stop pending search + clearTimeout(this.searchDelay); + this.searchResults = this.needs; + } + - this.searchDelay = setTimeout(() => { - const currentSearchValue = form.search; //latest value of the search - this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { - this.searchResults = n; - console.log(currentSearchValue, this.searchResults); - this.showElement(document.getElementById('search-results')); - this.showElement(document.getElementById('search-status')); - if (this.searchResults.length === this.needs.length) { - this.updateSearchStatus("Please refine your search"); - this.searchResults = []; - } else if (this.searchResults.length === 0) { - this.updateSearchStatus("No results found"); - } else { - this.updateSearchStatus("Search results:"); - } - }); - }, 250); + } delete(id : number) { @@ -127,6 +129,6 @@ export class NeedListComponent { } back() { - this.searchResults = []; + this.searchResults = this.needs; } } -- cgit v1.2.3 From 237b9197c08c46a11fe45347e2d41428a558f75b Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 20 Mar 2025 10:18:43 -0400 Subject: component style refactor for simpler display --- .../app/components/cupboard/cupboard.component.css | 20 +++- .../components/cupboard/cupboard.component.html | 101 +++++++++++---------- .../app/components/cupboard/cupboard.component.ts | 2 - 3 files changed, 69 insertions(+), 54 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index fe4971a..4c6ac4b 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -1,18 +1,30 @@ :host { - display: block; + display: flex; + justify-content: left; border: 2px solid #000; border-radius: 5px; padding: 10px 20px; } +#menu { + display: flex; + justify-content: space-between; + margin: 10px; + * { + border: 3px solid #000; + + border-top-left-radius: 5px; + border-top-right-radius: 5px; + margin-right: 5px; + border-bottom: 0px; + } +} -#menu, #create-form, #delete-form, #update-form { +#create-form, #delete-form, #update-form { background-color: #d9d9d9; padding: 10px 20px 20px 20px; border: 2px solid #000; border-radius: 5px; - width: 20%; visibility: visible; - } #create-button { diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 0d64475..4577844 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -1,50 +1,55 @@ -

    Cupboard

    -

    Admin View

    -
  • -- cgit v1.2.3 From 5eef7755f799d0f4fffad88dd05f18459c206253 Mon Sep 17 00:00:00 2001 From: benal01 Date: Fri, 21 Mar 2025 10:18:32 -0400 Subject: gitignore --- ufund-api/.gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufund-api/.gitignore b/ufund-api/.gitignore index 052bd9d..24d3397 100644 --- a/ufund-api/.gitignore +++ b/ufund-api/.gitignore @@ -32,5 +32,7 @@ build/ .vscode/ ### application specific ### -# /src/main/resources/application.properties -# /data/cupboard.json \ No newline at end of file +ufund-api/src/main/resources/application.properties +ufund-api/data/cupboard.json +ufund-api/data/users.json +ufund-api/data/userAuths.json \ No newline at end of file -- cgit v1.2.3 From 0ba69e502b89ed2d8fe51b3b8b40eb8fba5830e1 Mon Sep 17 00:00:00 2001 From: sowgro Date: Fri, 21 Mar 2025 23:11:37 -0400 Subject: start making some css --- ufund-ui/src/app/app.component.css | 19 +++++++++++++++++++ ufund-ui/src/app/app.component.html | 19 +++++++++++++++---- ufund-ui/src/styles.css | 12 ++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index e69de29..b2dfb87 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -0,0 +1,19 @@ +#header { + display: flex; + flex-direction: row; + justify-content: space-between; + border-bottom: black solid 1px; + padding: 0 10px; + background-color: #d9d9d9; + + h1 { + padding: 0; + margin: 0; + } + + div { + display: flex; + align-items: center; + gap: 10px; + } +} diff --git a/ufund-ui/src/app/app.component.html b/ufund-ui/src/app/app.component.html index a490237..3058117 100644 --- a/ufund-ui/src/app/app.component.html +++ b/ufund-ui/src/app/app.component.html @@ -1,6 +1,17 @@ - -

    jelly solutions

    -{{currentUser$ | async}}
    -
    + diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index 90d4ee0..471f272 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -1 +1,13 @@ /* You can add global styles to this file, and also import other style files */ + +* { + box-sizing: border-box; +} + +html, body { + margin: 0; +} + +body { + font-family: sans-serif; +} -- cgit v1.2.3 From 0be2b5868bdda04146a22ec81596dbbb81922360 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sat, 22 Mar 2025 00:04:40 -0400 Subject: improve login page --- ufund-ui/src/app/app.component.css | 7 ++++++- .../src/app/components/login/login.component.css | 22 +++++++++++++++++----- .../src/app/components/login/login.component.html | 16 +++++++++------- ufund-ui/src/styles.css | 9 +++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index b2dfb87..63608c0 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -1,10 +1,15 @@ +:host { + display: flex; + flex-direction: column; + height: 100%; +} + #header { display: flex; flex-direction: row; justify-content: space-between; border-bottom: black solid 1px; padding: 0 10px; - background-color: #d9d9d9; h1 { padding: 0; diff --git a/ufund-ui/src/app/components/login/login.component.css b/ufund-ui/src/app/components/login/login.component.css index 435cc87..cae0992 100644 --- a/ufund-ui/src/app/components/login/login.component.css +++ b/ufund-ui/src/app/components/login/login.component.css @@ -1,8 +1,20 @@ -:host, .border { - display: flex; - flex-direction: column; - max-width: 300px; - gap: 5px +:host { + display: flex; + align-items: center; + justify-content: center; + height: 100%; + background-image: url("https://www.fineshare.com/background/jellyfish-under-fluorescent-illumination.jpg"); +} + +#box { + display: flex; + flex-direction: column; + max-width: 330px; + gap: 5px; + backdrop-filter: blur(10px); + background-color: rgba(0, 0, 0, 0.1); + padding: 30px; + color: white; } .border { diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html index 2cdb6d0..aff108f 100644 --- a/ufund-ui/src/app/components/login/login.component.html +++ b/ufund-ui/src/app/components/login/login.component.html @@ -1,7 +1,9 @@ -You must be logged in to view this page -

    Login:

    - - - - -{{statusText | async}} +
    + You must be logged in to view this page +

    Login:

    + + + + + {{statusText | async}} +
    diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index 471f272..fdf67c7 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -6,8 +6,17 @@ html, body { margin: 0; + height: 100%; } body { font-family: sans-serif; } + +input { + font-size: 14pt; +} + +button, .button { + font-size: 14pt; +} -- cgit v1.2.3 From 69e79cc423110ea7df3d960f95e612934d256dd8 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sat, 22 Mar 2025 00:24:09 -0400 Subject: Create basic home page --- ufund-ui/src/app/app-routing.module.ts | 12 ++++++------ .../src/app/components/home-page/home-page.component.css | 7 +++++++ .../src/app/components/home-page/home-page.component.html | 5 ++--- .../src/app/components/need-page/need-page.component.html | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ufund-ui/src/app/app-routing.module.ts b/ufund-ui/src/app/app-routing.module.ts index 4b76654..c83db8a 100644 --- a/ufund-ui/src/app/app-routing.module.ts +++ b/ufund-ui/src/app/app-routing.module.ts @@ -8,12 +8,12 @@ import {FundingBasketComponent} from './components/funding-basket/funding-basket import {NeedPageComponent} from './components/need-page/need-page.component'; const routes: Routes = [ - {path: '', component: HomePageComponent}, - {path: 'login', component: LoginComponent}, - {path: 'cupboard', component: CupboardComponent}, - {path: 'dashboard', component: DashboardComponent}, - {path: 'basket', component: FundingBasketComponent}, - {path: 'need/:id', component: NeedPageComponent} + { path: '', component: HomePageComponent, title: "Home | JS" }, + { path: 'login', component: LoginComponent, title: "Login | JS" }, + { path: 'cupboard', component: CupboardComponent, title: "Cupboard | JS" }, + { path: 'dashboard', component: DashboardComponent, title: "Dashboard | JS" }, + { path: 'basket', component: FundingBasketComponent, title: "Basket | JS" }, + { path: 'need/:id', component: NeedPageComponent, title: "Need | JS" } ]; @NgModule({ diff --git a/ufund-ui/src/app/components/home-page/home-page.component.css b/ufund-ui/src/app/components/home-page/home-page.component.css index e69de29..5f65225 100644 --- a/ufund-ui/src/app/components/home-page/home-page.component.css +++ b/ufund-ui/src/app/components/home-page/home-page.component.css @@ -0,0 +1,7 @@ +:host { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} diff --git a/ufund-ui/src/app/components/home-page/home-page.component.html b/ufund-ui/src/app/components/home-page/home-page.component.html index d41e670..b2eed0b 100644 --- a/ufund-ui/src/app/components/home-page/home-page.component.html +++ b/ufund-ui/src/app/components/home-page/home-page.component.html @@ -1,3 +1,2 @@ - - Login/Sign Up - \ No newline at end of file +

    Helping fund coral reef and marine life conservation

    + diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index 90fd459..b2579c9 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -1,4 +1,4 @@ - +

    Viewing Need: {{need?.name}}

    internal id: {{need?.id}}
    @@ -19,4 +19,4 @@

    Goal: {{need?.maxGoal}}

    Current: {{need?.current}}

    -

    This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!

    \ No newline at end of file +

    This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!

    -- cgit v1.2.3 From 2b67bd14828c8c0bffe461a66542a2dba6c19f93 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 11:21:30 -0400 Subject: API creation bug fix- the max goal would not be casted properly --- .../com/ufund/api/ufundapi/controller/CupboardController.java | 3 ++- ufund-ui/src/app/components/cupboard/cupboard.component.css | 9 ++++++--- ufund-ui/src/app/components/need-list/need-list.component.css | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index 36ae341..55cf88d 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -50,7 +50,8 @@ public class CupboardController { public ResponseEntity createNeed(@RequestBody Map params) { System.out.println(params); String name = (String) params.get("name"); - double maxGoal = (double) params.get("maxGoal"); + System.out.println("attemtping cast maxgoual"); + double maxGoal = ((Number) params.get("maxGoal")).doubleValue(); Need.GoalType goalType = GoalType.valueOf((String) params.get("type")); try { diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index 4c6ac4b..434b136 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -1,17 +1,21 @@ :host { display: flex; - justify-content: left; + justify-content: space-evenly; border: 2px solid #000; border-radius: 5px; padding: 10px 20px; + > div { + width: 40%; + } } + + #menu { display: flex; justify-content: space-between; margin: 10px; * { border: 3px solid #000; - border-top-left-radius: 5px; border-top-right-radius: 5px; margin-right: 5px; @@ -29,5 +33,4 @@ #create-button { padding: 10px 20px; - } \ No newline at end of file diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index f8948ee..bf7b982 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -4,7 +4,6 @@ display: block; border-radius: 5px; } - li, div { border: 2px solid #000; border-radius: 5px; -- cgit v1.2.3 From 2abd4b4ba9171821ac545f8dcb67be1e7d722e01 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 11:58:39 -0400 Subject: replaced unneccicary methods for form selection with ngIf --- ufund-ui/src/app/components/cupboard/cupboard.component.css | 2 +- ufund-ui/src/app/components/cupboard/cupboard.component.html | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index 434b136..6c2e5c6 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -12,7 +12,7 @@ #menu { display: flex; - justify-content: space-between; + margin: 10px; * { border: 3px solid #000; diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 4577844..41bb4a7 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -5,10 +5,10 @@

    Admin View

    -
    +

    Create a new need


    @@ -22,11 +22,10 @@
    - - ‼️{{statusText | async}} + {{statusText | async}}
    -
    +

    Update a need


    @@ -46,7 +45,6 @@
    - {{statusText | async}}
    -- cgit v1.2.3 From e9564ba2514f32c63d2ce4ecfc9eeb9f3269f3dd Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 12:14:00 -0400 Subject: [ngClass] tab styling --- .../app/components/cupboard/cupboard.component.css | 21 ++++++---- .../components/cupboard/cupboard.component.html | 4 +- .../app/components/cupboard/cupboard.component.ts | 46 ++-------------------- 3 files changed, 20 insertions(+), 51 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index 6c2e5c6..6e70951 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -14,13 +14,20 @@ display: flex; margin: 10px; - * { - border: 3px solid #000; - border-top-left-radius: 5px; - border-top-right-radius: 5px; - margin-right: 5px; - border-bottom: 0px; - } + +} + +.tab, .selected-tab { + background-color: lightgray; + border: 3px solid #000; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + margin-right: 5px; + border-bottom: 0px; +} + +.selected-tab { + background-color: white; } #create-form, #delete-form, #update-form { diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 41bb4a7..9b74b2a 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -5,8 +5,8 @@

    Admin View

    Create a new need

    diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index f8023c3..646c4ff 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -16,7 +16,7 @@ import { NeedListComponent } from '../need-list/need-list.component'; export class CupboardComponent implements OnInit { protected statusText = new BehaviorSubject("") - + selectedForm = "create" needs: any; @ViewChild("needList") needList?: NeedListComponent @@ -24,9 +24,6 @@ export class CupboardComponent implements OnInit { ngOnInit(): void { this.cupboardService.getNeeds().subscribe(n => this.needs = n); - this.close(); - this.openmenu(); - if (this.isManager()) { console.log("Admin view of Cupboard"); } else { @@ -41,44 +38,9 @@ export class CupboardComponent implements OnInit { type: '' }; selectedNeedId: number | null = null; - - private hideElement(element: any) { - if (element) { - element.style.visibility = 'hidden'; - element.style.position = 'absolute'; - } - } - - private showElement(element: any) { - if (element) { - element.style.visibility = 'visible'; - element.style.position = 'relative'; - } - } - openmenu() { - const menuElement = document.getElementById('menu'); - this.showElement(menuElement); - } - - opencreate() { - this.close(); - this.showElement(document.getElementById('create-form')); - } - - openupdate() { - this.close(); - this.showElement(document.getElementById('update-form')); - } - - back() { - this.close(); - this.openmenu(); - } - - close() { - this.hideElement(document.getElementById('create-form')); - this.hideElement(document.getElementById('destroy-form')); - this.hideElement(document.getElementById('update-form')); + + selectForm(name: string) { + this.selectedForm = name; } populateForm(need: any): void { -- cgit v1.2.3 From d8b9c0da32383630f0831fdf6a7f13c96174ee4c Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 12:17:50 -0400 Subject: removing unneccicary functions for element visiblity in need list --- .../components/need-list/need-list.component.css | 3 +-- .../components/need-list/need-list.component.ts | 29 ---------------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index bf7b982..29a9626 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -26,6 +26,5 @@ li { background-color: #d9d9d9; padding: 10px 20px 20px 20px; border: 2px solid #000; - border-radius: 5px; - visibility: visible; + border-radius: 5px; } \ No newline at end of file diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index f5d7855..3f77df4 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -24,38 +24,11 @@ export class NeedListComponent { this.needs = n; this.searchResults = this.needs; }); - console.log(this.searchResults); } ngOnInit(): void { this.refresh() - this.close(); - } - - private showElement(element: any) { - if (element){ - element.style.visibility = 'visible'; - element.style.position = 'relative'; - } - } - - private hideElement(element: any) { - if (element){ - element.style.visibility = 'hidden'; - element.style.position = 'absolute'; - } - } - - open() { - this.hideElement(document.getElementById('search-button')); - this.showElement(document.getElementById('search-container')); - } - - close() { - this.hideElement(document.getElementById('search-container')); - this.showElement(document.getElementById('search-button')); - this.hideElement(document.getElementById('search-status')); } private searchDelay: any; @@ -75,8 +48,6 @@ export class NeedListComponent { this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { this.searchResults = n; console.log(currentSearchValue, this.searchResults); - this.showElement(document.getElementById('search-results')); - this.showElement(document.getElementById('search-status')); }); } }, 250); -- cgit v1.2.3 From 2ae7c1036b7ce398e2b18928215f74d57bb3cec6 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 12:28:36 -0400 Subject: search reformatting --- ufund-ui/src/app/components/need-list/need-list.component.css | 1 - ufund-ui/src/app/components/need-list/need-list.component.html | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 29a9626..2e4a31b 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -24,7 +24,6 @@ li { #search-container { background-color: #d9d9d9; - padding: 10px 20px 20px 20px; border: 2px solid #000; border-radius: 5px; } \ No newline at end of file diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 9f22633..0345519 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,8 +1,7 @@

    Needs List

    -
    - +
    -- cgit v1.2.3 From b725948521e81965a18991e7dd59a2bc84dbd460 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 12:56:28 -0400 Subject: need list uses button instead of link --- .../app/components/need-list/need-list.component.css | 15 ++++++++++++--- .../components/need-list/need-list.component.html | 20 +++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 2e4a31b..8f017cd 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -1,17 +1,26 @@ :host { - list-style-type:circle; + list-style-type: none; border: 2px solid #000; display: block; border-radius: 5px; } -li, div { + +div, li > button { border: 2px solid #000; border-radius: 5px; padding: 5px; margin: 5px; } -li { +ul { + list-style-type: none; + padding-inline-start: 0px; +} + +li > button { + width: 98%; + padding: 1%; + margin: 1%; display: flex; justify-content: space-between; align-items: center; diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 0345519..fef22d7 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -12,12 +12,14 @@

    All Needs

    No Results Found

    -
  • - - {{need.name}} - - - -
  • +
      +
    • + + + +
    • +
    \ No newline at end of file -- cgit v1.2.3 From 381e57d62f01056d823af74d186f6de87df9fcee Mon Sep 17 00:00:00 2001 From: sowgro Date: Sat, 22 Mar 2025 16:35:10 -0400 Subject: Dark mode! --- ufund-ui/src/app/app.component.css | 8 +++++++- .../app/components/cupboard/cupboard.component.css | 8 ++++---- .../src/app/components/login/login.component.css | 3 ++- .../src/app/components/login/login.component.html | 2 +- .../components/need-list/need-list.component.css | 8 ++++---- ufund-ui/src/styles.css | 21 +++++++++++++++++++++ 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index 63608c0..17bbed7 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -8,12 +8,14 @@ display: flex; flex-direction: row; justify-content: space-between; - border-bottom: black solid 1px; + border-bottom: light-dark(#d3d3d3, black) solid 1px; padding: 0 10px; + background-color: light-dark(#f5f5f5, #2e2e2e); h1 { padding: 0; margin: 0; + } div { @@ -21,4 +23,8 @@ align-items: center; gap: 10px; } + + a { + color: light-dark(black, white); + } } diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index fe4971a..c8add60 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -1,6 +1,6 @@ :host { display: block; - border: 2px solid #000; + /*border: 2px solid #000;*/ border-radius: 5px; padding: 10px 20px; } @@ -9,7 +9,7 @@ background-color: #d9d9d9; padding: 10px 20px 20px 20px; border: 2px solid #000; - border-radius: 5px; + border-radius: 5px; width: 20%; visibility: visible; @@ -17,5 +17,5 @@ #create-button { padding: 10px 20px; - -} \ No newline at end of file + +} diff --git a/ufund-ui/src/app/components/login/login.component.css b/ufund-ui/src/app/components/login/login.component.css index cae0992..c752de3 100644 --- a/ufund-ui/src/app/components/login/login.component.css +++ b/ufund-ui/src/app/components/login/login.component.css @@ -10,11 +10,12 @@ display: flex; flex-direction: column; max-width: 330px; - gap: 5px; + gap: 7px; backdrop-filter: blur(10px); background-color: rgba(0, 0, 0, 0.1); padding: 30px; color: white; + border-radius: 5px; } .border { diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html index aff108f..516b07b 100644 --- a/ufund-ui/src/app/components/login/login.component.html +++ b/ufund-ui/src/app/components/login/login.component.html @@ -1,6 +1,6 @@
    You must be logged in to view this page -

    Login:

    +

    Login

    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index bbc3f2c..fa3ed4f 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -4,7 +4,7 @@ display: block; width: 30%; border-radius: 5px; - + } li, div { @@ -16,9 +16,9 @@ li, div { } #search-form { - background-color: #d9d9d9; + background-color: light-dark(#d9d9d9, #1b1b1b); padding: 10px 20px 20px 20px; border: 2px solid #000; - border-radius: 5px; + border-radius: 5px; visibility: visible; - } \ No newline at end of file + } diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index fdf67c7..dc7dcea 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -1,5 +1,9 @@ /* You can add global styles to this file, and also import other style files */ +:root { + color-scheme: light dark; +} + * { box-sizing: border-box; } @@ -7,6 +11,7 @@ html, body { margin: 0; height: 100%; + background-color: light-dark(white, #242424); } body { @@ -15,8 +20,24 @@ body { input { font-size: 14pt; + padding: 5px; + border-radius: 5px; + border-style: none; + background-color: light-dark(#ebebeb, #3a3a3a); + + &:hover { + background-color: light-dark(#e1e1e1, #444444); + } } button, .button { font-size: 14pt; + padding: 5px 10px; + border-radius: 5px; + border-style: none; + background-color: light-dark(#ebebeb, #3a3a3a); + + &:hover { + background-color: light-dark(#e1e1e1, #444444); + } } -- cgit v1.2.3 From a05f6f0ab8dead76f937a2d7196fa005af0367fe Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 24 Mar 2025 10:27:31 -0400 Subject: hover feedback for need list's button --- ufund-ui/src/app/components/need-list/need-list.component.css | 6 ++++++ ufund-ui/src/app/components/need-list/need-list.component.html | 4 ++-- ufund-ui/src/app/components/need-list/need-list.component.ts | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 8f017cd..c2b8b90 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -24,8 +24,14 @@ li > button { display: flex; justify-content: space-between; align-items: center; + transition: all 0.3s ease; } +li > button:hover p { + font-weight: bold; +} + + .icon { width: 15px; margin: 3px -3px -1px -3px; diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index fef22d7..fc2daa5 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -13,9 +13,9 @@

    No Results Found

      -
    • +
    • diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 3f77df4..8ae7370 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -78,6 +78,13 @@ export class NeedListComponent { return type === ("HELPER" as unknown as userType); } + changeText(id : number, text : string) { + const label = document.getElementById('need-label-' + id); + if (label) { + label.innerHTML = text; + } + } + add(need: Need) { const currentUser = this.usersService.getCurrentUser(); //console.log("get current user in angular:", currentUser) -- cgit v1.2.3 From 1c1d3922e7eea35764ebab39b18172ed2c8c82d9 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 24 Mar 2025 10:38:40 -0400 Subject: better feedback using a --- ufund-ui/src/app/components/need-list/need-list.component.css | 8 +++++++- ufund-ui/src/app/components/need-list/need-list.component.html | 4 ++-- ufund-ui/src/app/components/need-list/need-list.component.ts | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index c2b8b90..c42dfda 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -25,10 +25,16 @@ li > button { justify-content: space-between; align-items: center; transition: all 0.3s ease; + font-weight: bold; +} + +li > button span { + font-style: italic; + font-weight: normal; } li > button:hover p { - font-weight: bold; + text-decoration: underline; } diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index fc2daa5..741b899 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -13,9 +13,9 @@

      No Results Found

        -
      • +
      • diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 8ae7370..0f86921 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -79,10 +79,10 @@ export class NeedListComponent { } changeText(id : number, text : string) { - const label = document.getElementById('need-label-' + id); - if (label) { - label.innerHTML = text; - } + const span = document.getElementById('hover-status-label-' + id); + if (span) { + span.innerHTML = ' ' + text; + } } add(need: Need) { -- cgit v1.2.3 From 96f833352eff7b9428daf2add988ecd0a2b41d92 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 24 Mar 2025 21:21:32 -0400 Subject: Tweak style --- ufund-ui/src/app/components/login/login.component.css | 7 +++++-- ufund-ui/src/app/components/login/login.component.html | 5 ++++- ufund-ui/src/styles.css | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ufund-ui/src/app/components/login/login.component.css b/ufund-ui/src/app/components/login/login.component.css index c752de3..4bfcbb8 100644 --- a/ufund-ui/src/app/components/login/login.component.css +++ b/ufund-ui/src/app/components/login/login.component.css @@ -9,13 +9,16 @@ #box { display: flex; flex-direction: column; - max-width: 330px; - gap: 7px; + max-width: 350px; + gap: 10px; backdrop-filter: blur(10px); background-color: rgba(0, 0, 0, 0.1); padding: 30px; color: white; border-radius: 5px; + border-style: solid; + border-width: 1px; + border-color: white; } .border { diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html index 516b07b..e04ec23 100644 --- a/ufund-ui/src/app/components/login/login.component.html +++ b/ufund-ui/src/app/components/login/login.component.html @@ -4,6 +4,9 @@ - + + {{statusText | async}}
    diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index dc7dcea..bad2232 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -22,7 +22,8 @@ input { font-size: 14pt; padding: 5px; border-radius: 5px; - border-style: none; + border-style: solid; + border-width: 1px; background-color: light-dark(#ebebeb, #3a3a3a); &:hover { @@ -32,7 +33,7 @@ input { button, .button { font-size: 14pt; - padding: 5px 10px; + padding: 6px 10px; border-radius: 5px; border-style: none; background-color: light-dark(#ebebeb, #3a3a3a); -- cgit v1.2.3 From f0ac1eda74367afc375112a7269c085a511ce490 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 24 Mar 2025 22:23:36 -0400 Subject: viewing search results inside cupboard component --- .../components/cupboard/cupboard.component.html | 11 +++------ .../app/components/cupboard/cupboard.component.ts | 28 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 9b74b2a..3ed06fb 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -9,7 +9,7 @@
    -

    Create a new need

    +

    Create Need



    @@ -26,15 +26,10 @@
    -

    Update a need

    +

    Update Need


    -
    - - -
    -
    -
    +



    diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 646c4ff..e38f8c0 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -16,10 +16,9 @@ import { NeedListComponent } from '../need-list/need-list.component'; export class CupboardComponent implements OnInit { protected statusText = new BehaviorSubject("") - selectedForm = "create" + selectedForm = "create"; needs: any; - @ViewChild("needList") needList?: NeedListComponent - + @ViewChild("needList") needList?: NeedListComponent; constructor(private cupboardService: CupboardService, private usersService: UsersService) { } ngOnInit(): void { @@ -38,9 +37,32 @@ export class CupboardComponent implements OnInit { type: '' }; selectedNeedId: number | null = null; + searchResults: any[] = []; selectForm(name: string) { + //get search results from the need list + if (this.needList) { + this.searchResults = this.needList.searchResults; + } + console.log(this.searchResults) this.selectedForm = name; + if (name == 'update') { + if (this.searchResults) { + this.searchResults.forEach((element: any) => { + console.log(element) + }); + } + + } + } + + async updateSearchResults() { + if (this.needList) { + while (this.selectedForm == 'update') { + this.searchResults = this.needList.searchResults + await new Promise(resolve => setTimeout(resolve, 100)); + } + } } populateForm(need: any): void { -- cgit v1.2.3 From 428992e125d3089aeb34da0190a3df05d0992cf0 Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 25 Mar 2025 08:46:05 -0400 Subject: assets for need list search and edit --- ufund-ui/public/edit.png | Bin 0 -> 6649 bytes ufund-ui/public/search.png | Bin 0 -> 12743 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 ufund-ui/public/edit.png create mode 100644 ufund-ui/public/search.png diff --git a/ufund-ui/public/edit.png b/ufund-ui/public/edit.png new file mode 100644 index 0000000..3b6e2d8 Binary files /dev/null and b/ufund-ui/public/edit.png differ diff --git a/ufund-ui/public/search.png b/ufund-ui/public/search.png new file mode 100644 index 0000000..1940ef5 Binary files /dev/null and b/ufund-ui/public/search.png differ -- cgit v1.2.3 From 20458b2ae22466d0b75a2ae60f318e514c0d905f Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 25 Mar 2025 08:46:45 -0400 Subject: need list reformatting- button does not span whole list element --- .../app/components/need-list/need-list.component.css | 19 ++++++++++++++----- .../app/components/need-list/need-list.component.html | 14 ++++++++++---- .../app/components/need-list/need-list.component.ts | 7 ++++++- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index c42dfda..74dbc34 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -5,7 +5,7 @@ border-radius: 5px; } -div, li > button { +div { border: 2px solid #000; border-radius: 5px; padding: 5px; @@ -17,17 +17,26 @@ ul { padding-inline-start: 0px; } -li > button { - width: 98%; - padding: 1%; - margin: 1%; +li { display: flex; justify-content: space-between; align-items: center; transition: all 0.3s ease; font-weight: bold; + border: 2px solid #000; + border-radius: 5px; + margin: 5px; + + > button { + width: 90%; + float: left; + transition: all 0.3s ease; + font-weight: bold; + display: flex; + } } + li > button span { font-style: italic; font-weight: normal; diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 741b899..b31ccf0 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -13,13 +13,19 @@

    No Results Found

      -
    • - + + +
      + - - +
    \ No newline at end of file diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 0f86921..e47929b 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -11,6 +11,7 @@ import { userType } from '../../models/User'; styleUrl: './need-list.component.css' }) export class NeedListComponent { + selectedNeed: Need | undefined; needs: Need[] = []; searchResults: Need[] = []; @@ -109,4 +110,8 @@ export class NeedListComponent { back() { this.searchResults = this.needs; } -} + + select(need : Need) { + this.selectedNeed = need; + } +} \ No newline at end of file -- cgit v1.2.3 From f7cd2d90191c1d81526ed549514d82864c1aebb2 Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 25 Mar 2025 09:08:26 -0400 Subject: restyling of need list results --- .../app/components/need-list/need-list.component.css | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 74dbc34..c763105 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -1,4 +1,5 @@ :host { + --list-background-color: lightgray; list-style-type: none; border: 2px solid #000; display: block; @@ -18,6 +19,7 @@ ul { } li { + background-color: var(--list-background-color); display: flex; justify-content: space-between; align-items: center; @@ -25,17 +27,26 @@ li { font-weight: bold; border: 2px solid #000; border-radius: 5px; - margin: 5px; - + margin: 5px; > button { - width: 90%; + background-color: var(--list-background-color); + width: 88%; float: left; transition: all 0.3s ease; font-weight: bold; display: flex; + border: none; + border-radius: 5px; + } + + > section { + width: 12%; } } +section button{ + margin: 4%; +} li > button span { font-style: italic; @@ -48,7 +59,7 @@ li > button:hover p { .icon { - width: 15px; + width: 18px; margin: 3px -3px -1px -3px; } -- cgit v1.2.3 From 304b867c6fa5c1192e8cdec7fd22affb50e244b3 Mon Sep 17 00:00:00 2001 From: Akash Keshav <112591754+domesticchores@users.noreply.github.com> Date: Tue, 25 Mar 2025 09:37:49 -0400 Subject: implement sorting algorithms with selection buttons. -ak --- .../components/need-list/need-list.component.html | 7 ++++ .../components/need-list/need-list.component.ts | 46 ++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 36c12d0..c5faf74 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,4 +1,11 @@

    Needs List

    +
    +

    Sort by:

    + +

    +

    +
    +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 25f05d6..be444fb 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -1,8 +1,28 @@ -import { Component } from '@angular/core'; +import { Component, Input } from '@angular/core'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; import { userType } from '../../models/User'; + +interface sortAlgo { + (a: Need,b: Need): number; +} + +// sort functions +const sortByName: sortAlgo = (a: Need, b: Need): number => { + if(a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + return 1; +} + +const sortByMaxGoal: sortAlgo = (a: Need, b: Need): number => { + if(a.maxGoal >= b.maxGoal) { + return -1; + } + return 1; +} + @Component({ selector: 'app-need-list', standalone: false, @@ -12,6 +32,12 @@ import { userType } from '../../models/User'; export class NeedListComponent { needs: Need[] = []; searchResults: Need[] = []; + currentSortAlgo: sortAlgo = sortByMaxGoal; + + SortingAlgoArrays: {func:sortAlgo,name:string}[] = [ + {func:sortByMaxGoal,name:"sortByMaxGoal"}, + {func:sortByName,name:"sortByName"}, + ]; constructor( private cupboardService: CupboardService, @@ -19,7 +45,7 @@ export class NeedListComponent { ) {} refresh() { - this.cupboardService.getNeeds().subscribe(n => this.needs = n) + this.cupboardService.getNeeds().subscribe(n => this.needs = n.sort(this.currentSortAlgo)) } ngOnInit(): void { @@ -60,6 +86,19 @@ export class NeedListComponent { this.hideElement(document.getElementById('search-status')); } + changeSortAlgo(algoName: string, form: any) { + console.log(algoName); + this.SortingAlgoArrays.forEach(algo => { + if(algo.name === algoName) { + this.currentSortAlgo = algo.func; + console.log("changed sorting algorithm to: ", algo.name) + return + } + }); + this.refresh() + this.search(form); + } + private searchDelay: any; async search(form: any) { @@ -72,8 +111,9 @@ export class NeedListComponent { this.searchDelay = setTimeout(() => { const currentSearchValue = form.search; //latest value of the search + console.log("current search value: ", currentSearchValue) this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { - this.searchResults = n; + this.searchResults = n.sort(this.currentSortAlgo); console.log(currentSearchValue, this.searchResults); this.showElement(document.getElementById('search-results')); this.showElement(document.getElementById('search-status')); -- cgit v1.2.3 From 07d191cb1fc8890f66e9af7d19e8276089d18d8b Mon Sep 17 00:00:00 2001 From: Akash Keshav <112591754+domesticchores@users.noreply.github.com> Date: Tue, 25 Mar 2025 09:45:38 -0400 Subject: added more sort options; fix HTML error --- .../src/app/components/need-list/need-list.component.html | 2 ++ .../src/app/components/need-list/need-list.component.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index c5faf74..283cc99 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -3,7 +3,9 @@

    Sort by:

    +

    +

    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index be444fb..06bb17e 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -16,13 +16,24 @@ const sortByName: sortAlgo = (a: Need, b: Need): number => { return 1; } +const sortByNameReverse: sortAlgo = (a: Need, b: Need): number => { + return sortByName(a,b)*-1; +} + const sortByMaxGoal: sortAlgo = (a: Need, b: Need): number => { - if(a.maxGoal >= b.maxGoal) { + if(a.maxGoal == b.maxGoal) { + return sortByName(a,b); + } + else if(a.maxGoal > b.maxGoal) { return -1; } return 1; } +const sortByMinGoal: sortAlgo = (a: Need, b: Need): number => { + return sortByMaxGoal(a,b)*-1; +} + @Component({ selector: 'app-need-list', standalone: false, @@ -37,6 +48,8 @@ export class NeedListComponent { SortingAlgoArrays: {func:sortAlgo,name:string}[] = [ {func:sortByMaxGoal,name:"sortByMaxGoal"}, {func:sortByName,name:"sortByName"}, + {func:sortByNameReverse,name:"sortByNameReverse"}, + {func:sortByMinGoal,name:"sortByMinGoal"}, ]; constructor( -- cgit v1.2.3 From d9eb78521f29ead3a9f70b09e18a6d9560cc849c Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 25 Mar 2025 10:43:52 -0400 Subject: fancy selection animation for need list --- .../components/need-list/need-list.component.css | 2 +- .../components/need-list/need-list.component.html | 4 ++-- .../components/need-list/need-list.component.ts | 28 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index c763105..2eb6a8d 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -29,7 +29,7 @@ li { border-radius: 5px; margin: 5px; > button { - background-color: var(--list-background-color); + background-color: transparent; width: 88%; float: left; transition: all 0.3s ease; diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index b31ccf0..eaa8a6f 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -13,14 +13,14 @@

    No Results Found

      -
    • +
    • -
    diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index e38f8c0..cf9b95e 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import {Component, Input, OnInit, ViewChild} from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; import { Need, GoalType } from '../../models/Need'; @@ -38,9 +38,9 @@ export class CupboardComponent implements OnInit { }; selectedNeedId: number | null = null; searchResults: any[] = []; - + selectForm(name: string) { - //get search results from the need list + //get search results from the need list if (this.needList) { this.searchResults = this.needList.searchResults; } diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 9ef191a..bf78d99 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import {Component, Input} from '@angular/core'; import { NgForm } from '@angular/forms'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; @@ -15,6 +15,8 @@ export class NeedListComponent { needs: Need[] = []; searchResults: Need[] = []; + @Input() editF?: Function + constructor( private cupboardService: CupboardService, private usersService: UsersService @@ -43,7 +45,7 @@ export class NeedListComponent { } if (form) { this.searchDelay = setTimeout(() => { - + if (form) { const currentSearchValue = form.search; //latest value of the search this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { @@ -58,9 +60,9 @@ export class NeedListComponent { clearTimeout(this.searchDelay); this.searchResults = this.needs; } - - + + } delete(id : number) { @@ -80,10 +82,10 @@ export class NeedListComponent { } changeText(id : number, text : string) { - const span = document.getElementById('hover-status-label-' + id); + const span = document.getElementById('hover-status-label-' + id); if (span) { span.innerHTML = ' ' + text; - } + } } add(need: Need) { @@ -101,7 +103,7 @@ export class NeedListComponent { } else { window.alert("This need is already in your basket!") } - + } @@ -140,4 +142,4 @@ export class NeedListComponent { button.style.visibility = 'hidden'; } } -} \ No newline at end of file +} -- cgit v1.2.3 From 0549991d0b32de4de544d16478ce5b2782c1809d Mon Sep 17 00:00:00 2001 From: benal01 Date: Wed, 26 Mar 2025 18:59:55 -0400 Subject: use (output) for need edit selection --- ufund-ui/src/app/components/cupboard/cupboard.component.html | 2 +- ufund-ui/src/app/components/need-list/need-list.component.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index c2d146b..4b76f25 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -1,6 +1,6 @@

    Cupboard

    - +

    Admin View

    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index bf78d99..2eed87d 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -1,4 +1,4 @@ -import {Component, Input} from '@angular/core'; +import {Component, Output, EventEmitter} from '@angular/core'; import { NgForm } from '@angular/forms'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; @@ -11,11 +11,11 @@ import { userType } from '../../models/User'; styleUrl: './need-list.component.css' }) export class NeedListComponent { - selectedNeed: Need | undefined; + selectedNeed: Need | null = null; needs: Need[] = []; searchResults: Need[] = []; - @Input() editF?: Function + @Output() currentNeed = new EventEmitter(); constructor( private cupboardService: CupboardService, @@ -114,6 +114,8 @@ export class NeedListComponent { } select(need : Need) { + //emit value + this.currentNeed.emit(need); if (this.selectedNeed) { //revert already selected need to previous style console.log(need.id); -- cgit v1.2.3 From 959aa5101fbba55f20eda46d02addd27a74cf950 Mon Sep 17 00:00:00 2001 From: benal01 Date: Wed, 26 Mar 2025 19:03:16 -0400 Subject: snap form open on edit event --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index cf9b95e..0d2c1f5 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -66,6 +66,7 @@ export class CupboardComponent implements OnInit { } populateForm(need: any): void { + this.selectForm('update'); this.selectedNeed = { ...need }; } -- cgit v1.2.3 From d5ae670dbce9e5cabbd594759df490176fd8cecd Mon Sep 17 00:00:00 2001 From: benal01 Date: Wed, 26 Mar 2025 19:12:52 -0400 Subject: use selected id for the update form --- ufund-ui/src/app/components/cupboard/cupboard.component.html | 1 - ufund-ui/src/app/components/cupboard/cupboard.component.ts | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 4b76f25..d54eed9 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -29,7 +29,6 @@

    Update Need


    -



    diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 0d2c1f5..a8b9c14 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -79,14 +79,13 @@ export class CupboardComponent implements OnInit { console.log(form); const need: Need = { name: form.name, - id: form.id, //system will control this + id: this.selectedNeed.id, //system will control this maxGoal: form.maxGoal, type: GoalType[form.type as keyof typeof GoalType], filterAttributes: [], current: 0 }; - console.log("need:", need); - console.log(need.id, need, "need updated"); + this.cupboardService.updateNeed(need.id, need) .pipe(catchError((ex, r) => { if (ex.status == 500) { -- cgit v1.2.3 From 057efa1b557d5d874300c6cda8c7d74519c946d6 Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 27 Mar 2025 08:50:12 -0400 Subject: use instead of table with *ngFor for sort algorithms --- .../src/app/components/need-list/need-list.component.html | 15 ++++++--------- .../src/app/components/need-list/need-list.component.ts | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index de4be58..9799493 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,14 +1,11 @@

    Needs List

    -
    -

    Sort by:

    - -

    -

    -

    -

    -
    -
    + +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 208045f..c1063ce 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -45,6 +45,7 @@ export class NeedListComponent { selectedNeed: Need | null = null; needs: Need[] = []; searchResults: Need[] = []; + sortSelection: string = ''; currentSortAlgo: sortAlgo = sortByMaxGoal; SortingAlgoArrays: {func:sortAlgo,name:string}[] = [ -- cgit v1.2.3 From 84083e7229678c30d827270bfa25de66a02d7b8c Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 27 Mar 2025 08:54:06 -0400 Subject: display name for algorithms --- ufund-ui/src/app/components/need-list/need-list.component.html | 2 +- ufund-ui/src/app/components/need-list/need-list.component.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 9799493..a653527 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -3,7 +3,7 @@ diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index c1063ce..2fdd993 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -48,11 +48,11 @@ export class NeedListComponent { sortSelection: string = ''; currentSortAlgo: sortAlgo = sortByMaxGoal; - SortingAlgoArrays: {func:sortAlgo,name:string}[] = [ - {func:sortByMaxGoal,name:"sortByMaxGoal"}, - {func:sortByName,name:"sortByName"}, - {func:sortByNameReverse,name:"sortByNameReverse"}, - {func:sortByMinGoal,name:"sortByMinGoal"}, + SortingAlgoArrays: {func:sortAlgo,name:string,display:string}[] = [ + {func:sortByMaxGoal,name:"sortByMaxGoal", display:"Max Goal"}, + {func:sortByName,name:"sortByName", display:"Name"}, + {func:sortByNameReverse,name:"sortByNameReverse", display:"Name (reverse)"}, + {func:sortByMinGoal,name:"sortByMinGoal", display:"Min Goal"}, ]; @Output() currentNeed = new EventEmitter(); -- cgit v1.2.3 From 65590e6dfbed90e4acd342a72feb8d7b5120d70c Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 27 Mar 2025 09:49:41 -0400 Subject: refactor sorting to use acending descending toggle --- .../components/need-list/need-list.component.html | 5 ++- .../components/need-list/need-list.component.ts | 46 +++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index a653527..5be915c 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -3,9 +3,12 @@ +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 2fdd993..97be0cb 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -17,11 +17,7 @@ const sortByName: sortAlgo = (a: Need, b: Need): number => { return 1; } -const sortByNameReverse: sortAlgo = (a: Need, b: Need): number => { - return sortByName(a,b)*-1; -} - -const sortByMaxGoal: sortAlgo = (a: Need, b: Need): number => { +const sortByGoal: sortAlgo = (a: Need, b: Need): number => { if(a.maxGoal == b.maxGoal) { return sortByName(a,b); } @@ -31,10 +27,6 @@ const sortByMaxGoal: sortAlgo = (a: Need, b: Need): number => { return 1; } -const sortByMinGoal: sortAlgo = (a: Need, b: Need): number => { - return sortByMaxGoal(a,b)*-1; -} - @Component({ selector: 'app-need-list', standalone: false, @@ -45,14 +37,13 @@ export class NeedListComponent { selectedNeed: Need | null = null; needs: Need[] = []; searchResults: Need[] = []; + sortMode = 'Ascending' sortSelection: string = ''; - currentSortAlgo: sortAlgo = sortByMaxGoal; + currentSortAlgo: sortAlgo = sortByGoal; - SortingAlgoArrays: {func:sortAlgo,name:string,display:string}[] = [ - {func:sortByMaxGoal,name:"sortByMaxGoal", display:"Max Goal"}, - {func:sortByName,name:"sortByName", display:"Name"}, - {func:sortByNameReverse,name:"sortByNameReverse", display:"Name (reverse)"}, - {func:sortByMinGoal,name:"sortByMinGoal", display:"Min Goal"}, + SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [ + {func:sortByGoal,name:"sortByMaxGoal", display:["Max Goal", "Min Goal"]}, + {func:sortByName,name:"sortByName", display:["Name", "Name (Descending)"]}, ]; @Output() currentNeed = new EventEmitter(); @@ -64,22 +55,34 @@ export class NeedListComponent { refresh() { this.cupboardService.getNeeds().subscribe(n => { - this.needs = n.sort(this.currentSortAlgo); + if (this.sortMode == 'Ascending') { + this.needs = n.sort(this.currentSortAlgo); + } else { + this.needs = n.sort(this.currentSortAlgo).reverse(); + } this.searchResults = this.needs; }); - console.log(this.searchResults); } ngOnInit(): void { this.refresh() } + changeSortMode(form : any) { + if (this.sortMode == 'Ascending'){ + this.sortMode = 'Descending' + } else { + this.sortMode = 'Ascending' + } + this.search(form) + } + changeSortAlgo(algoName: string, form: any) { console.log(algoName); this.SortingAlgoArrays.forEach(algo => { if(algo.name === algoName) { this.currentSortAlgo = algo.func; - console.log("changed sorting algorithm to: ", algo.name) + console.log("changed sorting algorithm to: ", algo.name + this.sortMode) return } }); @@ -102,7 +105,12 @@ export class NeedListComponent { if (form) { const currentSearchValue = form.search; //latest value of the search this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { - this.searchResults = n.sort(this.currentSortAlgo); + if (this.sortMode == 'Ascending') { + this.searchResults = n.sort(this.currentSortAlgo); + } else { + this.searchResults = n.sort(this.currentSortAlgo).reverse(); + } + console.log(currentSearchValue, this.searchResults); }); } -- cgit v1.2.3 From ee4154df85a971f3a0f8e43fd6afdfa6a620ea99 Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 27 Mar 2025 10:09:19 -0400 Subject: refactor change sort algo func with [(ngModel)] binding --- .../components/need-list/need-list.component.html | 2 +- .../components/need-list/need-list.component.ts | 25 ++++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 5be915c..4f259a0 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,7 +1,7 @@

    Needs List

    - diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 97be0cb..177d9f7 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -38,8 +38,9 @@ export class NeedListComponent { needs: Need[] = []; searchResults: Need[] = []; sortMode = 'Ascending' - sortSelection: string = ''; + currentSortAlgo: sortAlgo = sortByGoal; + sortSelection: string = this.currentSortAlgo.name; SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [ {func:sortByGoal,name:"sortByMaxGoal", display:["Max Goal", "Min Goal"]}, @@ -77,19 +78,6 @@ export class NeedListComponent { this.search(form) } - changeSortAlgo(algoName: string, form: any) { - console.log(algoName); - this.SortingAlgoArrays.forEach(algo => { - if(algo.name === algoName) { - this.currentSortAlgo = algo.func; - console.log("changed sorting algorithm to: ", algo.name + this.sortMode) - return - } - }); - this.refresh() - this.search(form); - } - private searchDelay: any; async search(form: any) { @@ -103,6 +91,15 @@ export class NeedListComponent { this.searchDelay = setTimeout(() => { if (form) { + //sorting based on algo selected + this.SortingAlgoArrays.forEach(algo => { + if(algo.name === this.sortSelection) { + this.currentSortAlgo = algo.func; + console.log("changed sorting algorithm to: ", algo.name + this.sortMode) + return + } + }); + const currentSearchValue = form.search; //latest value of the search this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { if (this.sortMode == 'Ascending') { -- cgit v1.2.3 From 0b4c76c5dc7313ae42c62be3c682c1f88cec13fd Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 27 Mar 2025 10:36:32 -0400 Subject: defaut value for sorting --- ufund-ui/src/app/components/need-list/need-list.component.html | 2 +- ufund-ui/src/app/components/need-list/need-list.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 4f259a0..693307f 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,7 +1,7 @@

    Needs List

    - diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 177d9f7..f935e03 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -40,10 +40,10 @@ export class NeedListComponent { sortMode = 'Ascending' currentSortAlgo: sortAlgo = sortByGoal; - sortSelection: string = this.currentSortAlgo.name; + sortSelection: string = 'sortByGoal'; SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [ - {func:sortByGoal,name:"sortByMaxGoal", display:["Max Goal", "Min Goal"]}, + {func:sortByGoal,name:"sortByGoal", display:["Max Goal", "Min Goal"]}, {func:sortByName,name:"sortByName", display:["Name", "Name (Descending)"]}, ]; -- cgit v1.2.3 From fb4e2bc3eb66ca861eb8393ade21811e4510669a Mon Sep 17 00:00:00 2001 From: sowgro Date: Fri, 28 Mar 2025 19:09:53 -0400 Subject: Start implementation new design --- ufund-ui/public/jf.png | Bin 0 -> 1159826 bytes ufund-ui/src/app/app.component.css | 25 +++++++++++++---- ufund-ui/src/app/app.component.html | 6 ++--- .../components/home-page/home-page.component.css | 30 +++++++++++++++++++++ .../components/home-page/home-page.component.html | 12 +++++++-- .../src/app/components/login/login.component.css | 8 ++++-- ufund-ui/src/index.html | 4 +++ ufund-ui/src/styles.css | 19 ++++++++++--- 8 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 ufund-ui/public/jf.png diff --git a/ufund-ui/public/jf.png b/ufund-ui/public/jf.png new file mode 100644 index 0000000..bbf95d5 Binary files /dev/null and b/ufund-ui/public/jf.png differ diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index 17bbed7..5596cf8 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -8,23 +8,38 @@ display: flex; flex-direction: row; justify-content: space-between; - border-bottom: light-dark(#d3d3d3, black) solid 1px; - padding: 0 10px; - background-color: light-dark(#f5f5f5, #2e2e2e); + /*border-bottom: light-dark(#d3d3d3, black) solid 1px;*/ + padding: 15px 20px; + /*background-color: light-dark(#f5f5f5, #2e2e2e);*/ + z-index: 2; h1 { padding: 0; margin: 0; - + font-weight: 500; + /*text-decoration: none;*/ + text-transform: uppercase; + font-size: 16pt; + letter-spacing: .5px; } div { display: flex; align-items: center; - gap: 10px; + gap: 20px; } + /*div:has(a:hover) a {*/ + /* color: light-dark(black, rgba(255, 255, 255, 0.5));*/ + /*}*/ + a { color: light-dark(black, white); + text-decoration: none; + } + + a:hover { + /*color: light-dark(black, white)*/ + text-decoration: underline; } } diff --git a/ufund-ui/src/app/app.component.html b/ufund-ui/src/app/app.component.html index 3058117..b0ee329 100644 --- a/ufund-ui/src/app/app.component.html +++ b/ufund-ui/src/app/app.component.html @@ -1,14 +1,14 @@
    - +

    Location: {{need?.location}}

    Goal: {{need?.maxGoal}}

    Current: {{need?.current}}

    +

    Urgent: {{need?.urgent}}

    This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!

    \ No newline at end of file -- cgit v1.2.3 From 88650361adfc9be8344b0d383100b0c6ab513973 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sun, 30 Mar 2025 00:33:41 -0400 Subject: basic css and info display for needs --- .../src/app/components/need-list/need-list.component.css | 13 +++++++++++-- .../src/app/components/need-list/need-list.component.html | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 19c126f..345326f 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -31,12 +31,21 @@ li { > button { background-color: transparent; width: 88%; - float: left; transition: all 0.3s ease; font-weight: bold; - display: flex; border: none; border-radius: 5px; + padding-left: 1.5%; + > section { + width: 100%; + flex: none; + display: inline-block; + background-color: magenta; + > progress { + width: 25%; + float: none; + } + } } > section { diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index ed151a3..88b9752 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -28,7 +28,14 @@
    • -- cgit v1.2.3 From daae556a1be7a30bc6f4606bd1b1567b713d054a Mon Sep 17 00:00:00 2001 From: benal01 Date: Sun, 30 Mar 2025 00:39:23 -0400 Subject: better display for urgency --- ufund-ui/src/app/components/need-list/need-list.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 88b9752..866e5e4 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -28,7 +28,7 @@
      • - Account created Proceed to login - {{statusText | async}} +
        + + Account created Proceed to login + {{statusText | async}} +
        + Already have an account? Log in
    diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts index 3b43287..1ab863d 100644 --- a/ufund-ui/src/app/components/signup/signup.component.ts +++ b/ufund-ui/src/app/components/signup/signup.component.ts @@ -22,7 +22,7 @@ class PasswordRequirements { export class SignupComponent { protected passwordStatusText = new BehaviorSubject("") - protected confirmPassStatusText = new BehaviorSubject("") + protected passwordsMatch = new BehaviorSubject(false) protected usernameStatusText = new BehaviorSubject("") protected showSuccessMessage = new BehaviorSubject(false) protected passwordStrongEnough = new BehaviorSubject(false) @@ -51,7 +51,7 @@ export class SignupComponent { } validate(username: string, passConfirm:string, password: string) { - this.confirmPassStatusText.next("") + this.passwordsMatch.next(false) this.usernameStatusText.next("") this.checkPasswordStrength(password); @@ -59,8 +59,8 @@ export class SignupComponent { this.usernameStatusText.next("Username field can't be blank") } - if (!(password === passConfirm) && !!passConfirm) { - this.confirmPassStatusText.next("Passwords don't match") + if (passConfirm && password === passConfirm) { + this.passwordsMatch.next(true) } this.ableToCreateAccount.next(this.passwordStrongEnough.getValue() && password === passConfirm && !!username) } @@ -106,7 +106,7 @@ export class SignupComponent { } else if (strength == 0) { this.passwordStatusText.next("") } else { - this.passwordStatusText.next("Password does not meet requirements") + this.passwordStatusText.next("5/6 checks required") } this.strength.next(strength) -- cgit v1.2.3 From 197be103d02db808b0e6bf8a1d1369e3d7928c03 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 30 Mar 2025 20:48:22 -0400 Subject: Modified controllers to return error text when catching errors. Also added additional error checking to CupboardService for physical needs. --- .../api/ufundapi/controller/AuthController.java | 6 +-- .../ufundapi/controller/CupboardController.java | 54 +++++++++++----------- .../api/ufundapi/controller/UserController.java | 26 +++++------ .../controller/CupboardControllerTest.java | 8 ++-- .../ufundapi/controller/UserControllerTest.java | 34 +++++++------- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java index aa99a90..82b2c67 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java @@ -43,10 +43,10 @@ public class AuthController { return new ResponseEntity<>(key, HttpStatus.OK); } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -64,7 +64,7 @@ public class AuthController { return new ResponseEntity<>(HttpStatus.OK); } catch (IOException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } } diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index d426aee..cce016c 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -51,7 +51,7 @@ public class CupboardController { * INTERNAL_SERVER_ERROR otherwise */ @PostMapping("") - public ResponseEntity createNeed(@RequestBody Map params, @RequestHeader("jelly-api-key") String key) { + public ResponseEntity createNeed(@RequestBody Map params, @RequestHeader("jelly-api-key") String key) { LOG.log(Level.INFO, "POST /cupboard body={0}", params); String name = (String) params.get("name"); @@ -66,16 +66,16 @@ public class CupboardController { return new ResponseEntity<>(need, HttpStatus.OK); } catch (DuplicateKeyException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.CONFLICT); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.CONFLICT); } catch (IllegalArgumentException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST); } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -88,15 +88,15 @@ public class CupboardController { * ResponseEntity with HTTP status of INTERNAL_SERVER_ERROR otherwise */ @GetMapping("") - public ResponseEntity getNeeds() { + public ResponseEntity getNeeds() { LOG.info("GET /cupboard"); try { Need[] needs = cupboardService.getNeeds(); return new ResponseEntity<>(needs, HttpStatus.OK); - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } catch (IOException ex) { + LOG.log(Level.SEVERE, ex.getLocalizedMessage()); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -112,15 +112,15 @@ public class CupboardController { *

    */ @GetMapping("/") - public ResponseEntity searchNeeds(@RequestParam String name) { + public ResponseEntity searchNeeds(@RequestParam String name) { LOG.info("GET /cupboard/?name="+name); try { Need[] needs = cupboardService.searchNeeds(name); return new ResponseEntity<>(needs, HttpStatus.OK); - } catch (IOException e) { - LOG.log(Level.SEVERE,e.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } catch (IOException ex) { + LOG.log(Level.SEVERE,ex.getLocalizedMessage()); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -133,7 +133,7 @@ public class CupboardController { * ResponseEntity with HTTP status of NOT_FOUND if not found
    */ @GetMapping("/{id}") - public ResponseEntity getNeed(@PathVariable int id) { + public ResponseEntity getNeed(@PathVariable int id) { LOG.log(Level.INFO, "GET /cupboard/{0}", id); try { @@ -143,9 +143,9 @@ public class CupboardController { } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } catch (IOException ex) { + LOG.log(Level.SEVERE, ex.getLocalizedMessage()); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -157,7 +157,7 @@ public class CupboardController { * @return OK response and the need if it was successful, or INTERNAL_SERVER_ERROR if there was an issue */ @PutMapping("/{id}") - public ResponseEntity updateNeed(@RequestBody Need need, @PathVariable int id, @RequestHeader("jelly-api-key") String key) { + public ResponseEntity updateNeed(@RequestBody Need need, @PathVariable int id, @RequestHeader("jelly-api-key") String key) { LOG.log(Level.INFO, "PUT /cupboard/{0} body={1}", of(id, need)); try { authService.keyHasAccessToCupboard(key); @@ -169,13 +169,13 @@ public class CupboardController { } } catch (IllegalArgumentException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST); } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -196,13 +196,13 @@ public class CupboardController { return new ResponseEntity<>(HttpStatus.OK); } catch (IllegalArgumentException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST); } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -213,7 +213,7 @@ public class CupboardController { * @return OK if the need was deleted, NOT_FOUND if the need was not found, or INTERNAL_SERVER_ERROR if an error occurred */ @DeleteMapping("/{id}") - public ResponseEntity deleteNeed(@PathVariable int id, @RequestHeader("jelly-api-key") String key) { + public ResponseEntity deleteNeed(@PathVariable int id, @RequestHeader("jelly-api-key") String key) { LOG.log(Level.INFO, "DELETE /cupboard/{0}", id); try { authService.keyHasAccessToCupboard(key); @@ -225,10 +225,10 @@ public class CupboardController { } } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java index 33d2e4f..a34e891 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java @@ -41,7 +41,7 @@ public class UserController { * otherwise */ @PostMapping("") - public ResponseEntity createUser(@RequestBody Map params) { + public ResponseEntity createUser(@RequestBody Map params) { LOG.log(Level.INFO, "POST /users body={0}", params); String username = params.get("username"); String password = params.get("password"); @@ -55,10 +55,10 @@ public class UserController { } } catch (DuplicateKeyException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.CONFLICT); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.CONFLICT); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -73,7 +73,7 @@ public class UserController { * ResponseEntity with HTTP status of INTERNAL_SERVER_ERROR otherwise */ @GetMapping("/{username}") - public ResponseEntity getUser(@PathVariable String username, @RequestHeader("jelly-api-key") String key) { + public ResponseEntity getUser(@PathVariable String username, @RequestHeader("jelly-api-key") String key) { LOG.log(Level.INFO, "GET /user/{0} key={1}", of(username, key)); try { @@ -86,10 +86,10 @@ public class UserController { } } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -104,7 +104,7 @@ public class UserController { * INTERNAL_SERVER_ERROR if there was an issue */ @PutMapping("/{username}") - public ResponseEntity updateUser(@RequestBody User user, @PathVariable String username, @RequestHeader("jelly-api-key") String key) { + public ResponseEntity updateUser(@RequestBody User user, @PathVariable String username, @RequestHeader("jelly-api-key") String key) { LOG.log(Level.INFO,"PUT /users/{0} body={1} key={2}", of(username, user, key)); try { authService.keyHasAccessToUser(username, key); @@ -116,13 +116,13 @@ public class UserController { } } catch (IllegalArgumentException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST); } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -135,7 +135,7 @@ public class UserController { * INTERNAL_SERVER_ERROR if an error occurred */ @DeleteMapping("/{username}") - public ResponseEntity deleteUser(@PathVariable String username, @RequestHeader("jelly-api-key") String key) { + public ResponseEntity deleteUser(@PathVariable String username, @RequestHeader("jelly-api-key") String key) { LOG.log(Level.INFO, "DELETE /users/{0} id={1}", of(username, key)); try { @@ -147,10 +147,10 @@ public class UserController { } } catch (IllegalAccessException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage()); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java index 75dbf84..c159db4 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java @@ -142,7 +142,7 @@ public class CupboardControllerTest { var res = cupboardController.getNeeds(); assertEquals(HttpStatus.OK, res.getStatusCode()); - assertArrayEquals(new Need[]{need}, res.getBody()); + assertArrayEquals(new Need[]{need}, (Need[]) res.getBody()); } @Test @@ -161,7 +161,7 @@ public class CupboardControllerTest { var res = cupboardController.getNeeds(); assertEquals(HttpStatus.OK, res.getStatusCode()); - assertArrayEquals(new Need[]{}, res.getBody()); + assertArrayEquals(new Need[]{}, (Need[]) res.getBody()); } @Test @@ -177,7 +177,7 @@ public class CupboardControllerTest { var res = cupboardController.searchNeeds("Na"); assertEquals(HttpStatus.OK, res.getStatusCode()); - assertArrayEquals(new Need[]{need}, res.getBody()); + assertArrayEquals(new Need[]{need}, (Need[]) res.getBody()); } @Test @@ -196,7 +196,7 @@ public class CupboardControllerTest { var res = cupboardController.searchNeeds("Na"); assertEquals(HttpStatus.OK, res.getStatusCode()); - assertArrayEquals(new Need[]{}, res.getBody()); + assertArrayEquals(new Need[]{}, (Need[]) res.getBody()); } @Test diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java index 06fb6cd..5870a93 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java @@ -50,12 +50,12 @@ public class UserControllerTest { // Invoke - ResponseEntity response = userController.getUser(username, key); + ResponseEntity response = userController.getUser(username, key); // Analyze assertEquals(HttpStatus.OK, response.getStatusCode()); assertNotNull(response.getBody()); - assertEquals(user.getUsername(), response.getBody().getUsername()); + assertEquals(user.getUsername(), ((User) response.getBody()).getUsername()); } @Test @@ -69,7 +69,7 @@ public class UserControllerTest { // Invoke - ResponseEntity response = userController.getUser(username, key); + ResponseEntity response = userController.getUser(username, key); // Analyze assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); @@ -85,7 +85,7 @@ public class UserControllerTest { doThrow(new IllegalAccessException()).when(mockAuthService).keyHasAccessToUser(username, key); // Invoke - ResponseEntity response = userController.getUser(username, key); + ResponseEntity response = userController.getUser(username, key); // Analyze assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); @@ -100,7 +100,7 @@ public class UserControllerTest { doThrow(new IOException()).when(mockUserService).getUser(username); // Invoke - ResponseEntity response = userController.getUser(username, key); + ResponseEntity response = userController.getUser(username, key); // Analyze assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); @@ -119,7 +119,7 @@ public class UserControllerTest { // Invoke - ResponseEntity response = userController.createUser(userMap); + ResponseEntity response = userController.createUser(userMap); // Analyze assertEquals(HttpStatus.CREATED, response.getStatusCode()); @@ -138,7 +138,7 @@ public class UserControllerTest { // Invoke - ResponseEntity response = userController.createUser(userMap); + ResponseEntity response = userController.createUser(userMap); // Analyze assertEquals(HttpStatus.CONFLICT, response.getStatusCode()); @@ -154,7 +154,7 @@ public class UserControllerTest { when(mockUserService.createUser(username, password)).thenThrow(DuplicateKeyException.class); // Invoke - ResponseEntity response = userController.createUser(userMap); + ResponseEntity response = userController.createUser(userMap); // Analyze assertEquals(HttpStatus.CONFLICT, response.getStatusCode()); @@ -172,7 +172,7 @@ public class UserControllerTest { // Invoke - ResponseEntity response = userController.createUser(userMap); + ResponseEntity response = userController.createUser(userMap); // Analyze assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); @@ -189,7 +189,7 @@ public class UserControllerTest { when(mockUserService.updateUser(user, username)).thenReturn(user); // Invoke - ResponseEntity response = userController.updateUser(user, username, key); + ResponseEntity response = userController.updateUser(user, username, key); // Analyze assertEquals(HttpStatus.OK, response.getStatusCode()); @@ -207,7 +207,7 @@ public class UserControllerTest { when(mockUserService.updateUser(user, username)).thenReturn(null); // Invoke - ResponseEntity response = userController.updateUser(user, username, key); + ResponseEntity response = userController.updateUser(user, username, key); // Analyze assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); @@ -223,7 +223,7 @@ public class UserControllerTest { doThrow(new IOException()).when(mockUserService).updateUser(user, username); // Invoke - ResponseEntity response = userController.updateUser(user, username, key); + ResponseEntity response = userController.updateUser(user, username, key); // Analyze assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); @@ -241,7 +241,7 @@ public class UserControllerTest { // Invoke - ResponseEntity response = userController.updateUser(user, username, key); + ResponseEntity response = userController.updateUser(user, username, key); // Analyze assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); @@ -256,7 +256,7 @@ public class UserControllerTest { when(mockUserService.deleteUser(username)).thenReturn(true); // Invoke - ResponseEntity response = userController.deleteUser(username, key); + ResponseEntity response = userController.deleteUser(username, key); // Analyze assertEquals(HttpStatus.OK, response.getStatusCode()); @@ -271,7 +271,7 @@ public class UserControllerTest { when(mockUserService.deleteUser(username)).thenReturn(false); // Invoke - ResponseEntity response = userController.deleteUser(username, key); + ResponseEntity response = userController.deleteUser(username, key); // Analyze assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); @@ -286,7 +286,7 @@ public class UserControllerTest { doThrow(new IOException()).when(mockUserService).deleteUser(username); // Invoke - ResponseEntity response = userController.deleteUser(username, key); + ResponseEntity response = userController.deleteUser(username, key); // Analyze assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); @@ -301,7 +301,7 @@ public class UserControllerTest { doThrow(new IllegalAccessException()).when(mockAuthService).keyHasAccessToUser(username, key); // Invoke - ResponseEntity response = userController.deleteUser(username, key); + ResponseEntity response = userController.deleteUser(username, key); // Analyze assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); -- cgit v1.2.3 From eb09f05ca697a3a6d3587f9278e332056bfd6f66 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 30 Mar 2025 20:48:32 -0400 Subject: Modified controllers to return error text when catching errors. Also added additional error checking to CupboardService for physical needs. --- .../src/main/java/com/ufund/api/ufundapi/service/CupboardService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index 4dcfcad..a86fe28 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -35,6 +35,8 @@ public class CupboardService { if (maxGoal <= 0) { throw new IllegalArgumentException("Max Goal must be greater than zero"); + } else if (goalType.equals(Need.GoalType.PHYSICAL) && maxGoal % 1 != 0) { + throw new IllegalArgumentException("Cannot have non whole number value for physical goal"); } for (Need searchNeed : cupboardDAO.getNeeds()) { @@ -95,6 +97,8 @@ public class CupboardService { } if (need.getMaxGoal() <= 0) { throw new IllegalArgumentException("Goal must be greater than 0"); + } else if (need.getType().equals(Need.GoalType.PHYSICAL) && need.getMaxGoal() % 1 != 0) { + throw new IllegalArgumentException("Cannot have non whole number value for physical goal"); } return cupboardDAO.updateNeed(need); } -- cgit v1.2.3 From aa5610d0f56c2a048212b3bd3a9ca5671ec855fa Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 30 Mar 2025 21:46:54 -0400 Subject: Continue working on css --- .../components/dashboard/dashboard.component.css | 2 +- .../components/need-list/need-list.component.css | 7 +++- .../components/need-list/need-list.component.html | 5 +-- .../components/need-page/need-page.component.css | 10 +++++ .../components/need-page/need-page.component.html | 47 ++++++++++++---------- ufund-ui/src/styles.css | 4 ++ 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.css b/ufund-ui/src/app/components/dashboard/dashboard.component.css index 9db015e..78a69ba 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.css +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.css @@ -1,7 +1,7 @@ :host { display: flex; flex-direction: column; - width: 1200px; + width: 1000px; align-self: center; gap: 20px } diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 5e07856..05354fc 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -75,14 +75,17 @@ li > button:hover p { #search-container { background-color: #d9d9d9; +} + #search-form { background-color: light-dark(#d9d9d9, #1b1b1b); padding: 10px 20px 20px 20px; border: 2px solid #000; border-radius: 5px; + border-radius: 5px; + visibility: visible; + .wide-input { width: 60%; } - border-radius: 5px; - visibility: visible; } diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 866e5e4..72bc9c5 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1,4 +1,3 @@ -

    Needs List

    @@ -43,9 +42,9 @@ -
    - \ No newline at end of file + diff --git a/ufund-ui/src/app/components/need-page/need-page.component.css b/ufund-ui/src/app/components/need-page/need-page.component.css index e69de29..a3a4014 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.css +++ b/ufund-ui/src/app/components/need-page/need-page.component.css @@ -0,0 +1,10 @@ +:host { + display: flex; + justify-content: center; +} + +#box { + display: flex; + flex-direction: column; + width: 1000px; +} diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index 7ce7633..a72167c 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -1,23 +1,26 @@ - -

    Viewing Need: {{need?.name}}

    -internal id: {{need?.id}} -
    -

    Looking for

    -

    {{need?.type}}

    -

    Donations.

    -
    -
    -

    Tags:

    -
      -
    • -

      {{tag}}

      -
    • -
    -
    +
    +

    {{need?.name}}

    +
    +

    Looking for {{need?.type}} Donations.

    +
    +
    +

    Tags:

    +
      +
    • +

      {{tag}}

      +
    • +
    +
    -
    -

    Location: {{need?.location}}

    -

    Goal: {{need?.maxGoal}}

    -

    Current: {{need?.current}}

    -

    Urgent: {{need?.urgent}}

    -

    This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!

    +
    +

    Location: {{need?.location}}

    +

    Urgent: {{need?.urgent}}

    + {{need?.current}} / {{need?.maxGoal}} + + This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete! +
    + + + +
    +
    diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index e4b4e8c..b3ecbd0 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -57,3 +57,7 @@ button, .button { .icon { font-family: 'Material Symbols Outlined' } + +h1 { + font-size: 40px; +} -- cgit v1.2.3 From cfe40fa1e416fbf4586ef36b63a145453a4d6224 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 00:38:37 -0400 Subject: Continue working on css (1) --- ufund-ui/public/delete.png | Bin 6396 -> 0 bytes ufund-ui/public/edit.png | Bin 6649 -> 0 bytes ufund-ui/public/search.png | Bin 12743 -> 0 bytes ufund-ui/src/app/app.component.css | 28 +++++ ufund-ui/src/app/app.component.html | 8 ++ ufund-ui/src/app/app.component.ts | 13 ++- .../app/components/cupboard/cupboard.component.css | 13 +-- .../components/cupboard/cupboard.component.html | 6 +- .../mini-need-list/mini-need-list.component.css | 1 + .../components/need-list/need-list.component.css | 126 ++++++++++----------- .../components/need-list/need-list.component.html | 73 ++++++------ .../components/need-list/need-list.component.ts | 4 +- ufund-ui/src/app/services/toasts.service.ts | 19 ++++ 13 files changed, 179 insertions(+), 112 deletions(-) delete mode 100644 ufund-ui/public/delete.png delete mode 100644 ufund-ui/public/edit.png delete mode 100644 ufund-ui/public/search.png create mode 100644 ufund-ui/src/app/services/toasts.service.ts diff --git a/ufund-ui/public/delete.png b/ufund-ui/public/delete.png deleted file mode 100644 index 6403705..0000000 Binary files a/ufund-ui/public/delete.png and /dev/null differ diff --git a/ufund-ui/public/edit.png b/ufund-ui/public/edit.png deleted file mode 100644 index 3b6e2d8..0000000 Binary files a/ufund-ui/public/edit.png and /dev/null differ diff --git a/ufund-ui/public/search.png b/ufund-ui/public/search.png deleted file mode 100644 index 1940ef5..0000000 Binary files a/ufund-ui/public/search.png and /dev/null differ diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index 5596cf8..5af3958 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -43,3 +43,31 @@ text-decoration: underline; } } + +.toast { + transform: translateY(-90px); + transition: transform .5s; + align-self: center; + z-index: 3; + position: absolute; + top: 15px; + display: flex; + flex-direction: row; + padding: 3px 15px; + background-color: #3a3a3a; + border-radius: 100000px; + gap: 10px; + align-items: center; + + button { + aspect-ratio: 1/1; + margin-right: -11px; + padding: 8px; + display: flex; + align-items: center; + } +} + +.toast.active { + transform: translateY(0); +} diff --git a/ufund-ui/src/app/app.component.html b/ufund-ui/src/app/app.component.html index b0ee329..b41a225 100644 --- a/ufund-ui/src/app/app.component.html +++ b/ufund-ui/src/app/app.component.html @@ -1,3 +1,11 @@ +
    + + + + + +
    + +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index af8cab4..47114c3 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -66,7 +66,7 @@ export class NeedListComponent { selectedNeed: Need | null = null; needs: Need[] = []; searchResults: Need[] = []; - sortMode = 'Ascending' + sortMode: 'Ascending' | 'Descending' = 'Ascending' currentSortAlgo: sortAlgo = sortByPriority; sortSelection: string = 'sortByPriority'; @@ -98,7 +98,7 @@ export class NeedListComponent { }); const form = document.getElementById('search-form') as HTMLFormElement; - form.reset(); + form.reset(); this.search(null); } diff --git a/ufund-ui/src/app/services/toasts.service.ts b/ufund-ui/src/app/services/toasts.service.ts new file mode 100644 index 0000000..0c35e45 --- /dev/null +++ b/ufund-ui/src/app/services/toasts.service.ts @@ -0,0 +1,19 @@ +import {Injectable} from '@angular/core'; + +export enum ToastType { + INFO, + WARNING, + ERROR +} + +@Injectable({ + providedIn: 'root' +}) +export class ToastsService { + + constructor() {} + + sendToast(type: ToastType, message: string, action?: {label: string, onAction: () => void}) { + + } +} -- cgit v1.2.3 From 227360990424abe323c44664b1d58d667b89a92f Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 10:10:41 -0400 Subject: backend support for description --- .../com/ufund/api/ufundapi/controller/CupboardController.java | 5 +++-- .../src/main/java/com/ufund/api/ufundapi/model/Need.java | 11 +++++++++-- .../java/com/ufund/api/ufundapi/service/CupboardService.java | 7 +++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index d426aee..ea86aa8 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -5,7 +5,6 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import com.ufund.api.ufundapi.service.AuthService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -22,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController; import com.ufund.api.ufundapi.DuplicateKeyException; import com.ufund.api.ufundapi.model.Need; import com.ufund.api.ufundapi.model.Need.GoalType; +import com.ufund.api.ufundapi.service.AuthService; import com.ufund.api.ufundapi.service.CupboardService; @RestController @@ -58,11 +58,12 @@ public class CupboardController { String location = (String) params.get("location"); double maxGoal = ((Number) params.get("maxGoal")).doubleValue(); boolean urgent = (Boolean) params.get("urgent"); + String description = (String) params.get("description"); Need.GoalType goalType = GoalType.valueOf((String) params.get("type")); try { authService.keyHasAccessToCupboard(key); - Need need = cupboardService.createNeed(name, location, maxGoal, goalType, urgent); + Need need = cupboardService.createNeed(name, location, maxGoal, goalType, urgent, description); return new ResponseEntity<>(need, HttpStatus.OK); } catch (DuplicateKeyException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java index 55a9441..35e81b3 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java @@ -17,6 +17,7 @@ public class Need { @JsonProperty("maxGoal") private double maxGoal; @JsonProperty("urgent") private boolean urgent; @JsonProperty("current") private double current; + @JsonProperty("description") private String description; /** * Create a new need, used by the controller @@ -27,14 +28,16 @@ public class Need { * @param maxGoal The maximum goal for this need * @param type The type of need (monetary, physical) * @param urgent The urgency of the need + * @param description The description of the need */ - public Need(@JsonProperty("name") String name, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent) { + public Need(@JsonProperty("name") String name, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent, @JsonProperty("Description") String description) { this.id = id; this.location = location; this.name = name; this.maxGoal = maxGoal; this.type = type; this.urgent = urgent; + this.description = description; } /** @@ -45,13 +48,15 @@ public class Need { * @param maxGoal The maximum goal for this need * @param type The type of need (monetary, physical) * @param urgent The urgency of the need + * @param description The description of the need */ - public Need(String name, String location, double maxGoal, GoalType type, boolean urgent) { + public Need(String name, String location, double maxGoal, GoalType type, boolean urgent, String description) { this.name = name; this.location = location; this.type = type; this.maxGoal = maxGoal; this.urgent = urgent; + this.description = description; } /** @@ -68,6 +73,7 @@ public class Need { this.maxGoal = other.maxGoal; this.current = other.current; this.urgent = other.urgent; + this.description = other.description; } public String getName() { @@ -94,6 +100,7 @@ public class Need { return current; } + public void setCurrent(double current) { this.current = current; } diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index 4dcfcad..d216b01 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -25,13 +25,16 @@ public class CupboardService { * Creates a new Need * * @param name The name of the need to create + * @param location The location of the new need * @param maxGoal The max goal of the new need * @param goalType The goal type of the new need + * @param urgent The urgency of the new need + * @param description The description of the new need * @return The need that was created * @throws IOException Thrown if there was any issue saving the data * @throws DuplicateKeyException If there already exists a need with the same name */ - public Need createNeed(String name, String location, double maxGoal, Need.GoalType goalType, boolean urgent) throws IOException, DuplicateKeyException { + public Need createNeed(String name, String location, double maxGoal, Need.GoalType goalType, boolean urgent, String description) throws IOException, DuplicateKeyException { if (maxGoal <= 0) { throw new IllegalArgumentException("Max Goal must be greater than zero"); @@ -43,7 +46,7 @@ public class CupboardService { } } - Need need = new Need(name, location, maxGoal, goalType, urgent); + Need need = new Need(name, location, maxGoal, goalType, urgent, description); return cupboardDAO.addNeed(need); } -- cgit v1.2.3 From bcdf234066ee277b7436428989d5e0dbf58c2f60 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 10:15:40 -0400 Subject: description textarea for forms --- ufund-ui/src/app/components/cupboard/cupboard.component.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 25b88ba..89d8fbe 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -24,6 +24,8 @@

    + +
    @@ -46,7 +48,8 @@
    - + +
    {{statusText | async}} -- cgit v1.2.3 From d4dd348e81d3aef4cc62335f1dad5a02452dfadd Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 10:16:03 -0400 Subject: frontend model support for description --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 6 ++++-- ufund-ui/src/app/models/Need.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 85ffd17..feb39e0 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -91,7 +91,8 @@ export class CupboardComponent implements OnInit { type: GoalType[form.type as keyof typeof GoalType], urgent: form.urgent, filterAttributes: [], - current: 0 + current: 0, + description: form.description }; this.cupboardService.updateNeed(need.id, need) @@ -127,7 +128,8 @@ export class CupboardComponent implements OnInit { type: form.type, urgent: form.urgent ? true : false, filterAttributes: [], - current: 0 + current: 0, + description: form.description }; console.log("need:", need); console.log("form submitted. creating need: ", need); diff --git a/ufund-ui/src/app/models/Need.ts b/ufund-ui/src/app/models/Need.ts index 1451cad..2a2800c 100644 --- a/ufund-ui/src/app/models/Need.ts +++ b/ufund-ui/src/app/models/Need.ts @@ -7,6 +7,7 @@ export interface Need { maxGoal: number; current: number; urgent: boolean; + description: string; } export enum GoalType { -- cgit v1.2.3 From 5f083f775917c15597b3b70a0eb6a0ce2fda7667 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 11:28:42 -0400 Subject: More css tweaks --- ufund-ui/src/app/app.component.html | 4 ++-- ufund-ui/src/app/app.component.ts | 19 ++++++++++++------- .../src/app/components/login/login.component.html | 1 - ufund-ui/src/styles.css | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ufund-ui/src/app/app.component.html b/ufund-ui/src/app/app.component.html index b41a225..89075e1 100644 --- a/ufund-ui/src/app/app.component.html +++ b/ufund-ui/src/app/app.component.html @@ -17,8 +17,8 @@
    Cupboard Basket - - + + diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 7d9afcd..8068659 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -3,6 +3,8 @@ import {BehaviorSubject, Observable} from 'rxjs'; import { DOCUMENT } from '@angular/common'; import {AuthService} from './services/auth.service'; import {ToastType} from './services/toasts.service'; +import {User} from './models/User'; +import {ActivatedRoute, Router} from '@angular/router'; interface ToastProps { type: ToastType, message: string, action?: {label: string, onAction: () => void} @@ -16,12 +18,14 @@ interface ToastProps { }) export class AppComponent implements OnInit { // title = 'ufund-ui'; - currentUser$: BehaviorSubject = new BehaviorSubject("Logged out."); + currentUser?: BehaviorSubject; toast = new BehaviorSubject({type: ToastType.INFO, message: "testToast"}) constructor( private authService: AuthService, + private router: Router, + private route: ActivatedRoute, @Inject(DOCUMENT) private document: Document ) {} @@ -30,14 +34,15 @@ export class AppComponent implements OnInit { } ngOnInit() { - this.authService.getCurrentUserSubject().subscribe(r => { - this.currentUser$?.next(r - ? "Logged in as " + r.username - : "Logged out." - ) - }) + this.currentUser = this.authService.getCurrentUserSubject() } + login() { + this.router.navigate(['/login'], {queryParams: {redir: this.router.url}}); + } + logout() { + location.reload() + } } diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html index 743b1b3..e1c3e2a 100644 --- a/ufund-ui/src/app/components/login/login.component.html +++ b/ufund-ui/src/app/components/login/login.component.html @@ -1,5 +1,4 @@
    - You must be logged in to view this page

    Login

    diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index b3ecbd0..b152e61 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -32,7 +32,7 @@ input { } } -button, .button { +button, input[type=button], input[type=reset], input[type=submit], .button { font-size: 14pt; padding: 6px 16px; border-radius: 9999px; -- cgit v1.2.3 From cb5be32bf0d050cc1fd37d7cc9b4c51e1c51fffe Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 12:08:22 -0400 Subject: Added dynamic error messaging to the cupboard --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 85ffd17..88ab46c 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { Need, GoalType } from '../../models/Need'; import { userType } from '../../models/User'; @@ -99,7 +99,7 @@ export class CupboardComponent implements OnInit { if (ex.status == 500) { this.statusText.next("Fields cannot be blank"); } else if (ex.status == 400) { - this.statusText.next("Goal must be greater than 0"); + this.statusText.next(ex.error); } else { this.statusText.next("Error on creating need"); } @@ -136,7 +136,7 @@ export class CupboardComponent implements OnInit { if (ex.status == 500) { this.statusText.next("Fields cannot be blank"); } else if (ex.status == 400) { - this.statusText.next("Goal must be greater than 0"); + this.statusText.next(ex.error); } else { this.statusText.next("Error on creating need"); } -- cgit v1.2.3 From 655f83af9ba59d6153c9916b9a31bfe12680655e Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 13:12:42 -0400 Subject: Implemented localStorage cookies to maintain user persistence --- ufund-ui/src/app/app.component.ts | 14 ++++++++++++-- ufund-ui/src/app/components/login/login.component.ts | 2 ++ ufund-ui/src/app/services/auth.service.ts | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 8068659..34256f3 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -1,5 +1,5 @@ -import {Component, OnInit, Inject, ViewChild} from '@angular/core'; -import {BehaviorSubject, Observable} from 'rxjs'; +import {Component, OnInit, Inject} from '@angular/core'; +import {BehaviorSubject} from 'rxjs'; import { DOCUMENT } from '@angular/common'; import {AuthService} from './services/auth.service'; import {ToastType} from './services/toasts.service'; @@ -34,7 +34,17 @@ export class AppComponent implements OnInit { } ngOnInit() { + console.log("AAAAAAAAAAAAAAAA") this.currentUser = this.authService.getCurrentUserSubject() + let data = localStorage.getItem("credential"); + if (data) { + let dataParsed = JSON.parse(data) + this.authService.restoreLogin(dataParsed.username, dataParsed.key) + console.log("Key found", dataParsed.key) + } else { + console.log("key missing") + console.log(data) + } } login() { diff --git a/ufund-ui/src/app/components/login/login.component.ts b/ufund-ui/src/app/components/login/login.component.ts index f6a2996..4dcaedd 100644 --- a/ufund-ui/src/app/components/login/login.component.ts +++ b/ufund-ui/src/app/components/login/login.component.ts @@ -35,6 +35,8 @@ export class LoginComponent implements OnInit { this.authService.login(username, password).then(() => { this.router.navigate([next]); + let key = this.authService.getApiKey() + localStorage.setItem("credential", JSON.stringify({username: username, key: key})) }).catch(ex => { this.statusText.next("Unable to login: " + friendlyHttpStatus[ex.status]) console.log(ex) diff --git a/ufund-ui/src/app/services/auth.service.ts b/ufund-ui/src/app/services/auth.service.ts index 6bc7145..b75c931 100644 --- a/ufund-ui/src/app/services/auth.service.ts +++ b/ufund-ui/src/app/services/auth.service.ts @@ -1,7 +1,8 @@ -import {Injectable} from '@angular/core'; +import {Injectable, Injector} from '@angular/core'; import {BehaviorSubject, firstValueFrom} from 'rxjs'; import {User} from '../models/User'; import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {UsersService} from './users.service'; @Injectable({ providedIn: 'root' @@ -24,7 +25,9 @@ export class AuthService { }); constructor( - private http: HttpClient + private http: HttpClient, + // private userService: UsersService + private injector: Injector ) {} async login(username: string, password: string) { @@ -42,6 +45,13 @@ export class AuthService { // this.currentUser.subscribe(r => console.log("currentUser: "+r.username)) } + async restoreLogin(username: string, key: string) { + + const userService = this.injector.get(UsersService); + this.apiKey = key; + this.currentUser.next(await firstValueFrom(userService.getUser(username))) + } + getCurrentUserSubject() { return this.currentUser; } -- cgit v1.2.3 From 07a9e3c6faf735b374c6b63235defeb8a38a6661 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 13:27:02 -0400 Subject: Implemented logout functionality with localStorage --- ufund-ui/src/app/app.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 34256f3..94a6439 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -52,6 +52,7 @@ export class AppComponent implements OnInit { } logout() { + localStorage.removeItem("credential") location.reload() } -- cgit v1.2.3 From ec88317c75ec907c319412502a1b189c97db9173 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 14:36:39 -0400 Subject: Modified need list to display percent as a whole number --- ufund-ui/src/app/components/need-list/need-list.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 3a4ca9c..e24ee09 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -41,7 +41,7 @@
    - {{need.current}}/{{need.maxGoal}} ({{(need.current / need.maxGoal) * 100}}%) + {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%)
    -- cgit v1.2.3 From 2031579ce6033fbe67a78b66d3da2ee6872748de Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 15:08:59 -0400 Subject: Removed old logging --- ufund-ui/src/app/app.component.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 94a6439..df9114e 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -34,16 +34,12 @@ export class AppComponent implements OnInit { } ngOnInit() { - console.log("AAAAAAAAAAAAAAAA") this.currentUser = this.authService.getCurrentUserSubject() let data = localStorage.getItem("credential"); if (data) { let dataParsed = JSON.parse(data) this.authService.restoreLogin(dataParsed.username, dataParsed.key) console.log("Key found", dataParsed.key) - } else { - console.log("key missing") - console.log(data) } } -- cgit v1.2.3 From 9f31fea81818dae21f67b23a6004a3ca369f8e0d Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 15:09:23 -0400 Subject: Added check to prevent redirect to login page --- ufund-ui/src/app/components/dashboard/dashboard.component.ts | 4 ++-- .../src/app/components/funding-basket/funding-basket.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 165c7ba..49d93bf 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -27,7 +27,7 @@ export class DashboardComponent implements OnInit{ ngOnInit() { let user = this.authService.getCurrentUser() - if(!user) { + if(!localStorage.getItem("credential") && !user) { this.router.navigate(['/login']) return } @@ -35,7 +35,7 @@ export class DashboardComponent implements OnInit{ firstValueFrom(this.cupboardService.getNeeds()).then(r => { this.topNeeds = r.sort((a, b) => b.current - a.current) this.almostThere = r.sort((a, b) => a.current/a.maxGoal - b.current/b.maxGoal) - this.inBasket = r.filter(n => n.id in user?.basket) + this.inBasket = r.filter(n => n.id in user!.basket) }) } diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index faa7e0b..5c5776f 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -26,7 +26,7 @@ export class FundingBasketComponent implements OnInit { // this is for login rerouting ngOnInit(): void { - if (!this.authService.getCurrentUser()) { + if (!localStorage.getItem("credential") && !this.authService.getCurrentUser()) { this.router.navigate(['/login'], {queryParams: {redir: this.router.url}}); return; } -- cgit v1.2.3 From d07e7630c836711b92cffd41fe99d15c84cb025f Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 15:09:41 -0400 Subject: Added animation to header tabs when hovering over them --- ufund-ui/src/app/app.component.css | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index 5af3958..5204919 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -38,10 +38,31 @@ text-decoration: none; } - a:hover { - /*color: light-dark(black, white)*/ - text-decoration: underline; + a { + display: block; + position: relative; + padding: 0.1em 0; + } + + a::after { + content: ''; + position: absolute; + bottom: 4px; + left: 0; + width: 100%; + height: 0.03em; + background-color: white; + opacity: 0; + transition: opacity 300ms, transform 300ms; } + + a:hover::after, + a:focus::after { + opacity: 1; + transform: translate3d(0, 0.2em, 0); + } + + } .toast { -- cgit v1.2.3 From b07405c2a1817271c84e25bfe62b6b3ff36136f9 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 15:10:52 -0400 Subject: Unused imports --- ufund-ui/src/app/components/dashboard/dashboard.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 49d93bf..645893f 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -1,10 +1,8 @@ import {Component, OnInit} from '@angular/core'; -import {userType} from '../../models/User'; import {AuthService} from '../../services/auth.service'; import {Router} from '@angular/router'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; -import {UsersService} from '../../services/users.service'; import {firstValueFrom} from 'rxjs'; @Component({ -- cgit v1.2.3 From da47933078796ea1b7b7b20468d2c2fe19b2e74f Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 17:27:57 -0400 Subject: Added bat file --- start.bat | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 start.bat diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..a19b267 --- /dev/null +++ b/start.bat @@ -0,0 +1,9 @@ +@echo off + +cd ufund-api + +start cmd /k "mvn compile exec:java" + +cd ../ufund-ui + +start cmd /k "ng serve -o" \ No newline at end of file -- cgit v1.2.3 From f7a0ce90b0ead17ad4002108d7e868899954c69d Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 17:28:20 -0400 Subject: Removed login check for now --- .../app/components/funding-basket/funding-basket.component.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index 5c5776f..08515c2 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -26,7 +26,7 @@ export class FundingBasketComponent implements OnInit { // this is for login rerouting ngOnInit(): void { - if (!localStorage.getItem("credential") && !this.authService.getCurrentUser()) { + if (!this.authService.getCurrentUser()) { this.router.navigate(['/login'], {queryParams: {redir: this.router.url}}); return; } @@ -45,6 +45,15 @@ export class FundingBasketComponent implements OnInit { contribution.setAttribute("style", "color: #ff0000"); } } + // if (this.usersService.getBasket().value != await firstValueFrom(this.usersService.getUser(1)) + // for (let c of this.usersService.getBasket().value) { + // if (c == null) { + // this.isValid = false; + // this.statusText.next("One or more needs have been deleted") + // } else { + // this.statusText.next("test") + // } + // } if (this.isValid) { for (let c of document.getElementById("funding-basket")?.querySelectorAll('.contribution')!) { let contribution = c as HTMLInputElement; -- cgit v1.2.3 From 97c9e1e0bb73c7b08c830c47548ac1c4b5bebd0b Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 17:33:04 -0400 Subject: TOASTS --- ufund-ui/src/app/app.component.css | 28 ----------- ufund-ui/src/app/app.component.html | 8 --- ufund-ui/src/app/app.component.ts | 14 ++---- ufund-ui/src/app/app.module.ts | 2 + .../src/app/components/toast/toast.component.css | 57 ++++++++++++++++++++++ .../src/app/components/toast/toast.component.html | 7 +++ .../src/app/components/toast/toast.component.ts | 37 ++++++++++++++ ufund-ui/src/app/services/toasts.service.ts | 12 ++++- 8 files changed, 118 insertions(+), 47 deletions(-) create mode 100644 ufund-ui/src/app/components/toast/toast.component.css create mode 100644 ufund-ui/src/app/components/toast/toast.component.html create mode 100644 ufund-ui/src/app/components/toast/toast.component.ts diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index 5204919..0bcd658 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -64,31 +64,3 @@ } - -.toast { - transform: translateY(-90px); - transition: transform .5s; - align-self: center; - z-index: 3; - position: absolute; - top: 15px; - display: flex; - flex-direction: row; - padding: 3px 15px; - background-color: #3a3a3a; - border-radius: 100000px; - gap: 10px; - align-items: center; - - button { - aspect-ratio: 1/1; - margin-right: -11px; - padding: 8px; - display: flex; - align-items: center; - } -} - -.toast.active { - transform: translateY(0); -} diff --git a/ufund-ui/src/app/app.component.html b/ufund-ui/src/app/app.component.html index 89075e1..959eada 100644 --- a/ufund-ui/src/app/app.component.html +++ b/ufund-ui/src/app/app.component.html @@ -1,11 +1,3 @@ -
    - - - - - -
    - - +
    {{need.current}}/{{need.maxGoal}} ({{(need.current / need.maxGoal) * 100}}%)
    - +
    + {{need.description}} +
    + +

    Update Need

    @@ -53,9 +51,8 @@

    - + - {{statusText | async}}

    diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html index e1c3e2a..c67b903 100644 --- a/ufund-ui/src/app/components/login/login.component.html +++ b/ufund-ui/src/app/components/login/login.component.html @@ -6,5 +6,4 @@ - {{statusText | async}} -- cgit v1.2.3 From 9c9708cc846dafe33234c38c37425468b9877514 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 21:32:55 -0400 Subject: Updated toast's types --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 12 ++++++------ .../components/funding-basket/funding-basket.component.ts | 6 +++++- ufund-ui/src/app/components/signup/signup.component.ts | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index fff8760..662def4 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -100,11 +100,11 @@ export class CupboardComponent implements OnInit { this.cupboardService.updateNeed(need.id, need) .pipe(catchError((ex, _) => { if (ex.status == 500) { - this.toastService.sendToast(ToastType.INFO, 'Fields cannot be blank'); + this.toastService.sendToast(ToastType.ERROR, 'Fields cannot be blank'); } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.INFO, ex.error); + this.toastService.sendToast(ToastType.ERROR, ex.error); } else { - this.toastService.sendToast(ToastType.INFO, "Error on creating need"); + this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); } return of() })) @@ -139,11 +139,11 @@ export class CupboardComponent implements OnInit { this.cupboardService.createNeed(need) .pipe(catchError((ex, _) => { if (ex.status == 500) { - this.toastService.sendToast(ToastType.INFO, "Fields cannot be blank"); + this.toastService.sendToast(ToastType.ERROR, "Fields cannot be blank"); } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.INFO, ex.error); + this.toastService.sendToast(ToastType.ERROR, ex.error); } else { - this.toastService.sendToast(ToastType.INFO, "Error on creating need"); + this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); } return of() })) diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index 24e2c0b..54ae720 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -46,7 +46,11 @@ export class FundingBasketComponent implements OnInit { this.isValid = false; contribution.setAttribute("style", "color: #ff0000"); - this.toastService.sendToast(ToastType.WARNING, "Invalid input in funding basket!") + this.toastService.sendToast(ToastType.ERROR, "Invalid input in funding basket!") + + setTimeout(() => { + contribution.setAttribute("style", "color: #ffffff"); + }, 3000); } } // if (this.usersService.getBasket().value != await firstValueFrom(this.usersService.getUser(1)) diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts index 5ec84ae..a20d828 100644 --- a/ufund-ui/src/app/components/signup/signup.component.ts +++ b/ufund-ui/src/app/components/signup/signup.component.ts @@ -47,7 +47,7 @@ export class SignupComponent { this.usersService.createUser(username, password).then(() => { this.showSuccessMessage.next(true); }).catch(ex => { - this.toastService.sendToast(ToastType.INFO, "Unable to create account: " + friendlyHttpStatus[ex.status]) + this.toastService.sendToast(ToastType.ERROR, "Unable to create account: " + friendlyHttpStatus[ex.status]) console.log(ex) }) } -- cgit v1.2.3 From 827831df4452449f11799c5e7daa2c6d1dd2ea90 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 21:35:26 -0400 Subject: Updated README --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2ab375e..42f5a07 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,7 @@ An online U-Fund system built in Java **21** and __Angular 19__ 2. Execute `mvn compile exec:java` 3. CD into the ufund-ui directory in a new terminal 4. Execute `ng serve -o` -3. Open in your browser `http://localhost:8080/` -4. _add any other steps required or examples of how to use/run_ +3. Open in your browser `http://localhost:4200/` ## Known bugs and disclaimers (It may be the case that your implementation is not perfect.) @@ -41,8 +40,9 @@ reports in HTML. To run tests on all tiers together do this: -1. Execute `mvn clean test jacoco:report` -2. Open in your browser the file at `PROJECT_API_HOME/target/site/jacoco/index.html` +1. CD into ufund/api +2. Execute `mvn clean test jacoco:report` +3. Open in your browser the file at `PROJECT_API_HOME/target/site/jacoco/index.html` To run tests on a single tier do this: @@ -68,10 +68,7 @@ To run tests on all the tiers in isolation do this: ## How to setup/run/test program 1. Tester, first obtain the Acceptance Test plan -2. IP address of target machine running the app -3. Execute ________ -4. ... -5. ... +2. Run the batch file ## License -- cgit v1.2.3 From aef3df6f9eacfe37479046826a9ca14310b72456 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 21:54:38 -0400 Subject: Apply css to funding basket --- .../funding-basket/funding-basket.component.css | 85 +++++++++++++++- .../funding-basket/funding-basket.component.html | 112 ++++++++++++++------- .../funding-basket/funding-basket.component.ts | 6 +- .../components/need-list/need-list.component.css | 21 +++- .../components/need-list/need-list.component.html | 23 +++-- .../components/need-list/need-list.component.ts | 13 +-- ufund-ui/src/styles.css | 4 + 7 files changed, 202 insertions(+), 62 deletions(-) diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css index 3dec496..a17f710 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css @@ -1,7 +1,82 @@ -td, p { - border: 2px solid #000; +:host { + display: flex; + justify-content: center; +} + +#box { + display: flex; + width: 1000px; + flex-direction: column; + gap: 10px; +} + +.needEntry { + background-color: #2e2e2e; + display: flex; + flex-direction: column; border-radius: 5px; - padding: 5px; - margin: 5px; +} + +#needList { + display: flex; + flex-direction: column; + gap: 10px; + max-width: 1000px; +} + +.needName { + font-weight: bold; +} + +.needType { + text-transform: uppercase; + font-size: 10pt; +} + +.split { + display: flex; + flex-direction: row; + justify-content: space-between; + + + .left { + display: flex; + flex-direction: column; + } -} \ No newline at end of file + .right { + display: flex; + flex-direction: column; + align-items: end; + } +} + +.urgent { + font-size: 11pt; + background-color: rgba(255, 165, 0, 0.27); + color: rgba(255, 165, 0, 1); + padding: 2px; + border-radius: 5px; +} + +.prog { + display: flex; + flex-direction: column; +} + +.clickable { + padding: 10px; + background-color: #3a3a3a; + border-radius: 5px; + cursor: pointer; +} + +.clickable:hover { + background-color: #444444; +} + +.actionArea { + display: flex; + padding: 5px; + gap: 5px; +} diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.html b/ufund-ui/src/app/components/funding-basket/funding-basket.component.html index 504e694..52b35c1 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.html +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.html @@ -1,39 +1,81 @@ -

    Funding Basket

    -
    - - {{ this.usersService.getBasket().getValue().length }} -
    + + + + -
    -

    There are no needs in the basket

    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Funding Basket

    + +
    +
    +
    +
    +
    + {{need.name}} + {{need.type}} +
    + +
    + URGENT + location_on{{need.location}} +
    +
    + +
    - - - - - - - - - - - -
    - {{need.name}} -

    Goal: {{need.maxGoal}}

    -

    Current: {{(need.current).toFixed(2)}}

    -

    How much to Contribute:

    -
    -
    - +
    + + {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%) + +
    + + + + +
    + +
    + +
    -
    -
    -
    -

    Invalid input in funding basket!

    - - {{statusText | async}} -
    \ No newline at end of file +
    +
    +
    + + +
    + There are no needs in your basket! Browse the cupboard +
    +
    diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index 24e2c0b..646ef35 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -39,7 +39,7 @@ export class FundingBasketComponent implements OnInit { async checkout() { this.isValid = true; - for (let c of document.getElementById("funding-basket")?.querySelectorAll('.contribution')!) { + for (let c of document.querySelectorAll('.contribution')!) { let contribution = c as HTMLInputElement; contribution.setAttribute("style", ""); if (contribution.value == '' || contribution.valueAsNumber <= 0) { @@ -59,7 +59,7 @@ export class FundingBasketComponent implements OnInit { // } // } if (this.isValid) { - for (let c of document.getElementById("funding-basket")?.querySelectorAll('.contribution')!) { + for (let c of document.querySelectorAll('.contribution')!) { let contribution = c as HTMLInputElement; let need = await firstValueFrom(this.cupboardService.getNeed(+contribution.id)); need.current += +contribution.value; @@ -77,11 +77,11 @@ export class FundingBasketComponent implements OnInit { })) .subscribe((result) => { if (result) { - console.log('need updated successfully'); //this.needList?.refresh() } else { console.log('need update failed'); } + this.toastService.sendToast(ToastType.INFO, "Checkout successful"); }); } } diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 1936b38..d4be5fa 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -5,11 +5,10 @@ } .needEntry { - background-color: #3a3a3a; + background-color: #2e2e2e; display: flex; flex-direction: column; border-radius: 5px; - padding: 10px; } #needList { @@ -59,6 +58,7 @@ select { flex-direction: row; justify-content: space-between; + .left { display: flex; flex-direction: column; @@ -83,3 +83,20 @@ select { display: flex; flex-direction: column; } + +.clickable { + padding: 10px; + background-color: #3a3a3a; + border-radius: 5px; + cursor: pointer; +} + +.clickable:hover { + background-color: #444444; +} + +.actionArea { + display: flex; + padding: 5px; + gap: 5px; +} diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index c325320..84f83d6 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -26,37 +26,38 @@
    -
    +
    {{need.name}} {{need.type}}
    - +
    URGENT location_on{{need.location}}
    - + +
    +
    {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%)
    -
    - {{need.description}} -
    - -
    - + +
    +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 47114c3..7a9d647 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -1,11 +1,11 @@ -import {Component , Output, EventEmitter} from '@angular/core'; -import { NgForm } from '@angular/forms'; +import {Component, EventEmitter, Output} from '@angular/core'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; -import { UsersService } from '../../services/users.service'; -import { userType } from '../../models/User'; +import {UsersService} from '../../services/users.service'; +import {userType} from '../../models/User'; import {AuthService} from '../../services/auth.service'; import {catchError, of} from 'rxjs'; +import {ToastsService, ToastType} from '../../services/toasts.service'; interface sortAlgo { (a: Need,b: Need): number; @@ -84,7 +84,8 @@ export class NeedListComponent { constructor( private cupboardService: CupboardService, private usersService: UsersService, - private authService: AuthService + private authService: AuthService, + private toastService: ToastsService ) {} refresh() { @@ -196,7 +197,7 @@ export class NeedListComponent { this.usersService.refreshBasket(); }); } else { - window.alert("This need is already in your basket!") + this.toastService.sendToast(ToastType.ERROR, "This need is already in your basket!") } diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index b152e61..f515154 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -38,6 +38,10 @@ button, input[type=button], input[type=reset], input[type=submit], .button { border-radius: 9999px; border-style: none; background-color: light-dark(#ebebeb, #3a3a3a); + display: flex; + gap: 5px; + text-align: center; + justify-content: center; &:hover { background-color: light-dark(#e1e1e1, #444444); -- cgit v1.2.3 From 4f8ddd385924b3c7c2b36acd28daf658ecc2cb09 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 21:57:32 -0400 Subject: Tweak validation in funding basket --- .../src/app/components/funding-basket/funding-basket.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index b3826be..ecf452a 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -45,11 +45,11 @@ export class FundingBasketComponent implements OnInit { if (contribution.value == '' || contribution.valueAsNumber <= 0) { this.isValid = false; - contribution.setAttribute("style", "color: #ff0000"); + contribution.setAttribute("style", "border-color: #ff0000"); this.toastService.sendToast(ToastType.ERROR, "Invalid input in funding basket!") setTimeout(() => { - contribution.setAttribute("style", "color: #ffffff"); + contribution.setAttribute("style", "border-color: #ffffff"); }, 3000); } } -- cgit v1.2.3 From 786a6db3f5a22f7bb2cc249731ef654b675c3c86 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 22:15:37 -0400 Subject: moving functionality to new component --- ufund-ui/src/app/app.module.ts | 2 + .../components/cupboard/cupboard.component.html | 23 -------- .../app/components/cupboard/cupboard.component.ts | 39 -------------- .../components/need-edit/need-edit.component.css | 0 .../components/need-edit/need-edit.component.html | 22 ++++++++ .../components/need-edit/need-edit.component.ts | 61 ++++++++++++++++++++++ 6 files changed, 85 insertions(+), 62 deletions(-) create mode 100644 ufund-ui/src/app/components/need-edit/need-edit.component.css create mode 100644 ufund-ui/src/app/components/need-edit/need-edit.component.html create mode 100644 ufund-ui/src/app/components/need-edit/need-edit.component.ts diff --git a/ufund-ui/src/app/app.module.ts b/ufund-ui/src/app/app.module.ts index c91256e..16455be 100644 --- a/ufund-ui/src/app/app.module.ts +++ b/ufund-ui/src/app/app.module.ts @@ -17,6 +17,7 @@ import {LoginComponent} from './components/login/login.component'; import { MiniNeedListComponent } from './components/mini-need-list/mini-need-list.component'; import { SignupComponent } from './components/signup/signup.component'; import { ToastComponent } from './components/toast/toast.component'; +import { NeedEditComponent } from './components/need-edit/need-edit.component'; @NgModule({ declarations: [ @@ -31,6 +32,7 @@ import { ToastComponent } from './components/toast/toast.component'; SignupComponent, MiniNeedListComponent, ToastComponent, + NeedEditComponent, ], imports: [ BrowserModule, diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 6f7799e..e9387a2 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -32,29 +32,6 @@
    -
    -

    Update Need

    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - -
    - -
    -
    -
    - - -
    - -

    diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 662def4..e70d98f 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -82,45 +82,6 @@ export class CupboardComponent implements OnInit { return type === ("MANAGER" as unknown as userType); } - update(form: any) { - console.log(form); - const need: Need = { - name: form.name, - image: form.image, - location: form.location, - id: this.selectedNeed.id, //system will control this - maxGoal: form.maxGoal, - type: GoalType[form.type as keyof typeof GoalType], - urgent: form.urgent, - filterAttributes: [], - current: 0, - description: form.description - }; - - this.cupboardService.updateNeed(need.id, need) - .pipe(catchError((ex, _) => { - if (ex.status == 500) { - this.toastService.sendToast(ToastType.ERROR, 'Fields cannot be blank'); - } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.ERROR, ex.error); - } else { - this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); - } - return of() - })) - .subscribe( - (result) => { - if (result) { - console.log("need updated successfully"); - this.needList?.refresh() - } else { - console.log("need update failed"); - } - } - - ); - } - submit(form: any) { const need: Need = { name: form.name, diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.css b/ufund-ui/src/app/components/need-edit/need-edit.component.css new file mode 100644 index 0000000..e69de29 diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.html b/ufund-ui/src/app/components/need-edit/need-edit.component.html new file mode 100644 index 0000000..bcb166b --- /dev/null +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.html @@ -0,0 +1,22 @@ +
    +

    Update Need

    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + +
    + +
    +
    +
    + + +
    +
    \ No newline at end of file diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.ts b/ufund-ui/src/app/components/need-edit/need-edit.component.ts new file mode 100644 index 0000000..02ffb71 --- /dev/null +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.ts @@ -0,0 +1,61 @@ +import { Component, Input, Output } from '@angular/core'; +import { Need, GoalType } from '../../models/Need'; +import { CupboardService } from '../../services/cupboard.service'; +import { catchError, of } from 'rxjs'; +import { ToastsService, ToastType } from '../../services/toasts.service'; + +@Component({ + selector: 'app-need-edit', + standalone: false, + templateUrl: './need-edit.component.html', + styleUrl: './need-edit.component.css' +}) +export class NeedEditComponent { + constructor( + private cupboardService: CupboardService, + private toastService: ToastsService + + ) {} + + @Input() selectedNeed!: Need; + @Output() selectedNeedID: number | null = null; + + update(form: any) { + console.log(form); + const need: Need = { + name: form.name, + image: form.image, + location: form.location, + id: this.selectedNeed.id, //system will control this + maxGoal: form.maxGoal, + type: GoalType[form.type as keyof typeof GoalType], + urgent: form.urgent, + filterAttributes: [], + current: 0, + description: form.description + }; + + this.cupboardService.updateNeed(need.id, need) + .pipe(catchError((ex, _) => { + if (ex.status == 500) { + this.toastService.sendToast(ToastType.ERROR, 'Fields cannot be blank'); + } else if (ex.status == 400) { + this.toastService.sendToast(ToastType.ERROR, ex.error); + } else { + this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); + } + return of() + })) + .subscribe( + (result) => { + if (result) { + console.log("need updated successfully"); + // this.needList?.refresh() + } else { + console.log("need update failed"); + } + } + + ); + } +} \ No newline at end of file -- cgit v1.2.3 From 4186983da13740ec0a4731770ac238922631be11 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 22:52:49 -0400 Subject: auto refresh with emitter --- ufund-ui/src/app/components/cupboard/cupboard.component.html | 1 + ufund-ui/src/app/components/need-edit/need-edit.component.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index e9387a2..2cfbe2d 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -8,6 +8,7 @@
    +

    Create Need

    diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.ts b/ufund-ui/src/app/components/need-edit/need-edit.component.ts index 02ffb71..2462534 100644 --- a/ufund-ui/src/app/components/need-edit/need-edit.component.ts +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, Output } from '@angular/core'; +import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Need, GoalType } from '../../models/Need'; import { CupboardService } from '../../services/cupboard.service'; import { catchError, of } from 'rxjs'; @@ -18,7 +18,7 @@ export class NeedEditComponent { ) {} @Input() selectedNeed!: Need; - @Output() selectedNeedID: number | null = null; + @Output() refreshNeedList = new EventEmitter(); update(form: any) { console.log(form); @@ -50,7 +50,7 @@ export class NeedEditComponent { (result) => { if (result) { console.log("need updated successfully"); - // this.needList?.refresh() + this.refreshNeedList.emit(); } else { console.log("need update failed"); } -- cgit v1.2.3 From 896e1219526a19400c7143b274193f8b818d6156 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 23:37:00 -0400 Subject: Commit half working changes to move to my laptop --- .../funding-basket/funding-basket.component.ts | 1 - .../components/need-list/need-list.component.html | 4 +- .../components/need-list/need-list.component.ts | 4 +- .../components/need-page/need-page.component.css | 57 ++++++++++++++++++++ .../components/need-page/need-page.component.html | 41 ++++++++++++-- .../components/need-page/need-page.component.ts | 62 ++++++++++++++++++++-- ufund-ui/src/styles.css | 6 ++- 7 files changed, 161 insertions(+), 14 deletions(-) diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index ecf452a..dcacca1 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -13,7 +13,6 @@ import {ToastsService, ToastType} from '../../services/toasts.service'; styleUrl: './funding-basket.component.css' }) export class FundingBasketComponent implements OnInit { - statusText: any; constructor( private router: Router, diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 84f83d6..e00ba47 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -54,10 +54,10 @@ addAdd To Basket
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 7a9d647..d641acf 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -160,6 +160,7 @@ export class NeedListComponent { delete(id : number) { this.cupboardService.deleteNeed(id).subscribe(() => { + this.toastService.sendToast(ToastType.INFO, "Need deleted.") this.needs = this.needs.filter(n => n.id !== id) }) this.refresh(); @@ -199,10 +200,7 @@ export class NeedListComponent { } else { this.toastService.sendToast(ToastType.ERROR, "This need is already in your basket!") } - - } - } back() { diff --git a/ufund-ui/src/app/components/need-page/need-page.component.css b/ufund-ui/src/app/components/need-page/need-page.component.css index a3a4014..f950171 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.css +++ b/ufund-ui/src/app/components/need-page/need-page.component.css @@ -8,3 +8,60 @@ flex-direction: column; width: 1000px; } + +.needName { + font-weight: bold; +} + +.needType { + text-transform: uppercase; + font-size: 10pt; +} + +.split { + display: flex; + flex-direction: row; + justify-content: space-between; + + + .left { + display: flex; + flex-direction: column; + } + + .right { + display: flex; + flex-direction: column; + align-items: end; + } +} + +.urgent { + font-size: 11pt; + background-color: rgba(255, 165, 0, 0.27); + color: rgba(255, 165, 0, 1); + padding: 2px; + border-radius: 5px; +} + +.prog { + display: flex; + flex-direction: column; +} + +.actionArea { + display: flex; + padding: 5px; + gap: 5px; +} + +#editor { + position: absolute; + background-color: #4a4a4a; + display: flex; + flex-direction: column; + justify-self: center; + align-self: center; + padding: 20px; + box-shadow: 0 0 100px black; +} diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index a72167c..a8479fd 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -13,14 +13,47 @@
    + {{need?.description}} + Need image

    Location: {{need?.location}}

    Urgent: {{need?.urgent}}

    {{need?.current}} / {{need?.maxGoal}} This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete! -
    - - - +
    + + + +
    + +
    +
    +
    + {{need.name}} + {{need.type}} +
    + +
    + URGENT + location_on{{need.location}} +
    +
    + +
    + +
    + + {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%) + +
    +
    + +
    diff --git a/ufund-ui/src/app/components/need-page/need-page.component.ts b/ufund-ui/src/app/components/need-page/need-page.component.ts index e38554c..ad4cacf 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.ts +++ b/ufund-ui/src/app/components/need-page/need-page.component.ts @@ -1,8 +1,12 @@ import {Component, Input} from '@angular/core'; import {GoalType, Need} from '../../models/Need'; -import {ActivatedRoute} from "@angular/router"; +import {ActivatedRoute, Router} from "@angular/router"; import {CupboardService} from "../../services/cupboard.service"; -import {NgFor} from '@angular/common'; +import {userType} from '../../models/User'; +import {AuthService} from '../../services/auth.service'; +import {catchError, of} from 'rxjs'; +import {ToastsService, ToastType} from '../../services/toasts.service'; +import {UsersService} from '../../services/users.service'; @Component({ selector: 'app-need-page', @@ -14,11 +18,15 @@ export class NeedPageComponent { constructor( private route: ActivatedRoute, private cupboardService: CupboardService, + private authService: AuthService, + private usersService: UsersService, + private toastService: ToastsService, + private router: Router ) {} public GoalType = GoalType; - @Input() need?: Need; + @Input() need!: Need; ngOnInit(): void { const id = Number(this.route.snapshot.paramMap.get('id')); @@ -28,4 +36,52 @@ export class NeedPageComponent { back() { window.history.back(); } + + isManager() { + const type = this.authService.getCurrentUser()?.type; + return type === ("MANAGER" as unknown as userType); + } + + isHelper() { + const type = this.authService.getCurrentUser()?.type; + return type === ("HELPER" as unknown as userType); + } + + add(need: Need) { + const currentUser = this.authService.getCurrentUser(); + //console.log("get current user in angular:", currentUser) + if (currentUser) { + if (!currentUser.basket.includes(need.id)) { + currentUser.basket.push(need.id); + this.usersService.updateUser(currentUser) + .pipe(catchError((err, _) => { + console.error(err); + return of(); + })) + .subscribe(() => { + this.usersService.refreshBasket(); + }); + } else { + this.toastService.sendToast(ToastType.ERROR, "This need is already in your basket!") + } + } + } + + delete(id : number) { + this.cupboardService.deleteNeed(id) + .pipe(catchError((ex, r) => { + this.toastService.sendToast(ToastType.ERROR, ex.error) + return of() + })) + .subscribe(() => { + // this.needs = this.needs.filter(n => n.id !== id) + this.toastService.sendToast(ToastType.INFO, "Need deleted") + this.router.navigate(['/']) + }) + // this.refresh(); + } + + edit(need: Need) { + + } } diff --git a/ufund-ui/src/styles.css b/ufund-ui/src/styles.css index f515154..75d6b36 100644 --- a/ufund-ui/src/styles.css +++ b/ufund-ui/src/styles.css @@ -1,7 +1,7 @@ /* You can add global styles to this file, and also import other style files */ :root { - color-scheme: light dark; + color-scheme: /*light*/ dark; } * { @@ -65,3 +65,7 @@ button, input[type=button], input[type=reset], input[type=submit], .button { h1 { font-size: 40px; } + +progress { + min-width: 100%; +} -- cgit v1.2.3 From bb2e7b50e1ca96120fc42eed1f090cf0e1c98258 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 23:47:36 -0400 Subject: needs per page --- .../components/need-list/need-list.component.html | 9 +++++- .../components/need-list/need-list.component.ts | 34 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 84f83d6..d43e07b 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -24,8 +24,15 @@

    All Needs

    No Results Found

    +
    + Page {{currentPage + 1}} of {{totalPages}}
    + + + + +
    -
    +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 7a9d647..bc3de42 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -66,7 +66,36 @@ export class NeedListComponent { selectedNeed: Need | null = null; needs: Need[] = []; searchResults: Need[] = []; + visibleNeeds: Need[] = []; sortMode: 'Ascending' | 'Descending' = 'Ascending' + currentPage: number = 0; + itemsPerPage: number = 5; + totalPages: number = Math.ceil(this.needs.length / this.itemsPerPage); + + decrementPage() { + this.currentPage--; + this.updateVisibleNeeds(); + } + + incrementPage() { + this.currentPage++; + this.updateVisibleNeeds(); + } + + editNeedsPerPage(amount: number) { + this.itemsPerPage = amount; + this.updateVisibleNeeds(); + } + + updateVisibleNeeds() { + this.totalPages = Math.ceil(this.searchResults.length / this.itemsPerPage); + this.visibleNeeds = this.searchResults.slice(this.currentPage * this.itemsPerPage, (this.currentPage + 1) * this.itemsPerPage); + } + + resetVisibleNeeds() { + this.currentPage = 0; + this.updateVisibleNeeds(); + } currentSortAlgo: sortAlgo = sortByPriority; sortSelection: string = 'sortByPriority'; @@ -96,6 +125,7 @@ export class NeedListComponent { this.needs = n.sort(this.currentSortAlgo).reverse(); } this.searchResults = this.needs; + this.updateVisibleNeeds(); }); const form = document.getElementById('search-form') as HTMLFormElement; @@ -105,6 +135,7 @@ export class NeedListComponent { ngOnInit(): void { this.refresh() + } changeSortMode(form : any) { @@ -145,8 +176,7 @@ export class NeedListComponent { } else { this.searchResults = n.sort(this.currentSortAlgo).reverse(); } - - console.log(currentSearchValue, this.searchResults); + this.updateVisibleNeeds(); }); } }, 250); -- cgit v1.2.3 From 61daadccf89b2b84820386558ac454c0123d4299 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 1 Apr 2025 01:16:49 -0400 Subject: More css cleanup --- ufund-ui/src/app/app.component.css | 44 ++++++++-------- .../app/components/cupboard/cupboard.component.css | 4 +- .../funding-basket/funding-basket.component.css | 2 +- .../components/home-page/home-page.component.css | 1 + .../components/need-list/need-list.component.css | 8 +++ .../components/need-list/need-list.component.html | 15 +++--- .../components/need-page/need-page.component.css | 30 ++++++----- .../components/need-page/need-page.component.html | 60 +++++++++------------- 8 files changed, 85 insertions(+), 79 deletions(-) diff --git a/ufund-ui/src/app/app.component.css b/ufund-ui/src/app/app.component.css index 0bcd658..f4ed668 100644 --- a/ufund-ui/src/app/app.component.css +++ b/ufund-ui/src/app/app.component.css @@ -38,29 +38,33 @@ text-decoration: none; } - a { - display: block; - position: relative; - padding: 0.1em 0; + a:hover { + text-decoration: underline; } - a::after { - content: ''; - position: absolute; - bottom: 4px; - left: 0; - width: 100%; - height: 0.03em; - background-color: white; - opacity: 0; - transition: opacity 300ms, transform 300ms; - } + /*a {*/ + /* display: block;*/ + /* position: relative;*/ + /* padding: 0.1em 0;*/ + /*}*/ - a:hover::after, - a:focus::after { - opacity: 1; - transform: translate3d(0, 0.2em, 0); - } + /*a::after {*/ + /* content: '';*/ + /* position: absolute;*/ + /* bottom: 4px;*/ + /* left: 0;*/ + /* width: 100%;*/ + /* height: 0.03em;*/ + /* background-color: white;*/ + /* opacity: 0;*/ + /* transition: opacity 300ms, transform 300ms;*/ + /*}*/ + + /*a:hover::after,*/ + /*a:focus::after {*/ + /* opacity: 1;*/ + /* transform: translate3d(0, 0.2em, 0);*/ + /*}*/ } diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index faff4d4..4116a77 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -4,7 +4,7 @@ } #box { - width: 1000px; + width: 800px; display: flex; flex-direction: column; } @@ -22,7 +22,7 @@ border-top-left-radius: 5px; border-top-right-radius: 5px; margin-right: 5px; - border-bottom: 0px; + border-bottom: 0; } .selected-tab { diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css index a17f710..dff6e06 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css @@ -5,7 +5,7 @@ #box { display: flex; - width: 1000px; + width: 800px; flex-direction: column; gap: 10px; } diff --git a/ufund-ui/src/app/components/home-page/home-page.component.css b/ufund-ui/src/app/components/home-page/home-page.component.css index 16f3140..a10377f 100644 --- a/ufund-ui/src/app/components/home-page/home-page.component.css +++ b/ufund-ui/src/app/components/home-page/home-page.component.css @@ -4,6 +4,7 @@ flex-direction: column; align-items: center; justify-content: center; + overflow: clip; } #hero { diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index d4be5fa..041b4ce 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -100,3 +100,11 @@ select { padding: 5px; gap: 5px; } + +#page-selector { + display: flex; + align-items: center; + justify-content: center; + padding: 10px; + gap: 10px +} diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 8ea7b88..8ea88b1 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -15,6 +15,8 @@ + +
    @@ -24,13 +26,6 @@

    All Needs

    No Results Found

    -
    - Page {{currentPage + 1}} of {{totalPages}}
    - - - - -
    @@ -69,3 +64,9 @@
    + +
    + + Page {{currentPage + 1}} of {{totalPages}} + +
    diff --git a/ufund-ui/src/app/components/need-page/need-page.component.css b/ufund-ui/src/app/components/need-page/need-page.component.css index f950171..844410f 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.css +++ b/ufund-ui/src/app/components/need-page/need-page.component.css @@ -6,7 +6,9 @@ #box { display: flex; flex-direction: column; - width: 1000px; + width: 800px; + justify-content: start; + gap: 10px; } .needName { @@ -15,7 +17,9 @@ .needType { text-transform: uppercase; - font-size: 10pt; + /*font-size: 10pt;*/ + margin-top: -20px; + /*margin-bottom: 20px;*/ } .split { @@ -47,21 +51,23 @@ .prog { display: flex; flex-direction: column; + margin-bottom: 15px; } .actionArea { display: flex; padding: 5px; gap: 5px; + margin-top: 10px; } -#editor { - position: absolute; - background-color: #4a4a4a; - display: flex; - flex-direction: column; - justify-self: center; - align-self: center; - padding: 20px; - box-shadow: 0 0 100px black; -} +/*#editor {*/ +/* position: absolute;*/ +/* background-color: #4a4a4a;*/ +/* display: flex;*/ +/* flex-direction: column;*/ +/* justify-self: center;*/ +/* align-self: center;*/ +/* padding: 20px;*/ +/* box-shadow: 0 0 100px black;*/ +/*}*/ diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index a8479fd..e8d292e 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -1,10 +1,29 @@

    {{need?.name}}

    -
    -

    Looking for {{need?.type}} Donations.

    + {{need?.type}} GOAL + + Need image + +

    {{need?.description}}

    +
    + + + This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!
    -
    -

    Tags:

    + + Target Goal: {{need.maxGoal}} + + Amount Currently Collected: {{need.current}} + + Location: {{need.location}} + + Urgency: + Not urgent + URGENT + + +
    + Tags:
    • {{tag}}

      @@ -12,14 +31,6 @@
    -
    - {{need?.description}} - Need image -

    Location: {{need?.location}}

    -

    Urgent: {{need?.urgent}}

    - {{need?.current}} / {{need?.maxGoal}} - - This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!
    - -
    -
    -
    - {{need.name}} - {{need.type}} -
    - -
    - URGENT - location_on{{need.location}} -
    -
    - -
    - -
    - - {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%) - -
    - -
    - -
    -- cgit v1.2.3 From 0e9c0803e35a23ef2e873dc7ebf224a49a92f207 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 1 Apr 2025 02:16:04 -0400 Subject: Get everything working enough to go in main --- .../app/components/cupboard/cupboard.component.css | 18 +++++++++++++--- .../components/cupboard/cupboard.component.html | 24 +++++++++++----------- .../app/components/cupboard/cupboard.component.ts | 2 +- .../components/dashboard/dashboard.component.html | 2 +- .../components/dashboard/dashboard.component.ts | 9 ++++++-- .../funding-basket/funding-basket.component.css | 2 +- .../components/need-edit/need-edit.component.css | 21 +++++++++++++++++++ .../components/need-edit/need-edit.component.html | 6 ++++-- .../components/need-list/need-list.component.css | 2 +- .../components/need-list/need-list.component.html | 1 - .../components/need-page/need-page.component.html | 6 +++--- 11 files changed, 66 insertions(+), 27 deletions(-) diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.css b/ufund-ui/src/app/components/cupboard/cupboard.component.css index 4116a77..e45d929 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.css +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.css @@ -30,13 +30,25 @@ } #create-form, #delete-form, #update-form { - background-color: #d9d9d9; + background-color: #3a3a3a; padding: 10px 20px 20px 20px; border: 2px solid #000; border-radius: 5px; visibility: visible; + /*position: absolute;*/ } -#create-button { - padding: 10px 20px; +#header { + display: flex; + gap: 20px; + align-items: center; + + h1 { + display: inline; + width: min-content; + } + + button { + margin-top: 3px; + } } diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 2cfbe2d..37954bb 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -1,14 +1,14 @@
    -

    Cupboard

    +
    -
    -

    Admin View

    - - + +
    + +

    Create Need

    @@ -27,12 +27,12 @@

    - -
    +
    +
    -
    - +
    +
    diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index e70d98f..2230cd3 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -16,7 +16,7 @@ import {ToastsService, ToastType} from '../../services/toasts.service'; export class CupboardComponent implements OnInit { - selectedForm = "create"; + selectedForm?: string = undefined; needs: any; @ViewChild("needList") needList?: NeedListComponent diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.html b/ufund-ui/src/app/components/dashboard/dashboard.component.html index 330d1f3..6a95ecd 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.html +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.html @@ -2,4 +2,4 @@

    Your Dashboard

    - + diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 645893f..c94b5c6 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -4,6 +4,7 @@ import {Router} from '@angular/router'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; import {firstValueFrom} from 'rxjs'; +import {UsersService} from '../../services/users.service'; @Component({ selector: 'app-dashboard', @@ -20,7 +21,8 @@ export class DashboardComponent implements OnInit{ constructor( protected authService: AuthService, protected router: Router, - protected cupboardService: CupboardService + protected cupboardService: CupboardService, + protected userService: UsersService ) {} ngOnInit() { @@ -33,7 +35,10 @@ export class DashboardComponent implements OnInit{ firstValueFrom(this.cupboardService.getNeeds()).then(r => { this.topNeeds = r.sort((a, b) => b.current - a.current) this.almostThere = r.sort((a, b) => a.current/a.maxGoal - b.current/b.maxGoal) - this.inBasket = r.filter(n => n.id in user!.basket) + }) + + this.userService.getBasket().subscribe(r => { + this.inBasket = r; }) } diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css index dff6e06..c46ef57 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css @@ -20,7 +20,7 @@ #needList { display: flex; flex-direction: column; - gap: 10px; + gap: 15px; max-width: 1000px; } diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.css b/ufund-ui/src/app/components/need-edit/need-edit.component.css index e69de29..17605c2 100644 --- a/ufund-ui/src/app/components/need-edit/need-edit.component.css +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.css @@ -0,0 +1,21 @@ +:host { + /*position: absolute;*/ + /*background-color: rgba(0, 0, 0, 0.5);*/ + /*display: flex;*/ + /*height: 100%;*/ + /*top: 0;*/ + /*left: 0;*/ + /*right: 0;*/ + /*z-index: 5;*/ + /*justify-content: center;*/ +} + +#create-form, #delete-form, #update-form { + margin-top: 50px; + background-color: #3a3a3a; + padding: 10px 20px 20px 20px; + border: 2px solid #000; + border-radius: 5px; + /*visibility: visible;*/ + /*position: absolute;*/ +} diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.html b/ufund-ui/src/app/components/need-edit/need-edit.component.html index bcb166b..e776415 100644 --- a/ufund-ui/src/app/components/need-edit/need-edit.component.html +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.html @@ -1,9 +1,11 @@

    Update Need

    -
    +

    +

    +



    @@ -19,4 +21,4 @@
    -
    \ No newline at end of file +
    diff --git a/ufund-ui/src/app/components/need-list/need-list.component.css b/ufund-ui/src/app/components/need-list/need-list.component.css index 041b4ce..5f2e5e1 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.css +++ b/ufund-ui/src/app/components/need-list/need-list.component.css @@ -14,7 +14,7 @@ #needList { display: flex; flex-direction: column; - gap: 10px + gap: 15px } select { diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 8ea88b1..c0501ba 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -25,7 +25,6 @@

    Search Results({{needs.length - searchResults.length}} needs filtered):

    All Needs

    No Results Found

    -
    diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index e8d292e..958dfa6 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -35,9 +35,9 @@ - + + + -- cgit v1.2.3