From 0016c846f27929944453d3e5bb86f2129e823750 Mon Sep 17 00:00:00 2001 From: HappyZ Date: Wed, 24 May 2023 21:27:12 -0700 Subject: [PATCH] [FE] allows to get up to 20 histories results --- BUILD | 2 + frontend.py | 16 +++-- static/imagesloaded.pkgd.min.js | 7 ++ static/masonry.pkgd.min.js | 9 +++ templates/index.html | 114 +++++++++++++++++++++++++------- utilities/database.py | 1 + 6 files changed, 119 insertions(+), 30 deletions(-) create mode 100644 static/imagesloaded.pkgd.min.js create mode 100644 static/masonry.pkgd.min.js diff --git a/BUILD b/BUILD index d46061b..4814cad 100644 --- a/BUILD +++ b/BUILD @@ -19,6 +19,8 @@ par_binary( "static/jquery.sketchable.min.js", "static/jsketch.min.js", "static/jquery.sketchable.memento.min.js", + "static/masonry.pkgd.min.js", + "static/imagesloaded.pkgd.min.js", ], ) diff --git a/frontend.py b/frontend.py index b87e99c..3215a14 100644 --- a/frontend.py +++ b/frontend.py @@ -81,10 +81,10 @@ def cancel_job(): logger.info("cancelling job with uuid {}..".format(req[UUID])) - result = database.cancel_job(job_uuid=req[UUID]) + result = database.cancel_job(job_uuid=req[UUID], apikey=req[APIKEY]) if result: - msg = "job with uuid {} removed".format(req[UUID]) + msg = "your job with uuid {} removed".format(req[UUID]) return jsonify({"msg": msg}) jobs = database.get_jobs(job_uuid=req[UUID]) @@ -93,7 +93,7 @@ def cancel_job(): return ( jsonify( { - "msg": "job {} is not in pending state, unable to cancel".format( + "msg": "your job {} is not in pending state, unable to cancel".format( req[UUID] ) } @@ -102,7 +102,7 @@ def cancel_job(): ) return ( - jsonify({"msg": "unable to find the job with uuid {}".format(req[UUID])}), + jsonify({"msg": "unable to find your job with uuid {}".format(req[UUID])}), 404, ) @@ -115,8 +115,14 @@ def get_jobs(): user = database.validate_user(req[APIKEY]) if not user: return "", 401 + + # define max number of jobs to fetch from db + job_count_limit = 20 - jobs = database.get_jobs(job_uuid=req[UUID]) + if UUID in req: + jobs = database.get_jobs(job_uuid=req[UUID], apikey=req[APIKEY], limit_count=job_count_limit) + else: + jobs = database.get_jobs(apikey=req[APIKEY], limit_count=job_count_limit) return jsonify({"jobs": jobs}) diff --git a/static/imagesloaded.pkgd.min.js b/static/imagesloaded.pkgd.min.js new file mode 100644 index 0000000..e443a77 --- /dev/null +++ b/static/imagesloaded.pkgd.min.js @@ -0,0 +1,7 @@ +/*! + * imagesLoaded PACKAGED v4.1.4 + * JavaScript is all like "You images are done yet or what?" + * MIT License + */ + +!function(e,t){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",t):"object"==typeof module&&module.exports?module.exports=t():e.EvEmitter=t()}("undefined"!=typeof window?window:this,function(){function e(){}var t=e.prototype;return t.on=function(e,t){if(e&&t){var i=this._events=this._events||{},n=i[e]=i[e]||[];return n.indexOf(t)==-1&&n.push(t),this}},t.once=function(e,t){if(e&&t){this.on(e,t);var i=this._onceEvents=this._onceEvents||{},n=i[e]=i[e]||{};return n[t]=!0,this}},t.off=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){var n=i.indexOf(t);return n!=-1&&i.splice(n,1),this}},t.emitEvent=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){i=i.slice(0),t=t||[];for(var n=this._onceEvents&&this._onceEvents[e],o=0;oe;e++){var i=h[e];t[i]=0}return t}function n(t){var e=getComputedStyle(t);return e||a("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See https://bit.ly/getsizebug1"),e}function o(){if(!d){d=!0;var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(e);var o=n(e);s=200==Math.round(t(o.width)),r.isBoxSizeOuter=s,i.removeChild(e)}}function r(e){if(o(),"string"==typeof e&&(e=document.querySelector(e)),e&&"object"==typeof e&&e.nodeType){var r=n(e);if("none"==r.display)return i();var a={};a.width=e.offsetWidth,a.height=e.offsetHeight;for(var d=a.isBorderBox="border-box"==r.boxSizing,l=0;u>l;l++){var c=h[l],f=r[c],m=parseFloat(f);a[c]=isNaN(m)?0:m}var p=a.paddingLeft+a.paddingRight,g=a.paddingTop+a.paddingBottom,y=a.marginLeft+a.marginRight,v=a.marginTop+a.marginBottom,_=a.borderLeftWidth+a.borderRightWidth,z=a.borderTopWidth+a.borderBottomWidth,E=d&&s,b=t(r.width);b!==!1&&(a.width=b+(E?0:p+_));var x=t(r.height);return x!==!1&&(a.height=x+(E?0:g+z)),a.innerWidth=a.width-(p+_),a.innerHeight=a.height-(g+z),a.outerWidth=a.width+y,a.outerHeight=a.height+v,a}}var s,a="undefined"==typeof console?e:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],u=h.length,d=!1;return r}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("desandro-matches-selector/matches-selector",e):"object"==typeof module&&module.exports?module.exports=e():t.matchesSelector=e()}(window,function(){"use strict";var t=function(){var t=window.Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],i=0;is?"round":"floor";r=Math[a](r),this.cols=Math.max(r,1)},n.getContainerWidth=function(){var t=this._getOption("fitWidth"),i=t?this.element.parentNode:this.element,n=e(i);this.containerWidth=n&&n.innerWidth},n._getItemLayoutPosition=function(t){t.getSize();var e=t.size.outerWidth%this.columnWidth,i=e&&1>e?"round":"ceil",n=Math[i](t.size.outerWidth/this.columnWidth);n=Math.min(n,this.cols);for(var o=this.options.horizontalOrder?"_getHorizontalColPosition":"_getTopColPosition",r=this[o](n,t),s={x:this.columnWidth*r.col,y:r.y},a=r.y+t.size.outerHeight,h=n+r.col,u=r.col;h>u;u++)this.colYs[u]=a;return s},n._getTopColPosition=function(t){var e=this._getTopColGroup(t),i=Math.min.apply(Math,e);return{col:e.indexOf(i),y:i}},n._getTopColGroup=function(t){if(2>t)return this.colYs;for(var e=[],i=this.cols+1-t,n=0;i>n;n++)e[n]=this._getColGroupY(n,t);return e},n._getColGroupY=function(t,e){if(2>e)return this.colYs[t];var i=this.colYs.slice(t,t+e);return Math.max.apply(Math,i)},n._getHorizontalColPosition=function(t,e){var i=this.horizontalColIndex%this.cols,n=t>1&&i+t>this.cols;i=n?0:i;var o=e.size.outerWidth&&e.size.outerHeight;return this.horizontalColIndex=o?i+t:this.horizontalColIndex,{col:i,y:this._getColGroupY(i,t)}},n._manageStamp=function(t){var i=e(t),n=this._getElementOffset(t),o=this._getOption("originLeft"),r=o?n.left:n.right,s=r+i.outerWidth,a=Math.floor(r/this.columnWidth);a=Math.max(0,a);var h=Math.floor(s/this.columnWidth);h-=s%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var u=this._getOption("originTop"),d=(u?n.top:n.bottom)+i.outerHeight,l=a;h>=l;l++)this.colYs[l]=Math.max(d,this.colYs[l])},n._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var t={height:this.maxY};return this._getOption("fitWidth")&&(t.width=this._getContainerFitWidth()),t},n._getContainerFitWidth=function(){for(var t=0,e=this.cols;--e&&0===this.colYs[e];)t++;return(this.cols-t)*this.columnWidth-this.gutter},n.needsResizeLayout=function(){var t=this.containerWidth;return this.getContainerWidth(),t!=this.containerWidth},i}); \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index e0cf8cf..33f3647 100644 --- a/templates/index.html +++ b/templates/index.html @@ -342,18 +342,20 @@ -
-
- - -
- -
- -
+
+
History
+
+
+ + + +
+
+
+
@@ -361,6 +363,8 @@ + +