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');
|
2020-04-18 19:20:15 -05:00
|
|
|
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-04-18 19:20:15 -05:00
|
|
|
|
2020-07-26 23:57:28 -05:00
|
|
|
activate() {
|
|
|
|
let url = ApiClient.getUrl('/QuickConnect/Activate');
|
|
|
|
return ApiClient.ajax({
|
|
|
|
type: 'POST',
|
2020-04-18 19:20:15 -05:00
|
|
|
url: url,
|
2020-07-26 23:57:28 -05:00
|
|
|
contentType: 'application/json',
|
|
|
|
dataType: 'json'
|
2020-04-18 19:20:15 -05:00
|
|
|
}).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);
|
2020-04-18 19:20:15 -05:00
|
|
|
|
|
|
|
Dashboard.alert({
|
2020-07-26 23:57:28 -05:00
|
|
|
title: 'Unable to activate quick connect',
|
2020-04-18 19:20:15 -05:00
|
|
|
message: message
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-26 23:57:28 -05:00
|
|
|
toast(globalize.translate('QuickConnectActivationSuccessful'));
|
2020-04-18 19:20:15 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}).catch((e) => {
|
2020-07-26 23:57:28 -05:00
|
|
|
console.error('Error activating quick connect. Error:', e);
|
2020-04-18 19:20:15 -05:00
|
|
|
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-04-18 19:20:15 -05:00
|
|
|
|
2020-07-26 23:57:28 -05:00
|
|
|
export default QuickConnectSettings;
|