Follow up to #332 (Replace all emby.media links with jellyfin.media links) (#344)

* Remove supporterkey.html
* remove supporterkeypage.js
* remove possibility to load "supporterkeypage"
* add FIXMEs as per suggestion
This commit is contained in:
Ben Fayers 2018-12-31 17:06:41 +00:00 committed by Vasily
parent fceeb95e2a
commit 55550e75b6
5 changed files with 2 additions and 246 deletions

View File

@ -154,6 +154,7 @@ define(["appSettings", "loading", "browser", "emby-linkbutton"], function(appSet
Dashboard.navigate("connectlogin.html?mode=connect")
});
var terms = view.querySelector(".terms");
//FIXME: Link below directs to "jellyfin.media/terms" which is a non existant URL
terms.innerHTML = Globalize.translate("LoginDisclaimer") + "<div style='margin-top:5px;'><a is='emby-linkbutton' class='button-link' href='http://jellyfin.media/terms' target='_blank'>" + Globalize.translate("TermsOfUse") + "</a></div>", AppInfo.isNativeApp ? (terms.classList.add("hide"), view.querySelector(".tvAppInfo").classList.add("hide")) : (terms.classList.remove("hide"), view.querySelector(".tvAppInfo").classList.remove("hide")), view.addEventListener("viewbeforeshow", function() {
var page = this;
if (page.querySelector("#txtSignupEmail").value = "", page.querySelector("#txtSignupUsername").value = "", page.querySelector("#txtSignupPassword").value = "", page.querySelector("#txtSignupPasswordConfirm").value = "", browser.safari && AppInfo.isNativeApp) page.querySelector(".embyIntroDownloadMessage").innerHTML = Globalize.translate("EmbyIntroDownloadMessageWithoutLink");

View File

@ -520,6 +520,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
serverId: ApiClient.serverId(),
element: page.querySelector(".serverActivityItems")
})));
//FIXME: There is no jellyfin swagger instance, as such this url is currently invalid
var swaggerUrl = "http://swagger.jellyfin.media?url=" + ApiClient.getUrl("openapi");
swaggerUrl = swaggerUrl + "&api_key=" + ApiClient.accessToken(), page.querySelector(".swaggerLink").setAttribute("href", swaggerUrl), refreshActiveRecordings(view, apiClient)
}

View File

