first pass of paginated dups, with drop-down (non-functional), but otherwise pages work - presume if I clicked it to delete, it would, but then I would need to re-do check_dups OR optimise and get it to come back to dups with next page -- probably preferred -- BUT, need to keep job state between page loads?

This commit is contained in:
2021-03-03 22:05:58 +11:00
parent e19e1b57f8
commit 1dc8477758

View File

@@ -2,12 +2,29 @@
<div class="container-fluid">
<h3 class="offset-lg-2">{{page_title}}</h3>
<div class="alert alert-info">Duplicate files have been detected. They have the same binary content,
but either have a different name or are stored in two different
but either have a different name, there are 3 or more copies or are stored in two different
directories. Choose between the options below. NOTE: after you click
'Delete Duplicates', the files / directories in red will be deleted from the file
system, those in green will remain</div>
<h5>{{overall_dup_sets}} sets/dirs of files containing {{overall_dup_cnt}} files</h5>
system, those in green will remain
</div>
<form class="d-flex justify-content-center form-inline">
<h5>
<div class="form-group">
<label for="page_size">{{overall_dup_sets}} sets/dirs of files
containing {{overall_dup_cnt}} files -- Showing&nbsp;</label>
<select class="form form-control" name="page_size">
{% for o in "5", "10", "20", "50" %}
<option
{% if o|int == page_size %}
selected
{% endif %}
>{{o}}</option>
{% endfor %}
</select>
&nbsp;duplicates at a time
</div>
</h5>
</form>
<script>
let D=[]
let F=[]
@@ -16,10 +33,11 @@
<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 page=namespace(cnt=0) %}
<h5>Choose between these files:</h5>
{% for dups in per_file_dups %}
{% set outer_loop=loop.index %}
<div class="col-lg-12 py-4">
<h5>Choose between these files:</h5>
<div class="col-lg-12 py-2">
{% for dup in dups %}
<alert id="kf{{outer_loop}}-f{{loop.index}}" style="cursor: pointer;" class="alert"
onClick="KeepFile({{outer_loop}},{{loop.index}})">{{dup.d}}/{{dup.f}}</alert>
@@ -34,23 +52,33 @@
</script>
{% endfor %}
</div class="col-lg-12">
{% set page.cnt = page.cnt + 1 %}
{% if page.cnt == page_size %}
{% break %}
{% endif %}
{% endfor %}
{% for dup in per_path_dups %}
<div class="col-lg-12 py-4">
<h5>{{dup.count}} duplicate files (same file names in 2 different directories). Choose path to KEEP:</h5>
<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 name="kdhash-{{loop.index}}" type="hidden" value="{{dup.hashes}}">
<script>
D[{{loop.index}}1]="{{dup.did1}}"
D[{{loop.index}}2]="{{dup.did2}}"
</script>
</div>
{% endfor %}
<input class="btn btn-danger" type="submit" value="Delete Duplicates">
{% if page.cnt < page_size %}
<h5 class="mt-3">Choose path to KEEP (same file names in 2 different directories):</h5>
{% for dup in per_path_dups %}
<div class="col-lg-12 py-2">
{{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 name="kdhash-{{loop.index}}" type="hidden" value="{{dup.hashes}}">
<script>
D[{{loop.index}}1]="{{dup.did1}}"
D[{{loop.index}}2]="{{dup.did2}}"
</script>
</div>
{% set page.cnt = page.cnt + 1 %}
{% if page.cnt == page_size %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
<input class="btn btn-danger mt-2" type="submit" value="Delete Duplicates">
</form>
</div class="row">
</div class="container">
@@ -59,15 +87,15 @@
<script>
function KeepFile(row, which)
{
$('[id^=kf' + row + ']').attr('class', 'alert alert-danger sm-txt')
$('#kf'+row+'-f'+which).attr('class', 'alert alert-success')
$('[id^=kf' + row + ']').attr('class', 'alert alert-danger sm-txt py-1')
$('#kf'+row+'-f'+which).attr('class', 'alert alert-success py-1')
$('#kfname-'+row).val( F[row.toString()+which.toString()] )
}
function KeepDir(row, which)
{
$('[id^=kd'+row+']').attr('class', 'alert alert-danger sm-txt')
$('#kd'+row+'-d'+which).attr('class', 'alert alert-success')
$('[id^=kd'+row+']').attr('class', 'alert alert-danger sm-txt py-1')
$('#kd'+row+'-d'+which).attr('class', 'alert alert-success py-1')
$('#kdid-'+row).val( D[row.toString()+which.toString()] )
}