LP1825891 AngJS support Hatch 'hostname' for registration user/berick/lp1825891-hatch-hostname-for-register
authorBill Erickson <berickxx@gmail.com>
Mon, 22 Apr 2019 21:02:05 +0000 (14:02 -0700)
committerBill Erickson <berickxx@gmail.com>
Mon, 22 Apr 2019 21:02:07 +0000 (14:02 -0700)
Populate the workstation name with the hostname of the PC when
registring a new workstation for Hatch-enabled workstations.

Note the code gracefully returns null if Hatch returns a 404 (not found)
or Hatch is not active.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/services/hatch.js

index d863844..c4b00d0 100644 (file)
@@ -823,6 +823,10 @@ function($scope , $q , $window , $location , egCore , egAlertDialog , workstatio
 
     console.log('set context org to ' + $scope.contextOrg);
 
+    egCore.hatch.hostname().then(function(name) {
+        $scope.newWSName = name || '';
+    });
+
     // fetch workstation reg perms
     egCore.perm.hasPermAt('REGISTER_WORKSTATION', true)
     .then(function(orgList) { 
index 467091a..a6edaa3 100644 (file)
@@ -890,6 +890,19 @@ angular.module('egCoreMod')
         return deferred.promise;
     }
 
+    service.hostname = function() {
+        if (service.hatchAvailable) {
+            return service.attemptHatchDelivery({action : 'hostname'})
+            .then(
+                function(name) { return name; },
+                // Gracefully handle case where Hatch has not yet been 
+                // updated to include the hostname command.
+                function() {return null}
+            );
+        } 
+        return $q.when(null);
+    }
+
     // The only requirement for opening Hatch is that the DOM be loaded.
     // Open the connection now so its state will be immediately available.
     service.openHatch();