Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#52
This commit is contained in:
2025-08-22 06:36:22 +12:00
parent ec387cc12e
commit 6e6b394289
42 changed files with 222 additions and 368 deletions

View File

@ -944,7 +944,7 @@ class SimpleAmbitRule(SimpleRule):
@property @property
def as_svg(self): def as_svg(self):
return IndigoUtils.smirks_to_svg(self.smirks, True) return IndigoUtils.smirks_to_svg(self.smirks, True, width=800, height=400)
class SimpleRDKitRule(SimpleRule): class SimpleRDKitRule(SimpleRule):
@ -1203,6 +1203,12 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin):
for n in self.root_nodes: for n in self.root_nodes:
queue.append(n) queue.append(n)
# Add unconnected nodes
for n in self.nodes:
if len(n.out_edges.all()) == 0:
if n not in queue:
queue.append(n)
while len(queue): while len(queue):
current = queue.pop() current = queue.pop()
processed.add(current) processed.add(current)
@ -1341,12 +1347,12 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin):
pw = Pathway() pw = Pathway()
pw.package = package pw.package = package
if name is None: if name is None or name.strip() == '':
name = f"Pathway {Pathway.objects.filter(package=package).count() + 1}" name = f"Pathway {Pathway.objects.filter(package=package).count() + 1}"
pw.name = name pw.name = name
if description is not None: if description is not None and description.strip() != '':
pw.description = description pw.description = description
pw.save() pw.save()

View File

