complete rewrite of viewer, videos need to be fixed. Otherwise, viewer now loads entry data for all "how_many" images on the screen, and allows prev/next movement between images without a DB load for the current page of images, then as required, it will retrieve the prev/next "how_many" from the database via /viewlist route, and go back into view/<id> of the appropriate new image of the new list. Also prevents going below 0 and beyond end of DB for the first time.
This commit is contained in:
@@ -6,38 +6,38 @@
|
||||
|
||||
<div class="container-fluid">
|
||||
<form id="main_form" method="POST">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{cwd}}">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{OPT['cwd']}}">
|
||||
{% if search_term is defined %}
|
||||
<input type="hidden" name="term" id="view_term" value="{{search_term}}">
|
||||
<input type="hidden" name="search_term" id="view_term" value="{{search_term}}">
|
||||
{% endif %}
|
||||
<div class="d-flex row mb-2">
|
||||
{% if folders %}
|
||||
{% if OPT['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", "" ) + "/" %}
|
||||
{% set tmp_path=OPT['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", "" ) + "/" %}
|
||||
{% set tmp_path=OPT['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", "" ) + "/" %}
|
||||
{% set tmp_path=OPT['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 }}
|
||||
{{CreateSelect( "noo", OPT['noo'], ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-2")|safe }}
|
||||
{{CreateSelect( "how_many", OPT['how_many'], ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }}
|
||||
{% if OPT['folders'] %}
|
||||
<input type="hidden" name="grouping" id="grouping" value="{{OPT['grouping']}}">
|
||||
{{CreateFoldersSelect( OPT['folders'], "rounded-end" )|safe }}
|
||||
{% else %}
|
||||
{{CreateFoldersSelect( folders )|safe }}
|
||||
{{CreateFoldersSelect( OPT['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 }}
|
||||
{{CreateSelect( "grouping", OPT['grouping'], ["None", "Day", "Week", "Month"], "", "rounded-end")|safe }}
|
||||
{% endif %}
|
||||
</div class="input-group">
|
||||
</div class="col">
|
||||
@@ -50,9 +50,9 @@
|
||||
<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>
|
||||
<span class="sm-txt my-auto"> {{OPT['how_many']}} files </span>
|
||||
{% set nxt_disabled="" %}
|
||||
{% if entry_data|length < how_many|int %}
|
||||
{% if entry_data|length < OPT['how_many']|int %}
|
||||
{% set nxt_disabled="disabled" %}
|
||||
{% endif %}
|
||||
<button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
|
||||
@@ -72,31 +72,31 @@
|
||||
</div>
|
||||
<div class="d-flex col col-auto justify-content-end">
|
||||
<div class="btn-group">
|
||||
{% if size == "64" %}
|
||||
{% if OPT['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" %}
|
||||
{% if OPT['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" %}
|
||||
{% if OPT['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" %}
|
||||
{% if OPT['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" %}
|
||||
{% if OPT['size'] == "256" %}
|
||||
{% set bt="btn-info text-white" %}
|
||||
{% else %}
|
||||
{% set bt="btn-outline-info" %}
|
||||
@@ -104,8 +104,8 @@
|
||||
<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}}">
|
||||
<input id="offset" type="hidden" name="offset" value="{{OPT['offset']}}">
|
||||
<input id="size" type="hidden" name="size" value="{{OPT['size']}}">
|
||||
</div class="form-row">
|
||||
{% set eids=namespace( str="" ) %}
|
||||
{# gather all the file eids and collect them in case we go gallery mode #}
|
||||
@@ -120,59 +120,59 @@
|
||||
<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>
|
||||
{% if OPT['folders'] and entry_data|length == 0 %}
|
||||
{% if OPT['cwd'] != OPT['root'] %}
|
||||
<figure id="_back" class="dir entry m-1" ecnt="1" dir="{{OPT['cwd']|ParentPath}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['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>
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['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">
|
||||
{% if loop.index==1 and OPT['folders'] %}
|
||||
{% if OPT['cwd'] != OPT['root'] %}
|
||||
<figure class="col col-auto g-0 dir entry m-1" ecnt="{{loop.index}}" dir="{{OPT['cwd']|ParentPath}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['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>
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['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" %}
|
||||
{% if not OPT['folders'] and obj.type.name == "Directory" %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
{% if grouping == "Day" %}
|
||||
{% if OPT['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" %}
|
||||
{% elif OPT['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" %}
|
||||
{% elif OPT['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)) %}
|
||||
{% if (not OPT['folders']) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(OPT['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>
|
||||
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{OPT['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>
|
||||
@@ -184,7 +184,7 @@
|
||||
</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>
|
||||
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" style="display:block" height="{{OPT['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>
|
||||
@@ -198,16 +198,16 @@
|
||||
</figure>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if folders %}
|
||||
{% if OPT['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) %}
|
||||
{% if dirname| TopLevelFolderOf(OPT['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">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['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">
|
||||
@@ -220,13 +220,13 @@
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<form id="nav_form" method="POST"">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{cwd}}">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{OPT['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>
|
||||
<span class="sm-txt my-auto"> {{OPT['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>
|
||||
@@ -242,13 +242,32 @@
|
||||
$('.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(); }
|
||||
);
|
||||
function CallViewRouteWrapper()
|
||||
{
|
||||
CallViewRoute( $(this).attr("id") )
|
||||
}
|
||||
|
||||
function CallViewRoute(id)
|
||||
{
|
||||
s='<form id="_fm" method="POST" action="/view/' + id + '">'
|
||||
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
|
||||
s+='<input type="hidden" name="noo" value="{{OPT['noo']}}">'
|
||||
s+='<input type="hidden" name="cwd" value="{{OPT['cwd']}}">'
|
||||
s+='<input type="hidden" name="root" value="{{OPT['root']}}">'
|
||||
s+='<input type="hidden" name="size" value="{{OPT['size']}}">'
|
||||
s+='<input type="hidden" name="grouping" value="{{OPT['grouping']}}">'
|
||||
s+='<input type="hidden" name="offset" value="{{OPT['offset']}}">'
|
||||
s+='<input type="hidden" name="folders" value="{{OPT['folders']}}">'
|
||||
s+='<input type="hidden" name="how_many" value="{{OPT['how_many']}}">'
|
||||
s+='<input type="hidden" name="orig_url" value="{{request.path}}">'
|
||||
{% if search_term is defined %}
|
||||
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
|
||||
{% endif %}
|
||||
s+='</form>'
|
||||
$(s).appendTo('body').submit();
|
||||
}
|
||||
|
||||
$('.figure').dblclick( CallViewRouteWrapper )
|
||||
|
||||
// different context menu on files
|
||||
$.contextMenu({
|
||||
@@ -307,11 +326,7 @@ $.contextMenu({
|
||||
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 == "view" ) { CallViewRoute( $(this).attr('id') ) }
|
||||
if( key == "move" ) { MoveDBox() }
|
||||
if( key == "del" ) { DelDBox('Delete') }
|
||||
if( key == "undel") { DelDBox('Restore') }
|
||||
@@ -329,7 +344,7 @@ $.contextMenu({
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
if( {{offset}} == 0 )
|
||||
if( {{OPT['offset']}} == 0 )
|
||||
{
|
||||
$('.prev').addClass('disabled')
|
||||
$('.prev').prop('disabled', true)
|
||||
|
||||
Reference in New Issue
Block a user