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", "tag": "v1.0.11",
"commit": "e3c1ab0c72905b58fb4d9adc2921ea73b5c085a5" "commit": "e3c1ab0c72905b58fb4d9adc2921ea73b5c085a5"
}, },
"_source": "git://github.com/polymerelements/paper-behaviors.git", "_source": "git://github.com/PolymerElements/paper-behaviors.git",
"_target": "^1.0.0", "_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" "iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
}, },
"ignore": [], "ignore": [],
"homepage": "https://github.com/polymerelements/paper-ripple", "homepage": "https://github.com/PolymerElements/paper-ripple",
"_release": "1.0.5", "_release": "1.0.5",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.5", "tag": "v1.0.5",
"commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5" "commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5"
}, },
"_source": "git://github.com/polymerelements/paper-ripple.git", "_source": "git://github.com/PolymerElements/paper-ripple.git",
"_target": "^1.0.0", "_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("backdrop", [embyWebComponentsBowerPath + "/backdrop/backdrop"], returnFirstDependency);
define("fetchHelper", [embyWebComponentsBowerPath + "/fetchhelper"], returnFirstDependency);
// hack for an android test before browserInfo is loaded // hack for an android test before browserInfo is loaded
if (Dashboard.isRunningInCordova() && window.MainActivity) { if (Dashboard.isRunningInCordova() && window.MainActivity) {

View File

@ -1,11 +1,6 @@
var SupporterKeyPage = { define(['fetchHelper'], function (fetchHelper) {
onPageShow: function () {
SupporterKeyPage.load(this);
},
load: function (page) {
function load(page) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getPluginSecurityInfo().then(function (info) { ApiClient.getPluginSecurityInfo().then(function (info) {
@ -22,7 +17,54 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
}, }
function loadUserInfo(page) {
Dashboard.getPluginSecurityInfo().then(function (info) {
if (info.IsMBSupporter) {
$('.supporterContainer', page).addClass('hide');
} else {
$('.supporterContainer', page).removeClass('hide');
}
});
}
function retrieveSupporterKey() {
Dashboard.showLoadingMsg();
var form = this;
var email = $('#txtEmail', form).val();
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
console.log(url);
fetchHelper.ajax({
url: url,
type: 'POST',
dataType: 'json'
}).then(function (result) {
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
});
} else {
require(['toast'], function (toast) {
toast(result.ErrorMessage);
});
}
console.log(result);
});
return false;
}
var SupporterKeyPage = {
updateSupporterKey: function () { updateSupporterKey: function () {
@ -56,7 +98,7 @@
var page = $(form).parents('.page')[0]; var page = $(form).parents('.page')[0];
SupporterKeyPage.load(page); load(page);
}); });
return false; return false;
@ -71,16 +113,21 @@
var newkey = $('#txtNewKey', form).val(); var newkey = $('#txtNewKey', form).val();
var oldkey = $('#txtOldKey', form).val(); var oldkey = $('#txtOldKey', form).val();
var info = { var url = "https://mb3admin.com/admin/service/supporter/linkKeys";
console.log(url);
fetchHelper.ajax({
url: url,
type: 'POST',
dataType: 'json',
query: {
email: email, email: email,
newkey: newkey, newkey: newkey,
oldkey: oldkey oldkey: oldkey
}; }
}).then(function (result) {
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(); Dashboard.hideLoadingMsg();
if (result.Success) { if (result.Success) {
require(['toast'], function (toast) { require(['toast'], function (toast) {
@ -96,67 +143,22 @@
}); });
return false; return false;
},
retrieveSupporterKey: function () {
Dashboard.showLoadingMsg();
var form = this;
var email = $('#txtEmail', form).val();
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
console.log(url);
$.post(url).then(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
});
} else {
require(['toast'], function (toast) {
toast(result.ErrorMessage);
});
} }
console.log(result);
});
return false;
}
}; };
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
(function () {
function loadUserInfo(page) {
Dashboard.getPluginSecurityInfo().then(function (info) {
if (info.IsMBSupporter) {
$('.supporterContainer', page).addClass('hide');
} else {
$('.supporterContainer', page).removeClass('hide');
}
});
}
$(document).on('pageinit', "#supporterKeyPage", function () { $(document).on('pageinit', "#supporterKeyPage", function () {
var page = this; var page = this;
$('#supporterKeyForm').on('submit', SupporterKeyPage.updateSupporterKey); $('#supporterKeyForm', this).on('submit', SupporterKeyPage.updateSupporterKey);
$('#lostKeyForm').on('submit', SupporterKeyPage.retrieveSupporterKey); $('#lostKeyForm', this).on('submit', retrieveSupporterKey);
$('#linkKeysForm').on('submit', SupporterKeyPage.linkSupporterKeys); $('#linkKeysForm', this).on('submit', SupporterKeyPage.linkSupporterKeys);
$('.benefits', page).html(Globalize.translate('HeaderSupporterBenefit', '<a href="http://emby.media/premiere" target="_blank">', '</a>')); $('.benefits', page).html(Globalize.translate('HeaderSupporterBenefit', '<a href="http://emby.media/premiere" target="_blank">', '</a>'));
}).on('pageshow', "#supporterKeyPage", function () { }).on('pageshow', "#supporterKeyPage", function () {
var page = this; var page = this;
loadUserInfo(page); loadUserInfo(page);
load(page);
}); });
})(); });