From 0806f299ce53ada88144a7e0e43c8a066c7a46d7 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Thu, 4 Jun 2020 22:07:34 +0200
Subject: [PATCH] use new api for ui

---
 inventory_provider/static/update.html | 38 ++++++++++++++++++---------
 inventory_provider/static/update.js   | 27 ++++++++++---------
 2 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/inventory_provider/static/update.html b/inventory_provider/static/update.html
index 18ba32d0..c460d147 100644
--- a/inventory_provider/static/update.html
+++ b/inventory_provider/static/update.html
@@ -30,21 +30,35 @@
           {{ update_request_status }}
         </div>
 
-        <span class="grid-item" ng-show="latch_error||latch_pending">
-          <table class="table table-striped" summary="update tasks">
+        <span class="grid-item" ng-show="errors.length">
+          <table class="table table-striped" summary="error messages">
             <tr>
-              <th colspan="4" scope="col">update tasks</th>
+              <th scope="col">errorss</th>
+            </tr>
+            <tr ng-repeat="description in errors">
+              <td>{{ description }}</td>
+            </tr>
+          </table>
+        </span>
+
+        <span class="grid-item" ng-show="warnings.length">
+          <table class="table table-striped" summary="warning messages">
+            <tr>
+              <th scope="col">warnings</th>
+            </tr>
+            <tr ng-repeat="description in warnings">
+              <td>{{ description }}</td>
+            </tr>
+          </table>
+        </span>
+
+        <span class="grid-item" ng-show="pending.length">
+          <table class="table table-striped" summary="pending tasks">
             <tr>
-              <th scope="col">name</th>
-              <th scope="col">status</th>
-              <th scope="col">success</th>
-              <th scope="col">message</th>
+              <th scope="col">pending tasks</th>
             </tr>
-            <tr ng-repeat="t in tasks">
-              <td>{{ t.name }}</td>
-              <td>{{ t.status }}</td>
-              <td>{{ t.success }}</td>
-              <td>{{ t.message }}</td>
+            <tr ng-repeat="description in pending">
+              <td>{{ description }}</td>
             </tr>
           </table>
         </span>
diff --git a/inventory_provider/static/update.js b/inventory_provider/static/update.js
index 64e68073..d3b92d6e 100644
--- a/inventory_provider/static/update.js
+++ b/inventory_provider/static/update.js
@@ -9,7 +9,10 @@ myApp.controller('update', function($scope, $http, $timeout) {
     $scope.update_request_status = "";
     $scope.update_request_error = false;
 
-    $scope.tasks = [];
+    $scope.pending = [];
+    $scope.failed = [];
+    $scope.errors = [];
+    $scope.warnings = [];
 
     $scope.check_status = function() {
 
@@ -46,25 +49,23 @@ myApp.controller('update', function($scope, $http, $timeout) {
 
         $http({
             method: 'GET',
-            // url: window.location.origin + "/jobs/check-task-status/9d1cbcd2-c377-4b7a-b969-04ce17f03f20"
-            url: window.location.origin + "/jobs/check-update-status"
+            url: window.location.origin + "/jobs/log"
         }).then(
             /* ok response */
             function(rsp) {
                 console.log('got update status rsp: ' + JSON.stringify(rsp.data).substring(0,30));
-                $scope.tasks = rsp.data.map(t => ({
-                    id: t.id,
-                    parent: t.parent,
-                    status: t.status,
-                    success: t.ready ? (t.success ? "OK" : "NO") : "-",
-                    message: (t.result && t.result.message) ? t.result.message.substring(0,100) : "",
-                    name: t.result ? t.result.task : "",
-                }));
+                $scope.pending = rsp.data.pending;
+                $scope.failed = rsp.data.failed;
+                $scope.warnings = rsp.data.warnings;
+                $scope.errors = rsp.data.errors;
             },
             /* error response */
             function(rsp) {
-                // assume this is 404 ...
-                $scope.tasks = [];
+                // assume this is 404 ...?
+                $scope.pending = [];
+                $scope.failed = [];
+                $scope.errors = [];
+                $scope.warnings = [];
             }
         );
 
-- 
GitLab