diff --git a/src/app/community/community.component.html b/src/app/community/community.component.html index 3bf70cdb946ae6b9bb5b467f51bb0ba958d4ab5a..4bb3ed2dfd41bd589c898eeb353cb1514a20d596 100644 --- a/src/app/community/community.component.html +++ b/src/app/community/community.component.html @@ -14,8 +14,9 @@ alt="user" width="50" class="rounded-circle">
-
{{ user }}
{{time | date:"yyyy-MM-dd"}} +
{{ user }}
+ + {{time | date:"yyyy-MM-dd"}}

{{ message }}

@@ -105,4 +106,4 @@ - \ No newline at end of file + diff --git a/src/app/maps/maps.component.css b/src/app/maps/maps.component.css index a8de609d1cd490bff1c90586923834439216be86..258a0856163687f989df2c1f438eaf0a1ae87414 100644 --- a/src/app/maps/maps.component.css +++ b/src/app/maps/maps.component.css @@ -10,3 +10,30 @@ agm-map { width: 100%; background-color: lightblue; } + +.description { + width: 100%; + background-color: lightgreen +} + +.content-header { + background-color: gray; + padding: 20px 0px 10px 0px; + align-items: middle; + font-size: 18pt; +} + +.content-grid { + display: grid; + grid-template-columns: repeat(3, 1fr); +} + +.content-grid > * { + padding: 5px; + background-color: whitesmoke; + border-radius: 5px; +} + +.content-grid > * > p { + word-wrap: break-word; +} diff --git a/src/app/maps/maps.component.html b/src/app/maps/maps.component.html index 8bbfc62c6b5044a809d83de0f9a93393017c4fb5..50c5c80c30b1c44aa7408be0fe1fe09595428a9f 100644 --- a/src/app/maps/maps.component.html +++ b/src/app/maps/maps.component.html @@ -21,19 +21,28 @@ {{ place.address }}
{{ place.postalCode }}
{{ place.city }}
- MAP.WEBSITE - -
- {{ 'MAP.WHO' | translate }} :
- {{ place.type }}
-

- + MAP.WEBSITE
+ {{ place.tel }}
+ {{ 'MAP.WHO' | translate }} : {{ place.type }}
-
-

{{d.name}}
{{d.address}}
{{d.postal_code}} {{ d.city }}
{{ d.tel }}
{{ d.website }}

+
+

{{t.key}}

+

MAP.UNCATEGORIZED

+
+
+

+ {{d.name}}
+ {{d.address}}
+ {{d.postalCode}} {{ d.city }}
+ {{ d.tel }}
+ MAP.WEBSITE
+ {{ 'MAP.DESCRIPTION' | translate }} : {{ d.description }}
+

