Added loading screen in admin interface. After all features are implemented, a more generic controller call will do the job.

This commit is contained in:
Martin Edenhofer 2015-10-19 14:06:12 +02:00
parent adca7db4fe
commit 03cd05478e
13 changed files with 59 additions and 26 deletions

View file

@ -531,6 +531,21 @@ class App.Controller extends Spine.Controller
stopPropagation: (e) -> stopPropagation: (e) ->
e.stopPropagation() e.stopPropagation()
startLoading: (el) =>
return if @initLoadingDone && !el
@initLoadingDone = true
@stopLoading()
later = =>
if el
el.html App.view('generic/page_loading')()
else
@html App.view('generic/page_loading')()
@initLoadingDoneDelay = @delay(later, 2800)
stopLoading: =>
return if !@initLoadingDoneDelay
@clearDelay(@initLoadingDoneDelay)
class App.ControllerPermanent extends App.Controller class App.ControllerPermanent extends App.Controller
constructor: -> constructor: ->
super super

View file

@ -244,6 +244,9 @@ class App.ChannelEmailAccountOverview extends App.Controller
#@load() #@load()
load: => load: =>
@startLoading()
@ajax( @ajax(
id: 'email_index' id: 'email_index'
type: 'GET' type: 'GET'
@ -251,6 +254,8 @@ class App.ChannelEmailAccountOverview extends App.Controller
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@stopLoading()
# load assets # load assets
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)

View file

@ -8,12 +8,14 @@ class App.SettingsArea extends App.Controller
@load() @load()
load: -> load: ->
@startLoading()
@ajax( @ajax(
id: "setting_area_#{@area}" id: "setting_area_#{@area}"
type: 'GET' type: 'GET'
url: "#{@apiPath}/settings/area/#{@area}" url: "#{@apiPath}/settings/area/#{@area}"
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@stopLoading()
App.Collection.load( localStorage: false, type: 'Setting', data: data ) App.Collection.load( localStorage: false, type: 'Setting', data: data )
@render() @render()
) )

View file

@ -16,6 +16,7 @@ class Index extends App.ControllerContent
#@load() #@load()
load: => load: =>
@startLoading()
@ajax( @ajax(
id: 'calendar_index' id: 'calendar_index'
type: 'GET' type: 'GET'
@ -29,6 +30,7 @@ class Index extends App.ControllerContent
# load assets # load assets
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)
@stopLoading()
@render(data) @render(data)
) )

View file

@ -10,12 +10,14 @@ class Index extends App.ControllerTabs
@title 'Objects', true @title 'Objects', true
# get data # get data
@startLoading()
@ajax( @ajax(
id: 'object_manager_attributes_list' id: 'object_manager_attributes_list'
type: 'GET' type: 'GET'
url: @apiPath + '/object_manager_attributes_list' url: @apiPath + '/object_manager_attributes_list'
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@stopLoading()
@build(data.objects) @build(data.objects)
) )

View file

@ -20,11 +20,13 @@ class Index extends App.ControllerContent
# fetch data, render view # fetch data, render view
load: -> load: ->
@startLoading()
@ajax( @ajax(
id: 'sessions' id: 'sessions'
type: 'GET' type: 'GET'
url: @apiPath + '/sessions' url: @apiPath + '/sessions'
success: (data) => success: (data) =>
@stopLoading()
@render(data) @render(data)
) )

View file

@ -15,16 +15,15 @@ class Index extends App.ControllerContent
#@load() #@load()
load: => load: =>
@startLoading()
@ajax( @ajax(
id: 'sla_index' id: 'sla_index'
type: 'GET' type: 'GET'
url: @apiPath + '/slas' url: @apiPath + '/slas'
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# load assets
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)
@stopLoading()
@render(data) @render(data)
) )

View file

@ -255,12 +255,14 @@ class TranslationList extends App.Controller
) )
load: => load: =>
@startLoading()
@ajax( @ajax(
id: 'translations_admin' id: 'translations_admin'
type: 'GET' type: 'GET'
url: @apiPath + "/translations/admin/lang/#{@locale}" url: @apiPath + "/translations/admin/lang/#{@locale}"
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@stopLoading()
@render(data) @render(data)
) )

View file

@ -47,16 +47,15 @@ class App.TriggerTime extends App.Controller
#@load() #@load()
load: => load: =>
@startLoading()
@ajax( @ajax(
id: 'trigger_time_index' id: 'trigger_time_index'
type: 'GET' type: 'GET'
url: @apiPath + '/jobs' url: @apiPath + '/jobs'
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# load assets
#App.Collection.loadAssets(data.assets) #App.Collection.loadAssets(data.assets)
@stopLoading()
@render(data) @render(data)
) )

