mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 02:48:19 -07:00
Merge pull request #79 from cvium/remove_more_connect
Remove unused Connect related from the frontend
This commit is contained in:
commit
d79a07dd34
@ -1,219 +0,0 @@
|
||||
define(['globalize', 'apphost', 'loading', 'alert', 'emby-linkbutton'], function (globalize, appHost, loading, alert) {
|
||||
'use strict';
|
||||
|
||||
function resolvePromise() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function rejectPromise() {
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
function showNewUserInviteMessage(result) {
|
||||
|
||||
if (!result.IsNewUserInvitation && !result.IsPending) {
|
||||
|
||||
// It was immediately approved
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
var message = result.IsNewUserInvitation ?
|
||||
globalize.translate('sharedcomponents#MessageInvitationSentToNewUser', result.GuestDisplayName) :
|
||||
globalize.translate('sharedcomponents#MessageInvitationSentToUser', result.GuestDisplayName);
|
||||
|
||||
return alert({
|
||||
|
||||
text: message,
|
||||
title: globalize.translate('sharedcomponents#HeaderInvitationSent')
|
||||
|
||||
}).then(resolvePromise, resolvePromise);
|
||||
}
|
||||
|
||||
function inviteGuest(options) {
|
||||
|
||||
var apiClient = options.apiClient;
|
||||
|
||||
loading.show();
|
||||
|
||||
// Add/Update connect info
|
||||
return apiClient.ajax({
|
||||
|
||||
type: "POST",
|
||||
url: apiClient.getUrl('Connect/Invite'),
|
||||
dataType: 'json',
|
||||
data: options.guestOptions || {}
|
||||
|
||||
}).then(function (result) {
|
||||
|
||||
loading.hide();
|
||||
return showNewUserInviteMessage(result);
|
||||
|
||||
}, function (response) {
|
||||
|
||||
loading.hide();
|
||||
|
||||
var statusCode = response ? response.status : 0;
|
||||
|
||||
if (statusCode === 502) {
|
||||
return showConnectServerUnreachableErrorMessage().then(rejectPromise, rejectPromise);
|
||||
}
|
||||
else if (statusCode === 404) {
|
||||
// User doesn't exist
|
||||
return alert({
|
||||
text: globalize.translate('sharedcomponents#GuestUserNotFound')
|
||||
}).then(rejectPromise, rejectPromise);
|
||||
|
||||
} else if ((statusCode || 0) >= 500) {
|
||||
|
||||
// Unable to reach connect server ?
|
||||
return alert({
|
||||
text: globalize.translate('sharedcomponents#ErrorReachingEmbyConnect')
|
||||
}).then(rejectPromise, rejectPromise);
|
||||
|
||||
} else {
|
||||
|
||||
// status 400 = account not activated
|
||||
|
||||
// General error
|
||||
return showGuestGeneralErrorMessage().then(rejectPromise, rejectPromise);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showGuestGeneralErrorMessage() {
|
||||
|
||||
var html;
|
||||
|
||||
if (appHost.supports('externallinks')) {
|
||||
html = globalize.translate('sharedcomponents#ErrorAddingGuestAccount1', '<a is="emby-linkbutton" class="button-link" href="https://emby.media/connect" target="_blank">https://emby.media/connect</a>');
|
||||
html += '<br/><br/>' + globalize.translate('sharedcomponents#ErrorAddingGuestAccount2', 'apps@emby.media');
|
||||
}
|
||||
|
||||
var text = globalize.translate('sharedcomponents#ErrorAddingGuestAccount1', 'https://emby.media/connect');
|
||||
text += '\n\n' + globalize.translate('sharedcomponents#ErrorAddingGuestAccount2', 'apps@emby.media');
|
||||
|
||||
return alert({
|
||||
text: text,
|
||||
html: html
|
||||
});
|
||||
}
|
||||
|
||||
function showConnectServerUnreachableErrorMessage() {
|
||||
|
||||
var text = globalize.translate('sharedcomponents#ErrorConnectServerUnreachable', 'https://connect.emby.media');
|
||||
|
||||
return alert({
|
||||
text: text
|
||||
});
|
||||
}
|
||||
|
||||
function showLinkUserErrorMessage(username, statusCode) {
|
||||
|
||||
var html;
|
||||
var text;
|
||||
|
||||
if (statusCode === 502) {
|
||||
return showConnectServerUnreachableErrorMessage();
|
||||
}
|
||||
else if (username) {
|
||||
|
||||
if (appHost.supports('externallinks')) {
|
||||
html = globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount1', '<a is="emby-linkbutton" class="button-link" href="https://emby.media/connect" target="_blank">https://emby.media/connect</a>');
|
||||
html += '<br/><br/>' + globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount2', 'apps@emby.media');
|
||||
}
|
||||
|
||||
text = globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount1', 'https://emby.media/connect');
|
||||
text += '\n\n' + globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount2', 'apps@emby.media');
|
||||
|
||||
} else {
|
||||
html = text = globalize.translate('sharedcomponents#DefaultErrorMessage');
|
||||
}
|
||||
|
||||
return alert({
|
||||
text: text,
|
||||
html: html
|
||||
});
|
||||
}
|
||||
|
||||
function updateUserLink(apiClient, user, newConnectUsername) {
|
||||
var currentConnectUsername = user.ConnectUserName || '';
|
||||
var enteredConnectUsername = newConnectUsername;
|
||||
|
||||
var linkUrl = apiClient.getUrl('Users/' + user.Id + '/Connect/Link');
|
||||
|
||||
if (currentConnectUsername && !enteredConnectUsername) {
|
||||
|
||||
// Remove connect info
|
||||
// Add/Update connect info
|
||||
return apiClient.ajax({
|
||||
|
||||
type: "DELETE",
|
||||
url: linkUrl
|
||||
|
||||
}).then(function () {
|
||||
|
||||
return alert({
|
||||
text: globalize.translate('sharedcomponents#MessageEmbyAccontRemoved'),
|
||||
title: globalize.translate('sharedcomponents#HeaderEmbyAccountRemoved'),
|
||||
|
||||
}).catch(resolvePromise);
|
||||
|
||||
}, function (response) {
|
||||
|
||||
var statusCode = response ? response.status : 0;
|
||||
|
||||
if (statusCode === 502) {
|
||||
return showConnectServerUnreachableErrorMessage().then(rejectPromise);
|
||||
}
|
||||
|
||||
return alert({
|
||||
text: globalize.translate('sharedcomponents#ErrorRemovingEmbyConnectAccount')
|
||||
|
||||
}).then(rejectPromise);
|
||||
});
|
||||
|
||||
}
|
||||
else if (currentConnectUsername !== enteredConnectUsername) {
|
||||
|
||||
// Add/Update connect info
|
||||
return apiClient.ajax({
|
||||
type: "POST",
|
||||
url: linkUrl,
|
||||
data: {
|
||||
ConnectUsername: enteredConnectUsername
|
||||
},
|
||||
dataType: 'json'
|
||||
|
||||
}).then(function (result) {
|
||||
|
||||
var msgKey = result.IsPending ? 'sharedcomponents#MessagePendingEmbyAccountAdded' : 'sharedcomponents#MessageEmbyAccountAdded';
|
||||
|
||||
return alert({
|
||||
text: globalize.translate(msgKey),
|
||||
title: globalize.translate('sharedcomponents#HeaderEmbyAccountAdded'),
|
||||
|
||||
}).catch(resolvePromise);
|
||||
|
||||
}, function (response) {
|
||||
|
||||
var statusCode = response ? response.status : 0;
|
||||
|
||||
if (statusCode === 502) {
|
||||
return showConnectServerUnreachableErrorMessage().then(rejectPromise);
|
||||
}
|
||||
|
||||
return showLinkUserErrorMessage('.', statusCode).then(rejectPromise);
|
||||
});
|
||||
|
||||
} else {
|
||||
return Promise.reject();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
inviteGuest: inviteGuest,
|
||||
updateUserLink: updateUserLink,
|
||||
showLinkUserErrorMessage: showLinkUserErrorMessage,
|
||||
showConnectServerUnreachableErrorMessage: showConnectServerUnreachableErrorMessage
|
||||
};
|
||||
});
|
@ -1,58 +0,0 @@
|
||||
define(["dialogHelper", "loading", "require", "emby-input", "emby-button", "emby-checkbox", "paper-icon-button-light", "formDialogStyle", "emby-linkbutton"], function(dialogHelper, loading, require) {
|
||||
"use strict";
|
||||
|
||||
function renderLibrarySharingList(context, result) {
|
||||
var folderHtml = "";
|
||||
folderHtml += result.Items.map(function(i) {
|
||||
var currentHtml = "";
|
||||
return currentHtml += '<label><input is="emby-checkbox" class="chkShareFolder" type="checkbox" data-folderid="' + i.Id + '" checked="checked"/><span>' + i.Name + "</span></label>"
|
||||
}).join(""), context.querySelector(".librarySharingList").innerHTML = folderHtml
|
||||
}
|
||||
|
||||
function inviteUser(dlg) {
|
||||
loading.show();
|
||||
var shareExcludes = Array.prototype.filter.call(dlg.querySelectorAll(".chkShareFolder"), function(i) {
|
||||
return i.checked
|
||||
}).map(function(i) {
|
||||
return i.getAttribute("data-folderid")
|
||||
});
|
||||
require(["connectHelper"], function(connectHelper) {
|
||||
connectHelper.inviteGuest({
|
||||
apiClient: ApiClient,
|
||||
guestOptions: {
|
||||
ConnectUsername: dlg.querySelector("#txtConnectUsername").value,
|
||||
EnabledLibraries: shareExcludes.join(","),
|
||||
SendingUserId: Dashboard.getCurrentUserId(),
|
||||
EnableLiveTv: !1
|
||||
}
|
||||
}).then(function() {
|
||||
loading.hide(), dlg.submitted = !0, dialogHelper.close(dlg)
|
||||
})
|
||||
})
|
||||
}
|
||||
return {
|
||||
show: function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
require(["text!./guestinviter.template.html"], function(template) {
|
||||
var dlg = dialogHelper.createDialog({
|
||||
removeOnClose: !0,
|
||||
size: "small"
|
||||
});
|
||||
dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a"), dlg.classList.add("formDialog");
|
||||
var html = "";
|
||||
html += Globalize.translateDocument(template), dlg.innerHTML = html, dialogHelper.open(dlg), dlg.addEventListener("close", function() {
|
||||
dlg.submitted ? resolve() : reject()
|
||||
}), dlg.querySelector(".btnCancel").addEventListener("click", function(e) {
|
||||
dialogHelper.close(dlg)
|
||||
}), dlg.querySelector("form").addEventListener("submit", function(e) {
|
||||
return inviteUser(dlg), e.preventDefault(), !1
|
||||
}), ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
|
||||
IsHidden: !1
|
||||
})).then(function(result) {
|
||||
renderLibrarySharingList(dlg, result)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
@ -1,36 +0,0 @@
|
||||
<div class="formDialogHeader">
|
||||
<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1">
|
||||
<i class="md-icon"></i>
|
||||
</button>
|
||||
<h3 class="formDialogHeaderTitle">
|
||||
${HeaderInviteUser}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="formDialogContent scrollY">
|
||||
<div class="dialogContentInner dialog-content-centered">
|
||||
<form class="addUserForm" style="max-width: none;margin:1em 0 0;">
|
||||
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="text" id="txtConnectUsername" value="" label="${LabelConnectGuestUserName}" required />
|
||||
<div class="fieldDescription">
|
||||
<div>${LabelConnectGuestUserNameHelp}</div>
|
||||
<div style="margin-top: .25em;"><a is="emby-linkbutton" class="button-link" href="https://github.com/jellyfin/jellyfin" target="_blank">${ButtonLearnMoreAboutEmbyConnect}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="checkboxListLabel">${HeaderShareMediaFolders}</h3>
|
||||
<div class="librarySharingList checkboxList paperList checkboxList-paperList">
|
||||
|
||||
</div>
|
||||
|
||||
<p class="fieldDescription" style="margin-top:.5em;">${MessageGuestSharingPermissionsHelp}</p>
|
||||
<br />
|
||||
|
||||
<div class="formDialogFooter">
|
||||
<button is="emby-button" type="submit" class="raised button-submit block formDialogFooterItem">
|
||||
<span>${ButtonSendInvitation}</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -28,7 +28,7 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l
|
||||
IsHidden: !1
|
||||
})).then(function(folders) {
|
||||
loadDeleteFolders(page, user, folders.Items)
|
||||
}), user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".disabledUserBanner", page).hide(), "Guest" == user.ConnectLinkType ? ($("#fldConnectInfo", page).hide(), $("#txtUserName", page).prop("disabled", "disabled")) : ($("#txtUserName", page).prop("disabled", "").removeAttr("disabled"), $("#fldConnectInfo", page).show()), $(".lnkEditUserPreferences", page).attr("href", "mypreferencesmenu.html?userId=" + user.Id), libraryMenu.setTitle(user.Name), page.querySelector(".username").innerHTML = user.Name, $("#txtUserName", page).val(user.Name), $("#txtConnectUserName", page).val(currentUser.ConnectUserName), $("#chkIsAdmin", page).checked(user.Policy.IsAdministrator), $("#chkDisabled", page).checked(user.Policy.IsDisabled), $("#chkIsHidden", page).checked(user.Policy.IsHidden), $("#chkRemoteControlSharedDevices", page).checked(user.Policy.EnableSharedDeviceControl), $("#chkEnableRemoteControlOtherUsers", page).checked(user.Policy.EnableRemoteControlOfOtherUsers), $("#chkEnableDownloading", page).checked(user.Policy.EnableContentDownloading), $("#chkManageLiveTv", page).checked(user.Policy.EnableLiveTvManagement), $("#chkEnableLiveTvAccess", page).checked(user.Policy.EnableLiveTvAccess), $("#chkEnableMediaPlayback", page).checked(user.Policy.EnableMediaPlayback), $("#chkEnableAudioPlaybackTranscoding", page).checked(user.Policy.EnableAudioPlaybackTranscoding), $("#chkEnableVideoPlaybackTranscoding", page).checked(user.Policy.EnableVideoPlaybackTranscoding), $("#chkEnableVideoPlaybackRemuxing", page).checked(user.Policy.EnablePlaybackRemuxing), $("#chkRemoteAccess", page).checked(null == user.Policy.EnableRemoteAccess || user.Policy.EnableRemoteAccess), $("#chkEnableSyncTranscoding", page).checked(user.Policy.EnableSyncTranscoding), $("#chkEnableConversion", page).checked(user.Policy.EnableMediaConversion || !1), $("#chkEnableSharing", page).checked(user.Policy.EnablePublicSharing), $("#txtRemoteClientBitrateLimit", page).val(user.Policy.RemoteClientBitrateLimit / 1e6 || ""), loading.hide()
|
||||
}), user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".disabledUserBanner", page).hide(), "Guest" == user.ConnectLinkType ? ($("#fldConnectInfo", page).hide(), $("#txtUserName", page).prop("disabled", "disabled")) : ($("#txtUserName", page).prop("disabled", "").removeAttr("disabled"), $("#fldConnectInfo", page).show()), $(".lnkEditUserPreferences", page).attr("href", "mypreferencesmenu.html?userId=" + user.Id), libraryMenu.setTitle(user.Name), page.querySelector(".username").innerHTML = user.Name, $("#txtUserName", page).val(user.Name), $("#chkIsAdmin", page).checked(user.Policy.IsAdministrator), $("#chkDisabled", page).checked(user.Policy.IsDisabled), $("#chkIsHidden", page).checked(user.Policy.IsHidden), $("#chkRemoteControlSharedDevices", page).checked(user.Policy.EnableSharedDeviceControl), $("#chkEnableRemoteControlOtherUsers", page).checked(user.Policy.EnableRemoteControlOfOtherUsers), $("#chkEnableDownloading", page).checked(user.Policy.EnableContentDownloading), $("#chkManageLiveTv", page).checked(user.Policy.EnableLiveTvManagement), $("#chkEnableLiveTvAccess", page).checked(user.Policy.EnableLiveTvAccess), $("#chkEnableMediaPlayback", page).checked(user.Policy.EnableMediaPlayback), $("#chkEnableAudioPlaybackTranscoding", page).checked(user.Policy.EnableAudioPlaybackTranscoding), $("#chkEnableVideoPlaybackTranscoding", page).checked(user.Policy.EnableVideoPlaybackTranscoding), $("#chkEnableVideoPlaybackRemuxing", page).checked(user.Policy.EnablePlaybackRemuxing), $("#chkRemoteAccess", page).checked(null == user.Policy.EnableRemoteAccess || user.Policy.EnableRemoteAccess), $("#chkEnableSyncTranscoding", page).checked(user.Policy.EnableSyncTranscoding), $("#chkEnableConversion", page).checked(user.Policy.EnableMediaConversion || !1), $("#chkEnableSharing", page).checked(user.Policy.EnablePublicSharing), $("#txtRemoteClientBitrateLimit", page).val(user.Policy.RemoteClientBitrateLimit / 1e6 || ""), loading.hide()
|
||||
}
|
||||
|
||||
function onSaveComplete(page, user) {
|
||||
|
@ -29,10 +29,9 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em
|
||||
Name: form.querySelector("#txtUsername").value,
|
||||
Password: form.querySelector("#txtManualPassword").value
|
||||
},
|
||||
url: apiClient.getUrl("Startup/User"),
|
||||
dataType: "json"
|
||||
url: apiClient.getUrl("Startup/User")
|
||||
}).then(onUpdateUserComplete, function(response) {
|
||||
response && response.status;
|
||||
console.log(response);
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user