diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 46c40b6c999..b7c64ef9c14 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -34,6 +34,7 @@ - [Ryan Hartzell](https://github.com/ryan-hartzell) - [Thibault Nocchi](https://github.com/ThibaultNocchi) - [MrTimscampi](https://github.com/MrTimscampi) + - [ConfusedPolarBear](https://github.com/ConfusedPolarBear) - [Sarab Singh](https://github.com/sarab97) - [GuilhermeHideki](https://github.com/GuilhermeHideki) - [Andrei Oanca](https://github.com/OancaAndrei) diff --git a/package.json b/package.json index 5ca5c151519..d53ef70cb6e 100644 --- a/package.json +++ b/package.json @@ -166,6 +166,8 @@ "src/components/playmenu.js", "src/components/pluginManager.js", "src/components/prompt/prompt.js", + "src/components/qualityOptions.js", + "src/components/quickConnectSettings/quickConnectSettings.js", "src/components/recordingcreator/recordingbutton.js", "src/components/recordingcreator/recordingcreator.js", "src/components/recordingcreator/seriesrecordingeditor.js", @@ -173,7 +175,6 @@ "src/components/refreshdialog/refreshdialog.js", "src/components/recordingcreator/recordingeditor.js", "src/components/recordingcreator/recordingfields.js", - "src/components/qualityOptions.js", "src/components/remotecontrol/remotecontrol.js", "src/components/sanatizefilename.js", "src/components/scrollManager.js", @@ -244,6 +245,7 @@ "src/controllers/dashboard/plugins/installed/index.js", "src/controllers/dashboard/plugins/available/index.js", "src/controllers/dashboard/plugins/repositories/index.js", + "src/controllers/dashboard/quickconnect.js", "src/controllers/dashboard/scheduledtasks/scheduledtask.js", "src/controllers/dashboard/scheduledtasks/scheduledtasks.js", "src/controllers/dashboard/serveractivity.js", @@ -292,6 +294,7 @@ "src/controllers/user/menu/index.js", "src/controllers/user/playback/index.js", "src/controllers/user/profile/index.js", + "src/controllers/user/quickConnect/index.js", "src/controllers/user/subtitles/index.js", "src/controllers/wizard/finish/index.js", "src/controllers/wizard/remote/index.js", diff --git a/src/components/quickConnectSettings/quickConnectSettings.js b/src/components/quickConnectSettings/quickConnectSettings.js new file mode 100644 index 00000000000..e802f92ba13 --- /dev/null +++ b/src/components/quickConnectSettings/quickConnectSettings.js @@ -0,0 +1,41 @@ +import globalize from 'globalize'; +import toast from 'toast'; + +export class QuickConnectSettings { + constructor() { } + + authorize(code) { + let 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() { + let 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; diff --git a/src/controllers/dashboard/quickconnect.js b/src/controllers/dashboard/quickconnect.js new file mode 100644 index 00000000000..87c88d8a41e --- /dev/null +++ b/src/controllers/dashboard/quickconnect.js @@ -0,0 +1,58 @@ +import loading from 'loading'; +import toast from 'toast'; +import globalize from 'globalize'; + +const unavailable = 'Unavailable'; +const available = 'Available'; +const active = 'Active'; +let page; + +export default function(view) { + view.addEventListener('viewshow', function () { + page = this; + loading.show(); + page.querySelector('#btnQuickConnectSubmit').onclick = onSubmit; + updatePage(); + }); +} + +function loadPage(status) { + let check = status === available || status === active; + + page.querySelector('#quickConnectStatus').textContent = status.toLocaleLowerCase(); + page.querySelector('#chkQuickConnectAvailable').checked = check; + + loading.hide(); +} + +function onSubmit() { + loading.show(); + + let newStatus = page.querySelector('#chkQuickConnectAvailable').checked ? available : unavailable; + + let url = ApiClient.getUrl('/QuickConnect/Available?Status=' + newStatus); + + ApiClient.ajax({ + type: 'POST', + url: url + }, true).then(() => { + toast(globalize.translate('SettingsSaved')); + setTimeout(updatePage, 500); + + return true; + }).catch((e) => { + console.error('Unable to set quick connect status. error:', e); + }); + + loading.hide(); + return false; +} + +function updatePage() { + ApiClient.getQuickConnect('Status').then((response) => { + loadPage(response); + return true; + }).catch((e) => { + console.error('Unable to get quick connect status. error:', e); + }); +} diff --git a/src/controllers/session/login/index.html b/src/controllers/session/login/index.html index 458ac7df3be..8c694561685 100644 --- a/src/controllers/session/login/index.html +++ b/src/controllers/session/login/index.html @@ -42,6 +42,10 @@