Show spinner on login.

This commit is contained in:
Dominik Picheta 2018-05-11 17:41:06 +01:00
commit 17436010a2

View file

@ -11,11 +11,13 @@ when defined(js):
type type
LoginModal* = ref object LoginModal* = ref object
shown: bool shown: bool
loading: bool
onLogIn: proc () onLogIn: proc ()
onSignUp: proc () onSignUp: proc ()
error: Option[PostError] error: Option[PostError]
proc onLogInPost(httpStatus: int, response: kstring, state: LoginModal) = proc onLogInPost(httpStatus: int, response: kstring, state: LoginModal) =
state.loading = false
let status = httpStatus.HttpCode let status = httpStatus.HttpCode
if status == Http200: if status == Http200:
state.shown = false state.shown = false
@ -35,6 +37,7 @@ when defined(js):
)) ))
proc onLogInClick(ev: Event, n: VNode, state: LoginModal) = proc onLogInClick(ev: Event, n: VNode, state: LoginModal) =
state.loading = true
state.error = none[PostError]() state.error = none[PostError]()
let uri = makeUri("login") let uri = makeUri("login")
@ -91,7 +94,10 @@ when defined(js):
a(href="#reset-password-modal"): a(href="#reset-password-modal"):
text "Reset your password" text "Reset your password"
tdiv(class="modal-footer"): tdiv(class="modal-footer"):
button(class="btn btn-primary", button(class=class(
{"loading": state.loading},
"btn btn-primary"
),
onClick=(ev: Event, n: VNode) => onLogInClick(ev, n, state)): onClick=(ev: Event, n: VNode) => onLogInClick(ev, n, state)):
text "Log in" text "Log in"
button(class="btn", button(class="btn",