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

727 lines
22 KiB
JavaScript
Raw Normal View History

2013-02-20 18:33:05 -07:00
var DashboardPage = {
2014-01-22 13:46:01 -07:00
newsStartIndex: 0,
2013-02-20 18:33:05 -07:00
onPageShow: function () {
2013-12-24 11:37:29 -07:00
var page = this;
2014-01-22 13:46:01 -07:00
DashboardPage.newsStartIndex = 0;
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
2013-12-24 11:37:29 -07:00
DashboardPage.pollForInfo(page);
2013-02-20 18:33:05 -07:00
DashboardPage.startInterval();
$(ApiClient).on("websocketmessage", DashboardPage.onWebSocketMessage).on("websocketopen", DashboardPage.onWebSocketConnectionChange).on("websocketerror", DashboardPage.onWebSocketConnectionChange).on("websocketclose", DashboardPage.onWebSocketConnectionChange);
2013-02-20 18:33:05 -07:00
DashboardPage.lastAppUpdateCheck = null;
DashboardPage.lastPluginUpdateCheck = null;
2013-07-07 08:53:26 -07:00
Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) {
if (pluginSecurityInfo.IsMBSupporter) {
$('#contribute', page).hide();
2013-07-07 08:53:26 -07:00
} else {
2013-12-24 11:37:29 -07:00
$('#contribute', page).show();
2013-07-07 08:53:26 -07:00
}
});
2014-01-18 14:52:01 -07:00
DashboardPage.reloadNews(page);
},
reloadNews: function (page) {
2014-01-22 13:46:01 -07:00
var query = {
StartIndex: DashboardPage.newsStartIndex,
Limit: 5
};
2014-01-18 14:52:01 -07:00
2014-01-22 13:46:01 -07:00
ApiClient.getProductNews(query).done(function (result) {
2014-01-18 14:52:01 -07:00
var html = result.Items.map(function (item) {
var itemHtml = '';
itemHtml += '<div class="newsItem">';
itemHtml += '<a class="newsItemHeader" href="' + item.Link + '" target="_blank">' + item.Title + '</a>';
2014-01-18 15:47:44 -07:00
var date = parseISO8601Date(item.Date, { toLocal: true });
itemHtml += '<div class="newsItemDate">' + date.toLocaleDateString() + '</div>';
2014-01-18 21:25:01 -07:00
itemHtml += '<div class="newsItemDescription">' + item.DescriptionHtml + '</div>';
2014-01-18 14:52:01 -07:00
itemHtml += '</div>';
return itemHtml;
});
2014-01-22 13:46:01 -07:00
var pagingHtml = '';
pagingHtml += '<div>';
pagingHtml += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, false, [], false);
pagingHtml += '</div>';
2014-01-22 13:46:01 -07:00
html = html.join('') + pagingHtml;
var elem = $('.latestNewsItems', page).html(html).trigger('create');
$('.btnNextPage', elem).on('click', function () {
DashboardPage.newsStartIndex += query.Limit;
DashboardPage.reloadNews(page);
});
$('.btnPreviousPage', elem).on('click', function () {
DashboardPage.newsStartIndex -= query.Limit;
DashboardPage.reloadNews(page);
});
2014-01-18 14:52:01 -07:00
});
2013-02-20 18:33:05 -07:00
},
onPageHide: function () {
$(ApiClient).off("websocketmessage", DashboardPage.onWebSocketMessage).off("websocketopen", DashboardPage.onWebSocketConnectionChange).off("websocketerror", DashboardPage.onWebSocketConnectionChange).off("websocketclose", DashboardPage.onWebSocketConnectionChange);
2013-02-20 18:33:05 -07:00
DashboardPage.stopInterval();
},
startInterval: function () {
if (ApiClient.isWebSocketOpen()) {
ApiClient.sendWebSocketMessage("DashboardInfoStart", "0,1500");
2013-02-20 18:33:05 -07:00
}
},
stopInterval: function () {
if (ApiClient.isWebSocketOpen()) {
ApiClient.sendWebSocketMessage("DashboardInfoStop");
2013-02-20 18:33:05 -07:00
}
},
onWebSocketMessage: function (e, msg) {
2013-12-24 11:37:29 -07:00
var page = $.mobile.activePage;
2013-02-20 18:33:05 -07:00
if (msg.MessageType == "DashboardInfo") {
2013-12-24 11:37:29 -07:00
DashboardPage.renderInfo(page, msg.Data);
2013-02-20 18:33:05 -07:00
}
},
onWebSocketConnectionChange: function () {
DashboardPage.stopInterval();
DashboardPage.startInterval();
},
2013-12-24 11:37:29 -07:00
pollForInfo: function (page) {
$.getJSON("dashboardInfo").done(function (result) {
DashboardPage.renderInfo(page, result);
});
2013-02-20 18:33:05 -07:00
},
2013-12-24 11:37:29 -07:00
renderInfo: function (page, dashboardInfo) {
2013-02-20 18:33:05 -07:00
DashboardPage.lastDashboardInfo = dashboardInfo;
DashboardPage.renderRunningTasks(dashboardInfo);
2013-12-24 11:37:29 -07:00
DashboardPage.renderSystemInfo(page, dashboardInfo);
DashboardPage.renderActiveConnections(page, dashboardInfo);
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
},
2013-12-24 11:37:29 -07:00
renderActiveConnections: function (page, dashboardInfo) {
2013-02-20 18:33:05 -07:00
var html = '';
var container = $('.connections', page);
2013-02-20 18:33:05 -07:00
$('.sessionPosterItem', container).addClass('deadSession');
2014-01-02 14:21:06 -07:00
var deviceId = ApiClient.deviceId();
2013-02-20 18:33:05 -07:00
for (var i = 0, length = dashboardInfo.ActiveConnections.length; i < length; i++) {
var connection = dashboardInfo.ActiveConnections[i];
var itemId = 'session' + connection.Id;
2013-02-20 18:33:05 -07:00
var elem = $('#' + itemId, page);
if (elem.length) {
DashboardPage.updateSession(elem, connection);
continue;
}
html += '<div class="sessionPosterItem posterItem squarePosterItem" id="' + itemId + '" style="vertical-align:top;margin-bottom:2em;">';
var nowPlayingItem = connection.NowPlayingItem;
var imageUrl = DashboardPage.getNowPlayingImage(nowPlayingItem);
var style = "";
if (imageUrl) {
style += 'background-image:url(\'' + imageUrl + '\');';
}
var onclick = connection.DeviceId == deviceId ? '' : ' onclick="RemoteControl.showMenu({sessionId:\'' + connection.Id + '\'});"';
2013-02-20 18:33:05 -07:00
html += '<a' + onclick + ' data-imageurl="' + imageUrl + '" href="#" class="posterItemImage coveredPosterItemImage" style="' + style + 'background-color:#f2f2f2;display:block;">';
var defaultTextStyle = '';
2014-01-02 14:21:06 -07:00
if (nowPlayingItem) {
defaultTextStyle = "display:none;";
}
html += '<div class="posterItemDefaultText" style="' + defaultTextStyle + '">Nothing currently playing</div>';
html += '<div class="posterItemTextOverlay">';
2013-02-20 18:33:05 -07:00
var itemNameStyle='';
2013-02-20 18:33:05 -07:00
if (!nowPlayingItem) {
itemNameStyle = "display:none;";
}
html += '<div class="posterItemText posterItemName" style="' + itemNameStyle + '">' + (nowPlayingItem ? nowPlayingItem.Name : '') + '</div>';
var progressStyle='';
if (!nowPlayingItem) {
progressStyle = "display:none;";
}
html += "<div class='posterItemText posterItemProgress' style='" + progressStyle + "'>";
html += '<progress class="itemProgressBar" min="0" max="100" value="' + DashboardPage.getPlaybackProgress(connection) + '"></progress>';
html += "</div>";
html += "</div>";
html += '<img src="' + DashboardPage.getClientImage(connection) + '" style="top:10px;left:10px;height:24px;position:absolute;opacity: .95;" />';
html += '</a>';
html += '<div class="sessionItemText">' + DashboardPage.getSessionItemText(connection) + '</div>';
//html += '<td class="clientType" style="text-align:center;">';
//html += DashboardPage.getClientType(connection);
//html += '</td>';
//html += '<td>';
//html += '<div>';
//if (deviceId == connection.DeviceId) {
// html += connection.Client;
//} else {
// html += '<a href="#" onclick="RemoteControl.showMenu({sessionId:\'' + connection.Id + '\'});">' + connection.Client + '</a>';
//}
//html += '</div>';
2013-02-20 18:33:05 -07:00
//html += '</td>';
2013-02-20 18:33:05 -07:00
//html += '<td class="nowPlayingImage">';
//html += DashboardPage.getNowPlayingImage(nowPlayingItem);
//html += '</td>';
2013-02-20 18:33:05 -07:00
//html += '<td class="nowPlayingText">';
//html += DashboardPage.getNowPlayingText(connection, nowPlayingItem);
//html += '</td>';
html += '</div>';
2013-02-20 18:33:05 -07:00
}
container.append(html).trigger('create');
2013-02-20 18:33:05 -07:00
$('.deadSession', container).remove();
},
getPlaybackProgress: function (session) {
if (session.NowPlayingItem) {
if (session.NowPlayingItem.RunTimeTicks) {
var pct = (session.NowPlayingPositionTicks || 0) / session.NowPlayingItem.RunTimeTicks;
return pct * 100;
}
}
return 0;
},
2014-01-03 19:59:20 -07:00
getUsersHtml: function (session) {
var html = '<div>';
if (session.UserId) {
html += session.UserName;
}
2014-01-03 19:59:20 -07:00
html += session.AdditionalUsers.map(function (currentSession) {
return ', ' + currentSession.UserName;
2014-01-03 19:59:20 -07:00
});
html += '</div>';
2014-01-03 19:59:20 -07:00
return html;
},
updateSession: function (elem, session) {
2014-01-03 19:59:20 -07:00
elem.removeClass('deadSession');
2014-01-03 19:59:20 -07:00
$('.sessionItemText', elem).html(DashboardPage.getSessionItemText(session));
2014-01-03 19:59:20 -07:00
var nowPlayingItem = session.NowPlayingItem;
if (nowPlayingItem) {
$('.posterItemDefaultText', elem).hide();
$('.posterItemProgress', elem).show();
$('.posterItemName', elem).show().html(nowPlayingItem.Name);
$('progress', elem).val(DashboardPage.getPlaybackProgress(session));
} else {
$('.posterItemDefaultText', elem).show();
$('.posterItemProgress', elem).hide();
$('.posterItemName', elem).hide().html('');
}
var imageUrl = DashboardPage.getNowPlayingImage(nowPlayingItem);
var image = $('.posterItemImage', elem)[0];
if (imageUrl && imageUrl != image.getAttribute('data-imageurl')) {
image.style.backgroundImage = 'url(\'' + imageUrl + '\')';
image.setAttribute('data-imageurl', imageUrl);
} else if (!imageUrl && image.getAttribute('data-imageurl')) {
image.style.backgroundImage = null;
image.setAttribute('data-imageurl', '');
}
2013-02-20 18:33:05 -07:00
},
getSessionItemText: function (connection) {
var html = '';
html += '<div class="posterItemText">';
html += DashboardPage.getUsersHtml(connection);
html += '</div>';
//html += '<div class="posterItemText">' + connection.Client + '</div>';
//html += '<div class="posterItemText">' + connection.ApplicationVersion + '</div>';
html += '<div class="posterItemText">' + connection.DeviceName + '</div>';
return html;
},
getClientImage: function (connection) {
2013-02-20 18:33:05 -07:00
2013-03-21 13:20:00 -07:00
var clientLowered = connection.Client.toLowerCase();
2013-05-18 11:58:03 -07:00
2013-03-21 13:20:00 -07:00
if (clientLowered == "dashboard") {
2013-02-20 18:33:05 -07:00
2013-06-02 05:13:41 -07:00
var device = connection.DeviceName.toLowerCase();
var imgUrl;
if (device.indexOf('chrome') != -1) {
imgUrl = 'css/images/clients/chrome.png';
}
else if (device.indexOf('firefox') != -1) {
imgUrl = 'css/images/clients/firefox.png';
}
2013-07-28 06:58:26 -07:00
else if (device.indexOf('internet explorer') != -1) {
2013-06-02 05:13:41 -07:00
imgUrl = 'css/images/clients/ie.png';
}
else if (device.indexOf('safari') != -1) {
imgUrl = 'css/images/clients/safari.png';
}
else {
imgUrl = 'css/images/clients/html5.png';
}
return imgUrl;
2013-02-20 18:33:05 -07:00
}
2013-05-10 09:20:20 -07:00
if (clientLowered == "mb-classic") {
2013-03-21 13:20:00 -07:00
return "css/images/clients/mbc.png";
2013-03-21 13:20:00 -07:00
}
if (clientLowered == "media browser theater") {
2013-02-20 18:33:05 -07:00
return "css/images/clients/mb.png";
2013-02-20 18:33:05 -07:00
}
2013-03-21 13:20:00 -07:00
if (clientLowered == "android") {
2013-02-20 18:33:05 -07:00
return "css/images/clients/android.png";
2013-02-20 18:33:05 -07:00
}
2013-05-22 12:31:27 -07:00
if (clientLowered == "roku") {
return "css/images/clients/roku.jpg";
2013-05-22 12:31:27 -07:00
}
2013-03-21 13:20:00 -07:00
if (clientLowered == "ios") {
2013-02-20 18:33:05 -07:00
return "css/images/clients/ios.png";
2013-02-20 18:33:05 -07:00
}
2013-03-21 13:20:00 -07:00
if (clientLowered == "windows rt") {
2013-02-20 18:33:05 -07:00
return "css/images/clients/windowsrt.png";
2013-02-20 18:33:05 -07:00
}
2013-03-21 13:20:00 -07:00
if (clientLowered == "windows phone") {
2013-02-20 18:33:05 -07:00
return "css/images/clients/windowsphone.png";
2013-02-20 18:33:05 -07:00
}
2013-03-21 13:20:00 -07:00
if (clientLowered == "dlna") {
2013-03-04 19:32:14 -07:00
return "css/images/clients/dlna.png";
2013-03-04 19:32:14 -07:00
}
2013-08-09 07:25:54 -07:00
if (clientLowered == "mbkinect") {
return "css/images/clients/mbkinect.png";
2013-08-09 07:25:54 -07:00
}
2013-12-21 11:37:34 -07:00
if (clientLowered == "xbmc") {
return "css/images/clients/xbmc.png";
2013-12-21 11:37:34 -07:00
}
2013-02-20 18:33:05 -07:00
return "css/images/clients/mb.png";
2013-02-20 18:33:05 -07:00
},
getNowPlayingImage: function (item) {
if (item && item.ThumbItemId) {
return ApiClient.getImageUrl(item.ThumbItemId, {
type: "Thumb",
height: 300,
tag: item.ThumbImageTag
});
}
if (item && item.BackdropItemId) {
return ApiClient.getImageUrl(item.BackdropItemId, {
type: "Backdrop",
height: 300,
tag: item.BackdropImageTag
});
}
if (item && item.PrimaryImageTag) {
return ApiClient.getImageUrl(item.Id, {
type: "Primary",
height: 300,
tag: item.PrimaryImageTag
});
2013-02-20 18:33:05 -07:00
}
return "";
},
getNowPlayingText: function (connection, item) {
var html = "";
if (item) {
html += "<div><a href='itemdetails.html?id=" + item.Id + "'>" + item.Name + "</a></div>";
2013-02-20 18:33:05 -07:00
html += "<div>";
if (item.RunTimeTicks) {
2013-06-07 10:29:33 -07:00
html += Dashboard.getDisplayTime(connection.NowPlayingPositionTicks || 0) + " / ";
2013-02-20 18:33:05 -07:00
2013-06-07 10:29:33 -07:00
html += Dashboard.getDisplayTime(item.RunTimeTicks);
2013-02-20 18:33:05 -07:00
}
html += "</div>";
}
return html;
},
renderRunningTasks: function (dashboardInfo) {
var page = $.mobile.activePage;
var html = '';
if (!dashboardInfo.RunningTasks.length) {
html += '<p>No tasks are currently running.</p>';
2013-09-28 11:16:30 -07:00
$('#runningTasksCollapsible', page).hide();
} else {
$('#runningTasksCollapsible', page).show();
2013-02-20 18:33:05 -07:00
}
for (var i = 0, length = dashboardInfo.RunningTasks.length; i < length; i++) {
var task = dashboardInfo.RunningTasks[i];
html += '<p>';
html += task.Name;
if (task.State == "Running") {
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
2013-02-21 21:23:06 -07:00
html += '<span style="color:#267F00;margin-right:5px;font-weight:bold;"> - ' + progress + '%</span>';
2013-02-20 18:33:05 -07:00
2013-12-25 20:44:26 -07:00
html += '<button type="button" data-icon="stop" data-iconpos="notext" data-inline="true" data-mini="true" onclick="DashboardPage.stopTask(\'' + task.Id + '\');">Stop</button>';
2013-02-20 18:33:05 -07:00
}
else if (task.State == "Cancelling") {
html += '<span style="color:#cc0000;"> - Stopping</span>';
}
html += '</p>';
}
$('#divRunningTasks', page).html(html).trigger('create');
},
2013-12-24 11:37:29 -07:00
renderSystemInfo: function (page, dashboardInfo) {
2013-02-20 18:33:05 -07:00
Dashboard.updateSystemInfo(dashboardInfo.SystemInfo);
$('#appVersionNumber', page).html(dashboardInfo.SystemInfo.Version);
var port = dashboardInfo.SystemInfo.HttpServerPortNumber;
2013-05-18 11:58:03 -07:00
if (port == dashboardInfo.SystemInfo.WebSocketPortNumber) {
$('#ports', page).html('Running on port <b>' + port + '</b>');
} else {
$('#ports', page).html('Running on ports <b>' + port + '</b> and <b>' + dashboardInfo.SystemInfo.WebSocketPortNumber + '</b>');
}
2013-02-20 18:33:05 -07:00
if (dashboardInfo.RunningTasks.filter(function (task) {
return task.Id == dashboardInfo.ApplicationUpdateTaskId;
}).length) {
2013-12-24 11:37:29 -07:00
$('#btnUpdateApplication', page).buttonEnabled(false);
2013-02-20 18:33:05 -07:00
} else {
2013-12-24 11:37:29 -07:00
$('#btnUpdateApplication', page).buttonEnabled(true);
2013-02-20 18:33:05 -07:00
}
2013-12-24 11:37:29 -07:00
2013-10-07 07:38:31 -07:00
if (dashboardInfo.SystemInfo.CanSelfRestart) {
$('.btnRestartContainer', page).removeClass('hide');
} else {
$('.btnRestartContainer', page).addClass('hide');
}
2013-02-20 18:33:05 -07:00
2014-02-26 14:31:47 -07:00
DashboardPage.renderUrls(page, dashboardInfo.SystemInfo);
DashboardPage.renderApplicationUpdateInfo(page, dashboardInfo);
DashboardPage.renderPluginUpdateInfo(page, dashboardInfo);
DashboardPage.renderPendingInstallations(page, dashboardInfo.SystemInfo);
2013-02-20 18:33:05 -07:00
},
2014-02-26 14:31:47 -07:00
renderUrls: function (page, systemInfo) {
2014-02-26 14:31:47 -07:00
var url = ApiClient.serverAddress() + "/mediabrowser";
2013-02-20 18:33:05 -07:00
2014-02-26 14:31:47 -07:00
$('#bookmarkUrl', page).html(url).attr("href", url);
2013-02-20 18:33:05 -07:00
2014-02-26 14:31:47 -07:00
if (systemInfo.WanAddress) {
var externalUrl = systemInfo.WanAddress + "/mediabrowser";
$('.externalUrl', page).html('Remote access: <a href="' + externalUrl + '" target="_blank">' + externalUrl + '</a>').show().trigger('create');
} else {
$('.externalUrl', page).hide();
}
},
renderApplicationUpdateInfo: function (page, dashboardInfo) {
2013-02-20 18:33:05 -07:00
$('#updateFail', page).hide();
if (!dashboardInfo.SystemInfo.HasPendingRestart) {
2013-02-20 18:33:05 -07:00
// Only check once every 10 mins
if (DashboardPage.lastAppUpdateCheck && (new Date().getTime() - DashboardPage.lastAppUpdateCheck) < 600000) {
return;
}
DashboardPage.lastAppUpdateCheck = new Date().getTime();
ApiClient.getAvailableApplicationUpdate().done(function (packageInfo) {
2013-02-28 13:00:17 -07:00
var version = packageInfo[0];
2013-02-20 18:33:05 -07:00
if (!version) {
$('#pUpToDate', page).show();
$('#pUpdateNow', page).hide();
} else {
$('#pUpToDate', page).hide();
$('#pUpdateNow', page).show();
2013-12-24 11:37:29 -07:00
if (dashboardInfo.SystemInfo.CanSelfUpdate) {
$('#btnUpdateApplicationContainer', page).show();
$('#btnManualUpdateContainer', page).hide();
} else {
$('#btnUpdateApplicationContainer', page).hide();
$('#btnManualUpdateContainer', page).show();
}
2013-02-20 18:33:05 -07:00
$('#newVersionNumber', page).html("Version " + version.versionStr + " is now available for download.");
}
}).fail(function () {
$('#updateFail', page).show();
2013-02-20 18:33:05 -07:00
});
} else {
2013-02-20 18:33:05 -07:00
if (dashboardInfo.SystemInfo.HasPendingRestart) {
$('#pUpToDate', page).hide();
} else {
$('#pUpToDate', page).show();
}
2013-02-20 18:33:05 -07:00
$('#pUpdateNow', page).hide();
}
},
2014-02-26 14:31:47 -07:00
renderPendingInstallations: function (page, systemInfo) {
if (systemInfo.CompletedInstallations.length) {
$('#collapsiblePendingInstallations', page).show();
} else {
$('#collapsiblePendingInstallations', page).hide();
return;
}
var html = '';
for (var i = 0, length = systemInfo.CompletedInstallations.length; i < length; i++) {
var update = systemInfo.CompletedInstallations[i];
html += '<div><strong>' + update.Name + '</strong> (' + update.Version + ')</div>';
}
$('#pendingInstallations', page).html(html);
},
2014-02-26 14:31:47 -07:00
renderPluginUpdateInfo: function (page, dashboardInfo) {
2013-02-20 18:33:05 -07:00
// Only check once every 10 mins
if (DashboardPage.lastPluginUpdateCheck && (new Date().getTime() - DashboardPage.lastPluginUpdateCheck) < 600000) {
return;
}
DashboardPage.lastPluginUpdateCheck = new Date().getTime();
ApiClient.getAvailablePluginUpdates().done(function (updates) {
var elem = $('#pPluginUpdates', page);
2013-02-20 18:33:05 -07:00
if (updates.length) {
elem.show();
2013-02-20 18:33:05 -07:00
} else {
elem.hide();
2013-02-20 18:33:05 -07:00
return;
}
var html = '';
for (var i = 0, length = updates.length; i < length; i++) {
var update = updates[i];
html += '<p><strong>A new version of ' + update.name + ' is available!</strong></p>';
2014-01-14 22:01:58 -07:00
html += '<button type="button" data-icon="arrow-d" data-theme="b" onclick="DashboardPage.installPluginUpdate(this);" data-name="' + update.name + '" data-guid="' + update.guid + '" data-version="' + update.versionStr + '" data-classification="' + update.classification + '">Update Now</button>';
2013-02-20 18:33:05 -07:00
}
elem.html(html).trigger('create');
2013-02-20 18:33:05 -07:00
}).fail(function () {
2013-07-10 13:06:11 -07:00
$('#updateFail', page).show();
2013-02-20 18:33:05 -07:00
});
},
installPluginUpdate: function (button) {
2013-12-24 11:37:29 -07:00
$(button).buttonEnabled(false);
2013-02-20 18:33:05 -07:00
var name = button.getAttribute('data-name');
var guid = button.getAttribute('data-guid');
2013-02-20 18:33:05 -07:00
var version = button.getAttribute('data-version');
var classification = button.getAttribute('data-classification');
Dashboard.showLoadingMsg();
ApiClient.installPlugin(name, guid, classification, version).done(function () {
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
});
},
updateApplication: function () {
var page = $.mobile.activePage;
2013-12-24 11:37:29 -07:00
$('#btnUpdateApplication', page).buttonEnabled(false);
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
ApiClient.startScheduledTask(DashboardPage.lastDashboardInfo.ApplicationUpdateTaskId).done(function () {
2013-12-24 11:37:29 -07:00
DashboardPage.pollForInfo(page);
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
});
},
stopTask: function (id) {
2013-12-24 11:37:29 -07:00
var page = $.mobile.activePage;
2013-02-20 18:33:05 -07:00
ApiClient.stopScheduledTask(id).done(function () {
2013-12-24 11:37:29 -07:00
DashboardPage.pollForInfo(page);
2013-02-20 18:33:05 -07:00
});
},
restart: function () {
Dashboard.confirm("Are you sure you wish to restart Media Browser Server?", "Restart", function (result) {
if (result) {
2013-12-24 11:37:29 -07:00
$('#btnRestartServer').buttonEnabled(false);
$('#btnShutdown').buttonEnabled(false);
Dashboard.restartServer();
}
2013-10-01 08:16:38 -07:00
});
},
shutdown: function () {
Dashboard.confirm("Are you sure you wish to shutdown Media Browser Server?", "Shutdown", function (result) {
if (result) {
2013-12-24 11:37:29 -07:00
$('#btnRestartServer').buttonEnabled(false);
$('#btnShutdown').buttonEnabled(false);
2013-10-01 08:16:38 -07:00
ApiClient.shutdownServer();
}
});
2013-02-20 18:33:05 -07:00
}
};
$(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pagehide', "#dashboardPage", DashboardPage.onPageHide);