mirror of https://github.com/D4-project/d4-core
chg: [UI uuid_management + sensor_status] add sensor description
parent
bf2fce284f
commit
c26e95ce50
server/web
|
@ -275,7 +275,7 @@ def sensors_status():
|
||||||
active_connection = False
|
active_connection = False
|
||||||
|
|
||||||
if first_seen is not None and last_seen is not None:
|
if first_seen is not None and last_seen is not None:
|
||||||
status_daily_uuid.append({"uuid": result,"first_seen": first_seen, "last_seen": last_seen,
|
status_daily_uuid.append({"uuid": result,
|
||||||
"active_connection": active_connection, "description": description,
|
"active_connection": active_connection, "description": description,
|
||||||
"first_seen_gmt": first_seen_gmt, "last_seen_gmt": last_seen_gmt,
|
"first_seen_gmt": first_seen_gmt, "last_seen_gmt": last_seen_gmt,
|
||||||
"l_uuid_types": l_uuid_types, "Error": Error})
|
"l_uuid_types": l_uuid_types, "Error": Error})
|
||||||
|
@ -373,12 +373,13 @@ def uuid_management():
|
||||||
if is_valid_uuid_v4(uuid_sensor):
|
if is_valid_uuid_v4(uuid_sensor):
|
||||||
|
|
||||||
disk_stats = get_uuid_disk_statistics(uuid_sensor)
|
disk_stats = get_uuid_disk_statistics(uuid_sensor)
|
||||||
|
|
||||||
first_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'first_seen')
|
first_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'first_seen')
|
||||||
first_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(first_seen)))
|
first_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(first_seen)))
|
||||||
last_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'last_seen')
|
last_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'last_seen')
|
||||||
last_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(last_seen)))
|
last_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(last_seen)))
|
||||||
description = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'description')
|
description = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'description')
|
||||||
|
if not description:
|
||||||
|
description = ''
|
||||||
Error = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'Error')
|
Error = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'Error')
|
||||||
if redis_server_stream.exists('temp_blacklist_uuid:{}'.format(uuid_sensor)):
|
if redis_server_stream.exists('temp_blacklist_uuid:{}'.format(uuid_sensor)):
|
||||||
temp_blacklist_uuid = True
|
temp_blacklist_uuid = True
|
||||||
|
@ -394,8 +395,7 @@ def uuid_management():
|
||||||
Error = "All IP using this UUID are Blacklisted"
|
Error = "All IP using this UUID are Blacklisted"
|
||||||
else:
|
else:
|
||||||
blacklisted_ip_by_uuid = False
|
blacklisted_ip_by_uuid = False
|
||||||
data_uuid= {"first_seen": first_seen, "last_seen": last_seen,
|
data_uuid= {"description": description,
|
||||||
"description": description,
|
|
||||||
"temp_blacklist_uuid": temp_blacklist_uuid,
|
"temp_blacklist_uuid": temp_blacklist_uuid,
|
||||||
"blacklisted_uuid": blacklisted_uuid, "blacklisted_ip_by_uuid": blacklisted_ip_by_uuid,
|
"blacklisted_uuid": blacklisted_uuid, "blacklisted_ip_by_uuid": blacklisted_ip_by_uuid,
|
||||||
"first_seen_gmt": first_seen_gmt, "last_seen_gmt": last_seen_gmt, "Error": Error}
|
"first_seen_gmt": first_seen_gmt, "last_seen_gmt": last_seen_gmt, "Error": Error}
|
||||||
|
@ -508,6 +508,16 @@ def uuid_change_stream_max_size():
|
||||||
else:
|
else:
|
||||||
return 'Invalid uuid'
|
return 'Invalid uuid'
|
||||||
|
|
||||||
|
@app.route('/uuid_change_description')
|
||||||
|
def uuid_change_description():
|
||||||
|
uuid_sensor = request.args.get('uuid')
|
||||||
|
description = request.args.get('description')
|
||||||
|
if is_valid_uuid_v4(uuid_sensor):
|
||||||
|
redis_server_metadata.hset('metadata_uuid:{}'.format(uuid_sensor), 'description', description)
|
||||||
|
return jsonify()
|
||||||
|
else:
|
||||||
|
return jsonify({'error':'invalid uuid'}), 400
|
||||||
|
|
||||||
# # TODO: check analyser uuid dont exist
|
# # TODO: check analyser uuid dont exist
|
||||||
@app.route('/add_new_analyzer')
|
@app.route('/add_new_analyzer')
|
||||||
def add_new_analyzer():
|
def add_new_analyzer():
|
||||||
|
|
|
@ -86,8 +86,8 @@
|
||||||
</a>
|
</a>
|
||||||
<div class="text-info"><small>{{row_uuid['description']}}</small></div>
|
<div class="text-info"><small>{{row_uuid['description']}}</small></div>
|
||||||
</td>
|
</td>
|
||||||
<td>{{row_uuid['first_seen_gmt']}} - ({{row_uuid['first_seen']}})</td>
|
<td>{{row_uuid['first_seen_gmt']}}</td>
|
||||||
<td>{{row_uuid['last_seen_gmt']}} - ({{row_uuid['last_seen']}})</td>
|
<td>{{row_uuid['last_seen_gmt']}}</td>
|
||||||
<td>
|
<td>
|
||||||
{% for uuid_type in row_uuid['l_uuid_types'] %}
|
{% for uuid_type in row_uuid['l_uuid_types'] %}
|
||||||
<span class="badge badge-dark">{{uuid_type}}</span>
|
<span class="badge badge-dark">{{uuid_type}}</span>
|
||||||
|
|
|
@ -17,6 +17,13 @@
|
||||||
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/d3v5.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/d3v5.min.js')}}"></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.edit_icon:hover{
|
||||||
|
cursor: pointer;
|
||||||
|
color: #17a2b8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -43,14 +50,31 @@
|
||||||
UUID: {{uuid_sensor}}
|
UUID: {{uuid_sensor}}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{{data_uuid['description']}}
|
<div class="mb-2">
|
||||||
|
<span id="description-text-block">
|
||||||
|
<span id="description-text">{{data_uuid['description']}}</span>
|
||||||
|
<span onclick="show_edit_description();">
|
||||||
|
<i class="fa fa-pencil edit_icon"></i>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span id="description-edit-block" hidden>
|
||||||
|
<div class="input-group">
|
||||||
|
<input class="form-control" type="text" id="input-description" value="{{data_uuid['description']}}"></input>
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-info" onclick="edit_description();">
|
||||||
|
<i class="fa fa-pencil edit_icon"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="card-group">
|
<div class="card-group">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-info text-white">
|
<div class="card-header bg-info text-white">
|
||||||
First Seen
|
First Seen
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">{{data_uuid['first_seen_gmt']}} - ({{data_uuid['first_seen']}})</p>
|
<p class="card-text">{{data_uuid['first_seen_gmt']}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
@ -58,7 +82,7 @@
|
||||||
Last Seen
|
Last Seen
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">{{data_uuid['last_seen_gmt']}} - ({{data_uuid['last_seen']}})</p>
|
<p class="card-text">{{data_uuid['last_seen_gmt']}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
@ -251,6 +275,9 @@
|
||||||
<script>
|
<script>
|
||||||
var chart = {};
|
var chart = {};
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$('#description-edit-block').hide();
|
||||||
|
$('#description-edit-block').removeAttr("hidden")
|
||||||
|
|
||||||
table = $('#myTable_1').DataTable(
|
table = $('#myTable_1').DataTable(
|
||||||
{
|
{
|
||||||
"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
|
"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
|
||||||
|
@ -309,6 +336,25 @@ function swap_stats_type(){
|
||||||
chart.stackBarChart2 =barchart_type_stack(url_json_stats, '#barchart_type_disk');
|
chart.stackBarChart2 =barchart_type_stack(url_json_stats, '#barchart_type_disk');
|
||||||
chart.onResize();
|
chart.onResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_edit_description(){
|
||||||
|
$('#description-text-block').hide();
|
||||||
|
$('#description-edit-block').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit_description(){
|
||||||
|
var new_description = $('#input-description').val()
|
||||||
|
var data_to_send = { uuid: "{{uuid_sensor}}", "description": new_description}
|
||||||
|
|
||||||
|
$.get("{{ url_for('uuid_change_description') }}", data_to_send, function(data, status){
|
||||||
|
if(status == "success") {
|
||||||
|
$('#description-text').text(new_description)
|
||||||
|
$('#description-edit-block').hide();
|
||||||
|
$('#description-text-block').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
Loading…
Reference in New Issue