@ -4,6 +4,9 @@ from typing import List, Dict, Any
from django.conf import settings as s from django.conf import settings as s
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db.models import F, Value
from django.db.models.fields import CharField
from django.db.models.functions import Concat
from django.http import JsonResponse, HttpResponse, HttpResponseNotAllowed, HttpResponseBadRequest from django.http import JsonResponse, HttpResponse, HttpResponseNotAllowed, HttpResponseBadRequest
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
@ -436,8 +439,16 @@ def scenarios(request):
if request.GET.get('all'): if request.GET.get('all'):
return JsonResponse({ return JsonResponse({
"objects": [ "objects": [
{"name": pw.name, "url": pw.url, "reviewed": True} {"name": s.name, "url": s.full_url, "reviewed": True}
for pw in reviewed_scenario_qs for s in reviewed_scenario_qs.annotate(
full_url=Concat(
Value(s.SERVER_URL + '/package/'),
F("package__uuid"),
Value("/scenario/"),
F("uuid"),
output_field=CharField(),
)
)
] ]
}) })
@ -517,6 +528,7 @@ def search(request):
packages = PackageManager.get_reviewed_packages() packages = PackageManager.get_reviewed_packages()
search_result = SearchManager.search(packages, searchterm, mode) search_result = SearchManager.search(packages, searchterm, mode)
return JsonResponse(search_result, safe=False) return JsonResponse(search_result, safe=False)
context = get_base_context(request) context = get_base_context(request)
@ -542,6 +554,7 @@ def search(request):
packages = PackageManager.get_reviewed_packages() packages = PackageManager.get_reviewed_packages()
context['search_result'] = SearchManager.search(packages, searchterm, mode) context['search_result'] = SearchManager.search(packages, searchterm, mode)
context['search_result']['searchterm'] = searchterm
return render(request, 'search.html', context) return render(request, 'search.html', context)
@ -706,7 +719,7 @@ def package_model(request, package_uuid, model_uuid):
elif request.method == 'POST': elif request.method == 'POST':
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-model': if hidden == 'delete':
current_model.delete() current_model.delete()
return redirect(current_package.url + '/model') return redirect(current_package.url + '/model')
else: else:
@ -757,7 +770,7 @@ def package(request, package_uuid):
logger.debug(f"{k}\t{v}") logger.debug(f"{k}\t{v}")
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-package': if hidden == 'delete':
logger.debug(current_package.delete()) logger.debug(current_package.delete())
return redirect(s.SERVER_URL + '/package') return redirect(s.SERVER_URL + '/package')
else: else:
@ -897,7 +910,7 @@ def package_compound(request, package_uuid, compound_uuid):
elif request.method == 'POST': elif request.method == 'POST':
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-compound': if hidden == 'delete':
current_compound.delete() current_compound.delete()
return redirect(current_package.url + '/compound') return redirect(current_package.url + '/compound')
else: else:
@ -940,6 +953,7 @@ def package_compound_structures(request, package_uuid, compound_uuid):
context['meta']['current_package'] = current_package context['meta']['current_package'] = current_package
context['object_type'] = 'structure' context['object_type'] = 'structure'
context['breadcrumbs'] = breadcrumbs(current_package, 'compound', current_compound, 'structure')
reviewed_compound_structure_qs = CompoundStructure.objects.none() reviewed_compound_structure_qs = CompoundStructure.objects.none()
unreviewed_compound_structure_qs = CompoundStructure.objects.none() unreviewed_compound_structure_qs = CompoundStructure.objects.none()
@ -979,15 +993,38 @@ def package_compound_structure(request, package_uuid, compound_uuid, structure_u
context['title'] = f'enviPath - {current_package.name} - {current_compound.name} - {current_structure.name}' context['title'] = f'enviPath - {current_package.name} - {current_compound.name} - {current_structure.name}'
context['meta']['current_package'] = current_package context['meta']['current_package'] = current_package
context['object_type'] = 'compound' context['object_type'] = 'structure'
context['compound_structure'] = current_structure context['compound_structure'] = current_structure
context['current_object'] = current_structure context['current_object'] = current_structure
context['breadcrumbs'] = breadcrumbs(current_package, 'compound', current_compound, 'structure', current_structure)
return render(request, 'objects/compound_structure.html', context) return render(request, 'objects/compound_structure.html', context)
elif request.method == 'POST': elif request.method == 'POST':
if hidden := request.POST.get('hidden', None):
if hidden == 'delete':
# Check if we have to delete the compound as no structure is left
if len(current_structure.compound.structures.all()) == 1:
# This will delete the structure as well
current_compound.delete()
return redirect(current_package.url + '/compound')
else:
if current_structure.normalized_structure:
current_compound.delete()
return redirect(current_package.url + '/compound')
else:
if current_compound.default_structure == current_structure:
current_structure.delete()
current_compound.default_structure = current_compound.structures.all().first()
return redirect(current_compound.url + '/structure')
else:
current_structure.delete()
return redirect(current_compound.url + '/structure')
else:
return HttpResponseBadRequest()
selected_scenarios = request.POST.getlist('selected-scenarios') selected_scenarios = request.POST.getlist('selected-scenarios')
if selected_scenarios: if selected_scenarios:
@ -1109,7 +1146,7 @@ def package_rule(request, package_uuid, rule_uuid):
elif request.method == 'POST': elif request.method == 'POST':
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-rule': if hidden == 'delete':
current_rule.delete() current_rule.delete()
return redirect(current_package.url + '/rule') return redirect(current_package.url + '/rule')
else: else:
@ -1212,7 +1249,7 @@ def package_reaction(request, package_uuid, reaction_uuid):
elif request.method == 'POST': elif request.method == 'POST':
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-reaction': if hidden == 'delete':
current_reaction.delete() current_reaction.delete()
return redirect(current_package.url + '/reaction') return redirect(current_package.url + '/reaction')
else: else:
@ -1281,8 +1318,8 @@ def package_pathways(request, package_uuid):
log_post_params(request) log_post_params(request)
name = request.POST.get('name', 'Pathway ' + str(Pathway.objects.filter(package=current_package).count())) name = request.POST.get('name')
description = request.POST.get('description', s.DEFAULT_VALUES['description']) description = request.POST.get('description')
pw_mode = request.POST.get('predict', 'predict') pw_mode = request.POST.get('predict', 'predict')
smiles = request.POST.get('smiles') smiles = request.POST.get('smiles')
@ -1303,7 +1340,14 @@ def package_pathways(request, package_uuid):
return error(request, "Pathway prediction failed!", return error(request, "Pathway prediction failed!",
f'Pathway prediction failed as received mode "{pw_mode}" is none of {modes}') f'Pathway prediction failed as received mode "{pw_mode}" is none of {modes}')
prediction_setting = request.POST.get('prediction-setting', None)
if prediction_setting:
prediction_setting = SettingManager.get_setting_by_url(current_user, prediction_setting)
else:
prediction_setting = current_user.prediction_settings()
pw = Pathway.create(current_package, stand_smiles, name=name, description=description) pw = Pathway.create(current_package, stand_smiles, name=name, description=description)
# set mode # set mode
pw.kv.update({'mode': pw_mode}) pw.kv.update({'mode': pw_mode})
pw.save() pw.save()
@ -1316,12 +1360,11 @@ def package_pathways(request, package_uuid):
if pw_mode == 'incremental': if pw_mode == 'incremental':
limit = 1 limit = 1
pred_setting = current_user.prediction_settings() pw.setting = prediction_setting
pw.setting = pred_setting
pw.save() pw.save()
from .tasks import predict from .tasks import predict
predict.delay(pw.pk, pred_setting.pk, limit=limit) predict.delay(pw.pk, prediction_setting.pk, limit=limit)
return redirect(pw.url) return redirect(pw.url)
@ -1371,7 +1414,7 @@ def package_pathway(request, package_uuid, pathway_uuid):
elif request.method == 'POST': elif request.method == 'POST':
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-pathway': if hidden == 'delete':
current_pathway.delete() current_pathway.delete()
return redirect(current_package.url + '/pathway') return redirect(current_package.url + '/pathway')
else: else:
@ -1514,7 +1557,7 @@ def package_pathway_node(request, package_uuid, pathway_uuid, node_uuid):
log_post_params(request) log_post_params(request)
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-node': if hidden == 'delete':
# pre_delete signal will take care of edge deletion # pre_delete signal will take care of edge deletion
current_node.delete() current_node.delete()
@ -1616,7 +1659,7 @@ def package_pathway_edge(request, package_uuid, pathway_uuid, edge_uuid):
'title'] = f'enviPath - {current_package.name} - {current_pathway.name} - {current_edge.edge_label.name}' 'title'] = f'enviPath - {current_package.name} - {current_pathway.name} - {current_edge.edge_label.name}'
context['meta']['current_package'] = current_package context['meta']['current_package'] = current_package
context['object_type'] = 'reaction' context['object_type'] = 'edge'
context['breadcrumbs'] = breadcrumbs(current_package, 'pathway', current_pathway, 'edge', current_edge) context['breadcrumbs'] = breadcrumbs(current_package, 'pathway', current_pathway, 'edge', current_edge)
context['edge'] = current_edge context['edge'] = current_edge
context['current_object'] = current_edge context['current_object'] = current_edge
@ -1628,7 +1671,7 @@ def package_pathway_edge(request, package_uuid, pathway_uuid, edge_uuid):
log_post_params(request) log_post_params(request)
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-edge': if hidden == 'delete':
current_edge.delete() current_edge.delete()
return redirect(current_pathway.url) return redirect(current_pathway.url)
@ -1896,7 +1939,7 @@ def group(request, group_uuid):
log_post_params(request) log_post_params(request)
if hidden := request.POST.get('hidden', None): if hidden := request.POST.get('hidden', None):
if hidden == 'delete-group': if hidden == 'delete':
current_group.delete() current_group.delete()
return redirect(s.SERVER_URL + '/group') return redirect(s.SERVER_URL + '/group')
else: else:

