diff --git a/src/Umbraco.Core/UrlHelperExtensions.cs b/src/Umbraco.Core/UrlHelperExtensions.cs index d2a12bbca8..4320bab5cc 100644 --- a/src/Umbraco.Core/UrlHelperExtensions.cs +++ b/src/Umbraco.Core/UrlHelperExtensions.cs @@ -13,17 +13,6 @@ namespace Umbraco.Core public static class UrlHelperExtensions { - /// - /// Returns the base path (not including the 'action') of the MVC controller "ExamineManagementController" - /// - /// - /// - public static string GetExamineManagementServicePath(this UrlHelper url) - { - var result = url.Action("Index", "ExamineManagement", new { area = GlobalSettings.UmbracoMvcArea }); - return result.TrimEnd("Index").EnsureEndsWith('/'); - } - /// /// Returns the base path (not including the 'action') of the MVC controller "SaveFileController" /// diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index c8a4b7b752..f65b71a4c7 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -68,6 +68,10 @@ True ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + False + ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll + False ..\packages\NUnit.2.6.2\lib\nunit.framework.dll @@ -86,12 +90,27 @@ True ..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.Entity.dll + + ..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll + + + ..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll + True ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll + + ..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dll + True ..\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll diff --git a/src/Umbraco.Tests/packages.config b/src/Umbraco.Tests/packages.config index fad9bf56f9..a4c2a47825 100644 --- a/src/Umbraco.Tests/packages.config +++ b/src/Umbraco.Tests/packages.config @@ -5,8 +5,14 @@ + + + + + + diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 6d13a9bee3..ec23a09a8f 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -1975,8 +1975,6 @@ - - diff --git a/src/Umbraco.Web.UI/umbraco/Views/ExamineManagement/ExamineDetails.cshtml b/src/Umbraco.Web.UI/umbraco/Views/ExamineManagement/ExamineDetails.cshtml deleted file mode 100644 index 13ef0ab4c9..0000000000 --- a/src/Umbraco.Web.UI/umbraco/Views/ExamineManagement/ExamineDetails.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@model Umbraco.Web.Search.ExamineDashboardDetails - -
-
-
-

Examine Management

- uGoLive -
-
-
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/Views/Web.config b/src/Umbraco.Web.UI/umbraco/Views/Web.config deleted file mode 100644 index edac1a2296..0000000000 --- a/src/Umbraco.Web.UI/umbraco/Views/Web.config +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Umbraco.Web.UI/umbraco/dashboard/ExamineManagement.ascx b/src/Umbraco.Web.UI/umbraco/dashboard/ExamineManagement.ascx index 5aca9fed9b..80db34a482 100644 --- a/src/Umbraco.Web.UI/umbraco/dashboard/ExamineManagement.ascx +++ b/src/Umbraco.Web.UI/umbraco/dashboard/ExamineManagement.ascx @@ -1,5 +1,7 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExamineManagement.ascx.cs" Inherits="Umbraco.Web.UI.Umbraco.Dashboard.ExamineManagement" %> <%@ Import Namespace="Umbraco.Core" %> +<%@ Import Namespace="Umbraco.Web" %> +<%@ Import Namespace="umbraco" %> <%@ Register TagPrefix="cc1" Namespace="Umbraco.Web.UI.Controls" Assembly="umbraco" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> @@ -24,9 +26,89 @@
-
- +
+
+
+

Examine Management

+ Examine Management + +
+ +
+ +

Indexers

+ +
+
+ + + + + + + + + + + + + + + +
Include node types
Exclude node types
Parent node id
+ +
+ System fields + + + + + + + + + + + + + + + +
NameEnable sortingType
+
+ +
+ User fields + + + + + + + + + + + + + + + +
NameEnable sortingType
+
+ + + + + + +
+ +
+
+ +
+
-
diff --git a/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.css b/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.css index 5f282702bb..39cf8f3d25 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.css +++ b/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.css @@ -1 +1,23 @@ - \ No newline at end of file +#examineManagement .indexer { + padding-top: 3px; +} + +#examineManagement .propertyPane { + padding: 5px; +} + +#examineManagement table th +{ + font-weight: bold; + width: 200px; +} +#examineManagement table td { + color: #999; +} + +#examineManagement .propertyPane strong +{ + color: #f26e20; + padding: 3px; + display: block; +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.js b/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.js index cf44c67b0c..87dcfb9c28 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.js +++ b/src/Umbraco.Web.UI/umbraco_client/Dashboards/ExamineManagement.js @@ -3,11 +3,21 @@ (function ($) { Umbraco.Dashboards.ExamineManagement = base2.Base.extend({ - + //private methods/variables _opts: null, _koViewModel: null, + _mapDictionaryToArray: function (dictionary) { + var result = []; + for (var key in dictionary) { + if (dictionary.hasOwnProperty(key)) { + result.push({ key: key, value: dictionary[key] }); + } + } + return result; + }, + // Constructor constructor: function (opts) { // Merge options with default @@ -20,29 +30,53 @@ init: function () { var self = this; - + //The knockout js view model for the selected item self._koViewModel = { - summary: ko.observable(""), - loading: ko.observable(false) + indexerDetails: ko.observable(""), + loading: ko.observable(false), + expandIndex: function () { + + } //publishAll: ko.observable(false), //includeUnpublished: ko.observable(false) }; - + ko.applyBindings(self._koViewModel, self._opts.container.get(0)); - this.loadSummary(); + this.loadDetails(); }, - - loadSummary: function() { + + loadDetails: function () { var self = this; self._koViewModel.loading(true); - $.get(self._opts.restServiceLocation + "Index", - function(e) { + $.get(self._opts.restServiceLocation + "GetIndexerDetails", + function (e) { self._koViewModel.loading(false); - self._koViewModel.summary(e); - }, "html").fail(function(a, b, c) { + + for (var item in e) { + //need to re-map the dictionary to an array so we can bind to it + e[item].IndexerProperties = self._mapDictionaryToArray(e[item].IndexerProperties); + //add a showProperties property to the object + e[item].showProperties = ko.observable(false); + //add a toggleProperties method + e[item].toggleProperties = function () { + this.showProperties(!this.showProperties()); + }; + //change the include/exclude node types to say something different if they are empty + e[item].IndexCriteria.IncludeNodeTypes = e[item].IndexCriteria.IncludeNodeTypes.join(); + e[item].IndexCriteria.ExcludeNodeTypes = e[item].IndexCriteria.ExcludeNodeTypes.join(); + if (e[item].IndexCriteria.IncludeNodeTypes == "") + e[item].IndexCriteria.IncludeNodeTypes = "Include all"; + if (e[item].IndexCriteria.ExcludeNodeTypes == "") + e[item].IndexCriteria.ExcludeNodeTypes = "Exclude none"; + //change the Standard and user fields to be an array so we can bind it + //e[item].IndexCriteria.StandardFields = self._mapDictionaryToArray(e[item].IndexerProperties); + } + + self._koViewModel.indexerDetails(e); + }).fail(function (a, b, c) { alert("error: " + b); }); } diff --git a/src/Umbraco.Web/Search/ExamineDetailsModel.cs b/src/Umbraco.Web/Search/ExamineDetailsModel.cs index ac72b6a832..0b80bdbe5c 100644 --- a/src/Umbraco.Web/Search/ExamineDetailsModel.cs +++ b/src/Umbraco.Web/Search/ExamineDetailsModel.cs @@ -8,17 +8,15 @@ namespace Umbraco.Web.Search { public class ExamineIndexerModel { - public string Name { get; set; } - public bool SupportsUnpublished { get; set; } - public bool SupportsProtected { get; set; } - public IIndexCriteria IndexCriteria { get; set; } + public ExamineIndexerModel() + { + IndexerProperties = new Dictionary(); + } + + public string Name { get; set; } + public IIndexCriteria IndexCriteria { get; set; } + + public IDictionary IndexerProperties { get; private set; } } - /// - /// Model to use to render the dashboard details - /// - public class ExamineDashboardDetails - { - public IEnumerable Indexers { get; set; } - } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 21e3a4a666..1825c03580 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -548,6 +548,7 @@ ASPXCodeBehind + @@ -1757,7 +1758,7 @@ - + diff --git a/src/Umbraco.Web/UrlHelperExtensions.cs b/src/Umbraco.Web/UrlHelperExtensions.cs index 68415c2f03..a60d765f87 100644 --- a/src/Umbraco.Web/UrlHelperExtensions.cs +++ b/src/Umbraco.Web/UrlHelperExtensions.cs @@ -4,6 +4,7 @@ using System.Web.Mvc; using Umbraco.Core; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; +using Umbraco.Web.WebServices; namespace Umbraco.Web { @@ -12,6 +13,17 @@ namespace Umbraco.Web /// public static class UrlHelperExtensions { + /// + /// Returns the base path (not including the 'action') of the MVC controller "ExamineManagementController" + /// + /// + /// + public static string GetExamineManagementServicePath(this UrlHelper url) + { + var result = url.GetUmbracoApiService("GetIndexerDetails"); + return result.TrimEnd("GetIndexerDetails").EnsureEndsWith('/'); + } + /// /// Return the Url for a Web Api service /// diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs new file mode 100644 index 0000000000..5134db9d97 --- /dev/null +++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs @@ -0,0 +1,69 @@ +using System; +using System.Web; +using System.Web.Http; +using Umbraco.Core.Configuration; +using Umbraco.Web.Security; +using umbraco.BusinessLogic; + +namespace Umbraco.Web.WebApi +{ + [UmbracoAuthorize] + public abstract class UmbracoAuthorizedApiController : UmbracoApiController + { + private User _user; + private bool _userisValidated = false; + + /// + /// The current user ID + /// + private int _uid = 0; + + /// + /// The page timeout in seconds. + /// + private long _timeout = 0; + + /// + /// Returns the currently logged in Umbraco User + /// + protected User UmbracoUser + { + get + { + if (!_userisValidated) ValidateUser(); + return _user; + } + } + + private void ValidateUser() + { + if ((WebSecurity.UmbracoUserContextId != "")) + { + _uid = WebSecurity.GetUserId(WebSecurity.UmbracoUserContextId); + _timeout = WebSecurity.GetTimeout(WebSecurity.UmbracoUserContextId); + + if (_timeout > DateTime.Now.Ticks) + { + _user = global::umbraco.BusinessLogic.User.GetUser(_uid); + + // Check for console access + if (_user.Disabled || (_user.NoConsole && GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && !GlobalSettings.RequestIsLiveEditRedirector(HttpContext.Current))) + { + throw new ArgumentException("You have no priviledges to the umbraco console. Please contact your administrator"); + } + _userisValidated = true; + WebSecurity.UpdateLogin(_timeout); + } + else + { + throw new ArgumentException("User has timed out!!"); + } + } + else + { + throw new InvalidOperationException("The user has no umbraco contextid - try logging in"); + } + + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs b/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs new file mode 100644 index 0000000000..f326076b15 --- /dev/null +++ b/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web.Mvc; +using Examine; +using Examine.LuceneEngine.Providers; +using Umbraco.Core; +using Umbraco.Core.Configuration; +using Umbraco.Web.Mvc; +using Umbraco.Web.Search; +using Umbraco.Web.WebApi; + +namespace Umbraco.Web.WebServices +{ + public class ExamineManagementApiController : UmbracoAuthorizedApiController + { + /// + /// Get the details + /// + /// + public IEnumerable GetIndexerDetails() + { + var model = new List( + ExamineManager.Instance.IndexProviderCollection.Select(indexer => + { + var indexerModel = new ExamineIndexerModel() + { + IndexCriteria = indexer.IndexerData, + Name = indexer.Name + }; + var props = TypeHelper.CachedDiscoverableProperties(indexer.GetType(), mustWrite: false) + //ignore these properties + .Where(x => !new[] { "IndexerData", "Description", "WorkingFolder" }.InvariantContains(x.Name)) + .OrderBy(x => x.Name); + foreach (var p in props) + { + indexerModel.IndexerProperties.Add(p.Name, p.GetValue(indexer, null).ToString()); + } + return indexerModel; + })); + return model; + } + + //public IEnumerable GetSearcherDetails() + //{ + // var model = new List( + // ExamineManager.Instance.IndexProviderCollection.Select(indexer => + // { + // var indexerModel = new ExamineIndexerModel() + // { + // IndexCriteria = indexer.IndexerData, + // Name = indexer.Name + // }; + // var props = TypeHelper.CachedDiscoverableProperties(indexer.GetType(), mustWrite: false) + // .OrderBy(x => x.Name); + // foreach (var p in props) + // { + // indexerModel.IndexerProperties.Add(p.Name, p.GetValue(indexer, null).ToString()); + // } + // return indexerModel; + // })); + // return model; + //} + + + } +} diff --git a/src/Umbraco.Web/WebServices/ExamineManagementController.cs b/src/Umbraco.Web/WebServices/ExamineManagementController.cs deleted file mode 100644 index 19e92cffeb..0000000000 --- a/src/Umbraco.Web/WebServices/ExamineManagementController.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web.Mvc; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Web.Mvc; - -namespace Umbraco.Web.WebServices -{ - public class ExamineManagementController : UmbracoAuthorizedController - { - /// - /// Get the details - /// - /// - public ActionResult Index() - { - return View("~" + GlobalSettings.Path.EnsureEndsWith('/').EnsureStartsWith('/') + "Views/ExamineManagement/ExamineDetails.cshtml"); - } - - } -} diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs index f29a20f0d3..6be57db384 100644 --- a/src/UmbracoExamine/UmbracoContentIndexer.cs +++ b/src/UmbracoExamine/UmbracoContentIndexer.cs @@ -341,7 +341,7 @@ namespace UmbracoExamine { if (CanInitialize()) { - return indexSet.ToIndexCriteria(DataService); + return indexSet.ToIndexCriteria(DataService, IndexFieldPolicies); } else {