diff --git a/web/app/assets/javascripts/JamServer.js b/web/app/assets/javascripts/JamServer.js index f13b0abfc..500d942f0 100644 --- a/web/app/assets/javascripts/JamServer.js +++ b/web/app/assets/javascripts/JamServer.js @@ -394,6 +394,21 @@ payload.client_update.size ); } + + if(context.JK.ClientUpdateInstance) { + context.JK.ClientUpdateInstance.isUpdateAvailable().then(function(isUpdateAvailable) { + if (!isUpdateAvailable) { + // Check if the user has not set up their gear yet + context.JK.hasOneConfiguredDevice().then(function(hasOneConfiguredDevice){ + if (!hasOneConfiguredDevice) { + // Show the gear setup reminder dialog + context.JK.GearSetupReminderInstance.show(); + } + }); + } + }); + } + }, 0); } diff --git a/web/app/assets/javascripts/clientUpdate.js b/web/app/assets/javascripts/clientUpdate.js index 0fd4230c8..d6e9ce9b4 100644 --- a/web/app/assets/javascripts/clientUpdate.js +++ b/web/app/assets/javascripts/clientUpdate.js @@ -299,6 +299,46 @@ }); } + async function isUpdateAvailable(){ + //this should check if the current version is less than the server version + //if so, return true + //otherwise return false + + var os = await context.jamClient.GetDetailedOS(); + //os = 'Win32' + var product = "JamClientModern" + var currentVersion = await context.jamClient.ClientUpdateVersion(); + if (!forceShow && (currentVersion == null || currentVersion.indexOf("Compiled")) > -1) { + // this is a developer build; it doesn't make much sense to do an packaged update, so skip + console.log("skipping client update check because this is a development build ('" + currentVersion + "')") + return false; + } + // # strange client oddity: remove quotes, if found, from start and finish of version. + if (currentVersion.indexOf('"') == 0 && currentVersion.lastIndexOf('"') == currentVersion.length - 1) { + currentVersion = currentVersion.substring(1, currentVersion.length - 1); + } + return new Promise((resolve, reject) => { + $.ajax({ + type: "GET", + url: "/api/versioncheck?product=" + product + "&os=" + os, + success: function (response) { + if(!jQuery.isEmptyObject(response)){ + // runCheck(product, response.version, response.uri, response.size, currentVersion); + var result = shouldUpdate(currentVersion, response.version); + resolve(result); + } else { + resolve(false); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + logger.error("Unable to do a client update check against /api/versioncheck"); + resolve(false); + } + }); + + }); + } + async function startDownload(url) { console.log("starting client updater download from: " + url); @@ -344,6 +384,7 @@ this.initialize = initialize; this.check = check; this.runCheck = runCheck; + this.isUpdateAvailable = isUpdateAvailable; } return this; diff --git a/web/app/assets/javascripts/gear_setup_reminder.js b/web/app/assets/javascripts/gear_setup_reminder.js new file mode 100644 index 000000000..8866c219b --- /dev/null +++ b/web/app/assets/javascripts/gear_setup_reminder.js @@ -0,0 +1,48 @@ +(function (context, $) { + + "use strict"; + + context.JK = context.JK || {}; + + context.JK.GearSetupReminder = function (app) { + + function showModal(options) { + options = options || {}; + + $('#gear_setup_reminder').attr('data-mode', 'gear-setup-reminder'); + + $('body').on('keyup', cancelModal); + + $("#gear_setup_reminder a.close-modal").click(function () { + app.layout.closeDialog('gear-setup-reminder'); + $('body').off('keyup', cancelModal); + return false; + }) + + $("#gear_setup_reminder a.setup-gear").click(function () { + app.layout.closeDialog('gear-setup-reminder'); + $('body').off('keyup', cancelModal); + window.location.hash = '#/account/audio'; + return false; + }) + + if(!app.layout.isDialogShowing('gear-setup-reminder')) { + app.layout.showDialog('gear-setup-reminder') + } + + } + + function cancelModal(e) { + if ((e.ctrlKey || e.metaKey) && e.keyCode == 78) { + console.log("update canceled!"); + app.layout.closeDialog('gear-setup-reminder'); + } + } + + // Expose publics + this.show = showModal; + } + + return this; + +})(window, jQuery); diff --git a/web/app/assets/stylesheets/client/client.css b/web/app/assets/stylesheets/client/client.css index 8dd471be3..dd3706e03 100644 --- a/web/app/assets/stylesheets/client/client.css +++ b/web/app/assets/stylesheets/client/client.css @@ -78,6 +78,7 @@ *= require ./sessionList *= require ./searchResults *= require ./clientUpdate + *= require ./gearSetupReminder *= require ./musician *= require ./help *= require ./jquery-ui-overrides diff --git a/web/app/assets/stylesheets/client/gearSetupReminder.scss b/web/app/assets/stylesheets/client/gearSetupReminder.scss new file mode 100644 index 000000000..97b5c0860 --- /dev/null +++ b/web/app/assets/stylesheets/client/gearSetupReminder.scss @@ -0,0 +1,12 @@ +#gear_setup_reminder { + display:none; + + width:800px; + min-height:0; + + h2 { + font-weight:bold; + font-size:x-large; + } +} + diff --git a/web/app/views/clients/_gear_setup_reminder.html.erb b/web/app/views/clients/_gear_setup_reminder.html.erb new file mode 100644 index 000000000..7a82770aa --- /dev/null +++ b/web/app/views/clients/_gear_setup_reminder.html.erb @@ -0,0 +1,42 @@ +
\ No newline at end of file diff --git a/web/app/views/clients/index.html.erb b/web/app/views/clients/index.html.erb index f26184ae8..ec6287308 100644 --- a/web/app/views/clients/index.html.erb +++ b/web/app/views/clients/index.html.erb @@ -99,6 +99,7 @@ <%= render "hoverSession" %> <%= render "notify" %> <%= render "client_update" %> +<%= render "gear_setup_reminder" %> <%= render "overlay_small" %> <%= render "listenBroadcast" %> <%= render "sync_viewer_templates" %> @@ -225,6 +226,23 @@ JK.ClientUpdateInstance = clientUpdate; clientUpdate.initialize(); + var gearSetupReminder = new JK.GearSetupReminder(JK.app); + JK.GearSetupReminderInstance = gearSetupReminder; + + if(clientUpdate) { + clientUpdate.isUpdateAvailable().then(function(isUpdateAvailable) { + if (!isUpdateAvailable) { + // Check if the user has not set up their gear yet + JK.hasOneConfiguredDevice().then(function(hasOneConfiguredDevice){ + if (!hasOneConfiguredDevice) { + // Show the gear setup reminder dialog + GearSetupReminderInstance.show(); + } + }); + } + }); + } + var homeScreen = new JK.HomeScreen(JK.app); homeScreen.initialize();