From 6ccba50734455c617ef34692437c0102aa3a9bb0 Mon Sep 17 00:00:00 2001 From: afinogen Date: Thu, 28 Dec 2017 13:47:40 +0300 Subject: [PATCH 1/2] add check new app version --- _locales/en/messages.json | 12 ++++++++++++ gulpfile.js | 3 ++- js/appUpdater.js | 40 +++++++++++++++++++++++++++++++++++++++ main.css | 8 ++++++++ main.html | 10 ++++++++++ main.js | 3 +++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 js/appUpdater.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a1bbe7de..cc3b0fc8 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2250,5 +2250,17 @@ }, "portColumnSensors": { "message": "Sensors" + }, + "appUpdateNotificationHeader": { + "message": "New version aviable!" + }, + "appUpdateNotificationDescription": { + "message": "Visit the website to see the changes GitHub" + }, + "closeUpdateBtn": { + "message": "Close" + }, + "downloadUpdatesBtn": { + "message": "Download new app" } } diff --git a/gulpfile.js b/gulpfile.js index f6aa17c5..fdbdcfee 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -97,7 +97,8 @@ sources.js = [ './js/serial_queue.js', './js/msp_balanced_interval.js', './tabs/advanced_tuning.js', - './js/peripherals.js' + './js/peripherals.js', + './js/appUpdater.js' ]; sources.mapCss = [ diff --git a/js/appUpdater.js b/js/appUpdater.js new file mode 100644 index 00000000..1aff6f7c --- /dev/null +++ b/js/appUpdater.js @@ -0,0 +1,40 @@ +'use strict'; + +var appUpdater = appUpdater || {}; + +appUpdater.checkRelease = function (currVersion) { + var modalStart; + $.get('https://api.github.com/repos/iNavFlight/inav-configurator/releases', function (releaseData) { + GUI.log('Loaded release information from GitHub.'); + //Git return sorted list, 0 - last release + if (semver.gt(releaseData[0].tag_name, currVersion)) { + GUI.log(releaseData[0].tag_name, chrome.runtime.getManifest().version); + GUI.log(currVersion); + + //For download zip + // releaseData[0].assets.forEach(function(item, i) { + // if (str.indexOf(item.name) !== -1) { + // console.log(item); + // downloadUrl = item.browser_download_url; + // } + // }); + + GUI.log('New version aviable!'); + modalStart = new jBox('Modal', { + width: 400, + height: 200, + animation: false, + closeOnClick: false, + closeOnEsc: true, + content: $('#appUpdateNotification') + }).open(); + } + }); + + $('#update-notification-close').on('click', function () { + modalStart.close(); + }); + $('#update-notification-download').on('click', function () { + modalStart.close(); + }); +}; \ No newline at end of file diff --git a/main.css b/main.css index b62c5b56..6d226eae 100644 --- a/main.css +++ b/main.css @@ -1883,6 +1883,10 @@ select { margin: 1em; } +.modal__buttons--upbottom { + bottom: 22px; +} + .modal__button { padding: 1em; text-align: center; @@ -1918,6 +1922,10 @@ select { transition: all ease 0.2s; } +.modal__button--main--inline { + display: inline; +} + .modal__button--disabled { cursor: default; color: #fff; diff --git a/main.html b/main.html index cc197198..457d9e7e 100755 --- a/main.html +++ b/main.html @@ -8,6 +8,16 @@
+