1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/components/quickConnectSettings/quickConnectSettings.js

65 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-07-26 23:57:28 -05:00
import globalize from 'globalize';
import toast from 'toast';
2020-04-12 00:44:30 -05:00
2020-07-26 23:57:28 -05:00
export class QuickConnectSettings {
constructor() { }
authorize(code) {
let url = ApiClient.getUrl('/QuickConnect/Authorize');
ApiClient.ajax({
2020-07-26 23:57:28 -05:00
type: 'POST',
2020-04-12 00:44:30 -05:00
url: url,
data: {
2020-07-26 23:57:28 -05:00
'Code': code
2020-04-12 00:44:30 -05:00
}
2020-07-26 23:57:28 -05:00
}, true).then(() => {
require(['toast'], function (toast) {
toast(globalize.translate('QuickConnectAuthorizeSuccess'));
});
}).catch(() => {
require(['toast'], function (toast) {
toast(globalize.translate('QuickConnectAuthorizeFail'));
});
2020-04-25 15:46:22 -05:00
});
// prevent bubbling
return false;
2020-04-12 00:44:30 -05:00
}
2020-07-26 23:57:28 -05:00
activate() {
let url = ApiClient.getUrl('/QuickConnect/Activate');
return ApiClient.ajax({
type: 'POST',
url: url,
2020-07-26 23:57:28 -05:00
contentType: 'application/json',
dataType: 'json'
}).then((json) => {
let message = json.Error;
2020-07-26 23:57:28 -05:00
if (message && message !== '') {
console.error('Error activating quick connect. Error: ', json.Error);
Dashboard.alert({
2020-07-26 23:57:28 -05:00
title: 'Unable to activate quick connect',
message: message
});
return false;
}
2020-07-26 23:57:28 -05:00
toast(globalize.translate('QuickConnectActivationSuccessful'));
return true;
}).catch((e) => {
2020-07-26 23:57:28 -05:00
console.error('Error activating quick connect. Error:', e);
throw e;
});
2020-04-12 00:44:30 -05:00
}
2020-07-26 23:57:28 -05:00
submit() {
2020-04-12 00:44:30 -05:00
return false;
2020-07-26 23:57:28 -05:00
}
}
2020-07-26 23:57:28 -05:00
export default QuickConnectSettings;