Prześlij pliki do 'trening-planer'

This commit is contained in:
Karolina Słonka 2019-01-31 21:31:47 +00:00
parent db33f0aab6
commit 58f8222a8f
2 changed files with 29 additions and 20 deletions

View File

@ -1,4 +1,4 @@
{{ define "Index" }}
<!DOCTYPE html>
<html lang="pl">
<head>
@ -68,30 +68,25 @@ function dodawanieCwiczenia(id) {
<div class="row">
<div class="col-lg-8">
<form action="/dodajcwiczenie/" method="POST">
<div class="col-lg-12">
<div class="col-lg-12" style="margin-top: 15px">Nazwa:<input type="text" class="form-control" name="Nazwa" placeholder="Nazwa" style="width: 800px"></div>
<div class="col-lg-4" style="margin-top: 15px">Rodzaj:<input type="text" class="form-control" name="Rodzaj" placeholder="Rodzaj" style="width: 350px"></div>
<div class="col-lg-4" style="margin-top: 15px">Zdjecie:<input type="text" class="form-control" name="Zdjecie" placeholder="Zdjecie" style="width: 420px"></div>
<div class="col-lg-12" style="margin-top: 15px">Opis:<textarea type="textarea" class="form-control" name="Opis" style="width: 800px;height: 400px"></textarea></div>
<div class="col-lg-12" style="margin-top: 15px">Nazwa:<input type="text" class="form-control" name="Nazwa" placeholder="Nazwa" style="width: 600px"></div>
<div class="col-lg-4" style="margin-top: 15px">Rodzaj:<input type="text" class="form-control" name="Rodzaj" placeholder="Rodzaj" style="width: 150px"></div>
<div class="col-lg-4" style="margin-top: 15px">Zdjecie:<input type="text" class="form-control" name="Zdjecie" placeholder="Zdjecie" style="width: 120px"></div>
<div class="col-lg-12" style="margin-top: 15px">Opis:<textarea type="textarea" class="form-control" name="Opis" style="width: 600px;height: 400px"></textarea></div>
<div class="col-lg-offset-5 col-lg-2 btn-group btn-group-xs" role="group" aria-label="Zarządzaj wpisem" style="margin-top: 15px;" >
<button type="submit" class="btn btn-default" style="height: 50px" onclick="dodawanieDoBazy()" >Dodaj ćwiczenie</button></div></div>
</form>
<button type="submit" class="btn btn-default" style="height: 50px" onclick="dodawanieDoBazy()" >Dodaj ćwiczenie</button></div> </form>
</div>
<div class="col-lg-4" style="background-color: #EBC79E;margin-top: 15px"> <h2>Lista dodanych przez Ciebie ćwiczeń</h2> <br/><br/> {{ range . }} {{.Nazwa}}<br/>{{end}}</div></div>
</div>
</div>
</div>
@ -112,3 +107,4 @@ function dodawanieCwiczenia(id) {
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
{{ end}}

View File

@ -86,7 +86,7 @@ var tmpl2 = template.Must(template.ParseGlob("planowanieTreningu.html"))
var tmpl3 = template.Must(template.ParseGlob("cwiczenie.html"))
var tmpl4 = template.Must(template.ParseGlob("wyniki.html"))
var tmpl5 = template.Must(template.ParseGlob("wymiary.html"))
var tmpl6 = template.Must(template.ParseGlob("dodajcwiczenie.html"))
var tmpl = template.Must(template.ParseGlob("koszyk.html"))
//deklaracja tmpl-KONIEC
@ -738,9 +738,22 @@ Zdjecie := r.FormValue("Zdjecie")
fmt.Println(insert)
fmt.Println(err)
}
p := Plan{Opis: "zakładka"}
t, _ := template.ParseFiles("dodajcwiczenie.html")
t.Execute(w, p)
// p := Plan{Opis: "zakładka"}
// t, _ := template.ParseFiles("dodajcwiczenie.html")
// t.Execute(w, p)
rows2, err := db.Query("select nazwa from baza.cwiczenie where uzytkownik=?",getCookie(w,r))
emp2 := Plan{}
res2 := []Plan{}
for rows2.Next() {
var nazwa string
err = rows2.Scan(&nazwa)
if err != nil {panic(err.Error()) }
emp2.Nazwa = nazwa
res2 = append(res2, emp2)
}
tmpl6.ExecuteTemplate(w, "Index", res2)
}}