View File

@ -12,7 +12,7 @@
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a> <i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_compound_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Compound</a> <i class="glyphicon glyphicon-trash"></i> Delete Compound</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -8,7 +8,7 @@
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a> <i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_compound_structure_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Compound Structure</a> <i class="glyphicon glyphicon-trash"></i> Delete Compound Structure</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -0,0 +1,10 @@
{% if meta.can_edit %}
<li>
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
</li>
<li>
<a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Edge</a>
</li>
{% endif %}

View File

@ -1,10 +1,10 @@
{% if meta.can_edit %} {% if meta.can_edit %}
<li>
<a role="button" data-toggle="modal" data-target="#delete_group_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Group</a>
</li>
<li> <li>
<a role="button" data-toggle="modal" data-target="#edit_group_member_modal"> <a role="button" data-toggle="modal" data-target="#edit_group_member_modal">
<i class="glyphicon glyphicon-trash"></i> Add/Remove Member</a> <i class="glyphicon glyphicon-trash"></i> Add/Remove Member</a>
</li> </li>
<li>
<a role="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Group</a>
</li>
{% endif %} {% endif %}

View File

@ -1,6 +1,6 @@
{% if meta.can_edit %} {% if meta.can_edit %}
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_model_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Model</a> <i class="glyphicon glyphicon-trash"></i> Delete Model</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -8,7 +8,7 @@
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a> <i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_node_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Node</a> <i class="glyphicon glyphicon-trash"></i> Delete Node</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -12,7 +12,7 @@
<i class="glyphicon glyphicon-duplicate"></i> License</a> <i class="glyphicon glyphicon-duplicate"></i> License</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_package_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Package</a> <i class="glyphicon glyphicon-trash"></i> Delete Package</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -35,7 +35,7 @@
<i class="glyphicon glyphicon-trash"></i> Delete Reaction</a> <i class="glyphicon glyphicon-trash"></i> Delete Reaction</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_pathway_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Pathway</a> <i class="glyphicon glyphicon-trash"></i> Delete Pathway</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -8,7 +8,7 @@
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a> <i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_reaction_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Reaction</a> <i class="glyphicon glyphicon-trash"></i> Delete Reaction</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -8,7 +8,7 @@
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a> <i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
</li> </li>
<li> <li>
<a class="button" data-toggle="modal" data-target="#delete_rule_modal"> <a class="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Rule</a> <i class="glyphicon glyphicon-trash"></i> Delete Rule</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -16,7 +16,7 @@
{# <i class="glyphicon glyphicon-console"></i> Manage API Token</a>#} {# <i class="glyphicon glyphicon-console"></i> Manage API Token</a>#}
{# </li>#} {# </li>#}
<li> <li>
<a role="button" data-toggle="modal" data-target="#delete_user_modal"> <a role="button" data-toggle="modal" data-target="#generic_delete_modal">
<i class="glyphicon glyphicon-trash"></i> Delete Account</a> <i class="glyphicon glyphicon-trash"></i> Delete Account</a>
</li> </li>
{% endif %} {% endif %}

View File

@ -83,21 +83,26 @@
<!-- Collect the nav links, forms, and other content for toggling --> <!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse collapse-framework navbar-collapse-framework" id="navbarCollapse"> <div class="collapse navbar-collapse collapse-framework navbar-collapse-framework" id="navbarCollapse">
<ul class="nav navbar-nav navbar-nav-framework"> <ul class="nav navbar-nav navbar-nav-framework">
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Predict Pathway<b class="caret"></b></a>
<ul role="menu" class="dropdown-menu">
<li> <li>
<a class="button" data-toggle="modal" data-target="#predict_modal"> <a class="button" data-toggle="modal" data-target="#predict_modal">
<i class=" glyphicon glyphicon-tag"></i> Predict Pathway Predict Pathway
</a> </a>
</li> </li>
<li> {# <li class="dropdown">#}
<a class="button" data-toggle="modal" data-target="#batch_predict_modal"> {# <a data-toggle="dropdown" class="dropdown-toggle" href="#">Predict Pathway<b class="caret"></b></a>#}
<i class=" glyphicon glyphicon-tags"></i> Batch Prediction {# <ul role="menu" class="dropdown-menu">#}
</a> {# <li>#}
</li> {# <a class="button" data-toggle="modal" data-target="#predict_modal">#}
</ul> {# <i class=" glyphicon glyphicon-tag"></i> Predict Pathway#}
</li> {# </a>#}
{# </li>#}
{# <li>#}
{# <a class="button" data-toggle="modal" data-target="#batch_predict_modal">#}
{# <i class=" glyphicon glyphicon-tags"></i> Batch Prediction#}
{# </a>#}
{# </li>#}
{# </ul>#}
{# </li>#}
<li><a href="{{ meta.server_url }}/package" id="packageLink">Package</a></li> <li><a href="{{ meta.server_url }}/package" id="packageLink">Package</a></li>
<li><a href="{{ meta.server_url }}/search" id="searchLink">Search</a></li> <li><a href="{{ meta.server_url }}/search" id="searchLink">Search</a></li>
<li><a href="{{ meta.server_url }}/model" id="modelLink">Modelling</a></li> <li><a href="{{ meta.server_url }}/model" id="modelLink">Modelling</a></li>
@ -192,6 +197,23 @@
{% endif %} {% endif %}
{% block content %} {% block content %}
{% endblock content %} {% endblock content %}
{% if meta.current_package.license %}
<p></p>
<div class="panel-group" id="license_accordion">
<div class="panel panel-default list-group-item" style="background-color:#f5f5f5">
<div class="panel-title">
<a data-toggle="collapse" data-parent="#licence_accordion" href="#license">License</a>
</div>
</div>
<div id="license" class="panel-collapse collapse in">
<div class="panel-body list-group-item">
<a target="_blank" href="{{ meta.current_package.license.link }}">
<img src="{{ meta.current_package.license.image_link }}">
</a>
</div>
</div>
</div>
{% endif %}
</div> </div>
<!-- FOOTER --> <!-- FOOTER -->

View File

@ -143,6 +143,14 @@
} }
$(function () { $(function () {
$('#index-form').on("keydown", function (e) {
if (e.key === "Enter") {
e.preventDefault();
goButtonClicked();
}
});
// Code that should be executed once DOM is ready goes here // Code that should be executed once DOM is ready goes here
$('#dropdown-predict').on('click', actionDropdownClicked); $('#dropdown-predict').on('click', actionDropdownClicked);
$('#dropdown-search').on('click', actionDropdownClicked); $('#dropdown-search').on('click', actionDropdownClicked);

View File

@ -1,35 +0,0 @@
{% load static %}
<!-- Delete Compound -->
<div id="delete_compound_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Compound</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Deletes the Compound and associated Structures.
<form id="delete-compound-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete-compound"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="delete-compound-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function() {
$('#delete-compound-modal-submit').click(function(e){
e.preventDefault();
$('#delete-compound-modal-form').submit();
});
})
</script>

View File

@ -1,38 +0,0 @@
{% load static %}
<!-- Delete Group -->
<div id="delete_group_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Group</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-danger">
Clicking "Delete" will <strong>permanently</strong> delete the Group.
This action can't be undone!
</div>
<form id="delete-group-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" name="hidden" value="delete-group">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="delete-group-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function() {
$('#delete-group-modal-submit').click(function(e){
e.preventDefault();
$('#delete-group-modal-form').submit();
});
})
</script>

View File

@ -1,35 +0,0 @@
{% load static %}
<!-- Delete Model -->
<div id="delete_model_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Model</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Deletes the Model.
<form id="delete-model-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete-model"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="delete-model-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#delete-model-modal-submit').click(function (e) {
e.preventDefault();
$('#delete-model-modal-form').submit();
});
})
</script>

View File

@ -1,35 +0,0 @@
{% load static %}
<!-- Delete Node -->
<div id="delete_node_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Node</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Deletes the Node as well as ingoing and outgoing edges.
<form id="delete-node-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete-node"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="delete-node-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#delete-node-modal-submit').click(function (e) {
e.preventDefault();
$('#delete-node-modal-form').submit();
});
})
</script>

View File

@ -1,36 +0,0 @@
{% load static %}
<!-- Delete Package -->
<div id="delete_package_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Package</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Deleting a Package deletes the very Package
as well as all Objects stored in the Package.
<form id="delete-package-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete-package"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="delete-package-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function() {
$('#delete-package-modal-submit').click(function(e){
e.preventDefault();
$('#delete-package-modal-form').submit();
});
})
</script>

View File

@ -22,7 +22,7 @@
<option value="{{ e.url }}">{{ e.edge_label.name }}</option> <option value="{{ e.url }}">{{ e.edge_label.name }}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type="hidden" id="hidden" name="hidden" value="delete-edge"/> <input type="hidden" id="hidden" name="hidden" value="delete"/>
</form> </form>
<p></p> <p></p>
<div id="delete_pathway_edge_image"></div> <div id="delete_pathway_edge_image"></div>

View File

@ -1,35 +0,0 @@
{% load static %}
<!-- Delete Pathway -->
<div id="delete_pathway_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Pathway</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Deletes the Pathway together with all Nodes and Edges.
<form id="delete-pathway-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete-pathway"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="delete-pathway-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#delete-pathway-modal-submit').click(function (e) {
e.preventDefault();
$('#delete-pathway-modal-form').submit();
});
})
</script>

View File

@ -22,7 +22,7 @@
<option value="{{ n.url }}">{{ n.default_node_label.name }}</option> <option value="{{ n.url }}">{{ n.default_node_label.name }}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type="hidden" id="hidden" name="hidden" value="delete-node"/> <input type="hidden" id="hidden" name="hidden" value="delete"/>
</form> </form>
<p></p> <p></p>
<div id="delete_pathway_node_image"></div> <div id="delete_pathway_node_image"></div>

View File

@ -1,35 +0,0 @@
{% load static %}
<!-- Delete Reaction -->
<div id="delete_reaction_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete Reaction</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Deletes the Reaction.
<form id="delete-reaction-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete-reaction"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="delete-reaction-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#delete-reaction-modal-submit').click(function (e) {
e.preventDefault();
$('#delete-reaction-modal-form').submit();
});
})
</script>

