added last seen datetime to Gateway Setting in Admin UI
parent
f73936a452
commit
e4b9cffd18
|
@ -544,6 +544,7 @@ function config($translateProvider) {
|
||||||
GATEWAY: {
|
GATEWAY: {
|
||||||
GATEWAY: 'Gateway',
|
GATEWAY: 'Gateway',
|
||||||
TOKEN: 'Token',
|
TOKEN: 'Token',
|
||||||
|
LAST_SEEN_DATETIME: 'Last Seen Datetime',
|
||||||
SELECT_GATEWAY: 'Select Gateway',
|
SELECT_GATEWAY: 'Select Gateway',
|
||||||
ADD_GATEWAY: 'Add Gateway',
|
ADD_GATEWAY: 'Add Gateway',
|
||||||
EDIT_GATEWAY: 'Edit Gateway',
|
EDIT_GATEWAY: 'Edit Gateway',
|
||||||
|
@ -1605,7 +1606,8 @@ function config($translateProvider) {
|
||||||
},
|
},
|
||||||
GATEWAY: {
|
GATEWAY: {
|
||||||
GATEWAY: '网关',
|
GATEWAY: '网关',
|
||||||
TOKEN: 'Token',
|
TOKEN: '令牌',
|
||||||
|
LAST_SEEN_DATETIME: '最后在线时间',
|
||||||
SELECT_GATEWAY: '选择网关',
|
SELECT_GATEWAY: '选择网关',
|
||||||
ADD_GATEWAY: '添加网关',
|
ADD_GATEWAY: '添加网关',
|
||||||
EDIT_GATEWAY: '编辑网关',
|
EDIT_GATEWAY: '编辑网关',
|
||||||
|
@ -2655,7 +2657,8 @@ function config($translateProvider) {
|
||||||
},
|
},
|
||||||
GATEWAY: {
|
GATEWAY: {
|
||||||
GATEWAY: 'Tor',
|
GATEWAY: 'Tor',
|
||||||
TOKEN: 'Zeichen',
|
TOKEN: 'Token',
|
||||||
|
LAST_SEEN_DATETIME: 'Zuletzt gesehen datetime',
|
||||||
SELECT_GATEWAY: 'Wählen Sie ein Gateway',
|
SELECT_GATEWAY: 'Wählen Sie ein Gateway',
|
||||||
ADD_GATEWAY: 'Gateway hinzufügen',
|
ADD_GATEWAY: 'Gateway hinzufügen',
|
||||||
EDIT_GATEWAY: 'Gateway bearbeiten',
|
EDIT_GATEWAY: 'Gateway bearbeiten',
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<th class="text-center">{{'SETTING.ID' | translate}}</th>
|
<th class="text-center">{{'SETTING.ID' | translate}}</th>
|
||||||
<th class="text-center">{{'SETTING.NAME' | translate}}</th>
|
<th class="text-center">{{'SETTING.NAME' | translate}}</th>
|
||||||
<th class="text-center">{{'GATEWAY.TOKEN' | translate}}</th>
|
<th class="text-center">{{'GATEWAY.TOKEN' | translate}}</th>
|
||||||
|
<th class="text-center">{{'GATEWAY.LAST_SEEN_DATETIME' | translate}}</th>
|
||||||
<th class="text-center">{{'SETTING.ACTION' | translate}}</th>
|
<th class="text-center">{{'SETTING.ACTION' | translate}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
<td class="text-center">{{ gateway.id }}</td>
|
<td class="text-center">{{ gateway.id }}</td>
|
||||||
<td class="text-center">{{ gateway.name }}</td>
|
<td class="text-center">{{ gateway.name }}</td>
|
||||||
<td class="text-center">{{ gateway.token}}</td>
|
<td class="text-center">{{ gateway.token}}</td>
|
||||||
|
<td class="text-center">{{ gateway.last_seen_datetime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a class="btn btn-primary btn-rounded btn-xs" ng-click="editGateway(gateway)" >{{'SETTING.EDIT' | translate}}</a>
|
<a class="btn btn-primary btn-rounded btn-xs" ng-click="editGateway(gateway)" >{{'SETTING.EDIT' | translate}}</a>
|
||||||
<a ng-click="deleteGateway(gateway)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>
|
<a ng-click="deleteGateway(gateway)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>
|
||||||
|
|
|
@ -20,12 +20,9 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="knowledgefile in knowledgefiles">
|
<tr ng-repeat="knowledgefile in knowledgefiles">
|
||||||
<td class="text-center">{{ knowledgefile.id }}</td>
|
<td class="text-center">{{ knowledgefile.id }}</td>
|
||||||
<td class="text-center"><a href="./upload/{{knowledgefile.uuid}}"
|
<td class="text-center"><a href="./upload/{{knowledgefile.uuid}}" download="{{knowledgefile.file_name}}">{{ knowledgefile.file_name }}</a></td>
|
||||||
download="{{knowledgefile.file_name}}">{{ knowledgefile.file_name }}</a>
|
|
||||||
</td>
|
|
||||||
<td class="text-center">{{ knowledgefile.user_display_name }}</td>
|
<td class="text-center">{{ knowledgefile.user_display_name }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">{{ knowledgefile.upload_datetime | date:'yyyy-MM-dd HH:mm'}}</td>
|
||||||
{{ knowledgefile.upload_datetime | date:'yyyy-MM-dd HH:mm'}}</td>
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a ng-click="restoreKnowledgeFile(knowledgefile)"
|
<a ng-click="restoreKnowledgeFile(knowledgefile)"
|
||||||
class="btn btn-danger btn-rounded btn-xs">{{'KNOWLEDGEFILE.RESTORE' | translate}}</a>
|
class="btn btn-danger btn-rounded btn-xs">{{'KNOWLEDGEFILE.RESTORE' | translate}}</a>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import simplejson as json
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
import config
|
import config
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
|
||||||
class GatewayCollection:
|
class GatewayCollection:
|
||||||
|
@ -18,7 +18,7 @@ class GatewayCollection:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def on_get(req, resp):
|
def on_get(req, resp):
|
||||||
cnx = mysql.connector.connect(**config.myems_system_db)
|
cnx = mysql.connector.connect(**config.myems_system_db)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor(dictionary=True)
|
||||||
|
|
||||||
query = (" SELECT id, name, uuid, token, last_seen_datetime_utc "
|
query = (" SELECT id, name, uuid, token, last_seen_datetime_utc "
|
||||||
" FROM tbl_gateways "
|
" FROM tbl_gateways "
|
||||||
|
@ -29,19 +29,14 @@ class GatewayCollection:
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
|
|
||||||
result = list()
|
result = list()
|
||||||
now = datetime.utcnow().replace(second=0, microsecond=0, tzinfo=None)
|
|
||||||
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_seen_time = row[4]
|
meta_result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
||||||
if last_seen_time is not None and (now - last_seen_time).total_seconds() > 5 * 60:
|
"token": row['token'],
|
||||||
status = "online"
|
"last_seen_datetime":
|
||||||
else:
|
row['last_seen_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
||||||
status = "offline"
|
if isinstance(row['last_seen_datetime_utc'], datetime) else None,
|
||||||
meta_result = {"id": row[0], "name": row[1], "uuid": row[2],
|
}
|
||||||
"token": row[3],
|
|
||||||
"last_seen_datetime": row[4].timestamp() * 1000 if isinstance(row[4],
|
|
||||||
datetime) else None,
|
|
||||||
"status": status}
|
|
||||||
result.append(meta_result)
|
result.append(meta_result)
|
||||||
|
|
||||||
resp.body = json.dumps(result)
|
resp.body = json.dumps(result)
|
||||||
|
@ -105,7 +100,7 @@ class GatewayItem:
|
||||||
description='API.INVALID_GATEWAY_ID')
|
description='API.INVALID_GATEWAY_ID')
|
||||||
|
|
||||||
cnx = mysql.connector.connect(**config.myems_system_db)
|
cnx = mysql.connector.connect(**config.myems_system_db)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor(dictionary=True)
|
||||||
|
|
||||||
query = (" SELECT id, name, uuid, token, last_seen_datetime_utc "
|
query = (" SELECT id, name, uuid, token, last_seen_datetime_utc "
|
||||||
" FROM tbl_gateways "
|
" FROM tbl_gateways "
|
||||||
|
@ -118,17 +113,13 @@ class GatewayItem:
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||||
description='API.GATEWAY_NOT_FOUND')
|
description='API.GATEWAY_NOT_FOUND')
|
||||||
|
|
||||||
now = datetime.utcnow().replace(second=0, microsecond=0, tzinfo=None)
|
result = {"id": row['id'],
|
||||||
last_seen_time = row[4]
|
"name": row['name'],
|
||||||
if last_seen_time is not None and (now - last_seen_time).total_seconds() > 5 * 60:
|
"uuid": row['uuid'],
|
||||||
status = "online"
|
"token": row['token'],
|
||||||
else:
|
"last_seen_datetime":
|
||||||
status = "offline"
|
row['last_seen_datetime_utc'].replace(tzinfo=timezone.utc).timestamp()*1000
|
||||||
|
if isinstance(row['last_seen_datetime_utc'], datetime) else None}
|
||||||
result = {"id": row[0], "name": row[1], "uuid": row[2],
|
|
||||||
"token": row[3],
|
|
||||||
"last_seen_datetime": row[4].timestamp()*1000 if isinstance(row[4], datetime) else None,
|
|
||||||
"status": status}
|
|
||||||
|
|
||||||
resp.body = json.dumps(result)
|
resp.body = json.dumps(result)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue