fix: misc
This commit is contained in:
@@ -63,7 +63,7 @@ func (gc *GroupController) GroupHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
if action == "addCard" {
|
||||
cardName := c.PostForm("Name")
|
||||
cardName := c.PostForm("name")
|
||||
_, err := services.Cards.Create(c, cardName, int32(id))
|
||||
|
||||
if err != nil {
|
||||
@@ -73,6 +73,16 @@ func (gc *GroupController) GroupHandler(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if action == "deleteCard" {
|
||||
err := services.Cards.Delete(c)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
c.HTML(http.StatusBadRequest, "accessauths.html", gin.H{"error": err})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if action == "delete" {
|
||||
err := services.Groups.Delete(c, int32(id))
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"fmt"
|
||||
"git.dynamicdiscord.de/malobeo/portal/openapi"
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetApiClient(c *gin.Context) *openapi.APIClient {
|
||||
configuration := openapi.NewConfiguration()
|
||||
//TODO: read from env
|
||||
configuration.Host = "localhost:8000"
|
||||
configuration.Scheme = "http"
|
||||
configuration.Host = os.Getenv("GATEKEEPER_HOST")
|
||||
configuration.Scheme = os.Getenv("GATEKEEPER_SCHEME")
|
||||
|
||||
if c != nil {
|
||||
authToken, err := c.Cookie("Authorization")
|
||||
|
||||
@@ -32,6 +32,21 @@ func (u *CardService) Create(c *gin.Context, name string, groupId int32) (*opena
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (u *CardService) Delete(c *gin.Context) error {
|
||||
apiClient := internal.GetApiClient(c)
|
||||
|
||||
resp, r, err := apiClient.CardAPI.DelCardApiV1CardsDelete(context.Background()).Execute()
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `CardAPI.DelCardApiV1CardsDelete``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
return err
|
||||
}
|
||||
// response from `LoginForAccessTokenTokenPost`: Token
|
||||
fmt.Fprintf(os.Stdout, "Response from `CardAPI.CreateCardCardsPost`: %v\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *CardService) GetCardsByGroup(c *gin.Context, groupId int32) ([]openapi.Card, error) {
|
||||
apiClient := internal.GetApiClient(c)
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
<div>
|
||||
<label for="weekday" class="block text-sm/6 font-medium text-gray-900">Weekday</label>
|
||||
<select name="weekday" id="weekday">
|
||||
<option value="1">Monday</option>
|
||||
<option value="2">Tuesday</option>
|
||||
<option value="3">Wednesday</option>
|
||||
<option value="4">Thursday</option>
|
||||
<option value="5">Friday</option>
|
||||
<option value="6">Saturday</option>
|
||||
<option value="7">Sunday</option>
|
||||
<option value="0">Monday</option>
|
||||
<option value="1">Tuesday</option>
|
||||
<option value="2">Wednesday</option>
|
||||
<option value="3">Thursday</option>
|
||||
<option value="4">Friday</option>
|
||||
<option value="5">Saturday</option>
|
||||
<option value="6">Sunday</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
<input type="text" id="name" name="name" value="{{ .Name }}" class="w-full border border-gray-300 rounded-md p-2 focus:outline-none focus:ring focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<form action="/access/{{ .Id }}" method="POST">
|
||||
<form action="/groups/{{ .Id }}" method="POST">
|
||||
{{ range .Cards }}
|
||||
<div class="mx-auto p-4 m-4 bg-gray-100 flex flex-wrap border rounded shadow-md">
|
||||
{{ .Name }} - {{ .CardSerial }}
|
||||
<div class="grid grid-cols-2 mt-4 flex flex-wrap gap-2 w-full">
|
||||
<button type="submit" name="action" value="removeGroup" class="bg-red-500 hover:bg-red-700 text-white
|
||||
<button type="submit" name="action" value="deleteCard" class="bg-red-500 hover:bg-red-700 text-white
|
||||
text-sm/6 font-bold py-2 px-4 rounded">Remove Card</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -34,13 +34,17 @@
|
||||
</form>
|
||||
|
||||
<div class="mb-4">
|
||||
<form action="/access/{{ .Id }}" method="POST">
|
||||
<form action="/groups/{{ .Id }}" method="POST">
|
||||
<label for="variant-value1" class="block text-sm/6 font-medium text-gray-900">Card Name</label>
|
||||
<input type="text" id="name" name="name" placeholder="name" class="w-full border border-gray-300 rounded-md p-2 focus:outline-none focus:ring focus:ring-blue-500">
|
||||
<div class="grid grid-cols-2 mt-4 flex flex-wrap gap-2 w-full">
|
||||
<button type="submit" name="action" value="addCard" class="bg-green-500 hover:bg-red-700 text-white
|
||||
text-sm/6 font-bold py-2 px-4 rounded">Add Card</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 mt-4 flex flex-wrap gap-2 w-full">
|
||||
<button type="submit" name="action" value="deleteCard" class="bg-red-500 hover:bg-red-700 text-white
|
||||
text-sm/6 font-bold py-2 px-4 rounded">Remove Card</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user