better formatting for all automatic matches, deal with automatic matching of preferred_paths, put <input type=hidden> fields in for files in storage and import paths, only display headings/content if it actually exists

This commit is contained in:
2021-03-21 17:00:36 +11:00
parent 7e14280ec5
commit 055dd58d34

View File

@@ -64,39 +64,36 @@
<form class="form form-inline col-lg-12" action="{{url_for('rm_dups')}}" method="POST">
{# pass this through so that the back-end can delete this message when it rm_dups #}
<input type="hidden" name="fe_msg_id" value={{fe_msg_id}}>
{% set auto=namespace(str="") %}
{% set page=namespace(cnt=0) %}
{% set pref=namespace(have="") %}
{% set count=namespace( del=0, keep=0 ) %}
{% for dups in DD.ip_to_sp_dups_keep %}
{# for each hash in ip_to_sp_dups_*, auto keep the _keep, auto delete the _del, only need hidden input #}
{% for h in DD.ip_to_sp_dups_keep %}
<input type="hidden" name="kfhash-{{outer_loop}}" value="{{h}}">
{% set count.keep = count.keep+1 %}
need to do some hidden inputs here to keep these files<br>
{% set count.del = count.del + DD.ip_to_sp_dups_del[h]|length %}
{% endfor %}
{% for dups in DD.ip_to_sp_dups_del %}
{% set count.del = count.del+1 %}
maybe need to do some hidden inputs here to del these files? (not sure it was needed in del code to triple-check)<br>
{% endfor %}
{% if count.keep or count.del %}
<div class="col-lg-12">
Keeping {{count.keep}} files in storage path and deleting {{count.del}} from import path
</div>
{% set count.keep=0 %}
{% set count.del=0 %}
{% if count.keep %}
{% set auto.str = auto.str + "<li>Keeping {} files in storage path and deleting {} from import path</li>".format(count.keep, count.del) %}
{% endif %}
<h5>Choose between these files:</h5>
<h5 class="col-lg-12">Choose between these files:</h5>
{% set count=namespace( del=0, keep=0 ) %}
{% for dups in DD.per_file_dups %}
{% set outer_loop=loop.index %}
{% set pref.have="" %}
{% for dup in dups %}
{# for each hash in preferred_file, auto keep it, only need hidden input, dont process further #}
{% if DD.preferred_file[dup.h] %}
{% set pref.have = "True" %}
{% if DD.preferred_file[dup.h] == dup.id %}
<input type="hidden" name="kfhash-{{outer_loop}}" value="{{dup.h}}">
<input type="hidden" id="kfname-{{outer_loop}}" name="kfname-{{outer_loop}}" value="">
{% set count.keep = count.keep + 1 %}
{% else %}
{% set count.del = count.del + (dups|length-1) %}
{% endif %}
{% else %}
{# okay, show an alert / make it choosable for each of these manually processed dups #}
{% if page.cnt <= pagesize %}
{% if loop.index == 1 %}
<div class="col-lg-12 py-2">
@@ -127,36 +124,55 @@
{% endif %}
{% endfor %}
<div class="col-lg-12">
Matched preference regexp: Keep={{count.keep}}, Deleting={{count.del}}
</div>
{% if count.keep %}
{% set auto.str = auto.str + "<li>Duplicates in storage path matching naming convention: Keep={}, Delete={}</li>".format(count.keep, count.del) %}
{% endif %}
{% set count=namespace( del=0, keep=0 ) %}
{% if page.cnt < pagesize %}
<h5 class="mt-3">Choose path to KEEP (same file names in 2 different directories):</h5>
{% for dup in DD.per_path_dups %}
{% if DD.preferred_path[dup.did1] or DD.preferred_path[dup.did2] %}
<input id="kdid-{{loop.index}}" type="hidden" name="kdid-1">
<input name="kdhash-{{loop.index}}" type="hidden" value="{{dup.hashes}}">
{% if DD.preferred_path[dup.did1] %}
<input type="hidden" name="kdid-{{loop.index}}" value="DD.preferred_path[dup.did1]">
{% else %}
<input type="hidden" name="kdid-{{loop.index}}" value="DD.preferred_path[dup.did2]">
{% endif %}
{% set count.keep = count.keep + 1 %}
{% else %}
<div class="col-lg-12 py-2">
<h5 class="col-lg-12 mt-3">Choose path to KEEP (same file names in 2 different directories):</h5>
{{dup.count}} duplicates in:
<alert id="kd{{loop.index}}-d1" style="cursor: pointer;" onClick="KeepDir({{loop.index}}, 1)" class="alert">{{dup.d1}}</alert> or
<alert id="kd{{loop.index}}-d2" style="cursor: pointer;" onClick="KeepDir({{loop.index}}, 2)" class="alert">{{dup.d2}}</alert>
<input id="kdid-{{loop.index}}" type="hidden" name="kdid-1">
<input id="kdid-{{loop.index}}" type="hidden" name="kdid-{{loop.index}}">
<input name="kdhash-{{loop.index}}" type="hidden" value="{{dup.hashes}}">
<script>
D[{{loop.index}}1]="{{dup.did1}}"
D[{{loop.index}}2]="{{dup.did2}}"
{% if DD.preferred_path[dup.h] == dup.id1 %}
KeepDir( {{loop.inex}}, 1 )
{% endif %}
{% if DD.preferred_path[dup.h] == dup.id2 %}
KeepDir( {{loop.inex}}, 2 )
{% endif %}
</script>
</div>
{% endif %}
{% set page.cnt = page.cnt + 1 %}
{% if page.cnt == pagesize %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% if count.keep %}
<div class="col-lg-12">
{% set auto.str = auto.str + "<li>Keeping={}, Deleting={} paths of duplicates</li>".format(count.keep, count.keep) %}
</div>
{% endif %}
{% if auto.str|length %}
<alert class="alert alert-info">AUTOMATICALLY matched naming conventions resulting in:
<ul>
{{auto.str|safe}}
</ul>
</alert>
{% endif %}
<div class="col-lg-12"></div>
<input class="btn btn-danger mt-2" type="submit" value="Delete Duplicates">
</form>
</div class="row">