Commit 71ed431c authored by lanpodder's avatar lanpodder

Kontaktseite und Quellenangaben hinzugefügt. Backend anpassung notwendig

parent 5c69b7b0
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\app-routing.module.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
\ No newline at end of file
......@@ -68,7 +68,8 @@ import { OsminformationComponent } from './widgets/entry/osminformation/osminfor
import { GoodplaceComponent } from './widgets/entry/goodplace/goodplace.component';
import { EditsourceComponent } from './widgets/modals/editsource/editsource.component';
import { DatenexportSeiteComponent } from './datenexport-seite/datenexport-seite.component';
import { QuellenAngabeComponent } from './widgets/entry/quellen-angabe/quellen-angabe.component';
import { QuellenAngabeComponent } from './widgets/entry/quellen-angabe/quellen-angabe.component';
import { FormcontrolBlockComponent } from './home/contact/formcontrol-block/formcontrol-block.component';
enableProdMode();
......@@ -127,6 +128,7 @@ enableProdMode();
EditsourceComponent,
DatenexportSeiteComponent,
QuellenAngabeComponent,
FormcontrolBlockComponent,
//MatAutocompleteModule,
],
imports: [
......
......@@ -16,6 +16,7 @@ export class DatenexportSeiteComponent implements OnInit {
exportUrl: string;
//die namen die am ende als json namen reinkommen
exportFieldItems: {
name: string
}[] = [
......@@ -62,17 +63,16 @@ export class DatenexportSeiteComponent implements OnInit {
}
submitExportForm(){ //communication with service or api here
var exportVars = []
exportVars.push(this.exportFormGroup.get('formatFields').value);
var exportJson = {};
exportJson['format'] = this.exportFormGroup.get('formatFields').value;
this.exportFields.controls.forEach(
(item, index) => {
if(item.value === true){
exportVars.push(this.exportFieldItems[index].name);
exportJson[this.exportFieldItems[index].name] = item.value;
}
}
);
console.log(exportVars.toString());
console.log(this.exportUrl);
console.log(exportJson); //das dann als json an die api?
var win = window.open(this.exportUrl+'/GeoElements/EdgeList', '_blank');
win.opener = null;
win.focus();
......
<div class="widget-wrap big-widget">
<div class="container contact pagecontainer">
<div markdown [src]="'assets/markdown/Kontakt.md'"></div>
<form (ngSubmit)="onSubmit()" [formGroup]="contactform">
<app-formcontrol-block [controlname]="'name'" [labelname]="'Name*'">
<input type="text" id="name" formControlName="name" class="form-control">
</app-formcontrol-block>
<app-formcontrol-block [controlname]="'email'" [labelname]="'E-Mail*'">
<input id="email" type="text" formControlName="email" class="form-control">
</app-formcontrol-block>
<app-formcontrol-block [controlname]="'betreff'" [labelname]="'Betreff*'">
<select id="betreff" formControlName="betreff" class="form-control">
<option value="allgemeines">Allgemeines zum Projekt</option>
<option value="bugreport">Bugreport</option>
<option value="presseanfragen">Presseanfragen</option>
<option value="stammtisch">Stammtisch & Mitmachen</option>
</select>
</app-formcontrol-block>
<app-formcontrol-block [controlname]="'nachricht'" [labelname]="'Deine Nachricht*'">
<textarea id="nachricht" formControlName="nachricht" class="form-control" style="height: 250px"></textarea>
</app-formcontrol-block>
<div class="checkbox">
<label>
<input type="checkbox" id="datenschutz" formControlName="datenschutz">
Wenn du dieses Formular ausfüllst, erheben wir personenbezogene Daten von dir (deinen Namen und
deine
E-Mail-Adresse). Diese Daten werden gespeichert und ausschließlich zu Zwecken der Beantwortung
deiner
Anfrage/Nachricht und einer möglichen folgenden Korrespondenz mit dir verarbeitet und genutzt. Mit
deiner Anmeldung willigst du in eine Speicherung und Nutzung der Daten zu diesen Zwecken ein. Eine
Übermittlung der Daten an Dritte zu anderen als oben aufgeführten Zwecken findet nicht statt. *
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" formControlName="newsletter">
Ich erlaube, dass meine Daten auch über diese Kontaktanfrage hinaus gespeichert werden, damit die
Betreiber*innen mich über kommende Veranstaltungen und Neuigkeiten zum GeoPortal des Guten Lebens
informieren können. Eine Übermittlung der Daten an Dritte zu anderen als diesen Zwecken findet nicht
statt.
</label>
</div>
<button type="submit" class="btn btn-outline-success" [disabled]="!contactform.valid">Senden</button>
</form>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { FormBuilder } from '@angular/forms';
import { Validators } from '@angular/forms';
@Component({
selector: 'app-contact',
......@@ -6,10 +9,22 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./contact.component.css']
})
export class ContactComponent implements OnInit {
show_contact_formular:boolean=false;
constructor() { }
//show_contact_formular:boolean=false;
contactform = this.fb.group({
name: ['', Validators.required],
email: ['', Validators.required],
betreff: ['', Validators.required],
nachricht: ['', Validators.required],
datenschutz: ['', Validators.required],
newsletter: ['']
});
constructor(private fb: FormBuilder) { }
ngOnInit() {
}
onSubmit(){
console.log(this.contactform.value);
}
}
<div class="form-group">
<label *ngIf="labelname !== null && labelname !== ''" for="{{controlname}}">{{labelname}}</label>
<ng-content></ng-content>
</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormcontrolBlockComponent } from './formcontrol-block.component';
describe('FormcontrolBlockComponent', () => {
let component: FormcontrolBlockComponent;
let fixture: ComponentFixture<FormcontrolBlockComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FormcontrolBlockComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(FormcontrolBlockComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-formcontrol-block',
templateUrl: './formcontrol-block.component.html',
styleUrls: ['./formcontrol-block.component.css']
})
export class FormcontrolBlockComponent implements OnInit {
@Input("controlname") controlname: string;
@Input("labelname") labelname: string;
constructor() { }
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, } from '@angular/core';
@Component({
selector: 'app-kontaktformular',
......@@ -7,6 +7,8 @@ import { Component, OnInit } from '@angular/core';
})
export class KontaktformularComponent implements OnInit {
constructor() { }
ngOnInit() {
......
......@@ -2,14 +2,17 @@ import { Injectable } from '@angular/core';
import { User } from '../models/User';
import { GeoportalApiService } from './geoportal-api.service';
import { LogService } from './log.service';
import { Observable,Subject } from 'rxjs';
import { Observable, Subject } from 'rxjs';
import { Router } from '@angular/router';
import { CacheService } from './cache.service';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Injectable({
providedIn: 'root'
})
/*
* Alan:
* Login Callback in eigene Funktion extrahiert
*/
export class AuthService {
currentUser: User;
......@@ -17,83 +20,53 @@ export class AuthService {
profileRetrieved: boolean = false;
loginFailed: boolean = false;
bearer: string;
public onLoggedIn:Subject<boolean>;
constructor(private apiService: GeoportalApiService, private logger: LogService, private router:Router,private cache:CacheService) {
public onLoggedIn: Subject<boolean>;
constructor(private apiService: GeoportalApiService, private logger: LogService, private router: Router, private cache: CacheService) {
this.logger.debug("auth.service: Trying to load currentUser.");
this.onLoggedIn = new Subject<boolean>();
let currentUserObject:User;
if(this.cache.has('currentUserObject')){
currentUserObject = this.cache.get('currentUserObject');
let currentUserObject: User;
if (this.cache.has('currentUserObject')) {
currentUserObject = this.cache.get('currentUserObject');
}
if(currentUserObject == null){
if (currentUserObject == null) {
this.logger.debug("auth.service: failed to load user from localstorage.");
}else{
} else {
this.currentUser = new User(currentUserObject);
this.profileRetrieved=true;
this.loginFailed=false;
this.loggedIn=true;
this.profileRetrieved = true;
this.loginFailed = false;
this.loggedIn = true;
apiService.loadBearer();
}
}
login(username: string, password: string, savelogin: boolean) {
this.apiService.login(username, password)
.subscribe(
response => {
if ( response['Bearer'] ) {
this.bearer = response['Bearer'];
this.loggedIn = true;
this.loginFailed = false;
this.currentUser = new User(response);
this.apiService.setBearer(this.bearer);
this.apiService.getCurrentUser().subscribe(
res => {
console.log("Userdata:" +JSON.stringify(res,null,3));
this.currentUser.setData( res );
this.logger.debug( this.currentUser.toString() );
this.profileRetrieved=true;
this.logger.notify('success','Login erfolgreich.');
this.onLoggedIn.next(true);
if( savelogin ) {
this.saveLogin();
}else{
this.logger.debug("auth.service: not saving login: "+JSON.stringify(savelogin));
}
}
);
}
},
error => {
this.logger.debug('auth.service: errorpath.');
this.logger.notify('error','Login fehlgeschlagen.');
this.loginFailed = true;
this.loggedIn = false;
}
);
.subscribe(
response => {
this.handleLoginResponse(response, savelogin);
},
error => {
this.handleLoginError();
}
);
}
logout(){
this.profileRetrieved = false;
this.loggedIn = false;
this.currentUser.clear();
this.apiService.deleteBearer();
this.cache.remove("currentUserObject");
this.logger.debug("logging out.");
//this.router.navigate(['login']);
return true;
logout() {
this.profileRetrieved = false;
this.loggedIn = false;
this.currentUser.clear();
this.apiService.deleteBearer();
this.cache.remove("currentUserObject");
this.logger.debug("logging out.");
//this.router.navigate(['login']);
return true;
}
saveLogin(){
saveLogin() {
this.logger.debug("auth.service: Saving current user.");
this.cache.set("currentUserObject",this.currentUser);
this.logger.debug("auth.service: Saved to localStorage: "+JSON.stringify(this.currentUser));
this.cache.set("currentUserObject", this.currentUser);
this.logger.debug("auth.service: Saved to localStorage: " + JSON.stringify(this.currentUser));
this.apiService.saveBearer();
this.logger.debug("Bearer saved.");
}
......@@ -117,4 +90,49 @@ export class AuthService {
setLoggedIn(loggedIn: boolean) {
this.loggedIn = loggedIn;
}
private checkAndExecuteLoginSave(save: boolean){
if (save) {
this.saveLogin();
} else {
this.logger.debug("auth.service: not saving login: " + JSON.stringify(save));
}
}
private handleLoginError(){
this.logger.debug('auth.service: errorpath.');
this.logger.notify('error', 'Login fehlgeschlagen.');
this.loginFailed = true;
this.loggedIn = false;
}
private handleLoginResponse(response: any, saveLogin: boolean){
if (!response['Bearer']) {
return;
}
this.bearer = response['Bearer'];
this.loggedIn = true;
this.loginFailed = false;
this.currentUser = new User(response);
this.apiService.setBearer(this.bearer);
this.apiService.getCurrentUser().subscribe(
res => {
this.handleUserResponse(res);
this.checkAndExecuteLoginSave(saveLogin);
}
);
}
private handleUserResponse(response: any){
console.log("Userdata:" + JSON.stringify(response, null, 3));
this.currentUser.setData(response);
this.logger.debug(this.currentUser.toString());
this.profileRetrieved = true;
this.logger.notify('success', 'Login erfolgreich.');
this.onLoggedIn.next(true);
}
}
......@@ -11,90 +11,91 @@ import { isArray } from 'util';
providedIn: 'root'
})
export class BliService {
dimensions: Array<BliDimension>;
dimensions: Array<BliDimension>;
constructor(
private logger: LogService,
private authService: AuthService,
private apiService: GeoportalApiService,
private cache: CacheService) {
private logger: LogService,
private authService: AuthService,
private apiService: GeoportalApiService,
private cache: CacheService) {
this.dimensions=BliDimensionFactory.dimensions;
this.dimensions = BliDimensionFactory.dimensions;
this.logger.debug("BliService constructed.");
this.getFromServer();
}
getIconClass(name){
switch(name){
case 'Einkommen':{return 'bliicon bliicon-income';}
case 'Arbeit':{return 'bliicon bliicon-work';}
case 'Wohnbedingungen':{return 'bliicon bliicon-housing';}
case 'Gesundheit':{return 'bliicon bliicon-health';}
case 'Work-Life-Balance':{return 'bliicon bliicon-wlbalance';}
case 'Bildung':{return 'bliicon bliicon-education';}
case 'Gemeinschaft':{return 'bliicon bliicon-community';}
case 'Engagement/Beteiligung':{return 'bliicon bliicon-engagement';}
case 'Umwelt':{return 'bliicon bliicon-nature';}
case 'Sicherheit':{return 'bliicon bliicon-security';}
case 'Zufriedenheit':{return 'bliicon bliicon-satisfaction';}
case 'Infrastruktur':{return 'bliicon bliicon-infrastructure';}
case 'Freizeit und Kultur':{return 'bliicon bliicon-leisure';}
default: return '';
}
getIconClass(name) {
switch (name) {
case 'Einkommen': { return 'bliicon bliicon-income'; }
case 'Arbeit': { return 'bliicon bliicon-work'; }
case 'Wohnbedingungen': { return 'bliicon bliicon-housing'; }
case 'Gesundheit': { return 'bliicon bliicon-health'; }
case 'Work-Life-Balance': { return 'bliicon bliicon-wlbalance'; }
case 'Bildung': { return 'bliicon bliicon-education'; }
case 'Gemeinschaft': { return 'bliicon bliicon-community'; }
case 'Engagement/Beteiligung': { return 'bliicon bliicon-engagement'; }
case 'Umwelt': { return 'bliicon bliicon-nature'; }
case 'Sicherheit': { return 'bliicon bliicon-security'; }
case 'Zufriedenheit': { return 'bliicon bliicon-satisfaction'; }
case 'Infrastruktur': { return 'bliicon bliicon-infrastructure'; }
case 'Freizeit und Kultur': { return 'bliicon bliicon-leisure'; }
default: return '';
}
getIcon(name){
switch(name){
case 'Einkommen':{return 'fa fa-money';}
case 'Arbeit':{return 'fa fa-briefcase';}
case 'Wohnbedingungen':{return 'fa fa-home';}
case 'Gesundheit':{return 'fa fa-medkit';}
case 'Work-Life-Balance':{return 'fa fa-balance-scale';}
case 'Bildung':{return 'fa fa-book';}
case 'Gemeinschaft':{return 'fa fa-users';}
case 'Engagement/Beteiligung':{return 'fa fa-check-square-o';}
case 'Umwelt':{return 'fa fa-envira';}
case 'Sicherheit':{return 'fa fa-shield';}
case 'Zufriedenheit':{return 'fa fa-heart';}
case 'Infrastruktur':{return 'fa fa-road';}
case 'Freizeit und Kultur':{return 'fa fa-film';}
}
getIcon(name) {
switch (name) {
case 'Einkommen': { return 'fa fa-money'; }
case 'Arbeit': { return 'fa fa-briefcase'; }
case 'Wohnbedingungen': { return 'fa fa-home'; }
case 'Gesundheit': { return 'fa fa-medkit'; }
case 'Work-Life-Balance': { return 'fa fa-balance-scale'; }
case 'Bildung': { return 'fa fa-book'; }
case 'Gemeinschaft': { return 'fa fa-users'; }
case 'Engagement/Beteiligung': { return 'fa fa-check-square-o'; }
case 'Umwelt': { return 'fa fa-envira'; }
case 'Sicherheit': { return 'fa fa-shield'; }
case 'Zufriedenheit': { return 'fa fa-heart'; }
case 'Infrastruktur': { return 'fa fa-road'; }
case 'Freizeit und Kultur': { return 'fa fa-film'; }
default: return '';
}
}
getFromServer() {
let expires=new Date();
expires.setDate(expires.getDate()+1);
if(this.cache.has("blidimensions")){
let expires = new Date();
expires.setDate(expires.getDate() + 1);
if (this.cache.has("blidimensions")) {
this.logger.debug("BliService: returning cached version.");
this.parseResponse(this.cache.get("blidimensions"));
}else{
this.logger.debug("BliService: Reading bli-dimensions from server.");
this.apiService.getBliDimensions().subscribe(
(response)=>{
this.cache.set("blidimensions",response,expires);
} else {
this.logger.debug("BliService: Reading bli-dimensions from server.");
this.apiService.getBliDimensions().subscribe(
(response) => {
this.cache.set("blidimensions", response, expires);
this.parseResponse(response);
},
(error)=>{
this.logger.debug( "BliService: Failed to get bli dimensions from server." +JSON.stringify(error));
this.logger.notify('error','failed to read bli-dimensions');
});
},
(error) => {
this.logger.debug("BliService: Failed to get bli dimensions from server." + JSON.stringify(error));
this.logger.notify('error', 'failed to read bli-dimensions');
});
}
}
}
parseResponse(response:any){
this.logger.debug("BliService: parsing response.");
parseResponse(response: any) {
this.logger.debug("BliService: parsing response.");
this.logger.debug(JSON.stringify(response));
if(isArray(response)){
this.dimensions.length=0;
for(let element of response ){
BliDimensionFactory.create(element);
}
}else{
this.logger.debug("BliService: result is not an array.");
}
this.logger.debug("response parsed.");
this.logger.debug(JSON.stringify(response));
if (isArray(response)) {
this.dimensions.length = 0;
for (let element of response) {
BliDimensionFactory.create(element);
}
} else {
this.logger.debug("BliService: result is not an array.");
}
this.logger.debug("response parsed.");
}
}
......@@ -46,5 +46,4 @@ export class CategoryService {
parseError(error:any){
this.logger.debug("CategoryService: error parsing/getting data from server.");
}
}
......@@ -11,6 +11,10 @@ import { BliService } from './bli.service';
@Injectable({
providedIn: 'root'
})
/*
* Alan:
* response und error handler funktionen erstellt und excessives logging in eigene methode extrahiert
*/
export class GeoElementService {
nodes: Array<OsmNode>;
......@@ -22,32 +26,15 @@ export class GeoElementService {
this.nodes = new Array<OsmNode>();
}
elementSaved(response) {
this.logger.debug('GeoElementService: successfully saved item. response: ' + JSON.stringify(response));
this.logger.notify('success', 'update successful.');
}
elementFailedToSave(errorResponse) {
this.logger.debug("GeoElementService: Error saving element.");
if (errorResponse.error && errorResponse.error.error) {
this.logger.notify('error', 'error saving element: ' + errorResponse.error.error);
} else {
this.logger.notify('error', 'unknown error while saving element');
}
this.logger.debug(JSON.stringify(errorResponse));
}
save(element: OsmNode) {
this.logger.debug("GeoElementService: sending node to server (save).");
this.logger.debug(JSON.stringify(element));
return this.apiService.saveGeoElement(element).subscribe(
(response) => {
this.logger.debug("GeoElementService: got response from server after create-operation.");
this.elementSaved(response);
this.handleSaveResponse(response);
},
(error) => {
this.logger.debug("GeoElementService: got error back: " + JSON.stringify(error, null, 4));
this.elementFailedToSave(error);
this.handleSaveError(error);
});
}
......@@ -56,11 +43,10 @@ export class GeoElementService {
this.logger.debug("Element: "+element.debugString());
return this.apiService.updateGeoElement(element).subscribe(
(response) => {
this.logger.debug("GeoElementService: got response from server after update-operation.");
this.elementSaved(response);
this.handleUpdateResponse(response);
},
(error) => {
this.elementFailedToSave(error);
this.handleUpdateError(error);
});
}
......@@ -75,11 +61,45 @@ export class GeoElementService {
);
}
parseResponse(response: any) {
private parseResponse(response: any) {
this.logger.debug("GeoElementService: Got response.");
}
parseError(error: any) {
private parseError(error: any) {
this.logger.debug("GeoItemService: Got error-response.");
}
private handleUpdateResponse(response){
this.logger.debug("GeoElementService: got response from server after update-operation.");
this.logResponse(response);
}
private handleUpdateError(error){
this.logError(error, "updating element");
}
private handleSaveResponse(response){
this.logger.debug("GeoElementService: got response from server after create-operation.");
this.logResponse(response);
}
private handleSaveError(error){
this.logError(error, "saving element");
}
private logResponse(response) {
this.logger.debug('GeoElementService: successfully saved item. response: ' + JSON.stringify(response));
this.logger.notify('success', 'update successful.');
}
private logError(errorResponse, errorMessage: string) {
this.logger.debug("GeoElementService: received error: " + JSON.stringify(errorResponse, null, 4));
this.logger.debug("GeoElementService: Error "+errorMessage+".");
if (errorResponse.error && errorResponse.error.error) {
this.logger.notify('error', 'error '+errorMessage+': ' + errorResponse.error.error);
} else {
this.logger.notify('error', 'unknown error while ');
}
this.logger.debug(JSON.stringify(errorResponse));
}
}
This diff is collapsed.
......@@ -32,6 +32,12 @@ import { OsmNodeService } from './osm-node.service';
@Injectable({
providedIn: 'root'
})
/*
* Alan:
* ein wenig toten code entfernt,
* eine switch case vereinfacht
*/
export class MapService {
maxZoom : number = 14;
......@@ -122,19 +128,16 @@ export class MapService {
}