View File

@ -1,38 +0,0 @@
{% load static %}
<!-- Delete User -->
<div id="delete_user_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete User</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-danger">
Clicking "Delete" will <strong>permanently</strong> delete the User and associated data.
This action can't be undone!
</div>
<form id="delete-user-modal-form" accept-charset="UTF-8" action="" data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" name="hidden" value="delete-user">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="delete-user-modal-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function() {
$('#delete-user-modal-submit').click(function(e){
e.preventDefault();
$('#delete-user-modal-form').submit();
});
})
</script>

View File

@ -29,6 +29,7 @@
$('#download-pathway-modal-submit').click(function (e) { $('#download-pathway-modal-submit').click(function (e) {
e.preventDefault(); e.preventDefault();
$('#download-pathway-modal-form').submit(); $('#download-pathway-modal-form').submit();
$('#download_pathway_modal').modal('hide');
}); });
}) })

View File

@ -0,0 +1,42 @@
{% load static %}
<!-- Delete Object -->
<div id="generic_delete_modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Delete {{ object_type|capfirst }}</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{% if object_type == 'user' %}
Clicking "Delete" will <strong>permanently</strong> delete the User and associated data.
This action can't be undone!
{% else %}
Deletes the {{ object_type|capfirst }}. Related objects that depend on this {{ object_type|capfirst }}
will be deleted as well.
{% endif %}
<form id="generic-delete-modal-form" accept-charset="UTF-8" action="{{ current_object.url }}"
data-remote="true" method="post">
{% csrf_token %}
<input type="hidden" id="hidden" name="hidden" value="delete"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="generic-delete-modal-form-submit">Delete</button>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#generic-delete-modal-form-submit').click(function (e) {
e.preventDefault();
$('#generic-delete-modal-form').submit();
});
})
</script>

