summaryrefslogtreecommitdiff
path: root/ui/app/app.js
blob: a27cba6c473407145a9620dd4953282b939d4ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import bitmask from 'lib/bitmask'
import Account from 'models/account'
import Provider from 'models/provider'
import EventLogger from 'lib/event_logger'

class Application {
  constructor() {
  }

  //
  // main entry point for the application
  //
  initialize() {
    this.ev = new EventLogger()
    if (this.debugging()) {
      this.show(this.debug_panel)
    } else {
      this.start()
    }
  }

  start() {
    Provider.list(false).then(domains => {
      Account.initializeList(domains)
      Account.active().then(account => {
        if (account == null) {
          this.show('greeter')
        } else {
          Account.addPrimary(account)
          this.show('main', {initialAccount: account})
        }
      }, error => {
        this.show('error', {error: error})
      })
    }, error => {
      this.show('error', {error: error})
    })
  }

  show(panel, properties) {
    this.switcher.show(panel, properties)
  }

  debugging() {
    this.debug_panel = window.location.hash.replace('#', '')
    return this.debug_panel && this.debug_panel != 'main'
  }
}

var App = new Application
export default App