• Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login
  • Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login

Widget - Running Sensors

Scheduled Pinned Locked Moved General Discussion
14 Posts 3 Posters 4.2k Views 2 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.
  • G Offline
    gouds
    last edited by 28 Dec 2016, 01:07

    Dashboard Item - List all running sensors. Anyone done anything? (Just a nice table to show a list)

    J 1 Reply Last reply 28 Dec 2016, 01:44 Reply Quote 0
    • J Offline
      jkandasa @gouds
      last edited by 28 Dec 2016, 01:44

      @gouds said:

      Dashboard Item - List all running sensors. Anyone done anything? (Just a nice table to show a list)

      What does mean running sensors?

      G 1 Reply Last reply 28 Dec 2016, 01:47 Reply Quote 0
      • G Offline
        gouds @jkandasa
        last edited by 28 Dec 2016, 01:47

        @jkandasa List sensors that are currently 'ON'

        J 1 Reply Last reply 28 Dec 2016, 01:52 Reply Quote 0
        • J Offline
          jkandasa @gouds
          last edited by 28 Dec 2016, 01:52

          @gouds ok, I will the code soon.

          1 Reply Last reply Reply Quote 0
          • G Offline
            gouds
            last edited by 6 Jan 2017, 01:36

            cheers. It would be a great help.... Thanks

            J 1 Reply Last reply 9 Jan 2017, 17:47 Reply Quote 0
            • J Offline
              jkandasa @gouds
              last edited by 9 Jan 2017, 17:47

              @gouds

              I have introduced this feature on latest SNAPSHOT.

              Use the following script and template to show only ON switches. You modify filter-options on the script. When you click on HTML table, it will take you to actual sensor page. Where you can control your switch easily.

              JavaScript:
              var myImports = new JavaImporter(java.io, java.lang, java.util, org.mycontroller.standalone.message.McMessageUtils.MESSAGE_TYPE_SET_REQ);
              
              with(myImports) {
                var options = new HashMap();
                //Sort by timestamp.
                options.put("orderBy", "timestamp");
                options.put("pageLimit", new Long(-1));
                //Order by descending
                options.put("order", "desc");
               //Update sensor variable type
                options.put("variableType", MESSAGE_TYPE_SET_REQ.V_STATUS);
              //Update value
                options.put("value", "1");
              
                //Get sensors data
                var sensorVariables = mcApi.sensor().getVariables(options);
              
              }
              
              HTML template:
              <table class="table table-hover table-bordered table-striped mc-table">
                <thead>
                  <th>{{ 'NAME' | translate }}</th>
                  <th>{{ 'LAST_SEEN' | translate }}</th>
                </thead>
                <tbody>
                  <#list sensorVariables.data as item>
                    <tr ui-sref="sensorsDetail({id: ${item.sensorId} })">
                      <td ng-bind-html="'${(item.resourceName)!}' | mcResourceRepresentation"></td>
                      <td><span uib-tooltip="{{ ${(item.timestamp?c)!"Never"} | date:mchelper.cfg.dateFormat:mchelper.cfg.timezone}}" tooltip-placement="left" am-time-ago="${(item.timestamp?c)!"Never"}"></span></td>
                    </tr>
                  </#list>
                </tbody>
              </table>
              
              Final result:

              0_1483983879371_upload-4f120fca-8861-4343-a39f-bd1fd0d74822

              1 Reply Last reply Reply Quote 0
              • G Offline
                gouds
                last edited by 12 Jan 2017, 20:47

                Thanks very much. This worked a treat. 🙂

                1 Reply Last reply Reply Quote 1
                • R Offline
                  RMF69
                  last edited by RMF69 26 Feb 2018, 21:29

                  Has something change on the 1,2,0.Final ? This example worked with the previous, but now I get

                  angular.js:10661 GET https://localhost:8443/mc/rest/templates/getHtml?script=operations%2Flast-seen-nodes.js&scriptBindings=%7B%7D&template=last-seen-nodes.html 400 (Bad request)
                  

                  I don't have mc in side www... I'm sure I don't understand whats going on 🙂 or should be

                  Thanks

                  J 1 Reply Last reply 28 Feb 2018, 05:28 Reply Quote 0
                  • J Offline
                    jkandasa @RMF69
                    last edited by 28 Feb 2018, 05:28

                    @rmf69 mc not inside www dir. It is path will be addressed by MyController REST API.
                    Can you check the template and script available on your MyControlle server?

                    R 1 Reply Last reply 28 Feb 2018, 07:49 Reply Quote 0
                    • R Offline
                      RMF69 @jkandasa
                      last edited by 28 Feb 2018, 07:49

                      @jkandasa sure, if I knew or had a better idea of what I was looking for, the script and template, the ones I've inserted exist... but where do I need to look for rest api ?

                      J 1 Reply Last reply 28 Feb 2018, 08:18 Reply Quote 0
                      • J Offline
                        jkandasa @RMF69
                        last edited by jkandasa 28 Feb 2018, 08:18

                        @rmf69 Can you post your script and template page? Also this widget edit screen?

                        1 Reply Last reply Reply Quote 0
                        • R Offline
                          RMF69
                          last edited by RMF69 28 Feb 2018, 08:53

                          [EDIT] I've answered myself... in the .js there was a filter restriction on // options.put("variableType", MESSAGE_TYPE_SET_REQ.V_STATUS);
                          no wonder no sensors where show
                          [/edit]
                          Hi I had to re copy the examples at top again, as I'd modified the origional, not a good idea i know if I wanted to fix something.

                          I've re inserted the example js and html template above, and no longer get the error I'd posted however still no sensor variables show.

                          Here are some screen shots
                          (0_1519807954237_scriptedit.png
                          (0_1519807964086_templateedit.png
                          (0_1519807973680_customwidget.png
                          (0_1519807987336_customerwidgetoutput.png
                          (0_1519807997880_topology.png

                          Thanks again for any help

                          J 1 Reply Last reply 28 Feb 2018, 10:49 Reply Quote 0
                          • J Offline
                            jkandasa @RMF69
                            last edited by 28 Feb 2018, 10:49

                            @rmf69 Also you have another filter,

                              options.put("value", "1");
                            
                            R 1 Reply Last reply 28 Feb 2018, 21:56 Reply Quote 0
                            • R Offline
                              RMF69 @jkandasa
                              last edited by 28 Feb 2018, 21:56

                              @jkandasa Thanks for that, missed it.

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

                              0

                              Online

                              618

                              Users

                              531

                              Topics

                              3.4k

                              Posts
                              Copyright © 2015-2025 MyController.org | Contributors | Localization