606 lines
29 KiB
HTML
606 lines
29 KiB
HTML
{% extends "base.html" %}
|
|
{% block main_content %}
|
|
|
|
<div class="container-fluid">
|
|
<form id="main_form" method="POST">
|
|
<input type="hidden" name="cwd" id="cwd" value="{{cwd}}">
|
|
{% if search_term is defined %}
|
|
<input type="hidden" name="term" id="view_term" value="{{search_term}}">
|
|
{% endif %}
|
|
<div class="d-flex row mb-2">
|
|
{% if folders %}
|
|
<div class="my-auto col col-auto">
|
|
<span class="alert alert-primary py-2">
|
|
{% if "files_ip" in request.url %}
|
|
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#import"/></svg>
|
|
{% set tmp_path=cwd | replace( "static/Import", "" ) + "/" %}
|
|
{% elif "files_sp" in request.url %}
|
|
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#db"/></svg>
|
|
{% set tmp_path=cwd | replace( "static/Storage", "" ) + "/" %}
|
|
{% elif "files_rbp" in request.url %}
|
|
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#trash"/></svg>
|
|
{% set tmp_path=cwd | replace( "static/Bin", "" ) + "/" %}
|
|
{% endif %}
|
|
{{tmp_path}}</span>
|
|
</div class="col my-auto">
|
|
{% endif %}
|
|
<div class="col col-auto">
|
|
<div class="input-group">
|
|
{{CreateSelect( "noo", noo, ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-2")|safe }}
|
|
{{CreateSelect( "how_many", how_many, ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }}
|
|
{% if folders %}
|
|
<input type="hidden" name="grouping" id="grouping" value="{{grouping}}">
|
|
{{CreateFoldersSelect( folders, "rounded-end" )|safe }}
|
|
{% else %}
|
|
{{CreateFoldersSelect( folders )|safe }}
|
|
<span class="sm-txt my-auto btn btn-outline-info disabled border-top border-bottom">grouped by:</span>
|
|
{{CreateSelect( "grouping", grouping, ["None", "Day", "Week", "Month"], "", "rounded-end")|safe }}
|
|
{% endif %}
|
|
</div class="input-group">
|
|
</div class="col">
|
|
{% if search_term is defined %}
|
|
<div class="col col-auto my-auto">
|
|
<span class="alert alert-primary p-2">Searched for: '{{search_term}}'</span>
|
|
</div class="col my-auto">
|
|
{% endif %}
|
|
<div class="col flex-grow-1 my-auto d-flex justify-content-center w-100">
|
|
<button id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
|
|
</button>
|
|
<span class="sm-txt my-auto"> {{how_many}} files </span>
|
|
{% set nxt_disabled="" %}
|
|
{% if entry_data|length < how_many|int %}
|
|
{% set nxt_disabled="disabled" %}
|
|
{% endif %}
|
|
<button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
|
|
</button>
|
|
<button id="move" disabled name="move" class="sm-txt btn btn-outline-primary ms-4" onClick="MoveDBox(); return false;">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_plus"/></svg>
|
|
</button>
|
|
{% if "files_rbp" in request.url %}
|
|
<button id="del" disabled name="del" class="sm-txt btn btn-outline-success mx-1" onClick="DelDBox('Restore'); return false;">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#trash"/></svg>
|
|
{% else %}
|
|
<button id="del" disabled name="del" class="sm-txt btn btn-outline-danger mx-1" onClick="DelDBox('Delete'); return false;">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#trash"/></svg>
|
|
{% endif %}
|
|
</button>
|
|
</div>
|
|
<div class="d-flex col col-auto justify-content-end">
|
|
<div class="btn-group">
|
|
{% if size == "64" %}
|
|
{% set bt="btn-info text-white" %}
|
|
{% else %}
|
|
{% set bt="btn-outline-info" %}
|
|
{% endif %}
|
|
<button id="64" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,64); return false;">XS</button>
|
|
{% if size == "96" %}
|
|
{% set bt="btn-info text-white" %}
|
|
{% else %}
|
|
{% set bt="btn-outline-info" %}
|
|
{% endif %}
|
|
<button id="96" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,96); return false;">S</button>
|
|
{% if size == "128" %}
|
|
{% set bt="btn-info text-white" %}
|
|
{% else %}
|
|
{% set bt="btn-outline-info" %}
|
|
{% endif %}
|
|
<button id="128" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,128); return false;">M</button>
|
|
{% if size == "192" %}
|
|
{% set bt="btn-info text-white" %}
|
|
{% else %}
|
|
{% set bt="btn-outline-info" %}
|
|
{% endif %}
|
|
<button id="192" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,192); return false;">L</button>
|
|
{% if size == "256" %}
|
|
{% set bt="btn-info text-white" %}
|
|
{% else %}
|
|
{% set bt="btn-outline-info" %}
|
|
{% endif %}
|
|
<button id="256" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,256); return false;">XL</button>
|
|
</div class="btn-group">
|
|
</div class="col">
|
|
<input id="offset" type="hidden" name="offset" value="{{offset}}">
|
|
<input id="size" type="hidden" name="size" value="{{size}}">
|
|
</div class="form-row">
|
|
{% set eids=namespace( str="" ) %}
|
|
{# gather all the file eids and collect them in case we go gallery mode #}
|
|
{% for obj in entry_data %}
|
|
{% if obj.type.name != "Directory" %}
|
|
{% set eids.str = eids.str + obj.id|string +"," %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
<input name="eids" id="eids" type="hidden" value="{{eids.str}}">
|
|
</form>
|
|
</div>
|
|
<div class="row ms-2">
|
|
{% set last = namespace(printed=0) %}
|
|
{# rare event of empty folder, still need to show back button #}
|
|
{% if folders and entry_data|length == 0 %}
|
|
{% if cwd != root %}
|
|
<figure id="_back" class="dir entry m-1" ecnt="1" dir="{{cwd|ParentPath}}" type="Directory">
|
|
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
|
|
<figcaption class="figure-caption text-center">Back</figcaption>
|
|
</figure class="figure">
|
|
<script>f=$('#_back'); w=f.find('svg').width(); f.find('figcaption').width(w);</script>
|
|
{% else %}
|
|
<div class="col col-auto g-0 m-1">
|
|
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% for obj in entry_data %}
|
|
{% if loop.index==1 and folders %}
|
|
{% if cwd != root %}
|
|
<figure class="col col-auto g-0 dir entry m-1" ecnt="{{loop.index}}" dir="{{cwd|ParentPath}}" type="Directory">
|
|
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}" fill="currentColor">
|
|
<use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
|
|
<figcaption class="svg_cap figure-caption text-center">Back</figcaption>
|
|
</figure class="figure">
|
|
{% else %}
|
|
{# create an even lighter-grey, unclickable back button - so folders dont jump around when you go into them #}
|
|
<div class="col col-auto g-0 m-1">
|
|
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if not folders and obj.type.name == "Directory" %}
|
|
{% continue %}
|
|
{% endif %}
|
|
{% if grouping == "Day" %}
|
|
{% if last.printed != obj.file_details.day %}
|
|
<div class="row ps-3"><h6>Day: {{obj.file_details.day}} of {{obj.file_details.month}}/{{obj.file_details.year}}</h6></div>
|
|
{% set last.printed = obj.file_details.day %}
|
|
{% endif %}
|
|
{% elif grouping == "Week" %}
|
|
{% if last.printed != obj.file_details.woy %}
|
|
<div class="row ps-3"><h6>Week #: {{obj.file_details.woy}} of {{obj.file_details.year}}</h6></div>
|
|
{% set last.printed = obj.file_details.woy %}
|
|
{% endif %}
|
|
{% elif grouping == "Month" %}
|
|
{% if last.printed != obj.file_details.month %}
|
|
<div class="row ps-3"><h6>Month: {{obj.file_details.month}} of {{obj.file_details.year}}</h6></div>
|
|
{% set last.printed = obj.file_details.month %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if obj.type.name != "Directory" %}
|
|
{% if (not folders) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(cwd)) %}
|
|
<figure id="{{obj.id}}" ecnt="{{loop.index}}" class="col col-auto g-0 figure entry m-1" path_type="{{obj.in_dir.in_path.type.name}}" size="{{obj.file_details.size_mb}}" hash="{{obj.file_details.hash}}" in_dir="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}" fname="{{obj.name}}" yr="{{obj.file_details.year}}" date="{{obj.file_details.year}}{{"%02d" % obj.file_details.month}}{{"%02d" % obj.file_details.day}}" pretty_date="{{obj.file_details.day}}/{{obj.file_details.month}}/{{obj.file_details.year}}" type="{{obj.type.name}}">
|
|
{% if obj.type.name=="Image" %}
|
|
<div style="position:relative; width:100%">
|
|
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
|
|
{% if search_term is defined %}
|
|
<div style="position:absolute; bottom: 0px; left: 2px;">
|
|
<svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#{{LocationIcon(obj)}}"/></svg>
|
|
</div>
|
|
{% endif %}
|
|
<div id="s{{obj.id}}" style="display:none; position:absolute; top: 50%; left:50%; transform:translate(-50%, -50%);">
|
|
<img height="64px" src="{{url_for('internal', filename='throbber.gif')}}"></img>
|
|
</div>
|
|
</div>
|
|
{% elif obj.type.name == "Video" %}
|
|
<div style="position:relative; width:100%">
|
|
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" style="display:block" height="{{size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
|
|
<div style="position:absolute; top: 0px; left: 2px;">
|
|
<svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#film"/></svg>
|
|
</div>
|
|
{% if search_term is defined %}
|
|
<div style="position:absolute; bottom: 0px; left: 2px;">
|
|
<svg width="16" height="16" fill="white"><use xlink:href="#{{url_for('internal', filename='icons.svg')}}#{{LocationIcon(obj)}}"/></svg>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</figure>
|
|
{% endif %}
|
|
{% else %}
|
|
{% if folders %}
|
|
{% if obj.dir_details.rel_path | length %}
|
|
{% set dirname=obj.dir_details.in_path.path_prefix+'/'+obj.dir_details.rel_path %}
|
|
{% else %}
|
|
{% set dirname=obj.dir_details.in_path.path_prefix %}
|
|
{% endif %}
|
|
{# if this dir is the toplevel of the cwd, show the folder icon #}
|
|
{% if dirname| TopLevelFolderOf(cwd) %}
|
|
<figure class="col col-auto g-0 figure dir entry m-1" id={{obj.id}} ecnt={{loop.index}} dir="{{dirname}}" type="Directory">
|
|
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}" fill="currentColor">
|
|
<use xlink:href="{{url_for('internal', filename='icons.svg')}}#Directory"/></svg>
|
|
<figcaption class="svg_cap figure-caption text-center text-wrap text-break">{{obj.name}}</figcaption>
|
|
</figure class="figure">
|
|
<script>f=$('#{{obj.id}}'); w=f.find('svg').width(); f.find('figcaption').width(w);</script>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
</div>
|
|
<div class="container-fluid">
|
|
<form id="nav_form" method="POST"">
|
|
<input type="hidden" name="cwd" id="cwd" value="{{cwd}}">
|
|
<div class="row">
|
|
<div class="col my-auto d-flex justify-content-center">
|
|
<button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); })" id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
|
|
</button>
|
|
<span class="sm-txt my-auto"> {{how_many}} files </span>
|
|
<button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); });" id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
|
|
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div class="container">
|
|
{% endblock main_content %}
|
|
{% block script_content %}
|
|
<script>
|
|
|
|
function GetSelnAsDiv()
|
|
{
|
|
seln=''
|
|
$('.highlight').each(function( index ) {
|
|
seln+='<div fname="' + $(this).attr('fname') + '" yr="' + $(this).attr('yr') +
|
|
'" date="' + $(this).attr('date') +
|
|
'" class="px-1">' + $(this).children().parent().html() + '</div>'
|
|
seln+='<input type="hidden" name="eid-'+index+'" value="'+$(this).attr('id')+'">'
|
|
} )
|
|
return '<div class="row col-12">'+seln+'</div>'
|
|
}
|
|
|
|
function GetSelnAsData()
|
|
{
|
|
to_del=''
|
|
$('.highlight').each(function( index ) { to_del+='&eid-'+index+'='+$(this).attr('id') } )
|
|
return to_del
|
|
}
|
|
|
|
function RunAIOnSeln(person)
|
|
{
|
|
post_data = GetSelnAsData()
|
|
post_data += '&person='+person.replace('ai-','')
|
|
$.ajax({ type: 'POST', data: post_data, url: '/run_ai_on', success: function(data){ window.location='/'; return false; } })
|
|
}
|
|
|
|
function DelDBox(del_or_undel)
|
|
{
|
|
to_del = GetSelnAsData()
|
|
$('#dbox-title').html(del_or_undel+' Selected File(s)')
|
|
div ='<div class="row col-12"><p class="col">' + del_or_undel + ' the following files?</p></div>'
|
|
div+=GetSelnAsDiv()
|
|
div+=`<div class="row col-12">
|
|
<button onClick="$('#dbox').modal('hide')" class="btn btn-outline-secondary col-2">Cancel</button>
|
|
`
|
|
div+=`
|
|
<button onClick="$('#dbox').modal('hide'); $.ajax({ type: 'POST', data: to_del, url:
|
|
`
|
|
if( del_or_undel == "Delete" )
|
|
div+=`
|
|
'/delete_files',
|
|
success: function(data){ window.location='/'; return false; } })" class="btn btn-outline-danger col-2">Ok</button>
|
|
</div>
|
|
`
|
|
else
|
|
div+=`
|
|
'/restore_files',
|
|
success: function(data){ window.location='/'; return false; } })" class="btn btn-outline-success col-2">Ok</button>
|
|
</div>
|
|
`
|
|
$('#dbox-content').html(div)
|
|
$('#dbox').modal('show')
|
|
}
|
|
|
|
function DetailsDBox()
|
|
{
|
|
$('#dbox-title').html('Details of Selected File(s)')
|
|
var div ='<div class="row col-12">'
|
|
$('.highlight').each(function( index ) {
|
|
div += "<div class='col-3' style='background-color:lightgray'>Name:</div><div class='col-9' style='background-color:lightgray'>" + $(this).attr('fname') + "</div>"
|
|
div += "<div class='col-3'>Date:</div><div class='col-9'>" + $(this).attr('pretty_date') + "</div>"
|
|
dir = $(this).attr('in_dir')
|
|
if( dir.slice(-1) != "/" )
|
|
dir=dir.concat('/')
|
|
div += "<div class='col-3'>Dir:</div><div class='col-9'>" + dir + "</div>"
|
|
div += "<div class='col-3'>Size:</div><div class='col-9'>" + $(this).attr('size') + " MB</div>"
|
|
div += "<div class='col-3'>Hash:</div><div class='col-9'>" + $(this).attr('hash') + "</div>"
|
|
div += "<div class='col-3'>Path Type:</div><div class='col-9'>" + $(this).attr('path_type') + "</div>"
|
|
} )
|
|
div += `
|
|
</div>
|
|
<br>
|
|
<div class="form-row col-12">
|
|
<button onClick="$('#dbox').modal('hide'); return false;" class="btn btn-outline-secondary offset-1 col-2">Cancel</button>
|
|
</div>
|
|
`
|
|
$('#dbox-content').html(div)
|
|
$('#dbox').modal('show')
|
|
}
|
|
|
|
|
|
var attempt=0;
|
|
|
|
function CheckRotateJob(id,job_id)
|
|
{
|
|
$.ajax(
|
|
{
|
|
type: 'POST', data: '&job_id='+job_id, url: '/checkrotatejob', success: function(data) {
|
|
if( data.finished )
|
|
{
|
|
$('#s'+id).hide()
|
|
$('#'+id).find('img.thumb').attr('style', 'filter: color(100%);' );
|
|
$('#'+id).addClass('entry')
|
|
$('#'+id).find('.thumb').attr('src', 'data:image/jpeg;base64,'+data.thumbnail)
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
setTimeout( function() { CheckRotateJob(id,job_id) }, 1000,id, job_id );
|
|
}
|
|
},
|
|
} )
|
|
}
|
|
|
|
function Rotate(amt)
|
|
{
|
|
$('.highlight').each(function( id, e ) {
|
|
post_data = '&amt='+amt+'&id='+e.id
|
|
{# send rotate for this image, grayscale the thumbmail, add color spinning wheel overlay, and start checking for job end #}
|
|
$.ajax({ type: 'POST', data: post_data, url: '/rotate', success: function(data){ $('#'+e.id).find('img.thumb').attr('style', 'filter: grayscale(100%);' ); $('#'+e.id).removeClass('entry'); $('#s'+e.id).show(); CheckRotateJob(e.id,data.job_id); return false; } })
|
|
} )
|
|
}
|
|
|
|
function MoveDBox()
|
|
{
|
|
$('#dbox-title').html('Move Selected File(s) to new directory in Storage Path')
|
|
div =`
|
|
<div class="form-row col-12">
|
|
<p class="col">Moving the following files?</p>
|
|
</div>
|
|
<form id="mv_fm" class="form form-control-inline col-12" method="POST" action="/move_files">
|
|
`
|
|
div+=GetSelnAsDiv()
|
|
yr=$('.highlight').first().attr('yr')
|
|
dt=$('.highlight').first().attr('date')
|
|
div+=`
|
|
<div class="input-group my-3">
|
|
<alert class="alert alert-primary my-auto py-1">
|
|
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#db"/></svg>
|
|
`
|
|
sps={{StoragePathNames()|safe}}
|
|
if( sps.length > 1 ) {
|
|
{# NB: alert-primary here is a hack to get the bg the same color as the alert primary by #}
|
|
div+= '<select name="storage_rp" class="text-primary alert-primary py-1 border border-primary rounded">'
|
|
for(p of sps) {
|
|
div+= '<option>'+p+'</option>'
|
|
}
|
|
div+= '</select>'
|
|
} else {
|
|
div+= '/'+sps[0]+'/'
|
|
div+= '<input type="hidden" name="storage_rp" value="' + sps[0] + '">'
|
|
}
|
|
div+=`
|
|
</alert>
|
|
<input id="prefix" type="text" name="prefix" class="text-primary text-right form-control"
|
|
`
|
|
div+="value="+yr+'/'+dt+"-"
|
|
div+=`
|
|
"></input>
|
|
<input type="text" name="suffix" class="form-control" placeholder="name"> </input>
|
|
</div>
|
|
<br>
|
|
<div class="form-row col-12">
|
|
<button onClick="$('#dbox').modal('hide'); return false;" class="btn btn-outline-secondary offset-1 col-2">Cancel</button>
|
|
<button onClick="$('#dbox').modal('hide'); $('#mv_fm').submit(); return false;" class="btn btn-outline-primary col-2">Ok</button>
|
|
</div>
|
|
</form>
|
|
`
|
|
$('#dbox-content').html(div)
|
|
$('#dbox').modal('show')
|
|
}
|
|
|
|
function ChangeSize(clicked_button,sz)
|
|
{
|
|
$('.sz-but.btn-info').removeClass('btn-info text-white').addClass('btn-outline-info')
|
|
$(clicked_button).addClass('btn-info text-white').removeClass('btn-outline-info')
|
|
$('.thumb').attr( {height: sz, style: 'font-size:'+sz+'px' } )
|
|
$('#size').val(sz)
|
|
sz=sz-22
|
|
$('.svg').height(sz);
|
|
$('.svg').width(sz);
|
|
$('.svg_cap').width(sz);
|
|
}
|
|
|
|
// e == event (can see if shift/ctrl held down while left-clicking
|
|
// el == element the click is on
|
|
// this allows single-click to select, ctrl-click to (de)select 1 item, and
|
|
// shift-click to add all elements between highlighted area and clicked area,
|
|
// whether you click after highlight or before
|
|
function DoSel(e, el)
|
|
{
|
|
if( e.ctrlKey )
|
|
{
|
|
$(el).toggleClass('highlight')
|
|
return
|
|
}
|
|
if( e.shiftKey )
|
|
{
|
|
st=Number($('.highlight').first().attr('ecnt'))
|
|
end=Number($('.highlight').last().attr('ecnt'))
|
|
clicked=Number($(el).attr('ecnt'))
|
|
if( ! $('#folders').value )
|
|
{
|
|
st -= 1
|
|
end -= 1
|
|
clicked -= 1
|
|
}
|
|
// if we shift-click first element, then st/end are NaN, so just highlightthe one clicked
|
|
if( isNaN(st) )
|
|
{
|
|
$('.entry').slice( clicked, clicked+1 ).addClass('highlight')
|
|
return
|
|
}
|
|
if( clicked > end )
|
|
$('.entry').slice( end, clicked+1 ).addClass('highlight')
|
|
else
|
|
$('.entry').slice( clicked, st ).addClass('highlight')
|
|
return
|
|
}
|
|
$('.highlight').removeClass('highlight')
|
|
$(el).addClass('highlight')
|
|
}
|
|
|
|
function SetButtonState() {
|
|
var sel=false
|
|
$('.highlight').each(function( index ) { sel=true } )
|
|
if( sel ) {
|
|
$('#move').attr('disabled', false )
|
|
$('#del').attr('disabled', false )
|
|
} else {
|
|
$('#move').attr('disabled', true )
|
|
$('#del').attr('disabled', true )
|
|
}
|
|
}
|
|
|
|
function FiguresOrDirsOrBoth() {
|
|
var figure=false
|
|
var dir=false
|
|
$('.highlight').each(function( index ) {
|
|
if( $(this).hasClass('figure') ) {
|
|
figure=true
|
|
}
|
|
if( $(this).hasClass('dir') ) {
|
|
dir=true
|
|
}
|
|
} )
|
|
if( figure & ! dir )
|
|
return "figure"
|
|
if( ! figure & dir )
|
|
return "dir"
|
|
return "both"
|
|
}
|
|
|
|
function SelContainsBinAndNotBin() {
|
|
var bin=false
|
|
var not_bin=false
|
|
$('.highlight').each(function( index ) {
|
|
if( $(this).attr('path_type') == "Bin" ) {
|
|
bin=true
|
|
} else {
|
|
not_bin=true
|
|
}
|
|
} )
|
|
if( bin && not_bin )
|
|
return true
|
|
else
|
|
return false
|
|
}
|
|
|
|
function NoSel() {
|
|
var sel=false
|
|
$('.highlight').each(function( index ) { sel=true } )
|
|
// func looks for No Selection, so if sel is true and we have a sel, return false (i.e. NOT No Sel -> Sel )
|
|
if( sel )
|
|
return false
|
|
else
|
|
return true
|
|
}
|
|
|
|
$('.figure').click( function(e) { DoSel(e, this ); SetButtonState(); return false; });
|
|
$(document).on('click', function(e) { $('.highlight').removeClass('highlight') ; SetButtonState() });
|
|
|
|
$('.figure').dblclick(
|
|
function() {
|
|
s='<form id="_fm" method="POST" action="/view/' + $(this).attr("id");
|
|
s+='"><input type="hidden" name="eids" value="'+$("#eids").val() + '"></form>'
|
|
$(s).appendTo('body').submit(); }
|
|
);
|
|
|
|
|
|
// different context menu on files
|
|
$.contextMenu({
|
|
selector: '.entry',
|
|
build: function($triggerElement, e){
|
|
// when right-clicking & no selection add one OR deal with ctrl/shift right-lick as it always changes seln
|
|
if( NoSel() || e.ctrlKey || e.shiftKey )
|
|
DoSel(e, e.currentTarget )
|
|
|
|
if( FiguresOrDirsOrBoth() == "figure" )
|
|
{
|
|
item_list = {
|
|
details: { name: "Details..." },
|
|
view: { name: "View File" },
|
|
sep: "---",
|
|
}
|
|
if( e.currentTarget.getAttribute('type') == 'Image' )
|
|
{
|
|
item_list['rotate'] = {
|
|
name: "Rotate",
|
|
items: {
|
|
"r90": { "name" : "90 degrees" },
|
|
"r180": { "name" : "180 degrees" },
|
|
"r270": { "name" : "270 degrees" },
|
|
"fliph": { "name" : "flip horizontally" },
|
|
"flipv": { "name" : "flip vertically" }
|
|
}
|
|
}
|
|
|
|
}
|
|
item_list['move'] = { name: "Move selected file(s) to new storage folder" }
|
|
item_list['sep2'] = { sep: "---" }
|
|
}
|
|
else
|
|
item_list = {}
|
|
|
|
item_list['ai'] = {
|
|
name: "Scan file for faces",
|
|
items: {
|
|
{% for p in people %}
|
|
"ai-{{p.tag}}": {"name": "{{p.tag}}"},
|
|
{% endfor %}
|
|
"ai-all": {"name": "all"},
|
|
}
|
|
}
|
|
|
|
if( SelContainsBinAndNotBin() ) {
|
|
item_list['both']= { name: 'Cannot delete and restore at same time', disabled: true }
|
|
} else {
|
|
if (e.currentTarget.getAttribute('path_type') == 'Bin' )
|
|
item_list['undel']= { name: "Restore selected file(s)" }
|
|
else if( e.currentTarget.getAttribute('type') != 'Directory' )
|
|
item_list['del']= { name: "Delete Selected file(s)" }
|
|
}
|
|
|
|
return {
|
|
callback: function( key, options) {
|
|
if( key == "details" ) { DetailsDBox() }
|
|
if( key == "view" ) {
|
|
s='<form id="_fm" method="POST" action="/view/' + $(this).attr("id");
|
|
s+='"><input type="hidden" name="eids" value="'+$("#eids").val() + '"></form>'
|
|
$(s).appendTo('body').submit();
|
|
}
|
|
if( key == "move" ) { MoveDBox() }
|
|
if( key == "del" ) { DelDBox('Delete') }
|
|
if( key == "undel") { DelDBox('Restore') }
|
|
if( key == "r90" ) { Rotate(90) }
|
|
if( key == "r180" ) { Rotate(180) }
|
|
if( key == "r270" ) { Rotate(270) }
|
|
if( key == "fliph" ) { Rotate("fliph") }
|
|
if( key == "flipv" ) { Rotate("flipv") }
|
|
if( key.startsWith("ai")) { RunAIOnSeln(key) }
|
|
},
|
|
items: item_list
|
|
};
|
|
}
|
|
});
|
|
|
|
|
|
$(document).ready(function() {
|
|
if( {{offset}} == 0 )
|
|
{
|
|
$('.prev').addClass('disabled')
|
|
$('.prev').prop('disabled', true)
|
|
}
|
|
$(".dir").click( function(e) { $('#offset').val(0) ; $('#cwd').val( $(this).attr('dir') ) ; $('#main_form').submit() } )
|
|
} )
|
|
</script>
|
|
{% endblock script_content %}
|