• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Getting a point value without an endless loop

    User help
    2
    5
    450
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      ms_brunette
      last edited by

      Hi everyone!
      I'm a new worker with Mango and I'm trying to write my own module. I want to get a latest value of a data point, but I found only a way to get a point (not a value). Is there a function to get a value? I tried to find a syntax for the component <ma-get-point-value> but I could not..
      My code for getting point is:

      $scope.getPoint = (city, block) =>
          {
              maPoint.query({rqlQuery: "eq(tags.City,"+city+")&eq(tags.Block,"+block+")"}).$promise.then((points) => {
                  $scope.blockPoints = points;
              })
              
              document.getElementById("block").innerHTML = $scope.blockPoints[0].xid;
          }
      

      I also tried to get point value through $http.get. I got the value, but my page went into an endless loop.. And I don't understand how to stop it (and why it continues).
      My code with $http.get is:

      $scope.pointValue = []
      $scope.getPrumer = () =>
          {
              $http.get(`https:///localhost:8080/rest/v2/point-values/latest/xid?fields=VALUE&limit=1`).then(response =>
                  {
                      $scope.pointValue = response.data;
                  });
              
              document.getElementById("value").innerHTML = $scope.pointValue[0].value;
          }
      

      Please help me understand what I'm doing wrong.

      MattFoxM 1 Reply Last reply Reply Quote 0
      • MattFoxM
        MattFox @ms_brunette
        last edited by MattFox

        @ms_brunette Welcome to the forum!
        In the angular js world, you don't need document.getElementById, you'd use angular.element('#id')
        angular.element(document.getElementById(id))
        which is a subset of jquery.

        Also I'd recommend looking at the docs and examples for using the various directives. Activate it by turning it on in the edit menu under administration then saving.

        Also, if you know how angular works and are aware of how to make controllers and components use maPoint to do point queries. For values however, use maPointValues.

        Refer to their github repo for MangoAutomation under the https://github.com/MangoAutomation/ma-dashboards to see how the services and directives works.

        If you're still stuck I'll be able to help more in about a day or so

        Fox

        Do not follow where the path may lead; go instead where there is no path.
        And leave a trail - Muriel Strode

        MattFoxM 1 Reply Last reply Reply Quote 1
        • MattFoxM
          MattFox @MattFox
          last edited by

          @ms_brunette here's an old post I wrote highlighting how to make a component with the user module addon
          https://forum.mango-os.com/topic/3720/pop-up-window-face-plate/12?_=1713211779825

          Fox

          Do not follow where the path may lead; go instead where there is no path.
          And leave a trail - Muriel Strode

          M 1 Reply Last reply Reply Quote 1
          • M
            ms_brunette @MattFox
            last edited by

            @MattFox Thank you for answering! Actually, I already won this battle, but apparently there is a whole war ahead :D
            I didn't understand all the behavior, but I found a working solution for my case.
            Regarding your comments - in my environment angular.element('#id') doesn't work by some reasons, and I still don't know how to write maPointValues correctly..
            Thanks for the link. I found it very useful!

            MattFoxM 1 Reply Last reply Reply Quote 0
            • MattFoxM
              MattFox @ms_brunette
              last edited by MattFox

              @ms_brunette you're welcome! Always happy to help. Also, my apologies, angular.element(htmlelrnent), I misunderstood the jqlite reference.

              So HTML string or DOMElement should be the value in the element method. It will return a jQuery object.
              https://docs.angularjs.org/api/ng/function/angular.element

              Feel free to post another forum question if you are unable to find a solution via the search box.

              Fox

              Do not follow where the path may lead; go instead where there is no path.
              And leave a trail - Muriel Strode

              1 Reply Last reply Reply Quote 1
              • First post
                Last post