Logout, navbar.

This commit is contained in:
Luka Vandervelden 2019-07-10 13:13:52 +02:00
parent f70f8a17f3
commit 0e86ca5806

View File

@ -376,6 +376,10 @@ KanbanSocket = (socket-url) ->
self.socket.onmessage = (event) -> self.socket.onmessage = (event) ->
self.on-message event self.on-message event
self.reopen = ->
self.socket.close!
self.open-socket!
self.open-socket! self.open-socket!
self.send = (opts) -> self.send = (opts) ->
@ -502,6 +506,25 @@ socket.on-message = (event) ->
console.log message console.log message
renderer = -> renderer = ->
render-navbar = ->
h \div.navbar [
h \div.navbar-start [
h \a.navbar-item.is-size-1 {
onclick: ->
model.viewed-project := undefined
model.current-view := "projects-list"
} [ "⌂" ]
]
h \div.navbar-end [
h \a.navbar-item {
onclick: ->
model.current-view := "login"
socket.reopen!
} [ "Logout" ]
]
]
h \div.section [ h \div.section [
switch model.current-view switch model.current-view
when "login" when "login"
@ -539,22 +562,16 @@ renderer = ->
] ]
when "project" when "project"
h \div [ h \div [
h \div.navbar [ render-navbar!
h \div.navbar-end [
h \a.navbar-item {
onclick: ->
model.viewed-project := undefined
model.current-view := "projects-list"
} [ "Go back" ]
]
]
if model.projects[model.viewed-project] if model.projects[model.viewed-project]
model.projects[model.viewed-project].render! model.projects[model.viewed-project].render!
] ]
when "projects-list" when "projects-list"
h \div#projects-list [ h \div#projects-list [
h \div (model.projects-list || []).map (project) -> render-navbar!
h \div.section (model.projects-list || []).map (project) ->
h \a.box { h \a.box {
key: project.id key: project.id
onclick: -> onclick: ->