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!
Something's missing.
Sorry, we can't find that page