diff --git a/plugins/Sidebar/SidebarPlugin.py b/plugins/Sidebar/SidebarPlugin.py index 7eb39e74..bc0f22e2 100644 --- a/plugins/Sidebar/SidebarPlugin.py +++ b/plugins/Sidebar/SidebarPlugin.py @@ -477,7 +477,7 @@ class UiWebsocketPlugin(object): from util import helper self.log.info("Downloading GeoLite2 City database...") - self.cmd("notification", ["geolite-info", _["Downloading GeoLite2 City database (one time only, ~20MB)..."], 0]) + self.cmd("progress", ["geolite-info", _["Downloading GeoLite2 City database (one time only, ~20MB)..."], 0]) db_urls = [ "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz", "https://raw.githubusercontent.com/texnikru/GeoLite2-Database/master/GeoLite2-City.mmdb.gz" @@ -486,13 +486,18 @@ class UiWebsocketPlugin(object): try: # Download response = helper.httpRequest(db_url) - + data_size = response.getheader('content-length') + data_recv = 0 data = StringIO.StringIO() while True: buff = response.read(1024 * 512) if not buff: break data.write(buff) + data_recv += 1024 * 512 + if data_size: + progress = int(float(data_recv) / int(data_size) * 100) + self.cmd("progress", ["geolite-info", _["Downloading GeoLite2 City database (one time only, ~20MB)..."], progress]) self.log.info("GeoLite2 City database downloaded (%s bytes), unpacking..." % data.tell()) data.seek(0) @@ -500,16 +505,16 @@ class UiWebsocketPlugin(object): with gzip.GzipFile(fileobj=data) as gzip_file: shutil.copyfileobj(gzip_file, open(db_path, "wb")) - self.cmd("notification", ["geolite-done", _["GeoLite2 City database downloaded!"], 5000]) + self.cmd("progress", ["geolite-info", _["GeoLite2 City database downloaded!"], 100]) time.sleep(2) # Wait for notify animation return True except Exception as err: self.log.error("Error downloading %s: %s" % (db_url, err)) pass - self.cmd("notification", [ - "geolite-error", + self.cmd("progress", [ + "geolite-info", _["GeoLite2 City database download error: {}!
Please download manually and unpack to data dir:
{}"].format(err, db_urls[0]), - 0 + -100 ]) def actionSidebarGetPeers(self, to): diff --git a/src/Ui/media/Notifications.coffee b/src/Ui/media/Notifications.coffee index 9f38921b..c06a95dc 100644 --- a/src/Ui/media/Notifications.coffee +++ b/src/Ui/media/Notifications.coffee @@ -13,7 +13,7 @@ class Notifications add: (id, type, body, timeout=0) -> - id = id.replace /[^A-Za-z0-9]/g, "" + id = id.replace /[^A-Za-z0-9-]/g, "" # Close notifications with same id for elem in $(".notification-#{id}") @close $(elem) diff --git a/src/Ui/media/all.js b/src/Ui/media/all.js index 8a5fa48b..58eff9b6 100644 --- a/src/Ui/media/all.js +++ b/src/Ui/media/all.js @@ -711,7 +711,7 @@ jQuery.extend( jQuery.easing, if (timeout == null) { timeout = 0; } - id = id.replace(/[^A-Za-z0-9]/g, ""); + id = id.replace(/[^A-Za-z0-9-]/g, ""); ref = $(".notification-" + id); for (i = 0, len = ref.length; i < len; i++) { elem = ref[i]; @@ -807,6 +807,7 @@ jQuery.extend( jQuery.easing, }).call(this); + /* ---- src/Ui/media/Wrapper.coffee ---- */ @@ -1562,4 +1563,4 @@ jQuery.extend( jQuery.easing, window.wrapper = new Wrapper(ws_url); -}).call(this); +}).call(this); \ No newline at end of file