• 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

    Hide a field if it is not updated during last day

    Mango Automation general Discussion
    2
    5
    1.5k
    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.
    • E
      etantonio
      last edited by

      Hy,
      in my application I've the following report:

      0_1571655556183_826601f0-d422-40c2-97c8-3d1a6c3f1038c-immagine.png

      the latest column shows the latest datetime ok the corresponding TRK. Maybe for some reason like in the figure, the latest timestamp is really old so I don't want to show that row, for example I want to see only the rows updated during last day.

      Maybe a way to achieve this is:

      <ma-now update-interval="1 minutes" output="theTimeNow"></ma-now>
      ..
            <ng-if="!TRK_0_1_automa_state.time.isBefore(theTimeNow | maMoment:'subtract':24:'hours'")>
              <h5>{{TRK_0_1_automa_state.time | date:'yyyy-MM-dd  HH:mm:ss'}}</h5>
            </ng-if>
      ..
            <ng-if="!TRK_1_1_automa_state.time.isBefore(theTimeNow | maMoment:'subtract':24:'hours'")>
              <h5>{{TRK_1_1_automa_state.time | date:'yyyy-MM-dd  HH:mm:ss'}}</h5>
            </ng-if>
      
      

      but the code seems to be always true, so it is not ok because both automa_state.time are showed.

      Any idea about where is the problem?
      Thanks,
      Antonio

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

        Hi @etantonio

        The problem is that TRK_0_1_automa_state.time is not a moment.js object and you cannot use .isBefore() on it. It is an epoch timestamp (i.e. a number, specifically of seconds since 1980).

        I would suggest using this

        <ma-now update-interval="1 minutes" output="theTimeNow" on-change="theTimeADayAgo = $value.clone().subtract(24, 'hours')"></ma-now>
        

        Then

        <div ng-if="theTimeADayAgo.isBefore(TRK_0_1_automa_state.time)">
        

        Developer at Radix IoT

        1 Reply Last reply Reply Quote 0
        • E
          etantonio
          last edited by etantonio

          Thanks Jared,
          in any case, using the following code:

              <ma-now update-interval="1 minutes" output="theTimeNow" on-change="theTimeADayAgo = $value.clone().subtract(24, 'hours')"></ma-now>
              <md-grid-tile class="dark-gray">
                  <h5>{{theTimeADayAgo|moment:'format':'D MMM YYYY - HH:mm'}}</h5>
              </md-grid-tile>
           	  <md-grid-tile class="dark-gray">
                <h5>{{theTimeNow|moment:'format':'D MMM YYYY - HH:mm'}}</h5>
              </md-grid-tile>
          

          I've this result:

          0_1571835141023_b41eaf9f-3ab0-493c-bfcd-d5ad9278a0c8-immagine.png

          and in fact the row filtering based on datetime seems to be not working.

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

            moment is not a valid filter name, it is maMoment as per your first post. You could also just call the function directly instead of using the filter -

            theTimeADayAgo.format('D MMM YYYY - HH:mm')
            

            Developer at Radix IoT

            1 Reply Last reply Reply Quote 0
            • E
              etantonio
              last edited by etantonio

              at the end of all the simplest working solution for me seems to be

              <ma-now update-interval="1 minutes" output="theTimeNow"></ma-now>
              <ma-calc input="theTimeNow | moment:'subtract':24:'hours'" output="theTimeADayAgo"></ma-calc>
              

              and then:

              <md-grid-list
                    md-cols="11"
                    md-gutter="0px"
                    md-row-height="35px" ng-if="theTimeADayAgo.isBefore(TRK_0_1_automa_state.time)">
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post