View file

@ -49,6 +49,7 @@ class Index extends App.Controller
@recent() @recent()
renderResult: (user_ids = []) -> renderResult: (user_ids = []) ->
@stopLoading()
callbackHeader = (header) -> callbackHeader = (header) ->
attribute = attribute =
@ -126,6 +127,7 @@ class Index extends App.Controller
@$('.tab.active').each( (i,d) -> @$('.tab.active').each( (i,d) ->
role_ids.push $(d).data('id') role_ids.push $(d).data('id')
) )
@startLoading(@$('.table-overview'))
App.Ajax.request( App.Ajax.request(
id: 'search' id: 'search'
type: 'GET' type: 'GET'
@ -137,11 +139,10 @@ class Index extends App.Controller
full: 1 full: 1
processData: true, processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
# load assets
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)
@renderResult(data.user_ids) @renderResult(data.user_ids)
done: =>
@stopLoading()
) )
recent: => recent: =>
@ -149,6 +150,7 @@ class Index extends App.Controller
@$('.tab.active').each( (i,d) -> @$('.tab.active').each( (i,d) ->
role_ids.push $(d).data('id') role_ids.push $(d).data('id')
) )
@startLoading(@$('.table-overview'))
App.Ajax.request( App.Ajax.request(
id: 'search' id: 'search'
type: 'GET' type: 'GET'
@ -159,11 +161,10 @@ class Index extends App.Controller
full: 1 full: 1
processData: true, processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
# load assets
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)
@renderResult(data.user_ids) @renderResult(data.user_ids)
complete: =>
@stopLoading()
) )
new: (e) -> new: (e) ->

View file

@ -32,7 +32,7 @@ class _delaySingleton extends Spine.Module
constructor: -> constructor: ->
@levelStack = {} @levelStack = {}
set: ( callback, timeout, key, level ) -> set: ( callback, timeout, key, level ) =>
if !level if !level
level = '_all' level = '_all'
@ -59,9 +59,9 @@ class _delaySingleton extends Spine.Module
level: level level: level
} }
return delay_id key.toString()
clear: ( key, level ) -> clear: ( key, level ) =>
if !level if !level
level = '_all' level = '_all'
@ -80,19 +80,19 @@ class _delaySingleton extends Spine.Module
if _.isEmpty( @levelStack[ level ] ) if _.isEmpty( @levelStack[ level ] )
delete @levelStack[ level ] delete @levelStack[ level ]
clearLevel: (level) -> clearLevel: (level) =>
return if !@levelStack[ level ] return if !@levelStack[ level ]
for key, data of @levelStack[ level ] for key, data of @levelStack[ level ]
@clear( key, level ) @clear( key, level )
delete @levelStack[level] delete @levelStack[level]
reset: -> reset: =>
for level, items of @levelStack for level, items of @levelStack
for key, data of items for key, data of items
@clear( key, level ) @clear( key, level )
@levelStack[level] = {} @levelStack[level] = {}
true true
_all: -> _all: =>
@levelStack @levelStack

View file

@ -32,7 +32,7 @@ class _intervalSingleton extends Spine.Module
constructor: -> constructor: ->
@levelStack = {} @levelStack = {}
set: ( callback, timeout, key, level ) -> set: ( callback, timeout, key, level ) =>
if !level if !level
level = '_all' level = '_all'
@ -57,9 +57,9 @@ class _intervalSingleton extends Spine.Module
level: level level: level
} }
return interval_id key.toString()
clear: ( key, level ) -> clear: ( key, level ) =>
if !level if !level
level = '_all' level = '_all'
@ -78,18 +78,18 @@ class _intervalSingleton extends Spine.Module
if _.isEmpty( @levelStack[ level ] ) if _.isEmpty( @levelStack[ level ] )
delete @levelStack[ level ] delete @levelStack[ level ]
clearLevel: (level) -> clearLevel: (level) =>
return if !@levelStack[ level ] return if !@levelStack[ level ]
for key, data of @levelStack[ level ] for key, data of @levelStack[ level ]
@clear( key, level ) @clear( key, level )
delete @levelStack[level] delete @levelStack[level]
reset: -> reset: =>
for level, items of @levelStack for level, items of @levelStack
for key, data of items for key, data of items
@clear( key, level ) @clear( key, level )
@levelStack[level] = {} @levelStack[level] = {}
true true
_all: -> _all: =>
@levelStack @levelStack

View file

@ -0,0 +1,4 @@
<div class="page-loading">
<div class="small loading icon"></div>
<div class="page-loading-label"><%- @T('Loading...') %></div>
</div>