mirror of https://github.com/CIRCL/lookyloo
new: Fetch the exiting collection names from the monitoring interface
parent
089c007280
commit
7a96ae9767
|
@ -120,6 +120,8 @@ class Lookyloo():
|
||||||
self.monitoring = PyLookylooMonitoring(monitoring_config['url'], get_useragent_for_requests())
|
self.monitoring = PyLookylooMonitoring(monitoring_config['url'], get_useragent_for_requests())
|
||||||
if self.monitoring.is_up:
|
if self.monitoring.is_up:
|
||||||
self.monitoring_enabled = True
|
self.monitoring_enabled = True
|
||||||
|
# NOTE: maybe move that somewhere else: we'll need to restart the webserver
|
||||||
|
# if we change the settings in the monitoring instance
|
||||||
self.monitoring_settings = self.monitoring.instance_settings()
|
self.monitoring_settings = self.monitoring.instance_settings()
|
||||||
|
|
||||||
self.logger.info('Initializing context...')
|
self.logger.info('Initializing context...')
|
||||||
|
|
|
@ -709,6 +709,13 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
if cache.error:
|
if cache.error:
|
||||||
flash(cache.error, 'warning')
|
flash(cache.error, 'warning')
|
||||||
|
|
||||||
|
if lookyloo.monitoring_enabled:
|
||||||
|
try:
|
||||||
|
monitoring_collections = lookyloo.monitoring.collections()
|
||||||
|
except Exception as e:
|
||||||
|
monitoring_collections = []
|
||||||
|
flash(f'Unable to get existing connections from the monitoring : {e}', 'warning')
|
||||||
|
|
||||||
return render_template('tree.html', tree_json=ct.to_json(),
|
return render_template('tree.html', tree_json=ct.to_json(),
|
||||||
info=cache,
|
info=cache,
|
||||||
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
|
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
|
||||||
|
@ -717,6 +724,7 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
meta=meta, enable_mail_notification=enable_mail_notification,
|
meta=meta, enable_mail_notification=enable_mail_notification,
|
||||||
enable_monitoring=lookyloo.monitoring_enabled,
|
enable_monitoring=lookyloo.monitoring_enabled,
|
||||||
monitoring_settings=lookyloo.monitoring_settings if lookyloo.monitoring_enabled else None,
|
monitoring_settings=lookyloo.monitoring_settings if lookyloo.monitoring_enabled else None,
|
||||||
|
monitoring_collections=monitoring_collections if lookyloo.monitoring_enabled else [],
|
||||||
enable_context_by_users=enable_context_by_users,
|
enable_context_by_users=enable_context_by_users,
|
||||||
enable_categorization=enable_categorization,
|
enable_categorization=enable_categorization,
|
||||||
enable_bookmark=enable_bookmark,
|
enable_bookmark=enable_bookmark,
|
||||||
|
|
|
@ -740,8 +740,18 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="collection" class="form-label">Collection</label>
|
{% if monitoring_collections %}
|
||||||
|
<label for="collection" class="form-label">Pick a collection.</label>
|
||||||
|
<input type="text" class="form-control" list="collections" id="collection" name="collection" placeholder="Type a collection name, or select an existing one (arrow down to see them)">
|
||||||
|
<datalist id="collections">
|
||||||
|
{% for name in monitoring_collections %}
|
||||||
|
<option value="{{name}}">{{name}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
{%else%}
|
||||||
|
<label for=collection" class="form-label">Add to a collection.</label>
|
||||||
<input type="text" class="form-control" name="collection" id="collection" placeholder="Name of the collection">
|
<input type="text" class="form-control" name="collection" id="collection" placeholder="Name of the collection">
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 form-check">
|
<div class="mb-3 form-check">
|
||||||
<input class="form-check-input" type="checkbox" name="confirm" onchange="document.getElementById('btn-notification').disabled = !this.checked;"></input>
|
<input class="form-check-input" type="checkbox" name="confirm" onchange="document.getElementById('btn-notification').disabled = !this.checked;"></input>
|
||||||
|
|
Loading…
Reference in New Issue