UX improvements in the LS client.
Mostly display of errors or successes and the ability to log out.ipc07
parent
a2d633f4fb
commit
9dd31ded64
|
@ -33,7 +33,11 @@ document.add-event-listener \DOMContentLoaded ->
|
||||||
user: model.user
|
user: model.user
|
||||||
token: model.token
|
token: model.token
|
||||||
|
|
||||||
on-model-update: -> projector.schedule-render!
|
on-model-update: ->
|
||||||
|
projector.schedule-render!
|
||||||
|
on-logout: ->
|
||||||
|
model.token := void
|
||||||
|
model.user := void
|
||||||
}
|
}
|
||||||
|
|
||||||
projector.schedule-render!
|
projector.schedule-render!
|
||||||
|
|
|
@ -25,17 +25,29 @@ default-heading-renderer = (self) ->
|
||||||
full-name = get-full-name self
|
full-name = get-full-name self
|
||||||
|
|
||||||
h \div.section {key: \heading} [
|
h \div.section {key: \heading} [
|
||||||
h \div.title.is-2 [ full-name ]
|
h \div.media [
|
||||||
|
h \div.media-content [
|
||||||
|
h \div.title.is-2 [ full-name ]
|
||||||
|
|
||||||
if full-name != self.user.login
|
if full-name != self.user.login
|
||||||
h \div.title.is-3.subtitle [
|
h \div.title.is-3.subtitle [
|
||||||
self.user.login
|
self.user.login
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if self.on-logout
|
||||||
|
h \div.media-right [
|
||||||
|
h \a {
|
||||||
|
onclick: ->
|
||||||
|
self.on-logout!
|
||||||
|
} [ "Logout" ]
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
Fields = {
|
Fields = {
|
||||||
render-text-input: (token, auth-ws, key, inputs, model) ->
|
render-text-input: (token, auth-ws, key, inputs, model, on-request) ->
|
||||||
upload = ->
|
upload = ->
|
||||||
console.log "clickity click", key, inputs[key], inputs
|
console.log "clickity click", key, inputs[key], inputs
|
||||||
return unless inputs[key]
|
return unless inputs[key]
|
||||||
|
@ -47,6 +59,7 @@ Fields = {
|
||||||
|
|
||||||
inputs[key] := void
|
inputs[key] := void
|
||||||
|
|
||||||
|
on-request!
|
||||||
auth-ws.set-extra token, "profile", payload
|
auth-ws.set-extra token, "profile", payload
|
||||||
|
|
||||||
h \div.field.has-addons {key: key} [
|
h \div.field.has-addons {key: key} [
|
||||||
|
@ -79,6 +92,7 @@ UserConfigurationPanel = (args) ->
|
||||||
heading-renderer: args.heading-renderer || default-heading-renderer
|
heading-renderer: args.heading-renderer || default-heading-renderer
|
||||||
|
|
||||||
on-model-update: args.on-model-update || ->
|
on-model-update: args.on-model-update || ->
|
||||||
|
on-logout: args.on-logout || void
|
||||||
|
|
||||||
model: args.model || [
|
model: args.model || [
|
||||||
["fullName", "Full Name", "string"]
|
["fullName", "Full Name", "string"]
|
||||||
|
@ -105,6 +119,20 @@ UserConfigurationPanel = (args) ->
|
||||||
|
|
||||||
self.on-model-update!
|
self.on-model-update!
|
||||||
|
|
||||||
|
auth-ws.add-event-listener \error, (message) ->
|
||||||
|
self.error := message.reason
|
||||||
|
|
||||||
|
self.on-model-update!
|
||||||
|
|
||||||
|
# Profile updates would be a \extra-updated, so this is specific to the
|
||||||
|
# password.
|
||||||
|
auth-ws.add-event-listener \user-edited, (message) ->
|
||||||
|
self.input["password.old"] := void
|
||||||
|
self.input["password.new"] := void
|
||||||
|
self.input["password.new2"] := void
|
||||||
|
self.success := "password"
|
||||||
|
self.on-model-update!
|
||||||
|
|
||||||
unless self.profile
|
unless self.profile
|
||||||
auth-ws.socket.onopen = ->
|
auth-ws.socket.onopen = ->
|
||||||
auth-ws.get-extra self.token, "profile"
|
auth-ws.get-extra self.token, "profile"
|
||||||
|
@ -131,7 +159,7 @@ UserConfigurationPanel = (args) ->
|
||||||
when "string", "image-url"
|
when "string", "image-url"
|
||||||
h \div.field { key: key } [
|
h \div.field { key: key } [
|
||||||
h \div.label [ label ]
|
h \div.label [ label ]
|
||||||
Fields.render-text-input self.token, auth-ws, key, self.input, self.profile
|
Fields.render-text-input self.token, auth-ws, key, self.input, self.profile, (-> self.error := void)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -141,27 +169,35 @@ UserConfigurationPanel = (args) ->
|
||||||
|
|
||||||
h \div.box { key: \password } [
|
h \div.box { key: \password } [
|
||||||
h \div.title.is-4 [ "Password" ]
|
h \div.title.is-4 [ "Password" ]
|
||||||
h \div.label [ "Old #{label}" ]
|
h \div.label [ "Old password" ]
|
||||||
h \div.control [
|
h \div.control [
|
||||||
h \input.input {
|
h \input.input {
|
||||||
type: \password
|
type: \password
|
||||||
|
value: self.input["password.old"]
|
||||||
oninput: (e) ->
|
oninput: (e) ->
|
||||||
self.input["password.old"] = e.target.value
|
self.input["password.old"] = e.target.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.error == "invalid credentials"
|
||||||
|
h \div.help.is-danger [
|
||||||
|
"The old password was invalid!"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
h \div.label [ "New #{label}" ]
|
h \div.label [ "New password" ]
|
||||||
h \div.control [
|
h \div.control [
|
||||||
h \input.input {
|
h \input.input {
|
||||||
type: \password
|
type: \password
|
||||||
|
value: self.input["password.new"]
|
||||||
oninput: (e) ->
|
oninput: (e) ->
|
||||||
self.input["password.new"] = e.target.value
|
self.input["password.new"] = e.target.value
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
h \div.label [ "New #{label} (repeat)" ]
|
h \div.label [ "New password (repeat)" ]
|
||||||
h \div.field.has-addons [
|
h \div.field.has-addons [
|
||||||
h \div.control.is-expanded [
|
h \div.control.is-expanded [
|
||||||
h \input.input {
|
h \input.input {
|
||||||
type: \password
|
type: \password
|
||||||
|
value: self.input["password.new2"]
|
||||||
oninput: (e) ->
|
oninput: (e) ->
|
||||||
self.input["password.new2"] = e.target.value
|
self.input["password.new2"] = e.target.value
|
||||||
}
|
}
|
||||||
|
@ -176,11 +212,17 @@ UserConfigurationPanel = (args) ->
|
||||||
if self.input["password.new"] != self.input["password.new2"]
|
if self.input["password.new"] != self.input["password.new2"]
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.error := void
|
||||||
auth-ws.update-password self.user.login, self.input["password.old"], self.input["password.new"]
|
auth-ws.update-password self.user.login, self.input["password.old"], self.input["password.new"]
|
||||||
|
|
||||||
} [ "Update" ]
|
} [ "Update" ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if self.success == "password"
|
||||||
|
h \div.help.is-success [
|
||||||
|
"Password successfully updated!"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.show-developer
|
if self.show-developer
|
||||||
|
|
Loading…
Reference in New Issue