changed last run datetime and next run datetime formater for rule from timestamp to strftime
parent
15ca471b83
commit
dec9bc6e87
|
@ -21,7 +21,6 @@
|
||||||
<th >{{'FDD.EXPRESSION' | translate}}</th>
|
<th >{{'FDD.EXPRESSION' | translate}}</th>
|
||||||
<th >{{'FDD.MESSAGE_TEMPLATE' | translate}}</th>
|
<th >{{'FDD.MESSAGE_TEMPLATE' | translate}}</th>
|
||||||
<th >{{'SETTING.ACTION' | translate}}</th>
|
<th >{{'SETTING.ACTION' | translate}}</th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -33,14 +32,13 @@
|
||||||
<td >{{ rule.priority }}</td>
|
<td >{{ rule.priority }}</td>
|
||||||
<td >{{ rule.channel }}</td>
|
<td >{{ rule.channel }}</td>
|
||||||
<td >{{ rule.is_enabled==true?'SETTING.ON':'SETTING.OFF' | translate}}</td>
|
<td >{{ rule.is_enabled==true?'SETTING.ON':'SETTING.OFF' | translate}}</td>
|
||||||
<td >{{ rule.last_run_datetime | date:'yyyy-MM-ddTHH:mm:ss'}}</td>
|
<td >{{ rule.last_run_datetime }}</td>
|
||||||
<td >{{ rule.next_run_datetime | date:'yyyy-MM-ddTHH:mm:ss'}}</td>
|
<td >{{ rule.next_run_datetime }}</td>
|
||||||
<td > {{'FDD.CLICK_EDIT_FOR_DETAILS' | translate}} </td>
|
<td > {{'FDD.CLICK_EDIT_FOR_DETAILS' | translate}} </td>
|
||||||
<td > {{'FDD.CLICK_EDIT_FOR_DETAILS' | translate}} </td>
|
<td > {{'FDD.CLICK_EDIT_FOR_DETAILS' | translate}} </td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a class="btn btn-primary btn-rounded btn-xs" ng-click="editRule(rule)" >{{'SETTING.EDIT' | translate}}</a>
|
<a class="btn btn-primary btn-rounded btn-xs" ng-click="editRule(rule)" >{{'SETTING.EDIT' | translate}}</a>
|
||||||
<a ng-click="deleteRule(rule)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>
|
<a ng-click="deleteRule(rule)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1247,8 +1247,8 @@ Result in JSON
|
||||||
| expression | string | JSON string of diagnosed objects, points, values, and recipients |
|
| expression | string | JSON string of diagnosed objects, points, values, and recipients |
|
||||||
| message_template | string | Plain text template that supports $-substitutions |
|
| message_template | string | Plain text template that supports $-substitutions |
|
||||||
| is_enabled | boolean | Indicates if this rule is enabled |
|
| is_enabled | boolean | Indicates if this rule is enabled |
|
||||||
| last_run_datetime | float | null, or the number of milliseconds since January 1, 1970, 00:00:00, universal time |
|
| last_run_datetime | float | null, or the last run datetime string in local timezone |
|
||||||
| next_run_datetime | float | null, or the number of milliseconds since January 1, 1970, 00:00:00, universal time |
|
| next_run_datetime | float | null, or the next run datetime string in local timezone |
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -i -X GET {{base_url}}/rules/{id}
|
curl -i -X GET {{base_url}}/rules/{id}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
||||||
import json
|
import json
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import timezone
|
from datetime import datetime, timezone, timedelta
|
||||||
import config
|
import config
|
||||||
from core.userlogger import user_logger
|
from core.userlogger import user_logger
|
||||||
|
|
||||||
|
@ -33,16 +33,26 @@ class RuleCollection:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
|
|
||||||
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||||
|
if config.utc_offset[0] == '-':
|
||||||
|
timezone_offset = -timezone_offset
|
||||||
|
|
||||||
result = list()
|
result = list()
|
||||||
if rows is not None and len(rows) > 0:
|
if rows is not None and len(rows) > 0:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
last_run_datetime = None
|
if isinstance(row['last_run_datetime_utc'], datetime):
|
||||||
if row['last_run_datetime_utc'] is not None:
|
last_run_datetime_local = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||||
last_run_datetime = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
timedelta(minutes=timezone_offset)
|
||||||
|
last_run_datetime = last_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
else:
|
||||||
|
last_run_datetime = None
|
||||||
|
|
||||||
next_run_datetime = None
|
if isinstance(row['next_run_datetime_utc'], datetime):
|
||||||
if row['next_run_datetime_utc'] is not None:
|
next_run_datetime_local = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||||
next_run_datetime = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
timedelta(minutes=timezone_offset)
|
||||||
|
next_run_datetime = next_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
else:
|
||||||
|
next_run_datetime = None
|
||||||
|
|
||||||
meta_result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
meta_result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
||||||
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
|
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
|
||||||
|
@ -204,13 +214,23 @@ class RuleItem:
|
||||||
if row is None:
|
if row is None:
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||||
description='API.RULE_NOT_FOUND')
|
description='API.RULE_NOT_FOUND')
|
||||||
last_run_datetime = None
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||||
if row['last_run_datetime_utc'] is not None:
|
if config.utc_offset[0] == '-':
|
||||||
last_run_datetime = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
timezone_offset = -timezone_offset
|
||||||
|
|
||||||
next_run_datetime = None
|
if isinstance(row['last_run_datetime_utc'], datetime):
|
||||||
if row['next_run_datetime_utc'] is not None:
|
last_run_datetime_local = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||||
next_run_datetime = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
timedelta(minutes=timezone_offset)
|
||||||
|
last_run_datetime = last_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
else:
|
||||||
|
last_run_datetime = None
|
||||||
|
|
||||||
|
if isinstance(row['next_run_datetime_utc'], datetime):
|
||||||
|
next_run_datetime_local = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||||
|
timedelta(minutes=timezone_offset)
|
||||||
|
next_run_datetime = next_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
else:
|
||||||
|
next_run_datetime = None
|
||||||
|
|
||||||
result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
||||||
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
|
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
|
||||||
|
|
Loading…
Reference in New Issue