mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #2155 from thornbill/quickconnect-enhancements
Improve QuickConnect ux
This commit is contained in:
commit
c383c8075a
9 changed files with 92 additions and 60 deletions
|
@ -13,10 +13,11 @@ import template from './dialog.template.html';
|
||||||
|
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function showDialog(options) {
|
function showDialog(options = { dialogOptions: {}, buttons: [] }) {
|
||||||
const dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false,
|
||||||
|
...options.dialogOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
const enableTvLayout = layoutManager.tv;
|
const enableTvLayout = layoutManager.tv;
|
||||||
|
|
|
@ -360,14 +360,17 @@ import '../../assets/css/scrollstyles.css';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDialog(options) {
|
export function createDialog(options = {}) {
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
// If there's no native dialog support, use a plain div
|
// If there's no native dialog support, use a plain div
|
||||||
// Also not working well in samsung tizen browser, content inside not clickable
|
// 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
|
// 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');
|
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('focuscontainer');
|
||||||
dlg.classList.add('hide');
|
dlg.classList.add('hide');
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
import globalize from '../../scripts/globalize';
|
|
||||||
import toast from '../toast/toast';
|
|
||||||
import Dashboard from '../../scripts/clientUtils';
|
|
||||||
|
|
||||||
export class QuickConnectSettings {
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
authorize(code) {
|
|
||||||
const url = ApiClient.getUrl('/QuickConnect/Authorize?Code=' + code);
|
|
||||||
ApiClient.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: url
|
|
||||||
}, true).then(() => {
|
|
||||||
toast(globalize.translate('QuickConnectAuthorizeSuccess'));
|
|
||||||
}).catch(() => {
|
|
||||||
toast(globalize.translate('QuickConnectAuthorizeFail'));
|
|
||||||
});
|
|
||||||
|
|
||||||
// prevent bubbling
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
activate() {
|
|
||||||
const url = ApiClient.getUrl('/QuickConnect/Activate');
|
|
||||||
return ApiClient.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: url
|
|
||||||
}).then(() => {
|
|
||||||
toast(globalize.translate('QuickConnectActivationSuccessful'));
|
|
||||||
return true;
|
|
||||||
}).catch((e) => {
|
|
||||||
console.error('Error activating quick connect. Error:', e);
|
|
||||||
Dashboard.alert({
|
|
||||||
title: globalize.translate('HeaderError'),
|
|
||||||
message: globalize.translate('DefaultErrorMessage')
|
|
||||||
});
|
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default QuickConnectSettings;
|
|
|
@ -37,8 +37,8 @@
|
||||||
<button is="emby-button" type="button" class="raised cancel block btnManual">
|
<button is="emby-button" type="button" class="raised cancel block btnManual">
|
||||||
<span>${ButtonManualLogin}</span>
|
<span>${ButtonManualLogin}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button is="emby-button" type="button" class="raised cancel block btnQuick">
|
<button is="emby-button" type="button" class="raised cancel block btnQuick hide">
|
||||||
<span>${ButtonUseQuickConnect}</span>
|
<span>${ButtonUseQuickConnect}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ import '../../../elements/emby-checkbox/emby-checkbox';
|
||||||
import Dashboard from '../../../scripts/clientUtils';
|
import Dashboard from '../../../scripts/clientUtils';
|
||||||
import ServerConnections from '../../../components/ServerConnections';
|
import ServerConnections from '../../../components/ServerConnections';
|
||||||
import toast from '../../../components/toast/toast';
|
import toast from '../../../components/toast/toast';
|
||||||
|
import dialogHelper from '../../../components/dialogHelper/dialogHelper';
|
||||||
|
import baseAlert from '../../../components/alert';
|
||||||
|
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
|
@ -49,9 +51,12 @@ import toast from '../../../components/toast/toast';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dashboard.alert({
|
baseAlert({
|
||||||
message: globalize.translate('QuickConnectAuthorizeCode', json.Code),
|
dialogOptions: {
|
||||||
title: globalize.translate('QuickConnect')
|
id: 'quickConnectAlert'
|
||||||
|
},
|
||||||
|
title: globalize.translate('QuickConnect'),
|
||||||
|
text: globalize.translate('QuickConnectAuthorizeCode', json.Code)
|
||||||
});
|
});
|
||||||
|
|
||||||
const connectUrl = apiClient.getUrl('/QuickConnect/Connect?Secret=' + json.Secret);
|
const connectUrl = apiClient.getUrl('/QuickConnect/Connect?Secret=' + json.Secret);
|
||||||
|
@ -64,11 +69,23 @@ import toast from '../../../components/toast/toast';
|
||||||
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
|
// Close the QuickConnect dialog
|
||||||
|
const dlg = document.getElementById('quickConnectAlert');
|
||||||
|
if (dlg) {
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
}
|
||||||
|
|
||||||
const result = await apiClient.quickConnect(data.Authentication);
|
const result = await apiClient.quickConnect(data.Authentication);
|
||||||
onLoginSuccessful(result.User.Id, result.AccessToken, apiClient);
|
onLoginSuccessful(result.User.Id, result.AccessToken, apiClient);
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
|
// Close the QuickConnect dialog
|
||||||
|
const dlg = document.getElementById('quickConnectAlert');
|
||||||
|
if (dlg) {
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
}
|
||||||
|
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('QuickConnectDeactivated'),
|
message: globalize.translate('QuickConnectDeactivated'),
|
||||||
title: globalize.translate('HeaderError')
|
title: globalize.translate('HeaderError')
|
||||||
|
@ -263,6 +280,17 @@ import toast from '../../../components/toast/toast';
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiClient = getApiClient();
|
const apiClient = getApiClient();
|
||||||
|
|
||||||
|
apiClient.getQuickConnect('Status')
|
||||||
|
.then(status => {
|
||||||
|
if (status !== 'Unavailable') {
|
||||||
|
view.querySelector('.btnQuick').classList.remove('hide');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.debug('Failed to get QuickConnect status');
|
||||||
|
});
|
||||||
|
|
||||||
apiClient.getPublicUsers().then(function (users) {
|
apiClient.getPublicUsers().then(function (users) {
|
||||||
if (users.length) {
|
if (users.length) {
|
||||||
showVisualForm();
|
showVisualForm();
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<a is="emby-linkbutton" data-ripple="false" href="#" style="display:block;padding:0;margin:0;" class="lnkQuickConnectPreferences listItem-border">
|
<a is="emby-linkbutton" data-ripple="false" href="#" style="display:block;padding:0;margin:0;" class="lnkQuickConnectPreferences listItem-border hide">
|
||||||
<div class="listItem">
|
<div class="listItem">
|
||||||
<em class="material-icons listItemIcon listItemIcon-transparent">tap_and_play</em>
|
<em class="material-icons listItemIcon listItemIcon-transparent">tap_and_play</em>
|
||||||
<div class="listItemBody">
|
<div class="listItemBody">
|
||||||
|
|
|
@ -35,6 +35,16 @@ export default function (view, params) {
|
||||||
const supportsMultiServer = appHost.supports('multiserver');
|
const supportsMultiServer = appHost.supports('multiserver');
|
||||||
page.querySelector('.selectServer').classList.toggle('hide', !supportsMultiServer);
|
page.querySelector('.selectServer').classList.toggle('hide', !supportsMultiServer);
|
||||||
|
|
||||||
|
ApiClient.getQuickConnect('Status')
|
||||||
|
.then(status => {
|
||||||
|
if (status !== 'Unavailable') {
|
||||||
|
page.querySelector('.lnkQuickConnectPreferences').classList.remove('hide');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.debug('Failed to get QuickConnect status');
|
||||||
|
});
|
||||||
|
|
||||||
ApiClient.getUser(userId).then(function (user) {
|
ApiClient.getUser(userId).then(function (user) {
|
||||||
page.querySelector('.headerUsername').innerHTML = user.Name;
|
page.querySelector('.headerUsername').innerHTML = user.Name;
|
||||||
if (user.Policy.IsAdministrator && !layoutManager.tv) {
|
if (user.Policy.IsAdministrator && !layoutManager.tv) {
|
||||||
|
|
36
src/controllers/user/quickConnect/helper.js
Normal file
36
src/controllers/user/quickConnect/helper.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import globalize from '../../../scripts/globalize';
|
||||||
|
import toast from '../../../components/toast/toast';
|
||||||
|
import Dashboard from '../../../scripts/clientUtils';
|
||||||
|
|
||||||
|
export const authorize = (code) => {
|
||||||
|
const url = ApiClient.getUrl('/QuickConnect/Authorize?Code=' + code);
|
||||||
|
ApiClient.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url
|
||||||
|
}, true).then(() => {
|
||||||
|
toast(globalize.translate('QuickConnectAuthorizeSuccess'));
|
||||||
|
}).catch(() => {
|
||||||
|
toast(globalize.translate('QuickConnectAuthorizeFail'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// prevent bubbling
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const activate = () => {
|
||||||
|
const url = ApiClient.getUrl('/QuickConnect/Activate');
|
||||||
|
return ApiClient.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url
|
||||||
|
}).then(() => {
|
||||||
|
toast(globalize.translate('QuickConnectActivationSuccessful'));
|
||||||
|
return true;
|
||||||
|
}).catch((e) => {
|
||||||
|
console.error('Error activating quick connect. Error:', e);
|
||||||
|
Dashboard.alert({
|
||||||
|
title: globalize.translate('HeaderError'),
|
||||||
|
message: globalize.translate('DefaultErrorMessage')
|
||||||
|
});
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,17 +1,13 @@
|
||||||
import QuickConnectSettings from '../../../components/quickConnectSettings/quickConnectSettings';
|
import { activate, authorize } from './helper';
|
||||||
import globalize from '../../../scripts/globalize';
|
import globalize from '../../../scripts/globalize';
|
||||||
import toast from '../../../components/toast/toast';
|
import toast from '../../../components/toast/toast';
|
||||||
|
|
||||||
export default function (view) {
|
export default function (view) {
|
||||||
let quickConnectSettingsInstance = null;
|
|
||||||
|
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
const codeElement = view.querySelector('#txtQuickConnectCode');
|
const codeElement = view.querySelector('#txtQuickConnectCode');
|
||||||
|
|
||||||
quickConnectSettingsInstance = new QuickConnectSettings();
|
|
||||||
|
|
||||||
view.querySelector('#btnQuickConnectActivate').addEventListener('click', () => {
|
view.querySelector('#btnQuickConnectActivate').addEventListener('click', () => {
|
||||||
quickConnectSettingsInstance.activate(quickConnectSettingsInstance).then(() => {
|
activate().then(() => {
|
||||||
renderPage();
|
renderPage();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,7 +20,7 @@ export default function (view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const code = codeElement.value;
|
const code = codeElement.value;
|
||||||
quickConnectSettingsInstance.authorize(code);
|
authorize(code);
|
||||||
});
|
});
|
||||||
|
|
||||||
view.querySelector('.quickConnectSettingsContainer').addEventListener('submit', (e) => {
|
view.querySelector('.quickConnectSettingsContainer').addEventListener('submit', (e) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue