From 03cd05478ea0b6fd495d95a428b4a8ae7c5ab8f1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 19 Oct 2015 14:06:12 +0200 Subject: [PATCH] Added loading screen in admin interface. After all features are implemented, a more generic controller call will do the job. --- .../controllers/_application_controller.coffee | 15 +++++++++++++++ .../app/controllers/_channel/email.coffee | 5 +++++ .../app/controllers/_settings/area.coffee | 2 ++ .../javascripts/app/controllers/calendar.coffee | 2 ++ .../app/controllers/object_manager.coffee | 2 ++ .../javascripts/app/controllers/session.coffee | 2 ++ .../javascripts/app/controllers/sla.coffee | 5 ++--- .../app/controllers/translation.coffee | 2 ++ .../javascripts/app/controllers/trigger.coffee | 5 ++--- .../javascripts/app/controllers/users.coffee | 17 +++++++++-------- .../javascripts/app/lib/app_post/delay.coffee | 12 ++++++------ .../app/lib/app_post/interval.coffee | 12 ++++++------ .../app/views/generic/page_loading.jst.eco | 4 ++++ 13 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 app/assets/javascripts/app/views/generic/page_loading.jst.eco diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index 619116a2a..47728e507 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -531,6 +531,21 @@ class App.Controller extends Spine.Controller stopPropagation: (e) -> 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 constructor: -> super diff --git a/app/assets/javascripts/app/controllers/_channel/email.coffee b/app/assets/javascripts/app/controllers/_channel/email.coffee index fa7504944..e23878755 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.coffee @@ -244,6 +244,9 @@ class App.ChannelEmailAccountOverview extends App.Controller #@load() load: => + + @startLoading() + @ajax( id: 'email_index' type: 'GET' @@ -251,6 +254,8 @@ class App.ChannelEmailAccountOverview extends App.Controller processData: true success: (data, status, xhr) => + @stopLoading() + # load assets App.Collection.loadAssets(data.assets) diff --git a/app/assets/javascripts/app/controllers/_settings/area.coffee b/app/assets/javascripts/app/controllers/_settings/area.coffee index 9921a74d8..f7ae38654 100644 --- a/app/assets/javascripts/app/controllers/_settings/area.coffee +++ b/app/assets/javascripts/app/controllers/_settings/area.coffee @@ -8,12 +8,14 @@ class App.SettingsArea extends App.Controller @load() load: -> + @startLoading() @ajax( id: "setting_area_#{@area}" type: 'GET' url: "#{@apiPath}/settings/area/#{@area}" processData: true success: (data, status, xhr) => + @stopLoading() App.Collection.load( localStorage: false, type: 'Setting', data: data ) @render() ) diff --git a/app/assets/javascripts/app/controllers/calendar.coffee b/app/assets/javascripts/app/controllers/calendar.coffee index 30a16400b..fdb2a21d0 100644 --- a/app/assets/javascripts/app/controllers/calendar.coffee +++ b/app/assets/javascripts/app/controllers/calendar.coffee @@ -16,6 +16,7 @@ class Index extends App.ControllerContent #@load() load: => + @startLoading() @ajax( id: 'calendar_index' type: 'GET' @@ -29,6 +30,7 @@ class Index extends App.ControllerContent # load assets App.Collection.loadAssets(data.assets) + @stopLoading() @render(data) ) diff --git a/app/assets/javascripts/app/controllers/object_manager.coffee b/app/assets/javascripts/app/controllers/object_manager.coffee index e963aa622..e35c950d5 100644 --- a/app/assets/javascripts/app/controllers/object_manager.coffee +++ b/app/assets/javascripts/app/controllers/object_manager.coffee @@ -10,12 +10,14 @@ class Index extends App.ControllerTabs @title 'Objects', true # get data + @startLoading() @ajax( id: 'object_manager_attributes_list' type: 'GET' url: @apiPath + '/object_manager_attributes_list' processData: true success: (data, status, xhr) => + @stopLoading() @build(data.objects) ) diff --git a/app/assets/javascripts/app/controllers/session.coffee b/app/assets/javascripts/app/controllers/session.coffee index b208ee116..f149c081b 100644 --- a/app/assets/javascripts/app/controllers/session.coffee +++ b/app/assets/javascripts/app/controllers/session.coffee @@ -20,11 +20,13 @@ class Index extends App.ControllerContent # fetch data, render view load: -> + @startLoading() @ajax( id: 'sessions' type: 'GET' url: @apiPath + '/sessions' success: (data) => + @stopLoading() @render(data) ) diff --git a/app/assets/javascripts/app/controllers/sla.coffee b/app/assets/javascripts/app/controllers/sla.coffee index 1dcb5b536..d098c2356 100644 --- a/app/assets/javascripts/app/controllers/sla.coffee +++ b/app/assets/javascripts/app/controllers/sla.coffee @@ -15,16 +15,15 @@ class Index extends App.ControllerContent #@load() load: => + @startLoading() @ajax( id: 'sla_index' type: 'GET' url: @apiPath + '/slas' processData: true success: (data, status, xhr) => - - # load assets App.Collection.loadAssets(data.assets) - + @stopLoading() @render(data) ) diff --git a/app/assets/javascripts/app/controllers/translation.coffee b/app/assets/javascripts/app/controllers/translation.coffee index ef9ac2c5a..5362752f2 100644 --- a/app/assets/javascripts/app/controllers/translation.coffee +++ b/app/assets/javascripts/app/controllers/translation.coffee @@ -255,12 +255,14 @@ class TranslationList extends App.Controller ) load: => + @startLoading() @ajax( id: 'translations_admin' type: 'GET' url: @apiPath + "/translations/admin/lang/#{@locale}" processData: true success: (data, status, xhr) => + @stopLoading() @render(data) ) diff --git a/app/assets/javascripts/app/controllers/trigger.coffee b/app/assets/javascripts/app/controllers/trigger.coffee index 7ce2a4e33..123f79965 100644 --- a/app/assets/javascripts/app/controllers/trigger.coffee +++ b/app/assets/javascripts/app/controllers/trigger.coffee @@ -47,16 +47,15 @@ class App.TriggerTime extends App.Controller #@load() load: => + @startLoading() @ajax( id: 'trigger_time_index' type: 'GET' url: @apiPath + '/jobs' processData: true success: (data, status, xhr) => - - # load assets #App.Collection.loadAssets(data.assets) - + @stopLoading() @render(data) ) diff --git a/app/assets/javascripts/app/controllers/users.coffee b/app/assets/javascripts/app/controllers/users.coffee index fc059be15..7cb4dc376 100644 --- a/app/assets/javascripts/app/controllers/users.coffee +++ b/app/assets/javascripts/app/controllers/users.coffee @@ -49,6 +49,7 @@ class Index extends App.Controller @recent() renderResult: (user_ids = []) -> + @stopLoading() callbackHeader = (header) -> attribute = @@ -126,6 +127,7 @@ class Index extends App.Controller @$('.tab.active').each( (i,d) -> role_ids.push $(d).data('id') ) + @startLoading(@$('.table-overview')) App.Ajax.request( id: 'search' type: 'GET' @@ -137,11 +139,10 @@ class Index extends App.Controller full: 1 processData: true, success: (data, status, xhr) => - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @renderResult(data.user_ids) + done: => + @stopLoading() ) recent: => @@ -149,6 +150,7 @@ class Index extends App.Controller @$('.tab.active').each( (i,d) -> role_ids.push $(d).data('id') ) + @startLoading(@$('.table-overview')) App.Ajax.request( id: 'search' type: 'GET' @@ -159,11 +161,10 @@ class Index extends App.Controller full: 1 processData: true, success: (data, status, xhr) => - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @renderResult(data.user_ids) + complete: => + @stopLoading() ) new: (e) -> diff --git a/app/assets/javascripts/app/lib/app_post/delay.coffee b/app/assets/javascripts/app/lib/app_post/delay.coffee index 9c3d09f5e..0588be2ac 100644 --- a/app/assets/javascripts/app/lib/app_post/delay.coffee +++ b/app/assets/javascripts/app/lib/app_post/delay.coffee @@ -32,7 +32,7 @@ class _delaySingleton extends Spine.Module constructor: -> @levelStack = {} - set: ( callback, timeout, key, level ) -> + set: ( callback, timeout, key, level ) => if !level level = '_all' @@ -59,9 +59,9 @@ class _delaySingleton extends Spine.Module level: level } - return delay_id + key.toString() - clear: ( key, level ) -> + clear: ( key, level ) => if !level level = '_all' @@ -80,19 +80,19 @@ class _delaySingleton extends Spine.Module if _.isEmpty( @levelStack[ level ] ) delete @levelStack[ level ] - clearLevel: (level) -> + clearLevel: (level) => return if !@levelStack[ level ] for key, data of @levelStack[ level ] @clear( key, level ) delete @levelStack[level] - reset: -> + reset: => for level, items of @levelStack for key, data of items @clear( key, level ) @levelStack[level] = {} true - _all: -> + _all: => @levelStack diff --git a/app/assets/javascripts/app/lib/app_post/interval.coffee b/app/assets/javascripts/app/lib/app_post/interval.coffee index fec999e2b..757d3f2e4 100644 --- a/app/assets/javascripts/app/lib/app_post/interval.coffee +++ b/app/assets/javascripts/app/lib/app_post/interval.coffee @@ -32,7 +32,7 @@ class _intervalSingleton extends Spine.Module constructor: -> @levelStack = {} - set: ( callback, timeout, key, level ) -> + set: ( callback, timeout, key, level ) => if !level level = '_all' @@ -57,9 +57,9 @@ class _intervalSingleton extends Spine.Module level: level } - return interval_id + key.toString() - clear: ( key, level ) -> + clear: ( key, level ) => if !level level = '_all' @@ -78,18 +78,18 @@ class _intervalSingleton extends Spine.Module if _.isEmpty( @levelStack[ level ] ) delete @levelStack[ level ] - clearLevel: (level) -> + clearLevel: (level) => return if !@levelStack[ level ] for key, data of @levelStack[ level ] @clear( key, level ) delete @levelStack[level] - reset: -> + reset: => for level, items of @levelStack for key, data of items @clear( key, level ) @levelStack[level] = {} true - _all: -> + _all: => @levelStack diff --git a/app/assets/javascripts/app/views/generic/page_loading.jst.eco b/app/assets/javascripts/app/views/generic/page_loading.jst.eco new file mode 100644 index 000000000..01ee126fc --- /dev/null +++ b/app/assets/javascripts/app/views/generic/page_loading.jst.eco @@ -0,0 +1,4 @@ +
+
+
<%- @T('Loading...') %>
+