updated tandoor widget to use helper-pod data
This commit is contained in:
@@ -629,24 +629,15 @@ data:
|
||||
|
||||
- type: custom-api
|
||||
title: Meal for the Day
|
||||
cache: 1d
|
||||
cache: 5m
|
||||
|
||||
# Use the endpoint that definitely exists in your Tandoor
|
||||
url: ${TANDOOR_URL}/api/recipe/
|
||||
headers:
|
||||
Accept: application/json
|
||||
Authorization: Bearer ${TANDOOR_TOKEN}
|
||||
# Served by glance-helper: stable picks for the day + "cooked" support
|
||||
url: http://glance-helper.glance-system.svc.cluster.local:8000/tandoor/daily
|
||||
parameters:
|
||||
count: 3
|
||||
|
||||
# Pass base url into template (NO env() needed)
|
||||
options:
|
||||
base_url: ${TANDOOR_URL}
|
||||
|
||||
# Use Prometheus time() to make the pick stable for the day
|
||||
subrequests:
|
||||
epoch:
|
||||
url: ${PROMETHEUS_URL}/api/v1/query
|
||||
parameters:
|
||||
query: time()
|
||||
tandoor_url: https://tandoor.dooplex.hu
|
||||
|
||||
template: |
|
||||
<style>
|
||||
@@ -657,86 +648,49 @@ data:
|
||||
.mealimg { height:150px; background:rgba(0,0,0,0.15); display:flex; align-items:center; justify-content:center; overflow:hidden; }
|
||||
.mealimg img { width:100%; height:100%; object-fit:cover; display:block; }
|
||||
.mealnoimg { opacity:.55; font-size:12px; padding:18px; text-align:center; }
|
||||
.mealname { padding:10px 12px 12px; font-weight:700; opacity:.95; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.mealname { padding:10px 12px 8px; font-weight:700; opacity:.95; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.mealactions { padding:0 12px 12px; display:flex; gap:10px; opacity:.8; font-size:12px; }
|
||||
.mealactions a { text-decoration:none; }
|
||||
.meallink { display:block; color:inherit; text-decoration:none; }
|
||||
</style>
|
||||
|
||||
{{ $base := .Options.StringOr "base_url" "https://tandoor.dooplex.hu" }}
|
||||
{{ $recipes := .JSON.Array "results" }}
|
||||
{{ $n := len $recipes }}
|
||||
{{ $tandoor := .Options.StringOr "tandoor_url" "https://tandoor.dooplex.hu" }}
|
||||
{{ $items := .JSON.Array "items" }}
|
||||
{{ $total := .JSON.Int "total_recipes" }}
|
||||
{{ $date := .JSON.String "date" }}
|
||||
|
||||
{{ if lt $n 1 }}
|
||||
<div class="mealwrap">
|
||||
<div class="color-negative">No recipes returned from Tandoor.</div>
|
||||
<div class="mealmeta">
|
||||
<span>Check token / permissions</span>
|
||||
<a href="{{ $base }}" target="_blank" rel="noreferrer">Open Tandoor</a>
|
||||
</div>
|
||||
<div class="mealwrap">
|
||||
<div class="mealmeta">
|
||||
<span>Today’s picks ({{ $total }} total)</span>
|
||||
<a href="{{ $tandoor }}" target="_blank" rel="noreferrer">Open Tandoor</a>
|
||||
</div>
|
||||
{{ else }}
|
||||
|
||||
{{ $epoch := (.Subrequest "epoch").JSON.Float "data.result.0.value.1" }}
|
||||
{{ $day := div $epoch 86400.0 | toInt }}
|
||||
|
||||
{{ $i0 := mod $day $n }}
|
||||
{{ $i1 := mod (add $i0 1) $n }}
|
||||
{{ $i2 := mod (add $i0 2) $n }}
|
||||
|
||||
{{ $p0 := print "results." $i0 }}
|
||||
{{ $p1 := print "results." $i1 }}
|
||||
{{ $p2 := print "results." $i2 }}
|
||||
|
||||
{{ $id0 := .JSON.Int (print $p0 ".id") }}
|
||||
{{ $nm0 := .JSON.String (print $p0 ".name") }}
|
||||
{{ $im0 := .JSON.String (print $p0 ".image") }}
|
||||
|
||||
{{ $id1 := .JSON.Int (print $p1 ".id") }}
|
||||
{{ $nm1 := .JSON.String (print $p1 ".name") }}
|
||||
{{ $im1 := .JSON.String (print $p1 ".image") }}
|
||||
|
||||
{{ $id2 := .JSON.Int (print $p2 ".id") }}
|
||||
{{ $nm2 := .JSON.String (print $p2 ".name") }}
|
||||
{{ $im2 := .JSON.String (print $p2 ".image") }}
|
||||
|
||||
<div class="mealwrap">
|
||||
<div class="mealmeta">
|
||||
<span>Today’s picks ({{ printf "%d" $n }} total)</span>
|
||||
<a href="{{ $base }}" target="_blank" rel="noreferrer">Open Tandoor</a>
|
||||
</div>
|
||||
|
||||
{{ if lt (len $items) 1 }}
|
||||
<div class="color-negative">No recipes returned.</div>
|
||||
{{ else }}
|
||||
<div class="mealscroller">
|
||||
<div class="mealslide">
|
||||
<a class="meallink" href="{{ $base }}/recipe/{{ $id0 }}" target="_blank" rel="noreferrer">
|
||||
<div class="mealimg">
|
||||
{{ if $im0 }}<img src="{{ $im0 }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||
</div>
|
||||
<div class="mealname">{{ $nm0 }}</div>
|
||||
</a>
|
||||
</div>
|
||||
{{ range $i, $r := $items }}
|
||||
{{ $name := $r.String "name" }}
|
||||
{{ $img := $r.String "image" }}
|
||||
{{ $url := $r.String "url" }}
|
||||
{{ $cook := $r.String "cook_url" }}
|
||||
|
||||
<div class="mealslide">
|
||||
<a class="meallink" href="{{ $base }}/recipe/{{ $id1 }}" target="_blank" rel="noreferrer">
|
||||
<div class="mealimg">
|
||||
{{ if $im1 }}<img src="{{ $im1 }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||
<div class="mealslide">
|
||||
<a class="meallink" href="{{ $url }}" target="_blank" rel="noreferrer">
|
||||
<div class="mealimg">
|
||||
{{ if $img }}<img src="{{ $img }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||
</div>
|
||||
<div class="mealname">{{ $name }}</div>
|
||||
</a>
|
||||
<div class="mealactions">
|
||||
<a href="{{ $url }}" target="_blank" rel="noreferrer">Open</a>
|
||||
<a href="{{ $cook }}" target="_blank" rel="noreferrer">Cooked today ✓</a>
|
||||
</div>
|
||||
<div class="mealname">{{ $nm1 }}</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="mealslide">
|
||||
<a class="meallink" href="{{ $base }}/recipe/{{ $id2 }}" target="_blank" rel="noreferrer">
|
||||
<div class="mealimg">
|
||||
{{ if $im2 }}<img src="{{ $im2 }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||
</div>
|
||||
<div class="mealname">{{ $nm2 }}</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
# ---------- CENTER COLUMN ----------
|
||||
- size: full
|
||||
@@ -2180,10 +2134,6 @@ spec:
|
||||
value: "http://uptimekuma.uptimekuma-system.svc.cluster.local:3001"
|
||||
- name: UPTIME_KUMA_STATUS_SLUG
|
||||
value: "homepage"
|
||||
- name: TANDOOR_URL
|
||||
value: "https://tandoor.dooplex.hu"
|
||||
- name: TANDOOR_TOKEN
|
||||
value: "tda_8a8b169c_5d1f_4962_83a2_0f2719c7d61a"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
|
||||
Reference in New Issue
Block a user