From ea13cf6ab3b71ff5e83fca876ec71fec1f7b00ae Mon Sep 17 00:00:00 2001 From: sowgro Date: Wed, 26 Mar 2025 15:38:46 -0400 Subject: Make frontend work with the new backend checkout system --- ufund-ui/src/app/app.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ufund-ui/src/app/app.component.ts') diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 7dc8ffb..86717c4 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -1,7 +1,7 @@ import {Component, OnInit, Inject} from '@angular/core'; -import {UsersService} from './services/users.service'; import {BehaviorSubject} from 'rxjs'; import { DOCUMENT } from '@angular/common'; +import {AuthService} from './services/auth.service'; @Component({ selector: 'app-root', @@ -14,16 +14,16 @@ export class AppComponent implements OnInit { currentUser$: BehaviorSubject = new BehaviorSubject("Logged out."); constructor( - private userService: UsersService, + private authService: AuthService, @Inject(DOCUMENT) private document: Document ) {} reloadPage() { this.document.defaultView?.location.reload(); - } + } ngOnInit() { - this.userService.getCurrentUserSubject().subscribe(r => { + this.authService.getCurrentUserSubject().subscribe(r => { this.currentUser$?.next(r ? "Logged in as " + r.username : "Logged out." -- 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/src/app/app.component.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/app.component.ts') diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 86717c4..7d9afcd 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -1,7 +1,12 @@ -import {Component, OnInit, Inject} from '@angular/core'; -import {BehaviorSubject} from 'rxjs'; +import {Component, OnInit, Inject, ViewChild} from '@angular/core'; +import {BehaviorSubject, Observable} from 'rxjs'; import { DOCUMENT } from '@angular/common'; import {AuthService} from './services/auth.service'; +import {ToastType} from './services/toasts.service'; + +interface ToastProps { + type: ToastType, message: string, action?: {label: string, onAction: () => void} +} @Component({ selector: 'app-root', @@ -12,6 +17,8 @@ import {AuthService} from './services/auth.service'; export class AppComponent implements OnInit { // title = 'ufund-ui'; currentUser$: BehaviorSubject = new BehaviorSubject("Logged out."); + toast = new BehaviorSubject({type: ToastType.INFO, message: "testToast"}) + constructor( private authService: AuthService, @@ -31,4 +38,6 @@ export class AppComponent implements OnInit { }) } + + } -- 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.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'ufund-ui/src/app/app.component.ts') 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() + } } -- 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 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/app.component.ts') 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() { -- 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(+) (limited to 'ufund-ui/src/app/app.component.ts') 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 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(-) (limited to 'ufund-ui/src/app/app.component.ts') 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 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.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'ufund-ui/src/app/app.component.ts') diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index df9114e..2f98334 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -1,15 +1,11 @@ -import {Component, OnInit, Inject} from '@angular/core'; +import {Component, OnInit, Inject, ViewContainerRef} from '@angular/core'; import {BehaviorSubject} from 'rxjs'; import { DOCUMENT } from '@angular/common'; import {AuthService} from './services/auth.service'; -import {ToastType} from './services/toasts.service'; +import {ToastsService} 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} -} - @Component({ selector: 'app-root', templateUrl: './app.component.html', @@ -19,13 +15,13 @@ interface ToastProps { export class AppComponent implements OnInit { // title = 'ufund-ui'; currentUser?: BehaviorSubject; - toast = new BehaviorSubject({type: ToastType.INFO, message: "testToast"}) - constructor( private authService: AuthService, private router: Router, private route: ActivatedRoute, + protected toastService: ToastsService, + private viewContainerRef: ViewContainerRef, @Inject(DOCUMENT) private document: Document ) {} @@ -34,6 +30,7 @@ export class AppComponent implements OnInit { } ngOnInit() { + this.toastService.setRootViewContainerRef(this.viewContainerRef) this.currentUser = this.authService.getCurrentUserSubject() let data = localStorage.getItem("credential"); if (data) { @@ -51,5 +48,4 @@ export class AppComponent implements OnInit { localStorage.removeItem("credential") location.reload() } - } -- cgit v1.2.3