diff --git a/dashboard-ui/bower_components/emby-apiclient/localassetmanager.js b/dashboard-ui/bower_components/emby-apiclient/localassetmanager.js index 08e543aaf0..101cb6267a 100644 --- a/dashboard-ui/bower_components/emby-apiclient/localassetmanager.js +++ b/dashboard-ui/bower_components/emby-apiclient/localassetmanager.js @@ -1 +1 @@ -define(["filerepository","itemrepository","useractionrepository","transfermanager","cryptojs-md5"],function(filerepository,itemrepository,useractionrepository,transfermanager){"use strict";function getLocalItem(serverId,itemId){return itemrepository.get(serverId,itemId)}function recordUserAction(action){return action.Id=createGuid(),useractionrepository.set(action.Id,action)}function getUserActions(serverId){return useractionrepository.getByServerId(serverId)}function deleteUserAction(action){return useractionrepository.remove(action.Id)}function deleteUserActions(actions){var results=[];return actions.forEach(function(action){results.push(deleteUserAction(action))}),Promise.all(results)}function getServerItems(serverId){return itemrepository.getAll(serverId)}function getItemsFromIds(serverId,ids){var actions=ids.map(function(id){var strippedId=stripStart(id,"local:");return getLocalItem(serverId,strippedId)});return Promise.all(actions).then(function(items){var libItems=items.map(function(locItem){return locItem.Item});return Promise.resolve(libItems)})}function getViews(serverId,userId){return itemrepository.getServerItemTypes(serverId,userId).then(function(types){var item,list=[];return types.indexOf("audio")>-1&&(item={Name:"Music",ServerId:serverId,Id:"localview:MusicView",Type:"MusicView",CollectionType:"music",IsFolder:!0},list.push(item)),types.indexOf("photo")>-1&&(item={Name:"Photos",ServerId:serverId,Id:"localview:PhotosView",Type:"PhotosView",CollectionType:"photos",IsFolder:!0},list.push(item)),types.indexOf("episode")>-1&&(item={Name:"TV",ServerId:serverId,Id:"localview:TVView",Type:"TVView",CollectionType:"tvshows",IsFolder:!0},list.push(item)),types.indexOf("movie")>-1&&(item={Name:"Movies",ServerId:serverId,Id:"localview:MoviesView",Type:"MoviesView",CollectionType:"movies",IsFolder:!0},list.push(item)),types.indexOf("video")>-1&&(item={Name:"Videos",ServerId:serverId,Id:"localview:VideosView",Type:"VideosView",CollectionType:"videos",IsFolder:!0},list.push(item)),types.indexOf("musicvideo")>-1&&(item={Name:"Music Videos",ServerId:serverId,Id:"localview:MusicVideosView",Type:"MusicVideosView",CollectionType:"videos",IsFolder:!0},list.push(item)),Promise.resolve(list)})}function getTypeFilterForTopLevelView(parentId){var typeFilter=null;switch(parentId){case"localview:MusicView":typeFilter="MusicAlbum";break;case"localview:PhotosView":typeFilter="PhotoAlbum";break;case"localview:TVView":typeFilter="Series";break;case"localview:VideosView":typeFilter="Video";break;case"localview:MoviesView":typeFilter="Movie";break;case"localview:MusicVideosView":typeFilter="MusicVideo"}return typeFilter}function normalizeId(id){return id?(id=stripStart(id,"localview:"),id=stripStart(id,"local:")):null}function getViewItems(serverId,userId,options){var parentId=options.ParentId,typeFilter=getTypeFilterForTopLevelView(parentId);parentId=normalizeId(parentId);var seasonId=normalizeId(options.SeasonId||options.seasonId),seriesId=normalizeId(options.SeriesId||options.seriesId),includeItemTypes=options.IncludeItemTypes?options.IncludeItemTypes.split(","):[];return typeFilter&&(parentId=null,includeItemTypes.push(typeFilter)),getServerItems(serverId).then(function(items){var resultItems=items.filter(function(item){if(item.SyncStatus&&"synced"!==item.SyncStatus)return!1;if(options.MediaType&&item.Item.MediaType!==options.MediaType)return!1;if(seriesId&&item.Item.SeriesId!==seriesId)return!1;if(seasonId&&item.Item.SeasonId!==seasonId)return!1;if("IsNotFolder"===options.Filters&&item.Item.IsFolder)return!1;if("IsFolder"===options.Filters&&!item.Item.IsFolder)return!1;if(includeItemTypes.length&&includeItemTypes.indexOf(item.Item.Type||"")===-1)return!1;if(options.Recursive);else if(parentId&&item.Item.ParentId!==parentId)return!1;return!0}).map(function(item2){return item2.Item});return"DateCreated"===options.SortBy&&resultItems.sort(function(a,b){return compareDates(a.DateCreated,b.DateCreated)}),options.Limit&&(resultItems=resultItems.slice(0,options.Limit)),Promise.resolve(resultItems)})}function removeObsoleteContainerItems(serverId){return getServerItems(serverId).then(function(items){var seriesItems=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"series"===type}),seasonItems=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"season"===type}),albumItems=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"musicalbum"===type||"photoalbum"===type}),requiredSeriesIds=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"episode"===type}).map(function(item2){return item2.Item.SeriesId}).filter(filterDistinct),requiredSeasonIds=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"episode"===type}).map(function(item2){return item2.Item.SeasonId}).filter(filterDistinct),requiredAlbumIds=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"audio"===type||"photo"===type}).map(function(item2){return item2.Item.AlbumId}).filter(filterDistinct),obsoleteItems=[];seriesItems.forEach(function(item){requiredSeriesIds.indexOf(item.Item.Id)<0&&obsoleteItems.push(item)}),seasonItems.forEach(function(item){requiredSeasonIds.indexOf(item.Item.Id)<0&&obsoleteItems.push(item)}),albumItems.forEach(function(item){requiredAlbumIds.indexOf(item.Item.Id)<0&&obsoleteItems.push(item)});var p=Promise.resolve();return obsoleteItems.forEach(function(item){p=p.then(function(){return itemrepository.remove(item.ServerId,item.Id)})}),p})}function removeLocalItem(localItem){return itemrepository.get(localItem.ServerId,localItem.Id).then(function(item){return filerepository.deleteFile(item.LocalPath).then(function(){var p=Promise.resolve(!0);return item.AdditionalFiles&&item.AdditionalFiles.forEach(function(file){p=p.then(function(){return filerepository.deleteFile(file.Path)})}),p.then(function(file){return itemrepository.remove(localItem.ServerId,localItem.Id)})},function(error){var p=Promise.resolve(!0);return item.AdditionalFiles&&item.AdditionalFiles.forEach(function(file){p=p.then(function(item){return filerepository.deleteFile(file.Path)})}),p.then(function(file){return itemrepository.remove(localItem.ServerId,localItem.Id)})})})}function addOrUpdateLocalItem(localItem){return itemrepository.set(localItem.ServerId,localItem.Id,localItem)}function createLocalItem(libraryItem,apiClient,jobItem){var localPath,path=getDirectoryPath(libraryItem,apiClient.serverName()),localFolder=filerepository.getFullLocalPath(path);if(jobItem&&(path.push(getLocalFileName(libraryItem,jobItem.OriginalFileName)),localPath=filerepository.getFullLocalPath(path)),libraryItem.MediaSources)for(var i=0;i0&&(fileName=fileName.substring(0,pos)),fileName}function downloadFile(url,localItem){var folder=filerepository.getLocalPath(),imageUrl=getImageUrl(localItem.Item.ServerId,localItem.Item.Id,{type:"Primary",index:0});return transfermanager.downloadFile(url,folder,localItem,imageUrl)}function downloadSubtitles(url,fileName){var folder=filerepository.getLocalPath();return transfermanager.downloadSubtitles(url,folder,fileName)}function getImageUrl(serverId,itemId,imageOptions){var imageType=imageOptions.type,index=imageOptions.index,pathArray=getImagePath(serverId,itemId,imageType,index),relPath=pathArray.join("/"),prefix="ms-appdata:///local";return prefix+"/"+relPath}function hasImage(serverId,itemId,imageType,index){var pathArray=getImagePath(serverId,itemId,imageType,index),localFilePath=filerepository.getFullMetadataPath(pathArray);return filerepository.fileExists(localFilePath).then(function(exists){return Promise.resolve(exists)},function(err){return Promise.resolve(!1)})}function fileExists(localFilePath){return filerepository.fileExists(localFilePath)}function downloadImage(localItem,url,serverId,itemId,imageType,index){var pathArray=getImagePath(serverId,itemId,imageType,index),localFilePath=filerepository.getFullMetadataPath(pathArray);localItem.AdditionalFiles||(localItem.AdditionalFiles=[]);var fileInfo={Path:localFilePath,Type:"Image",Name:imageType+index.toString(),ImageType:imageType};localItem.AdditionalFiles.push(fileInfo);var folder=filerepository.getMetadataPath();return transfermanager.downloadImage(url,folder,localFilePath)}function isDownloadFileInQueue(path){return transfermanager.isDownloadFileInQueue(path)}function getDownloadItemCount(){return transfermanager.getDownloadItemCount()}function getDirectoryPath(item,serverName){var parts=[];parts.push(serverName);var itemtype=item.Type.toLowerCase();if("episode"===itemtype){parts.push("TV");var seriesName=item.SeriesName;seriesName&&parts.push(seriesName);var seasonName=item.SeasonName;seasonName&&parts.push(seasonName)}else if("video"===itemtype)parts.push("Videos"),parts.push(item.Name);else if("audio"===itemtype){parts.push("Music");var albumArtist=item.AlbumArtist;albumArtist&&parts.push(albumArtist),item.AlbumId&&item.Album&&parts.push(item.Album)}else"photo"===itemtype&&(parts.push("Photos"),item.AlbumId&&item.Album&&parts.push(item.Album));for(var finalParts=[],i=0;ifind.length&&0===str.indexOf(find))}function stripStart(str,find){return startsWith(str,find)?str.substr(find.length):str}function filterDistinct(value,index,self){return self.indexOf(value)===index}function compareDates(a,b){return isFinite(a=a.valueOf())&&isFinite(b=b.valueOf())?(a>b)-(a-1&&(item={Name:"Music",ServerId:serverId,Id:"localview:MusicView",Type:"MusicView",CollectionType:"music",IsFolder:!0},list.push(item)),types.indexOf("photo")>-1&&(item={Name:"Photos",ServerId:serverId,Id:"localview:PhotosView",Type:"PhotosView",CollectionType:"photos",IsFolder:!0},list.push(item)),types.indexOf("episode")>-1&&(item={Name:"TV",ServerId:serverId,Id:"localview:TVView",Type:"TVView",CollectionType:"tvshows",IsFolder:!0},list.push(item)),types.indexOf("movie")>-1&&(item={Name:"Movies",ServerId:serverId,Id:"localview:MoviesView",Type:"MoviesView",CollectionType:"movies",IsFolder:!0},list.push(item)),types.indexOf("video")>-1&&(item={Name:"Videos",ServerId:serverId,Id:"localview:VideosView",Type:"VideosView",CollectionType:"videos",IsFolder:!0},list.push(item)),types.indexOf("musicvideo")>-1&&(item={Name:"Music Videos",ServerId:serverId,Id:"localview:MusicVideosView",Type:"MusicVideosView",CollectionType:"videos",IsFolder:!0},list.push(item)),Promise.resolve(list)})}function getTypeFilterForTopLevelView(parentId){var typeFilter=null;switch(parentId){case"localview:MusicView":typeFilter="MusicAlbum";break;case"localview:PhotosView":typeFilter="PhotoAlbum";break;case"localview:TVView":typeFilter="Series";break;case"localview:VideosView":typeFilter="Video";break;case"localview:MoviesView":typeFilter="Movie";break;case"localview:MusicVideosView":typeFilter="MusicVideo"}return typeFilter}function normalizeId(id){return id?(id=stripStart(id,"localview:"),id=stripStart(id,"local:")):null}function getViewItems(serverId,userId,options){var parentId=options.ParentId,typeFilter=getTypeFilterForTopLevelView(parentId);parentId=normalizeId(parentId);var seasonId=normalizeId(options.SeasonId||options.seasonId),seriesId=normalizeId(options.SeriesId||options.seriesId),includeItemTypes=options.IncludeItemTypes?options.IncludeItemTypes.split(","):[];return typeFilter&&(parentId=null,includeItemTypes.push(typeFilter)),getServerItems(serverId).then(function(items){var resultItems=items.filter(function(item){if(item.SyncStatus&&"synced"!==item.SyncStatus)return!1;if(options.MediaType&&item.Item.MediaType!==options.MediaType)return!1;if(seriesId&&item.Item.SeriesId!==seriesId)return!1;if(seasonId&&item.Item.SeasonId!==seasonId)return!1;if("IsNotFolder"===options.Filters&&item.Item.IsFolder)return!1;if("IsFolder"===options.Filters&&!item.Item.IsFolder)return!1;if(includeItemTypes.length&&includeItemTypes.indexOf(item.Item.Type||"")===-1)return!1;if(options.Recursive);else if(parentId&&item.Item.ParentId!==parentId)return!1;return!0}).map(function(item2){return item2.Item});return"DateCreated"===options.SortBy&&resultItems.sort(function(a,b){return compareDates(a.DateCreated,b.DateCreated)}),options.Limit&&(resultItems=resultItems.slice(0,options.Limit)),Promise.resolve(resultItems)})}function removeObsoleteContainerItems(serverId){return getServerItems(serverId).then(function(items){var seriesItems=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"series"===type}),seasonItems=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"season"===type}),albumItems=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"musicalbum"===type||"photoalbum"===type}),requiredSeriesIds=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"episode"===type}).map(function(item2){return item2.Item.SeriesId}).filter(filterDistinct),requiredSeasonIds=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"episode"===type}).map(function(item2){return item2.Item.SeasonId}).filter(filterDistinct),requiredAlbumIds=items.filter(function(item){var type=(item.Item.Type||"").toLowerCase();return"audio"===type||"photo"===type}).map(function(item2){return item2.Item.AlbumId}).filter(filterDistinct),obsoleteItems=[];seriesItems.forEach(function(item){requiredSeriesIds.indexOf(item.Item.Id)<0&&obsoleteItems.push(item)}),seasonItems.forEach(function(item){requiredSeasonIds.indexOf(item.Item.Id)<0&&obsoleteItems.push(item)}),albumItems.forEach(function(item){requiredAlbumIds.indexOf(item.Item.Id)<0&&obsoleteItems.push(item)});var p=Promise.resolve();return obsoleteItems.forEach(function(item){p=p.then(function(){return itemrepository.remove(item.ServerId,item.Id)})}),p})}function removeLocalItem(localItem){return itemrepository.get(localItem.ServerId,localItem.Id).then(function(item){return filerepository.deleteFile(item.LocalPath).then(function(){var p=Promise.resolve(!0);return item.AdditionalFiles&&item.AdditionalFiles.forEach(function(file){p=p.then(function(){return filerepository.deleteFile(file.Path)})}),p.then(function(file){return itemrepository.remove(localItem.ServerId,localItem.Id)})},function(error){var p=Promise.resolve(!0);return item.AdditionalFiles&&item.AdditionalFiles.forEach(function(file){p=p.then(function(item){return filerepository.deleteFile(file.Path)})}),p.then(function(file){return itemrepository.remove(localItem.ServerId,localItem.Id)})})})}function addOrUpdateLocalItem(localItem){return itemrepository.set(localItem.ServerId,localItem.Id,localItem)}function createLocalItem(libraryItem,serverInfo,jobItem){var localPath,path=getDirectoryPath(libraryItem,serverInfo),localFolder=filerepository.getFullLocalPath(path);if(jobItem&&(path.push(getLocalFileName(libraryItem,jobItem.OriginalFileName)),localPath=filerepository.getFullLocalPath(path)),libraryItem.MediaSources)for(var i=0;i0&&(fileName=fileName.substring(0,pos)),fileName}function downloadFile(url,localItem){var folder=filerepository.getLocalPath(),imageUrl=getImageUrl(localItem.Item.ServerId,localItem.Item.Id,{type:"Primary",index:0});return transfermanager.downloadFile(url,folder,localItem,imageUrl)}function downloadSubtitles(url,fileName){var folder=filerepository.getLocalPath();return transfermanager.downloadSubtitles(url,folder,fileName)}function getImageUrl(serverId,itemId,imageOptions){var imageType=imageOptions.type,index=imageOptions.index,pathArray=getImagePath(serverId,itemId,imageType,index),relPath=pathArray.join("/"),prefix="ms-appdata:///local";return prefix+"/"+relPath}function hasImage(serverId,itemId,imageType,index){var pathArray=getImagePath(serverId,itemId,imageType,index),localFilePath=filerepository.getFullMetadataPath(pathArray);return filerepository.fileExists(localFilePath).then(function(exists){return Promise.resolve(exists)},function(err){return Promise.resolve(!1)})}function fileExists(localFilePath){return filerepository.fileExists(localFilePath)}function downloadImage(localItem,url,serverId,itemId,imageType,index){var pathArray=getImagePath(serverId,itemId,imageType,index),localFilePath=filerepository.getFullMetadataPath(pathArray);localItem.AdditionalFiles||(localItem.AdditionalFiles=[]);var fileInfo={Path:localFilePath,Type:"Image",Name:imageType+index.toString(),ImageType:imageType};localItem.AdditionalFiles.push(fileInfo);var folder=filerepository.getMetadataPath();return transfermanager.downloadImage(url,folder,localFilePath)}function isDownloadFileInQueue(path){return transfermanager.isDownloadFileInQueue(path)}function getDownloadItemCount(){return transfermanager.getDownloadItemCount()}function getDirectoryPath(item,server){var parts=[];parts.push(server.Name);var itemtype=item.Type.toLowerCase();if("episode"===itemtype){parts.push("TV");var seriesName=item.SeriesName;seriesName&&parts.push(seriesName);var seasonName=item.SeasonName;seasonName&&parts.push(seasonName)}else if("video"===itemtype)parts.push("Videos"),parts.push(item.Name);else if("audio"===itemtype){parts.push("Music");var albumArtist=item.AlbumArtist;albumArtist&&parts.push(albumArtist),item.AlbumId&&item.Album&&parts.push(item.Album)}else"photo"===itemtype&&(parts.push("Photos"),item.AlbumId&&item.Album&&parts.push(item.Album));for(var finalParts=[],i=0;ifind.length&&0===str.indexOf(find))}function stripStart(str,find){return startsWith(str,find)?str.substr(find.length):str}function filterDistinct(value,index,self){return self.indexOf(value)===index}function compareDates(a,b){return isFinite(a=a.valueOf())&&isFinite(b=b.valueOf())?(a>b)-(a=length?void resolve():void uploadFile(files[index],apiClient).then(function(){uploadNext(files,index+1,apiClient,resolve,reject)},function(){uploadNext(files,index+1,apiClient,resolve,reject)})}function uploadFile(file,apiClient){return new Promise(function(resolve,reject){require(["fileupload","cryptojs-sha1"],function(FileUpload){var name="camera image "+(new Date).getTime(),url=apiClient.getUrl("Devices/CameraUploads",{DeviceId:apiClient.deviceId(),Name:name,Album:"Camera Roll",Id:getUploadId(file),api_key:apiClient.accessToken()});console.log("Uploading file to "+url),(new FileUpload).upload(file,name,url).then(resolve,reject)})})}function ContentUploader(){}return ContentUploader.prototype.uploadImages=function(connectionManager,apiClient){return cameraRoll.getFiles().then(function(photos){return photos.length?apiClient.getContentUploadHistory().then(function(uploadHistory){return photos=getFilesToUpload(photos,uploadHistory),console.log("Found "+photos.length+" files to upload"),new Promise(function(resolve,reject){uploadNext(photos,0,apiClient,resolve,reject)})},function(){return Promise.resolve()}):Promise.resolve()})},ContentUploader}); \ No newline at end of file +define(["localassetmanager","cameraRoll"],function(localAssetManager,cameraRoll){"use strict";function getFilesToUpload(files,uploadHistory){return files.filter(function(file){return!!file&&0===uploadHistory.FilesUploaded.filter(function(u){return getUploadId(file)===u.Id}).length})}function getUploadId(file){return CryptoJS.SHA1(file+"1").toString()}function uploadNext(files,index,server,apiClient,resolve,reject){var length=files.length;return index>=length?void resolve():void uploadFile(files[index],apiClient).then(function(){uploadNext(files,index+1,server,apiClient,resolve,reject)},function(){uploadNext(files,index+1,server,apiClient,resolve,reject)})}function uploadFile(file,apiClient){return new Promise(function(resolve,reject){require(["fileupload","cryptojs-sha1"],function(FileUpload){var name="camera image "+(new Date).getTime(),url=apiClient.getUrl("Devices/CameraUploads",{DeviceId:apiClient.deviceId(),Name:name,Album:"Camera Roll",Id:getUploadId(file),api_key:apiClient.accessToken()});console.log("Uploading file to "+url),(new FileUpload).upload(file,name,url).then(resolve,reject)})})}function ContentUploader(){}return ContentUploader.prototype.uploadImages=function(connectionManager,server){return cameraRoll.getFiles().then(function(photos){if(!photos.length)return Promise.resolve();var apiClient=connectionManager.getApiClient(server.Id);return apiClient.getContentUploadHistory().then(function(uploadHistory){return photos=getFilesToUpload(photos,uploadHistory),console.log("Found "+photos.length+" files to upload"),new Promise(function(resolve,reject){uploadNext(photos,0,server,apiClient,resolve,reject)})},function(){return Promise.resolve()})})},ContentUploader}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-apiclient/sync/mediasync.js b/dashboard-ui/bower_components/emby-apiclient/sync/mediasync.js index a4574bd449..700ba0ed65 100644 --- a/dashboard-ui/bower_components/emby-apiclient/sync/mediasync.js +++ b/dashboard-ui/bower_components/emby-apiclient/sync/mediasync.js @@ -1 +1 @@ -define(["localassetmanager"],function(localassetmanager){"use strict";function processDownloadStatus(apiClient,options){return console.log("[mediasync] Begin processDownloadStatus"),localassetmanager.resyncTransfers().then(function(){return localassetmanager.getServerItems(apiClient.serverId()).then(function(items){console.log("[mediasync] Begin processDownloadStatus getServerItems completed");var p=Promise.resolve(),cnt=0,progressItems=items.filter(function(item){return"transferring"===item.SyncStatus||"queued"===item.SyncStatus});return progressItems.forEach(function(item){p=p.then(function(){return reportTransfer(apiClient,item)}),cnt++}),p.then(function(){return console.log("[mediasync] Exit processDownloadStatus. Items reported: "+cnt.toString()),Promise.resolve()})})})}function reportTransfer(apiClient,item){return localassetmanager.getItemFileSize(item.LocalPath).then(function(size){return size>0?apiClient.reportSyncJobItemTransferred(item.SyncJobItemId).then(function(){return item.SyncStatus="synced",localassetmanager.addOrUpdateLocalItem(item)},function(error){return console.error("[mediasync] Mediasync error on reportSyncJobItemTransferred",error),item.SyncStatus="error",localassetmanager.addOrUpdateLocalItem(item)}):localassetmanager.isDownloadFileInQueue(item.LocalPath).then(function(result){return result?Promise.resolve():(console.log("[mediasync] reportTransfer: Size is 0 and download no longer in queue. Deleting item."),localassetmanager.removeLocalItem(item).then(function(){return console.log("[mediasync] reportTransfer: Item deleted."),Promise.resolve()},function(err2){return console.log("[mediasync] reportTransfer: Failed to delete item.",err2),Promise.resolve()}))})},function(error){return console.error("[mediasync] reportTransfer: error on getItemFileSize. Deleting item.",error),localassetmanager.removeLocalItem(item).then(function(){return console.log("[mediasync] reportTransfer: Item deleted."),Promise.resolve()},function(err2){return console.log("[mediasync] reportTransfer: Failed to delete item.",error),Promise.resolve()})})}function reportOfflineActions(apiClient){return console.log("[mediasync] Begin reportOfflineActions"),localassetmanager.getUserActions(apiClient.serverId()).then(function(actions){return actions.length?apiClient.reportOfflineActions(actions).then(function(){return localassetmanager.deleteUserActions(actions).then(function(){return console.log("[mediasync] Exit reportOfflineActions (actions reported and deleted.)"),Promise.resolve()})},function(err){return console.error("[mediasync] error on apiClient.reportOfflineActions: "+err.toString()),localassetmanager.deleteUserActions(actions)}):(console.log("[mediasync] Exit reportOfflineActions (no actions)"),Promise.resolve())})}function syncData(apiClient,syncUserItemAccess){return console.log("[mediasync] Begin syncData"),localassetmanager.getServerItems(apiClient.serverId()).then(function(items){var completedItems=items.filter(function(item){return item&&("synced"===item.SyncStatus||"error"===item.SyncStatus)}),request={TargetId:apiClient.deviceId(),LocalItemIds:completedItems.map(function(xitem){return xitem.ItemId})};return apiClient.syncData(request).then(function(result){return afterSyncData(apiClient,syncUserItemAccess,result).then(function(){return console.log("[mediasync] Exit syncData"),Promise.resolve()},function(err){return console.error("[mediasync] Error in syncData: "+err.toString()),Promise.resolve()})})})}function afterSyncData(apiClient,enableSyncUserItemAccess,syncDataResult){console.log("[mediasync] Begin afterSyncData");var p=Promise.resolve(),serverId=apiClient.serverId();return syncDataResult.ItemIdsToRemove&&syncDataResult.ItemIdsToRemove.length>0&&syncDataResult.ItemIdsToRemove.forEach(function(itemId){p=p.then(function(){return removeLocalItem(itemId,serverId)})}),enableSyncUserItemAccess&&(p=p.then(function(){return syncUserItemAccess(syncDataResult,serverId)})),p=p.then(function(){return removeObsoleteContainerItems(serverId)}),p.then(function(){return console.log("[mediasync] Exit afterSyncData"),Promise.resolve()})}function removeObsoleteContainerItems(serverId){return console.log("[mediasync] Begin removeObsoleteContainerItems"),localassetmanager.removeObsoleteContainerItems(serverId)}function removeLocalItem(itemId,serverId){return console.log("[mediasync] Begin removeLocalItem"),localassetmanager.getLocalItem(serverId,itemId).then(function(item){return item?localassetmanager.removeLocalItem(item):Promise.resolve()})}function getNewMedia(apiClient,options,downloadCount){return console.log("[mediasync] Begin getNewMedia"),apiClient.getReadySyncItems(apiClient.deviceId()).then(function(jobItems){var p=Promise.resolve(),maxDownloads=10,currentCount=downloadCount;return jobItems.forEach(function(jobItem){currentCount++<=maxDownloads&&(p=p.then(function(){return getNewItem(jobItem,apiClient,options)}))}),p.then(function(){return console.log("[mediasync] Exit getNewMedia"),Promise.resolve()})})}function getNewItem(jobItem,apiClient,options){console.log("[mediasync] Begin getNewItem");var libraryItem=jobItem.Item;return localassetmanager.getLocalItem(apiClient.serverId(),libraryItem.Id).then(function(existingItem){return!existingItem||"queued"!==existingItem.SyncStatus&&"transferring"!==existingItem.SyncStatus&&"synced"!==existingItem.SyncStatus?(libraryItem.CanDelete=!1,libraryItem.CanDownload=!1,libraryItem.SupportsSync=!1,libraryItem.People=[],libraryItem.Chapters=[],libraryItem.Studios=[],libraryItem.SpecialFeatureCount=null,libraryItem.LocalTrailerCount=null,libraryItem.RemoteTrailers=[],localassetmanager.createLocalItem(libraryItem,serverInfo,jobItem).then(function(localItem){return console.log("[mediasync] getNewItem: createLocalItem completed"),localItem.SyncStatus="queued",downloadParentItems(apiClient,jobItem,localItem,options).then(function(){return downloadMedia(apiClient,jobItem,localItem,options).then(function(){return getImages(apiClient,jobItem,localItem).then(function(){return getSubtitles(apiClient,jobItem,localItem)})})})})):(console.log("[mediasync] getNewItem: getLocalItem found existing item"),Promise.resolve())})}function downloadParentItems(apiClient,jobItem,localItem,options){var p=Promise.resolve(),libraryItem=localItem.Item;(libraryItem.Type||"").toLowerCase();return libraryItem.SeriesId&&(p=p.then(function(){return downloadItem(apiClient,libraryItem,libraryItem.SeriesId)})),libraryItem.SeasonId&&(p=p.then(function(){return downloadItem(apiClient,libraryItem,libraryItem.SeasonId).then(function(seasonItem){return libraryItem.SeasonPrimaryImageTag=(seasonItem.Item.ImageTags||{}).Primary,Promise.resolve()})})),libraryItem.AlbumId&&(p=p.then(function(){return downloadItem(apiClient,libraryItem,libraryItem.AlbumId)})),p}function downloadItem(apiClient,libraryItem,itemId){return apiClient.getItem(apiClient.getCurrentUserId(),itemId).then(function(downloadedItem){return downloadedItem.CanDelete=!1,downloadedItem.CanDownload=!1,downloadedItem.SupportsSync=!1,downloadedItem.People=[],downloadedItem.SpecialFeatureCount=null,downloadedItem.BackdropImageTags=null,downloadedItem.ParentBackdropImageTags=null,downloadedItem.ParentArtImageTag=null,downloadedItem.ParentLogoImageTag=null,localassetmanager.createLocalItem(downloadedItem,null).then(function(localItem){return localassetmanager.addOrUpdateLocalItem(localItem).then(function(){return Promise.resolve(localItem)})})},function(err){return console.error("[mediasync] downloadItem failed: "+err.toString()),Promise.resolve(null)})}function downloadMedia(apiClient,jobItem,localItem,options){var url=apiClient.getUrl("Sync/JobItems/"+jobItem.SyncJobItemId+"/File",{api_key:apiClient.accessToken()}),localPath=localItem.LocalPath;return console.log("[mediasync] Downloading media. Url: "+url+". Local path: "+localPath),options=options||{},localassetmanager.downloadFile(url,localItem).then(function(filename){return localItem.SyncStatus="transferring",localassetmanager.addOrUpdateLocalItem(localItem)})}function getImages(apiClient,jobItem,localItem){console.log("[mediasync] Begin getImages");var p=Promise.resolve(),libraryItem=localItem.Item,serverId=libraryItem.ServerId,mainImageTag=(libraryItem.ImageTags||{}).Primary;libraryItem.Id&&mainImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,mainImageTag,"Primary")}));var logoImageTag=(libraryItem.ImageTags||{}).Logo;libraryItem.Id&&logoImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,logoImageTag,"Logo")}));var artImageTag=(libraryItem.ImageTags||{}).Art;libraryItem.Id&&artImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,artImageTag,"Art")}));var bannerImageTag=(libraryItem.ImageTags||{}).Banner;libraryItem.Id&&bannerImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,bannerImageTag,"Banner")}));var thumbImageTag=(libraryItem.ImageTags||{}).Thumb;if(libraryItem.Id&&thumbImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,thumbImageTag,"Thumb")})),libraryItem.Id&&libraryItem.BackdropImageTags)for(var i=0;i2?Promise.resolve():reportOfflineActions(apiClient).then(function(){return getNewMedia(apiClient,options,downloadCount).then(function(){return syncData(apiClient,!1).then(function(){return console.log("[mediasync]************************************* Exit sync"),Promise.resolve()})})})})})},function(err){console.error(err.toString())})}}}); \ No newline at end of file +define(["localassetmanager"],function(localassetmanager){"use strict";function processDownloadStatus(apiClient,serverInfo,options){return console.log("[mediasync] Begin processDownloadStatus"),localassetmanager.resyncTransfers().then(function(){return localassetmanager.getServerItems(serverInfo.Id).then(function(items){console.log("[mediasync] Begin processDownloadStatus getServerItems completed");var p=Promise.resolve(),cnt=0,progressItems=items.filter(function(item){return"transferring"===item.SyncStatus||"queued"===item.SyncStatus});return progressItems.forEach(function(item){p=p.then(function(){return reportTransfer(apiClient,item)}),cnt++}),p.then(function(){return console.log("[mediasync] Exit processDownloadStatus. Items reported: "+cnt.toString()),Promise.resolve()})})})}function reportTransfer(apiClient,item){return localassetmanager.getItemFileSize(item.LocalPath).then(function(size){return size>0?apiClient.reportSyncJobItemTransferred(item.SyncJobItemId).then(function(){return item.SyncStatus="synced",localassetmanager.addOrUpdateLocalItem(item)},function(error){return console.error("[mediasync] Mediasync error on reportSyncJobItemTransferred",error),item.SyncStatus="error",localassetmanager.addOrUpdateLocalItem(item)}):localassetmanager.isDownloadFileInQueue(item.LocalPath).then(function(result){return result?Promise.resolve():(console.log("[mediasync] reportTransfer: Size is 0 and download no longer in queue. Deleting item."),localassetmanager.removeLocalItem(item).then(function(){return console.log("[mediasync] reportTransfer: Item deleted."),Promise.resolve()},function(err2){return console.log("[mediasync] reportTransfer: Failed to delete item.",err2),Promise.resolve()}))})},function(error){return console.error("[mediasync] reportTransfer: error on getItemFileSize. Deleting item.",error),localassetmanager.removeLocalItem(item).then(function(){return console.log("[mediasync] reportTransfer: Item deleted."),Promise.resolve()},function(err2){return console.log("[mediasync] reportTransfer: Failed to delete item.",error),Promise.resolve()})})}function reportOfflineActions(apiClient,serverInfo){return console.log("[mediasync] Begin reportOfflineActions"),localassetmanager.getUserActions(serverInfo.Id).then(function(actions){return actions.length?apiClient.reportOfflineActions(actions).then(function(){return localassetmanager.deleteUserActions(actions).then(function(){return console.log("[mediasync] Exit reportOfflineActions (actions reported and deleted.)"),Promise.resolve()})},function(err){return console.error("[mediasync] error on apiClient.reportOfflineActions: "+err.toString()),localassetmanager.deleteUserActions(actions)}):(console.log("[mediasync] Exit reportOfflineActions (no actions)"),Promise.resolve())})}function syncData(apiClient,serverInfo,syncUserItemAccess){return console.log("[mediasync] Begin syncData"),localassetmanager.getServerItems(serverInfo.Id).then(function(items){var completedItems=items.filter(function(item){return item&&("synced"===item.SyncStatus||"error"===item.SyncStatus)}),request={TargetId:apiClient.deviceId(),LocalItemIds:completedItems.map(function(xitem){return xitem.ItemId})};return apiClient.syncData(request).then(function(result){return afterSyncData(apiClient,serverInfo,syncUserItemAccess,result).then(function(){return console.log("[mediasync] Exit syncData"),Promise.resolve()},function(err){return console.error("[mediasync] Error in syncData: "+err.toString()),Promise.resolve()})})})}function afterSyncData(apiClient,serverInfo,enableSyncUserItemAccess,syncDataResult){console.log("[mediasync] Begin afterSyncData");var p=Promise.resolve();return syncDataResult.ItemIdsToRemove&&syncDataResult.ItemIdsToRemove.length>0&&syncDataResult.ItemIdsToRemove.forEach(function(itemId){p=p.then(function(){return removeLocalItem(itemId,serverInfo.Id)})}),enableSyncUserItemAccess&&(p=p.then(function(){return syncUserItemAccess(syncDataResult,serverInfo.Id)})),p=p.then(function(){return removeObsoleteContainerItems(serverInfo.Id)}),p.then(function(){return console.log("[mediasync] Exit afterSyncData"),Promise.resolve()})}function removeObsoleteContainerItems(serverId){return console.log("[mediasync] Begin removeObsoleteContainerItems"),localassetmanager.removeObsoleteContainerItems(serverId)}function removeLocalItem(itemId,serverId){return console.log("[mediasync] Begin removeLocalItem"),localassetmanager.getLocalItem(serverId,itemId).then(function(item){return item?localassetmanager.removeLocalItem(item):Promise.resolve()})}function getNewMedia(apiClient,serverInfo,options,downloadCount){return console.log("[mediasync] Begin getNewMedia"),apiClient.getReadySyncItems(apiClient.deviceId()).then(function(jobItems){var p=Promise.resolve(),maxDownloads=10,currentCount=downloadCount;return jobItems.forEach(function(jobItem){currentCount++<=maxDownloads&&(p=p.then(function(){return getNewItem(jobItem,apiClient,serverInfo,options)}))}),p.then(function(){return console.log("[mediasync] Exit getNewMedia"),Promise.resolve()})})}function getNewItem(jobItem,apiClient,serverInfo,options){console.log("[mediasync] Begin getNewItem");var libraryItem=jobItem.Item;return localassetmanager.getLocalItem(serverInfo.Id,libraryItem.Id).then(function(existingItem){return!existingItem||"queued"!==existingItem.SyncStatus&&"transferring"!==existingItem.SyncStatus&&"synced"!==existingItem.SyncStatus?(libraryItem.CanDelete=!1,libraryItem.CanDownload=!1,libraryItem.SupportsSync=!1,libraryItem.People=[],libraryItem.Chapters=[],libraryItem.Studios=[],libraryItem.SpecialFeatureCount=null,libraryItem.LocalTrailerCount=null,libraryItem.RemoteTrailers=[],localassetmanager.createLocalItem(libraryItem,serverInfo,jobItem).then(function(localItem){return console.log("[mediasync] getNewItem: createLocalItem completed"),localItem.SyncStatus="queued",downloadParentItems(apiClient,jobItem,localItem,serverInfo,options).then(function(){return downloadMedia(apiClient,jobItem,localItem,options).then(function(){return getImages(apiClient,jobItem,localItem).then(function(){return getSubtitles(apiClient,jobItem,localItem)})})})})):(console.log("[mediasync] getNewItem: getLocalItem found existing item"),Promise.resolve())})}function downloadParentItems(apiClient,jobItem,localItem,serverInfo,options){var p=Promise.resolve(),libraryItem=localItem.Item;(libraryItem.Type||"").toLowerCase();return libraryItem.SeriesId&&(p=p.then(function(){return downloadItem(apiClient,libraryItem,libraryItem.SeriesId,serverInfo)})),libraryItem.SeasonId&&(p=p.then(function(){return downloadItem(apiClient,libraryItem,libraryItem.SeasonId,serverInfo).then(function(seasonItem){return libraryItem.SeasonPrimaryImageTag=(seasonItem.Item.ImageTags||{}).Primary,Promise.resolve()})})),libraryItem.AlbumId&&(p=p.then(function(){return downloadItem(apiClient,libraryItem,libraryItem.AlbumId,serverInfo)})),p}function downloadItem(apiClient,libraryItem,itemId,serverInfo){return apiClient.getItem(apiClient.getCurrentUserId(),itemId).then(function(downloadedItem){return downloadedItem.CanDelete=!1,downloadedItem.CanDownload=!1,downloadedItem.SupportsSync=!1,downloadedItem.People=[],downloadedItem.SpecialFeatureCount=null,downloadedItem.BackdropImageTags=null,downloadedItem.ParentBackdropImageTags=null,downloadedItem.ParentArtImageTag=null,downloadedItem.ParentLogoImageTag=null,localassetmanager.createLocalItem(downloadedItem,serverInfo,null).then(function(localItem){return localassetmanager.addOrUpdateLocalItem(localItem).then(function(){return Promise.resolve(localItem)})})},function(err){return console.error("[mediasync] downloadItem failed: "+err.toString()),Promise.resolve(null)})}function downloadMedia(apiClient,jobItem,localItem,options){var url=apiClient.getUrl("Sync/JobItems/"+jobItem.SyncJobItemId+"/File",{api_key:apiClient.accessToken()}),localPath=localItem.LocalPath;return console.log("[mediasync] Downloading media. Url: "+url+". Local path: "+localPath),options=options||{},localassetmanager.downloadFile(url,localItem).then(function(filename){return localItem.SyncStatus="transferring",localassetmanager.addOrUpdateLocalItem(localItem)})}function getImages(apiClient,jobItem,localItem){console.log("[mediasync] Begin getImages");var p=Promise.resolve(),libraryItem=localItem.Item,serverId=libraryItem.ServerId,mainImageTag=(libraryItem.ImageTags||{}).Primary;libraryItem.Id&&mainImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,mainImageTag,"Primary")}));var logoImageTag=(libraryItem.ImageTags||{}).Logo;libraryItem.Id&&logoImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,logoImageTag,"Logo")}));var artImageTag=(libraryItem.ImageTags||{}).Art;libraryItem.Id&&artImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,artImageTag,"Art")}));var bannerImageTag=(libraryItem.ImageTags||{}).Banner;libraryItem.Id&&bannerImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,bannerImageTag,"Banner")}));var thumbImageTag=(libraryItem.ImageTags||{}).Thumb;if(libraryItem.Id&&thumbImageTag&&(p=p.then(function(){return downloadImage(localItem,apiClient,serverId,libraryItem.Id,thumbImageTag,"Thumb")})),libraryItem.Id&&libraryItem.BackdropImageTags)for(var i=0;i2?Promise.resolve():reportOfflineActions(apiClient,serverInfo).then(function(){return getNewMedia(apiClient,serverInfo,options,downloadCount).then(function(){return syncData(apiClient,serverInfo,!1).then(function(){return console.log("[mediasync]************************************* Exit sync"),Promise.resolve()})})})})})},function(err){console.error(err.toString())})}}}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-apiclient/sync/multiserversync.js b/dashboard-ui/bower_components/emby-apiclient/sync/multiserversync.js index 4c1b47ddd9..e75bd5121a 100644 --- a/dashboard-ui/bower_components/emby-apiclient/sync/multiserversync.js +++ b/dashboard-ui/bower_components/emby-apiclient/sync/multiserversync.js @@ -1 +1 @@ -define(["serversync"],function(ServerSync){"use strict";function syncNext(connectionManager,apiClients,index,options,resolve,reject){var length=apiClients.length;if(index>=length)return void resolve();var apiClient=apiClients[index];console.log("Creating ServerSync to server: "+apiClient.serverId()),(new ServerSync).sync(connectionManager,apiClient,options).then(function(){syncNext(connectionManager,apiClients,index+1,options,resolve,reject)},function(){syncNext(connectionManager,apiClients,index+1,options,resolve,reject)})}function MultiServerSync(){}return MultiServerSync.prototype.sync=function(connectionManager,options){return new Promise(function(resolve,reject){var apiClients=connectionManager.getApiClients();syncNext(connectionManager,apiClients,0,options,resolve,reject)})},MultiServerSync}); \ No newline at end of file +define(["serversync"],function(ServerSync){"use strict";function syncNext(connectionManager,servers,index,options,resolve,reject){var length=servers.length;if(index>=length)return void resolve();var server=servers[index];console.log("Creating ServerSync to server: "+server.Id),(new ServerSync).sync(connectionManager,server,options).then(function(){syncNext(connectionManager,servers,index+1,options,resolve,reject)},function(){syncNext(connectionManager,servers,index+1,options,resolve,reject)})}function MultiServerSync(){}return MultiServerSync.prototype.sync=function(connectionManager,options){return new Promise(function(resolve,reject){var servers=connectionManager.getSavedServers();syncNext(connectionManager,servers,0,options,resolve,reject)})},MultiServerSync}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-apiclient/sync/serversync.js b/dashboard-ui/bower_components/emby-apiclient/sync/serversync.js index f32908db63..2dc8d71949 100644 --- a/dashboard-ui/bower_components/emby-apiclient/sync/serversync.js +++ b/dashboard-ui/bower_components/emby-apiclient/sync/serversync.js @@ -1 +1 @@ -define([],function(){"use strict";function performSync(connectionManager,apiClient,options){var serverId=apiClient.serverId();console.log("ServerSync.performSync to server: "+serverId),options=options||{};var uploadPhotos=options.uploadPhotos!==!1;options.cameraUploadServers&&options.cameraUploadServers.indexOf(serverId)===-1&&(uploadPhotos=!1);var pr=Promise.resolve();return pr.then(function(){return uploadPhotos?uploadContent(connectionManager,apiClient,options):Promise.resolve()}).then(function(){return syncMedia(connectionManager,apiClient,options)})}function uploadContent(connectionManager,apiClient,options){return new Promise(function(resolve,reject){require(["contentuploader"],function(ContentUploader){var uploader=new ContentUploader;uploader.uploadImages(connectionManager,apiClient).then(resolve,reject)})})}function syncMedia(connectionManager,apiClient,options){return new Promise(function(resolve,reject){require(["mediasync"],function(MediaSync){(new MediaSync).sync(apiClient,options).then(resolve,reject)})})}function ServerSync(){}return ServerSync.prototype.sync=function(connectionManager,apiClient,options){var serverId=apiClient.serverId();return apiClient.accessToken()?performSync(connectionManager,apiClient,options):(console.log("Skipping sync to server "+serverId+" because there is no saved authentication information."),Promise.resolve())},ServerSync}); \ No newline at end of file +define([],function(){"use strict";function performSync(connectionManager,server,options){console.log("ServerSync.performSync to server: "+server.Id),options=options||{};var uploadPhotos=options.uploadPhotos!==!1;options.cameraUploadServers&&options.cameraUploadServers.indexOf(server.Id)===-1&&(uploadPhotos=!1);var pr=Promise.resolve();return pr.then(function(){return uploadPhotos?uploadContent(connectionManager,server,options):Promise.resolve()}).then(function(){return syncMedia(connectionManager,server,options)})}function uploadContent(connectionManager,server,options){return new Promise(function(resolve,reject){require(["contentuploader"],function(ContentUploader){var uploader=new ContentUploader;uploader.uploadImages(connectionManager,server).then(resolve,reject)})})}function syncMedia(connectionManager,server,options){return new Promise(function(resolve,reject){require(["mediasync"],function(MediaSync){var apiClient=connectionManager.getApiClient(server.Id);(new MediaSync).sync(apiClient,server,options).then(resolve,reject)})})}function ServerSync(){}return ServerSync.prototype.sync=function(connectionManager,server,options){if(!server.AccessToken&&!server.ExchangeToken)return console.log("Skipping sync to server "+server.Id+" because there is no saved authentication information."),Promise.resolve();var connectionOptions={updateDateLastAccessed:!1,enableWebSocket:!1,reportCapabilities:!1,enableAutomaticBitrateDetection:!1};return connectionManager.connectToServer(server,connectionOptions).then(function(result){return result.State===MediaBrowser.ConnectionState.SignedIn?performSync(connectionManager,server,options):(console.log("Unable to connect to server id: "+server.Id),Promise.reject())},function(err){throw console.log("Unable to connect to server id: "+server.Id),err})},ServerSync}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.css b/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.css index 848c55dff6..64f6a01425 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.css +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.css @@ -1 +1 @@ -.emby-select,.selectLabel{display:block}.emby-select{margin:0;margin-bottom:0!important;border-style:solid;border-width:0 0 1px;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:110%;font-family:inherit;font-weight:inherit;padding:.35em .8em .3em 0;cursor:pointer;outline:0!important;-webkit-tap-highlight-color:transparent;width:100%}.emby-select::-moz-focus-inner{border:0}.emby-select-withoptioncolor{color:inherit;background:0 0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.emby-select-withoptioncolor>option{color:initial}.selectContainer{margin-bottom:1.8em;position:relative}.selectArrowContainer{position:absolute;right:0;top:.25em;color:inherit}.selectArrow{margin-top:.35em}.emby-select-selectionbar{height:2px;-webkit-transform:scale(0,1);transform:scale(0,1);-webkit-transition:-webkit-transform .25s ease-out;-o-transition:transform .25s ease-out;transition:transform .25s ease-out;position:relative;top:-1px;margin-bottom:.5em;-webkit-transform-origin:center center;transform-origin:center center}.emby-select:focus+.emby-select-selectionbar{-webkit-transform:none;transform:none} \ No newline at end of file +.emby-select,.selectLabel{display:block}.emby-select{margin:0;margin-bottom:0!important;border-style:solid;border-width:0 0 1px;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:110%;font-family:inherit;font-weight:inherit;padding:.35em .25em .3em 0;cursor:pointer;outline:0!important;-webkit-tap-highlight-color:transparent;width:100%}.emby-select::-moz-focus-inner{border:0}.emby-select-withoptioncolor{color:inherit;background:0 0}.emby-select-withoptioncolor>option{color:initial}.selectContainer{margin-bottom:1.8em;position:relative}.emby-select-selectionbar{height:2px;-webkit-transform:scale(0,1);transform:scale(0,1);-webkit-transition:-webkit-transform .25s ease-out;-o-transition:transform .25s ease-out;transition:transform .25s ease-out;position:relative;top:-1px;margin-bottom:.5em;-webkit-transform-origin:center center;transform-origin:center center}.emby-select:focus+.emby-select-selectionbar{-webkit-transform:none;transform:none} \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.js b/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.js index c6fd5f36f8..261c14eaf9 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.js +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-select/emby-select.js @@ -1 +1 @@ -define(["layoutManager","browser","actionsheet","css!./emby-select","registerElement"],function(layoutManager,browser,actionsheet){"use strict";function enableNativeMenu(){return!(!browser.edgeUwp&&!browser.xboxOne)||!browser.tizen&&!browser.orsay&&(!!browser.tv||!layoutManager.tv)}function triggerChange(select){var evt=document.createEvent("HTMLEvents");evt.initEvent("change",!1,!0),select.dispatchEvent(evt)}function setValue(select,value){select.value=value}function showActionSheet(select){var labelElem=getLabel(select),title=labelElem?labelElem.textContent||labelElem.innerText:null;actionsheet.show({items:select.options,positionTo:select,title:title}).then(function(value){setValue(select,value),triggerChange(select)})}function getLabel(select){for(var elem=select.previousSibling;elem&&"LABEL"!==elem.tagName;)elem=elem.previousSibling;return elem}function onFocus(e){var label=getLabel(this);label&&(label.classList.add("selectLabelFocused"),label.classList.remove("selectLabelUnfocused"))}function onBlur(e){var label=getLabel(this);label&&(label.classList.add("selectLabelUnfocused"),label.classList.remove("selectLabelFocused"))}function onMouseDown(e){e.button||enableNativeMenu()||(e.preventDefault(),showActionSheet(this))}function onKeyDown(e){switch(e.keyCode){case 13:return void(enableNativeMenu()||(e.preventDefault(),showActionSheet(this)));case 37:case 38:case 39:case 40:return void(layoutManager.tv&&e.preventDefault())}}var EmbySelectPrototype=Object.create(HTMLSelectElement.prototype),inputId=0;EmbySelectPrototype.createdCallback=function(){this.id||(this.id="embyselect"+inputId,inputId++),browser.firefox||this.classList.add("emby-select-withoptioncolor"),this.addEventListener("mousedown",onMouseDown),this.addEventListener("keydown",onKeyDown),this.addEventListener("focus",onFocus),this.addEventListener("blur",onBlur)},EmbySelectPrototype.attachedCallback=function(){if(!this.classList.contains("emby-select")){this.classList.add("emby-select");var label=this.ownerDocument.createElement("label");label.innerHTML=this.getAttribute("label")||"",label.classList.add("selectLabel"),label.classList.add("selectLabelUnfocused"),label.htmlFor=this.id,this.parentNode.insertBefore(label,this);var div=document.createElement("div");div.classList.add("emby-select-selectionbar"),this.parentNode.insertBefore(div,this.nextSibling);var arrowContainer=document.createElement("div");arrowContainer.classList.add("selectArrowContainer"),arrowContainer.innerHTML='
0
',this.parentNode.appendChild(arrowContainer);var arrow=document.createElement("i");arrow.classList.add("md-icon"),arrow.classList.add("selectArrow"),arrow.innerHTML="",arrowContainer.appendChild(arrow)}},EmbySelectPrototype.setLabel=function(text){var label=this.parentNode.querySelector("label");label.innerHTML=text},document.registerElement("emby-select",{prototype:EmbySelectPrototype,extends:"select"})}); \ No newline at end of file +define(["layoutManager","browser","actionsheet","css!./emby-select","registerElement"],function(layoutManager,browser,actionsheet){"use strict";function enableNativeMenu(){return!(!browser.edgeUwp&&!browser.xboxOne)||!browser.tizen&&!browser.orsay&&(!!browser.tv||!layoutManager.tv)}function triggerChange(select){var evt=document.createEvent("HTMLEvents");evt.initEvent("change",!1,!0),select.dispatchEvent(evt)}function setValue(select,value){select.value=value}function showActionSheet(select){var labelElem=getLabel(select),title=labelElem?labelElem.textContent||labelElem.innerText:null;actionsheet.show({items:select.options,positionTo:select,title:title}).then(function(value){setValue(select,value),triggerChange(select)})}function getLabel(select){for(var elem=select.previousSibling;elem&&"LABEL"!==elem.tagName;)elem=elem.previousSibling;return elem}function onFocus(e){var label=getLabel(this);label&&(label.classList.add("selectLabelFocused"),label.classList.remove("selectLabelUnfocused"))}function onBlur(e){var label=getLabel(this);label&&(label.classList.add("selectLabelUnfocused"),label.classList.remove("selectLabelFocused"))}function onMouseDown(e){e.button||enableNativeMenu()||(e.preventDefault(),showActionSheet(this))}function onKeyDown(e){switch(e.keyCode){case 13:return void(enableNativeMenu()||(e.preventDefault(),showActionSheet(this)));case 37:case 38:case 39:case 40:return void(layoutManager.tv&&e.preventDefault())}}var EmbySelectPrototype=Object.create(HTMLSelectElement.prototype),inputId=0;EmbySelectPrototype.createdCallback=function(){this.id||(this.id="embyselect"+inputId,inputId++),browser.firefox||this.classList.add("emby-select-withoptioncolor"),this.addEventListener("mousedown",onMouseDown),this.addEventListener("keydown",onKeyDown),this.addEventListener("focus",onFocus),this.addEventListener("blur",onBlur)},EmbySelectPrototype.attachedCallback=function(){if(!this.classList.contains("emby-select")){this.classList.add("emby-select");var label=this.ownerDocument.createElement("label");label.innerHTML=this.getAttribute("label")||"",label.classList.add("selectLabel"),label.classList.add("selectLabelUnfocused"),label.htmlFor=this.id,this.parentNode.insertBefore(label,this);var div=document.createElement("div");div.classList.add("emby-select-selectionbar"),this.parentNode.insertBefore(div,this.nextSibling)}},EmbySelectPrototype.setLabel=function(text){var label=this.parentNode.querySelector("label");label.innerHTML=text},document.registerElement("emby-select",{prototype:EmbySelectPrototype,extends:"select"})}); \ No newline at end of file