|
Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 System : Windows NT SERVER-PC 10.0 build 26200 (Windows 11) AMD64 User : ServerPC ( 0) PHP Version : 8.2.12 Disable Function : NONE Directory : C:/Users/ServerPC/AppData/Roaming/Emby-Server/system/dashboard-ui/modules/common/ |
Upload File : |
define(["exports","./../emby-apiclient/events.js","./playback/playbackmanager.js","./input/api.js","./../emby-apiclient/connectionmanager.js"],function(_exports,_events,_playbackmanager,_api,_connectionmanager){function onChannelManagementInfoUpdated(e,apiClient,data){var options,id,item=data.Channel;item?(id=data.Id,(options=this.options)&&-1!==(id=(options=options.itemsContainer).indexOfItemId(id))&&options.onItemUpdated(id,item)):getEventsToMonitor(this).includes("ChannelManagementInfoUpdated")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onUserDataChanged(e,apiClient,userData,data){var options=this.options;if(options){if(!options.enableUserData)return;var item,options=options.itemsContainer,index=options.indexOfItemId(userData.ItemId);-1!==index&&(item=options.getItem(index))&&(item.UserData=userData,options.onItemUpdated(index,item))}userData=getEventsToMonitor(this);(userData.includes("markfavorite")||userData.includes("markplayed"))&&this.notifyRefreshNeeded(data.IsLocalEvent)}function getEventsToMonitor(instance){instance=instance.options;if(instance){var itemsContainer=instance.itemsContainer;if(itemsContainer&&itemsContainer.getEventsToMonitor)return itemsContainer.getEventsToMonitor();itemsContainer=instance.monitorEvents;if(itemsContainer)return itemsContainer.split(",")}return[]}function onTimerCreated(e,apiClient,data){var options,item,programId=data.ProgramId,newTimerId=data.Id;newTimerId&&(options=this.options)&&-1!==(programId=(options=options.itemsContainer).indexOfItemId(programId))&&(item=options.getItem(programId))&&(item.TimerId=newTimerId,options.onItemUpdated(programId,item)),getEventsToMonitor(this).includes("Timers")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onPluginsUninstalled(e,apiClient,data){getEventsToMonitor(this).includes("Plugins")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onUserNotificationsSaved(e,apiClient,data){getEventsToMonitor(this).includes("UserNotifications")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onUserNotificationsDeleted(e,apiClient,data){getEventsToMonitor(this).includes("UserNotifications")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSyncJobCreated(e,apiClient,data){getEventsToMonitor(this).includes("SyncJobs")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSyncJobItemCancelled(e,apiClient,data){getEventsToMonitor(this).includes("SyncJobItems")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSyncJobItemUpdated(e,apiClient,data){var options,index,item;getEventsToMonitor(this).includes("SyncJobItems")&&(options=this.options)&&-1!==(index=(options=options.itemsContainer).indexOfItemId(data.Id))&&(item=options.getItem(index))&&(Object.assign(item,data),options.onItemUpdated(index,item))}function onSyncJobCancelled(e,apiClient,data){getEventsToMonitor(this).includes("SyncJobs")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSyncJobUpdated(e,apiClient,data){var options,index,item;getEventsToMonitor(this).includes("SyncJobs")&&(options=this.options)&&-1!==(index=(options=options.itemsContainer).indexOfItemId(data.Id))&&(item=options.getItem(index))&&(Object.assign(item,data),options.onItemUpdated(index,item))}function onUsersDeleted(e,apiClient,data){getEventsToMonitor(this).includes("Users")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onScheduledTaskTriggersUpdated(e,apiClient,data){getEventsToMonitor(this).includes("ScheduledTaskTriggers")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onCredentialsUpdated(){getEventsToMonitor(this).includes("Servers")&&this.notifyRefreshNeeded(!0)}function onApiKeyCreated(e,apiClient,data){getEventsToMonitor(this).includes("ApiKeys")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onApiKeysDeleted(e,apiClient,data){getEventsToMonitor(this).includes("ApiKeys")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onDevicesDeleted(e,apiClient,data){getEventsToMonitor(this).includes("Devices")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onLiveTVGuideSourcesDeleted(e,apiClient,data){getEventsToMonitor(this).includes("LiveTVGuideSources")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onLiveTVTunerDevicesDeleted(e,apiClient,data){getEventsToMonitor(this).includes("LiveTVTunerDevices")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onTimerCancelled(e,apiClient,data){var options,item,programId=data.ProgramId;programId&&(options=this.options)&&-1!==(programId=(options=options.itemsContainer).indexOfItemId(programId))&&(item=options.getItem(programId))&&(item.TimerId=null,options.onItemUpdated(programId,item)),getEventsToMonitor(this).includes("Timers")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSeriesTimerUpdated(e,apiClient,data){getEventsToMonitor(this).includes("SeriesTimers")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSeriesTimerCreated(e,apiClient,data){getEventsToMonitor(this).includes("SeriesTimers")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onSeriesTimerCancelled(e,apiClient,data){getEventsToMonitor(this).includes("SeriesTimers")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onItemsRemovedFromCollection(e,apiClient,data){var _instance$options;null!=(_instance$options=this.options)&&_instance$options.itemIds.includes(data.CollectionId||-1)&&getEventsToMonitor(this).includes("CollectionItems")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onItemsRemovedFromPlaylist(e,apiClient,data){var _instance$options2;null!=(_instance$options2=this.options)&&_instance$options2.itemIds.includes(data.PlaylistId||-1)&&getEventsToMonitor(this).includes("PlaylistItems")&&this.notifyRefreshNeeded(data.IsLocalEvent)}function onRecordingStarted(e,apiClient,data){getEventsToMonitor(this).includes("RecordingStarted")&&this.notifyRefreshNeeded(!0)}function onRecordingEnded(e,apiClient,data){getEventsToMonitor(this).includes("RecordingEnded")&&this.notifyRefreshNeeded(!0)}function includesAny(array1,array2){return array1.some(function(r){return array2.includes(r)})}function onItemsMerged(e,apiClient,data){var itemsUpdated=data.Items||[],options=this.options;if(options){var itemsContainer=options.itemsContainer,options=options.itemIds;if(options&&includesAny(itemsUpdated,options))this.notifyRefreshNeeded(data.IsLocalEvent);else for(var i=0,length=itemsUpdated.length;i<length;i++){var updateditemId=itemsUpdated[i];if(-1!==itemsContainer.indexOfItemId(updateditemId))return void this.notifyRefreshNeeded(data.IsLocalEvent)}}}function onLibraryChanged(e,apiClient,data){var eventsToMonitor=getEventsToMonitor(this);if(!eventsToMonitor.includes("SeriesTimers")&&!eventsToMonitor.includes("Timers")){var eventsToMonitor=data.ItemsAdded||[],itemsRemoved=data.ItemsRemoved||[],itemsUpdated=data.ItemsUpdated||[],options=this.options;if(options){var itemsContainer=options.itemsContainer,itemIds=options.itemIds;if(itemIds&&includesAny(itemsUpdated,itemIds))return void this.notifyRefreshNeeded(data.IsLocalEvent);if((options.refreshOnItemUpdated||data.IsLocalEvent)&&!1!==options.refreshOnItemUpdated)for(var i=0,length=itemsUpdated.length;i<length;i++){var updateditemId=itemsUpdated[i];if(-1!==itemsContainer.indexOfItemId(updateditemId))return void this.notifyRefreshNeeded(data.IsLocalEvent)}}if(eventsToMonitor.length||itemsRemoved.length){if(options){for(var _itemsContainer=options.itemsContainer,_i=0,_length=itemsRemoved.length;_i<_length;_i++){var removedItemId=itemsRemoved[_i];if(-1!==_itemsContainer.indexOfItemId(removedItemId))return void this.notifyRefreshNeeded(data.IsLocalEvent)}itemIds=options.parentId;if(itemIds){var eventsToMonitor=data.FoldersAddedTo||[],options=data.FoldersRemovedFrom||[],collectionFolders=data.CollectionFolders||[];if(!eventsToMonitor.includes(itemIds)&&!options.includes(itemIds)&&!collectionFolders.includes(itemIds))return}}this.notifyRefreshNeeded(data.IsLocalEvent)}}}function onPlaybackStopped(e,stopInfo){var stopInfo=stopInfo.state,eventsToMonitor=getEventsToMonitor(this);stopInfo.NowPlayingItem&&"Video"===stopInfo.NowPlayingItem.MediaType?eventsToMonitor.includes("videoplayback")&&this.notifyRefreshNeeded(!0):stopInfo.NowPlayingItem&&"Audio"===stopInfo.NowPlayingItem.MediaType&&eventsToMonitor.includes("audioplayback")&&this.notifyRefreshNeeded(!0)}function onPlayerChanged(){getEventsToMonitor(this).includes("nowplaying")&&this.notifyRefreshNeeded(!0)}function addNotificationEvent(instance,name,handler,owner){handler=handler.bind(instance);owner=owner||_api.default,_events.default.on(owner,name,handler),instance["event_"+name]=handler}function removeNotificationEvent(instance,name,handler,owner){var localHandler=instance["event_"+name];localHandler&&(owner=owner||_api.default,_events.default.off(owner,name,localHandler),instance["event_"+name]=null)}function ItemsRefresher(options){this.options=options||{},addNotificationEvent(this,"UserDataChanged",onUserDataChanged),addNotificationEvent(this,"TimerCreated",onTimerCreated),addNotificationEvent(this,"SeriesTimerCreated",onSeriesTimerCreated),addNotificationEvent(this,"SeriesTimerUpdated",onSeriesTimerUpdated),addNotificationEvent(this,"TimerCancelled",onTimerCancelled),addNotificationEvent(this,"DevicesDeleted",onDevicesDeleted),addNotificationEvent(this,"ApiKeyCreated",onApiKeyCreated),addNotificationEvent(this,"ApiKeysDeleted",onApiKeysDeleted),addNotificationEvent(this,"LiveTVGuideSourcesDeleted",onLiveTVGuideSourcesDeleted),addNotificationEvent(this,"LiveTVTunerDevicesDeleted",onLiveTVTunerDevicesDeleted),addNotificationEvent(this,"UserNotificationsSaved",onUserNotificationsSaved),addNotificationEvent(this,"UserNotificationsDeleted",onUserNotificationsDeleted),addNotificationEvent(this,"SyncJobCreated",onSyncJobCreated),addNotificationEvent(this,"SyncJobCancelled",onSyncJobCancelled),addNotificationEvent(this,"SyncJobUpdated",onSyncJobUpdated),addNotificationEvent(this,"SyncJobItemCancelled",onSyncJobItemCancelled),addNotificationEvent(this,"SyncJobItemUpdated",onSyncJobItemUpdated),addNotificationEvent(this,"SyncJobItemReady",onSyncJobItemUpdated),addNotificationEvent(this,"UsersDeleted",onUsersDeleted),addNotificationEvent(this,"ScheduledTaskTriggersUpdated",onScheduledTaskTriggersUpdated),addNotificationEvent(this,"PluginsUninstalled",onPluginsUninstalled),addNotificationEvent(this,"SeriesTimerCancelled",onSeriesTimerCancelled),addNotificationEvent(this,"LibraryChanged",onLibraryChanged),addNotificationEvent(this,"ItemsMerged",onItemsMerged),addNotificationEvent(this,"ItemsSplit",onItemsMerged),addNotificationEvent(this,"ItemsRemovedFromCollection",onItemsRemovedFromCollection),addNotificationEvent(this,"ItemsRemovedFromPlaylist",onItemsRemovedFromPlaylist),addNotificationEvent(this,"ItemsMovedInPlaylist",onItemsRemovedFromPlaylist),addNotificationEvent(this,"RecordingStarted",onRecordingStarted),addNotificationEvent(this,"RecordingEnded",onRecordingEnded),addNotificationEvent(this,"ChannelManagementInfoUpdated",onChannelManagementInfoUpdated),addNotificationEvent(this,"playbackstop",onPlaybackStopped,_playbackmanager.default),addNotificationEvent(this,"playerchange",onPlayerChanged,_playbackmanager.default),addNotificationEvent(this,"credentialsupdated",onCredentialsUpdated,_connectionmanager.default)}function clearRefreshTimeout(instance){instance=instance.refreshTimeout;instance&&clearTimeout(instance)}function clearRefreshInterval(instance,isPausing){instance.refreshInterval&&(clearTimeout(instance.refreshInterval),instance.refreshInterval=null,isPausing||(instance.refreshIntervalEndTime=null))}function resetRefreshInterval(instance,intervalMs){var _instance$options3;clearRefreshInterval(instance),(intervalMs=intervalMs||(null==(_instance$options3=instance.options)?void 0:_instance$options3.refreshIntervalMs))&&(instance.bound_onRefreshInterval||(instance.bound_onRefreshInterval=function(){this.notifyRefreshNeeded(!0)}.bind(instance)),instance.refreshInterval=setTimeout(instance.bound_onRefreshInterval,intervalMs),instance.refreshIntervalEndTime=Date.now()+intervalMs)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,ItemsRefresher.prototype.pause=function(){clearRefreshInterval(this,!0),this.paused=!0},ItemsRefresher.prototype.resume=function(options){this.paused=!1;var refreshIntervalEndTime=this.refreshIntervalEndTime;return refreshIntervalEndTime&&(0<(refreshIntervalEndTime=refreshIntervalEndTime-Date.now())&&!this.needsRefresh?resetRefreshInterval(this,refreshIntervalEndTime):(this.needsRefresh=!0,this.refreshIntervalEndTime=null)),this.needsRefresh||options&&options.refresh?this.refreshItems(options):Promise.resolve()},ItemsRefresher.prototype.resetRefreshInterval=function(){resetRefreshInterval(this)},ItemsRefresher.prototype.refreshItems=function(options){if(this.paused)return this.needsRefresh=!0,Promise.resolve();this.needsRefresh=!1,this.bound_onDataFetched||(this.bound_onDataFetched=function(result){resetRefreshInterval(this),this.afterRefresh&&this.afterRefresh(result)}.bind(this));var _this$options=null==(_this$options=this.options)?void 0:_this$options.itemsContainer;return _this$options?_this$options.refreshItemsInternal(options).then(this.bound_onDataFetched):Promise.resolve()},ItemsRefresher.prototype.mergeOptions=function(options){Object.assign(this.options,options),resetRefreshInterval(this)},ItemsRefresher.prototype.notifyIsRefreshing=function(){this.needsRefresh=!1},ItemsRefresher.prototype.notifyRefreshNeeded=function(isInForeground){var _this$options2;clearRefreshTimeout(this),this.paused?this.needsRefresh=!0:!0===(isInForeground=!1===(null==(_this$options2=this.options)?void 0:_this$options2.immediateUpdate)?!1:isInForeground)?this.refreshItems():(this.bound_onRefreshTimeout||(this.bound_onRefreshTimeout=function(){this.refreshItems()}.bind(this)),this.refreshTimeout=setTimeout(this.bound_onRefreshTimeout,3e3))},ItemsRefresher.prototype.destroy=function(){clearRefreshInterval(this),clearRefreshTimeout(this),removeNotificationEvent(this,"UserDataChanged"),removeNotificationEvent(this,"TimerCreated"),removeNotificationEvent(this,"SeriesTimerCreated"),removeNotificationEvent(this,"SeriesTimerUpdated"),removeNotificationEvent(this,"TimerCancelled"),removeNotificationEvent(this,"DevicesDeleted"),removeNotificationEvent(this,"ApiKeyCreated"),removeNotificationEvent(this,"ApiKeysDeleted"),removeNotificationEvent(this,"LiveTVGuideSourcesDeleted"),removeNotificationEvent(this,"LiveTVTunerDevicesDeleted"),removeNotificationEvent(this,"UserNotificationsSaved"),removeNotificationEvent(this,"UserNotificationsDeleted"),removeNotificationEvent(this,"SyncJobCreated"),removeNotificationEvent(this,"SyncJobCancelled"),removeNotificationEvent(this,"SyncJobUpdated"),removeNotificationEvent(this,"SyncJobItemCancelled"),removeNotificationEvent(this,"SyncJobItemUpdated"),removeNotificationEvent(this,"SyncJobItemReady"),removeNotificationEvent(this,"UsersDeleted"),removeNotificationEvent(this,"ScheduledTaskTriggersUpdated"),removeNotificationEvent(this,"PluginsUninstalled"),removeNotificationEvent(this,"SeriesTimerCancelled"),removeNotificationEvent(this,"LibraryChanged"),removeNotificationEvent(this,"ItemsMerged"),removeNotificationEvent(this,"ItemsSplit"),removeNotificationEvent(this,"ItemsRemovedFromCollection"),removeNotificationEvent(this,"ItemsRemovedFromPlaylist"),removeNotificationEvent(this,"ItemsMovedInPlaylist"),removeNotificationEvent(this,"RecordingStarted"),removeNotificationEvent(this,"RecordingEnded"),removeNotificationEvent(this,"ChannelManagementInfoUpdated"),removeNotificationEvent(this,"playbackstop",0,_playbackmanager.default),removeNotificationEvent(this,"playerchange",0,_playbackmanager.default),removeNotificationEvent(this,"credentialsupdated",0,_connectionmanager.default),this.fetchData=null,this.options=null,this.bound_onRefreshTimeout=null,this.bound_onRefreshInterval=null,this.bound_onDataFetched=null};_exports.default=ItemsRefresher});