• 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

    Is a directive or ability to enable and disable points from the new V3 UI available or in works?

    Dashboard Designer & Custom AngularJS Pages
    5
    18
    4.4k
    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.
    • ThomasEinastoT
      ThomasEinasto
      last edited by

      Craig,

      Depending on the version it might not work. I have one instance here which is not beta and it issues out rejection to the POST made by $save().

      I think IAS staff might comment on this subject more.

      Thomas

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

        @Phillip-Weeks @ThomasEinasto Which version of Mango are you both using? I'm assuming 3.5.x. Make sure you are using the latest UI and API module. If you can post the exact error response from the Chrome developer console that would be helpful.

        Developer at Radix IoT

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

          I've looked into it and this feature is not actually in 3.5.x, it is included with 3.6.

          Here's a user module with the backported feature that you can use -

          define(['angular', 'require'], function(angular, require) {
              'use strict';
          
              const userModule = angular.module('userModule', ['maUiApp']);
          
              userModule.decorator('maDataSource', ['$delegate', '$http', function(DataSource, $http) {
                  
                  Object.assign(DataSource.prototype, {
                      enable(enabled = true, restart = false) {
                          this.$enableToggling = true;
                          
                          const url = '/rest/v1/data-sources/enable-disable/' + encodeURIComponent(this.xid);
                          return $http({
                              url,
                              method: 'PUT',
                              params: {
                                  enabled: !!enabled,
                                  restart
                              }
                          }).then(() => {
                              this.enabled = enabled;
                          }).finally(() => {
                              delete this.$enableToggling;
                          });
                      }
                  });
                  
                  return DataSource;
              }]);
              
              return userModule;
          }); // define
          

          I'd recommend removing this when you upgrade to 3.6.x

          Developer at Radix IoT

          1 Reply Last reply Reply Quote 0
          • P
            Phillip Weeks
            last edited by Phillip Weeks

            example please of calling it in html

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

              What Jared has written here I'm pretty certain extends the DataSource module in the dashboard.
              Once it's added to the user module, For example

              <ma-data-source-list ng-model="myDataSource" auto-init="false" query="{name: 'meta'}" sort="['-name']" start="3"
              limit="6" show-clear="true"></ma-data-source-list>
              
              <ma-button label="Toggle Enable/Disable" ng-click="myDataSource.enable()"></ma-button>
              
              

              I don't see any binding here allowing us to set the datasource to be either enabled or disabled. Just toggled between the two states. Can always change that by making a directive though.

              EDIT: Oops forgot the closing </ma-button>!

              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 0
              • P
                Phillip Weeks
                last edited by

                Nope still not changing the DS. How can I tell if the user-module I added in UI settings is actually being called?

                1 Reply Last reply Reply Quote 0
                • ThomasEinastoT
                  ThomasEinasto
                  last edited by

                  It would be more helpful if you open console in the browser to see what errors you are having.

                  Something like this:

                  0_1559649793677_6c1a50f2-c978-4f2f-8e12-4d01faa5e742-image.png

                  1 Reply Last reply Reply Quote 0
                  • P
                    Phillip Weeks
                    last edited by Phillip Weeks

                    I don't believe it is doing anything.
                    0_1559652547166_81d1c7e6-b1e5-4e20-b6ae-9ebf020ea314-image.png

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

                      @Phillip-Weeks This is how you add it as a user module - https://help.infiniteautomation.com/getting-started-with-a-user-module

                      If it is being loaded correctly you will see it on the sources tab of Chrome's dev tools (under /rest/v2/file-stores/public/userModule.js for example).

                      You should also see the network request being issued on the network tab when you click the button.

                      Developer at Radix IoT

                      1 Reply Last reply Reply Quote 0
                      • P
                        Phillip Weeks
                        last edited by

                        OK Thanks Jared I have it working now. Thank-you very much for all your help and to the other guys as well. That's great.

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