]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5718 Show error popup
authorStas Vilchik <vilchiks@gmail.com>
Tue, 4 Nov 2014 09:37:29 +0000 (10:37 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 4 Nov 2014 09:38:45 +0000 (10:38 +0100)
server/sonar-web/src/main/coffee/common/processes.coffee
server/sonar-web/src/main/coffee/issues/controller.coffee
server/sonar-web/src/main/less/ui.less
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 3e63cf83e069b5f3928779f0b7849873bcb97c1a..21c7ab1266c17d47944e8eee1f8cbb1ad33a65ff 100644 (file)
@@ -9,8 +9,8 @@ _.extend process,
 
   addBackgroundProcess: ->
     uid = _.uniqueId 'process'
-    @queue[uid] = new Date()
-    setTimeout (=> @showSpinner uid if @isBackgroundProcessAlive uid), @timeout
+    @renderSpinner uid
+    @queue[uid] = setTimeout (=> @showSpinner uid), @timeout
     uid
 
 
@@ -19,23 +19,47 @@ _.extend process,
 
 
   finishBackgroundProcess: (uid) ->
-    delete @queue[uid]
-    @removeSpinner uid
+    if @isBackgroundProcessAlive uid
+      clearInterval @queue[uid]
+      delete @queue[uid]
+      @removeSpinner uid
 
 
-  showSpinner: (uid) ->
+  failBackgroundProcess: (uid) ->
+    if @isBackgroundProcessAlive uid
+      clearInterval @queue[uid]
+      delete @queue[uid]
+      spinner = @getSpinner uid
+      spinner.addClass 'process-spinner-failed'
+      spinner.text t 'process.fail'
+      close = $('<button></button>').html('<i class="icon-close"></i>').addClass 'process-spinner-close'
+      close.appendTo spinner
+      close.on 'click', => @removeSpinner uid
+
+
+  renderSpinner: (uid) ->
     id = "spinner-#{uid}"
     spinner = $ '<div></div>'
     spinner.addClass 'process-spinner'
     spinner.prop 'id', id
-    spinner.text t 'process.still_working'
+    text = t 'process.still_working'
+    text = 'Still Working...' if text == 'process.still_working'
+    spinner.text text
     spinner.appendTo $('body')
+
+
+  showSpinner: (uid) ->
+    spinner = @getSpinner(uid)
     setTimeout (-> spinner.addClass 'shown'), @fadeTimeout
 
 
   removeSpinner: (uid) ->
+    @getSpinner(uid).remove()
+
+
+  getSpinner: (uid) ->
     id = "spinner-#{uid}"
-    $('#' + id).remove()
+    $('#' + id)
 
 
 _.extend window, process: process
index 58263c8dc0218d2087f67b9d1143f5959666332e..2c00adf1641fad3b5ffb7f02e4b9b3ee126beee2 100644 (file)
@@ -59,25 +59,25 @@ define [
       _.extend data, @options.app.state.get 'query'
 
       fetchIssuesProcess = window.process.addBackgroundProcess()
-      $.get "#{baseUrl}/api/issues/search", data, (r) =>
+      $.get "#{baseUrl}/api/issues/search", data
+      .done (r) =>
         issues = @options.app.issues.parseIssues r
         if firstPage
           @options.app.issues.reset issues
         else
           @options.app.issues.add issues
-
         FACET_DATA_FIELDS.forEach (field) => @options.app.facets[field] = r[field]
         @options.app.facets.reset @_allFacets()
         @options.app.facets.add r.facets, merge: true
         @enableFacets @_enabledFacets()
-
         @options.app.state.set
           page: r.p
           pageSize: r.ps
           total: r.total
           maxResultsReached: r.p * r.ps >= r.total
-
         window.process.finishBackgroundProcess fetchIssuesProcess
+      .fail ->
+        window.process.failBackgroundProcess fetchIssuesProcess
 
 
     fetchNextPage: ->
@@ -99,9 +99,12 @@ define [
         facet.set enabled: true
       else
         p = window.process.addBackgroundProcess()
-        @requestFacet(id).done =>
+        @requestFacet(id)
+        .done =>
           facet.set enabled: true
           window.process.finishBackgroundProcess p
+        .fail ->
+          window.process.failBackgroundProcess p
 
 
     disableFacet: (id) ->
index 3ba3a87670fa9a82c8ee4800c110bdee16324f68..5b1776e0228a24f529d208e0581abcf1762c5bcc 100644 (file)
@@ -406,7 +406,7 @@ input[type=button] {
   top: 0; left: 50%;
   width: 300px;
   margin-left: -150px;
-  padding: 3px 0;
+  line-height: 22px;
   background-color: #f0e8ac;
   border-radius: 0 0 3px 3px;
   text-align: center;
@@ -415,3 +415,17 @@ input[type=button] {
 
   &.shown { opacity: 1; }
 }
+
+.process-spinner-failed {
+  background-color: @red;
+  color: @white;
+}
+
+.process-spinner-close {
+  float: right;
+  margin-right: 5px;
+  padding: 3px;
+  background: none !important;
+  border: none !important;
+  line-height: 1;
+}
index e369300c7ab11385dc9866febd5a2a631cd50968..61e917b5c76fabc31e828e1f15541a4b5f89dae1 100644 (file)
@@ -533,6 +533,7 @@ libraries.page=Libraries
 #------------------------------------------------------------------------------
 
 process.still_working=Still Working...
+process.fail=Failed
 
 
 #------------------------------------------------------------------------------