From 5dc893da388712a105f06dea9333f2c245ba1c9a Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Thu, 23 May 2024 18:09:54 -0500 Subject: [PATCH] imagePath changed --- bizmatch-server/.gitignore | 3 +- bizmatch-server/package.json | 1 + bizmatch-server/src/drizzle/import.ts | 48 ++++++++---- ...omsday.sql => 0000_burly_bruce_banner.sql} | 1 + .../migrations/meta/0000_snapshot.json | 8 +- .../src/drizzle/migrations/meta/_journal.json | 4 +- bizmatch-server/src/drizzle/schema.ts | 1 + bizmatch-server/src/file/file.service.ts | 77 +++++++++++-------- bizmatch-server/src/image/image.controller.ts | 70 ++++++++--------- bizmatch-server/src/models/db.model.ts | 1 + bizmatch-server/src/user/user.service.ts | 10 +-- .../details-business-listing.component.html | 2 +- ...commercial-property-listing.component.html | 4 +- ...s-commercial-property-listing.component.ts | 4 +- .../details-user/details-user.component.html | 4 +- .../details-user/details-user.component.ts | 3 +- .../broker-listings.component.html | 4 +- .../broker-listings.component.ts | 4 +- .../business-listings.component.html | 4 +- .../business-listings.component.ts | 4 +- ...ommercial-property-listings.component.html | 6 +- .../subscription/account/account.component.ts | 30 ++++---- .../edit-business-listing.component.ts | 8 +- ...commercial-property-listing.component.html | 2 +- ...t-commercial-property-listing.component.ts | 19 +++-- bizmatch/src/app/services/image.service.ts | 37 +++++---- bizmatch/src/app/services/listings.service.ts | 4 - bizmatch/src/app/services/user.service.ts | 18 ++--- 28 files changed, 209 insertions(+), 172 deletions(-) rename bizmatch-server/src/drizzle/migrations/{0000_melted_doomsday.sql => 0000_burly_bruce_banner.sql} (98%) diff --git a/bizmatch-server/.gitignore b/bizmatch-server/.gitignore index 422d033..0b86619 100644 --- a/bizmatch-server/.gitignore +++ b/bizmatch-server/.gitignore @@ -55,4 +55,5 @@ pids # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json -pictures \ No newline at end of file +pictures +pictures_base \ No newline at end of file diff --git a/bizmatch-server/package.json b/bizmatch-server/package.json index 3a96b6a..eb08ec5 100644 --- a/bizmatch-server/package.json +++ b/bizmatch-server/package.json @@ -37,6 +37,7 @@ "cors": "^2.8.5", "dotenv": "^16.4.5", "drizzle-orm": "^0.30.8", + "fs-extra": "^11.2.0", "handlebars": "^4.7.8", "ky": "^1.2.0", "nest-winston": "^1.9.4", diff --git a/bizmatch-server/src/drizzle/import.ts b/bizmatch-server/src/drizzle/import.ts index 422e27c..a71111b 100644 --- a/bizmatch-server/src/drizzle/import.ts +++ b/bizmatch-server/src/drizzle/import.ts @@ -1,11 +1,13 @@ import 'dotenv/config'; import { drizzle } from 'drizzle-orm/node-postgres'; import { existsSync, readFileSync, readdirSync, statSync, unlinkSync } from 'fs'; +import fs from 'fs-extra'; import { join } from 'path'; import pkg from 'pg'; import { rimraf } from 'rimraf'; import sharp from 'sharp'; import { BusinessListing, CommercialPropertyListing, User, UserData } from 'src/models/db.model.js'; +import { emailToDirName } from 'src/models/main.model.js'; import * as schema from './schema.js'; const { Pool } = pkg; @@ -32,6 +34,11 @@ const targetPathProfile = `./pictures/profile`; deleteFilesOfDir(targetPathProfile); const targetPathLogo = `./pictures/logo`; deleteFilesOfDir(targetPathLogo); +const targetPathProperty = `./pictures/property`; +deleteFilesOfDir(targetPathProperty); +fs.ensureDirSync(`./pictures/logo`); +fs.ensureDirSync(`./pictures/profile`); +fs.ensureDirSync(`./pictures/property`); for (const userData of usersData) { const user: User = { firstname: '', lastname: '', email: '' }; user.licensedIn = []; @@ -58,20 +65,21 @@ for (const userData of usersData) { user.gender = userData.gender; user.created = new Date(); user.updated = new Date(); - const u = await db.insert(schema.users).values(user).returning({ insertedId: schema.users.id, gender: schema.users.gender }); - generatedUserData.push(u[0].insertedId); + const u = await db.insert(schema.users).values(user).returning({ insertedId: schema.users.id, gender: schema.users.gender, email: schema.users.email }); + generatedUserData.push(u[0]); i++; + if (u[0].gender === 'male') { male++; - const data = readFileSync(`./pictures/profile_base/Mann_${male}.jpg`); - await storeProfilePicture(data, u[0].insertedId); + const data = readFileSync(`./pictures_base/profile/Mann_${male}.jpg`); + await storeProfilePicture(data, emailToDirName(u[0].email)); } else { female++; - const data = readFileSync(`./pictures/profile_base/Frau_${female}.jpg`); - await storeProfilePicture(data, u[0].insertedId); + const data = readFileSync(`./pictures_base/profile/Frau_${female}.jpg`); + await storeProfilePicture(data, emailToDirName(u[0].email)); } - const data = readFileSync(`./pictures/logos_base/${i}.jpg`); - await storeCompanyLogo(data, u[0].insertedId); + const data = readFileSync(`./pictures_base/logo/${i}.jpg`); + await storeCompanyLogo(data, emailToDirName(u[0].email)); } //Business Listings filePath = `./data/businesses.json`; @@ -82,7 +90,9 @@ for (const business of businessJsonData) { delete business.id; business.created = new Date(business.created); business.updated = new Date(business.created); - business.userId = getRandomItem(generatedUserData); + const user = getRandomItem(generatedUserData); + business.userId = user.insertedId; + business.imageName = emailToDirName(user.email); await db.insert(schema.businesses).values(business); } //Corporate Listings @@ -92,14 +102,20 @@ const commercialJsonData = JSON.parse(data) as CommercialPropertyListing[]; // E for (const commercial of commercialJsonData) { const id = commercial.id; delete commercial.id; - + const user = getRandomItem(generatedUserData); commercial.imageOrder = getFilenames(id); - commercial.imagePath = id; + commercial.imagePath = emailToDirName(user.email); const insertionDate = getRandomDateWithinLastYear(); commercial.created = insertionDate; commercial.updated = insertionDate; - commercial.userId = getRandomItem(generatedUserData); - await db.insert(schema.commercials).values(commercial); + commercial.userId = user.insertedId; + const result = await db.insert(schema.commercials).values(commercial).returning(); + //fs.ensureDirSync(`./pictures/property/${result[0].imagePath}/${result[0].serialId}`); + try { + fs.copySync(`./pictures_base/property/${id}`, `./pictures/property/${result[0].imagePath}/${result[0].serialId}`); + } catch (err) { + console.log(`----- No pictures available for ${id} ------`); + } } //End @@ -115,7 +131,7 @@ function getRandomItem(arr: T[]): T { } function getFilenames(id: string): string[] { try { - let filePath = `./pictures/property/${id}`; + let filePath = `./pictures_base/property/${id}`; return readdirSync(filePath); } catch (e) { return null; @@ -141,14 +157,14 @@ async function storeProfilePicture(buffer: Buffer, userId: string) { await sharp(output).toFile(`./pictures/profile/${userId}.avif`); } -async function storeCompanyLogo(buffer: Buffer, userId: string) { +async function storeCompanyLogo(buffer: Buffer, adjustedEmail: string) { let quality = 50; const output = await sharp(buffer) .resize({ width: 300 }) .avif({ quality }) // Verwende AVIF //.webp({ quality }) // Verwende Webp .toBuffer(); - await sharp(output).toFile(`./pictures/logo/${userId}.avif`); // Ersetze Dateierweiterung + await sharp(output).toFile(`./pictures/logo/${adjustedEmail}.avif`); // Ersetze Dateierweiterung // await fs.outputFile(`./pictures/logo/${userId}`, file.buffer); } diff --git a/bizmatch-server/src/drizzle/migrations/0000_melted_doomsday.sql b/bizmatch-server/src/drizzle/migrations/0000_burly_bruce_banner.sql similarity index 98% rename from bizmatch-server/src/drizzle/migrations/0000_melted_doomsday.sql rename to bizmatch-server/src/drizzle/migrations/0000_burly_bruce_banner.sql index 619b0e9..afbe261 100644 --- a/bizmatch-server/src/drizzle/migrations/0000_melted_doomsday.sql +++ b/bizmatch-server/src/drizzle/migrations/0000_burly_bruce_banner.sql @@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS "businesses" ( "reasonForSale" varchar(255), "brokerLicencing" varchar(255), "internals" text, + "imagePath" varchar(200), "created" timestamp, "updated" timestamp, "visits" integer, diff --git a/bizmatch-server/src/drizzle/migrations/meta/0000_snapshot.json b/bizmatch-server/src/drizzle/migrations/meta/0000_snapshot.json index 60cb54a..b14fcf9 100644 --- a/bizmatch-server/src/drizzle/migrations/meta/0000_snapshot.json +++ b/bizmatch-server/src/drizzle/migrations/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "a27bba95-3910-4b41-b241-ce91f2201311", + "id": "fc58c59b-ac5c-406e-8fdb-b05de40aed17", "prevId": "00000000-0000-0000-0000-000000000000", "version": "5", "dialect": "pg", @@ -147,6 +147,12 @@ "primaryKey": false, "notNull": false }, + "imagePath": { + "name": "imagePath", + "type": "varchar(200)", + "primaryKey": false, + "notNull": false + }, "created": { "name": "created", "type": "timestamp", diff --git a/bizmatch-server/src/drizzle/migrations/meta/_journal.json b/bizmatch-server/src/drizzle/migrations/meta/_journal.json index 5f09050..c61103a 100644 --- a/bizmatch-server/src/drizzle/migrations/meta/_journal.json +++ b/bizmatch-server/src/drizzle/migrations/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "5", - "when": 1716417232952, - "tag": "0000_melted_doomsday", + "when": 1716495198537, + "tag": "0000_burly_bruce_banner", "breakpoints": true } ] diff --git a/bizmatch-server/src/drizzle/schema.ts b/bizmatch-server/src/drizzle/schema.ts index 868a642..f929b43 100644 --- a/bizmatch-server/src/drizzle/schema.ts +++ b/bizmatch-server/src/drizzle/schema.ts @@ -49,6 +49,7 @@ export const businesses = pgTable('businesses', { reasonForSale: varchar('reasonForSale', { length: 255 }), brokerLicencing: varchar('brokerLicencing', { length: 255 }), internals: text('internals'), + imageName: varchar('imagePath', { length: 200 }), created: timestamp('created'), updated: timestamp('updated'), visits: integer('visits'), diff --git a/bizmatch-server/src/file/file.service.ts b/bizmatch-server/src/file/file.service.ts index 92a429e..496c341 100644 --- a/bizmatch-server/src/file/file.service.ts +++ b/bizmatch-server/src/file/file.service.ts @@ -20,6 +20,9 @@ export class FileService { fs.ensureDirSync(`./pictures/logo`); fs.ensureDirSync(`./pictures/property`); } + // ############ + // Subscriptions + // ############ private loadSubscriptions(): void { const filePath = join(__dirname, '../..', 'assets', 'subscriptions.json'); const rawData = readFileSync(filePath, 'utf8'); @@ -28,36 +31,43 @@ export class FileService { getSubscriptions(): Subscription[] { return this.subscriptions; } - async storeProfilePicture(file: Express.Multer.File, userId: string) { + // ############ + // Profile + // ############ + async storeProfilePicture(file: Express.Multer.File, adjustedEmail: string) { let quality = 50; const output = await sharp(file.buffer) .resize({ width: 300 }) .avif({ quality }) // Verwende AVIF //.webp({ quality }) // Verwende Webp .toBuffer(); - await sharp(output).toFile(`./pictures/profile/${userId}.avif`); + await sharp(output).toFile(`./pictures/profile/${adjustedEmail}.avif`); } - hasProfile(userId: string) { - return fs.existsSync(`./pictures/profile/${userId}.avif`); + hasProfile(adjustedEmail: string) { + return fs.existsSync(`./pictures/profile/${adjustedEmail}.avif`); } - - async storeCompanyLogo(file: Express.Multer.File, userId: string) { + // ############ + // Logo + // ############ + async storeCompanyLogo(file: Express.Multer.File, adjustedEmail: string) { let quality = 50; const output = await sharp(file.buffer) .resize({ width: 300 }) .avif({ quality }) // Verwende AVIF //.webp({ quality }) // Verwende Webp .toBuffer(); - await sharp(output).toFile(`./pictures/logo/${userId}.avif`); // Ersetze Dateierweiterung + await sharp(output).toFile(`./pictures/logo/${adjustedEmail}.avif`); // Ersetze Dateierweiterung // await fs.outputFile(`./pictures/logo/${userId}`, file.buffer); } - hasCompanyLogo(userId: string) { - return fs.existsSync(`./pictures/logo/${userId}.avif`) ? true : false; + hasCompanyLogo(adjustedEmail: string) { + return fs.existsSync(`./pictures/logo/${adjustedEmail}.avif`) ? true : false; } - - async getPropertyImages(listingId: string): Promise { + // ############ + // Property + // ############ + async getPropertyImages(imagePath: string, serial: string): Promise { const result: string[] = []; - const directory = `./pictures/property/${listingId}`; + const directory = `./pictures/property/${imagePath}/${serial}`; if (fs.existsSync(directory)) { const files = await fs.readdir(directory); files.forEach(f => { @@ -68,9 +78,9 @@ export class FileService { return []; } } - async hasPropertyImages(listingId: string): Promise { + async hasPropertyImages(imagePath: string, serial: string): Promise { const result: ImageProperty[] = []; - const directory = `./pictures/property/${listingId}`; + const directory = `./pictures/property/${imagePath}/${serial}`; if (fs.existsSync(directory)) { const files = await fs.readdir(directory); return files.length > 0; @@ -78,15 +88,18 @@ export class FileService { return false; } } - async storePropertyPicture(file: Express.Multer.File, listingId: string): Promise { + async storePropertyPicture(file: Express.Multer.File, imagePath: string, serial: string): Promise { const suffix = file.mimetype.includes('png') ? 'png' : 'jpg'; - const directory = `./pictures/property/${listingId}`; + const directory = `./pictures/property/${imagePath}/${serial}`; fs.ensureDirSync(`${directory}`); const imageName = await this.getNextImageName(directory); //await fs.outputFile(`${directory}/${imageName}`, file.buffer); await this.resizeImageToAVIF(file.buffer, 150 * 1024, imageName, directory); return `${imageName}.avif`; } + // ############ + // utils + // ############ async getNextImageName(directory) { try { const files = await fs.readdir(directory); @@ -115,22 +128,22 @@ export class FileService { let timeTaken = Date.now() - start; this.logger.info(`Quality: ${quality} - Time: ${timeTaken} milliseconds`); } - getProfileImagesForUsers(userids: string) { - const ids = userids.split(','); - let result = {}; - for (const id of ids) { - result = { ...result, [id]: fs.existsSync(`./pictures/profile/${id}.avif`) }; - } - return result; - } - getCompanyLogosForUsers(userids: string) { - const ids = userids.split(','); - let result = {}; - for (const id of ids) { - result = { ...result, [id]: fs.existsSync(`./pictures/logo/${id}.avif`) }; - } - return result; - } + // getProfileImagesForUsers(userids: string) { + // const ids = userids.split(','); + // let result = {}; + // for (const id of ids) { + // result = { ...result, [id]: fs.existsSync(`./pictures/profile/${id}.avif`) }; + // } + // return result; + // } + // getCompanyLogosForUsers(userids: string) { + // const ids = userids.split(','); + // let result = {}; + // for (const id of ids) { + // result = { ...result, [id]: fs.existsSync(`./pictures/logo/${id}.avif`) }; + // } + // return result; + // } deleteImage(path: string) { fs.unlinkSync(path); } diff --git a/bizmatch-server/src/image/image.controller.ts b/bizmatch-server/src/image/image.controller.ts index 0819160..8eb26a3 100644 --- a/bizmatch-server/src/image/image.controller.ts +++ b/bizmatch-server/src/image/image.controller.ts @@ -17,58 +17,54 @@ export class ImageController { @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger, private selectOptions: SelectOptionsService, ) {} - - @Post('uploadPropertyPicture/:imagePath') + // ############ + // Property + // ############ + @Post('uploadPropertyPicture/:imagePath/:serial') @UseInterceptors(FileInterceptor('file')) - async uploadPropertyPicture(@UploadedFile() file: Express.Multer.File, @Param('imagePath') imagePath: string) { - const imagename = await this.fileService.storePropertyPicture(file, imagePath); + async uploadPropertyPicture(@UploadedFile() file: Express.Multer.File, @Param('imagePath') imagePath: string, @Param('serial') serial: string) { + const imagename = await this.fileService.storePropertyPicture(file, imagePath, serial); await this.listingService.addImage(imagePath, imagename); } - - @Post('uploadProfile/:id') - @UseInterceptors(FileInterceptor('file')) - async uploadProfile(@UploadedFile() file: Express.Multer.File, @Param('id') id: string) { - await this.fileService.storeProfilePicture(file, id); - } - - @Post('uploadCompanyLogo/:id') - @UseInterceptors(FileInterceptor('file')) - async uploadCompanyLogo(@UploadedFile() file: Express.Multer.File, @Param('id') id: string) { - await this.fileService.storeCompanyLogo(file, id); - } - - @Get(':id') - async getPropertyImagesById(@Param('id') id: string): Promise { - const result = await this.listingService.findById(id, commercials); + @Get(':email/:serial') + async getPropertyImagesById(@Param('email') adjustedEmail: string, @Param('serial') serial: string): Promise { + const result = await this.listingService.findByImagePath(adjustedEmail); const listing = result as CommercialPropertyListing; if (listing.imageOrder) { return listing.imageOrder; } else { - const imageOrder = await this.fileService.getPropertyImages(id); + const imageOrder = await this.fileService.getPropertyImages(adjustedEmail, serial); listing.imageOrder = imageOrder; this.listingService.updateListing(listing.id, listing, commercials); return imageOrder; } } - @Get('profileImages/:userids') - async getProfileImagesForUsers(@Param('userids') userids: string): Promise { - return await this.fileService.getProfileImagesForUsers(userids); + @Delete('propertyPicture/:imagePath/:serial/:imagename') + async deletePropertyImagesById(@Param('imagePath') imagePath: string, @Param('serial') serial: string, @Param('imagename') imagename: string): Promise { + this.fileService.deleteImage(`pictures/property/${imagePath}/${serial}/${imagename}`); } - @Get('companyLogos/:userids') - async getCompanyLogosForUsers(@Param('userids') userids: string): Promise { - return await this.fileService.getCompanyLogosForUsers(userids); + // ############ + // Profile + // ############ + @Post('uploadProfile/:email') + @UseInterceptors(FileInterceptor('file')) + async uploadProfile(@UploadedFile() file: Express.Multer.File, @Param('email') adjustedEmail: string) { + await this.fileService.storeProfilePicture(file, adjustedEmail); } - - @Delete('propertyPicture/:imagePath/:imagename') - async deletePropertyImagesById(@Param('imagePath') imagePath: string, @Param('imagename') imagename: string): Promise { - this.fileService.deleteImage(`pictures/property/${imagePath}/${imagename}`); + @Delete('profile/:email/') + async deleteProfileImagesById(@Param('email') email: string): Promise { + this.fileService.deleteImage(`pictures/profile/${email}.avif`); } - @Delete('logo/:userid/') - async deleteLogoImagesById(@Param('userid') userid: string): Promise { - this.fileService.deleteImage(`pictures/logo/${userid}.avif`); + // ############ + // Logo + // ############ + @Post('uploadCompanyLogo/:email') + @UseInterceptors(FileInterceptor('file')) + async uploadCompanyLogo(@UploadedFile() file: Express.Multer.File, @Param('email') adjustedEmail: string) { + await this.fileService.storeCompanyLogo(file, adjustedEmail); } - @Delete('profile/:userid/') - async deleteProfileImagesById(@Param('userid') userid: string): Promise { - this.fileService.deleteImage(`pictures/profile/${userid}.avif`); + @Delete('logo/:email/') + async deleteLogoImagesById(@Param('email') adjustedEmail: string): Promise { + this.fileService.deleteImage(`pictures/logo/${adjustedEmail}.avif`); } } diff --git a/bizmatch-server/src/models/db.model.ts b/bizmatch-server/src/models/db.model.ts index 344d198..3ff474b 100644 --- a/bizmatch-server/src/models/db.model.ts +++ b/bizmatch-server/src/models/db.model.ts @@ -61,6 +61,7 @@ export interface BusinessListing { reasonForSale?: string; brokerLicencing?: string; internals?: string; + imageName?: string; created?: Date; updated?: Date; visits?: number; diff --git a/bizmatch-server/src/user/user.service.ts b/bizmatch-server/src/user/user.service.ts index 70df1fa..ed8912c 100644 --- a/bizmatch-server/src/user/user.service.ts +++ b/bizmatch-server/src/user/user.service.ts @@ -7,7 +7,7 @@ import * as schema from '../drizzle/schema.js'; import { PG_CONNECTION } from '../drizzle/schema.js'; import { FileService } from '../file/file.service.js'; import { User } from '../models/db.model.js'; -import { ListingCriteria } from '../models/main.model.js'; +import { ListingCriteria, emailToDirName } from '../models/main.model.js'; @Injectable() export class UserService { @@ -33,8 +33,8 @@ export class UserService { .from(schema.users) .where(sql`email = ${email}`)) as User[]; const user = users[0]; - user.hasCompanyLogo = this.fileService.hasCompanyLogo(user.id); - user.hasProfile = this.fileService.hasProfile(user.id); + user.hasCompanyLogo = this.fileService.hasCompanyLogo(emailToDirName(user.email)); + user.hasProfile = this.fileService.hasProfile(emailToDirName(user.email)); return user; } async getUserById(id: string) { @@ -43,8 +43,8 @@ export class UserService { .from(schema.users) .where(sql`id = ${id}`)) as User[]; const user = users[0]; - user.hasCompanyLogo = this.fileService.hasCompanyLogo(id); - user.hasProfile = this.fileService.hasProfile(id); + user.hasCompanyLogo = this.fileService.hasCompanyLogo(emailToDirName(user.email)); + user.hasProfile = this.fileService.hasProfile(emailToDirName(user.email)); return user; } async saveUser(user: any): Promise { diff --git a/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.html b/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.html index 5bec8a6..73934ed 100644 --- a/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.html +++ b/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.html @@ -94,7 +94,7 @@
Listing by  {{ listingUser.firstname }} {{ listingUser.lastname }} @if(listingUser.hasCompanyLogo){ - + }
} diff --git a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html index 0de73bd..40c3baf 100644 --- a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html +++ b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html @@ -51,7 +51,7 @@
- + @if (mailinfo){ @@ -84,7 +84,7 @@
Listing by  {{ listingUser.firstname }} {{ listingUser.lastname }} @if(listingUser.hasCompanyLogo){ - + }
} diff --git a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts index b6cf51e..e9ce3ca 100644 --- a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts +++ b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts @@ -10,6 +10,7 @@ import { CommercialPropertyListing, User } from '../../../../../../bizmatch-serv import { ErrorResponse, KeycloakUser, ListingCriteria, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { HistoryService } from '../../../services/history.service'; +import { ImageService } from '../../../services/image.service'; import { ListingsService } from '../../../services/listings.service'; import { MailService } from '../../../services/mail.service'; import { SelectOptionsService } from '../../../services/select-options.service'; @@ -67,6 +68,7 @@ export class DetailsCommercialPropertyListingComponent { private sanitizer: DomSanitizer, public historyService: HistoryService, public keycloakService: KeycloakService, + private imageService: ImageService, ) { this.mailinfo = { sender: {}, userId: '', email: '', url: environment.mailinfoUrl }; @@ -77,7 +79,7 @@ export class DetailsCommercialPropertyListingComponent { const token = await this.keycloakService.getToken(); this.user = map2User(token); this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty')); - this.propertyImages = await this.listingsService.getPropertyImages(this.listing.id); + this.propertyImages = await this.imageService.getPropertyImages(this.listing.imagePath, this.listing.serialId); this.listingUser = await this.userService.getById(this.listing.userId); this.description = this.sanitizer.bypassSecurityTrustHtml(this.listing.description); } diff --git a/bizmatch/src/app/pages/details/details-user/details-user.component.html b/bizmatch/src/app/pages/details/details-user/details-user.component.html index c1e2b4b..2d5c1a9 100644 --- a/bizmatch/src/app/pages/details/details-user/details-user.component.html +++ b/bizmatch/src/app/pages/details/details-user/details-user.component.html @@ -6,7 +6,7 @@
@if(user.hasProfile){ - + } @else { } @@ -30,7 +30,7 @@
@if(user.hasCompanyLogo){ - + } diff --git a/bizmatch/src/app/pages/details/details-user/details-user.component.ts b/bizmatch/src/app/pages/details/details-user/details-user.component.ts index e690eec..6f2d69b 100644 --- a/bizmatch/src/app/pages/details/details-user/details-user.component.ts +++ b/bizmatch/src/app/pages/details/details-user/details-user.component.ts @@ -6,7 +6,7 @@ import { MessageService } from 'primeng/api'; import { GalleriaModule } from 'primeng/galleria'; import { Observable } from 'rxjs'; import { BusinessListing, CommercialPropertyListing, User } from '../../../../../../bizmatch-server/src/models/db.model'; -import { KeycloakUser, ListingCriteria } from '../../../../../../bizmatch-server/src/models/main.model'; +import { KeycloakUser, ListingCriteria, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { HistoryService } from '../../../services/history.service'; import { ImageService } from '../../../services/image.service'; @@ -37,6 +37,7 @@ export class DetailsUserComponent { offeredServices: SafeHtml; ts = new Date().getTime(); env = environment; + emailToDirName = emailToDirName; constructor( private activatedRoute: ActivatedRoute, private router: Router, diff --git a/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.html b/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.html index 2e23322..43d8e67 100644 --- a/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.html +++ b/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.html @@ -32,7 +32,7 @@
@if(user.hasProfile){ - + } @else { } @@ -45,7 +45,7 @@
@if(user.hasCompanyLogo){ - + } @else { } diff --git a/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts b/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts index f5babe3..ed5affb 100644 --- a/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts +++ b/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts @@ -12,7 +12,7 @@ import { PaginatorModule } from 'primeng/paginator'; import { StyleClassModule } from 'primeng/styleclass'; import { ToggleButtonModule } from 'primeng/togglebutton'; import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model'; -import { ListingCriteria, ListingType } from '../../../../../../bizmatch-server/src/models/main.model'; +import { ListingCriteria, ListingType, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { ImageService } from '../../../services/image.service'; import { ListingsService } from '../../../services/listings.service'; @@ -60,7 +60,7 @@ export class BrokerListingsComponent { ts = new Date().getTime(); env = environment; public category: 'business' | 'commercialProperty' | 'professionals_brokers' | undefined; - + emailToDirName = emailToDirName; constructor( public selectOptions: SelectOptionsService, private listingsService: ListingsService, diff --git a/bizmatch/src/app/pages/listings/business-listings/business-listings.component.html b/bizmatch/src/app/pages/listings/business-listings/business-listings.component.html index f0cc28c..7b7eb8c 100644 --- a/bizmatch/src/app/pages/listings/business-listings/business-listings.component.html +++ b/bizmatch/src/app/pages/listings/business-listings/business-listings.component.html @@ -51,7 +51,7 @@ @for (listing of listings; track listing.id) {
-
+
@@ -66,7 +66,7 @@

Established: {{ listing.established }}

diff --git a/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts b/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts index 8771dab..308d8dc 100644 --- a/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts +++ b/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts @@ -13,7 +13,7 @@ import { StyleClassModule } from 'primeng/styleclass'; import { ToggleButtonModule } from 'primeng/togglebutton'; import { TooltipModule } from 'primeng/tooltip'; import { BusinessListing } from '../../../../../../bizmatch-server/src/models/db.model'; -import { ListingCriteria, ListingType } from '../../../../../../bizmatch-server/src/models/main.model'; +import { ListingCriteria, ListingType, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { ImageService } from '../../../services/image.service'; import { ListingsService } from '../../../services/listings.service'; @@ -58,7 +58,7 @@ export class BusinessListingsComponent { rows: number = 12; env = environment; public category: 'business' | 'commercialProperty' | 'professionals_brokers' | undefined; - + emailToDirName = emailToDirName; constructor( public selectOptions: SelectOptionsService, private listingsService: ListingsService, diff --git a/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.html b/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.html index 75534e1..fd8e8c2 100644 --- a/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.html +++ b/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.html @@ -51,7 +51,11 @@
@if (listing.imageOrder?.length>0){ - Image + Image } @else { Image } diff --git a/bizmatch/src/app/pages/subscription/account/account.component.ts b/bizmatch/src/app/pages/subscription/account/account.component.ts index d4af3df..c8806fd 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.ts +++ b/bizmatch/src/app/pages/subscription/account/account.component.ts @@ -13,7 +13,7 @@ import { FileUpload, FileUploadModule } from 'primeng/fileupload'; import { SelectButtonModule } from 'primeng/selectbutton'; import { lastValueFrom } from 'rxjs'; import { User } from '../../../../../../bizmatch-server/src/models/db.model'; -import { AutoCompleteCompleteEvent, Invoice, Subscription } from '../../../../../../bizmatch-server/src/models/main.model'; +import { AutoCompleteCompleteEvent, Invoice, Subscription, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { ImageCropperComponent, stateOptions } from '../../../components/image-cropper/image-cropper.component'; import { GeoService } from '../../../services/geo.service'; @@ -80,8 +80,8 @@ export class AccountComponent { } this.userSubscriptions = await lastValueFrom(this.subscriptionService.getAllSubscriptions(this.user.id)); - this.profileUrl = this.user.hasProfile ? `${this.env.imageBaseUrl}/pictures/profile/${this.user.id}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; - this.companyLogoUrl = this.user.hasCompanyLogo ? `${this.env.imageBaseUrl}/pictures/logo/${this.user.id}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; + this.profileUrl = this.user.hasProfile ? `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; + this.companyLogoUrl = this.user.hasCompanyLogo ? `${this.env.imageBaseUrl}/pictures/logo/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; } printInvoice(invoice: Invoice) {} @@ -92,11 +92,11 @@ export class AccountComponent { onUploadCompanyLogo(event: any) { const uniqueSuffix = '?_ts=' + new Date().getTime(); - this.companyLogoUrl = `${this.env.imageBaseUrl}/pictures/logo/${this.user.id}${uniqueSuffix}`; + this.companyLogoUrl = `${this.env.imageBaseUrl}/pictures/logo/${emailToDirName(this.user.email)}${uniqueSuffix}`; } onUploadProfilePicture(event: any) { const uniqueSuffix = '?_ts=' + new Date().getTime(); - this.profileUrl = `${this.env.imageBaseUrl}/pictures/profile/${this.user.id}${uniqueSuffix}`; + this.profileUrl = `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}${uniqueSuffix}`; } setImageToFallback(event: Event) { (event.target as HTMLImageElement).src = `/assets/images/placeholder.png`; // Pfad zum Platzhalterbild @@ -132,30 +132,30 @@ export class AccountComponent { ratioVariable: type === 'company' ? true : false, }, header: 'Edit Image', - width: '50vw', + width: '30vw', modal: true, closeOnEscape: true, keepInViewport: true, closable: false, - breakpoints: { - '960px': '75vw', - '640px': '90vw', - }, + // breakpoints: { + // '960px': '75vw', + // '640px': '90vw', + // }, }); this.dialogRef.onClose.subscribe(cropper => { if (cropper) { this.loadingService.startLoading('uploadImage'); cropper.getCroppedCanvas().toBlob(async blob => { - this.imageUploadService.uploadImage(blob, type === 'company' ? 'uploadCompanyLogo' : 'uploadProfile', this.user.id).subscribe( + this.imageUploadService.uploadImage(blob, type === 'company' ? 'uploadCompanyLogo' : 'uploadProfile', emailToDirName(this.user.email)).subscribe( async event => { if (event.type === HttpEventType.Response) { this.loadingService.stopLoading('uploadImage'); if (this.type === 'company') { this.user.hasCompanyLogo = true; // - this.companyLogoUrl = `${this.env.imageBaseUrl}/pictures/logo/${this.user.id}.avif?_ts=${new Date().getTime()}`; + this.companyLogoUrl = `${this.env.imageBaseUrl}/pictures/logo/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}`; } else { this.user.hasProfile = true; - this.profileUrl = `${this.env.imageBaseUrl}/pictures/profile/${this.user.id}.avif?_ts=${new Date().getTime()}`; + this.profileUrl = `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}`; } await this.userService.save(this.user); } @@ -180,10 +180,10 @@ export class AccountComponent { accept: async () => { if (type === 'profile') { this.user.hasProfile = false; - await Promise.all([this.imageService.deleteProfileImagesById(this.user.id), this.userService.save(this.user)]); + await Promise.all([this.imageService.deleteProfileImagesById(this.user.email), this.userService.save(this.user)]); } else { this.user.hasCompanyLogo = false; - await Promise.all([this.imageService.deleteLogoImagesById(this.user.id), this.userService.save(this.user)]); + await Promise.all([this.imageService.deleteLogoImagesById(this.user.email), this.userService.save(this.user)]); } this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'Image deleted' }); this.user = await this.userService.getById(this.user.id); diff --git a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts index 97fa66a..abfbd53 100644 --- a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts +++ b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts @@ -18,7 +18,7 @@ import { DialogService, DynamicDialogModule, DynamicDialogRef } from 'primeng/dy import { EditorModule } from 'primeng/editor'; import { FileUpload, FileUploadModule } from 'primeng/fileupload'; import { BusinessListing, CommercialPropertyListing, User } from '../../../../../../bizmatch-server/src/models/db.model'; -import { AutoCompleteCompleteEvent, ImageProperty } from '../../../../../../bizmatch-server/src/models/main.model'; +import { AutoCompleteCompleteEvent, ImageProperty, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { InputNumberModule } from '../../../components/inputnumber/inputnumber.component'; import { ArrayToStringPipe } from '../../../pipes/array-to-string.pipe'; @@ -62,7 +62,6 @@ export class EditBusinessListingComponent { maxFileSize = 3000000; uploadUrl: string; environment = environment; - propertyImages: string[]; responsiveOptions = [ { breakpoint: '1199px', @@ -123,14 +122,15 @@ export class EditBusinessListingComponent { this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'business')); } else { this.listing = createDefaultBusinessListing(); - this.listing.userId = await this.userService.getId(keycloakUser.email); + const listingUser = await this.userService.getByMail(keycloakUser.email); + this.listing.userId = listingUser.id; + this.listing.imageName = emailToDirName(keycloakUser.email); if (this.data) { this.listing.title = this.data?.title; this.listing.description = this.data?.description; } } this.uploadUrl = `${environment.apiBaseUrl}/bizmatch/image/uploadPropertyPicture/${this.listing.id}`; - this.propertyImages = await this.listingsService.getPropertyImages(this.listing.id); } async save() { diff --git a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html index f3a74c0..2795535 100644 --- a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html +++ b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.html @@ -116,7 +116,7 @@ @for (image of propertyImages; track image) {
- +
diff --git a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts index 1388270..e04a26d 100644 --- a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts +++ b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts @@ -18,7 +18,6 @@ import { DialogModule } from 'primeng/dialog'; import { DialogService, DynamicDialogModule, DynamicDialogRef } from 'primeng/dynamicdialog'; import { EditorModule } from 'primeng/editor'; import { FileUpload, FileUploadModule } from 'primeng/fileupload'; -import { v4 as uuidv4 } from 'uuid'; import { BusinessListing, CommercialPropertyListing, User } from '../../../../../../bizmatch-server/src/models/db.model'; import { AutoCompleteCompleteEvent, ImageProperty, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; @@ -63,7 +62,6 @@ export class EditCommercialPropertyListingComponent { private id: string | undefined = this.activatedRoute.snapshot.params['id'] as string | undefined; user: User; maxFileSize = 3000000; - uploadUrl: string; environment = environment; propertyImages: string[]; responsiveOptions = [ @@ -131,15 +129,15 @@ export class EditCommercialPropertyListingComponent { this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty')); } else { this.listing = createDefaultCommercialPropertyListing(); - this.listing.userId = await this.userService.getId(keycloakUser.email); - this.listing.imagePath = `${emailToDirName(keycloakUser.email)}_${uuidv4()}`; + const listingUser = await this.userService.getByMail(keycloakUser.email); + this.listing.userId = listingUser.id; + this.listing.imagePath = `${emailToDirName(keycloakUser.email)}`; if (this.data) { this.listing.title = this.data?.title; this.listing.description = this.data?.description; } } - this.uploadUrl = `${environment.apiBaseUrl}/bizmatch/image/uploadPropertyPicture/${this.listing.id}`; - this.propertyImages = await this.listingsService.getPropertyImages(this.listing.id); + this.propertyImages = await this.imageService.getPropertyImages(this.listing.imagePath, this.listing.serialId); } async save() { @@ -176,12 +174,13 @@ export class EditCommercialPropertyListingComponent { if (cropper) { this.loadingService.startLoading('uploadImage'); cropper.getCroppedCanvas().toBlob(async blob => { - this.imageService.uploadImage(blob, 'uploadPropertyPicture', this.listing.imagePath).subscribe( + this.imageService.uploadImage(blob, 'uploadPropertyPicture', this.listing.imagePath, this.listing.serialId).subscribe( async event => { if (event.type === HttpEventType.Response) { console.log('Upload abgeschlossen', event.body); this.loadingService.stopLoading('uploadImage'); - this.propertyImages = await this.listingsService.getPropertyImages(this.listing.id); + this.propertyImages = await this.imageService.getPropertyImages(this.listing.imagePath, this.listing.serialId); + this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty')); } }, error => console.error('Fehler beim Upload:', error), @@ -205,9 +204,9 @@ export class EditCommercialPropertyListingComponent { accept: async () => { this.listing.imageOrder = this.listing.imageOrder.filter(item => item !== imageName); - await Promise.all([this.imageService.deleteListingImage(this.listing.imagePath, imageName), this.listingsService.save(this.listing, 'commercialProperty')]); + await Promise.all([this.imageService.deleteListingImage(this.listing.imagePath, this.listing.serialId, imageName), this.listingsService.save(this.listing, 'commercialProperty')]); this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'Image deleted' }); - this.propertyImages = await this.listingsService.getPropertyImages(this.listing.id); + this.propertyImages = await this.imageService.getPropertyImages(this.listing.imagePath, this.listing.serialId); }, reject: () => { // this.messageService.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected' }); diff --git a/bizmatch/src/app/services/image.service.ts b/bizmatch/src/app/services/image.service.ts index 24b378c..3bf3dff 100644 --- a/bizmatch/src/app/services/image.service.ts +++ b/bizmatch/src/app/services/image.service.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { lastValueFrom } from 'rxjs'; -import { ImageType } from '../../../../bizmatch-server/src/models/main.model'; +import { emailToDirName } from '../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../environments/environment'; @Injectable({ @@ -12,33 +12,32 @@ export class ImageService { constructor(private http: HttpClient) {} - uploadImage(imageBlob: Blob, type: 'uploadPropertyPicture' | 'uploadCompanyLogo' | 'uploadProfile', imagePath: string) { - const uploadUrl = `${this.apiBaseUrl}/bizmatch/image/${type}/${imagePath}`; + uploadImage(imageBlob: Blob, type: 'uploadPropertyPicture' | 'uploadCompanyLogo' | 'uploadProfile', imagePath: string, serialId?: number) { + let uploadUrl = `${this.apiBaseUrl}/bizmatch/image/${type}/${imagePath}`; + if (type === 'uploadPropertyPicture') { + uploadUrl = `${this.apiBaseUrl}/bizmatch/image/${type}/${imagePath}/${serialId}`; + } const formData = new FormData(); formData.append('file', imageBlob, 'image.png'); return this.http.post(uploadUrl, formData, { - // headers: this.headers, - //reportProgress: true, observe: 'events', }); } - async deleteUserImage(userid: string, type: ImageType, name?: string) { - return await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/${type.delete}${userid}`)); + + async deleteListingImage(imagePath: string, serial: number, name?: string) { + return await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/propertyPicture/${imagePath}/${serial}/${name}`)); } - async deleteListingImage(imagePath: string, name?: string) { - return await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/propertyPicture/${imagePath}/${name}`)); + + async deleteLogoImagesById(email: string) { + const adjustedEmail = emailToDirName(email); + await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/logo/${adjustedEmail}`)); } - async getProfileImagesForUsers(userids: string[]) { - return await lastValueFrom(this.http.get<[]>(`${this.apiBaseUrl}/bizmatch/image/profileImages/${userids.join(',')}`)); + async deleteProfileImagesById(email: string) { + const adjustedEmail = emailToDirName(email); + await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/profile/${adjustedEmail}`)); } - async getCompanyLogosForUsers(userids: string[]) { - return await lastValueFrom(this.http.get<[]>(`${this.apiBaseUrl}/bizmatch/image/companyLogos/${userids.join(',')}`)); - } - async deleteLogoImagesById(userid: string) { - await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/logo/${userid}`)); - } - async deleteProfileImagesById(userid: string) { - await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/profile/${userid}`)); + async getPropertyImages(imagePath: string, serial: number): Promise { + return await lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/image/${imagePath}/${serial}`)); } } diff --git a/bizmatch/src/app/services/listings.service.ts b/bizmatch/src/app/services/listings.service.ts index 85696ec..c419814 100644 --- a/bizmatch/src/app/services/listings.service.ts +++ b/bizmatch/src/app/services/listings.service.ts @@ -40,10 +40,6 @@ export class ListingsService { async deleteCommercialPropertyListing(id: string, imagePath: string) { await lastValueFrom(this.http.delete(`${this.apiBaseUrl}/bizmatch/listings/commercialProperty/${id}/${imagePath}`)); } - - async getPropertyImages(id: string): Promise { - return await lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/image/${id}`)); - } async changeImageOrder(id: string, propertyImages: string[]): Promise { return await lastValueFrom(this.http.put(`${this.apiBaseUrl}/bizmatch/listings/commercialProperty/imageOrder/${id}`, propertyImages)); } diff --git a/bizmatch/src/app/services/user.service.ts b/bizmatch/src/app/services/user.service.ts index 4578807..4de591c 100644 --- a/bizmatch/src/app/services/user.service.ts +++ b/bizmatch/src/app/services/user.service.ts @@ -33,13 +33,13 @@ export class UserService { async getAllStates(): Promise { return await lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/user/states/all`)); } - async getId(email: string): Promise { - if (sessionStorage.getItem('USERID')) { - return sessionStorage.getItem('USERID'); - } else { - const user = await this.getByMail(email); - sessionStorage.setItem('USERID', user.id); - return user.id; - } - } + // async getId(email: string): Promise { + // if (sessionStorage.getItem('USERID')) { + // return sessionStorage.getItem('USERID'); + // } else { + // const user = await this.getByMail(email); + // sessionStorage.setItem('USERID', user.id); + // return user.id; + // } + // } }