update components

This commit is contained in:
Luke Pulverenti 2017-01-11 01:20:44 -05:00
parent 51d44957c3
commit e9b1b4ad5f
9 changed files with 62 additions and 56 deletions

View File

@ -16,12 +16,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.1.111",
"_release": "1.1.111",
"version": "1.1.112",
"_release": "1.1.112",
"_resolution": {
"type": "version",
"tag": "1.1.111",
"commit": "6a58b3a503f28eda5198d662643edaedd921abbd"
"tag": "1.1.112",
"commit": "e4b3d6c51534d2d0035e45ebfb486ea9959317aa"
},
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
"_target": "^1.1.51",

View File

@ -251,6 +251,10 @@
return credentialProvider.credentials().ConnectAccessToken;
};
self.getApiClients = function () {
return apiClients;
};
self.getServerInfo = function (id) {
var servers = credentialProvider.credentials().Servers;

View File

@ -14,12 +14,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.4.460",
"_release": "1.4.460",
"version": "1.4.461",
"_release": "1.4.461",
"_resolution": {
"type": "version",
"tag": "1.4.460",
"commit": "c25b2134e84594781f7eb2e6bd85bc2529a1d922"
"tag": "1.4.461",
"commit": "4f817f597ac06d80fe41e3d7d096f4fd5d9b7be2"
},
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.1",

View File

@ -6,15 +6,13 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
function getCardsHtml(items, options) {
var apiClient = connectionManager.currentApiClient();
if (arguments.length === 1) {
options = arguments[0];
items = options.items;
}
var html = buildCardsHtmlInternal(items, apiClient, options);
var html = buildCardsHtmlInternal(items, options);
return html;
}
@ -254,7 +252,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
options.width = options.width || getImageWidth(options.shape);
}
function buildCardsHtmlInternal(items, apiClient, options) {
function buildCardsHtmlInternal(items, options) {
var isVertical;
@ -269,7 +267,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
setCardData(items, options);
if (options.indexBy === 'Genres') {
return buildCardsByGenreHtmlInternal(items, apiClient, options);
return buildCardsByGenreHtmlInternal(items, options);
}
var className = 'card';
@ -290,11 +288,18 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
var hasOpenSection;
var sectionTitleTagName = options.sectionTitleTagName || 'div';
var apiClient;
var lastServerId;
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
if (item.ServerId !== lastServerId) {
lastServerId = item.ServerId;
apiClient = connectionManager.getApiClient(lastServerId);
}
if (options.indexBy) {
var newIndexValue = '';
@ -404,7 +409,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
});
}
function buildCardsByGenreHtmlInternal(items, apiClient, options) {
function buildCardsByGenreHtmlInternal(items, options) {
var className = 'card';
@ -435,7 +440,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
}
var cardClass = className;
currentItemHtml += buildCard(i, renderItem, apiClient, options, cardClass);
currentItemHtml += buildCard(i, renderItem, connectionManager.getApiClient(renderItem.ServerId), options, cardClass);
itemsInRow++;
@ -1412,9 +1417,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
}
}
var apiClient = connectionManager.currentApiClient();
var html = buildCardsHtmlInternal(items, apiClient, options);
var html = buildCardsHtmlInternal(items, options);
if (html) {

View File

@ -196,10 +196,7 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
events.on(apiClient, "websocketmessage", onWebSocketMessageReceived);
}
var current = connectionManager.currentApiClient();
if (current) {
bindEvents(current);
}
connectionManager.getApiClients().forEach(bindEvents);
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {

View File

@ -28,10 +28,7 @@ define(['connectionManager', 'events'], function (connectionManager, events) {
events.on(apiClient, "websocketmessage", onWebSocketMessageReceived);
}
var current = connectionManager.currentApiClient();
if (current) {
bindEvents(current);
}
connectionManager.getApiClients().forEach(bindEvents);
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {

View File

@ -53,7 +53,7 @@ define(['playbackManager', 'userSettings'], function (playbackManager, userSetti
require(['connectionManager'], function (connectionManager) {
var apiClient = connectionManager.currentApiClient();
var apiClient = connectionManager.getApiClient(item.ServerId);
apiClient.getThemeMedia(apiClient.getCurrentUserId(), item.Id, true).then(function (themeMediaResult) {
var ownerId = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.OwnerId : themeMediaResult.ThemeSongsResult.OwnerId;
@ -74,7 +74,7 @@ define(['playbackManager', 'userSettings'], function (playbackManager, userSetti
var state = e.detail.state || {};
var item = state.item;
if (item) {
if (item && item.ServerId) {
loadThemeMedia(item);
return;
}

View File

@ -8,7 +8,7 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
markFavorite: markFavorite
};
function getUserDataButtonHtml(method, itemId, buttonCssClass, iconCssClass, icon, tooltip, style) {
function getUserDataButtonHtml(method, itemId, serverId, buttonCssClass, iconCssClass, icon, tooltip, style) {
if (style === 'fab-mini') {
style = 'fab';
@ -30,7 +30,7 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
iconCssClass += 'md-icon';
return '<button title="' + tooltip + '" data-itemid="' + itemId + '" is="' + is + '" data-method="' + method + '" class="' + className + '"><i class="'+ iconCssClass + '">' + icon + '</i></button>';
return '<button title="' + tooltip + '" data-itemid="' + itemId + '" data-serverid="' + serverId + '" is="' + is + '" data-method="' + method + '" class="' + className + '"><i class="' + iconCssClass + '">' + icon + '</i></button>';
}
function onContainerClick(e) {
@ -98,15 +98,17 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
var iconCssClass = options.iconCssClass;
var serverId = item.ServerId;
if (includePlayed !== false) {
var tooltipPlayed = globalize.translate('sharedcomponents#MarkPlayed');
if (item.MediaType === 'Video' || item.Type === 'Series' || item.Type === 'Season' || item.Type === 'BoxSet' || item.Type === 'Playlist') {
if (item.Type !== 'TvChannel') {
if (userData.Played) {
html += getUserDataButtonHtml('markPlayed', itemId, btnCssClass + ' btnUserDataOn', iconCssClass, 'check', tooltipPlayed, style);
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass + ' btnUserDataOn', iconCssClass, 'check', tooltipPlayed, style);
} else {
html += getUserDataButtonHtml('markPlayed', itemId, btnCssClass, iconCssClass, 'check', tooltipPlayed, style);
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass, iconCssClass, 'check', tooltipPlayed, style);
}
}
}
@ -116,24 +118,24 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
//var tooltipDislike = globalize.translate('sharedcomponents#Dislike');
//if (typeof userData.Likes == "undefined") {
// html += getUserDataButtonHtml('markDislike', itemId, btnCssClass + ' btnUserData btnDislike', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, btnCssClass + ' btnUserData btnLike', 'thumb-up', tooltipLike);
// html += getUserDataButtonHtml('markDislike', itemId, serverId, btnCssClass + ' btnUserData btnDislike', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, serverId, btnCssClass + ' btnUserData btnLike', 'thumb-up', tooltipLike);
//}
//else if (userData.Likes) {
// html += getUserDataButtonHtml('markDislike', itemId, btnCssClass + ' btnUserData btnDislike', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, btnCssClass + ' btnUserData btnLike btnUserDataOn', 'thumb-up', tooltipLike);
// html += getUserDataButtonHtml('markDislike', itemId, serverId, btnCssClass + ' btnUserData btnDislike', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, serverId, btnCssClass + ' btnUserData btnLike btnUserDataOn', 'thumb-up', tooltipLike);
//}
//else {
// html += getUserDataButtonHtml('markDislike', itemId, btnCssClass + ' btnUserData btnDislike btnUserDataOn', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, btnCssClass + ' btnUserData btnLike', 'thumb-up', tooltipLike);
// html += getUserDataButtonHtml('markDislike', itemId, serverId, btnCssClass + ' btnUserData btnDislike btnUserDataOn', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, serverId, btnCssClass + ' btnUserData btnLike', 'thumb-up', tooltipLike);
//}
var tooltipFavorite = globalize.translate('sharedcomponents#Favorite');
if (userData.IsFavorite) {
html += getUserDataButtonHtml('markFavorite', itemId, btnCssClass + ' btnUserData btnUserDataOn', iconCssClass, 'favorite', tooltipFavorite, style);
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData btnUserDataOn', iconCssClass, 'favorite', tooltipFavorite, style);
} else {
html += getUserDataButtonHtml('markFavorite', itemId, btnCssClass + ' btnUserData', iconCssClass, 'favorite', tooltipFavorite, style);
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData', iconCssClass, 'favorite', tooltipFavorite, style);
}
return html;
@ -142,10 +144,11 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
function markFavorite(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
var markAsFavorite = !link.classList.contains('btnUserDataOn');
favorite(id, markAsFavorite);
favorite(id, serverId, markAsFavorite);
if (markAsFavorite) {
link.classList.add('btnUserDataOn');
@ -157,16 +160,17 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
function markLike(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
if (!link.classList.contains('btnUserDataOn')) {
likes(id, true);
likes(id, serverId, true);
link.classList.add('btnUserDataOn');
} else {
clearLike(id);
clearLike(id, serverId);
link.classList.remove('btnUserDataOn');
}
@ -177,16 +181,17 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
function markDislike(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
if (!link.classList.contains('btnUserDataOn')) {
likes(id, false);
likes(id, serverId, false);
link.classList.add('btnUserDataOn');
} else {
clearLike(id);
clearLike(id, serverId);
link.classList.remove('btnUserDataOn');
}
@ -197,43 +202,44 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
function markPlayed(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
if (!link.classList.contains('btnUserDataOn')) {
played(id, true);
played(id, serverId, true);
link.classList.add('btnUserDataOn');
} else {
played(id, false);
played(id, serverId, false);
link.classList.remove('btnUserDataOn');
}
}
function likes(id, isLiked) {
var apiClient = connectionManager.currentApiClient();
function likes(id, serverId, isLiked) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.updateUserItemRating(apiClient.getCurrentUserId(), id, isLiked);
}
function played(id, isPlayed) {
var apiClient = connectionManager.currentApiClient();
function played(id, serverId, isPlayed) {
var apiClient = connectionManager.getApiClient(serverId);
var method = isPlayed ? 'markPlayed' : 'markUnplayed';
return apiClient[method](apiClient.getCurrentUserId(), id, new Date());
}
function favorite(id, isFavorite) {
var apiClient = connectionManager.currentApiClient();
function favorite(id, serverId, isFavorite) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.updateFavoriteStatus(apiClient.getCurrentUserId(), id, isFavorite);
}
function clearLike(id) {
function clearLike(id, serverId) {
var apiClient = connectionManager.currentApiClient();
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.clearUserItemRating(apiClient.getCurrentUserId(), id);
}

View File

@ -599,7 +599,6 @@ var Dashboard = {
};
if (Dashboard.isRunningInCordova() && !browserInfo.safari) {
caps.SupportsOfflineAccess = true;
caps.SupportsSync = true;
caps.SupportsContentUploading = true;
}