jams.templ 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. package views
  2. import "github.com/pocketbase/pocketbase/core"
  3. // JamList renders the list of all jams.
  4. templ JamList(jams []*core.Record, locationNames map[string]string, songCounts map[string]SongCount) {
  5. @Layout("Jams") {
  6. <div class="level">
  7. <div class="level-left">
  8. <h1 class="title">Jams</h1>
  9. </div>
  10. <div class="level-right">
  11. <a class="button is-primary" href="/jams/new">+ New Jam</a>
  12. </div>
  13. </div>
  14. if len(jams) == 0 {
  15. <p class="has-text-grey">No jams logged yet.</p>
  16. } else {
  17. <table class="table is-fullwidth is-striped is-hoverable">
  18. <thead>
  19. <tr><th>Date</th><th>Location</th><th>Songs</th></tr>
  20. </thead>
  21. <tbody>
  22. for _, j := range jams {
  23. <tr>
  24. <td><a href={ templ.SafeURL("/jams/" + j.Id) }>{ dateOnly(j.GetString("date")) }</a></td>
  25. <td>{ locationNames[j.GetString("location")] }</td>
  26. <td>{ songCountDisplay(songCounts[j.Id]) }</td>
  27. </tr>
  28. }
  29. </tbody>
  30. </table>
  31. }
  32. }
  33. }
  34. // JamNew renders the new-jam creation form.
  35. templ JamNew(locations []*core.Record) {
  36. @Layout("New Jam") {
  37. <h1 class="title">New Jam</h1>
  38. <form method="POST" action="/jams" class="box" style="max-width:480px">
  39. <div class="field">
  40. <label class="label">Date</label>
  41. <div class="control">
  42. <input class="input" type="date" name="date" required/>
  43. </div>
  44. </div>
  45. <div class="field">
  46. <label class="label">Location</label>
  47. <div class="control">
  48. <div class="select is-fullwidth">
  49. <select name="location" required>
  50. <option value="">— select —</option>
  51. for _, loc := range locations {
  52. <option value={ loc.Id }>{ loc.GetString("name") }</option>
  53. }
  54. </select>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="field">
  59. <label class="label">Notes</label>
  60. <div class="control">
  61. <textarea class="textarea" name="notes" rows="2"></textarea>
  62. </div>
  63. </div>
  64. <div class="field mt-4">
  65. <div class="control">
  66. <button class="button is-primary" type="submit">Create Jam</button>
  67. <a class="button ml-2" href="/jams">Cancel</a>
  68. </div>
  69. </div>
  70. </form>
  71. }
  72. }
  73. // SetlistRow is the view model for a single row in the setlist table.
  74. type SetlistRow struct {
  75. ID string
  76. Artist string
  77. Title string
  78. Played bool
  79. }
  80. // JamDetail renders a single jam and its setlist.
  81. templ JamDetail(jam *core.Record, location *core.Record, rows []SetlistRow) {
  82. @Layout("Jam — " + dateOnly(jam.GetString("date"))) {
  83. <div class="level">
  84. <div class="level-left">
  85. <h1 class="title">{ dateOnly(jam.GetString("date")) } — <a href={ templ.SafeURL("/locations/" + location.Id) }>{ location.GetString("name") }</a></h1>
  86. </div>
  87. </div>
  88. <div class="columns">
  89. <div class="column is-two-thirds">
  90. <h2 class="subtitle">Setlist</h2>
  91. <table class="table is-fullwidth" id="setlist">
  92. <thead>
  93. <tr><th>Artist</th><th>Title</th><th>Played</th><th></th></tr>
  94. </thead>
  95. <tbody id="setlist-rows">
  96. for _, row := range rows {
  97. @SetlistRowFrag(jam.Id, row)
  98. }
  99. </tbody>
  100. </table>
  101. <div class="mt-4" id="song-add-form">
  102. @SongAddForm(jam.Id)
  103. </div>
  104. </div>
  105. <div class="column">
  106. if jam.GetString("notes") != "" {
  107. <p><strong>Notes:</strong> { jam.GetString("notes") }</p>
  108. }
  109. </div>
  110. </div>
  111. }
  112. }
  113. // SetlistRowFrag renders a single setlist row (used for HTMX swap).
  114. templ SetlistRowFrag(jamID string, row SetlistRow) {
  115. <tr id={ "row-" + row.ID }>
  116. <td>{ row.Artist }</td>
  117. <td>{ row.Title }</td>
  118. <td>
  119. <input
  120. type="checkbox"
  121. if row.Played {
  122. checked
  123. }
  124. hx-patch={ "/setlist/" + row.ID + "/played" }
  125. hx-target={ "#row-" + row.ID }
  126. hx-swap="outerHTML"
  127. />
  128. </td>
  129. <td>
  130. <button
  131. class="button is-small is-ghost"
  132. hx-get={ "/setlist/" + row.ID + "/edit" }
  133. hx-target={ "#row-" + row.ID }
  134. hx-swap="outerHTML"
  135. >✎</button>
  136. <button
  137. class="delete"
  138. hx-delete={ "/setlist/" + row.ID }
  139. hx-target={ "#row-" + row.ID }
  140. hx-swap="outerHTML"
  141. hx-confirm="Remove this song from the setlist?"
  142. ></button>
  143. </td>
  144. </tr>
  145. }
  146. // SetlistEditFrag renders a setlist row as an inline edit form.
  147. templ SetlistEditFrag(row SetlistRow) {
  148. <tr id={ "row-" + row.ID }>
  149. <td><input class="input is-small" type="text" name="artist" value={ row.Artist } required/></td>
  150. <td><input class="input is-small" type="text" name="title" value={ row.Title } required/></td>
  151. <td>
  152. <input
  153. type="checkbox"
  154. name="played"
  155. if row.Played {
  156. checked
  157. }
  158. />
  159. </td>
  160. <td>
  161. <button
  162. class="button is-small is-primary mr-1"
  163. hx-patch={ "/setlist/" + row.ID }
  164. hx-include="closest tr"
  165. hx-target={ "#row-" + row.ID }
  166. hx-swap="outerHTML"
  167. >Save</button>
  168. <button
  169. class="button is-small"
  170. hx-get={ "/setlist/" + row.ID + "/view" }
  171. hx-target={ "#row-" + row.ID }
  172. hx-swap="outerHTML"
  173. >Cancel</button>
  174. </td>
  175. </tr>
  176. }
  177. // SongAddForm renders the add-song form for a jam. Artist has a typeahead
  178. // datalist (suggestions only; free-form text is always accepted).
  179. templ SongAddForm(jamID string) {
  180. <form
  181. hx-post={ "/jams/" + jamID + "/songs" }
  182. hx-target="#setlist-rows"
  183. hx-swap="beforeend"
  184. hx-on--after-request="if(event.detail.requestConfig.verb==='post') { this.reset(); const a=this.querySelector('[name=artist]'); setTimeout(()=>{a.focus();a.scrollIntoView({behavior:'smooth',block:'nearest'});},0); }"
  185. >
  186. <div class="field has-addons">
  187. <div class="control is-expanded">
  188. <input
  189. class="input"
  190. type="text"
  191. name="artist"
  192. placeholder="Artist"
  193. list="song-artist-list"
  194. hx-get="/songs/search"
  195. hx-trigger="input changed delay:300ms, change from:[name=title]"
  196. hx-target="#song-artist-list"
  197. hx-swap="innerHTML"
  198. hx-include="[name=title]"
  199. autocomplete="off"
  200. required
  201. />
  202. <datalist id="song-artist-list"></datalist>
  203. </div>
  204. <div class="control is-expanded">
  205. <input
  206. class="input"
  207. type="text"
  208. name="title"
  209. placeholder="Title"
  210. list="song-title-list"
  211. hx-get="/songs/search"
  212. hx-vals='{"field":"title"}'
  213. hx-trigger="input changed delay:300ms, change from:[name=artist]"
  214. hx-target="#song-title-list"
  215. hx-swap="innerHTML"
  216. hx-include="[name=artist]"
  217. autocomplete="off"
  218. required
  219. />
  220. <datalist id="song-title-list"></datalist>
  221. </div>
  222. <div class="control">
  223. <label class="checkbox" style="padding: 0.5em 0.75em">
  224. <input type="checkbox" name="played"/> Played
  225. </label>
  226. </div>
  227. <div class="control">
  228. <button class="button is-link" type="submit">Add</button>
  229. </div>
  230. </div>
  231. </form>
  232. }
PANIC: session(release): write data/sessions/7/a/7a3c0122a4bdf074: no space left on device

PANIC

session(release): write data/sessions/7/a/7a3c0122a4bdf074: no space left on device
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/session@v1.0.3/session.go:204 (0xb13e07)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:80 (0x967b75)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:114 (0x967bf6)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/recovery.go:161 (0x15baec4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/logger.go:40 (0x96b257)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:187 (0x972959)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:304 (0x973a01)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/macaron.go:218 (0x96c572)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:3311 (0x85a5cd)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:2073 (0x837f6f)
/my/cache/.heroku/go/go1.26.3/go/src/runtime/asm_amd64.s:1771 (0x493380)