WebUI: Dynamically get accountService roles

Get the AccountService roles dynamically
by calling redfish/rest API's and use them
in user management webui.

Test:
Loaded web page and checked user management
page for appropriate roles fetched from dbus.

Change-Id: I4f51cb0a622a1be8b0bfec2b2fe3ecdee2538c6a
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/app/users/controllers/user-accounts-controller.js b/app/users/controllers/user-accounts-controller.js
index 5f90844..4148f54 100644
--- a/app/users/controllers/user-accounts-controller.js
+++ b/app/users/controllers/user-accounts-controller.js
@@ -10,32 +10,38 @@
   'use strict';
 
   angular.module('app.users').controller('userAccountsController', [
-    '$scope', 'APIUtils',
-    function($scope, APIUtils) {
-      // TODO: Get the roles using Roles redfish URI.
-      $scope.roles = ['Administrator', 'Operator', 'User', 'Callback'];
+    '$scope', '$q', 'APIUtils',
+    function($scope, $q, APIUtils) {
+      $scope.users = [];
+      $scope.roles = [];
       $scope.state = 'none';
       $scope.outMsg = '';
       $scope.loading = true;
 
       function loadUserInfo() {
-        $scope.users = [];
         $scope.loading = true;
         $scope.isUserSelected = false;
         $scope.selectedUser = null;
-
-        APIUtils.getAllUserAccounts()
-            .then(
+        $q.all([
+            APIUtils.getAllUserAccounts().then(
                 function(res) {
                   $scope.users = res;
                 },
                 function(error) {
                   console.log(JSON.stringify(error));
+                }),
+            APIUtils.getAccountServiceRoles().then(
+                function(res) {
+                  $scope.roles = res;
+                },
+                function(error) {
+                  console.log(JSON.stringify(error));
                 })
-            .finally(function() {
-              $scope.loading = false;
-            });
+          ]).finally(function() {
+          $scope.loading = false;
+        });
       };
+
       $scope.cancel = function() {
         $scope.state = 'none';
         $scope.outMsg = '';
@@ -171,6 +177,7 @@
               $scope.loading = false;
             });
       };
+
       loadUserInfo();
     }
   ]);