aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-08-02 16:36:44 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-08-02 16:36:44 -0400
commita52ea4cf084c0e734fa9cd76e332b8e80d9f255b (patch)
tree707a0c4184e950329ba26fca6cf39586578b5fd1
parentf9e1f3f4e8857a4e2a9561664cbd36f769c01a6d (diff)
added metadata editor sidebar
-rw-r--r--MediaBrowser.Api/LibraryService.cs100
-rw-r--r--MediaBrowser.WebDashboard/Api/DashboardService.cs4
-rw-r--r--MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj75
3 files changed, 176 insertions, 3 deletions
diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs
index bad3b4796..91ca8a534 100644
--- a/MediaBrowser.Api/LibraryService.cs
+++ b/MediaBrowser.Api/LibraryService.cs
@@ -144,6 +144,25 @@ namespace MediaBrowser.Api
public Guid? UserId { get; set; }
}
+ [Route("/Items/{Id}/Ancestors", "GET")]
+ [Api(Description = "Gets all parents of an item")]
+ public class GetAncestors : IReturn<BaseItemDto[]>
+ {
+ /// <summary>
+ /// Gets or sets the user id.
+ /// </summary>
+ /// <value>The user id.</value>
+ [ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public Guid? UserId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the id.
+ /// </summary>
+ /// <value>The id.</value>
+ [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string Id { get; set; }
+ }
+
/// <summary>
/// Class LibraryService
/// </summary>
@@ -179,6 +198,84 @@ namespace MediaBrowser.Api
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
+ public object Get(GetAncestors request)
+ {
+ var result = GetAncestors(request).Result;
+
+ return ToOptimizedResult(result);
+ }
+
+ /// <summary>
+ /// Gets the ancestors.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <returns>Task{BaseItemDto[]}.</returns>
+ public async Task<BaseItemDto[]> GetAncestors(GetAncestors request)
+ {
+ var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
+
+ var tasks = new List<Task<BaseItemDto>>();
+
+ var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
+
+ // Get everything
+ var fields = Enum.GetNames(typeof(ItemFields))
+ .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
+ .ToList();
+
+ var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
+
+ BaseItem parent = item.Parent;
+
+ while (parent != null)
+ {
+ if (user != null)
+ {
+ parent = TranslateParentItem(parent, user);
+ }
+
+ tasks.Add(dtoBuilder.GetBaseItemDto(parent, fields, user));
+
+ if (parent is UserRootFolder)
+ {
+ break;
+ }
+
+ parent = parent.Parent;
+ }
+
+ return await Task.WhenAll(tasks).ConfigureAwait(false);
+ }
+
+ private BaseItem TranslateParentItem(BaseItem item, User user)
+ {
+ if (item.Parent is AggregateFolder)
+ {
+ return user.RootFolder.GetChildren(user, true).FirstOrDefault(i =>
+ {
+
+ try
+ {
+ return i.LocationType == LocationType.FileSystem &&
+ i.ResolveArgs.PhysicalLocations.Contains(item.Path);
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error getting ResolveArgs for {0}", ex, i.Path);
+ return false;
+ }
+
+ });
+ }
+
+ return item;
+ }
+
+ /// <summary>
+ /// Gets the specified request.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <returns>System.Object.</returns>
public object Get(GetCriticReviews request)
{
var result = GetCriticReviewsAsync(request).Result;
@@ -231,8 +328,7 @@ namespace MediaBrowser.Api
{
try
{
- await
- _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None)
+ await _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None)
.ConfigureAwait(false);
}
catch (Exception ex)
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index 11e842b2c..32cec1793 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -418,7 +418,8 @@ namespace MediaBrowser.WebDashboard.Api
{
"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js",
"http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js",
- "scripts/all.js" + versionString
+ "scripts/all.js" + versionString,
+ "thirdparty/jstree1.0fix2/jquery.jstree.js"
};
var tags = files.Select(s => string.Format("<script src=\"{0}\"></script>", s)).ToArray();
@@ -546,6 +547,7 @@ namespace MediaBrowser.WebDashboard.Api
"detailtable.css",
"posteritem.css",
"tileitem.css",
+ "metadataeditor.css",
"notifications.css",
"search.css",
"pluginupdates.css",
diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
index dbe0ba4ee..be836948b 100644
--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
@@ -90,6 +90,9 @@
<Content Include="dashboard-ui\css\images\remote.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\css\metadataeditor.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\css\notifications.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -515,6 +518,78 @@
<Content Include="dashboard-ui\thirdparty\html5slider.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\jquery.jstree.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\apple\bg.jpg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\apple\d.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\apple\dot_for_ie.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\apple\style.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\apple\throbber.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\classic\d.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\classic\d.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\classic\dot_for_ie.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\classic\style.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\classic\throbber.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default-rtl\d.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default-rtl\d.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default-rtl\dots.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default-rtl\style.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default-rtl\throbber.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default\d.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default\d.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default\style.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\default\throbber.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\mb3\d.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\mb3\d.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\mb3\style.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="dashboard-ui\thirdparty\jstree1.0fix2\themes\mb3\throbber.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\tvgenres.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>