         force:
             refreshModel: true
 
-    setupAjax: Em.on "init", ->
-        Em.$.ajaxSetup
+    setupAjax: @on "init", ->
+        $.ajaxSetup
             beforeSend: (xhr) ->
                 xhr.setRequestHeader "X-OPENXPKI-Client", "1"
 
     needReboot: [ "login", "logout", "login!logout", "welcome" ]
 
-    source: Em.computed -> Em.Object.create
-        page: null
-        ping: null
-        refresh: null
-        structure: null
-        rtoken: null
-        status: null
-        tabs: []
-        navEntries: []
+    source: EmberObject.extend
+        page: tracked()
+        ping: tracked()
+        refresh: tracked()
+        structure: tracked()
+        rtoken: tracked()
+        status: tracked()
+        modal: tracked()
+        tabs: A []          # Ember Arrays are automatically tracked
+        navEntries: A []    # Ember Arrays are automatically tracked
 
     beforeModel: (req) ->
         if req.queryParams.force
             delete req.queryParams.force
 
-        source = @get "source"
         model_id = req.params.openxpki.model_id
 
-        if not source.get("navEntries.length") or model_id in @needReboot
+        if not this.source.navEntries.length or model_id in @needReboot
             @sendAjax data:
                 page: "bootstrap!structure"
                 baseurl: window.location.pathname
 
     model: (req) ->
-        navEntries = @get "source.navEntries"
         data = page: req.model_id
         data.limit = req.limit if req.limit
         data.startat = req.startat if req.startat
 
-        entries = navEntries.reduce (p, n) ->
+        entries = this.source.navEntries.reduce (p, n) ->
             p.concat(n, n.entries||[])
         , []
 

import Em from "components-ember"

Route = Em.Route.extend
    queryParams:
        startat:
            refreshModel: true

        else if req.model_id in @needReboot
            data.target = "top"

        this.source.page = req.model_id
        @sendAjax
            data: data
        .then (doc) ->
            this.source

    doPing: (cfg) ->
        this.source.ping = later @, =>
            $.ajax
                url: cfg.href
            @doPing cfg
        , cfg.timeout


    sendAjax: (req) ->
        req.dataType = "json"
        req.type ?= if req?.data?.action then "POST" else "GET"
        req.url ?= @config.url
        req.data._ = new Date().getTime()
        $(".loading").addClass "in-progress"

        if req.type is "POST"
            req.data._rtoken = this.source.rtoken

        target = req.data.target or "self"
        if target is "self"
            if this.source.modal
                target = "modal"
            else if this.source.tabs.length > 1
                target = "active"
            else
                target = "top"

        if this.source.refresh
            cancel this.source.refresh
            this.source.refresh = null
            $(".refresh").removeClass "in-progress"

        new Promise (resolve, reject) =>
            $.ajax(req).then (doc) =>
                this.source.beginPropertyChanges()

                this.source.status = doc.status
                this.source.modal = null

                if doc.ping
                    cancel this.source.ping if this.source.ping
                    @doPing doc.ping

                if doc.refresh
                    this.source.refresh = later(@, ->
                        @sendAjax data:
                            page: doc.refresh.href
                    , doc.refresh.timeout)
                    scheduleOnce "afterRender", =>
                        $(".refresh").addClass "in-progress"

                if doc.goto
