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,84 +17,21 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
}, }
updateSupporterKey: function () { function loadUserInfo(page) {
Dashboard.showLoadingMsg(); Dashboard.getPluginSecurityInfo().then(function (info) {
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')
});
if (info.IsMBSupporter) {
$('.supporterContainer', page).addClass('hide');
} else { } else {
Dashboard.alert({ $('.supporterContainer', page).removeClass('hide');
message: Globalize.translate('MessageKeyRemoved'),
title: Globalize.translate('HeaderConfirmation')
});
} }
var page = $(form).parents('.page')[0];
SupporterKeyPage.load(page);
}); });
}
return false; function retrieveSupporterKey() {
},
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 () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var form = this; var form = this;
@ -107,8 +39,14 @@
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email; var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
console.log(url); console.log(url);
$.post(url).then(function (res) { fetchHelper.ajax({
var result = JSON.parse(res);
url: url,
type: 'POST',
dataType: 'json'
}).then(function (result) {
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
if (result.Success) { if (result.Success) {
require(['toast'], function (toast) { require(['toast'], function (toast) {
@ -126,37 +64,101 @@
return false; 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) { ApiClient.updatePluginSecurityInfo(info).then(function () {
$('.supporterContainer', page).addClass('hide');
} else { Dashboard.resetPluginSecurityInfo();
$('.supporterContainer', page).removeClass('hide'); 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 () { $(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);
}); });
})(); });