gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit40bf3b9740bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre40bf3b97/components/timezone.hl

2.5 KB

  1. // components/timezone.hl — THE TIME ZONE of the signed-in account (ident#40.3), placed by components/home.hl on `/`. The host passes in
  2. // the account's current zone (timeZone); this component owns the input, the browser's zone and the save (face changeTimeZone, which
  3. // asks lib/accounts.hl setTimeZone). The host shows the messages: $parent.status(message, notice) and, after a save, $parent.zoneSaved(zone).
  4. import { accountOfSession, setTimeZone } from '../lib/accounts.hl'
  5. timeZone = ''
  6. tzInput = timeZone
  7. Style {
  8. '#timezonesection' {
  9. marginTop = '.6rem'
  10. }
  11. }
  12. View {
  13. section { id = "timezonesection"
  14. h2 { "Time zone" }
  15. p { class = "lead" "Taken from your browser at your first login. Currently " strong { id = "timezone" timeZone } "." }
  16. p { id = "digestnote" class = "lead" "Your daily mail of notifications comes at 17:00 in this time zone." }
  17. form { id = "tzform"
  18. on submit(e) {
  19. e.preventDefault()
  20. emit saveZone(e)
  21. }
  22. label { "Time zone (IANA name, e.g. Europe/Vienna)"
  23. input { id = "tzinput" name = "timeZone" autocomplete = "off" maxlength = "64" required = "required" value = tzInput on input(e) { emit setTz(e.target.value) } }
  24. }
  25. formButtons {
  26. button { id = "savetz" type = "submit" "Save time zone" }
  27. button { id = "browsertz" type = "button" class = "quiet" "Use this browser's" on click(e) { emit useBrowserZone(e) } }
  28. }
  29. }
  30. }
  31. }
  32. on setTz(v) { tzInput = v }
  33. // the browser's own time zone (IANA name) and whether a name is one it knows (`Intl` is a
  34. // browser global of client code, hybriel#18)
  35. browserZone = () => { return Intl.DateTimeFormat().resolvedOptions().timeZone }
  36. knownZone = (v) => { return v == 'UTC' || Intl.supportedValuesOf('timeZone').includes(v) }
  37. on useBrowserZone(e) { tzInput = browserZone() }
  38. on saveZone(e) {
  39. $parent.status('', '')
  40. v = tzInput.trim()
  41. if (!knownZone(v)) {
  42. $parent.status('this browser does not know the time zone “' + v + '”', '')
  43. return null
  44. }
  45. r = emit server changeTimeZone(v)
  46. if (r == null) {
  47. $parent.status('the server did not answer — try again', '')
  48. return null
  49. }
  50. if (r.error != null) {
  51. $parent.status(r.error, '')
  52. return null
  53. }
  54. tzInput = r.timeZone
  55. $parent.zoneSaved(r.timeZone)
  56. }
  57. // A face runs on a BLANK instance (its arguments and its imports only); the account comes from the session.
  58. on server changeTimeZone(tz, session) {
  59. let me = accountOfSession(&session)
  60. if (me == null) { return { error = 'you are not signed in' } }
  61. r = setTimeZone(me.id, tz)
  62. if (r.error != null) { return r }
  63. return { timeZone = r.account.timeZone }
  64. }

Branches

Latest commits

  • 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
  • 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
  • d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
  • ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre
  • 47e516afident#33 ident#34: the identity form's avatar rules move into identityform.hl; the preview and Remove button are hidden with the hidden attribute instead of built class strings (avatarPreviewClass, avatarRemoveClass gone)mre
  • 5cb5cf0eident#33: the code field's look moves into codestep.hl's Stylemre
  • f421cd60ident#33: the shell's own rules (user menu address, offline note, network probe) move into main.hl's Stylemre
  • c512fb96Merge branch 'f4-homesplit' into mainIdent
  • 07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre
  • 59e8fcc1ident#40.3: the app's identity choice is one component (components/chooseidentity.hl); its face chooseIdentity moves with itmre
  • e23efdfcident#40.3: the identity list is one component (components/identitylist.hl); its delete and face dropIdentity move with itmre
  • e24b59a6ident#40.3: the time zone is one component (components/timezone.hl); its face changeTimeZone moves with itmre
  • 8cbc5717ident#40.3: the email step is one component (components/emailstep.hl) placed by home.hl and embed.hlmre
  • 6fad3bd2Merge branch 'f3-codestep' into mainIdent
  • 51e387f2|||PR ident#40 the code step is one component (components/codestep.hl) placed by home.hl and embed.hl; its verify face, setCode, browserZone and verify call exist once (#40.2)mre
  • c28bddeeMerge branch 'f2-shell' into mainIdent
  • c3a40ff6|||PR ident#40 one shell for the app and /start (account part off on /start, #40.1); startshell.hl removed; unused signOut faces gone (#40.4)mre
  • 060f3870ident#40.4: use the shell sign-out faces in regression gatesmre
  • 9b94aa6aMerge branch 'f1b-cleanup' into mainIdent
  • edcfce3f|||PR ident#41 ident#43 ident#44 login error page as a component (same status codes and text, pixel-identical), declarations and route wiring cleaned upmre