Basic System (#31)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#31
This commit is contained in:
2025-07-23 06:47:07 +12:00
parent 49e02ed97d
commit df896878f1
75 changed files with 3821 additions and 1429 deletions

View File

@ -16,23 +16,11 @@
<input id="rule-name" class="form-control" name="rule-name" placeholder="Name"/>
<label for="rule-description">Description</label>
<input id="rule-description" class="form-control" name="rule-description" placeholder="Description"/>
<label for="rule-smirks">SMIRKS</label>
<input id="rule-smirks" class="form-control" name="rule-smirks" placeholder="SMIRKS"/>
<p></p>
<!-- TODO Ruletypes -->
<!-- TODO Decide on rules to use?-->
<div id="rule-smirks-viz"></div>
<input type="hidden" name="rule-type" id="rule-type" value="SimpleAmbitRule">
<!-- <select id="rule-type" name="rule-type" class="form-control" data-width='100%'>-->
<!-- <option disabled selected>Select Rule Type</option>-->
<!-- {% for k, v in rule_types.items %}-->
<!-- <option value="{{ v }}">{{ k }}</option>-->
<!-- {% endfor %}-->
<!-- </select>-->
<!-- -->
<div>
<iframe id="new_rule_ketcher" src="{% static '/js/ketcher2/ketcher.html' %}" width="100%"
height="510"></iframe>
</div>
<input type="hidden" name="rule-smirks" id="rule-smirks">
<p></p>
</form>
</div>
@ -47,13 +35,36 @@
</div>
<script>
$(function() {
$('#rule-smirks').on('input', function(e) {
$('#rule-smirks-viz').empty()
smirks = $('#rule-smirks').val()
const img = new Image();
img.src = "{% url 'depict' %}?is_query_smirks=true&smirks=" + encodeURIComponent(smirks);
img.style.width = '100%';
img.style.height = '100%';
img.style.objectFit = 'cover';
img.onload = function () {
$('#rule-smirks-viz').append(img);
};
img.onerror = function () {
error_tpl = `
<div class="alert alert-error" role="alert">
<h4 class="alert-heading">Could not render SMIRKS!</h4>
<p>Could not render SMIRKS - Have you entered a valid SMIRKS?</a>
</p>
</div>`
$('#rule-smirks-viz').append(error_tpl);
};
});
$('#new_rule_modal_form_submit').on('click', function(e) {
e.preventDefault();
$(this).prop("disabled",true);
k = getKetcher('new_rule_ketcher');
$('#rule-smirks').val(k.getSmiles());
// submit form
$('#new_rule_modal_form').submit();
});