Initialization and settings upgrades

This commit is contained in:
2018-11-20 12:17:23 -03:00
parent 3bd7c06e60
commit 286c229ef9
2 changed files with 43 additions and 21 deletions
+35 -12
View File
@@ -25,18 +25,41 @@ export default Ember.Route.extend DunlopApplicationRoute,
# record.unloadRecord()
preloadResources: ->
@store.findAll 'panda/workflow-instance-type'
@store.findAll 'panda/organization'
@store.findAll 'user'
@store.findAll 'panda/tracker-subject'
@set 'router.globals.adapters', @store.findAll 'panda/adapter'
#Ember.RSVP.all([
# @store.findAll 'workflow-instance-type'
# @store.findAll 'organization'
# @store.findAll 'user'
# @store.findAll 'tracker-subject'
#]).then =>
# @set 'router.globals.preload_resources_fulfilled', true
Ember.RSVP.all([
@store.findAll 'panda/workflow-instance-type'
@store.findAll 'panda/organization'
@store.findAll 'user'
@store.findAll 'panda/tracker-subject'
@store.findAll 'panda/adapter'
@store.query('dunlop/user-filter', q: {scope_key_matches: 'panda/%'})
@load_backend_settings()
]).catch((reason) =>
@get('initial_resources_reject')(reason)
).then (results...) =>
@set 'router.globals.adapters', results[4] #.content ? this is a promise, could be an array @store.peekAll('panda/adapter')
@get('initial_resources_resolve')()
load_backend_settings: ->
session = @get('session')
url = "#{config.apiHost}/#{config.apiNamespace}/settings"
success = (settings) =>
# iterate for data bindings (environment)
return unless settings.data?
for setting in settings.data
@set "router.globals.#{setting.id}", setting.attributes.value
#Ember.assign @get('router.globals'), settings
window.app_globals = @get('router.globals')
request =
url: url
type: 'GET'
contentType: "application/json"
success: success
dataType: "json"
if get(session, 'isAuthenticated')
session.authorize 'authorizer:devise', (key, authorization) ->
request.crossDomain = true
request.headers = {"#{key}": authorization}
Ember.$.ajax request
actions:
debug: -> debugger
+8 -9
View File
@@ -14,15 +14,14 @@
.ui.floating.info.message
i.close.icon{action (mut globals.flash.notice) ''}
= globals.flash.notice
= outlet
/if globals.preload_resources_fulfilled
/ = outlet
/else
/ .ui.icon.message
/ i.notched.circle.loading.icon
/ .content
/ .header Preloading resources...
/ p Loading resources globally required before continuing with the application.
if globals.initial_resources_fulfilled
= outlet
else
.ui.icon.message
i.notched.circle.loading.icon
.content
.header Initial resources not loaded...
p Loading resources globally required before continuing with the application.
/button.basic.button{ action 'debug'} debug
= outlet 'modal'