171 lines
9.3 KiB
HTML
171 lines
9.3 KiB
HTML
{% extends "base.html" %} {% block main_content %}
|
|
<div class="container-fluid">
|
|
|
|
<h3 class="offset-lg-2">{{page_title}}</h3>
|
|
<form id="psform" class="d-flex justify-content-center form-inline" method="POST" action="">
|
|
<input type="hidden" name="fe_msg_id" value="{{fe_msg_id}}"></input>
|
|
<h5>
|
|
<div class="form-group">
|
|
<label for="pagesize">{{DD.overall_dup_sets}} sets/dirs of files
|
|
containing {{DD.overall_dup_cnt}} files -- Showing </label>
|
|
<select id="pagesize" class="form form-control" name="pagesize" onChange="ResetPageSize()">
|
|
{% for o in "5", "10", "15", "20", "25", "50", "75", "100", "200" %}
|
|
<option
|
|
{% if o|int == pagesize %}
|
|
selected
|
|
{% endif %}
|
|
>{{o}}</option>
|
|
{% endfor %}
|
|
</select>
|
|
duplicates at a time
|
|
<button class="button btn-info" onMouseOver="$('#dbox').modal('show'); return false;"><i class="fas fa-info-circle"></i></button>
|
|
</div>
|
|
</h5>
|
|
</form>
|
|
<script>
|
|
let D=[]
|
|
let F=[]
|
|
|
|
function ResetPageSize()
|
|
{
|
|
console.log( $("#pagesize").val() )
|
|
$("#psform").submit()
|
|
return false;
|
|
}
|
|
|
|
$('#dbox-title').html('Duplicate Files Processing (info)')
|
|
div=`
|
|
<p>The duplicates are shown below ({{pagesize}} at a time) in a per set of files or sets of directories</p>
|
|
<p>The per file sets are shown with the title 'Choose between these fiels' and show a series of duplicate files in a row, that comprise one of:</p>
|
|
<ul>
|
|
<li>3 or more of the same file</li>
|
|
<li>different file names in the same or different directories</li>
|
|
</ul>
|
|
<p>The per direcory sets are shown with the title 'Choose path to KEEP...' and show a series of directories in a row, that contain duplicate files. In this view duplicates have the same file name and any other files in these directories that are not duplicates will not be deleted</p>
|
|
<p>TO BE CLEAR: after you click the "Delete Duplicates" button, the files in red and duplicate files in directories in red will be deleted from the file system</p>
|
|
`
|
|
$('#dbox-content').html(div)
|
|
|
|
function KeepFile(row, which, al)
|
|
{
|
|
$('[id^=kf' + row + '-f]').attr('class', 'alert alert-danger sm-txt py-1')
|
|
$('[id^=kf' + row + '-f]').attr('class', 'alert alert-danger sm-txt py-1')
|
|
$('#kf'+row+'-f'+which).attr('class', 'alert alert-' + al + ' py-1')
|
|
$('#kfname-'+row).val( F[row.toString()+which.toString()] )
|
|
}
|
|
function KeepDir(row, which)
|
|
{
|
|
$('[id^=kd'+row+'-d]').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()] )
|
|
}
|
|
</script>
|
|
<div class="row">
|
|
<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) %}
|
|
{% set pref=namespace(have="") %}
|
|
{% set count=namespace( del=0, keep=0 ) %}
|
|
{% for dups in DD.ip_to_sp_dups_keep %}
|
|
{% set count.keep = count.keep+1 %}
|
|
need to do some hidden inputs here to keep these files<br>
|
|
{% 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 %}
|
|
{% endif %}
|
|
<h5>Choose between these files:</h5>
|
|
{% for dups in DD.per_file_dups %}
|
|
{% set outer_loop=loop.index %}
|
|
{% set pref.have="" %}
|
|
{% for dup in dups %}
|
|
{% 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 %}
|
|
{% if page.cnt <= pagesize %}
|
|
{% if loop.index == 1 %}
|
|
<div class="col-lg-12 py-2">
|
|
{% endif %}
|
|
<alert id="kf{{outer_loop}}-f{{loop.index}}" style="cursor: pointer;" class="alert"
|
|
onClick="KeepFile({{outer_loop}},{{loop.index}},'success')">{{dup.d}}/{{dup.f}}</alert>
|
|
{% if DD.preferred_file[dup.h] == dup.id %}
|
|
{% set pref.have="kf{}-f{}".format(outer_loop,loop.index) %}
|
|
{% endif %}
|
|
{% if loop.index < dups|length %}
|
|
or
|
|
{% else %}
|
|
<input type="hidden" name="kfhash-{{outer_loop}}" value="{{dup.h}}">
|
|
<input type="hidden" id="kfname-{{outer_loop}}" name="kfname-{{outer_loop}}" value="">
|
|
{% endif %}
|
|
<script>
|
|
F[{{outer_loop}}{{loop.index}}]="{{dup.id}}"
|
|
</script>
|
|
{% if loop.index == dups|length %}
|
|
</div class="col-lg-12">
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if pref.have == "" %}
|
|
<script>KeepFile( {{outer_loop}}, 1,'warning' )</script>
|
|
{% set page.cnt = page.cnt + 1 %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
<div class="col-lg-12">
|
|
Matched preference regexp: Keep={{count.keep}}, Deleting={{count.del}}
|
|
</div>
|
|
|
|
{% 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 %}
|
|
<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}}"
|
|
{% 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>
|
|
{% set page.cnt = page.cnt + 1 %}
|
|
{% if page.cnt == pagesize %}
|
|
{% break %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
<input class="btn btn-danger mt-2" type="submit" value="Delete Duplicates">
|
|
</form>
|
|
</div class="row">
|
|
</div class="container">
|
|
{% endblock main_content %}
|
|
{% block script_content %}
|
|
<script>
|
|
// force choose last of each dir set
|
|
$('[id$=d2]').each( function() { $(this).click() } )
|
|
</script>
|
|
{% endblock script_content %}
|