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.
Hide a field if it is not updated during last day
-
Hy,
in my application I've the following report: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 -
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)">
-
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:
and in fact the row filtering based on datetime seems to be not working.
-
moment
is not a valid filter name, it ismaMoment
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')
-
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)">