View File

@ -49,6 +49,18 @@
<iframe id="predict-modal-ketcher" src="{% static '/js/ketcher2/ketcher.html' %}" width="100%" <iframe id="predict-modal-ketcher" src="{% static '/js/ketcher2/ketcher.html' %}" width="100%"
height="510"></iframe> height="510"></iframe>
</div> </div>
<label for="prediction-setting">Default Prediction Setting</label>
<select id="prediction-setting" name="prediction-setting" class="form-control"
data-width='100%'>
<option disabled>Select a Setting</option>
{% for s in meta.available_settings %}
<option value="{{ s.url }}"{% if s.id == meta.user.default_setting.id %}selected{% endif %}>
{{ s.name }}{% if s.id == meta.user.default_setting.id %} <i>(User default)</i>{% endif %}
</option>
{% endfor %}
</select>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -5,6 +5,7 @@
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/edit_rule_modal.html" %} {% include "modals/objects/edit_rule_modal.html" %}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="rule-detail"> <div class="panel-group" id="rule-detail">

View File

@ -6,7 +6,7 @@
{% include "modals/objects/edit_compound_modal.html" %} {% include "modals/objects/edit_compound_modal.html" %}
{% include "modals/objects/add_structure_modal.html" %} {% include "modals/objects/add_structure_modal.html" %}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/delete_compound_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="compound-detail"> <div class="panel-group" id="compound-detail">

