diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index 5d32abc596..6647dda400 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -13,10 +13,11 @@ import template from './dialog.template.html'; /* eslint-disable indent */ - function showDialog(options) { + function showDialog(options = { dialogOptions: {}, buttons: [] }) { const dialogOptions = { removeOnClose: true, - scrollY: false + scrollY: false, + ...options.dialogOptions }; const enableTvLayout = layoutManager.tv; diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js index cdaf47996f..69f5677cfb 100644 --- a/src/components/dialogHelper/dialogHelper.js +++ b/src/components/dialogHelper/dialogHelper.js @@ -360,14 +360,17 @@ import '../../assets/css/scrollstyles.css'; }); } - export function createDialog(options) { - options = options || {}; - + export function createDialog(options = {}) { // If there's no native dialog support, use a plain div // Also not working well in samsung tizen browser, content inside not clickable // Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog const dlg = document.createElement('div'); + // Add an id so we can access the dialog element + if (options.id) { + dlg.id = options.id; + } + dlg.classList.add('focuscontainer'); dlg.classList.add('hide'); diff --git a/src/controllers/session/login/index.js b/src/controllers/session/login/index.js index abf2b9b33d..24b3a983eb 100644 --- a/src/controllers/session/login/index.js +++ b/src/controllers/session/login/index.js @@ -11,6 +11,8 @@ import '../../../elements/emby-checkbox/emby-checkbox'; import Dashboard from '../../../scripts/clientUtils'; import ServerConnections from '../../../components/ServerConnections'; import toast from '../../../components/toast/toast'; +import dialogHelper from '../../../components/dialogHelper/dialogHelper'; +import baseAlert from '../../../components/alert'; /* eslint-disable indent */ @@ -49,9 +51,12 @@ import toast from '../../../components/toast/toast'; return false; } - Dashboard.alert({ - message: globalize.translate('QuickConnectAuthorizeCode', json.Code), - title: globalize.translate('QuickConnect') + baseAlert({ + dialogOptions: { + id: 'quickConnectAlert' + }, + title: globalize.translate('QuickConnect'), + text: globalize.translate('QuickConnectAuthorizeCode', json.Code) }); const connectUrl = apiClient.getUrl('/QuickConnect/Connect?Secret=' + json.Secret); @@ -64,11 +69,23 @@ import toast from '../../../components/toast/toast'; clearInterval(interval); + // Close the QuickConnect dialog + const dlg = document.getElementById('quickConnectAlert'); + if (dlg) { + dialogHelper.close(dlg); + } + const result = await apiClient.quickConnect(data.Authentication); onLoginSuccessful(result.User.Id, result.AccessToken, apiClient); }, function (e) { clearInterval(interval); + // Close the QuickConnect dialog + const dlg = document.getElementById('quickConnectAlert'); + if (dlg) { + dialogHelper.close(dlg); + } + Dashboard.alert({ message: globalize.translate('QuickConnectDeactivated'), title: globalize.translate('HeaderError')