kleinere Korrekturen zu #60
This commit is contained in:
parent
7c9a47cf4e
commit
d4ec9d067f
|
|
@ -27,7 +27,7 @@ export class EMailComponent {
|
||||||
async sendMail() {
|
async sendMail() {
|
||||||
try {
|
try {
|
||||||
const result = await this.mailService.mailToFriend(this.shareByEMail);
|
const result = await this.mailService.mailToFriend(this.shareByEMail);
|
||||||
this.eMailService.accept();
|
this.eMailService.accept(this.shareByEMail);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.error && Array.isArray(error.error?.message)) {
|
if (error.error && Array.isArray(error.error?.message)) {
|
||||||
this.validationMessagesService.updateMessages(error.error.message);
|
this.validationMessagesService.updateMessages(error.error.message);
|
||||||
|
|
|
||||||
|
|
@ -8,22 +8,22 @@ import { ShareByEMail } from '../../../../../bizmatch-server/src/models/db.model
|
||||||
export class EMailService {
|
export class EMailService {
|
||||||
private modalVisibleSubject = new BehaviorSubject<boolean>(false);
|
private modalVisibleSubject = new BehaviorSubject<boolean>(false);
|
||||||
private shareByEMailSubject = new BehaviorSubject<ShareByEMail>({});
|
private shareByEMailSubject = new BehaviorSubject<ShareByEMail>({});
|
||||||
private resolvePromise!: (value: boolean) => void;
|
private resolvePromise!: (value: boolean | ShareByEMail) => void;
|
||||||
|
|
||||||
modalVisible$: Observable<boolean> = this.modalVisibleSubject.asObservable();
|
modalVisible$: Observable<boolean> = this.modalVisibleSubject.asObservable();
|
||||||
shareByEMail$: Observable<ShareByEMail> = this.shareByEMailSubject.asObservable();
|
shareByEMail$: Observable<ShareByEMail> = this.shareByEMailSubject.asObservable();
|
||||||
|
|
||||||
showShareByEMail(shareByEMail: ShareByEMail): Promise<boolean> {
|
showShareByEMail(shareByEMail: ShareByEMail): Promise<boolean | ShareByEMail> {
|
||||||
this.shareByEMailSubject.next(shareByEMail);
|
this.shareByEMailSubject.next(shareByEMail);
|
||||||
this.modalVisibleSubject.next(true);
|
this.modalVisibleSubject.next(true);
|
||||||
return new Promise<boolean>(resolve => {
|
return new Promise<boolean | ShareByEMail>(resolve => {
|
||||||
this.resolvePromise = resolve;
|
this.resolvePromise = resolve;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
accept(): void {
|
accept(value: ShareByEMail): void {
|
||||||
this.modalVisibleSubject.next(false);
|
this.modalVisibleSubject.next(false);
|
||||||
this.resolvePromise(true);
|
this.resolvePromise(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
reject(): void {
|
reject(): void {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||||
import { KeycloakService } from 'keycloak-angular';
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
import { ShareButton } from 'ngx-sharebuttons/button';
|
import { ShareButton } from 'ngx-sharebuttons/button';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { BusinessListing, EventTypeEnum, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
import { BusinessListing, EventTypeEnum, ShareByEMail, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||||
import { KeycloakUser, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model';
|
import { KeycloakUser, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { EMailService } from '../../../components/email/email.service';
|
import { EMailService } from '../../../components/email/email.service';
|
||||||
|
|
@ -112,7 +112,7 @@ export class DetailsBusinessListingComponent {
|
||||||
this.mailinfo.email = this.listingUser.email;
|
this.mailinfo.email = this.listingUser.email;
|
||||||
this.mailinfo.listing = this.listing;
|
this.mailinfo.listing = this.listing;
|
||||||
await this.mailService.mail(this.mailinfo);
|
await this.mailService.mail(this.mailinfo);
|
||||||
this.auditService.createEvent(this.listing.id, 'contact', this.user?.email);
|
this.auditService.createEvent(this.listing.id, 'contact', this.user?.email, this.mailinfo.sender);
|
||||||
this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 });
|
this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.messageService.addMessage({
|
this.messageService.addMessage({
|
||||||
|
|
@ -173,7 +173,7 @@ export class DetailsBusinessListingComponent {
|
||||||
type: 'business',
|
type: 'business',
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
this.auditService.createEvent(this.listing.id, 'email', this.user?.email);
|
this.auditService.createEvent(this.listing.id, 'email', this.user?.email, <ShareByEMail>result);
|
||||||
this.messageService.addMessage({
|
this.messageService.addMessage({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
text: 'Your Email has beend sent',
|
text: 'Your Email has beend sent',
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { KeycloakService } from 'keycloak-angular';
|
||||||
import { GalleryModule, ImageItem } from 'ng-gallery';
|
import { GalleryModule, ImageItem } from 'ng-gallery';
|
||||||
import { ShareButton } from 'ngx-sharebuttons/button';
|
import { ShareButton } from 'ngx-sharebuttons/button';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { CommercialPropertyListing, EventTypeEnum, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
import { CommercialPropertyListing, EventTypeEnum, ShareByEMail, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||||
import { CommercialPropertyListingCriteria, ErrorResponse, KeycloakUser, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model';
|
import { CommercialPropertyListingCriteria, ErrorResponse, KeycloakUser, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { EMailService } from '../../../components/email/email.service';
|
import { EMailService } from '../../../components/email/email.service';
|
||||||
|
|
@ -143,7 +143,7 @@ export class DetailsCommercialPropertyListingComponent {
|
||||||
this.mailinfo.email = this.listingUser.email;
|
this.mailinfo.email = this.listingUser.email;
|
||||||
this.mailinfo.listing = this.listing;
|
this.mailinfo.listing = this.listing;
|
||||||
await this.mailService.mail(this.mailinfo);
|
await this.mailService.mail(this.mailinfo);
|
||||||
this.auditService.createEvent(this.listing.id, 'contact', this.user?.email);
|
this.auditService.createEvent(this.listing.id, 'contact', this.user?.email, this.mailinfo.sender);
|
||||||
this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 });
|
this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.messageService.addMessage({
|
this.messageService.addMessage({
|
||||||
|
|
@ -183,7 +183,7 @@ export class DetailsCommercialPropertyListingComponent {
|
||||||
type: 'commercialProperty',
|
type: 'commercialProperty',
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
this.auditService.createEvent(this.listing.id, 'email', this.user?.email);
|
this.auditService.createEvent(this.listing.id, 'email', this.user?.email, <ShareByEMail>result);
|
||||||
this.messageService.addMessage({
|
this.messageService.addMessage({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
text: 'Your Email has beend sent',
|
text: 'Your Email has beend sent',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject, lastValueFrom, Observable } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { EventTypeEnum, ListingEvent } from '../../../../bizmatch-server/src/models/db.model';
|
import { EventTypeEnum, ListingEvent } from '../../../../bizmatch-server/src/models/db.model';
|
||||||
import { LogMessage } from '../../../../bizmatch-server/src/models/main.model';
|
import { LogMessage } from '../../../../bizmatch-server/src/models/main.model';
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
|
|
@ -12,21 +12,13 @@ import { GeoService } from './geo.service';
|
||||||
export class AuditService {
|
export class AuditService {
|
||||||
private apiBaseUrl = environment.apiBaseUrl;
|
private apiBaseUrl = environment.apiBaseUrl;
|
||||||
private apiKey = environment.ipinfo_token;
|
private apiKey = environment.ipinfo_token;
|
||||||
// private ipifyUrl = 'https://api.ipify.org?format=json';
|
|
||||||
// private ipInfoUrl = 'https://ipinfo.io';
|
|
||||||
private ipifyUrl = 'https://api.ipify.org?format=json';
|
|
||||||
private ipInfoUrl = 'https://ipinfo.io';
|
|
||||||
|
|
||||||
// BehaviorSubject to store the geolocation data
|
|
||||||
private geoLocationSubject = new BehaviorSubject<any>(null);
|
|
||||||
public geoLocation$: Observable<any> = this.geoLocationSubject.asObservable();
|
|
||||||
|
|
||||||
constructor(private http: HttpClient, private geoService: GeoService) {}
|
constructor(private http: HttpClient, private geoService: GeoService) {}
|
||||||
|
|
||||||
async log(message: LogMessage): Promise<void> {
|
async log(message: LogMessage): Promise<void> {
|
||||||
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/log`, message));
|
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/log`, message));
|
||||||
}
|
}
|
||||||
async createEvent(id: string, eventType: EventTypeEnum, userId: string): Promise<void> {
|
async createEvent(id: string, eventType: EventTypeEnum, userId: string, additionalData?): Promise<void> {
|
||||||
const ipInfo = await this.geoService.getIpInfo();
|
const ipInfo = await this.geoService.getIpInfo();
|
||||||
const [latitude, longitude] = ipInfo.loc ? ipInfo.loc.split(',') : [null, null]; //.map(Number);
|
const [latitude, longitude] = ipInfo.loc ? ipInfo.loc.split(',') : [null, null]; //.map(Number);
|
||||||
const listingEvent: ListingEvent = {
|
const listingEvent: ListingEvent = {
|
||||||
|
|
@ -40,7 +32,9 @@ export class AuditService {
|
||||||
locationCity: ipInfo.city,
|
locationCity: ipInfo.city,
|
||||||
locationLat: latitude,
|
locationLat: latitude,
|
||||||
locationLng: longitude,
|
locationLng: longitude,
|
||||||
|
additionalData,
|
||||||
};
|
};
|
||||||
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/event`, listingEvent));
|
let headers = new HttpHeaders().set('X-Hide-Loading', 'true');
|
||||||
|
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/event`, listingEvent, { headers }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue