• 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

    Open graphical representation when you click a Script for the server

    Scheduled Pinned Locked Moved User help
    12 Posts 3 Posters 2.9k Views 3 Watching
    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.
    • phildunlapP Offline
      phildunlap
      last edited by phildunlap

      Hi Prayol,

      It's been quite a while since I wrote a server-side scripting component for the graphical views!

      You can add the point on the component through the dropdown. You cannot create a point value dao as you tried (the proper way would be com.serotonin.m2m2.Common.databaseProxy.newPointValueDao();), nor is there a method that takes a string ID like that. Instead, use the value that's already been added to the script context for the point added to the component, something like,

      if (value === true) //assuming it's a binary point
      
      return "<img style='cursor:pointer;' src='graphics/Leds48/led48_green_1.png' onclick='mango.view.setPoint("+ point.id +", "+ pointComponent.id +", false);return false;'/>";
      
      else
      
      return "<img style='cursor:pointer;' src='graphics/Leds48/led48_white_0.png' onclick='mango.view.setPoint("+ point.id +", "+ pointComponent.id +", true);return false;'/>";
      

      I didn't test the HTML, but using 'value' and adding the point to the compoent like so:

      0_1527695831189_serverSideScriptContextPoint.png

      P 1 Reply Last reply Reply Quote 0
      • Jared WiltshireJ Offline
        Jared Wiltshire
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • P Offline
          Prayol @phildunlap
          last edited by

          @phildunlap Hello phildunlap, thanks for the help.
          See, I use a variation of Mango here in Brazil called ScadaBR. As for DAO, it is working correctly in this variation. My problem is that I'm not sure how to insert the redirect after a click into the server script. I have to direct the user to this representation: views.shtm? ViewId = 8, how do I? I can not do it alone. Thank you

          1 Reply Last reply Reply Quote 0
          • phildunlapP Offline
            phildunlap
            last edited by

            Have you tried a <script> tag that changes the window.location ?

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              Prayol @phildunlap
              last edited by

              @phildunlap said in Open graphical representation when you click a Script for the server:

              Have you tried a <script> tag that changes the window.location ?

              I tried this way: onclick = 'javascript: window.location.href =' http: // localhost: 8080 / ScadaBR / views.shtm? ViewId = 5 ";
              The problem, that is JavaScript is not my native language, so it is not a will and I do not know if it is correct what I did.

              1 Reply Last reply Reply Quote 0
              • phildunlapP Offline
                phildunlap
                last edited by

                This was my test, worked to get my from the view page to the edit page.

                var s = "<button onclick=\"window.location.href = 'http://localhost:8080/view_edit.shtm?viewId=1';\">";
                if( value < 50 )
                  return s+"<b>HELLO WORLD</b></button>";
                else
                  return s+"<b>GOODBYE WORLD</b></button>";
                
                P 1 Reply Last reply Reply Quote 0
                • P Offline
                  Prayol @phildunlap
                  last edited by

                  @phildunlap said in Open graphical representation when you click a Script for the server:

                  var s = "<button onclick="window.location.href = 'http://localhost:8080/view_edit.shtm?viewId=1';">";

                  Thank you my friend. It worked! Now I'm just taking the button shape that was created around the chart to look perfect! It's possible ?

                  1 Reply Last reply Reply Quote 0
                  • phildunlapP Offline
                    phildunlap
                    last edited by phildunlap

                    Certainly welcome (although consider using Mango :P). You can use a <div> tag, and a closing </div> instead of the <button></button>

                    P 1 Reply Last reply Reply Quote 0
                    • P Offline
                      Prayol @phildunlap
                      last edited by

                      @phildunlap
                      Your help, I have already been very helpful. I do not want to be inopportune, but by putting it this way: (var s = "<div> <onclick = " window.location.href = 'http: // localhost: 8080 / ScadaBR / views.shtm? ViewId = 8' ; \ "> <\ div>";) - I lose the click and redirect function. thankful

                      1 Reply Last reply Reply Quote 0
                      • phildunlapP Offline
                        phildunlap
                        last edited by

                        var s = "<div onclick=\"window.location.href = 'http://localhost:8080/view_edit.shtm?viewId=1';\">";
                        if( value < 50 )
                          return s+"<b>HELLO WORLD</b></div>";
                        else
                          return s+"<b>GOODBYE WORLD</b></div>";
                        
                        P 1 Reply Last reply Reply Quote 0
                        • P Offline
                          Prayol @phildunlap
                          last edited by

                          @phildunlap

                          SHOW !!!! Thank you, Thank you, Thank you.

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