55{{ end }}
66
77{{ define "WeatherClients" }}
8- < div hx-swap ="outerHTML " hx-get ="/weather_clients?refresh=true " hx-headers ='{"Accept": "text/html"} '
9- hx-trigger ="{{ if NotRefresh }}load, {{ end }}newWeatherClient from:body " uk-grid >
10- {{ range .Items }}
11- {{ template "weatherClientCard" . }}
12- {{ end }}
13- </ div >
14- < div id ="edit-modal-here "> </ div >
15- {{ end }}
16-
17- {{ define "weatherClientCard" }}
18- < div class ="uk-width-1-2@m " id ="weather-client-card-{{ .ID }} ">
19- < div class ="uk-card uk-card-default " style ="margin: 5%; ">
20- < div class ="uk-card-header uk-text-center ">
21- < h3 class ="uk-card-title uk-margin-remove-bottom ">
22- {{ .ID }}
23- </ h3 >
24- {{ template "cardEditButton" (print "/weather_clients/" .ID "/components?type=edit_modal") }}
8+ < div hx-swap ="outerHTML " hx-get ="/weather_clients?refresh=true&units={{ .Units }}&duration={{ .Duration }} " hx-headers ='{"Accept": "text/html"} '
9+ hx-trigger ="{{ if NotRefresh }}load, {{ end }}newWeatherClient from:body ">
10+ < div class ="uk-margin-small-top uk-margin-small-bottom uk-text-center ">
11+ < div class ="uk-button-group " style ="margin-right: 10px; ">
12+ < button class ="uk-button uk-button-small {{ if IsMetric }}uk-button-primary{{ else }}uk-button-default{{ end }} "
13+ hx-get ="/weather_clients?refresh=true&units=metric&duration={{ .Duration }} "
14+ hx-headers ='{"Accept": "text/html"} '
15+ hx-target ="closest div[hx-get] "
16+ hx-swap ="outerHTML "
17+ hx-push-url ="/weather_clients?units=metric&duration={{ .Duration }} ">
18+ Metric
19+ </ button >
20+ < button class ="uk-button uk-button-small {{ if not IsMetric }}uk-button-primary{{ else }}uk-button-default{{ end }} "
21+ hx-get ="/weather_clients?refresh=true&units=imperial&duration={{ .Duration }} "
22+ hx-headers ='{"Accept": "text/html"} '
23+ hx-target ="closest div[hx-get] "
24+ hx-swap ="outerHTML "
25+ hx-push-url ="/weather_clients?units=imperial&duration={{ .Duration }} ">
26+ Imperial
27+ </ button >
2528 </ div >
26- < div class ="uk-card-body ">
27- {{ .Type }}
29+ < select class ="uk-select uk-form-small " style ="width: auto; min-width: 90px; display: inline-block; "
30+ hx-get ="/weather_clients?refresh=true&units={{ .Units }} "
31+ hx-headers ='{"Accept": "text/html"} '
32+ hx-target ="closest div[hx-get] "
33+ hx-swap ="outerHTML "
34+ hx-trigger ="change "
35+ hx-vals ="js:{duration: event.target.value} "
36+ hx-push-url ="js:'/weather_clients?units={{ .Units }}&duration=' + event.target.value ">
37+ < option value ="24h " {{ if eq .Duration.String "24h0m0s" }}selected{{ end }}> 24h</ option >
38+ < option value ="48h " {{ if eq .Duration.String "48h0m0s" }}selected{{ end }}> 48h</ option >
39+ < option value ="72h " {{ if eq .Duration.String "72h0m0s" }}selected{{ end }}> 72h</ option >
40+ < option value ="168h " {{ if eq .Duration.String "168h0m0s" }}selected{{ end }}> 1 week</ option >
41+ </ select >
42+ </ div >
43+ < div uk-grid >
44+ {{ range .Items }}
45+ < div class ="uk-width-1-2@m " id ="weather-client-card-{{ .ID }} ">
46+ < div class ="uk-card uk-card-default " style ="margin: 5%; ">
47+ < div class ="uk-card-header uk-text-center ">
48+ < h3 class ="uk-card-title uk-margin-remove-bottom ">
49+ {{ .Type }}
50+ </ h3 >
51+ {{ template "cardEditButton" (print "/weather_clients/" .ID "/components?type=edit_modal") }}
52+ </ div >
53+ < div class ="uk-card-body ">
54+ {{ if .WeatherData }}
55+ < div class ="uk-flex uk-flex-center uk-flex-middle uk-grid-small " uk-grid >
56+ {{ if .WeatherData.Temperature }}
57+ < div class ="uk-flex uk-flex-middle ">
58+ < span uk-icon ="thermometer " class ="uk-margin-small-right " style ="color: #faa05a; "> </ span >
59+ {{ if IsMetric }}
60+ < span class ="uk-text-bold " style ="color: #faa05a; "> {{ printf "%.1f°C" .WeatherData.Temperature.Celsius }}</ span >
61+ {{ else }}
62+ < span class ="uk-text-bold " style ="color: #faa05a; "> {{ printf "%.1f°F" .WeatherData.Temperature.Fahrenheit }}</ span >
63+ {{ end }}
64+ </ div >
65+ {{ end }}
66+ {{ if .WeatherData.Rain }}
67+ < div class ="uk-flex uk-flex-middle ">
68+ < span uk-icon ="cloud-rain " class ="uk-margin-small-right uk-text-primary "> </ span >
69+ {{ if IsMetric }}
70+ < span class ="uk-text-bold uk-text-primary "> {{ printf "%.1f mm" (DerefFloat32 .WeatherData.Rain.MM) }}</ span >
71+ {{ else }}
72+ < span class ="uk-text-bold uk-text-primary "> {{ printf "%.2f in" (DerefFloat32 .WeatherData.Rain.Inches) }}</ span >
73+ {{ end }}
74+ </ div >
75+ {{ end }}
76+ </ div >
77+ {{ end }}
78+ </ div >
79+ </ div >
2880 </ div >
81+ {{ end }}
2982 </ div >
3083</ div >
84+ < div id ="edit-modal-here "> </ div >
3185{{ end }}
0 commit comments