+
+
diff --git a/src/app/maps/maps.component.ts b/src/app/maps/maps.component.ts index 133662f1ec98d951af017ea85761a6aeb39b1eb2..feb31c3f0d8d4fd101ffc8acd6f9a4e09659cd0a 100644 --- a/src/app/maps/maps.component.ts +++ b/src/app/maps/maps.component.ts @@ -7,7 +7,6 @@ import { TranslateService } from '@ngx-translate/core'; import { FirebaseDataService } from '../services/firebase-data.service'; import { MapPoint } from '../interfaces/map-point'; - @Component({ selector: 'app-maps', templateUrl: './maps.component.html', @@ -20,8 +19,10 @@ export class MapsComponent implements OnInit { cantonCenter: Location = { lat: 46.9479222, lng: 7.4446085 }; translate: TranslateService; + typeMap: {}; + cantonSelected = ''; - cantons = this.firebase.getCantons(); + cantons = this.firebaseDB.getCantons(); cantonData: MapPoint[] = []; regex: RegExp = /\(([^()]*)\)/g; @@ -30,7 +31,7 @@ export class MapsComponent implements OnInit { private geocodeService: GeocodeService, private ref: ChangeDetectorRef, public lang: LangService, - private firebase: FirebaseDataService) { + private firebaseDB: FirebaseDataService) { this.translate = lang.getTranslateService(); this.mapsAPI.load().then(() => { }); } @@ -42,9 +43,9 @@ export class MapsComponent implements OnInit { this.cantonCenter = location; } else { const point: MapPoint = this.cantonData.filter((e) => e.address == address && e.city == city && e.postalCode == cp)[0]; - // Update db point.latitude = '' + location.lat; point.longitude = '' + location.lng; + this.firebaseDB.updatePoint(point); } this.ref.detectChanges(); } @@ -60,7 +61,6 @@ export class MapsComponent implements OnInit { (e: MapPoint) => e.address !== '' && e.postalCode !== '' && e.city !== '' && e.latitude === '' && e.longitude === '' ).forEach((e: MapPoint) => { this.getLocation(e.address, e.postalCode, e.city, false); - console.log(e); }); } else { this.centersFound = false; @@ -71,8 +71,13 @@ export class MapsComponent implements OnInit { this.cantonSelected = this.cantons[value]; if (this.cantonSelected.match(this.regex) !== null) { const abbr = this.cantonSelected.match(this.regex)[0].substring(1, 3); - this.cantonData = await this.firebase.getCantonData(abbr); - console.log(this.cantonSelected, this.cantonData); + this.cantonData = await this.firebaseDB.getCantonData(abbr); + this.typeMap = {}; + for (const t of this.cantonData) { + (!(t.type in this.typeMap)) ? this.typeMap[t.type] = [] : null; + this.typeMap[t.type].push(t); + } + console.log(this.typeMap); } this.getPosition(); } diff --git a/src/app/services/firebase-data.service.ts b/src/app/services/firebase-data.service.ts index 34ef318c055aee6f0a850efb49add37d7cde3313..51cae1a70d2cf6b626d9f873f0addaa639733a9c 100644 --- a/src/app/services/firebase-data.service.ts +++ b/src/app/services/firebase-data.service.ts @@ -28,4 +28,20 @@ export class FirebaseDataService { return results; } + + async updatePoint(point: MapPoint) { + const ref = this.firebaseDB.database.ref('data/safe-spaces'); + ref.orderByChild('name') + .equalTo(point.name) + .orderByChild('address') + .equalTo(point.address) + .orderByChild('postalCode') + .equalTo(point.postalCode) + .once('value', (snapshot: firebase.database.DataSnapshot) => { + snapshot.forEach((s) => { + s.ref.update({ latitude: parseFloat(point.latitude), longitude: parseFloat(point.longitude) }); + }); + } + ); + } } diff --git a/src/app/services/geocode.service.ts b/src/app/services/geocode.service.ts index 83ee1fbb52269e8c7154f63c03e517117aff59df..2aa6de6433df8cb508cb50c98f540a30755ffc6d 100644 --- a/src/app/services/geocode.service.ts +++ b/src/app/services/geocode.service.ts @@ -9,44 +9,41 @@ declare var google: any; @Injectable() export class GeocodeService { private geocoder: any; - + constructor(private mapLoader: MapsAPILoader) {} - + private initGeocoder() { - console.log('Init geocoder!'); this.geocoder = new google.maps.Geocoder(); } - + private waitForMapsToLoad(): Observable { - if(!this.geocoder) { + if (!this.geocoder) { return from(this.mapLoader.load()) - .pipe( - tap(() => this.initGeocoder()), - map(() => true) + .pipe( + tap(() => this.initGeocoder()), + map(() => true) ); - } - return of(true); } - - geocodeAddress(location: string): Observable { - console.log('Start geocoding!'); - return this.waitForMapsToLoad().pipe( - switchMap(() => { - return new Observable(observer => { - this.geocoder.geocode({'address': location}, (results, status) => { - if (status == google.maps.GeocoderStatus.OK) { - console.log('Geocoding complete!'); - observer.next({ - lat: results[0].geometry.location.lat(), - lng: results[0].geometry.location.lng() - }); - } else { - console.log('Error - ', results, ' & Status - ', status); - observer.next({lat: 0, lng: 0}); - } - }); - }) - }) - )} - - } \ No newline at end of file + return of(true); + } + + geocodeAddress(location: string): Observable { + return this.waitForMapsToLoad().pipe( + switchMap(() => { + return new Observable(observer => { + this.geocoder.geocode({ address: location }, (results, status) => { + if (status == google.maps.GeocoderStatus.OK) { + observer.next({ + lat: results[0].geometry.location.lat(), + lng: results[0].geometry.location.lng() + }); + } else { + console.log('Error - ', results, ' & Status - ', status); + observer.next({lat: 0, lng: 0}); + } + }); + }); + }) + ); + } +} diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index c9298017c0851a24169280d9267650ad1c464c4e..1ac1d968e86b09d13876d1799c52c3b13f54f42b 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -54,7 +54,9 @@ "CANTONOF": "Kanton", "SORRY": "Es tut uns leid, aber diese Seite ist eine Demo. Die Daten f\u00fcr diesen Kanton k\u00f6nnen nicht geladen werden", "WEBSITE": "Webseite", - "WHO": "Für wen" + "WHO": "Für wen", + "DESCRIPTION": "Beschreibung", + "UNCATEGORIZED": "Unkategorisiert" }, "FILES": { "TEST": "test.png" diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 2bcb270cf9dec069660ae40e82fbab1553f7810f..d0c4fb70560934f45abb4d53567e18f5524c90a0 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -54,7 +54,9 @@ "CANTONOF": "Canton of", "SORRY": "Sorry, this site is a demo. The data for your canton could not be loaded.", "WEBSITE": "Website", - "WHO": "Who for" + "WHO": "Who for", + "DESCRIPTION": "Description", + "UNCATEGORIZED": "Uncategorized" }, "FILES": { "TEST": "test.png" diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json index a09cde9440c7c2109499afe35def24edd78613de..f44dcfa7a977fd7b84b23f9fb5cd6f202e4e4c08 100644 --- a/src/assets/i18n/fr.json +++ b/src/assets/i18n/fr.json @@ -54,7 +54,9 @@ "CANTONOF": "Canton de", "SORRY": "Nous sommes d\u00e9sol\u00e9s, ce site est une d\u00e9mo. Nous n'avons pas encore pu charger les donn\u00e9es de votre canton.", "WEBSITE": "Site Web", - "WHO": "Pour qui" + "WHO": "Pour qui", + "DESCRIPTION": "Description", + "UNCATEGORIZED": "Non class\u00e9" }, "FILES": { "TEST": "test.png" diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index 2f84c883b14f57dbd9183d7c415ac7be96eb7ded..98a0cf0a8bab75fc56955fbb6f4975993057fb89 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -54,7 +54,9 @@ "CANTONOF": "Cantone di", "SORRY": "Siamo spiacenti, questo sito \u00e9 una demo. Non siamo stati in grado di caricare i dati del tuo cantone", "WEBSITE": "Sito Internet", - "WHO": "Per chi" + "WHO": "Per chi", + "DESCRIPTION": "Descrizione", + "UNCATEGORIZED": "Senza categoria" }, "FILES": { "TEST": "test.png"