[Kimchi-devel] [PATCH 3/5] Add function to list all pending debug reports

Aline Manera alinefm at linux.vnet.ibm.com
Mon Sep 8 03:07:34 UTC 2014


Only the user who has started the debug report creation was able to get
the view of a pending debug report. But while switching tabs, this
information was lost.
To fix this behavior and also let all users get the same view, the
pending debug reports must be listed while loading the report grid.
In order to do that, create a function to return all the pending debug
reports.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.host.js | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/ui/js/src/kimchi.host.js b/ui/js/src/kimchi.host.js
index b2e08b8..526ce5d 100644
--- a/ui/js/src/kimchi.host.js
+++ b/ui/js/src/kimchi.host.js
@@ -380,6 +380,39 @@ kimchi.host_main = function() {
         });
     };
 
+    var getPendingReports = function() {
+        var reports = []
+        var filter = 'status=running&target_uri=' + encodeURIComponent('^/debugreports/*')
+
+        kimchi.getTasksByFilter(filter, function(tasks) {
+            for(var i = 0; i < tasks.length; i++) {
+                reportName = tasks[i].target_uri.replace(/^\/debugreports\//, '') || i18n['KCHDR6012M'];
+                reports.push({'name': reportName, 'time': i18n['KCHDR6007M']})
+
+                if(kimchi.trackingTasks.indexOf(tasks[i].id) >= 0) {
+                    continue;
+                }
+
+                kimchi.trackTask(tasks[i].id, function(result) {
+                    kimchi.topic('kimchi/debugReportAdded').publish();
+                }, function(result) {
+                    // Error message from Async Task status
+                    if (result['message']) {
+                        var errText = result['message'];
+                    }
+                    // Error message from standard kimchi exception
+                    else {
+                        var errText = result['responseJSON']['reason'];
+                    }
+                    result && kimchi.message.error(errText);
+                    kimchi.topic('kimchi/debugReportAdded').publish();
+                }, null);
+            }
+        }, null, true);
+
+        return reports;
+    };
+
     var listDebugReports = function() {
         kimchi.listReports(function(reports) {
             $('#debug-report-section').removeClass('hidden');
-- 
1.9.3




More information about the Kimchi-devel mailing list