jellyfin-web/dashboard-ui/scripts/dashboardpage.js

1 line
30 KiB
JavaScript
Raw Normal View History

2017-03-25 14:32:04 -07:00
define(["datetime","jQuery","dom","loading","humanedate","cardStyle","listViewStyle"],function(datetime,$,dom,loading){"use strict";function renderNoHealthAlertsMessage(page){var html='<p style="padding:0 .5em;display:flex;align-items:center;">';html+='<iron-icon icon="check" style="margin-right:.5em;background-color: #52B54B;border-radius:1em;color: #fff;"></iron-icon>',html+=Globalize.translate("HealthMonitorNoAlerts")+"</p>",page.querySelector(".healthMonitor").innerHTML=html}function refreshHealthMonitor(page){renderNoHealthAlertsMessage(page)}function onConnectionHelpClick(e){return e.preventDefault(),!1}function onEditServerNameClick(e){var page=dom.parentWithClass(this,"page");return require(["prompt"],function(prompt){prompt({label:Globalize.translate("LabelFriendlyServerName"),description:Globalize.translate("LabelFriendlyServerNameHelp"),value:page.querySelector(".serverNameHeader").innerHTML,confirmText:Globalize.translate("ButtonSave")}).then(function(value){loading.show(),ApiClient.getServerConfiguration().then(function(config){config.ServerName=value,ApiClient.updateServerConfiguration(config).then(function(){page.querySelector(".serverNameHeader").innerHTML=value,loading.hide()})})})}),e.preventDefault(),!1}window.DashboardPage={newsStartIndex:0,onPageInit:function(){var page=this;page.querySelector(".btnConnectionHelp").addEventListener("click",onConnectionHelpClick),page.querySelector(".btnEditServerName").addEventListener("click",onEditServerNameClick)},onPageShow:function(){var page=this,apiClient=ApiClient;apiClient&&(DashboardPage.newsStartIndex=0,loading.show(),DashboardPage.pollForInfo(page),DashboardPage.startInterval(apiClient),Events.on(apiClient,"websocketmessage",DashboardPage.onWebSocketMessage),Events.on(apiClient,"websocketopen",DashboardPage.onWebSocketOpen),DashboardPage.lastAppUpdateCheck=null,DashboardPage.lastPluginUpdateCheck=null,Dashboard.getPluginSecurityInfo().then(function(pluginSecurityInfo){DashboardPage.renderSupporterIcon(page,pluginSecurityInfo)}),DashboardPage.reloadSystemInfo(page),DashboardPage.reloadNews(page),DashboardPage.sessionUpdateTimer=setInterval(DashboardPage.refreshSessionsLocally,6e4),$(".activityItems",page).activityLogList(),$(".swaggerLink",page).attr("href",apiClient.getUrl("swagger-ui/index.html",{api_key:ApiClient.accessToken()})),refreshHealthMonitor(page))},onPageHide:function(){var page=this;$(".activityItems",page).activityLogList("destroy");var apiClient=ApiClient;apiClient&&(Events.off(apiClient,"websocketmessage",DashboardPage.onWebSocketMessage),Events.off(apiClient,"websocketopen",DashboardPage.onWebSocketOpen),DashboardPage.stopInterval(apiClient)),DashboardPage.sessionUpdateTimer&&clearInterval(DashboardPage.sessionUpdateTimer)},renderPaths:function(page,systemInfo){$("#cachePath",page).html(systemInfo.CachePath),$("#logPath",page).html(systemInfo.LogPath),$("#transcodingTemporaryPath",page).html(systemInfo.TranscodingTempPath),$("#metadataPath",page).html(systemInfo.InternalMetadataPath)},refreshSessionsLocally:function(){var list=DashboardPage.sessionsList;list&&DashboardPage.renderActiveConnections($.mobile.activePage,list)},reloadSystemInfo:function(page){ApiClient.getSystemInfo().then(function(systemInfo){page.querySelector(".serverNameHeader").innerHTML=systemInfo.ServerName;var localizedVersion=Globalize.translate("LabelVersionNumber",systemInfo.Version);systemInfo.SystemUpdateLevel&&"Release"!=systemInfo.SystemUpdateLevel&&(localizedVersion+=" "+Globalize.translate("Option"+systemInfo.SystemUpdateLevel).toLowerCase()),$("#appVersionNumber",page).html(localizedVersion),systemInfo.SupportsHttps?$("#ports",page).html(Globalize.translate("LabelRunningOnPorts",systemInfo.HttpServerPortNumber,systemInfo.HttpsPortNumber)):$("#ports",page).html(Globalize.translate("LabelRunningOnPort",systemInfo.HttpServerPortNumber)),systemInfo.CanSelfRestart?$(".btnRestartContainer",page).removeClass("hide"):$(".btnRestartContainer",page).addClass("hide"),DashboardPage.renderUrls(page,systemInfo),DashboardPage.renderPendingInstallations(page,systemInfo),sys