aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts8
-rw-r--r--ufund-ui/src/app/components/dashboard/dashboard.component.css2
-rw-r--r--ufund-ui/src/app/components/dashboard/dashboard.component.html13
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.ts6
-rw-r--r--ufund-ui/src/app/components/login/login.component.html4
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.css4
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.html9
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts28
-rw-r--r--ufund-ui/src/app/components/need-page/need-page.component.css10
-rw-r--r--ufund-ui/src/app/components/need-page/need-page.component.html56
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.html4
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.ts18
12 files changed, 97 insertions, 65 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index 2230cd3..a4706b3 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -1,6 +1,6 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import { CupboardService } from '../../services/cupboard.service';
-import { Need, GoalType } from '../../models/Need';
+import { Need } from '../../models/Need';
import { userType } from '../../models/User';
import { catchError, of } from 'rxjs';
import { NeedListComponent } from '../need-list/need-list.component';
@@ -90,7 +90,7 @@ export class CupboardComponent implements OnInit {
id: 0,
maxGoal: form.maxGoal,
type: form.type,
- urgent: form.urgent ? true : false,
+ urgent: !!form.urgent,
filterAttributes: [],
current: 0,
description: form.description
@@ -120,8 +120,4 @@ export class CupboardComponent implements OnInit {
);
}
-
- destroy() {
-
- }
}
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.css b/ufund-ui/src/app/components/dashboard/dashboard.component.css
index 78a69ba..185fdc2 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: 1000px;
+ width: 800px;
align-self: center;
gap: 20px
}
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.html b/ufund-ui/src/app/components/dashboard/dashboard.component.html
index 6a95ecd..2d7b4c3 100644
--- a/ufund-ui/src/app/components/dashboard/dashboard.component.html
+++ b/ufund-ui/src/app/components/dashboard/dashboard.component.html
@@ -1,5 +1,10 @@
-<h1>Your Dashboard</h1>
-<app-mini-need-list [needList]="topNeeds" jtitle="Top needs" url="/cupboard"/>
-<app-mini-need-list [needList]="almostThere" jtitle="Almost there" url="/cupboard"/>
-<app-mini-need-list [needList]="inBasket" jtitle="In your basket" url="/basket"/>
+<h1>Admin Dashboard</h1>
+<!--<app-mini-need-list [needList]="topNeeds" jtitle="Top needs" url="/cupboard"/>-->
+<!--<app-mini-need-list [needList]="almostThere" jtitle="Almost there" url="/cupboard"/>-->
+<!--<app-mini-need-list [needList]="inBasket" jtitle="In your basket" url="/basket"/>-->
+<span>_ Registered users</span>
+<span>_ Needs with overflow</span>
+<span>_ Needs in peoples baskets</span>
+<span>_ Total monetary contributions</span>
+<span>_ </span>
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 dcacca1..847baee 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
@@ -70,11 +70,11 @@ export class FundingBasketComponent implements OnInit {
this.cupboardService.checkoutNeed(need.id, +contribution.value)
.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, 'Goal must be greater than 0');
+ 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 new Observable<string>();
}))
diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html
index c67b903..1017d0f 100644
--- a/ufund-ui/src/app/components/login/login.component.html
+++ b/ufund-ui/src/app/components/login/login.component.html
@@ -1,7 +1,7 @@
<div id="box">
<h1>Login</h1>
- <input placeholder="Username" type="text" #username>
- <input placeholder="Password" type="password" #password>
+ <input placeholder="Username" type="text" #username (keydown.enter)="login(username.value, password.value)">
+ <input placeholder="Password" type="password" #password (keydown.enter)="login(username.value, password.value)">
<button type="button" (click)="login(username.value, password.value)">Login</button>
<div>
New? <a routerLink="/signup">Create an account</a>
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 5f2e5e1..e17609b 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
@@ -89,6 +89,10 @@ select {
background-color: #3a3a3a;
border-radius: 5px;
cursor: pointer;
+ height: 130px;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
}
.clickable:hover {
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 0d64c99..84f80dc 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
@@ -40,10 +40,9 @@
</div>
</div>
- <br>
-
<div class="prog">
<span id="hover-status-label-{{need.id}}"> </span>
+
<span>{{need.type.toString() == 'MONETARY' ? '$' : ''}}{{need.current}}/{{need.type.toString() == 'MONETARY' ? '$' : ''}}{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%)</span>
<progress [value]="need.current" [max]="need.maxGoal"></progress>
</div>
@@ -65,7 +64,9 @@
</div>
<div id="page-selector">
- <button *ngIf="currentPage > 0" (click)="decrementPage()"><span class="icon">arrow_back_ios</span></button>
+ <button [disabled]="!(currentPage !== 0)" (click)="firstPage()"><span class="icon">first_page</span></button>
+ <button [disabled]="!(currentPage > 0)" (click)="decrementPage()"><span class="icon">arrow_back_ios_new</span></button>
<span>Page {{currentPage + 1}} of {{totalPages}}</span>
- <button *ngIf="currentPage < totalPages - 1" (click)="incrementPage()"><span class="icon">arrow_forward_ios</span></button>
+ <button [disabled]="!(currentPage < totalPages - 1)" (click)="incrementPage()"><span class="icon">arrow_forward_ios</span></button>
+ <button [disabled]="!(currentPage !== totalPages - 1)" (click)="lastPage()"><span class="icon">last_page</span></button>
</div>
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 ed14d6a..ae6bc99 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,5 +1,5 @@
import {Component, EventEmitter, Output} from '@angular/core';
-import {Need} from '../../models/Need';
+import {GoalType, Need} from '../../models/Need';
import {CupboardService} from '../../services/cupboard.service';
import {UsersService} from '../../services/users.service';
import {userType} from '../../models/User';
@@ -72,14 +72,28 @@ export class NeedListComponent {
itemsPerPage: number = 5;
totalPages: number = Math.ceil(this.needs.length / this.itemsPerPage);
+ getPrefix(need: Need) {
+ return (need.type === GoalType.MONETARY) ? "$" : "";
+ }
+
decrementPage() {
this.currentPage--;
- this.updateVisibleNeeds();
+ this.updateVisibleNeeds();
}
incrementPage() {
this.currentPage++;
- this.updateVisibleNeeds();
+ this.updateVisibleNeeds();
+ }
+
+ lastPage() {
+ this.currentPage = this.totalPages - 1
+ this.updateVisibleNeeds()
+ }
+
+ firstPage() {
+ this.currentPage = 0
+ this.updateVisibleNeeds()
}
editNeedsPerPage() {
@@ -140,7 +154,7 @@ export class NeedListComponent {
ngOnInit(): void {
this.refresh()
-
+
}
changeSortMode(form : any) {
@@ -224,6 +238,7 @@ export class NeedListComponent {
if (currentUser) {
if (!currentUser.basket.includes(need.id)) {
currentUser.basket.push(need.id);
+ this.toastService.sendToast(ToastType.INFO, "Need added to your basket!")
this.usersService.updateUser(currentUser)
.pipe(catchError((err, _) => {
console.error(err);
@@ -273,8 +288,7 @@ export class NeedListComponent {
button.style.visibility = 'hidden';
}
}
-}
-function not(location: string) {
- throw new Error('Function not implemented.');
+
+ protected readonly GoalType = GoalType;
}
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 844410f..44db4b4 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
@@ -31,6 +31,7 @@
.left {
display: flex;
flex-direction: column;
+ width : 50%;
}
.right {
@@ -40,6 +41,15 @@
}
}
+.need-image {
+ width: 400px;
+ height: auto;
+ aspect-ratio: 16/9;
+ object-fit: cover;
+ border-radius: 10px;
+ box-shadow: rgb(0, 40, 70) 0 0 50px;
+}
+
.urgent {
font-size: 11pt;
background-color: rgba(255, 165, 0, 0.27);
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 12e9b74..6921eac 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,35 +1,41 @@
<div id="box">
- <h1>{{need?.name}}</h1>
- <span class="needType">{{need?.type}} GOAL</span>
-
- <img *ngIf="need.image" alt="Need image" [src]="need?.image"/>
-
- <p>{{need?.description}}</p>
+ <h1>{{need.name}}</h1>
+ <span class="needType">{{need.type}} GOAL</span>
+ <p>{{need.description}}</p>
<div class="prog">
<!-- <span>{{need?.current}} / {{need?.maxGoal}}</span>-->
- <progress [value]="need?.current" [max]="need?.maxGoal"></progress>
- <span>This goal is <strong>{{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}%</strong> complete!</span>
+ <progress [value]="need.current" [max]="need.maxGoal"></progress>
+ <span>This goal is <strong>{{(((need.current)*100) / (need.maxGoal)).toFixed(0)}}%</strong> complete!</span>
</div>
- <span><strong>Target Goal:</strong> {{need.type.toString() == 'MONETARY' ? '$' : ''}}{{need.maxGoal}}</span>
-
- <span><strong>Amount Currently Collected:</strong> {{need.type.toString() == 'MONETARY' ? '$' : ''}}{{need.current}}</span>
-
- <span><strong>Location:</strong> {{need.location}}</span>
-
- <span><strong>Urgency: </strong>
- <span *ngIf="!need.urgent">Not urgent</span>
- <span *ngIf="need.urgent" class="urgent">URGENT</span>
- </span>
- <div *ngIf="need.filterAttributes.length > 0">
- <strong>Tags:</strong>
- <ul style="display: flex; column-gap: 24px;">
- <li *ngFor="let tag of need?.filterAttributes">
- <p>{{tag}}</p>
- </li>
- </ul>
+ <div class="split">
+ <div class="left">
+ <span><strong>Target Goal:</strong> {{(need.type === GoalType.MONETARY) ? "$" : ""}}{{need.maxGoal}}</span>
+
+ <span><strong>Amount Currently Collected:</strong> {{need.type.toString() == 'MONETARY' ? '$' : ''}}{{need.current}}</span>
+
+ <span><strong>Location:</strong> {{need.location}}</span>
+
+ <span><strong>Urgency: </strong>
+ <span *ngIf="!need.urgent">Not urgent</span>
+ <span *ngIf="need.urgent" class="urgent">URGENT</span>
+ </span>
+
+ <div *ngIf="need.filterAttributes.length > 0">
+ <strong>Tags:</strong>
+ <ul style="display: flex; column-gap: 24px;">
+ <li *ngFor="let tag of need?.filterAttributes">
+ <p>{{tag}}</p>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="right">
+ <img *ngIf="need.image" alt="Need image" class="need-image" [src]="need.image"/>
+ </div>
</div>
+
<div class="actionArea">
<button *ngIf="isHelper()" (click)="add(need!)">
diff --git a/ufund-ui/src/app/components/signup/signup.component.html b/ufund-ui/src/app/components/signup/signup.component.html
index bc3aaf0..84f15e4 100644
--- a/ufund-ui/src/app/components/signup/signup.component.html
+++ b/ufund-ui/src/app/components/signup/signup.component.html
@@ -8,7 +8,7 @@
<div>
<div>
<input placeholder="Password" type="password" (input)="validate(username.value, confirmPass.value, password.value)" #password>
- <progress [ngClass]="'color' + strength.getValue()" id="bar" [value]="strength | async" max="6"> </progress>
+ <progress [ngClass]="'color' + strength.getValue()" id="bar" [value]="strength | async" max="5"> </progress>
<span *ngIf="passwordStatusText">{{passwordStatusText | async}}</span>
</div>
@@ -24,8 +24,6 @@
<div>
<button [disabled]="!(ableToCreateAccount | async)" (click)="signup(username.value, password.value)">Create Account</button>
- <span *ngIf="showSuccessMessage | async">Account created <a routerLink="/login">Proceed to login</a></span>
- <span *ngIf="statusText | async">{{statusText | async}}</span>
</div>
<span>Already have an account? <a routerLink="/login">Log in</a></span>
</div>
diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts
index a20d828..9c37211 100644
--- a/ufund-ui/src/app/components/signup/signup.component.ts
+++ b/ufund-ui/src/app/components/signup/signup.component.ts
@@ -3,10 +3,10 @@ import {UsersService} from '../../services/users.service';
import {Router} from '@angular/router';
import {BehaviorSubject} from 'rxjs';
import {ToastsService, ToastType} from '../../services/toasts.service';
+import {AuthService} from '../../services/auth.service';
class PasswordRequirements {
sixLong: {title: string, value: boolean} = {title: 'Is 6 characters or longer' , value: false}
- twelveLong: {title: string, value: boolean} = {title: 'Is 12 characters or longer', value: false}
lowercase: {title: string, value: boolean} = {title: 'Includes lowercase letter' , value: false}
uppercase: {title: string, value: boolean} = {title: 'Includes uppercase letter' , value: false}
number: {title: string, value: boolean} = {title: 'Includes number' , value: false}
@@ -25,17 +25,16 @@ export class SignupComponent {
protected passwordStatusText = new BehaviorSubject("")
protected passwordsMatch = new BehaviorSubject(false)
protected usernameStatusText = new BehaviorSubject("")
- protected showSuccessMessage = new BehaviorSubject(false)
protected passwordStrongEnough = new BehaviorSubject(false)
protected ableToCreateAccount = new BehaviorSubject(false)
protected passwordRequirements: PasswordRequirements = new PasswordRequirements()
protected strength = new BehaviorSubject(0)
- protected statusText = new BehaviorSubject("");
constructor(
protected usersService: UsersService,
protected router: Router,
- protected toastService: ToastsService
+ protected toastService: ToastsService,
+ protected authService: AuthService
) {}
signup(username: string | null, password: string | null) {
@@ -45,7 +44,10 @@ export class SignupComponent {
}
this.usersService.createUser(username, password).then(() => {
- this.showSuccessMessage.next(true);
+ // let action = {label: 'Proceed to login', onAction: () => this.router.navigate(["/login"])}
+ this.toastService.sendToast(ToastType.INFO, "Account successfully created")
+ this.authService.login(username, password)
+ this.router.navigate(["/"])
}).catch(ex => {
this.toastService.sendToast(ToastType.ERROR, "Unable to create account: " + friendlyHttpStatus[ex.status])
console.log(ex)
@@ -74,16 +76,12 @@ export class SignupComponent {
if (password.match(/[^!-~]/g)) {
this.passwordStatusText.next("Invalid characters")
-
return
}
if (password.length > 6) {
this.passwordRequirements.sixLong.value = true
}
- if (password.length > 12) {
- this.passwordRequirements.twelveLong.value = true
- }
if (password.match(/[a-z]/g)) {
this.passwordRequirements.lowercase.value = true
}
@@ -108,7 +106,7 @@ export class SignupComponent {
} else if (strength == 0) {
this.passwordStatusText.next("")
} else {
- this.passwordStatusText.next("5/6 checks required")
+ this.passwordStatusText.next("Password must meet requirements")
}
this.strength.next(strength)