diff --git a/bizmatch-server/src/app.module.ts b/bizmatch-server/src/app.module.ts index 4484c2e..9d7a82c 100644 --- a/bizmatch-server/src/app.module.ts +++ b/bizmatch-server/src/app.module.ts @@ -13,6 +13,9 @@ import { FileService } from './file/file.service.js'; import { GeoModule } from './geo/geo.module.js'; import { ImageModule } from './image/image.module.js'; import { ListingsModule } from './listings/listings.module.js'; +import { LogController } from './log/log.controller.js'; +import { LogModule } from './log/log.module.js'; + import { MailModule } from './mail/mail.module.js'; import { RequestDurationMiddleware } from './request-duration/request-duration.middleware.js'; import { SelectOptionsModule } from './select-options/select-options.module.js'; @@ -75,8 +78,9 @@ loadEnvFiles(); ImageModule, PassportModule, AiModule, + LogModule, ], - controllers: [AppController], + controllers: [AppController, LogController], providers: [AppService, FileService], }) export class AppModule { diff --git a/bizmatch-server/src/log/log.controller.ts b/bizmatch-server/src/log/log.controller.ts new file mode 100644 index 0000000..6fe77d7 --- /dev/null +++ b/bizmatch-server/src/log/log.controller.ts @@ -0,0 +1,19 @@ +import { Body, Controller, Inject, Post, Request, UseGuards } from '@nestjs/common'; +import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; +import { Logger } from 'winston'; +import { OptionalJwtAuthGuard } from '../jwt-auth/optional-jwt-auth.guard.js'; +import { LogMessage } from '../models/main.model.js'; +@Controller('log') +export class LogController { + constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {} + + @UseGuards(OptionalJwtAuthGuard) + @Post() + log(@Request() req, @Body() message: LogMessage) { + if (message.severity === 'info') { + this.logger.info(message.text); + } else { + this.logger.error(message.text); + } + } +} diff --git a/bizmatch-server/src/log/log.module.ts b/bizmatch-server/src/log/log.module.ts new file mode 100644 index 0000000..2b85cb7 --- /dev/null +++ b/bizmatch-server/src/log/log.module.ts @@ -0,0 +1,7 @@ +import { Module } from '@nestjs/common'; +import { LogController } from './log.controller.js'; + +@Module({ + controllers: [LogController], +}) +export class LogModule {} diff --git a/bizmatch-server/src/models/main.model.ts b/bizmatch-server/src/models/main.model.ts index 3f68a9f..dc92e44 100644 --- a/bizmatch-server/src/models/main.model.ts +++ b/bizmatch-server/src/models/main.model.ts @@ -247,6 +247,14 @@ export interface CountyResult { state: string; state_code: string; } +export interface LogMessage { + severity: 'error' | 'info'; + text: string; +} +export interface ModalResult { + accepted: boolean; + criteria?: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria; +} export function isEmpty(value: any): boolean { // Check for undefined or null if (value === undefined || value === null) { diff --git a/bizmatch/src/app/app.routes.ts b/bizmatch/src/app/app.routes.ts index ba318e4..37e46ab 100644 --- a/bizmatch/src/app/app.routes.ts +++ b/bizmatch/src/app/app.routes.ts @@ -54,6 +54,10 @@ export const routes: Routes = [ canActivate: [ListingCategoryGuard], component: NotFoundComponent, // Dummy-Komponente, wird nie angezeigt, da der Guard weiterleitet }, + { + path: 'notfound', + component: NotFoundComponent, + }, // ######### // User Details { diff --git a/bizmatch/src/app/components/header/header.component.ts b/bizmatch/src/app/components/header/header.component.ts index 0b03bcf..e9f7cdf 100644 --- a/bizmatch/src/app/components/header/header.component.ts +++ b/bizmatch/src/app/components/header/header.component.ts @@ -14,7 +14,7 @@ import { CriteriaChangeService } from '../../services/criteria-change.service'; import { SearchService } from '../../services/search.service'; import { SharedService } from '../../services/shared.service'; import { UserService } from '../../services/user.service'; -import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaProxy, map2User } from '../../utils/utils'; +import { assignProperties, compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaProxy, map2User } from '../../utils/utils'; import { DropdownComponent } from '../dropdown/dropdown.component'; import { ModalService } from '../search-modal/modal.service'; @Component({ @@ -86,9 +86,11 @@ export class HeaderComponent { ngAfterViewInit() {} async openModal() { - const accepted = await this.modalService.showModal(this.criteria); - if (accepted) { + const modalResult = await this.modalService.showModal(this.criteria); + if (modalResult.accepted) { this.searchService.search(this.criteria); + } else { + this.criteria = assignProperties(this.criteria, modalResult.criteria); } } navigateWithState(dest: string, state: any) { diff --git a/bizmatch/src/app/components/not-found/not-found.component.html b/bizmatch/src/app/components/not-found/not-found.component.html index 8071020..6084105 100644 --- a/bizmatch/src/app/components/not-found/not-found.component.html +++ b/bizmatch/src/app/components/not-found/not-found.component.html @@ -1 +1,35 @@ -

not-found works!

+ +
+
+
+

404

+

Something's missing.

+

Sorry, we can't find that page

+ + +
+
+
diff --git a/bizmatch/src/app/components/not-found/not-found.component.ts b/bizmatch/src/app/components/not-found/not-found.component.ts index f444acf..3c69836 100644 --- a/bizmatch/src/app/components/not-found/not-found.component.ts +++ b/bizmatch/src/app/components/not-found/not-found.component.ts @@ -1,8 +1,11 @@ +import { CommonModule } from '@angular/common'; import { Component } from '@angular/core'; +import { RouterModule } from '@angular/router'; @Component({ selector: 'app-not-found', standalone: true, - template: '

Page not found

', + imports: [CommonModule, RouterModule], + templateUrl: './not-found.component.html', }) export class NotFoundComponent {} diff --git a/bizmatch/src/app/components/search-modal/modal.service.ts b/bizmatch/src/app/components/search-modal/modal.service.ts index 259d487..1946cb6 100644 --- a/bizmatch/src/app/components/search-modal/modal.service.ts +++ b/bizmatch/src/app/components/search-modal/modal.service.ts @@ -1,7 +1,7 @@ // 1. Shared Service (modal.service.ts) import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; -import { BusinessListingCriteria, CommercialPropertyListingCriteria, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model'; +import { BusinessListingCriteria, CommercialPropertyListingCriteria, ModalResult, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model'; @Injectable({ providedIn: 'root', @@ -9,26 +9,26 @@ import { BusinessListingCriteria, CommercialPropertyListingCriteria, UserListing export class ModalService { private modalVisibleSubject = new BehaviorSubject(false); private messageSubject = new BehaviorSubject(null); - private resolvePromise!: (value: boolean) => void; + private resolvePromise!: (value: ModalResult) => void; modalVisible$: Observable = this.modalVisibleSubject.asObservable(); message$: Observable = this.messageSubject.asObservable(); - showModal(message: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria): Promise { + showModal(message: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria): Promise { this.messageSubject.next(message); this.modalVisibleSubject.next(true); - return new Promise(resolve => { + return new Promise(resolve => { this.resolvePromise = resolve; }); } accept(): void { this.modalVisibleSubject.next(false); - this.resolvePromise(true); + this.resolvePromise({ accepted: true }); } - reject(): void { + reject(backupCriteria: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria): void { this.modalVisibleSubject.next(false); - this.resolvePromise(false); + this.resolvePromise({ accepted: false, criteria: backupCriteria }); } } diff --git a/bizmatch/src/app/components/search-modal/search-modal.component.html b/bizmatch/src/app/components/search-modal/search-modal.component.html index cade652..66af002 100644 --- a/bizmatch/src/app/components/search-modal/search-modal.component.html +++ b/bizmatch/src/app/components/search-modal/search-modal.component.html @@ -9,7 +9,7 @@ } @else {

Professional Listing Search

} - + + @if(criteria.criteriaType==='businessListings'){
@@ -470,7 +475,7 @@