aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.WebDashboard
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.WebDashboard')
-rw-r--r--MediaBrowser.WebDashboard/Api/DashboardService.cs9
-rw-r--r--MediaBrowser.WebDashboard/ApiClient.js119
-rw-r--r--MediaBrowser.WebDashboard/packages.config2
3 files changed, 113 insertions, 17 deletions
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index 2c6b5532b..1c6cdad39 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -5,6 +5,7 @@ using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
+using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
@@ -118,6 +119,7 @@ namespace MediaBrowser.WebDashboard.Api
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
+ private readonly IFileSystem _fileSystem;
/// <summary>
/// Initializes a new instance of the <see cref="DashboardService" /> class.
@@ -126,13 +128,14 @@ namespace MediaBrowser.WebDashboard.Api
/// <param name="appHost">The app host.</param>
/// <param name="serverConfigurationManager">The server configuration manager.</param>
/// <param name="sessionManager">The session manager.</param>
- public DashboardService(ITaskManager taskManager, IServerApplicationHost appHost, IServerConfigurationManager serverConfigurationManager, ISessionManager sessionManager, IDtoService dtoService)
+ public DashboardService(ITaskManager taskManager, IServerApplicationHost appHost, IServerConfigurationManager serverConfigurationManager, ISessionManager sessionManager, IDtoService dtoService, IFileSystem fileSystem)
{
_taskManager = taskManager;
_appHost = appHost;
_serverConfigurationManager = serverConfigurationManager;
_sessionManager = sessionManager;
_dtoService = dtoService;
+ _fileSystem = fileSystem;
}
/// <summary>
@@ -324,7 +327,7 @@ namespace MediaBrowser.WebDashboard.Api
/// <returns>Task{Stream}.</returns>
private Stream GetRawResourceStream(string path)
{
- return new FileStream(GetDashboardResourcePath(path), FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true);
+ return _fileSystem.GetFileStream(GetDashboardResourcePath(path), FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true);
}
/// <summary>
@@ -611,7 +614,7 @@ namespace MediaBrowser.WebDashboard.Api
{
path = GetDashboardResourcePath(path);
- using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true))
+ using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
{
using (var streamReader = new StreamReader(fs))
{
diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js
index 97a443e84..25cbc9877 100644
--- a/MediaBrowser.WebDashboard/ApiClient.js
+++ b/MediaBrowser.WebDashboard/ApiClient.js
@@ -305,6 +305,75 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
url: url
});
};
+
+ function getRemoteImagePrefix(options) {
+
+ var urlPrefix;
+
+ if (options.artist) {
+ urlPrefix = "Artists/" + encodeName(options.artist);
+ delete options.artist;
+ }
+ else if (options.person) {
+ urlPrefix = "Persons/" + encodeName(options.person);
+ delete options.person;
+ }
+ else if (options.genre) {
+ urlPrefix = "Genres/" + encodeName(options.genre);
+ delete options.genre;
+ }
+ else if (options.musicGenre) {
+ urlPrefix = "MusicGenres/" + encodeName(options.musicGenre);
+ delete options.musicGenre;
+ }
+ else if (options.gameGenre) {
+ urlPrefix = "GameGenres/" + encodeName(options.gameGenre);
+ delete options.gameGenre;
+ }
+ else if (options.studio) {
+ urlPrefix = "Studios/" + encodeName(options.studio);
+ delete options.studio;
+ }
+ else {
+ urlPrefix = "Items/" + options.itemId;
+ delete options.itemId;
+ }
+
+ return urlPrefix;
+ }
+
+ self.getAvailableRemoteImages = function (options) {
+
+ if (!options) {
+ throw new Error("null options");
+ }
+
+ var urlPrefix = getRemoteImagePrefix(options);
+
+ var url = self.getUrl(urlPrefix + "/RemoteImages", options);
+
+ return self.ajax({
+ type: "GET",
+ url: url,
+ dataType: "json"
+ });
+ };
+
+ self.downloadRemoteImage = function (options) {
+
+ if (!options) {
+ throw new Error("null options");
+ }
+
+ var urlPrefix = getRemoteImagePrefix(options);
+
+ var url = self.getUrl(urlPrefix + "/RemoteImages/Download", options);
+
+ return self.ajax({
+ type: "POST",
+ url: url
+ });
+ };
/**
* Gets the current server status
@@ -2731,16 +2800,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
});
};
- /**
- * Marks an item as played or unplayed
- * This should not be used to update playstate following playback.
- * There are separate playstate check-in methods for that. This should be used for a
- * separate option to reset playstate.
- * @param {String} userId
- * @param {String} itemId
- * @param {Boolean} wasPlayed
- */
- self.updatePlayedStatus = function (userId, itemId, wasPlayed) {
+ self.getDateParamValue = function (date) {
+ function formatDigit(i) {
+ return i < 10 ? "0" + i : i;
+ }
+
+ var d = date;
+
+ return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds());
+ };
+
+ self.markPlayed = function (userId, itemId, date) {
if (!userId) {
throw new Error("null userId");
@@ -2750,12 +2820,35 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
throw new Error("null itemId");
}
- var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId);
+ var options = {};
- var method = wasPlayed ? "POST" : "DELETE";
+ if (date) {
+ options.DatePlayed = self.getDateParamValue(date);
+ }
+
+ var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId, options);
return self.ajax({
- type: method,
+ type: "POST",
+ url: url,
+ dataType: "json"
+ });
+ };
+
+ self.markUnplayed = function (userId, itemId) {
+
+ if (!userId) {
+ throw new Error("null userId");
+ }
+
+ if (!itemId) {
+ throw new Error("null itemId");
+ }
+
+ var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId);
+
+ return self.ajax({
+ type: "DELETE",
url: url,
dataType: "json"
});
diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config
index 9c48b3809..fb2cf4df5 100644
--- a/MediaBrowser.WebDashboard/packages.config
+++ b/MediaBrowser.WebDashboard/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="MediaBrowser.ApiClient.Javascript" version="3.0.181" targetFramework="net45" />
+ <package id="MediaBrowser.ApiClient.Javascript" version="3.0.187" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.62" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
</packages> \ No newline at end of file