@ -720,12 +720,6 @@ var Dashboard = {
dependencies: [],
autoFocus: !1,
roles: "admin"
}), defineRoute({
path: "/supporterkey.html",
dependencies: [],
controller: "scripts/supporterkeypage",
autoFocus: !1,
roles: "admin"
}), defineRoute({
path: "/syncactivity.html",
dependencies: [],
@ -1087,7 +1081,6 @@ var Dashboard = {
if ("wizard" === item) return "wizardstart.html";
if ("downloads" === item) return "offline/offline.html";
if ("downloadsettings" === item) return "mysyncsettings.html";
if ("premiere" === item) return "supporterkey.html";
if ("managedownloads" === item) return "managedownloads.html";
if ("manageserver" === item) return "dashboard.html";
if ("recordedtv" === item) return "livetv.html?tab=3&serverId=" + options.serverId;

View File

@ -1,141 +0,0 @@
define(["fetchHelper", "dom", "registrationServices", "loading", "confirm", "globalize", "connectionManager", "emby-linkbutton", "emby-collapse", "emby-input", "emby-button"], function(fetchHelper, dom, registrationServices, loading, confirm, globalize, connectionManager) {
"use strict";
function getPluginSecurityInfo() {
var apiClient = ApiClient;
return apiClient.getJSON(apiClient.getUrl("Plugins/SecurityInfo"))
}
function load(page) {
loading.show(), getPluginSecurityInfo().then(function(info) {
page.querySelector("#txtSupporterKey").value = info.SupporterKey || "", info.SupporterKey && !info.IsMBSupporter ? (page.querySelector("#txtSupporterKey").classList.add("invalidEntry"), page.querySelector(".notSupporter").classList.remove("hide")) : (page.querySelector("#txtSupporterKey").classList.remove("invalidEntry"), page.querySelector(".notSupporter").classList.add("hide")), info.IsMBSupporter ? (page.querySelector(".supporterContainer").classList.add("hide"), getPremiereStatus(info.SupporterKey).then(function(statusInfo) {
if (statusInfo) {
var statusLine, indicator = page.querySelector("#status-indicator .listItemIcon"),
extendedPlans = page.querySelector("#extended-plans");
switch (extendedPlans.innerHTML = globalize.translate("MessagePremiereExtendedPlans", '<a is="emby-linkbutton" class="button-link" href="https://github.com/jellyfin/jellyfin" target="_blank">', "</a>"), statusInfo.deviceStatus) {
case 2:
statusLine = globalize.translate("MessagePremiereStatusOver", statusInfo.planType), indicator.classList.add("expiredBackground"), indicator.classList.remove("nearExpiredBackground"), indicator.innerHTML = "&#xE000;", extendedPlans.classList.remove("hide");
break;
case 1:
statusLine = globalize.translate("MessagePremiereStatusClose", statusInfo.planType), indicator.classList.remove("expiredBackground"), indicator.classList.add("nearExpiredBackground"), indicator.innerHTML = "&#xE000;", extendedPlans.classList.remove("hide");
break;
default:
statusLine = globalize.translate("MessagePremiereStatusGood", statusInfo.planType), indicator.classList.remove("expiredBackground"), indicator.classList.remove("nearExpiredBackground"), indicator.innerHTML = "&#xE5CA;", extendedPlans.classList.add("hide")
}
page.querySelector("#premiere-status").innerHTML = statusLine;
var subsElement = page.querySelector("#premiere-subs");
if (statusInfo.subscriptions && statusInfo.subscriptions.length > 0) {
page.querySelector("#premiere-subs-content").innerHTML = getSubscriptionHtml(statusInfo.subscriptions, info.SupporterKey);
var sub = page.querySelector(".lnkSubscription");
sub && sub.addEventListener("click", cancelSub), subsElement.classList.remove("hide")
} else subsElement.classList.add("hide");
page.querySelector(".isSupporter").classList.remove("hide")
}
})) : (page.querySelector(".supporterContainer").classList.remove("hide"), page.querySelector(".isSupporter").classList.add("hide")), loading.hide()
})
}
function getPremiereStatus(key) {
var postData = "key=" + key + "&serverId=" + ApiClient.serverId();
return fetchHelper.ajax({
url: "https://mb3admin.local/admin/service/registration/getStatus",
type: "POST",
data: postData,
contentType: "application/x-www-form-urlencoded",
dataType: "json"
})
}
function getSubscriptionHtml(subs, key) {
return subs.map(function(item) {
var itemHtml = "",
makeLink = item.autoRenew && "Stripe" == item.store,
tagName = makeLink ? "button" : "div";
return itemHtml += (tagName = '<button type="button"') + ' class="listItem listItem-button listItem-noborder' + (makeLink ? " lnkSubscription" : "") + '" data-feature="' + item.feature + '" data-key="' + key + '">', itemHtml += '<i class="listItemIcon md-icon">dvr</i>', itemHtml += '<div class="listItemBody two-line">', itemHtml += '<div class="listItemBodyText">', itemHtml += globalize.translate("ListItemPremiereSub", item.planType, item.expDate, item.store), itemHtml += "</div>", itemHtml += '<div class="listItemBodyText secondary">', itemHtml += globalize.translate("Stripe" == item.store ? item.autoRenew ? "LabelClickToCancel" : "LabelAlreadyCancelled" : "LabelCancelInfo", item.store), itemHtml += "</div>", itemHtml += "</div>", itemHtml += "</" + tagName + ">"
})
}
function cancelSub(e) {
console.log("Cancel ");
var feature = this.getAttribute("data-feature"),
key = this.getAttribute("data-key");
confirm({
title: globalize.translate("HeaderCancelSub"),
text: globalize.translate("MessageConfirmSubCancel"),
confirmText: globalize.translate("ButtonCancelSub"),
cancelText: globalize.translate("ButtonDontCancelSub"),
primary: "cancel"
}).then(function() {
console.log("after confirm");
var postData = "key=" + key + "&feature=" + feature;
fetchHelper.ajax({
url: "https://mb3admin.local/admin/service/stripe/requestSubCancel",
type: "POST",
data: postData,
contentType: "application/x-www-form-urlencoded"
}).then(function(response) {
alertText({
text: globalize.translate("MessageSubCancelReqSent"),
title: globalize.translate("HeaderConfirmation")
})
}, function(response) {
alertText({
text: globalize.translate("MessageSubCancelError", "cancel@jellyfin.media")
})
})
})
}
function retrieveSupporterKey(e) {
loading.show();
var form = this,
email = form.querySelector("#txtEmail").value,
url = "https://mb3admin.local/admin/service/supporter/retrievekey?email=" + email;
return console.log(url), fetchHelper.ajax({
url: url,
type: "POST",
dataType: "json"
}).then(function(result) {
loading.hide(), result.Success ? require(["toast"], function(toast) {
toast(globalize.translate("MessageKeyEmailedTo").replace("{0}", email))
}) : require(["toast"], function(toast) {
toast(result.ErrorMessage)
}), console.log(result)
}), e.preventDefault(), !1
}
function alertText(options) {
require(["alert"], function(alert) {
alert(options)
})
}
function updateSupporterKey(e) {
loading.show();
var form = this,
key = form.querySelector("#txtSupporterKey").value,
info = {
SupporterKey: key
};
return ApiClient.updatePluginSecurityInfo(info).then(function() {
loading.hide(), alertText(key ? {
text: globalize.translate("MessageKeyUpdated"),
title: globalize.translate("HeaderConfirmation")
} : {
text: globalize.translate("MessageKeyRemoved"),
title: globalize.translate("HeaderConfirmation")
}), connectionManager.resetRegistrationInfo(ApiClient), load(dom.parentWithClass(form, "page"))
}, function() {
loading.hide(), connectionManager.resetRegistrationInfo(ApiClient), load(dom.parentWithClass(form, "page"))
}), e.preventDefault(), !1
}
function onSupporterLinkClick(e) {
registrationServices.showPremiereInfo(), e.preventDefault(), e.stopPropagation()
}
return function(view, params) {
view.querySelector("#supporterKeyForm").addEventListener("submit", updateSupporterKey), view.querySelector("#lostKeyForm").addEventListener("submit", retrieveSupporterKey), view.querySelector(".benefits").innerHTML = globalize.translate("HeaderSupporterBenefit", '<a is="emby-linkbutton" class="lnkPremiere button-link" href="https://github.com/jellyfin/jellyfin" target="_blank">', "</a>"), view.querySelector(".lnkPremiere").addEventListener("click", onSupporterLinkClick), view.addEventListener("viewshow", function() {
load(this)
})
}
});

View File

@ -1,98 +0,0 @@
<div id="supporterKeyPage" data-role="page" class="page type-interior">
<style>
.expiredBackground {
background: #cc3333 !important;
}
.nearExpiredBackground {
background: orange !important;
}
</style>
<div>
<div class="content-primary">
<div class="readOnlyContent">
<div>
<h2>${HeaderSupportTheTeam}</h2>
<p>${HeaderSupportTheTeamHelp}</p>
<p class="benefits"></p>
<div class="supporterContainer hide">
<br />
<a class="clearLink" href="https://github.com/jellyfin/jellyfin" target="_blank">
<button is="emby-button" type="button" class="raised block button-submit">
<span>${HeaderBecomeProjectSupporter}</span>
</button>
</a>
</div>
</div>
<form id="supporterKeyForm">
<div style="margin: 3em 0 1em;">
<h2>${TabSupporterKey}</h2>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtSupporterKey" label="${LabelSupporterKey}" autocomplete="off" />
<div class="fieldDescription">
${LabelSupporterKeyHelp}
</div>
</div>
<div class="hide notSupporter">
<p>
<strong>${MessageInvalidKey}</strong>
</p>
<p>
${ErrorMessageInvalidKey}
</p>
</div>
</div>
<p>
<button is="emby-button" type="submit" id="mbLegacyKeyBtn" class="raised block button-submit">
<span>${ButtonSave}</span>
</button>
</p>
</form>
<br />
<div class="hide isSupporter">
<h2 style="margin-bottom:0;">${HeaderStatus}</h2>
<div class="paperList paperList-clear" id="status-indicator" style="margin-top:0;">
<div class="listItem">
<i class="listItemIcon md-icon">&#xE5CA;</i>
<div class="listItemBody">
<div class="listItemBodyText" id="premiere-status"></div>
<div class="listItemBodyText secondary hide" id="extended-plans"></div>
</div>
</div>
</div>
<div id="premiere-subs" class="hide">
<h2>${Subscriptions}</h2>
<div id="premiere-subs-content" class="paperList"></div>
</div>
</div>
<br />
<div is="emby-collapse" title="${HeaderForgotKey}">
<div class="collapseContent">
<form id="lostKeyForm">
<div style="margin: 1em 0;" class="inputContainer">
<input is="emby-input" type="email" required id="txtEmail" label="${LabelEmailAddress}" />
<div class="fieldDescription">${LabelSupporterEmailAddress}</div>
</div>
<p>
<button is="emby-button" type="submit" id="mbRetrieveKeyBtn" class="raised block button-submit">
<span>${ButtonRetrieveKey}</span>
</button>
</p>
</form>
</div>
</div>
</div>
</div>
</div>
</div>