daisho
Version:
Modular dashboard framework
56 lines (42 loc) • 1.35 kB
text/coffeescript
import El from 'el.js'
import Events from '../events'
import m from '../mediator'
import html from '../templates/main'
export default class Main extends El.Form
tag: 'daisho-main'
html: html
configs:
'activeOrg': []
'search': []
error: null
orgs: null
lastRoot: null
init: ->
# use the parent data as data, this is special case
=
super()
# should have logged in by now do grab the orgs and look up active org key
= {}
for i, org of .get 'orgs'
[i] = org.fullName
.setKey .get('orgs')[.get('activeOrg')]['live-secret-key']
# when things are updated, update to latest page
'update', =>
current = ?.page?.current?.root
if current? && current !=
$el = $(current)
$page = $().find '#page'
$page.children().detach()
$page.append $el
current.scheduleUpdate?()
= current
# if active org is updated, restart the app
m.on Events.Change, (name, val)=>
if name == 'activeOrg'
.setKey .get('orgs')[val]['live-secret-key']
requestAnimationFrame ->
window.location.reload()
logout: ->
m.trigger Events.Logout, res
window.location.reload()
_submit: (event) ->