View File

@ -5,6 +5,7 @@
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/edit_compound_structure_modal.html" %} {% include "modals/objects/edit_compound_structure_modal.html" %}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="compound-structure-detail"> <div class="panel-group" id="compound-structure-detail">

View File

@ -4,8 +4,8 @@
{% block action_modals %} {% block action_modals %}
{# {% include "modals/objects/edit_edge_modal.html" %}#} {# {% include "modals/objects/edit_edge_modal.html" %}#}
{# {% include "modals/objects/delete_edge_modal.html" %}#}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="edge-detail"> <div class="panel-group" id="edge-detail">
@ -20,7 +20,7 @@
style="padding-right:1em"></span></a> style="padding-right:1em"></span></a>
<ul id="actionsList" class="dropdown-menu"> <ul id="actionsList" class="dropdown-menu">
{% block actions %} {% block actions %}
{# {% include "actions/objects/edge.html" %}#} {% include "actions/objects/edge.html" %}
{% endblock %} {% endblock %}
</ul> </ul>
</div> </div>

View File

@ -5,7 +5,7 @@
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/edit_group_modal.html" %} {% include "modals/objects/edit_group_modal.html" %}
{% include "modals/objects/edit_group_member_modal.html" %} {% include "modals/objects/edit_group_member_modal.html" %}
{% include "modals/objects/delete_group_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="package-detail"> <div class="panel-group" id="package-detail">

View File

@ -4,7 +4,7 @@
{% block content %} {% block content %}
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/delete_model_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<!-- Include required libs --> <!-- Include required libs -->

View File

@ -5,7 +5,7 @@
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/edit_node_modal.html" %} {% include "modals/objects/edit_node_modal.html" %}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/delete_node_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="node-detail"> <div class="panel-group" id="node-detail">

View File

@ -6,7 +6,7 @@
{% include "modals/objects/edit_package_modal.html" %} {% include "modals/objects/edit_package_modal.html" %}
{% include "modals/objects/edit_package_permissions_modal.html" %} {% include "modals/objects/edit_package_permissions_modal.html" %}
{% include "modals/objects/set_license_modal.html" %} {% include "modals/objects/set_license_modal.html" %}
{% include "modals/objects/delete_package_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="package-detail"> <div class="panel-group" id="package-detail">
@ -52,23 +52,5 @@
</div> </div>
{% if package.license %}
<p></p>
<div class="panel-group" id="license_accordion">
<div class="panel panel-default list-group-item" style="background-color:#f5f5f5">
<div class="panel-title">
<a data-toggle="collapse" data-parent="#licence_accordion" href="#license">License</a>
</div>
</div>
<div id="license" class="panel-collapse collapse in">
<div class="panel-body list-group-item">
<a target="_blank" href="{{ package.license.link }}">
<img src="{{ package.license.image_link }}">
</a>
</div>
</div>
</div>
{% endif %}
</div> </div>
{% endblock content %} {% endblock content %}

View File

@ -86,7 +86,7 @@
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/delete_pathway_node_modal.html" %} {% include "modals/objects/delete_pathway_node_modal.html" %}
{% include "modals/objects/delete_pathway_edge_modal.html" %} {% include "modals/objects/delete_pathway_edge_modal.html" %}
{% include "modals/objects/delete_pathway_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<p></p> <p></p>

View File

@ -5,7 +5,7 @@
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/edit_reaction_modal.html" %} {% include "modals/objects/edit_reaction_modal.html" %}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/delete_reaction_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="reaction-detail"> <div class="panel-group" id="reaction-detail">

View File

@ -3,7 +3,7 @@
{% block content %} {% block content %}
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="scenario-detail"> <div class="panel-group" id="scenario-detail">
<div class="panel panel-default"> <div class="panel panel-default">

View File

@ -5,6 +5,7 @@
{% block action_modals %} {% block action_modals %}
{% include "modals/objects/edit_rule_modal.html" %} {% include "modals/objects/edit_rule_modal.html" %}
{% include "modals/objects/generic_set_scenario_modal.html" %} {% include "modals/objects/generic_set_scenario_modal.html" %}
{% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="rule-detail"> <div class="panel-group" id="rule-detail">

View File

@ -7,7 +7,7 @@
{% include "modals/objects/edit_password_modal.html" %} {% include "modals/objects/edit_password_modal.html" %}
{% include "modals/collections/new_prediction_setting_modal.html" %} {% include "modals/collections/new_prediction_setting_modal.html" %}
{% include "modals/objects/manage_api_token_modal.html" %} {% include "modals/objects/manage_api_token_modal.html" %}
{% include "modals/objects/delete_user_modal.html" %} {% include "modals/objects/generic_delete_modal.html" %}
{% endblock action_modals %} {% endblock action_modals %}
<div class="panel-group" id="user-detail"> <div class="panel-group" id="user-detail">

View File

@ -79,6 +79,10 @@
allEmpty = true; allEmpty = true;
for (key in data) { for (key in data) {
if (key === 'searchterm') {
continue;
}
if (data[key].length < 1) { if (data[key].length < 1) {
continue; continue;
} }
@ -176,8 +180,16 @@
$("#selPackages").selectpicker(); $("#selPackages").selectpicker();
$("#search-button").on("click", search); $("#search-button").on("click", search);
$("#searchbar").on("keydown", function (e) {
if (e.key === "Enter") {
e.preventDefault();
search(e);
}
});
}); });
{% if search_result %} {% if search_result %}
$('#searchbar').val('{{ search_result.searchterm }}')
handleSearchResponse("results", {{ search_result|safe }}); handleSearchResponse("results", {{ search_result|safe }});
{% endif %} {% endif %}
</script> </script>