Commit e50d4ea3 authored by Sebastian's avatar Sebastian

kontaktformular funktioniert jetzt, elemente in search-komponente jetzt verlinkbar.

parent 70154b87
......@@ -63,7 +63,6 @@ export class AuthComponent implements OnInit {
if(this.asModal){
setTimeout(
()=>{
console.log("params:"+JSON.stringify(this.routeParams,null,3));
switch(this.routeParams['redirectTo']){
case 'entryedit':{
......
<div class="widget-wrap big-widget">
<div class="container contact pagecontainer">
<div *ngIf="sent">
<h1>Vielen Dank für deine Nachricht</h1>
<p>Wir werden uns so bald wir möglich mit deiner Anfrage oder deinem Feedback beschäftigen.</p>
<p>
</div>
<div *ngIf="!sent" class="container contact pagecontainer">
<form (ngSubmit)="onSubmit()" [formGroup]="contactform">
<app-formcontrol-block [controlname]="'name'" [labelname]="'Name*'">
<input type="text" id="name" formControlName="name" class="form-control">
......
......@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { FormBuilder } from '@angular/forms';
import { Validators } from '@angular/forms';
import { GeoportalApiService } from '../../services/geoportal-api.service';
import { LogService } from '../../services/log.service';
@Component({
selector: 'app-contact',
......@@ -18,13 +20,26 @@ export class ContactComponent implements OnInit {
datenschutz: ['', Validators.requiredTrue],
newsletter: ['']
});
constructor(private fb: FormBuilder) { }
sent:boolean = false;
constructor(private fb: FormBuilder, private api: GeoportalApiService, private logger: LogService) {
this.sent=false;
}
ngOnInit() {
}
onSubmit(){
console.log(this.contactform.value);
this.api.sendContactForm(this.contactform.value).subscribe(
(success)=>{
this.sent = true;
console.log(success);
window.scrollTo(0,0);
},
(error)=>{
this.logger.notify('error','Failed to send message.');
console.log("Error sending message: "+JSON.stringify(error));
}
);
}
}
import { Component, OnInit } from '@angular/core';
import { DatePipe } from '@angular/common';
import { Router } from '@angular/router';
import { Router,ActivatedRoute,Params, RoutesRecognized } from '@angular/router';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { OverpassService } from '../services/overpass.service';
import { GeoportalApiService } from '../services/geoportal-api.service';
......@@ -52,6 +52,8 @@ export class SearchComponent implements OnInit {
descCollapsed = true;
nutritionCollapsed = true;
elementAppsCollapsed = true;
private routeParams:any = null;
constructor(
private nodeService : OsmNodeService,
private formBuilder : FormBuilder,
......@@ -63,7 +65,8 @@ export class SearchComponent implements OnInit {
private authService : AuthService,
private spinner : NgxSpinnerService,
private nominatimService : NominatimService,
private router : Router
private router : Router,
private activeRoute: ActivatedRoute
) {
registerLocaleData(localeDe, 'de');
......@@ -83,8 +86,35 @@ export class SearchComponent implements OnInit {
}else{
this.logger.debug("user is not logged in.");
}
this.activeRoute.params.subscribe(
(data)=>{
console.log("got route parameters.");
console.log(JSON.stringify(data));
if(data['elementId']){
let node = OsmNodeFactory.getNodeById(data['elementId']);
if(node == null){
console.log("fetching element from server.");
this.apiService.getGeoElementById(data['elementId']).subscribe(
(element)=>{
let node = OsmNodeFactory.create(element);
this.nodeService.showDetails(node);
}
);
}else{
console.log("already have element.");
}
}else{
if(data['osmId'] && data['osmType']){
this.apiService.getGeoElementByOsmId(data['osmId'],data['osmType']).subscribe(
(element)=>{
let node = OsmNodeFactory.create(element);
this.nodeService.showDetails(node);
}
);
}
}
}
);
}
termChanged(event){
console.log("Event: "+event);
......
......@@ -87,6 +87,11 @@ export class GeoportalApiService {
);
}
sendContactForm(msg:any):Observable<any>
{
let request = this.http.post<any>(this.apiURL+'/contact/',msg,this.httpOptions);
return request;
}
registerUser(user: User): Observable<User> {
let post = this.http.post<User>(this.apiURL + '/accounts/register/', user, this.httpOptions);
return post;
......@@ -156,7 +161,11 @@ export class GeoportalApiService {
if (node == null) {
this.logger.debug("Cannot get element from server: argument is null");
}
let osmData = this.parseOsmId(node, type);
if(!osmData.osmtype.endsWith('s')){
osmData.osmtype+="s";
}
if (this.isValidOsmType(osmData.osmtype)) {
return this.http.get(this.apiURL + "/GeoElements/byOsmId/" + osmData.osmtype + "/" + osmData.osmid + "/", this.httpOptions);
}
......@@ -272,12 +281,12 @@ export class GeoportalApiService {
return (osmType != "" && osmType != null && osmType != undefined); //haesslig lange abfrage, lieber in eigene methode
}
private parseOsmId(node: OsmNode | number, type?: string) {
let osmType = "";
let osmId = -1;
if (node instanceof OsmNode) {
var types = [
{typeInNode: "way", typeOutput: "ways"},
{typeInNode: "node", typeOutput: "nodes"},
......@@ -301,6 +310,8 @@ export class GeoportalApiService {
}
return resultType;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment