diff --git a/TODO b/TODO
index 1ca2bbd..c05f3f2 100644
--- a/TODO
+++ b/TODO
@@ -1,20 +1,15 @@
###
# get override data into view
-# should start with an empty DB and test - definitely no dirs in storage_sp gives:
-# dir_id=dir_arr[0]
-# IndexError: list index out of range
-# TEST this, code in files will work, but now passes root_eid=0 for
-# this - so need GUI to work - may even be good to put an alert up - its so odd to hvae not root dir ONLY happens when no data
-# empty directories are sometimes showing "No matches for: 'undefined'" <- should only comes up for search in URL???
+# should start with an empty DB and test
+# definitely no dirs in storage_sp I now pass root_eid=0 for this
+# BUT - need GUI to work - may even be good to put an alert up - its so odd to have not root dir ONLY happens when no data
+# empty directories (2017/20171015-test/...) showing "No matches for: 'undefined'" <- should only comes up for search in URL???
# think I killed pa_job_manager without passing an eid to a transform job, shouldn't crash
# SHOULD JUST get AI to help clean-up and write defensive code here...
# also all the add ref img/add override, etc are non-functional - FIX the override* stuff first to get table/naming consistency as that is half the problem
-# delete button also uses current? (eid is empty anyway)
-# move as much jscript into *_support, as possible (if there are no more {{ - # then move it)
# convert move_paths to a json setup
# ALSO revisit this move_paths to be as safe as possible ultimately, triple-check there are no leading / or .. 's
-# TEST everything (don't forget keybindings)
-# transforms -> should consider removing the pull logic to see if a job is finished (have job-mgr push data back? while more rest, not sure b/e EVER sends data to F/E at moment)
+# TEST everything (don't forget keybindings,e.g. delete)
###
### major fix - go to everywhere I call GetEntries(), and redo the logic totally...
diff --git a/internal/js/files_support.js b/internal/js/files_support.js
index f12bb4a..e40a4c1 100644
--- a/internal/js/files_support.js
+++ b/internal/js/files_support.js
@@ -4,6 +4,21 @@ ICON["Import"]="import"
ICON["Storage"]="db"
ICON["Bin"]="trash"
+// function called when we get another page from inside the files view
+function getPageFigures(res, viewingIdx)
+{
+ // add all the figures to files_div
+ drawPageOfFigures()
+}
+
+// function called when we get another page from inside the viewer
+function getPageViewer(res, viewingIdx)
+{
+ document.viewing=document.entries[viewingIdx]
+ // update viewing, arrows and image/video too
+ ViewImageOrVideo()
+}
+
// grab all selected thumbnails and return a
containing the thumbnails
// with extra yr and date attached as attributes so we can set the default
// dir name for a move directory - not used in del, but no harm to include them
@@ -520,10 +535,10 @@ function drawPageOfFigures()
addFigure( obj, last, ecnt )
ecnt++
}
- if( document.entries.length == 0 && OPT.search_term != '' )
+ if( document.entries.length == 0 && OPT.search_term )
$('#figures').append( ` No matches for: '${OPT.search_term}'` )
$('.figure').click( function(e) { DoSel(e, this ); SetButtonState(); return false; });
- $('.figure').dblclick( function(e) { dblClickToViewEntry( $(this).attr('id') ) } )
+ $('.figure').dblclick( function(e) { dblClickToViewEntry( $(this).attr('id') ); setDisabledForViewingNextPrevBttons(); addViewerKeyHandler() } )
// for dir, getDirEntries 2nd param is back (or "up" a dir)
$(".dir").click( function(e) { document.back_id=this.id; getDirEntries(this.id,false) } )
$(".back").click( function(e) { getDirEntries(this.id,true) } )
@@ -553,21 +568,6 @@ function getPageFileList(res, viewingIdx)
$('#file_list_div').append(html)
}
-// function called when we get another page from inside the files view
-function getPageFigures(res, viewingIdx)
-{
- // add all the figures to files_div
- drawPageOfFigures()
-}
-
-// function called when we get another page from inside the viewer
-function getPageViewer(res, viewingIdx)
-{
- document.viewing=document.entries[viewingIdx]
- // update viewing, arrows and image/video too
- ViewImageOrVideo()
-}
-
// Function to get the 'page' of entry ids out of entryList
function getPage(pageNumber, successCallback, viewingIdx=0)
{
@@ -587,9 +587,15 @@ function getPage(pageNumber, successCallback, viewingIdx=0)
type: 'POST', url: '/get_entries_by_ids',
data: JSON.stringify(data), contentType: 'application/json',
dataType: 'json',
- success: function(res) { document.entries=res; successCallback(res,viewingIdx); },
+ success: function(res) {
+ document.entries=res;
+ successCallback(res,viewingIdx);
+ resetNextPrevButtons()
+ // if search, disable folders
+ if( OPT.search_term )
+ $('#folders').prop('disabled', 'disabled').removeClass('border-info').addClass('border-secondary').removeClass('text-info').addClass('text-secondary');
+ },
error: function(xhr, status, error) { console.error("Error:", error); } });
- resetNextPrevButtons()
return
}
@@ -620,6 +626,13 @@ function getPageNumberForId(id) {
// if we are on last page, disable next, it not ensure prev is enabled
function resetNextPrevButtons()
{
+ // no data, so disabled both
+ if( getPageNumberForId(pageList[0]) == -1 )
+ {
+ $('.prev').prop('disabled', true).addClass('disabled');
+ $('.next').prop('disabled', true).addClass('disabled');
+ return
+ }
if ( isFirstPage( getPageNumberForId(pageList[0]) ) )
$('.prev').prop('disabled', true).addClass('disabled');
else
@@ -661,12 +674,14 @@ function prevPage(successCallback)
return
}
+// function to see if we are on a phone or tablet (where we dont have ctrl or shift keys - helps to display fake buttons to allow multiselect on mobiles)
function isMobile() {
try{ document.createEvent("TouchEvent"); return true; }
catch(e){ return false; }
}
-
+// when we change one of the options (noo, how_many, folders) - then update '{how_many} files' str,
+// tweak noo menu for folders/flat view then reset the page contents based on current OPT values
function changeOPT(successCallback) {
OPT.how_many=$('#how_many').val()
new_f=$('#folders').val()
@@ -707,3 +722,119 @@ function changeOPT(successCallback) {
}
})
}
+
+// function to change the size of thumbnails when user clicks xs/s/m/l/xl buttons
+function changeSize()
+{
+ sz=$('input[name="size"]:checked').val();
+ $('.thumb').prop('height',sz);
+}
+
+
+function getPreviousEntry() {
+ var currentIndex = entryList.indexOf(document.viewing.id);
+
+ oldPageOffset=Math.floor(currentIndex / OPT.how_many)
+ if (currentIndex > 0) {
+ currentIndex--;
+ pageOffset=Math.floor(currentIndex / OPT.how_many)
+ currentIndex=currentIndex-(pageOffset*OPT.how_many)
+ // pref page, load it
+ if( oldPageOffset != pageOffset )
+ // pref page is pageOffset+1 now
+ getPage(pageOffset+1,getPageViewer,currentIndex)
+ else
+ document.viewing=document.entries[currentIndex]
+ }
+}
+
+function getNextEntry() {
+ var currentIndex = entryList.indexOf(document.viewing.id);
+
+ oldPageOffset=Math.floor(currentIndex / OPT.how_many)
+ if (currentIndex < entryList.length - 1) {
+ currentIndex++
+ pageOffset=Math.floor(currentIndex / OPT.how_many)
+ currentIndex=currentIndex-(pageOffset*OPT.how_many)
+ // next page, load it
+ if( oldPageOffset != pageOffset )
+ // next page is pageOffset+1 now
+ getPage(pageOffset+1,getPageViewer,currentIndex)
+ else
+ document.viewing=document.entries[currentIndex]
+ }
+}
+
+function entryIsAtStart() {
+ return document.viewing.id === entryList[0];
+}
+
+function entryIsAtEnd() {
+ return document.viewing.id === entryList[entryList.length - 1];
+}
+
+function setEntryById(id) {
+ var currentIndex = entryList.indexOf(parseInt(id));
+ // if we are on a different page, adjust as document.entries only has <= how_many
+ pageOffset=Math.floor(currentIndex / OPT.how_many)
+ currentIndex = currentIndex-(pageOffset*OPT.how_many)
+ document.viewing=document.entries[currentIndex]
+}
+
+function setDisabledForViewingNextPrevBttons()
+{
+ $('#la').attr('disabled', entryIsAtStart());
+ $('#ra').attr('disabled', entryIsAtEnd());
+}
+
+function addViewerKeyHandler() {
+ // allow a keypress on the viewer_div
+ $(document).keydown(function(event) {
+ // if dbox is visible, dont process this hot-key, we are inputting text
+ // into inputs instead
+ if( $("#dbox").is(':visible') )
+ return
+ switch (event.key)
+ {
+ case "Left": // IE/Edge specific value
+ case "ArrowLeft":
+ if( $('#la').prop('disabled') == false )
+ $('#la').click()
+ break;
+ case "Right": // IE/Edge specific value
+ case "ArrowRight":
+ if( $('#ra').prop('disabled') == false )
+ $('#ra').click()
+ break;
+ case "d":
+ $('#distance').click()
+ break;
+ case "f":
+ $('#faces').click()
+ break;
+ case "n":
+ $('#fname_toggle').click()
+ break;
+ case "F":
+ fullscreen=!document.fullscreen
+ ViewImageOrVideo()
+ break;
+ case "l":
+ JoblogSearch()
+ break;
+ case "Delete":
+ $('#del').click()
+ default:
+ return; // Quit when this doesn't handle the key event.
+ }
+ });
+}
+
+$(document).on('click', function(e) { $('.highlight').removeClass('highlight') ; SetButtonState() });
+
+function dblClickToViewEntry(id) {
+ $('#files_div').addClass('d-none')
+ $('#viewer_div').removeClass('d-none')
+ setEntryById( id )
+ ViewImageOrVideo()
+}
diff --git a/templates/files.html b/templates/files.html
index e77a5bf..38d1369 100644
--- a/templates/files.html
+++ b/templates/files.html
@@ -1,49 +1,24 @@
{% extends "base.html" %}
{% block main_content %}
+
-
-
@@ -80,10 +55,6 @@
Searched for: '{{search_term}}'
-
{% endif %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {# this whole div, just takes up the same space as the left button and is hidden for alignment only #}
+
+
+
+ Show:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AI Model:
+ {# can use 0 as default, it will be (re)set correctly in DrawImg() anyway #}
+ {{CreateSelect( "model", 0, ["N/A", "normal", "slow/accurate"], "", "rounded norm-txt", [0,1,2])|safe }}
+
- {# use this for color of toggles: https://www.codeply.com/p/4sL9uhevwJ #}
-
- {# this whole div, just takes up the same space as the left button and is hidden for alignment only #}
-
-
-
- Show:
-
-
-
-
-
-
-
-
-
-
-
-
-
- AI Model:
- {# can use 0 as default, it will be (re)set correctly in DrawImg() anyway #}
- {{CreateSelect( "model", 0, ["N/A", "normal", "slow/accurate"], "", "rounded norm-txt", [0,1,2])|safe }}
-