mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
connect updates
This commit is contained in:
parent
90082ed4bc
commit
83d7b945d7
25 changed files with 686 additions and 312 deletions
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>${TitleSignIn}</title>
|
<title>${TitleSignIn}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="serverlessPage">
|
||||||
<div id="connectLoginPage" data-role="page" class="page standalonePage connectLoginPage">
|
<div id="connectLoginPage" data-role="page" class="page standalonePage connectLoginPage">
|
||||||
|
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
|
|
|
@ -12,16 +12,16 @@
|
||||||
margin-left: .5em;
|
margin-left: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.libraryPage {
|
.libraryPage[data-theme='b'] {
|
||||||
background-color: #202020;
|
background-color: #202020;
|
||||||
}
|
}
|
||||||
|
|
||||||
.backdropPage {
|
.backdropPage {
|
||||||
background-color: rgba(15, 15,15, .86) !important;
|
background-color: rgba(20, 20,20, .86) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.backdropPage:not(.lightBackdropPage) {
|
.backdropPage:not(.lightBackdropPage) {
|
||||||
background-color: rgba(15, 15,15, .94) !important;
|
background-color: rgba(20, 20,20, .94) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.backdropContainer {
|
.backdropContainer {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.libraryPage:not(.metadataEditorPage):not(.noSecondaryNavPage) {
|
.libraryPage:not(.metadataEditorPage):not(.noSecondaryNavPage) {
|
||||||
padding-top: 100px !important;
|
padding-top: 95px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.libraryMenuDivider {
|
.libraryMenuDivider {
|
||||||
|
@ -149,23 +149,19 @@
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
top: 0;
|
top: 0;
|
||||||
background-image: linear-gradient(#262626,#111);
|
|
||||||
border-bottom: 1px solid #111;
|
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
border-left: 0;
|
border-left: 0;
|
||||||
border-right: 0;
|
border-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.libraryViewNav {
|
.libraryViewNav {
|
||||||
height: 48px;
|
height: 45px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 0;
|
right: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 51px;
|
top: 50px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
background-image: linear-gradient(#1a1a1a,#1a1a1a);
|
|
||||||
border-bottom: 1px solid #111;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
@ -175,6 +171,14 @@
|
||||||
overflow: -moz-scrollbars-none;
|
overflow: -moz-scrollbars-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.viewMenuBar {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.libraryViewNav {
|
||||||
|
background-color: #111;
|
||||||
|
}
|
||||||
|
|
||||||
.libraryViewNav::-webkit-scrollbar {
|
.libraryViewNav::-webkit-scrollbar {
|
||||||
height: 0 !important;
|
height: 0 !important;
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -182,7 +186,7 @@
|
||||||
|
|
||||||
.viewMenuLink {
|
.viewMenuLink {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #ccc !important;
|
color: #eee !important;
|
||||||
padding: 7px .5em 6px;
|
padding: 7px .5em 6px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -213,13 +217,13 @@
|
||||||
|
|
||||||
.viewMenuTextLink {
|
.viewMenuTextLink {
|
||||||
display: block;
|
display: block;
|
||||||
padding: .6em .5em .6em 38px !important;
|
padding: .65em .5em .55em 38px !important;
|
||||||
font-size: 15px;
|
font-size: 14px;
|
||||||
font-weight: 300 !important;
|
font-weight: 300 !important;
|
||||||
font-family: Roboto;
|
font-family: Roboto;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 14px 14px;
|
background-size: 13px 13px;
|
||||||
background-position: 13px center;
|
background-position: 12px center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.musicViewMenu {
|
.musicViewMenu {
|
||||||
|
@ -227,7 +231,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.homeViewMenu {
|
.homeViewMenu {
|
||||||
background-image: url(images/items/folders/home.png);
|
background-image: url(images/mblogoicon.png);
|
||||||
|
background-size: 39px 26px;
|
||||||
|
background-position: 10px center;
|
||||||
|
padding-left: 60px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tvshowsViewMenu, .livetvViewMenu {
|
.tvshowsViewMenu, .livetvViewMenu {
|
||||||
|
@ -315,7 +322,7 @@
|
||||||
margin: 0 0;
|
margin: 0 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
border-bottom: 5px solid transparent;
|
border-bottom: 4px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.libraryViewNav a:not(.ui-btn-active):hover {
|
.libraryViewNav a:not(.ui-btn-active):hover {
|
||||||
|
@ -324,17 +331,7 @@
|
||||||
|
|
||||||
.libraryViewNavLinkContent {
|
.libraryViewNavLinkContent {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 2px 15px 2px 15px;
|
padding: 1px 13px 1px 13px;
|
||||||
}
|
|
||||||
|
|
||||||
.libraryViewNav a + a .libraryViewNavLinkContent {
|
|
||||||
padding-left: 17px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.libraryViewNav a + a .libraryViewNavLinkContent {
|
|
||||||
border-left: 1px solid #333;
|
|
||||||
position: relative;
|
|
||||||
left: -2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (max-width: 500px) {
|
@media all and (max-width: 500px) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
-moz-border-radius: 2px;
|
-moz-border-radius: 2px;
|
||||||
-webkit-border-radius: 2px;
|
-webkit-border-radius: 2px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: 4px 12px 5px;
|
padding: 4px 12px 4px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
|
|
|
@ -64,10 +64,7 @@ body {
|
||||||
|
|
||||||
h1, h1 a {
|
h1, h1 a {
|
||||||
font-weight: 300 !important;
|
font-weight: 300 !important;
|
||||||
}
|
font-size: 24px;
|
||||||
|
|
||||||
.libraryPage h1, .libraryPage h1 a {
|
|
||||||
font-weight: 100 !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-loader h1 {
|
.ui-loader h1 {
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
|
|
||||||
var page = this;
|
var page = this;
|
||||||
|
|
||||||
ApiClient.getSystemInfo().done(function (info) {
|
|
||||||
|
|
||||||
var elem = $('#appVersionNumber', page);
|
var elem = $('#appVersionNumber', page);
|
||||||
|
|
||||||
elem.html(elem.html().replace('{0}', info.Version));
|
elem.html(elem.html().replace('{0}', ConnectionManager.appVersion()));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery, document);
|
})(jQuery, document);
|
|
@ -2,89 +2,41 @@
|
||||||
|
|
||||||
function onLoggedIn() {
|
function onLoggedIn() {
|
||||||
|
|
||||||
ConnectionManager.getServers().done(function (result) {
|
ConnectionManager.connect().done(function (result) {
|
||||||
|
|
||||||
if (result.length) {
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
connectToServerInstance(result[0]);
|
switch (result.State) {
|
||||||
|
|
||||||
} else {
|
case MediaBrowser.ConnectionState.Unavilable:
|
||||||
Dashboard.alert('Coming soon');
|
// Login succeeded so this should never happen
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.ServerSelection:
|
||||||
|
window.location = 'selectserver.html';
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.ServerSignIn:
|
||||||
|
// This should never happen in connect mode
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.SignedIn:
|
||||||
|
window.location = 'selectserver.html';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectToServerInstance(server) {
|
|
||||||
|
|
||||||
connectToServerAtUrl(server, server.Url).fail(function () {
|
|
||||||
|
|
||||||
if (server.LocalAddress) {
|
|
||||||
connectToServerAtUrl(server, server.LocalAddress).fail(showServerConnectionFailure);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
showServerConnectionFailure();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showServerConnectionFailure() {
|
|
||||||
alert('Unable to communicate with your server.');
|
|
||||||
}
|
|
||||||
|
|
||||||
function connectToServerAtUrl(server, url) {
|
|
||||||
|
|
||||||
var exchangeToken = server.AccessKey;
|
|
||||||
|
|
||||||
return $.ajax({
|
|
||||||
|
|
||||||
type: "GET",
|
|
||||||
url: url + "/mediabrowser/Connect/Exchange?format=json&ConnectUserId=" + ConnectionManager.connectUserId(),
|
|
||||||
dataType: "json",
|
|
||||||
|
|
||||||
error: function () {
|
|
||||||
// Don't show normal dashboard errors
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
"X-MediaBrowser-Token": exchangeToken
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}).done(function (result) {
|
|
||||||
|
|
||||||
Dashboard.serverAddress(url);
|
|
||||||
Dashboard.setCurrentUser(result.LocalUserId, result.AccessToken);
|
|
||||||
|
|
||||||
window.location = 'index.html';
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function login(page, username, password) {
|
function login(page, username, password) {
|
||||||
|
|
||||||
var md5 = CryptoJS.MD5(password).toString();
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
$.ajax({
|
ConnectionManager.loginToConnect(username, password).done(function () {
|
||||||
type: "POST",
|
|
||||||
url: "https://connect.mediabrowser.tv/service/user/authenticate",
|
|
||||||
data: {
|
|
||||||
userName: username,
|
|
||||||
password: md5
|
|
||||||
},
|
|
||||||
dataType: "json",
|
|
||||||
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
||||||
|
|
||||||
error: function () {
|
|
||||||
// Don't show normal dashboard errors
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}).done(function (result) {
|
|
||||||
|
|
||||||
ConnectionManager.onConnectAuthenticated(result);
|
|
||||||
|
|
||||||
onLoggedIn();
|
onLoggedIn();
|
||||||
|
|
||||||
}).fail(function (result) {
|
}).fail(function () {
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: Globalize.translate('MessageInvalidUser'),
|
message: Globalize.translate('MessageInvalidUser'),
|
||||||
|
|
|
@ -422,7 +422,7 @@
|
||||||
|
|
||||||
closePlayMenu();
|
closePlayMenu();
|
||||||
|
|
||||||
var html = '<div data-role="popup" class="externalPlayerFlyout" data-history="false" data-theme="a">';
|
var html = '<div data-role="popup" class="externalPlayerFlyout" data-theme="a">';
|
||||||
|
|
||||||
html += '<ul data-role="listview" style="min-width: 200px;">';
|
html += '<ul data-role="listview" style="min-width: 200px;">';
|
||||||
html += '<li data-role="list-divider" style="padding: 1em;text-align:center;">' + Globalize.translate('HeaderSelectExternalPlayer') + '</li>';
|
html += '<li data-role="list-divider" style="padding: 1em;text-align:center;">' + Globalize.translate('HeaderSelectExternalPlayer') + '</li>';
|
||||||
|
|
|
@ -438,7 +438,7 @@
|
||||||
loadlibraryButtons: loadlibraryButtons
|
loadlibraryButtons: loadlibraryButtons
|
||||||
};
|
};
|
||||||
|
|
||||||
})(jQuery, document, ApiClient);
|
})(jQuery, document);
|
||||||
|
|
||||||
(function ($, document) {
|
(function ($, document) {
|
||||||
|
|
||||||
|
|
|
@ -904,6 +904,16 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(ApiClient).on('websocketmessage', onWebSocketMessage);
|
function initializeApiClient(apiClient) {
|
||||||
|
$(apiClient).off('websocketmessage.librarylist', onWebSocketMessage).on('websocketmessage.librarylist', onWebSocketMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||||
|
|
||||||
|
initializeApiClient(apiClient);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery, document, window);
|
})(jQuery, document, window);
|
|
@ -28,20 +28,26 @@
|
||||||
|
|
||||||
html += '<div class="viewMenuSecondary">';
|
html += '<div class="viewMenuSecondary">';
|
||||||
|
|
||||||
|
if (user.localUser) {
|
||||||
|
|
||||||
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
|
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
|
||||||
|
|
||||||
html += '<button onclick="Search.showSearchPanel($.mobile.activePage);" type="button" data-role="none" class="headerButton headerButtonRight headerSearchButton"><img src="css/images/headersearch.png" /></button>';
|
html += '<button onclick="Search.showSearchPanel($.mobile.activePage);" type="button" data-role="none" class="headerButton headerButtonRight headerSearchButton"><img src="css/images/headersearch.png" /></button>';
|
||||||
|
} else {
|
||||||
|
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none" style="visibility:hidden;"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">';
|
html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">';
|
||||||
|
|
||||||
var userButtonHeight = 21;
|
var userButtonHeight = 21;
|
||||||
if (user.PrimaryImageTag) {
|
if (user.imageUrl) {
|
||||||
|
|
||||||
var url = ApiClient.getUserImageUrl(user.Id, {
|
var url = user.imageUrl;
|
||||||
height: userButtonHeight,
|
|
||||||
tag: user.PrimaryImageTag,
|
if (user.supportsImageParams) {
|
||||||
type: "Primary"
|
url += "height=" + userButtonHeight;
|
||||||
});
|
}
|
||||||
|
|
||||||
html += '<img src="' + url + '" style="height:' + userButtonHeight + 'px;" />';
|
html += '<img src="' + url + '" style="height:' + userButtonHeight + 'px;" />';
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,7 +56,7 @@
|
||||||
|
|
||||||
html += '</a>';
|
html += '</a>';
|
||||||
|
|
||||||
if (user.Configuration.IsAdministrator) {
|
if (user.canManageServer) {
|
||||||
html += '<a href="dashboard.html" class="headerButton headerButtonRight"><img src="css/images/items/folders/settings.png" /></a>';
|
html += '<a href="dashboard.html" class="headerButton headerButtonRight"><img src="css/images/items/folders/settings.png" /></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +124,17 @@
|
||||||
|
|
||||||
function updateLibraryMenu(panel) {
|
function updateLibraryMenu(panel) {
|
||||||
|
|
||||||
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
|
if (!apiClient) {
|
||||||
|
|
||||||
|
$('.adminMenuOptions').hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var userId = Dashboard.getCurrentUserId();
|
var userId = Dashboard.getCurrentUserId();
|
||||||
|
|
||||||
ApiClient.getUserViews(userId).done(function (result) {
|
apiClient.getUserViews(userId).done(function (result) {
|
||||||
|
|
||||||
var items = result.Items;
|
var items = result.Items;
|
||||||
|
|
||||||
|
@ -166,7 +180,7 @@
|
||||||
|
|
||||||
var requiresLibraryMenuRefresh = false;
|
var requiresLibraryMenuRefresh = false;
|
||||||
|
|
||||||
function getLibraryMenu() {
|
function getLibraryMenu(user) {
|
||||||
|
|
||||||
var panel = $('#libraryPanel');
|
var panel = $('#libraryPanel');
|
||||||
|
|
||||||
|
@ -178,7 +192,10 @@
|
||||||
|
|
||||||
html += '<div style="margin: 0 -1em;">';
|
html += '<div style="margin: 0 -1em;">';
|
||||||
|
|
||||||
html += '<a class="lnkMediaFolder viewMenuLink viewMenuTextLink homeViewMenu" href="index.html">' + Globalize.translate('ButtonHome') + '</a>';
|
var homeHref = ConnectionManager.currentApiClient() ? 'index.html' : 'selectserver.html';
|
||||||
|
|
||||||
|
html += '<a class="lnkMediaFolder viewMenuLink viewMenuTextLink homeViewMenu" href="' + homeHref + '">' + Globalize.translate('ButtonHome') + '</a>';
|
||||||
|
|
||||||
html += '<div class="libraryMenuDivider"></div>';
|
html += '<div class="libraryMenuDivider"></div>';
|
||||||
|
|
||||||
html += getViewsHtml();
|
html += getViewsHtml();
|
||||||
|
@ -364,7 +381,7 @@
|
||||||
var page = this;
|
var page = this;
|
||||||
if (!$('.viewMenuBar').length) {
|
if (!$('.viewMenuBar').length) {
|
||||||
|
|
||||||
Dashboard.getCurrentUser().done(function (user) {
|
ConnectionManager.user().done(function (user) {
|
||||||
|
|
||||||
renderHeader(user);
|
renderHeader(user);
|
||||||
|
|
||||||
|
@ -413,13 +430,20 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function initializeApiClient(apiClient) {
|
||||||
|
$(apiClient).off('websocketmessage.librarymenu', onWebSocketMessage).on('websocketmessage.librarymenu', onWebSocketMessage);
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
$(MediaController).on('playerchange', function () {
|
$(MediaController).on('playerchange', function () {
|
||||||
updateCastIcon();
|
updateCastIcon();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(ApiClient).on('websocketmessage', onWebSocketMessage);
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||||
|
|
||||||
|
initializeApiClient(apiClient);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
})(window, document, jQuery);
|
})(window, document, jQuery);
|
||||||
|
|
|
@ -335,4 +335,4 @@
|
||||||
programs = null;
|
programs = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery, document, ApiClient);
|
})(jQuery, document);
|
|
@ -437,7 +437,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(ApiClient).on("websocketmessage", onWebSocketMessageReceived);
|
|
||||||
|
|
||||||
|
function initializeApiClient(apiClient) {
|
||||||
|
$(apiClient).on("websocketmessage", onWebSocketMessageReceived);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||||
|
|
||||||
|
initializeApiClient(apiClient);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function getTargetsHtml(targets) {
|
function getTargetsHtml(targets) {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
var targets = [{
|
var targets = [{
|
||||||
name: 'My Browser',
|
name: 'My Browser',
|
||||||
id: ApiClient.deviceId(),
|
id: ConnectionManager.deviceId(),
|
||||||
playerName: self.name,
|
playerName: self.name,
|
||||||
playableMediaTypes: ['Audio', 'Video'],
|
playableMediaTypes: ['Audio', 'Video'],
|
||||||
isLocalPlayer: true,
|
isLocalPlayer: true,
|
||||||
|
|
|
@ -10,7 +10,13 @@
|
||||||
|
|
||||||
self.getNotificationsSummary = function () {
|
self.getNotificationsSummary = function () {
|
||||||
|
|
||||||
self.getNotificationsSummaryPromise = self.getNotificationsSummaryPromise || ApiClient.getNotificationSummary(Dashboard.getCurrentUserId());
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
|
if (!apiClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.getNotificationsSummaryPromise = self.getNotificationsSummaryPromise || apiClient.getNotificationSummary(Dashboard.getCurrentUserId());
|
||||||
|
|
||||||
return self.getNotificationsSummaryPromise;
|
return self.getNotificationsSummaryPromise;
|
||||||
};
|
};
|
||||||
|
@ -21,7 +27,13 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.getNotificationsSummary().done(function (summary) {
|
var promise = self.getNotificationsSummary();
|
||||||
|
|
||||||
|
if (!promise) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
promise.done(function (summary) {
|
||||||
|
|
||||||
var item = $('.btnNotificationsInner').removeClass('levelNormal').removeClass('levelWarning').removeClass('levelError').html(summary.UnreadCount);
|
var item = $('.btnNotificationsInner').removeClass('levelNormal').removeClass('levelWarning').removeClass('levelError').html(summary.UnreadCount);
|
||||||
|
|
||||||
|
@ -95,12 +107,16 @@
|
||||||
|
|
||||||
function refreshNotifications(startIndex, limit, elem, btn, showPaging) {
|
function refreshNotifications(startIndex, limit, elem, btn, showPaging) {
|
||||||
|
|
||||||
return ApiClient.getNotifications(Dashboard.getCurrentUserId(), { StartIndex: startIndex, Limit: limit }).done(function (result) {
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
|
if (apiClient) {
|
||||||
|
return apiClient.getNotifications(Dashboard.getCurrentUserId(), { StartIndex: startIndex, Limit: limit }).done(function (result) {
|
||||||
|
|
||||||
listUnreadNotifications(result.Notifications, result.TotalRecordCount, startIndex, limit, elem, btn, showPaging);
|
listUnreadNotifications(result.Notifications, result.TotalRecordCount, startIndex, limit, elem, btn, showPaging);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function listUnreadNotifications(list, totalRecordCount, startIndex, limit, elem, btn, showPaging) {
|
function listUnreadNotifications(list, totalRecordCount, startIndex, limit, elem, btn, showPaging) {
|
||||||
|
|
||||||
|
@ -201,12 +217,15 @@
|
||||||
|
|
||||||
$(document).on('headercreated', function (e) {
|
$(document).on('headercreated', function (e) {
|
||||||
|
|
||||||
|
if (ConnectionManager.currentApiClient()) {
|
||||||
$('<a class="headerButton headerButtonRight btnNotifications" href="#" title="Notifications"><div class="btnNotificationsInner">0</div></a>').insertAfter($('.headerUserButton')).on('click', Notifications.showNotificationsFlyout);
|
$('<a class="headerButton headerButtonRight btnNotifications" href="#" title="Notifications"><div class="btnNotificationsInner">0</div></a>').insertAfter($('.headerUserButton')).on('click', Notifications.showNotificationsFlyout);
|
||||||
|
|
||||||
Notifications.updateNotificationCount();
|
Notifications.updateNotificationCount();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(ApiClient).on("websocketmessage", function (e, msg) {
|
function initializeApiClient(apiClient) {
|
||||||
|
$(apiClient).on("websocketmessage", function (e, msg) {
|
||||||
|
|
||||||
|
|
||||||
if (msg.MessageType === "NotificationUpdated" || msg.MessageType === "NotificationAdded" || msg.MessageType === "NotificationsMarkedRead") {
|
if (msg.MessageType === "NotificationUpdated" || msg.MessageType === "NotificationAdded" || msg.MessageType === "NotificationsMarkedRead") {
|
||||||
|
@ -217,6 +236,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||||
|
|
||||||
|
initializeApiClient(apiClient);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery, document, Dashboard, LibraryBrowser);
|
})(jQuery, document, Dashboard, LibraryBrowser);
|
|
@ -19,6 +19,18 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showNoConfigurationMessage: function() {
|
||||||
|
Dashboard.alert({
|
||||||
|
message: Globalize.translate('NoPluginConfigurationMessage')
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
showConnectMessage: function () {
|
||||||
|
Dashboard.alert({
|
||||||
|
message: Globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
populateList: function (page, plugins, pluginConfigurationPages) {
|
populateList: function (page, plugins, pluginConfigurationPages) {
|
||||||
|
|
||||||
plugins = plugins.sort(function (plugin1, plugin2) {
|
plugins = plugins.sort(function (plugin1, plugin2) {
|
||||||
|
@ -39,10 +51,14 @@
|
||||||
|
|
||||||
html += "<li>";
|
html += "<li>";
|
||||||
|
|
||||||
if (configPage) {
|
if (Dashboard.isConnectMode()) {
|
||||||
|
html += "<a onclick='PluginsPage.showConnectMessage();' href='#'>";
|
||||||
|
}
|
||||||
|
else if (configPage) {
|
||||||
html += "<a href='" + Dashboard.getConfigurationPageUrl(configPage.Name) + "'>";
|
html += "<a href='" + Dashboard.getConfigurationPageUrl(configPage.Name) + "'>";
|
||||||
} else {
|
}
|
||||||
html += "<a onclick='Dashboard.alert(\"" + Globalize.translate('NoPluginConfigurationMessage') + "\");' href='#'>";
|
else {
|
||||||
|
html += "<a onclick='PluginsPage.showNoConfigurationMessage();' href='#'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "<h3>" + plugin.Name + "</h3>";
|
html += "<h3>" + plugin.Name + "</h3>";
|
||||||
|
|
|
@ -164,7 +164,10 @@
|
||||||
|
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
|
|
||||||
ApiClient.getSessions().done(function (sessions) {
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
|
if (apiClient) {
|
||||||
|
apiClient.getSessions().done(function (sessions) {
|
||||||
|
|
||||||
var currentTargetId = MediaController.getPlayerInfo().id;
|
var currentTargetId = MediaController.getPlayerInfo().id;
|
||||||
|
|
||||||
|
@ -180,6 +183,9 @@
|
||||||
|
|
||||||
deferred.resolveWith(null, [session]);
|
deferred.resolveWith(null, [session]);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
deferred.resolveWith(null, [{}]);
|
||||||
|
}
|
||||||
|
|
||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
};
|
};
|
||||||
|
@ -236,11 +242,14 @@
|
||||||
ControllableByUserId: Dashboard.getCurrentUserId()
|
ControllableByUserId: Dashboard.getCurrentUserId()
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiClient.getSessions(sessionQuery).done(function (sessions) {
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
|
if (apiClient) {
|
||||||
|
apiClient.getSessions(sessionQuery).done(function (sessions) {
|
||||||
|
|
||||||
var targets = sessions.filter(function (s) {
|
var targets = sessions.filter(function (s) {
|
||||||
|
|
||||||
return s.DeviceId != ApiClient.deviceId();
|
return s.DeviceId != apiClient.deviceId();
|
||||||
|
|
||||||
}).map(function (s) {
|
}).map(function (s) {
|
||||||
return {
|
return {
|
||||||
|
@ -261,6 +270,9 @@
|
||||||
|
|
||||||
deferred.reject();
|
deferred.reject();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
deferred.resolveWith(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
};
|
};
|
||||||
|
@ -290,6 +302,8 @@
|
||||||
|
|
||||||
function onWebSocketMessageReceived(e, msg) {
|
function onWebSocketMessageReceived(e, msg) {
|
||||||
|
|
||||||
|
var apiClient = this;
|
||||||
|
|
||||||
if (msg.MessageType === "Sessions") {
|
if (msg.MessageType === "Sessions") {
|
||||||
|
|
||||||
var currentTargetId = MediaController.getPlayerInfo().id;
|
var currentTargetId = MediaController.getPlayerInfo().id;
|
||||||
|
@ -314,7 +328,7 @@
|
||||||
}
|
}
|
||||||
else if (msg.MessageType === "PlaybackStart") {
|
else if (msg.MessageType === "PlaybackStart") {
|
||||||
|
|
||||||
if (msg.Data.DeviceId != ApiClient.deviceId()) {
|
if (msg.Data.DeviceId != apiClient.deviceId()) {
|
||||||
if (MediaController.getPlayerInfo().id == msg.Data.Id) {
|
if (MediaController.getPlayerInfo().id == msg.Data.Id) {
|
||||||
firePlaybackEvent('playbackstart', msg.Data);
|
firePlaybackEvent('playbackstart', msg.Data);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +336,7 @@
|
||||||
}
|
}
|
||||||
else if (msg.MessageType === "PlaybackStopped") {
|
else if (msg.MessageType === "PlaybackStopped") {
|
||||||
|
|
||||||
if (msg.Data.DeviceId != ApiClient.deviceId()) {
|
if (msg.Data.DeviceId != apiClient.deviceId()) {
|
||||||
if (MediaController.getPlayerInfo().id == msg.Data.Id) {
|
if (MediaController.getPlayerInfo().id == msg.Data.Id) {
|
||||||
firePlaybackEvent('playbackstop', msg.Data);
|
firePlaybackEvent('playbackstop', msg.Data);
|
||||||
}
|
}
|
||||||
|
@ -330,6 +344,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(ApiClient).on("websocketmessage", onWebSocketMessageReceived).on("websocketopen", onWebSocketConnectionChange);
|
|
||||||
|
function initializeApiClient(apiClient) {
|
||||||
|
$(apiClient).on("websocketmessage", onWebSocketMessageReceived).on("websocketopen", onWebSocketConnectionChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||||
|
|
||||||
|
initializeApiClient(apiClient);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(window, document, jQuery);
|
})(window, document, jQuery);
|
120
dashboard-ui/scripts/selectserver.js
Normal file
120
dashboard-ui/scripts/selectserver.js
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
function connectToServer(page, server) {
|
||||||
|
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
ConnectionManager.connectToServer(server).done(function (result) {
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
|
switch (result.State) {
|
||||||
|
|
||||||
|
case MediaBrowser.ConnectionState.Unavilable:
|
||||||
|
showServerConnectionFailure();
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.SignedIn:
|
||||||
|
{
|
||||||
|
var apiClient = result.ApiClient;
|
||||||
|
|
||||||
|
Dashboard.serverAddress(apiClient.serverAddress());
|
||||||
|
Dashboard.setCurrentUser(apiClient.getCurrentUserId(), apiClient.accessToken());
|
||||||
|
window.location = 'index.html';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showServerConnectionFailure() {
|
||||||
|
|
||||||
|
Dashboard.alert({
|
||||||
|
message: Globalize.translate("MessageUnableToConnectToServer"),
|
||||||
|
title: Globalize.translate("HeaderConnectionFailure")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderServers(page, servers) {
|
||||||
|
|
||||||
|
if (servers.length) {
|
||||||
|
$('.noServersMessage', page).hide();
|
||||||
|
} else {
|
||||||
|
$('.noServersMessage', page).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = '<ul data-role="listview" data-inset="true">';
|
||||||
|
|
||||||
|
html += servers.map(function (s) {
|
||||||
|
|
||||||
|
var serverHtml = '';
|
||||||
|
|
||||||
|
serverHtml += '<li>';
|
||||||
|
|
||||||
|
serverHtml += '<a class="lnkServer" data-serverid="' + s.Id + '" href="#">';
|
||||||
|
serverHtml += '<h3>';
|
||||||
|
serverHtml += s.Name;
|
||||||
|
serverHtml += '</h3>';
|
||||||
|
serverHtml += '</a>';
|
||||||
|
|
||||||
|
serverHtml += '</li>';
|
||||||
|
|
||||||
|
return serverHtml;
|
||||||
|
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
html += '</ul>';
|
||||||
|
|
||||||
|
var elem = $('.serverList', page).html(html).trigger('create');
|
||||||
|
|
||||||
|
$('.lnkServer', elem).on('click', function () {
|
||||||
|
|
||||||
|
var id = this.getAttribute('data-serverid');
|
||||||
|
var server = servers.filter(function (s) {
|
||||||
|
return s.Id == id;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
connectToServer(page, server);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPage(page) {
|
||||||
|
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
ConnectionManager.getServers().done(function (servers) {
|
||||||
|
|
||||||
|
renderServers(page, servers);
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('pageshow', "#selectServerPage", function () {
|
||||||
|
|
||||||
|
var page = this;
|
||||||
|
|
||||||
|
loadPage(page);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
window.SelectServerPage = {
|
||||||
|
|
||||||
|
onServerAddressEntrySubmit: function () {
|
||||||
|
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
var form = this;
|
||||||
|
var page = $(form).parents('.page');
|
||||||
|
|
||||||
|
|
||||||
|
// Disable default form submission
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
|
@ -77,7 +77,7 @@ var Dashboard = {
|
||||||
|
|
||||||
var userId = Dashboard.getCurrentUserId();
|
var userId = Dashboard.getCurrentUserId();
|
||||||
|
|
||||||
Dashboard.getUserPromise = ApiClient.getUser(userId).fail(Dashboard.logout);
|
Dashboard.getUserPromise = ConnectionManager.currentApiClient().getUser(userId).fail(Dashboard.logout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Dashboard.getUserPromise;
|
return Dashboard.getUserPromise;
|
||||||
|
@ -108,7 +108,7 @@ var Dashboard = {
|
||||||
|
|
||||||
var address = store.getItem('serverAddress');
|
var address = store.getItem('serverAddress');
|
||||||
|
|
||||||
if (!address) {
|
if (!address && !Dashboard.isConnectMode()) {
|
||||||
var loc = window.location;
|
var loc = window.location;
|
||||||
|
|
||||||
address = loc.protocol + '//' + loc.hostname;
|
address = loc.protocol + '//' + loc.hostname;
|
||||||
|
@ -146,7 +146,11 @@ var Dashboard = {
|
||||||
store.setItem("userId", userId);
|
store.setItem("userId", userId);
|
||||||
store.setItem("token", token);
|
store.setItem("token", token);
|
||||||
|
|
||||||
ApiClient.setCurrentUserId(userId, token);
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
|
if (apiClient) {
|
||||||
|
apiClient.setCurrentUserId(userId, token);
|
||||||
|
}
|
||||||
Dashboard.getUserPromise = null;
|
Dashboard.getUserPromise = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -157,7 +161,6 @@ var Dashboard = {
|
||||||
|
|
||||||
logout: function (logoutWithServer) {
|
logout: function (logoutWithServer) {
|
||||||
|
|
||||||
ConnectionManager.logoutFromConnect();
|
|
||||||
store.removeItem("userId");
|
store.removeItem("userId");
|
||||||
store.removeItem("token");
|
store.removeItem("token");
|
||||||
|
|
||||||
|
@ -168,7 +171,7 @@ var Dashboard = {
|
||||||
if (logoutWithServer === false) {
|
if (logoutWithServer === false) {
|
||||||
window.location = loginPage;
|
window.location = loginPage;
|
||||||
} else {
|
} else {
|
||||||
ApiClient.logout().done(function () {
|
ConnectionManager.logout().done(function () {
|
||||||
window.location = loginPage;
|
window.location = loginPage;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -529,30 +532,28 @@ var Dashboard = {
|
||||||
|
|
||||||
showUserFlyout: function (context) {
|
showUserFlyout: function (context) {
|
||||||
|
|
||||||
Dashboard.getCurrentUser().done(function (user) {
|
ConnectionManager.user().done(function (user) {
|
||||||
|
|
||||||
var html = '<div data-role="panel" data-position="right" data-display="overlay" id="userFlyout" data-position-fixed="true" data-theme="a">';
|
var html = '<div data-role="panel" data-position="right" data-display="overlay" id="userFlyout" data-position-fixed="true" data-theme="a">';
|
||||||
|
|
||||||
html += '<h3>';
|
html += '<h3>';
|
||||||
|
|
||||||
if (user.PrimaryImageTag) {
|
if (user.imageUrl) {
|
||||||
var imageUrl = ApiClient.getUserImageUrl(user.Id, {
|
var url = user.imageUrl;
|
||||||
|
|
||||||
width: 28,
|
if (user.supportsImageParams) {
|
||||||
tag: user.PrimaryImageTag,
|
url += "width=" + 28;
|
||||||
type: "Primary"
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
html += '<img style="max-width:28px;vertical-align:middle;margin-right:5px;" src="' + imageUrl + '" />';
|
|
||||||
}
|
}
|
||||||
html += user.Name;
|
|
||||||
|
html += '<img style="max-width:28px;vertical-align:middle;margin-right:5px;" src="' + url + '" />';
|
||||||
|
}
|
||||||
|
html += user.name;
|
||||||
html += '</h3>';
|
html += '</h3>';
|
||||||
|
|
||||||
html += '<form>';
|
html += '<form>';
|
||||||
|
|
||||||
if (user.Configuration.EnableUserPreferenceAccess) {
|
if (user.localUser && user.localUser.Configuration.EnableUserPreferenceAccess) {
|
||||||
html += '<p><a data-mini="true" data-role="button" href="mypreferencesdisplay.html?userId=' + user.Id + '" data-icon="gear">' + Globalize.translate('ButtonMyPreferences') + '</button></a>';
|
html += '<p><a data-mini="true" data-role="button" href="mypreferencesdisplay.html?userId=' + user.localUser.Id + '" data-icon="gear">' + Globalize.translate('ButtonMyPreferences') + '</button></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '<p><button data-mini="true" type="button" onclick="Dashboard.logout();" data-icon="lock">' + Globalize.translate('ButtonSignOut') + '</button></p>';
|
html += '<p><button data-mini="true" type="button" onclick="Dashboard.logout();" data-icon="lock">' + Globalize.translate('ButtonSignOut') + '</button></p>';
|
||||||
|
@ -633,10 +634,6 @@ var Dashboard = {
|
||||||
|
|
||||||
ensureToolsMenu: function (page, user) {
|
ensureToolsMenu: function (page, user) {
|
||||||
|
|
||||||
if (!page.hasClass('type-interior')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sidebar = $('.toolsSidebar', page);
|
var sidebar = $('.toolsSidebar', page);
|
||||||
|
|
||||||
if (!sidebar.length) {
|
if (!sidebar.length) {
|
||||||
|
@ -785,16 +782,6 @@ var Dashboard = {
|
||||||
ApiClient.openWebSocket();
|
ApiClient.openWebSocket();
|
||||||
},
|
},
|
||||||
|
|
||||||
onWebSocketOpened: function () {
|
|
||||||
|
|
||||||
ApiClient.reportCapabilities({
|
|
||||||
PlayableMediaTypes: "Audio,Video",
|
|
||||||
|
|
||||||
SupportedCommands: Dashboard.getSupportedRemoteCommands().join(',')
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
processGeneralCommand: function (cmd) {
|
processGeneralCommand: function (cmd) {
|
||||||
|
|
||||||
// Full list
|
// Full list
|
||||||
|
@ -1189,6 +1176,11 @@ var Dashboard = {
|
||||||
"DisplayMessage"
|
"DisplayMessage"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
isServerlessPage: function() {
|
||||||
|
var url = getWindowUrl().toLowerCase();
|
||||||
|
return url.indexOf('connectlogin.html') != -1 || url.indexOf('selectserver.html') != -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1231,43 +1223,57 @@ var Dashboard = {
|
||||||
alert(Globalize.translate('MessageBrowserDoesNotSupportWebSockets'));
|
alert(Globalize.translate('MessageBrowserDoesNotSupportWebSockets'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initializeApiClient(apiClient) {
|
||||||
|
|
||||||
|
$(apiClient).off('.dashboard').on("websocketmessage.dashboard", Dashboard.onWebSocketMessageReceived);
|
||||||
|
|
||||||
|
// TODO: Improve with http://webpjs.appspot.com/
|
||||||
|
apiClient.supportsWebP($.browser.chrome);
|
||||||
|
}
|
||||||
|
|
||||||
var appName = "Dashboard";
|
var appName = "Dashboard";
|
||||||
var appVersion = window.dashboardVersion;
|
var appVersion = window.dashboardVersion;
|
||||||
var deviceName = generateDeviceName();
|
var deviceName = generateDeviceName();
|
||||||
var deviceId = MediaBrowser.ApiClient.generateDeviceId();
|
var deviceId = MediaBrowser.ApiClient.generateDeviceId();
|
||||||
|
var credentialProvider = new MediaBrowser.CredentialProvider();
|
||||||
|
|
||||||
window.ApiClient = new MediaBrowser.ApiClient(Dashboard.serverAddress(), appName, appVersion, deviceName, deviceId);
|
var capabilities = {
|
||||||
window.ConnectionManager = new MediaBrowser.ConnectionManager(new MediaBrowser.CredentialProvider(), appName, appVersion, deviceName, deviceId);
|
PlayableMediaTypes: "Audio,Video",
|
||||||
|
|
||||||
$(ApiClient).on("websocketopen", Dashboard.onWebSocketOpened)
|
SupportedCommands: Dashboard.getSupportedRemoteCommands().join(',')
|
||||||
.on("websocketmessage", Dashboard.onWebSocketMessageReceived);
|
};
|
||||||
|
|
||||||
// TODO: Improve with http://webpjs.appspot.com/
|
window.ConnectionManager = new MediaBrowser.ConnectionManager(credentialProvider, appName, appVersion, deviceName, deviceId, capabilities);
|
||||||
ApiClient.supportsWebP($.browser.chrome);
|
if (Dashboard.isConnectMode()) {
|
||||||
|
|
||||||
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||||
|
|
||||||
|
initializeApiClient(apiClient);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Dashboard.serverAddress() && Dashboard.getCurrentUserId() && Dashboard.getAccessToken() && !Dashboard.isServerlessPage()) {
|
||||||
|
window.ApiClient = new MediaBrowser.ApiClient(Dashboard.serverAddress(), appName, appVersion, deviceName, deviceId, capabilities);
|
||||||
|
|
||||||
ApiClient.setCurrentUserId(Dashboard.getCurrentUserId(), Dashboard.getAccessToken());
|
ApiClient.setCurrentUserId(Dashboard.getCurrentUserId(), Dashboard.getAccessToken());
|
||||||
|
|
||||||
//test();
|
initializeApiClient(ApiClient);
|
||||||
|
|
||||||
|
ConnectionManager.addApiClient(ApiClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
window.ApiClient = new MediaBrowser.ApiClient(Dashboard.serverAddress(), appName, appVersion, deviceName, deviceId, capabilities);
|
||||||
|
|
||||||
|
ApiClient.setCurrentUserId(Dashboard.getCurrentUserId(), Dashboard.getAccessToken());
|
||||||
|
|
||||||
|
initializeApiClient(ApiClient);
|
||||||
|
|
||||||
|
ConnectionManager.addApiClient(ApiClient);
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function test() {
|
|
||||||
|
|
||||||
ConnectionManager.loginToConnect("luke", "ac501ac7111a1e5").done(function (result) {
|
|
||||||
|
|
||||||
var promise = ConnectionManager.connect();
|
|
||||||
|
|
||||||
promise.done(function (r) {
|
|
||||||
alert(JSON.stringify(r));
|
|
||||||
|
|
||||||
}).fail(function() {
|
|
||||||
|
|
||||||
alert('fail');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
var videoPlayerHtml = '<div id="mediaPlayer" data-theme="b" class="ui-bar-b" style="display: none;">';
|
var videoPlayerHtml = '<div id="mediaPlayer" data-theme="b" class="ui-bar-b" style="display: none;">';
|
||||||
|
@ -1352,11 +1358,13 @@ $(function () {
|
||||||
|
|
||||||
$(window).on("beforeunload", function () {
|
$(window).on("beforeunload", function () {
|
||||||
|
|
||||||
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
// Close the connection gracefully when possible
|
// Close the connection gracefully when possible
|
||||||
if (ApiClient.isWebSocketOpen() && !MediaPlayer.isPlaying()) {
|
if (apiClient && apiClient.isWebSocketOpen() && !MediaPlayer.isPlaying()) {
|
||||||
|
|
||||||
console.log('Sending close web socket command');
|
console.log('Sending close web socket command');
|
||||||
ApiClient.closeWebSocket();
|
apiClient.closeWebSocket();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1397,19 +1405,28 @@ $(document).on('pagebeforeshow', ".page", function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var apiClient = ConnectionManager.currentApiClient();
|
||||||
|
|
||||||
if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) {
|
if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) {
|
||||||
|
|
||||||
|
if (apiClient) {
|
||||||
Dashboard.getCurrentUser().done(function (user) {
|
Dashboard.getCurrentUser().done(function (user) {
|
||||||
|
|
||||||
if (!user.Configuration.IsAdministrator && page.hasClass('type-interior') && !page.hasClass('publicUserPage')) {
|
var isSettingsPage = page.hasClass('type-interior');
|
||||||
|
|
||||||
|
if (!user.Configuration.IsAdministrator && isSettingsPage) {
|
||||||
window.location.replace("index.html");
|
window.location.replace("index.html");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSettingsPage) {
|
||||||
Dashboard.ensureToolsMenu(page, user);
|
Dashboard.ensureToolsMenu(page, user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Dashboard.ensureHeader(page);
|
Dashboard.ensureHeader(page);
|
||||||
Dashboard.ensurePageTitle(page);
|
Dashboard.ensurePageTitle(page);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -1425,7 +1442,7 @@ $(document).on('pagebeforeshow', ".page", function () {
|
||||||
Dashboard.ensurePageTitle(page);
|
Dashboard.ensurePageTitle(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ApiClient.isWebSocketOpen()) {
|
if (apiClient && !apiClient.isWebSocketOpen()) {
|
||||||
Dashboard.refreshSystemInfoFromServer();
|
Dashboard.refreshSystemInfoFromServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
$('.userMenu', page).popup("close").remove();
|
$('.userMenu', page).popup("close").remove();
|
||||||
|
|
||||||
var html = '<div data-role="popup" class="userMenu" data-history="false" data-theme="a">';
|
var html = '<div data-role="popup" class="userMenu" data-theme="a">';
|
||||||
|
|
||||||
html += '<ul data-role="listview" style="min-width: 180px;">';
|
html += '<ul data-role="listview" style="min-width: 180px;">';
|
||||||
html += '<li data-role="list-divider">' + Globalize.translate('HeaderMenu') + '</li>';
|
html += '<li data-role="list-divider">' + Globalize.translate('HeaderMenu') + '</li>';
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
|
|
||||||
$('.userMenu', page).popup("close").remove();
|
$('.userMenu', page).popup("close").remove();
|
||||||
|
|
||||||
var html = '<div data-role="popup" class="userMenu" data-history="false" data-theme="a">';
|
var html = '<div data-role="popup" class="userMenu" data-theme="a">';
|
||||||
|
|
||||||
html += '<ul data-role="listview" style="min-width: 180px;">';
|
html += '<ul data-role="listview" style="min-width: 180px;">';
|
||||||
html += '<li data-role="list-divider">' + Globalize.translate('HeaderMenu') + '</li>';
|
html += '<li data-role="list-divider">' + Globalize.translate('HeaderMenu') + '</li>';
|
||||||
|
|
24
dashboard-ui/selectserver.html
Normal file
24
dashboard-ui/selectserver.html
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>${TitleMediaBrowser}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="selectServerPage" data-role="page" class="page libraryPage" data-theme="b">
|
||||||
|
|
||||||
|
<div data-role="content">
|
||||||
|
|
||||||
|
<div class="readOnlyContent" style="margin: 0 auto;">
|
||||||
|
<h1>${HeaderSelectServer}</h1>
|
||||||
|
|
||||||
|
<div class="serverList"></div>
|
||||||
|
<br />
|
||||||
|
<div class="noServersMessage" style="display:none;">
|
||||||
|
${MessageNoServersAvailableToConnect}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -16,7 +16,7 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
Remote: 1
|
Remote: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
return function (credentialProvider, appName, applicationVersion, deviceName, deviceId) {
|
return function (credentialProvider, appName, applicationVersion, deviceName, deviceId, capabilities) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var apiClients = [];
|
var apiClients = [];
|
||||||
|
@ -77,6 +77,34 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
return connectUser;
|
return connectUser;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.appVersion = function() {
|
||||||
|
return applicationVersion;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.deviceId = function () {
|
||||||
|
return deviceId;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.currentApiClient = function () {
|
||||||
|
|
||||||
|
return apiClients[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
self.addApiClient = function (apiClient) {
|
||||||
|
|
||||||
|
apiClients.push(apiClient);
|
||||||
|
|
||||||
|
apiClient.getPublicSystemInfo().done(function (systemInfo) {
|
||||||
|
|
||||||
|
var server = {};
|
||||||
|
updateServerInfo(server, systemInfo);
|
||||||
|
|
||||||
|
apiClient.serverInfo(server);
|
||||||
|
$(this).trigger('apiclientcreated', [apiClient]);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
function onConnectAuthenticated(user) {
|
function onConnectAuthenticated(user) {
|
||||||
|
|
||||||
connectUser = user;
|
connectUser = user;
|
||||||
|
@ -91,23 +119,27 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
var url = connectionMode == MediaBrowser.ConnectionMode.Local ? server.LocalAddress : server.RemoteAddress;
|
var url = connectionMode == MediaBrowser.ConnectionMode.Local ? server.LocalAddress : server.RemoteAddress;
|
||||||
|
|
||||||
apiClient = new MediaBrowser.ApiClient(url, appName, applicationVersion, deviceName, deviceId);
|
apiClient = new MediaBrowser.ApiClient(url, appName, applicationVersion, deviceName, deviceId, capabilities);
|
||||||
|
|
||||||
apiClients.push(apiClient);
|
apiClients.push(apiClient);
|
||||||
|
|
||||||
|
apiClient.serverInfo(server);
|
||||||
|
|
||||||
$(apiClient).on('authenticated', function (e, result) {
|
$(apiClient).on('authenticated', function (e, result) {
|
||||||
onLocalAuthenticated(this, result);
|
onLocalAuthenticated(this, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(this).trigger('apiclientcreated', [apiClient]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!server.accessToken) {
|
if (!server.AccessToken) {
|
||||||
|
|
||||||
apiClient.clearAuthenticationInfo();
|
apiClient.clearAuthenticationInfo();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
apiClient.setAuthenticationInfo(server.accessToken, server.userId);
|
apiClient.setAuthenticationInfo(server.AccessToken, server.UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiClient;
|
return apiClient;
|
||||||
|
@ -152,10 +184,7 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
|
|
||||||
if (self.isLoggedIntoConnect()) {
|
if (self.isLoggedIntoConnect() && !connectUser) {
|
||||||
deferred.resolveWith(null, [[]]);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
getConnectUser(credentials.ConnectUserId, credentials.ConnectAccessToken).done(function (user) {
|
getConnectUser(credentials.ConnectUserId, credentials.ConnectAccessToken).done(function (user) {
|
||||||
|
|
||||||
onConnectAuthenticated(user);
|
onConnectAuthenticated(user);
|
||||||
|
@ -165,6 +194,9 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
deferred.resolveWith(null, [[]]);
|
deferred.resolveWith(null, [[]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
deferred.resolveWith(null, [[]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
|
@ -172,7 +204,7 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
function getConnectUser(userId, accessToken) {
|
function getConnectUser(userId, accessToken) {
|
||||||
|
|
||||||
var url = "https://connect.mediabrowser.tv/service/user?userId=" + userId;
|
var url = "https://connect.mediabrowser.tv/service/user?id=" + userId;
|
||||||
|
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
@ -281,6 +313,79 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getImageUrl(localUser) {
|
||||||
|
|
||||||
|
if (connectUser && connectUser.ImageUrl) {
|
||||||
|
return {
|
||||||
|
url: connectUser.ImageUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (localUser.PrimaryImageTag) {
|
||||||
|
|
||||||
|
var apiClient = self.getApiClient(localUser);
|
||||||
|
|
||||||
|
var url = apiClient.getUserImageUrl(localUser.Id, {
|
||||||
|
tag: localUser.PrimaryImageTag,
|
||||||
|
type: "Primary"
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: url,
|
||||||
|
supportsImageParams: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: null,
|
||||||
|
supportsImageParams: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
self.user = function() {
|
||||||
|
|
||||||
|
var deferred = $.Deferred();
|
||||||
|
|
||||||
|
var localUser;
|
||||||
|
|
||||||
|
function onLocalUserDone() {
|
||||||
|
|
||||||
|
var image = getImageUrl(localUser);
|
||||||
|
|
||||||
|
deferred.resolveWith(null, [
|
||||||
|
{
|
||||||
|
connectUser: connectUser,
|
||||||
|
localUser: localUser,
|
||||||
|
name: connectUser ? connectUser.Name : localUser.Name,
|
||||||
|
canManageServer: localUser && localUser.Configuration.IsAdministrator,
|
||||||
|
imageUrl: image.url,
|
||||||
|
supportsImageParams: image.supportsParams
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEnsureConnectUserDone() {
|
||||||
|
|
||||||
|
var apiClient = self.currentApiClient();
|
||||||
|
if (apiClient && apiClient.getCurrentUserId()) {
|
||||||
|
apiClient.getUser(apiClient.getCurrentUserId()).done(function (u) {
|
||||||
|
localUser = u;
|
||||||
|
}).always(onLocalUserDone);
|
||||||
|
} else {
|
||||||
|
onLocalUserDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var credentials = credentialProvider.credentials();
|
||||||
|
|
||||||
|
if (credentials.ConnectUserId && credentials.ConnectAccessToken) {
|
||||||
|
ensureConnectUser(credentials).always(onEnsureConnectUserDone);
|
||||||
|
} else {
|
||||||
|
onEnsureConnectUserDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
return deferred.promise();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
self.isLoggedIntoConnect = function () {
|
self.isLoggedIntoConnect = function () {
|
||||||
|
|
||||||
return self.connectToken() && self.connectUserId();
|
return self.connectToken() && self.connectUserId();
|
||||||
|
@ -383,6 +488,10 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
var newList = mergeServers(servers, result);
|
var newList = mergeServers(servers, result);
|
||||||
|
|
||||||
|
newList.sort(function (a, b) {
|
||||||
|
return b.DateLastAccessed - a.DateLastAccessed;
|
||||||
|
});
|
||||||
|
|
||||||
deferred.resolveWith(null, [newList]);
|
deferred.resolveWith(null, [newList]);
|
||||||
|
|
||||||
credentials.servers = newList;
|
credentials.servers = newList;
|
||||||
|
@ -413,12 +522,10 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
|
|
||||||
servers.sort(function (a, b) {
|
|
||||||
return b.DateLastAccessed - a.DateLastAccessed;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (servers.length == 1) {
|
if (servers.length == 1) {
|
||||||
if (!servers[0].DateLastAccessed && !self.connectUser()) {
|
|
||||||
|
if (!servers[0].DateLastAccessed && !self.connectUserId()) {
|
||||||
|
|
||||||
deferred.resolveWith(null, [
|
deferred.resolveWith(null, [
|
||||||
{
|
{
|
||||||
Servers: servers,
|
Servers: servers,
|
||||||
|
@ -426,10 +533,15 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
ConnectUser: self.connectUser()
|
ConnectUser: self.connectUser()
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
|
} else {
|
||||||
|
|
||||||
self.connectToServer(servers[0]).done(function (result) {
|
self.connectToServer(servers[0]).done(function (result) {
|
||||||
|
|
||||||
|
if (result.State == MediaBrowser.ConnectionState.Unavailable) {
|
||||||
|
result.State = MediaBrowser.ConnectionState.ServerSelection;
|
||||||
|
}
|
||||||
|
|
||||||
deferred.resolveWith(null, [result]);
|
deferred.resolveWith(null, [result]);
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
|
@ -443,6 +555,7 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -468,10 +581,11 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
deferred.resolveWith(null, [
|
deferred.resolveWith(null, [
|
||||||
{
|
{
|
||||||
Servers: servers,
|
Servers: servers,
|
||||||
State: servers.length ? MediaBrowser.ConnectionState.ServerSelection : MediaBrowser.ConnectionState.Unavailable,
|
State: (!servers.length && !self.connectUser()) ? MediaBrowser.ConnectionState.Unavailable : MediaBrowser.ConnectionState.ServerSelection,
|
||||||
ConnectUser: self.connectUser()
|
ConnectUser: self.connectUser()
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
@ -576,6 +690,7 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
if (server.LocalAddress) {
|
if (server.LocalAddress) {
|
||||||
|
|
||||||
|
//onLocalTestDone();
|
||||||
// Try to connect to the local address
|
// Try to connect to the local address
|
||||||
tryConnect(server.LocalAddress).done(function (result) {
|
tryConnect(server.LocalAddress).done(function (result) {
|
||||||
|
|
||||||
|
@ -657,8 +772,16 @@ MediaBrowser.ConnectionManager = function (store) {
|
||||||
|
|
||||||
self.getApiClient = function (item) {
|
self.getApiClient = function (item) {
|
||||||
|
|
||||||
// TODO: accept string + objet
|
// Accept string + object
|
||||||
return apiClients[0];
|
if (item.ServerId) {
|
||||||
|
item = item.ServerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiClients.filter(function (a) {
|
||||||
|
|
||||||
|
return a.serverInfo().Id = item;
|
||||||
|
|
||||||
|
})[0];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@ MediaBrowser.CredentialProvider = function (store) {
|
||||||
store.setItem('servercredentials', JSON.stringify(get()));
|
store.setItem('servercredentials', JSON.stringify(get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.clear = function() {
|
||||||
|
credentials = null;
|
||||||
|
store.removeItem('servercredentials');
|
||||||
|
};
|
||||||
|
|
||||||
self.credentials = function (data) {
|
self.credentials = function (data) {
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
* @param {String} clientName
|
* @param {String} clientName
|
||||||
* @param {String} applicationVersion
|
* @param {String} applicationVersion
|
||||||
*/
|
*/
|
||||||
return function (serverAddress, clientName, applicationVersion, deviceName, deviceId) {
|
return function (serverAddress, clientName, applicationVersion, deviceName, deviceId, capabilities) {
|
||||||
|
|
||||||
if (!serverAddress) {
|
if (!serverAddress) {
|
||||||
throw new Error("Must supply a serverAddress");
|
throw new Error("Must supply a serverAddress");
|
||||||
|
@ -26,6 +26,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
var currentUserId;
|
var currentUserId;
|
||||||
var accessToken;
|
var accessToken;
|
||||||
var webSocket;
|
var webSocket;
|
||||||
|
var serverInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server address.
|
* Gets the server address.
|
||||||
|
@ -40,6 +41,13 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
return "/mediabrowser";
|
return "/mediabrowser";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.serverInfo = function (info) {
|
||||||
|
|
||||||
|
serverInfo = info || serverInfo;
|
||||||
|
|
||||||
|
return serverInfo;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or sets the current user id.
|
* Gets or sets the current user id.
|
||||||
*/
|
*/
|
||||||
|
@ -89,12 +97,13 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
/**
|
/**
|
||||||
* Wraps around jQuery ajax methods to add additional info to the request.
|
* Wraps around jQuery ajax methods to add additional info to the request.
|
||||||
*/
|
*/
|
||||||
self.ajax = function (request) {
|
self.ajax = function (request, includeAuthorization) {
|
||||||
|
|
||||||
if (!request) {
|
if (!request) {
|
||||||
throw new Error("Request cannot be null");
|
throw new Error("Request cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (includeAuthorization !== false) {
|
||||||
if (clientName) {
|
if (clientName) {
|
||||||
|
|
||||||
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '", Version="' + applicationVersion + '"';
|
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '", Version="' + applicationVersion + '"';
|
||||||
|
@ -111,6 +120,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
request.headers['X-MediaBrowser-Token'] = accessToken;
|
request.headers['X-MediaBrowser-Token'] = accessToken;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $.ajax(request);
|
return $.ajax(request);
|
||||||
};
|
};
|
||||||
|
@ -146,7 +156,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.enableAutomaticNetworking = function(server, connectionMode) {
|
self.enableAutomaticNetworking = function (server, connectionMode) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,6 +181,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
|
|
||||||
self.sendWebSocketMessage("Identity", clientName + "|" + deviceId + "|" + applicationVersion + "|" + deviceName);
|
self.sendWebSocketMessage("Identity", clientName + "|" + deviceId + "|" + applicationVersion + "|" + deviceName);
|
||||||
|
|
||||||
|
self.reportCapabilities(capabilities);
|
||||||
|
|
||||||
$(self).trigger("websocketopen");
|
$(self).trigger("websocketopen");
|
||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -848,6 +860,21 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current server status
|
||||||
|
*/
|
||||||
|
self.getPublicSystemInfo = function () {
|
||||||
|
|
||||||
|
var url = self.getUrl("System/Info/Public");
|
||||||
|
|
||||||
|
return self.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: url,
|
||||||
|
dataType: "json"
|
||||||
|
|
||||||
|
}, false);
|
||||||
|
};
|
||||||
|
|
||||||
self.getInstantMixFromSong = function (itemId, options) {
|
self.getInstantMixFromSong = function (itemId, options) {
|
||||||
|
|
||||||
var url = self.getUrl("Songs/" + itemId + "/InstantMix", options);
|
var url = self.getUrl("Songs/" + itemId + "/InstantMix", options);
|
||||||
|
@ -2049,7 +2076,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
});
|
|
||||||
|
}, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2081,7 +2109,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
};
|
};
|
||||||
|
|
||||||
var supportsWebP = false;
|
var supportsWebP = false;
|
||||||
self.supportsWebP = function(val) {
|
self.supportsWebP = function (val) {
|
||||||
|
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
supportsWebP = val;
|
supportsWebP = val;
|
||||||
|
@ -2264,7 +2292,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
contentType: "application/json"
|
contentType: "application/json"
|
||||||
|
|
||||||
}).done(function(result) {
|
}).done(function (result) {
|
||||||
|
|
||||||
|
|
||||||
$(self).trigger('authenticated', [result]);
|
$(self).trigger('authenticated', [result]);
|
||||||
|
@ -3170,7 +3198,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
|
|
||||||
(function (store) {
|
(function (store) {
|
||||||
|
|
||||||
MediaBrowser.ApiClient.generateDeviceId = function() {
|
MediaBrowser.ApiClient.generateDeviceId = function () {
|
||||||
|
|
||||||
var keys = [];
|
var keys = [];
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<title></title>
|
<title></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="editUserPage" data-role="page" class="page type-interior userProfilesPage publicUserPage">
|
<div id="editUserPage" data-role="page" class="page type-interior userProfilesPage">
|
||||||
|
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
<div class="content-primary">
|
<div class="content-primary">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue