fix supporter key page

This commit is contained in:
Luke Pulverenti 2016-03-13 16:12:42 -04:00
parent 4fb729169f
commit db21e17a96
4 changed files with 105 additions and 102 deletions

View File

@ -45,7 +45,7 @@
"tag": "v1.0.11",
"commit": "e3c1ab0c72905b58fb4d9adc2921ea73b5c085a5"
},
"_source": "git://github.com/polymerelements/paper-behaviors.git",
"_source": "git://github.com/PolymerElements/paper-behaviors.git",
"_target": "^1.0.0",
"_originalSource": "polymerelements/paper-behaviors"
"_originalSource": "PolymerElements/paper-behaviors"
}

View File

@ -32,14 +32,14 @@
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
},
"ignore": [],
"homepage": "https://github.com/polymerelements/paper-ripple",
"homepage": "https://github.com/PolymerElements/paper-ripple",
"_release": "1.0.5",
"_resolution": {
"type": "version",
"tag": "v1.0.5",
"commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5"
},
"_source": "git://github.com/polymerelements/paper-ripple.git",
"_source": "git://github.com/PolymerElements/paper-ripple.git",
"_target": "^1.0.0",
"_originalSource": "polymerelements/paper-ripple"
"_originalSource": "PolymerElements/paper-ripple"
}

View File

@ -1772,6 +1772,7 @@ var AppInfo = {};
}
define("backdrop", [embyWebComponentsBowerPath + "/backdrop/backdrop"], returnFirstDependency);
define("fetchHelper", [embyWebComponentsBowerPath + "/fetchhelper"], returnFirstDependency);
// hack for an android test before browserInfo is loaded
if (Dashboard.isRunningInCordova() && window.MainActivity) {

View File

@ -1,11 +1,6 @@
var SupporterKeyPage = {
onPageShow: function () {
SupporterKeyPage.load(this);
},
load: function (page) {
define(['fetchHelper'], function (fetchHelper) {
function load(page) {
Dashboard.showLoadingMsg();
ApiClient.getPluginSecurityInfo().then(function (info) {
@ -22,84 +17,21 @@
Dashboard.hideLoadingMsg();
});
},
}
updateSupporterKey: function () {
function loadUserInfo(page) {
Dashboard.showLoadingMsg();
var form = this;
var key = $('#txtSupporterKey', form).val();
var info = {
SupporterKey: key
};
ApiClient.updatePluginSecurityInfo(info).then(function () {
Dashboard.resetPluginSecurityInfo();
Dashboard.hideLoadingMsg();
if (key) {
Dashboard.alert({
message: Globalize.translate('MessageKeyUpdated'),
title: Globalize.translate('HeaderConfirmation')
});
Dashboard.getPluginSecurityInfo().then(function (info) {
if (info.IsMBSupporter) {
$('.supporterContainer', page).addClass('hide');
} else {
Dashboard.alert({
message: Globalize.translate('MessageKeyRemoved'),
title: Globalize.translate('HeaderConfirmation')
});
$('.supporterContainer', page).removeClass('hide');
}
var page = $(form).parents('.page')[0];
SupporterKeyPage.load(page);
});
}
return false;
},
linkSupporterKeys: function () {
Dashboard.showLoadingMsg();
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 = "https://mb3admin.com/admin/service/supporter/linkKeys";
console.log(url);
$.post(url, info).then(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageKeysLinked'));
});
} else {
require(['toast'], function (toast) {
toast(result.ErrorMessage);
});
}
console.log(result);
});
return false;
},
retrieveSupporterKey: function () {
function retrieveSupporterKey() {
Dashboard.showLoadingMsg();
var form = this;
@ -107,8 +39,14 @@
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
console.log(url);
$.post(url).then(function (res) {
var result = JSON.parse(res);
fetchHelper.ajax({
url: url,
type: 'POST',
dataType: 'json'
}).then(function (result) {
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
@ -126,37 +64,101 @@
return false;
}
};
var SupporterKeyPage = {
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
updateSupporterKey: function () {
(function () {
Dashboard.showLoadingMsg();
var form = this;
function loadUserInfo(page) {
var key = $('#txtSupporterKey', form).val();
Dashboard.getPluginSecurityInfo().then(function (info) {
var info = {
SupporterKey: key
};
if (info.IsMBSupporter) {
$('.supporterContainer', page).addClass('hide');
} else {
$('.supporterContainer', page).removeClass('hide');
}
});
}
ApiClient.updatePluginSecurityInfo(info).then(function () {
Dashboard.resetPluginSecurityInfo();
Dashboard.hideLoadingMsg();
if (key) {
Dashboard.alert({
message: Globalize.translate('MessageKeyUpdated'),
title: Globalize.translate('HeaderConfirmation')
});
} else {
Dashboard.alert({
message: Globalize.translate('MessageKeyRemoved'),
title: Globalize.translate('HeaderConfirmation')
});
}
var page = $(form).parents('.page')[0];
load(page);
});
return false;
},
linkSupporterKeys: function () {
Dashboard.showLoadingMsg();
var form = this;
var email = $('#txtNewEmail', form).val();
var newkey = $('#txtNewKey', form).val();
var oldkey = $('#txtOldKey', form).val();
var url = "https://mb3admin.com/admin/service/supporter/linkKeys";
console.log(url);
fetchHelper.ajax({
url: url,
type: 'POST',
dataType: 'json',
query: {
email: email,
newkey: newkey,
oldkey: oldkey
}
}).then(function (result) {
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageKeysLinked'));
});
} else {
require(['toast'], function (toast) {
toast(result.ErrorMessage);
});
}
console.log(result);
});
return false;
}
};
$(document).on('pageinit', "#supporterKeyPage", function () {
var page = this;
$('#supporterKeyForm').on('submit', SupporterKeyPage.updateSupporterKey);
$('#lostKeyForm').on('submit', SupporterKeyPage.retrieveSupporterKey);
$('#linkKeysForm').on('submit', SupporterKeyPage.linkSupporterKeys);
$('#supporterKeyForm', this).on('submit', SupporterKeyPage.updateSupporterKey);
$('#lostKeyForm', this).on('submit', retrieveSupporterKey);
$('#linkKeysForm', this).on('submit', SupporterKeyPage.linkSupporterKeys);
$('.benefits', page).html(Globalize.translate('HeaderSupporterBenefit', '<a href="http://emby.media/premiere" target="_blank">', '</a>'));
}).on('pageshow', "#supporterKeyPage", function () {
var page = this;
loadUserInfo(page);
load(page);
});
})();
});