|
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/search/ |
Upload File : |
define(["exports","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/emby-elements/emby-button/emby-button.js","./../modules/viewmanager/baseview.js","./../modules/focusmanager.js","./../modules/emby-apiclient/connectionmanager.js","./searchfields.js","./../modules/emby-apiclient/events.js","./../modules/common/globalize.js","./../modules/loading/loading.js","./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js","./../modules/layoutmanager.js","./../modules/cardbuilder/cardbuilder.js","./../modules/common/itemmanager/itemmanager.js"],function(_exports,_embyScroller,_embyButton,_baseview,_focusmanager,_connectionmanager,_searchfields,_events,_globalize,_loading,_embyItemscontainer,_layoutmanager,_cardbuilder,_itemmanager){function getCardOptionsForType(type,items){var options;return"BoxSet"===type||"Playlist"===type||"Game"===type||"Book"===type||"PhotoAlbum"===type||"MusicArtist"===type||"Person"===type?{shape:"autooverflow",fields:["Name"],focusTransformTitleAdjust:!0}:"Movie"===type||"Trailer"===type||"Series"===type?{shape:"autooverflow",fields:["Name","ProductionYear"],focusTransformTitleAdjust:!0}:"Photo"===type?{shape:"autooverflow",fields:["Name"],focusTransformTitleAdjust:!0}:"Audio"===type?{shape:"autooverflow",preferArtistTitle:!0,fields:["ParentName","Name"],action:"play",sideFooter:!0,focusTransformTitleAdjust:!0}:"TvChannel"===type?{shape:"autooverflow",fields:["Name","CurrentProgramParentName","CurrentProgramTime"],defaultBackground:!0,focusTransformTitleAdjust:!0}:"Program"===type?(function(options,type,items){"Program"===type&&items.length&&items[0].AsSeries&&(options.progress=!1,options.showAirDateTime=!1,options.fields=options.fields.filter(isNotName).filter(isNotParentName).filter(isNotAirTime),options.fields.push("ParentNameOrName"))}(options={shape:"autooverflow",fields:["ParentName","Name","AirTime"],showAirDateTime:!0,focusTransformTitleAdjust:!0},type,items),options):"Tag"===type?{shape:"autooverflow",fields:["Name"],defaultBackground:!0,multiSelect:!1,focusTransformTitleAdjust:!0}:{shape:"autooverflow",fields:["ParentName","Name"],focusTransformTitleAdjust:!0}}function isNotName(n){return"Name"!==n}function isNotParentName(n){return"ParentName"!==n}function isNotAirTime(n){return"AirTime"!==n}function renderSearchTypes(instance,apiClient,context,value,types,signal){for(var searchCategories=context.querySelector(".searchCategories"),promises=(searchCategories.innerHTML="",[]),i=0,length=types.length;i<length;i++){var type=(type=types[i]).Name||type,elem=document.createElement("div"),innerHTML=(elem.className="hide verticalSection albumResults","Audio"===type&&elem.classList.add("verticalSection-extrabottompadding"),'<h2 class="sectionTitle sectionTitle-cards padded-left padded-right">'+_itemmanager.default.getPluralItemTypeName(type)+"</h2>"),itemsContainerClass="itemsContainer scrollSlider focusable focuscontainer-x";"Audio"===type&&(itemsContainerClass+=" itemsContainer-sideFooters"),innerHTML=(innerHTML+='<div is="emby-scroller" data-horizontal="true" data-focusscroll="true" data-mousewheel="false" class="padded-top-focusscale padded-bottom-focusscale padded-left padded-right">')+('<div is="emby-itemscontainer" data-focusabletype="nearest" class="'+itemsContainerClass+'"></div>')+"</div>",elem.innerHTML=innerHTML,searchCategories.appendChild(elem),promises.push(function(instance,apiClient,query,context,section,signal){return query.Limit=16,query.ParentId=instance.params.parentId,function(instance,apiClient,query,signal){query.Recursive=!0,query.EnableTotalRecordCount=!1,query.ImageTypeLimit=1,query.Fields=getSearchFields(instance,query.IncludeItemTypes),"Program"===query.IncludeItemTypes&&(query.GroupProgramsBySeries=!0);"Program"===query.IncludeItemTypes&&(query.HasAired=!1);return apiClient.getItems(apiClient.getCurrentUserId(),query,signal)}(instance,apiClient,query,signal).then(function(result){var items=result.Items||result.SearchHints,items=getCardOptionsForType(query.IncludeItemTypes,items);return populateResults(result,context,section,items)})}(instance,apiClient,{searchTerm:value,IncludeItemTypes:type},context,elem,signal))}return Promise.all(promises)}function getSearchFields(instance,type){instance=instance.getRequestedItemFields()+",PrimaryImageAspectRatio,ProductionYear";return type&&"Series"!==type||(instance+=",Status,EndDate"),instance}function populateResults(result,context,section,cardOptions){result=result.Items||result.SearchHints,context=(section="string"==typeof section?context.querySelector(section):section).querySelector(".itemsContainer");return _cardbuilder.default.buildCards(result,Object.assign({itemsContainer:context,parentContainer:section,shape:"autooverflow",scalable:!0,focusTransformTitleAdjust:!0,horizontal:!0},cardOptions||{})),section.querySelector(".emby-scroller").scrollToBeginning({behavior:"instant"}),result}function SearchView(view,params){_baseview.default.apply(this,arguments),this.searchFields=new _searchfields.default({serverId:params.serverId||_connectionmanager.default.currentApiClient().serverId(),element:view.querySelector(".searchFields")}),this.search(""),_events.default.on(this.searchFields,"search",function(e,value){null!=(_instance$currentSear=this.currentSearchAbortController)&&_instance$currentSear.abort();var _instance$currentSear=new AbortController;this.currentSearchAbortController=_instance$currentSear,this.search(value,_instance$currentSear.signal)}.bind(this))}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(SearchView.prototype,_baseview.default.prototype),SearchView.prototype.onPause=function(){var _this$currentSearchAb;_baseview.default.prototype.onPause.apply(this,arguments),this.searchFields&&this.searchFields.pause(),null!=(_this$currentSearchAb=this.currentSearchAbortController)&&_this$currentSearchAb.abort(),this.currentSearchAbortController=null},SearchView.prototype.onInputCommand=function(e){"search"===e.detail.command?(_focusmanager.default.focus(this.view.querySelector(".searchfields-txtSearch")),e.preventDefault()):_baseview.default.prototype.onInputCommand.apply(this,arguments)},SearchView.prototype.search=function(value,signal){_loading.default.show();var apiClient=this.getApiClient(),elem=this.view.querySelector(".searchResults"),searchInfo=(elem.querySelector(".noResults").classList.add("hide"),{instance:this,searchTerm:value});return function(instance,apiClient,context,value,signal){(value||_layoutmanager.default.tv)&&context.querySelector(".searchSuggestions").classList.add("hide");var query={SearchTerm:value,Recursive:!0,EnableTotalRecordCount:!1,ImageTypeLimit:1,Limit:16,ParentId:instance.params.parentId,Fields:getSearchFields(instance),GroupProgramsBySeries:!0};return apiClient.getSearchResults(query,signal).then(function(result){var subPromises=[];return subPromises.push(populateResults(result,context,context.querySelector(".globalResults"),{shape:"autooverflow",fields:["ParentName","Name","Type","CurrentProgramParentName","AirTime"],showAirDateTime:!0,lines:4})),subPromises.push(renderSearchTypes(instance,apiClient,context,value,result.ItemTypes,signal)),Promise.all(subPromises)})}(this,apiClient,elem,value,signal).then(function(itemsResponses){_loading.default.hide();var hasResults,i,length,instance=this.instance;if(itemsResponses[0].length&&(hasResults=!0),(itemsResponses=itemsResponses[1]).length)for(i=0,length=itemsResponses.length;i<length;i++)if(itemsResponses[i].length){hasResults=!0;break}instance=instance.view.querySelector(".noResults"),hasResults||!this.searchTerm?instance.classList.add("hide"):(this.searchTerm.length<1?instance.innerHTML=_globalize.default.translate("TwoSearchCharsRequired"):instance.innerHTML=_globalize.default.translate("NoItemsMatchingFound"),instance.classList.remove("hide"))}.bind(searchInfo),function(){_loading.default.hide(),this.view.querySelector(".noResults").classList.remove("hide")}.bind(this))},SearchView.prototype.onResume=function(options){_baseview.default.prototype.onResume.apply(this,arguments),this.searchFields&&this.searchFields.resume(options)},SearchView.prototype.destroy=function(){_baseview.default.prototype.destroy.apply(this,arguments),this.searchFields&&(this.searchFields.destroy(),this.searchFields=null)};_exports.default=SearchView});