jellyfin-web/dashboard-ui/scripts/supporterkeypage.js

124 lines
3.2 KiB
JavaScript
Raw Normal View History

2013-02-20 18:33:05 -07:00
var SupporterKeyPage = {
onPageShow: function () {
2014-01-02 14:21:06 -07:00
SupporterKeyPage.load(this);
2013-02-20 18:33:05 -07:00
},
2014-01-02 14:21:06 -07:00
load: function (page) {
2014-05-18 12:58:42 -07:00
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
ApiClient.getPluginSecurityInfo().done(function (info) {
2014-05-18 12:58:42 -07:00
2013-02-20 18:33:05 -07:00
$('#txtSupporterKey', page).val(info.SupporterKey);
2014-01-02 14:21:06 -07:00
2014-05-18 12:58:42 -07:00
if (info.SupporterKey && !info.IsMBSupporter) {
$('#txtSupporterKey', page).addClass("invalidEntry");
$('.notSupporter', page).show();
} else {
$('#txtSupporterKey', page).removeClass("invalidEntry");
$('.notSupporter', page).hide();
}
2014-05-18 12:58:42 -07:00
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
});
},
2014-05-18 12:58:42 -07:00
2013-02-20 18:33:05 -07:00
updateSupporterKey: function () {
Dashboard.showLoadingMsg();
2014-01-02 14:21:06 -07:00
var form = this;
2014-05-18 12:58:42 -07:00
2014-01-02 14:21:06 -07:00
var key = $('#txtSupporterKey', form).val();
2013-02-20 18:33:05 -07:00
2014-05-18 12:58:42 -07:00
var info = {
SupporterKey: key
};
2013-02-20 18:33:05 -07:00
2014-05-18 12:58:42 -07:00
ApiClient.updatePluginSecurityInfo(info).done(function () {
2014-01-02 14:21:06 -07:00
2014-05-18 12:58:42 -07:00
Dashboard.resetPluginSecurityInfo();
Dashboard.hideLoadingMsg();
2014-01-02 14:21:06 -07:00
2014-05-18 12:58:42 -07:00
if (key) {
2014-05-18 12:58:42 -07:00
Dashboard.alert({
2014-05-30 12:23:56 -07:00
message: Globalize.translate('MessageKeyUpdated'),
title: Globalize.translate('HeaderConfirmation')
2014-05-18 12:58:42 -07:00
});
2014-01-02 14:21:06 -07:00
2014-05-18 12:58:42 -07:00
} else {
Dashboard.alert({
2014-05-30 12:23:56 -07:00
message: Globalize.translate('MessageKeyRemoved'),
title: Globalize.translate('HeaderConfirmation')
2014-05-18 12:58:42 -07:00
});
}
var page = $(form).parents('.page');
SupporterKeyPage.load(page);
});
2013-02-20 18:33:05 -07:00
return false;
},
2014-05-18 12:58:42 -07:00
linkSupporterKeys: function () {
Dashboard.showLoadingMsg();
2014-01-02 14:21:06 -07:00
var form = this;
var email = $('#txtNewEmail', form).val();
var newkey = $('#txtNewKey', form).val();
var oldkey = $('#txtOldKey', form).val();
var info = {
email: email,
newkey: newkey,
oldkey: oldkey
};
var url = "http://mb3admin.com/admin/service/supporter/linkKeys";
console.log(url);
$.post(url, info).done(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageKeysLinked'));
} else {
Dashboard.showError(result.ErrorMessage);
}
console.log(result);
});
return false;
},
2014-05-18 12:58:42 -07:00
2013-02-20 18:33:05 -07:00
retrieveSupporterKey: function () {
Dashboard.showLoadingMsg();
2014-01-02 14:21:06 -07:00
var form = this;
2013-02-20 18:33:05 -07:00
2014-01-02 14:21:06 -07:00
var email = $('#txtEmail', form).val();
2013-02-20 18:33:05 -07:00
2014-05-18 12:58:42 -07:00
var url = "http://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
2013-02-20 18:33:05 -07:00
console.log(url);
$.post(url).done(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
2013-02-20 18:33:05 -07:00
} else {
Dashboard.showError(result.ErrorMessage);
}
console.log(result);
});
return false;
}
};
2014-01-02 14:21:06 -07:00
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);