diff --git a/.gitignore b/.gitignore index 99a66bb..938b3c0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,5 @@ storage/ images_to_process/ DB_BACKUP/ new_img_dir/ -static/Bin -static/Import -static/Storage -static/upstream +static/ +internal/upstream diff --git a/TODO b/TODO index 175ac65..44e04ba 100644 --- a/TODO +++ b/TODO @@ -26,17 +26,19 @@ fullscreen could maybe use a bit of this: document.getElementById('canvas').requestFullscreen() - buttons: - to (re)do faces (always or somehow turn on for select) + buttons (with tootltips): rot90, rot180, rot270 flip h, flip z fullscreen + to (re)do faces (always or somehow turn on for select???) * could look to remove the hand fixing of json.loads of array data --> seems you can make your own datatype in the ORM, and it can do the conversion every time you use it - https://stackoverflow.com/questions/28143557/sqlalchemy-convert-column-value-back-and-forth-between-internal-and-database-fo * fix up logging in general * comment your code + * js files + * html files? * more OO goodness :) ## DB diff --git a/files.py b/files.py index 6340401..2a78495 100644 --- a/files.py +++ b/files.py @@ -631,6 +631,15 @@ def checkrotatejob(): resp['finished']=True return resp +################################################################################ +# /include -> return contents on /include and does not need a login, so we +# can get the icon, and potentially any js, bootstrap, etc. needed for the login page +################################################################################ +@app.route("/internal/") +def internal(filename): + print( filename ) + return send_from_directory("internal/", filename) + ################################################################################ # /static -> returns the contents of any file referenced inside /static. # we create/use symlinks in static/ to reference the images to show diff --git a/internal/favicon.ico b/internal/favicon.ico new file mode 100644 index 0000000..f8a50a0 Binary files /dev/null and b/internal/favicon.ico differ diff --git a/internal/icons.svg b/internal/icons.svg new file mode 100644 index 0000000..6247277 --- /dev/null +++ b/internal/icons.svg @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 90 + + + + 180 + + + + 270 + + + + + + + + + + + diff --git a/internal/js/files_support.js b/internal/js/files_support.js new file mode 100644 index 0000000..7d09885 --- /dev/null +++ b/internal/js/files_support.js @@ -0,0 +1,187 @@ +function GetSelnAsDiv() +{ + seln='' + $('.highlight').each(function( index ) { + seln+='
' + $(this).children().parent().html() + '
' + seln+='' + } ) + return '
'+seln+'
' +} + +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 ='

' + del_or_undel + ' the following files?

' + div+=GetSelnAsDiv() + div+=`
+ + ` + div+=` + +
+ ` + else + div+=` + '/restore_files', + success: function(data){ window.location='/'; return false; } })" class="btn btn-outline-success col-2">Ok + + ` + $('#dbox-content').html(div) + $('#dbox').modal('show') +} + +function DetailsDBox() +{ + $('#dbox-title').html('Details of Selected File(s)') + var div ='
' + $('.highlight').each(function( index ) { + div += "
Name:
" + $(this).attr('fname') + "
" + div += "
Date:
" + $(this).attr('pretty_date') + "
" + dir = $(this).attr('in_dir') + if( dir.slice(-1) != "/" ) + dir=dir.concat('/') + div += "
Dir:
" + dir + "
" + div += "
Size:
" + $(this).attr('size') + " MB
" + div += "
Hash:
" + $(this).attr('hash') + "
" + div += "
Path Type:
" + $(this).attr('path_type') + "
" + } ) + div += ` +
+
+
+ +
+ ` + $('#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 +} diff --git a/internal/js/transform.js b/internal/js/transform.js new file mode 100644 index 0000000..b96d1ed --- /dev/null +++ b/internal/js/transform.js @@ -0,0 +1,29 @@ +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; } }) + } ) +} diff --git a/internal/throbber.gif b/internal/throbber.gif new file mode 100644 index 0000000..1448c29 Binary files /dev/null and b/internal/throbber.gif differ diff --git a/templates/base.html b/templates/base.html index 918f90a..cd3b649 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,19 +7,19 @@ - + - - + + - - - - + + + + - + {% import "bootstrap/wtf.html" as wtf %}