Hi,

When creating a custom AngularJS directive pre-v1.2.0, the name of the client 
variable to bind to was “client”. Now, after upgrading the guacamole client to 
v1.5.0, the name has been changed to “focusedClient”. Changing this name has 
solved the issue completely.

Could someone explain why this was changed and documented?

Thanks!!
________________________________
From: Elijah <eli.ols...@gmail.com>
Sent: Thursday, August 29, 2024 11:41:27 PM
To: user@guacamole.apache.org <user@guacamole.apache.org>
Subject: Step-up from v1.30 to v1.40: Guacamole extension AngularJS 
$scope.client is undefined.


Hello,



Guacamole is a product that I use and love. I recently upgraded 
guacamole-client DOCKER versions from 1.3.0 to 1.4.0. This upgrade was largely 
due to the requirement of my host server running on RHEL8. I have an extension 
that I’ve built for Guacamole and has worked since version 1.10. Now the 
extension has regressed.



On Firefox WebTools:



TypeError: $scope.client is undefined

    loadScaleBackground https://<hostname>/app.js?b=20240330163951:172

    Angular 21

    jQuery 8

    Angular 15





I have created an AngularJS directive that mocks the client module directive 
“app/client/directives/guacClient.js”.



******************** START CODE BLOCK ********************



angular.module('client').directive('myClient', [

  function myClient() {

    return {

      restrict: 'E',

      replace:  true,

      scope: {

        client: '=',

      },

      controller: ['$scope',

                   '$routeParams',

                   'ManagedClient',

      function guacClientController($scope,

                                    $routeParams,

                                    ManagedClient)

      {

        // The display and client for the connection

        var display = null;

        var client = null;



        $scope.$watch('client', function attachManagedClient(managedClient)

          {

            if (!managedClient)

              return;



            // Get Guacamole client instance

            client = managedClient.client;

            display = client.getDisplay();



          } // end function: attachManagedClient

        ); // end $watch: client



…



    }; // end return statement for chipsClient()

  } // end function: chipsClient()

]); // end directive: chipsClient()



******************** END CODE BLOCK ********************



And here is where I inject the HTML directive with extension…



******************** START CODE BLOCK ********************



<meta name="after-children" content=".client-body">



<my-client client="client" menu="menu"></my-client>





******************** END CODE BLOCK ********************





When I inject console.log($scope) into my JS extension, I am returned with the 
$scope object with client as undefined.



I suspect that the $scope.$watch(‘client’, … is not returning a newVal of the 
client object and passing it to managedClient as undefined. Therefore, it will 
hit the return statement every time. I want to say that this is some type of 
visibility issue as the webapp “sources” (shown on WebTools) is much different 
as it was in guacamole-client v1.3.0. All the client code is no longer put into 
app.js and is split into a bunch of files, so maybe this is what’s causing the 
issue?



AngularJS is very new to me and I’m learning as I go. Any suggestions are 
appreciated.



Thanks,



Eli

Reply via email to