diff --git a/sqli/services/db.py b/sqli/services/db.py index 127eb52b..27534545 100644 --- a/sqli/services/db.py +++ b/sqli/services/db.py @@ -3,9 +3,7 @@ def setup_database(app: Application): - # create connection to the database app.on_startup.append(_init_pg) - # shutdown db connection on exit app.on_cleanup.append(_close_pg) @@ -13,7 +11,7 @@ async def _init_pg(app: Application): conf = app['config']['db'] dsn = ( - 'dbname={database} user={user} password={password} host={host} port={port}' + 'dbname={database} user={user} password= host={host} port={port}' .format(**conf) ) db = await aiopg.create_pool(dsn) diff --git a/sqli/services/redis.py b/sqli/services/redis.py index d0e4384b..2cebf636 100644 --- a/sqli/services/redis.py +++ b/sqli/services/redis.py @@ -9,8 +9,7 @@ def setup_redis(app: Application): async def _init_redis(app: Application): conf = app['config']['redis'] - redis = await aioredis.create_pool((conf['host'], conf['port']), - db=conf['db']) + redis = await aioredis.create_pool((conf['host'], conf['port']), db=conf['db']) app['redis'] = redis diff --git a/sqli/static/js/materialize.js b/sqli/static/js/materialize.js index bbd91bea..50ffa579 100644 --- a/sqli/static/js/materialize.js +++ b/sqli/static/js/materialize.js @@ -5914,11 +5914,11 @@ if (jQuery) { } }; - var closeFABMenu = function (btn) { - var $this = btn; + const closeFABMenu = function (btn) { + const $this = $(btn); // Get direction option - var horizontal = $this.hasClass('horizontal'); - var offsetY, offsetX; + const horizontal = $this.hasClass('horizontal'); + let offsetY, offsetX; if (horizontal === true) { offsetX = 40; @@ -5926,6 +5926,23 @@ if (jQuery) { offsetY = 40; } + try { + if (horizontal === true) { + $this.find('ul .btn-floating').velocity( + { translateY: 0, translateX: offsetX }, + { duration: 0 } + ); + } else { + $this.find('ul .btn-floating').velocity( + { translateY: offsetY, translateX: 0 }, + { duration: 0 } + ); + } + } catch (error) { + console.error('Error in closeFABMenu:', error); + } + } + $this.removeClass('active'); var time = 0; $this.find('ul .btn-floating').velocity("stop", true); @@ -5988,7 +6005,8 @@ if (jQuery) { transition: 'transform .2s' }); - setTimeout(function () { + const ANIMATION_DELAY = 100; + const animateMenu = () => { btn.css({ overflow: 'hidden', 'background-color': fabColor @@ -5998,6 +6016,10 @@ if (jQuery) { transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' }); menu.find('> li > a').css({ + }; + + // Use requestAnimationFrame for better performance and to avoid potential race conditions + requestAnimationFrame(animateMenu); opacity: 1 });