diff --git a/src/app/shared/components/filters-list/city-filter/city-filter.component.html b/src/app/shared/components/filters-list/city-filter/city-filter.component.html index 9825c8f099..efa25dc35a 100644 --- a/src/app/shared/components/filters-list/city-filter/city-filter.component.html +++ b/src/app/shared/components/filters-list/city-filter/city-filter.component.html @@ -33,7 +33,7 @@

- Ви знаходитесь в місті {{ settlement.settlement }}{{ settlement.settlement }}?

clear diff --git a/src/app/shared/components/filters-list/city-filter/city-filter.component.scss b/src/app/shared/components/filters-list/city-filter/city-filter.component.scss index e9cc8cc172..1aad86c293 100644 --- a/src/app/shared/components/filters-list/city-filter/city-filter.component.scss +++ b/src/app/shared/components/filters-list/city-filter/city-filter.component.scss @@ -73,6 +73,7 @@ h4{ text-align: center; font-size: 19px; margin-bottom: 0; + line-height: 1.3rem; span { font-weight: 700; } diff --git a/src/app/shared/components/map/map.component.html b/src/app/shared/components/map/map.component.html index ad19e7dab4..a16cde497b 100644 --- a/src/app/shared/components/map/map.component.html +++ b/src/app/shared/components/map/map.component.html @@ -1 +1 @@ -
+
\ No newline at end of file diff --git a/src/app/shared/components/map/map.component.ts b/src/app/shared/components/map/map.component.ts index 2784cdfe24..0ab237718f 100644 --- a/src/app/shared/components/map/map.component.ts +++ b/src/app/shared/components/map/map.component.ts @@ -1,49 +1,49 @@ -import { Codeficator } from './../../models/codeficator.model'; + import { Component, AfterViewInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core'; import * as Layer from 'leaflet'; import { FormGroup } from '@angular/forms'; -import { GeolocationService } from 'src/app/shared/services/geolocation/geolocation.service'; import { Coords } from '../../models/coords.model'; -import { Address, MapAddress } from '../../models/address.model'; +import { Address } from '../../models/address.model'; import { Workshop, WorkshopCard, WorkshopFilterCard } from '../../models/workshop.model'; import { Select } from '@ngxs/store'; -import { FilterState } from '../../store/filter.state'; import { Observable } from 'rxjs'; import { Subject } from 'rxjs'; import { takeUntil, filter, debounceTime } from 'rxjs/operators'; -import { GeolocationAddress } from '../../models/geolocationAddress.model'; import { UserState } from '../../store/user.state'; import { PreviousUrlService } from '../../services/previousUrl/previous-url.service'; import { WorkshopMarker } from '../../models/workshopMarker.model'; +import { GeocoderService } from './../../services/geolocation/geocoder.service'; +import { Geocoder } from './../../models/geolocation'; +import { Codeficator } from './../../models/codeficator.model'; +import { FilterState } from '../../store/filter.state'; @Component({ selector: 'app-map', templateUrl: './map.component.html', styleUrls: ['./map.component.scss'], }) -export class MapComponent { +export class MapComponent implements AfterViewInit, OnDestroy { + @Input() addressFormGroup: FormGroup; + @Input() isCreateWorkShops: boolean; + @Input() filteredWorkshops$: Observable; + + @Output() wrongMapAddress = new EventEmitter(); + @Output() selectedAddress = new EventEmitter(); + @Select(UserState.selectedWorkshop) selectedWorkshop$: Observable; - public defaultCoords: Coords; - public zoom = 11; - public workshops: WorkshopCard[]; - @Select(FilterState.settlement) settlement$: Observable; - destroy$: Subject = new Subject(); - @Input() addressFormGroup: FormGroup; - @Input() isCreateWorkShops: boolean; - @Input() filteredWorkshops$: Observable; - @Output() setAddressEvent = new EventEmitter(); - @Output() selectedAddress = new EventEmitter(); - - constructor(private geolocationService: GeolocationService, private previousUrlService: PreviousUrlService) {} + destroy$: Subject = new Subject(); map: Layer.Map; - singleMarker: Layer.Marker; - workshopMarkers: WorkshopMarker[] = []; - unselectedMarkerIcon: Layer.Icon = Layer.icon({ + private singleMarker: Layer.Marker; + private workshopMarkers: WorkshopMarker[] = []; + private defaultCoords: Coords; + private zoom = 11; + private workshops: WorkshopCard[]; + private unselectedMarkerIcon: Layer.Icon = Layer.icon({ iconSize: [25, 25], shadowSize: [0, 0], iconAnchor: [10, 41], @@ -51,8 +51,7 @@ export class MapComponent { popupAnchor: [-3, -76], iconUrl: '/assets/icons/marker.png', }); - - selectedMarkerIcon: Layer.Icon = Layer.icon({ + private selectedMarkerIcon: Layer.Icon = Layer.icon({ iconSize: [25, 25], shadowSize: [0, 0], iconAnchor: [10, 41], @@ -61,6 +60,68 @@ export class MapComponent { iconUrl: '/assets/icons/selectMarker.png', }); + constructor(private geocoderService: GeocoderService, private previousUrlService: PreviousUrlService) {} + + /** + * before map creation gets user coords from GeolocationService. If no user coords uses default coords + * Creates and sets map after div with is "map" renders. + * Adds onclick event handler which translates map coords into address + * subscribes on @input address change and on every change calls method to translate address into coords + */ + ngAfterViewInit(): void { + this.settlement$ + .pipe( + takeUntil(this.destroy$), + filter((settlement: Codeficator) => !!settlement) + ) + .subscribe((settlement: Codeficator) => { + this.defaultCoords = { lat: settlement.latitude, lng: settlement.longitude }; + this.map || this.initMap(); + this.flyTo(this.defaultCoords); + + // checking if there are filtered workshops on the map for teh result page view + if (!!this.filteredWorkshops$) { + this.setFilteredWorkshops(); + } + // checking if user edit workshop information to create adress for workshop + if (this.addressFormGroup) { + this.setAddress(); + } + }); + } + + private setFilteredWorkshops(): void { + this.filteredWorkshops$.pipe(takeUntil(this.destroy$)).subscribe((filteredWorkshops: WorkshopFilterCard) => { + this.workshopMarkers.forEach((workshopMarker: WorkshopMarker) => this.map.removeLayer(workshopMarker.marker)); + this.workshopMarkers = []; + if (filteredWorkshops) { + this.workshops = filteredWorkshops.entities; + filteredWorkshops.entities.forEach((workshop: WorkshopCard) => this.setAddressLocation(workshop.address)); + this.setPrevWorkshopMarker(); + } + }); + } + + private setAddress(): void { + const address: Geocoder = this.addressFormGroup.getRawValue(); + if (address.catottgId) { + this.geocoderService.addressDecode(address, (result: Geocoder) => { + if (result) { + this.setNewSingleMarker([result.latitude, result.longitude]); + } + this.wrongMapAddress.emit(!result); + }); + } + + this.addressFormGroup.valueChanges + .pipe( + debounceTime(500), + takeUntil(this.destroy$), + filter((address: Geocoder) => !!(address.longitude && address.latitude)) + ) + .subscribe((address: Geocoder) => this.setNewSingleMarker([address.latitude, address.longitude])); + } + /** * changing position on map * @param coords:Coords @@ -93,98 +154,29 @@ export class MapComponent { }); } - /** - * before map creation gets user coords from GeolocationService. If no user coords uses default coords - * Creates and sets map after div with is "map" renders. - * Adds onclick event handler which translates map coords into address - * subscribes on @input address change and on every change calls method to translate address into coords - */ - ngAfterViewInit(): void { - this.settlement$ - .pipe( - takeUntil(this.destroy$), - filter((settlement: Codeficator) => !!settlement) - ) - .subscribe((settlement: Codeficator) => { - this.defaultCoords = { lat: settlement.latitude, lng: settlement.longitude }; - this.map || this.initMap(); - this.flyTo(this.defaultCoords); - - // cheking if there are filtered workshops on the map - if (!!this.filteredWorkshops$) { - this.filteredWorkshops$.pipe(takeUntil(this.destroy$)).subscribe((filteredWorkshops: WorkshopFilterCard) => { - this.workshopMarkers.forEach((workshopMarker: WorkshopMarker) => - this.map.removeLayer(workshopMarker.marker) - ); - this.workshopMarkers = []; - if (filteredWorkshops) { - this.workshops = filteredWorkshops.entities; - filteredWorkshops.entities.forEach((workshop: WorkshopCard) => this.setAddressLocation(workshop.address)); - this.setPrevWorkshopMarker(); - } - }); - } - }); - - // cheking if user edit workshop information - if (this.addressFormGroup) { - this.addressFormGroup.value.latitude && this.setLocation(this.addressFormGroup.value); - - this.addressFormGroup.valueChanges.pipe(debounceTime(500)).subscribe((address: MapAddress) => { - if (!address.street && !address.buildingNumber) { - this.setAddressLocation(address); - } - if (address.codeficatorAddressDto && address.street && address.buildingNumber) { - this.setLocation(address); - } - }); - } - } - /** * uses GoelocationService to translate address into coords and sets marker on efault * @param address - type Address */ setAddressLocation(address: Address): void { - this.workshops ? this.setWorkshopMarkers(address) : this.setNewSingleMarker([address.codeficatorAddressDto.latitude, address.codeficatorAddressDto.longitude]); + this.workshops + ? this.setWorkshopMarkers(address) + : this.setNewSingleMarker([address.codeficatorAddressDto.latitude, address.codeficatorAddressDto.longitude]); } /** * uses GoelocationService to translate coords into address and sets emits event to update address in parent component * @param coords - type Coords */ - setMapLocation(coords: Coords): void { - this.geolocationService.locationDecode(coords, (result: GeolocationAddress) => { - if (result.address || (Array.isArray(result) && result.length)) { - const location = result.address || result[0].properties.address; - const codeficatorAddressDto = { - settlement:location.city || location.village || location.town || location.hamlet - } as Codeficator; - const street = location.road; - const buildingNumber = location.house_number; - const longitude = result.lon || result[0].lon; - const latitude = result.lat || result[0].lat; - this.setAddressEvent.emit({ codeficatorAddressDto, street, buildingNumber, longitude, latitude }); + private setMapLocation(coords: Coords): void { + this.geocoderService.locationDecode(coords, (result: Geocoder) => { + if (result) { + this.addressFormGroup.patchValue(result); } else { - this.setAddressEvent.emit({ - codeficatorAddressDto: null, - street: null, - buildingNumber: null, - }); - } - }); - } - - /** - * uses GeolocationService to translate address into coords and sets marker on default - * @param address - type Address - */ - setLocation(address: MapAddress): void { - this.geolocationService.addressDecode(address, (result: GeolocationAddress) => { - if (result.address || (Array.isArray(result) && result.length)) { - const coords: [number, number] = [result.lat || result[0].lat, result.lon || result[0].lon]; - this.setNewSingleMarker(coords); + this.addressFormGroup.reset(); + this.map.removeLayer(this.singleMarker); } + this.wrongMapAddress.emit(!result); }); } @@ -192,7 +184,7 @@ export class MapComponent { * This method remove existed marker and set the new marke to the map * @param coords - type [number, number] */ - setNewSingleMarker(coords: [number, number]): void { + private setNewSingleMarker(coords: [number, number]): void { this.singleMarker && this.map.removeLayer(this.singleMarker); this.singleMarker = this.createMarker(coords); this.map.addLayer(this.singleMarker); @@ -230,7 +222,10 @@ export class MapComponent { .subscribe((workshop: Workshop) => { const targetMarkers = this.workshopMarkers.filter((workshopMarker: WorkshopMarker) => { const { lat, lng } = workshopMarker.marker.getLatLng(); - return lat === workshop.address.codeficatorAddressDto.latitude && lng === workshop.address.codeficatorAddressDto.longitude; + return ( + lat === workshop.address.codeficatorAddressDto.latitude && + lng === workshop.address.codeficatorAddressDto.longitude + ); }); targetMarkers.forEach((targetMarker: WorkshopMarker) => { targetMarker.isSelected = true; diff --git a/src/app/shared/models/address.model.ts b/src/app/shared/models/address.model.ts index 83d38c03ab..dff4f9ac87 100644 --- a/src/app/shared/models/address.model.ts +++ b/src/app/shared/models/address.model.ts @@ -16,13 +16,4 @@ export class Address { this.id = address.id; } } -} - -export interface MapAddress { - codeficatorAddressDto: Codeficator; - street: string; - buildingNumber: string; - latitude?: number; - longitude?: number; - catottgId?: number; } \ No newline at end of file diff --git a/src/app/shared/models/geolocation.ts b/src/app/shared/models/geolocation.ts index 5eeaf52faa..db96122e87 100644 --- a/src/app/shared/models/geolocation.ts +++ b/src/app/shared/models/geolocation.ts @@ -17,3 +17,21 @@ export interface GeolocationCoordinates { longitude: number; speed: number | null; } + +export interface BaseGeocoder { + catottgId?: number; + street?: string; + buildingNumber?: string; + latitude?: number; + longitude?: number; + isReverse?: boolean; +} +export interface Geocoder extends BaseGeocoder { + latitude?: number; + longitude?: number; +} + +export interface GeocoderDTO extends BaseGeocoder { + lat: number; + lon: number; +} diff --git a/src/app/shared/services/codeficator/codeficator.service.ts b/src/app/shared/services/codeficator/codeficator.service.ts index 549c2555d2..0d45872837 100644 --- a/src/app/shared/services/codeficator/codeficator.service.ts +++ b/src/app/shared/services/codeficator/codeficator.service.ts @@ -1,15 +1,13 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Codeficator, CodeficatorCityDistrict } from '../../models/codeficator.model'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class CodeficatorService { - - constructor(private http: HttpClient) { - } + constructor(private http: HttpClient) {} /** * This method to get all Codeficators from the database @@ -34,4 +32,17 @@ export class CodeficatorService { searchCodeficatorCityDistrict(id: number): Observable { return this.http.get(`/api/v1/Codeficator/children?id=${id}`); } + + /** + * This method to get teh nearst settlemnt by coordinates + * @param lat number + * @param lon number + */ + getNearestByCoordinates(lat: number, lon: number): Observable { + let params = new HttpParams(); + params = params.set('Lat', lat.toString()); + params = params.set('Lon', lon.toString()); + + return this.http.get(`/api/v1/Codeficator/NearestByCoordinates`, { params }); + } } diff --git a/src/app/shared/services/detected-device.service.spec.ts b/src/app/shared/services/detected-device/detected-device.service.spec.ts similarity index 100% rename from src/app/shared/services/detected-device.service.spec.ts rename to src/app/shared/services/detected-device/detected-device.service.spec.ts diff --git a/src/app/shared/services/detected-device.service.ts b/src/app/shared/services/detected-device/detected-device.service.ts similarity index 100% rename from src/app/shared/services/detected-device.service.ts rename to src/app/shared/services/detected-device/detected-device.service.ts diff --git a/src/app/shared/services/feature-management/feature-management.service.ts b/src/app/shared/services/feature-management/feature-management.service.ts index d46cebdde2..25610688a2 100644 --- a/src/app/shared/services/feature-management/feature-management.service.ts +++ b/src/app/shared/services/feature-management/feature-management.service.ts @@ -4,17 +4,15 @@ import { Observable } from 'rxjs'; import { FeaturesList } from '../../models/featuresList.model'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class FeatureManagementService { + constructor(private http: HttpClient) {} - constructor(private http: HttpClient) { } - - /** + /** * This method get features flags depending on releases */ - getFeaturesList(): Observable { - return this.http.get('/api/v1/FeatureManagement/Get'); - } - + getFeaturesList(): Observable { + return this.http.get('/api/v1/FeatureManagement/Get'); + } } diff --git a/src/app/shared/services/geolocation/geocoder.service.ts b/src/app/shared/services/geolocation/geocoder.service.ts index af78ecb959..d5ba7e9650 100644 --- a/src/app/shared/services/geolocation/geocoder.service.ts +++ b/src/app/shared/services/geolocation/geocoder.service.ts @@ -1,77 +1,51 @@ -import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { tap } from 'rxjs/operators'; +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Geocoder } from '../../models/geolocation'; import { GeolocationAddress } from '../../models/geolocationAddress.model'; +import { Coords } from '../../models/coords.model'; +import { GeocoderDTO } from './../../models/geolocation'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) - export class GeocoderService { - /** - * Implementation of the [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) geocoder. - * - * [Nominatim Documentation](https://nominatim.org/release-docs/latest/api/Search/) - * - * [Nominatim usage policy](https://operations.osmfoundation.org/policies/nominatim/). - */ - private static url = 'https://nominatim.openstreetmap.org/'; + constructor(private http: HttpClient) {} /** - * Looks up a location from a textual description or address. - * - * @param http HttpClient instance - * @param query address description - * @param lang language code - * @returns response or reverse function + * returns a coordinates from codeficator address. + * + * @param address - Geocoder + * @param callback - Function, which receives 1 argument of type Address */ - public static geocode(http?: HttpClient, query?: string, lang?: string): { reverse: Function } | Observable | any { - return query ? - http.get(GeocoderService.url, - { - headers: GeocoderService.getHeaders(lang), - params: new HttpParams() - .set('q', query) - .set('limit', '5') - .set('format', 'json') - .set('addressdetails', '1') - } - ) : - { - reverse: GeocoderService.reverse - }; + addressDecode(address: Geocoder, callback: (GeolocationAddress) => void): void { + this.geocode({ + catottgId: address.catottgId, + street: address.street, + buildingNumber: address.buildingNumber, + }).subscribe((result: Geocoder) => callback(result)); } - /** - * Reverse geocoding generates an address from a latitude and longitude. - * - * @param http HttpClient instance - * @param lat latitude - * @param lon longitude - * @param lang language code - * @returns response - */ - private static reverse(http: HttpClient, lat: string, lon: string, lang: string): Observable { - return http.get(GeocoderService.url + `reverse`, - { - headers: GeocoderService.getHeaders(lang), - params: new HttpParams() - .set('lat', lat) - .set('lon', lon) - .set('format', 'json') - } - ); + locationDecode(coords: Coords, callback: (GeolocationAddress) => void): void { + this.geocode({ + latitude: coords.lat, + longitude: coords.lng, + isReverse: true, + }).subscribe((result: Geocoder) => callback(result)); } /** - * Generates Accept-Language header with specific language code - * - * @param lang language code - * @returns HttpHeaders + * This method get geolocation for map */ - private static getHeaders(lang: string): HttpHeaders { - return new HttpHeaders({ - 'Accept-Language': lang - }); + private geocode(payload: Geocoder): Observable { + return this.http + .post('/api/v1/Geocoding', { ...payload, lat: payload.latitude, lon: payload.longitude }) + .pipe( + map((result: GeocoderDTO) => { + return result ? { ...result, latitude: result.lat, longitude: result.lon } : null; + }) + ); } } diff --git a/src/app/shared/services/geolocation/geolocation.service.ts b/src/app/shared/services/geolocation/geolocation.service.ts index aa622872a0..a9f0efce3b 100644 --- a/src/app/shared/services/geolocation/geolocation.service.ts +++ b/src/app/shared/services/geolocation/geolocation.service.ts @@ -1,42 +1,29 @@ +import { CodeficatorService } from './../codeficator/codeficator.service'; import { ConfirmCity, SetCity } from './../../store/filter.actions'; import { Store } from '@ngxs/store'; import { Injectable } from '@angular/core'; import { Coords } from '../../models/coords.model'; import { GeolocationPositionError, GeolocationPosition } from '../../models/geolocation'; -import { GeocoderService } from './geocoder.service'; -import { HttpClient } from '@angular/common/http'; import { GeolocationAddress } from '../../models/geolocationAddress.model'; -import { Address } from '../../models/address.model'; import { Constants } from '../../constants/constants'; import { Codeficator } from '../../models/codeficator.model'; - @Injectable({ - providedIn: 'root' + providedIn: 'root', }) - export class GeolocationService { - userCoords = { - lat: null, - lng: null, - city: '' - }; - - constructor(public store: Store, private http: HttpClient) { } + constructor( + private store: Store, + private codeficatorService: CodeficatorService, + ) {} /** * This method sets default city Kyiv in localStorage if user deny geolocation */ confirmCity(settlement: Codeficator): void { - !!localStorage.getItem('cityConfirmation') ? - this.store.dispatch([ - new SetCity(JSON.parse(localStorage.getItem('cityConfirmation'))), - new ConfirmCity(true), - ]) : - this.store.dispatch([ - new SetCity(settlement), - new ConfirmCity(false), - ]); + !!localStorage.getItem('cityConfirmation') + ? this.store.dispatch([new SetCity(JSON.parse(localStorage.getItem('cityConfirmation'))), new ConfirmCity(true)]) + : this.store.dispatch([new SetCity(settlement), new ConfirmCity(false)]); } navigatorRecievedError(err: GeolocationPositionError): void { @@ -66,31 +53,13 @@ export class GeolocationService { } /** - * translates coords into address - * + * translates coords into codeficator address for filtering workshops * @param coords - Coords * @param callback - Function, which receives 1 argument of type Address */ - locationDecode(coords: Coords, callback: (GeolocationAddress) => void): void { - GeocoderService - .geocode() - .reverse(this.http, coords.lat, coords.lng, 'uk-UA, uk') - .subscribe((result: GeolocationAddress) => { // TODO: create enum for accept language param - callback(result); - }); - } - - /** - * returns a location from a textual description or address. - * - * @param address - Address - * @param callback - Function, which receives 1 argument of type Address - */ - addressDecode(address: Address, callback: (GeolocationAddress) => void): void { - GeocoderService - .geocode(this.http, `${address.codeficatorAddressDto.settlement}+${address.street}+${address.buildingNumber}`, 'uk-UA, uk') - .subscribe((result: GeolocationAddress) => { // TODO: create enum for accept language param - callback(result); - }); + getNearestByCoordinates(coords: Coords, callback: (GeolocationAddress) => void): void { + this.codeficatorService + .getNearestByCoordinates(coords.lat, coords.lng) + .subscribe((result: Codeficator) => callback(result)); } } diff --git a/src/app/shared/services/signalR/signal-r.service.ts b/src/app/shared/services/signalR/signal-r.service.ts index 07e908e7f9..9ebc721229 100644 --- a/src/app/shared/services/signalR/signal-r.service.ts +++ b/src/app/shared/services/signalR/signal-r.service.ts @@ -29,7 +29,6 @@ export class SignalRService { this.hubConnection .start() - .then(() => console.log('Connection started')) .catch(err => console.error('Error while starting connection: ' + err)); this.hubConnection.on("ReceiveNotification", (notification: Notification) => { diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 51bee3d649..486a69fc3f 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -283,7 +283,6 @@ export class AdminState { @Action(OnDeleteDirectionSuccess) onDeleteDirectionSuccess({ dispatch }: StateContext, { payload }: OnDeleteDirectionSuccess): void { - console.log('Direction is deleted', payload); dispatch([new ShowMessageBar({ message: 'Напрямок видалено!', type: 'success' }), new GetFilteredDirections()]); } @@ -312,7 +311,6 @@ export class AdminState { ]); patchState({ direction: payload }); this.location.back(); - console.log('Direction is created', payload); } @Action(UpdateDirection) updateDirection( @@ -340,7 +338,6 @@ export class AdminState { new GetFilteredDirections(), ]); this.location.back(); - console.log('Direction is updated', payload); } @Action(GetDirectionById) diff --git a/src/app/shared/store/registration.state.ts b/src/app/shared/store/registration.state.ts index 8bbb9f996d..62a979048c 100644 --- a/src/app/shared/store/registration.state.ts +++ b/src/app/shared/store/registration.state.ts @@ -153,7 +153,6 @@ export class RegistrationState { @Action(OnAuthFail) onAuthFail(): void { - console.log('Authorization failed'); this.snackBar.open("Упс! Перевірте з'єднання", '', { duration: 5000, panelClass: ['red-snackbar'], diff --git a/src/app/shared/store/user.state.ts b/src/app/shared/store/user.state.ts index 53d329daaf..c629b417c5 100644 --- a/src/app/shared/store/user.state.ts +++ b/src/app/shared/store/user.state.ts @@ -374,7 +374,6 @@ export class UserState { { id, parameters }: GetApplicationsByProviderId ): Observable { patchState({ isLoading: true }); - console.log(parameters); return this.applicationService .getApplicationsByProviderId(id, parameters) @@ -467,7 +466,6 @@ export class UserState { ): void { const message = Util.getWorkshopMessage(payload); patchState({ isLoading: false }); - console.log('Workshop is created', payload); dispatch([ new MarkFormDirty(false), new ShowMessageBar({ message: message.text, type: message.type }), @@ -491,7 +489,6 @@ export class UserState { @Action(OnDeleteWorkshopSuccess) onDeleteWorkshopSuccess({ dispatch }: StateContext, { payload }: OnDeleteWorkshopSuccess): void { - console.log('Workshop is deleted', payload); dispatch([ new ShowMessageBar({ message: `Дякуємо! Гурток "${payload.title}" видалено!`, @@ -517,7 +514,6 @@ export class UserState { @Action(OnCreateChildrenSuccess) onCreateChildrenSuccess({ dispatch }: StateContext, { payload }: OnCreateChildrenSuccess): void { - console.log('Child is created', payload); dispatch([ new ShowMessageBar({ message: 'Дякуємо! Дитина була успішно додана.', @@ -550,7 +546,6 @@ export class UserState { @Action(OnCreateProviderSuccess) onCreateProviderSuccess({ dispatch }: StateContext, { payload }: OnCreateProviderSuccess): void { dispatch(new GetProfile()).subscribe(() => this.router.navigate([''])); - console.log('Provider is created', payload); dispatch([ new ShowMessageBar({ message: 'Організацію успішно створено', @@ -672,7 +667,6 @@ export class UserState { { dispatch }: StateContext, { payload }: OnCreateAchievementSuccess ): void { - console.log('Achievement is created', payload); dispatch([new ShowMessageBar({ message: 'Новe Досягнення додано!', type: 'success' }), new MarkFormDirty(false)]); this.router.navigate(['/details/workshop/', payload.workshopId]); } @@ -711,7 +705,6 @@ export class UserState { { dispatch }: StateContext, { payload }: OnCreateApplicationSuccess ): void { - console.log('Application is created', payload); dispatch([new ShowMessageBar({ message: 'Заявку створено!', type: 'success' }), new MarkFormDirty(false)]); this.router.navigate(['']); } @@ -742,7 +735,6 @@ export class UserState { { dispatch }: StateContext, { payload }: OnDeleteAchievementSuccess ): void { - console.log('Child is deleted', payload); dispatch([ new ShowMessageBar({ message: 'Досягнення видалено!', type: 'success' }), new GetUsersChildren(), @@ -758,7 +750,6 @@ export class UserState { @Action(OnDeleteChildSuccess) onDeleteChildSuccess({ dispatch }: StateContext, { payload }: OnDeleteChildSuccess): void { - console.log('Child is deleted', payload); dispatch([new ShowMessageBar({ message: 'Дитину видалено!', type: 'success' }), new GetUsersChildren()]); } @@ -812,14 +803,12 @@ export class UserState { @Action(OnUpdateWorkshopSuccess) onUpdateWorkshopSuccess({ dispatch }: StateContext, { payload }: OnUpdateWorkshopSuccess): void { const message = Util.getWorkshopMessage(payload); - console.log('Workshop is updated', payload); dispatch([new MarkFormDirty(false), new ShowMessageBar({ message: message.text, type: message.type })]); this.router.navigate(['/personal-cabinet/provider/workshops']); } @Action(OnUpdateChildSuccess) onUpdateChildSuccess({ dispatch }: StateContext, { payload }: OnUpdateChildSuccess): void { - console.log('Child is updated', payload); dispatch([ new MarkFormDirty(false), new ShowMessageBar({ @@ -851,7 +840,6 @@ export class UserState { @Action(OnUpdateProviderSuccess) onUpdateProviderSuccess({ dispatch }: StateContext, { payload }: OnUpdateProviderSuccess): void { dispatch(new MarkFormDirty(false)); - console.log('Provider is updated', payload); dispatch([ new ShowMessageBar({ message: 'Організація успішно відредагована', @@ -947,7 +935,6 @@ export class UserState { @Action(OnCreateRatingSuccess) onCreateRatingSuccess({ dispatch }: StateContext, { payload }: OnCreateRatingSuccess): void { - console.log('Rate is created', payload); dispatch( new ShowMessageBar({ message: 'Оцінка успішно поставлена!', @@ -1040,7 +1027,6 @@ export class UserState { new MarkFormDirty(false), new ShowMessageBar({ message: 'Користувач успішно заблокований', type: 'success' }), ]); - console.log('parent is blocked', payload); } @Action(UnBlockParent) @@ -1071,7 +1057,6 @@ export class UserState { new MarkFormDirty(false), new ShowMessageBar({ message: 'Користувач успішно розблокований', type: 'success' }), ]); - console.log('parent is unBlocked', payload); } @Action(GetBlockedParents) diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.html index b945054812..3759195e60 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.html @@ -8,8 +8,11 @@

Або позначте на карті

-
- + +
+ Такої адреси не було знайдено на карті
diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.scss b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.scss index 6b7b56ee8c..490b29f940 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.scss +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.scss @@ -13,4 +13,11 @@ margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 2px solid #E3E3E3; +} +.warning{ + margin: 1rem; + text-align: center; + display: block; + color: red; + font-size: 10px; } \ No newline at end of file diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.spec.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.spec.ts index cf9e844ba9..15e401ebed 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.spec.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.spec.ts @@ -51,8 +51,6 @@ describe('CreateWorkshopAddressComponent', () => { }) class MockMapComponent { @Input() addressFormGroup: FormGroup; - @Input() isCreateWorkShops: boolean; - @Input() workshops: Workshop[]; } @Component({ selector: 'app-create-address-form', diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.ts index f97a623ef1..80727a7ed4 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop-address/create-workshop-address.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; -import { Address, MapAddress } from 'src/app/shared/models/address.model'; +import { Address } from 'src/app/shared/models/address.model'; import { FormValidators, ValidationConstants } from 'src/app/shared/constants/validation'; @Component({ @@ -12,10 +12,12 @@ export class CreateWorkshopAddressComponent implements OnInit { readonly validationConstants = ValidationConstants; @Input() address: Address; + @Output() passAddressFormGroup = new EventEmitter(); addressFormGroup: FormGroup; searchFormGroup: FormGroup; + noAddressFound = false; constructor(private formBuilder: FormBuilder) {} @@ -24,6 +26,8 @@ export class CreateWorkshopAddressComponent implements OnInit { street: new FormControl('', FormValidators.defaultAddressValidators), buildingNumber: new FormControl('', FormValidators.defaultAddressValidators), catottgId: new FormControl('', Validators.required), + latitude: new FormControl(''), + longitude: new FormControl(''), }); this.searchFormGroup = this.formBuilder.group({ settlementSearch: new FormControl('', FormValidators.defaultSearchValidators), @@ -32,7 +36,10 @@ export class CreateWorkshopAddressComponent implements OnInit { this.passAddressFormGroup.emit(this.addressFormGroup); } - onSetMapAddress(address: MapAddress): void { - + onWrongAddressSelect(result: boolean): void { + this.noAddressFound = result; + if (!result) { + this.searchFormGroup.reset(); + } } } diff --git a/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/child-info-box/child-info-box.component.ts b/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/child-info-box/child-info-box.component.ts index b351c58440..b0cdb44c3b 100644 --- a/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/child-info-box/child-info-box.component.ts +++ b/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/child-info-box/child-info-box.component.ts @@ -1,8 +1,8 @@ import { Component, Input, OnInit } from '@angular/core'; +import { DetectedDeviceService } from 'src/app/shared/services/detected-device/detected-device.service'; import { Constants } from '../../../../../../shared/constants/constants'; import { Gender } from '../../../../../../shared/enum/gender'; import { Child } from '../../../../../../shared/models/child.model'; -import { DetectedDeviceService } from '../../../../../../shared/services/detected-device.service'; import { Util } from '../../../../../../shared/utils/utils'; @Component({ diff --git a/src/app/shell/shell.component.ts b/src/app/shell/shell.component.ts index a7f319ecaf..9a87e5cd1e 100644 --- a/src/app/shell/shell.component.ts +++ b/src/app/shell/shell.component.ts @@ -1,3 +1,4 @@ +import { Codeficator } from './../shared/models/codeficator.model'; import { Observable, Subject } from 'rxjs'; import { GetFavoriteWorkshopsByUserId } from './../shared/store/user.actions'; import { Select, Store } from '@ngxs/store'; @@ -12,42 +13,26 @@ import { Role } from '../shared/enum/role'; @Component({ selector: 'app-shell', templateUrl: './shell.component.html', - styleUrls: ['./shell.component.scss'] + styleUrls: ['./shell.component.scss'], }) export class ShellComponent implements OnInit, OnDestroy { @Select(RegistrationState.role) role$: Observable; destroy$: Subject = new Subject(); - constructor( - private geolocationService: GeolocationService, - private store: Store - ) { } + constructor(private geolocationService: GeolocationService, private store: Store) {} ngOnInit(): void { this.geolocationService.handleUserLocation((coords: Coords) => { - coords && this.geolocationService.locationDecode(coords, (result) => { - this.geolocationService.confirmCity({ - longitude: coords.lng, - latitude: coords.lat, - settlement: result.address.city || result.address.town || result.address.village || result.address.hamlet, - id: null, - category: null, - territorialCommunity: '', - cityDistrict: '', - fullName: '' + coords && + this.geolocationService.getNearestByCoordinates(coords, (result: Codeficator) => { + this.geolocationService.confirmCity(result); }); - }); }); - this.role$ - .pipe(takeUntil(this.destroy$)) - .subscribe((role: string) => { - (role == Role.parent) && this.store.dispatch([ - new GetFavoriteWorkshops(), - new GetFavoriteWorkshopsByUserId() - ]); - }) + this.role$.pipe(takeUntil(this.destroy$)).subscribe((role: string) => { + role == Role.parent && this.store.dispatch([new GetFavoriteWorkshops(), new GetFavoriteWorkshopsByUserId()]); + }); } ngOnDestroy(): void { diff --git a/src/main.ts b/src/main.ts index 271ee657ea..59758a943a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,13 +1,12 @@ import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; if (environment.production) { - window.console.log = () => { }; enableProdMode(); } -platformBrowserDynamic().bootstrapModule(AppModule) +platformBrowserDynamic() + .bootstrapModule(AppModule) .catch(err => console.error(err));