mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
reduce socket activity
This commit is contained in:
parent
badc66da51
commit
785230eb8e
10 changed files with 12 additions and 11 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
dashboard-ui/components/activitylog.js
Normal file
1
dashboard-ui/components/activitylog.js
Normal file
|
@ -0,0 +1 @@
|
|||
define(["events","libraryBrowser","datetime","userSettings","serverNotifications","connectionManager","emby-button"],function(events,libraryBrowser,datetime,userSettings,serverNotifications,connectionManager){"use strict";function getEntryHtml(entry,apiClient){var html="";html+='<div class="listItem listItem-noborder">';var color="Error"==entry.Severity||"Fatal"==entry.Severity||"Warn"==entry.Severity?"#cc0000":"#52B54B";if(entry.UserId&&entry.UserPrimaryImageTag){var userImgUrl=apiClient.getUserImageUrl(entry.UserId,{type:"Primary",tag:entry.UserPrimaryImageTag,height:40});html+='<i class="listItemIcon md-icon" style="width:2em!important;height:2em!important;padding:0;color:transparent;background-color:'+color+";background-image:url('"+userImgUrl+"');background-repeat:no-repeat;background-position:center center;background-size: cover;\">dvr</i>"}else html+='<i class="listItemIcon md-icon" style="background-color:'+color+'">dvr</i>';html+='<div class="listItemBody three-line">',html+='<div class="listItemBodyText">',html+=entry.Name,html+="</div>",html+='<div class="listItemBodyText secondary">';var date=datetime.parseISO8601Date(entry.Date,!0);return html+=datetime.toLocaleString(date).toLowerCase(),html+="</div>",html+='<div class="listItemBodyText secondary listItemBodyText-nowrap">',html+=entry.ShortOverview||"",html+="</div>",html+="</div>",html+="</div>"}function renderList(elem,apiClient,result,startIndex,limit){var html=result.Items.map(function(i){return getEntryHtml(i,apiClient)}).join("");if(result.TotalRecordCount>limit){var query={StartIndex:startIndex,Limit:limit};html+=libraryBrowser.getQueryPagingHtml({startIndex:query.StartIndex,limit:query.Limit,totalRecordCount:result.TotalRecordCount,showLimit:!1,updatePageSizeSetting:!1})}elem.innerHTML=html;var btnNextPage=elem.querySelector(".btnNextPage");btnNextPage&&btnNextPage.addEventListener("click",function(){reloadData(elem,apiClient,startIndex+limit,limit)});var btnPreviousPage=elem.querySelector(".btnPreviousPage");btnPreviousPage&&btnPreviousPage.addEventListener("click",function(){reloadData(elem,apiClient,startIndex-limit,limit)})}function reloadData(elem,apiClient,startIndex,limit){null==startIndex&&(startIndex=parseInt(elem.getAttribute("data-activitystartindex")||"0")),limit=limit||parseInt(elem.getAttribute("data-activitylimit")||"7");var minDate=new Date;minDate.setTime(minDate.getTime()-864e5),ApiClient.getJSON(ApiClient.getUrl("System/ActivityLog/Entries",{startIndex:startIndex,limit:limit,minDate:minDate.toISOString()})).then(function(result){elem.setAttribute("data-activitystartindex",startIndex),elem.setAttribute("data-activitylimit",limit),renderList(elem,apiClient,result,startIndex,limit)})}function onActivityLogUpdate(e,apiClient,data){var options=this.options;options&&options.serverId===apiClient.serverId()&&reloadData(options.element,apiClient)}function ActivityLog(options){this.options=options;var element=options.element;element.classList.add("activityLogListWidget");var apiClient=connectionManager.getApiClient(options.serverId);reloadData(element,apiClient);var onUpdate=onActivityLogUpdate.bind(this);this.updateFn=onUpdate,events.on(serverNotifications,"ActivityLogEntry",onUpdate),apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("ActivityLogEntryStart","0,1500")}return ActivityLog.prototype.destroy=function(){var options=this.options;if(options){var element=options.element;element.classList.remove("activityLogListWidget");var apiClient=connectionManager.getApiClient(options.serverId);apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("ActivityLogEntryStop","0,1500")}var onUpdate=this.updateFn;onUpdate&&events.off(serverNotifications,"ActivityLogEntry",onUpdate),this.options=null},ActivityLog});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
define(["events","userSettings","emby-button"],function(events,userSettings){"use strict";return function(options){function pollTasks(){ApiClient.getScheduledTasks({IsEnabled:!0}).then(updateTasks)}function updateTasks(tasks){var task=tasks.filter(function(t){return t.Key==options.taskKey})[0];if(options.panel&&(task?options.panel.classList.remove("hide"):options.panel.classList.add("hide")),task){"Idle"==task.State?button.removeAttribute("disabled"):button.setAttribute("disabled","disabled"),button.setAttribute("data-taskid",task.Id);var progress=(task.CurrentProgressPercentage||0).toFixed(1);if(options.progressElem&&(options.progressElem.value=progress,"Running"==task.State?options.progressElem.classList.remove("hide"):options.progressElem.classList.add("hide")),options.lastResultElem){var lastResult=task.LastExecutionResult?task.LastExecutionResult.Status:"";"Failed"==lastResult?options.lastResultElem.html('<span style="color:#FF0000;">('+Globalize.translate("LabelFailed")+")</span>"):"Cancelled"==lastResult?options.lastResultElem.html('<span style="color:#0026FF;">('+Globalize.translate("LabelCancelled")+")</span>"):"Aborted"==lastResult?options.lastResultElem.html('<span style="color:#FF0000;">'+Globalize.translate("LabelAbortedByServerShutdown")+"</span>"):options.lastResultElem.html(lastResult)}}}function onScheduledTaskMessageConfirmed(id){ApiClient.startScheduledTask(id).then(pollTasks)}function onButtonClick(){var button=this,taskId=button.getAttribute("data-taskid");onScheduledTaskMessageConfirmed(taskId)}function onSocketOpen(){startInterval()}function onSocketMessage(e,msg){if("ScheduledTasksInfo"==msg.MessageType){var tasks=msg.Data;updateTasks(tasks)}}function onPollIntervalFired(){ApiClient.isWebSocketOpen()||pollTasks()}function startInterval(){ApiClient.isWebSocketOpen()&&ApiClient.sendWebSocketMessage("ScheduledTasksInfoStart","1000,1000"),pollInterval&&clearInterval(pollInterval),pollInterval=setInterval(onPollIntervalFired,5e3)}function stopInterval(){ApiClient.isWebSocketOpen()&&ApiClient.sendWebSocketMessage("ScheduledTasksInfoStop"),pollInterval&&clearInterval(pollInterval)}var pollInterval,button=options.button;options.panel&&options.panel.classList.add("hide"),"off"==options.mode?(button.removeEventListener("click",onButtonClick),events.off(ApiClient,"websocketmessage",onSocketMessage),events.off(ApiClient,"websocketopen",onSocketOpen),stopInterval()):(button.addEventListener("click",onButtonClick),pollTasks(),startInterval(),events.on(ApiClient,"websocketmessage",onSocketMessage),events.on(ApiClient,"websocketopen",onSocketOpen))}});
|
||||
define(["events","userSettings","serverNotifications","connectionManager","emby-button"],function(events,userSettings,serverNotifications,connectionManager){"use strict";return function(options){function pollTasks(){connectionManager.getApiClient(serverId).getScheduledTasks({IsEnabled:!0}).then(updateTasks)}function updateTasks(tasks){var task=tasks.filter(function(t){return t.Key==options.taskKey})[0];if(options.panel&&(task?options.panel.classList.remove("hide"):options.panel.classList.add("hide")),task){"Idle"==task.State?button.removeAttribute("disabled"):button.setAttribute("disabled","disabled"),button.setAttribute("data-taskid",task.Id);var progress=(task.CurrentProgressPercentage||0).toFixed(1);if(options.progressElem&&(options.progressElem.value=progress,"Running"==task.State?options.progressElem.classList.remove("hide"):options.progressElem.classList.add("hide")),options.lastResultElem){var lastResult=task.LastExecutionResult?task.LastExecutionResult.Status:"";"Failed"==lastResult?options.lastResultElem.html('<span style="color:#FF0000;">('+Globalize.translate("LabelFailed")+")</span>"):"Cancelled"==lastResult?options.lastResultElem.html('<span style="color:#0026FF;">('+Globalize.translate("LabelCancelled")+")</span>"):"Aborted"==lastResult?options.lastResultElem.html('<span style="color:#FF0000;">'+Globalize.translate("LabelAbortedByServerShutdown")+"</span>"):options.lastResultElem.html(lastResult)}}}function onScheduledTaskMessageConfirmed(id){connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks)}function onButtonClick(){var button=this,taskId=button.getAttribute("data-taskid");onScheduledTaskMessageConfirmed(taskId)}function onScheduledTasksUpdate(e,apiClient,info){apiClient.serverId()===serverId&&updateTasks(info)}function onPollIntervalFired(){connectionManager.getApiClient(serverId).isWebSocketOpen()||pollTasks()}function startInterval(){var apiClient=connectionManager.getApiClient(serverId);pollInterval&&clearInterval(pollInterval),apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("ScheduledTasksInfoStart","1000,1000"),pollInterval=setInterval(onPollIntervalFired,1e4)}function stopInterval(){var apiClient=connectionManager.getApiClient(serverId);apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("ScheduledTasksInfoStop"),pollInterval&&clearInterval(pollInterval)}var pollInterval,button=options.button,serverId=ApiClient.serverId();options.panel&&options.panel.classList.add("hide"),"off"==options.mode?(button.removeEventListener("click",onButtonClick),events.off(serverNotifications,"ScheduledTasksInfo",onScheduledTasksUpdate),stopInterval()):(button.addEventListener("click",onButtonClick),pollTasks(),startInterval(),events.on(serverNotifications,"ScheduledTasksInfo",onScheduledTasksUpdate))}});
|
|
@ -1061,8 +1061,8 @@
|
|||
"HeaderParentalRatings": "Parental Ratings",
|
||||
"HeaderVideoTypes": "Video Types",
|
||||
"HeaderYears": "Years",
|
||||
"HeaderBlockItemsWithNoRating": "Block content with no or unrecognized rating information:",
|
||||
"LabelBlockContentWithTags": "Block content with tags:",
|
||||
"HeaderBlockItemsWithNoRating": "Block items with no or unrecognized rating information:",
|
||||
"LabelBlockContentWithTags": "Block items with tags:",
|
||||
"LabelEnableSingleImageInDidlLimit": "Limit to single embedded image",
|
||||
"LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.",
|
||||
"TabActivity": "Activity",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue