Besucher auf Struct umgeschrieben
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.cosysda.de/HuskyTeufel/Hochzeit/planner"
|
"git.cosysda.de/HuskyTeufel/Hochzeit/planner"
|
||||||
@@ -21,8 +20,8 @@ func AddBesucherHandler(c *gin.Context) {
|
|||||||
c.JSON(statusCode, err)
|
c.JSON(statusCode, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println("Besucher hinzugefügt" + besucherItem.Message)
|
|
||||||
c.JSON(statusCode, gin.H{"id": planner.Add(besucherItem.Message)})
|
c.JSON(statusCode, gin.H{"id": planner.Add(besucherItem)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteBesucherHandler(c *gin.Context) {
|
func DeleteBesucherHandler(c *gin.Context) {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ func Get() []Besucher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add will add a new Besucher
|
// Add will add a new Besucher
|
||||||
func Add(message string) string {
|
func Add(newClient Besucher) string {
|
||||||
t := newBesucher(message)
|
t := newBesucher(newClient)
|
||||||
mtx.Lock()
|
mtx.Lock()
|
||||||
list = append(list, t)
|
list = append(list, t)
|
||||||
mtx.Unlock()
|
mtx.Unlock()
|
||||||
@@ -66,10 +66,11 @@ func isMatchingID(a, b string) bool {
|
|||||||
return a == b
|
return a == b
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBesucher(message string) Besucher {
|
func newBesucher(newBesucher Besucher) Besucher {
|
||||||
return Besucher{
|
return Besucher{
|
||||||
ID: xid.New().String(),
|
ID: xid.New().String(),
|
||||||
Message: message,
|
Name: newBesucher.Name,
|
||||||
Come: false,
|
Message: newBesucher.Message,
|
||||||
|
Come: newBesucher.Come,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
.example-radio-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.example-radio-button {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,11 +16,14 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<input placeholder="Ihre Name..." [(ngModel)]="BesucherName">
|
<input placeholder="Ihre Name..." [(ngModel)]="BesucherName">
|
||||||
<input placeholder="Eventuell eine Nachricht" [(ngModel)]="BesucherMessage">
|
<input placeholder="Eventuell eine Nachricht" [(ngModel)]="BesucherMessage"><br />
|
||||||
<label id="zusage-radio-button-group-label">Kommen Sie</label>
|
<label id="zusage-radio-button-group-label">Kommen Sie</label>
|
||||||
<mat-radio-group>
|
<mat-radio-group
|
||||||
<mat-radio-button value="1">Ja</mat-radio-button>
|
aria-labelledby="zusage-radio-button-group-label"
|
||||||
<mat-radio-button value="0">Nein</mat-radio-button>
|
class="example-radio-group"
|
||||||
|
[(ngModel)]="BesucherKommtRadio"
|
||||||
|
>
|
||||||
|
<mat-radio-button class="example-radio-button" *ngFor="let entscheidung of kommt" [value]="entscheidung">{{entscheidung}}</mat-radio-button>
|
||||||
</mat-radio-group>
|
</mat-radio-group>
|
||||||
<button class="btn btn-primary" (click)="addBesucher()">Abschicken</button>
|
<button class="btn btn-primary" (click)="addBesucher()">Abschicken</button>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { filter } from 'rxjs';
|
|||||||
import { BesucherService } from '../besucher.service';
|
import { BesucherService } from '../besucher.service';
|
||||||
import { Besucher } from 'src/besucher';
|
import { Besucher } from 'src/besucher';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-besucher',
|
selector: 'app-besucher',
|
||||||
templateUrl: './besucher.component.html',
|
templateUrl: './besucher.component.html',
|
||||||
@@ -17,8 +18,12 @@ export class BesucherComponent implements OnInit {
|
|||||||
kommendeBesuchers: Besucher[] = [];
|
kommendeBesuchers: Besucher[] = [];
|
||||||
BesucherName: string = "";
|
BesucherName: string = "";
|
||||||
BesucherMessage: string = "";
|
BesucherMessage: string = "";
|
||||||
|
|
||||||
BesucherKommt: boolean = false;
|
BesucherKommt: boolean = false;
|
||||||
|
|
||||||
|
BesucherKommtRadio: string = "";
|
||||||
|
kommt: string[] = ['Ja','Nein'];
|
||||||
|
|
||||||
constructor(private besucherService: BesucherService) { }
|
constructor(private besucherService: BesucherService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -48,8 +53,9 @@ export class BesucherComponent implements OnInit {
|
|||||||
name : this.BesucherName,
|
name : this.BesucherName,
|
||||||
message : this.BesucherMessage,
|
message : this.BesucherMessage,
|
||||||
id: '',
|
id: '',
|
||||||
come : this.BesucherKommt
|
come : this.convertBesucherkommtStringToBoolean(this.BesucherKommtRadio)
|
||||||
};
|
};
|
||||||
|
console.log(newBesucher.come);
|
||||||
this.besucherService.addBesucher(newBesucher).subscribe(() => {
|
this.besucherService.addBesucher(newBesucher).subscribe(() => {
|
||||||
this.getAll();
|
this.getAll();
|
||||||
this.BesucherMessage = '';
|
this.BesucherMessage = '';
|
||||||
@@ -57,4 +63,9 @@ export class BesucherComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
convertBesucherkommtStringToBoolean(input: string) : boolean {
|
||||||
|
return input == this.kommt[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user