You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Elijah <el...@gmail.com> on 2024/09/09 18:02:34 UTC

Re: Step-up from v1.30 to v1.40: Guacamole extension AngularJS $scope.client is undefined.

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 <el...@gmail.com>
Sent: Thursday, August 29, 2024 11:41:27 PM
To: user@guacamole.apache.org <us...@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

Re: Step-up from v1.30 to v1.40: Guacamole extension AngularJS $scope.client is undefined.

Posted by Nick Couchman <vn...@apache.org>.
On Mon, Sep 9, 2024 at 2:02 PM Elijah <el...@gmail.com> wrote:

> 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?
>
>
This was changed in the 1.4.0 release, when connection tiling was
introduced, and, thus, the idea of a "focusedClient". The Jira issue for
this was GUACAMOLE-724 (https://issues.apache.org/jira/browse/GUACAMOLE-724),
and the release notes for 1.4.0 cover the tiling changes:
https://guacamole.apache.org/releases/1.4.0/.

As this particular variable was part of the client front-end, and not part
of the guacamole-common-js API, there's probably not anything that
specifically calls out a change to this in the way that API-related changes
would be documented.

-Nick

>