diff --git a/src/Umbraco.Web.UI/Areas/UmbracoInstall/Views/Install/Index.cshtml b/src/Umbraco.Web.UI/Areas/UmbracoInstall/Views/Install/Index.cshtml index 00bc03b40c..8d9a2f3f99 100644 --- a/src/Umbraco.Web.UI/Areas/UmbracoInstall/Views/Install/Index.cshtml +++ b/src/Umbraco.Web.UI/Areas/UmbracoInstall/Views/Install/Index.cshtml @@ -1,4 +1,6 @@ -@{ +@using Umbraco.Web +@using Umbraco.Web.Install.Controllers +@{ Layout = null; } @@ -12,5 +14,13 @@
Hello world
+ diff --git a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs index 4df536ff55..2b930d08e0 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs @@ -1,9 +1,15 @@ using System; +using System.Collections.Generic; +using System.Net.Http; using System.Web.Http; +using Umbraco.Core; +using Umbraco.Core.Configuration; +using Umbraco.Web.Install.Models; +using Umbraco.Web.WebApi; namespace Umbraco.Web.Install.Controllers { - + [AngularJsonOnlyConfiguration] [HttpInstallAuthorize] public class InstallApiController : ApiController { @@ -24,5 +30,88 @@ namespace Umbraco.Web.Install.Controllers /// public UmbracoContext UmbracoContext { get; private set; } + /// + /// Gets the install setup + /// + /// + public InstallSetup GetSetup() + { + var status = new InstallSetup() + { + Status = GlobalSettings.ConfigurationStatus.IsNullOrWhiteSpace() ? InstallStatus.NewInstall : InstallStatus.Upgrade + }; + + //TODO: Check for user/site token + + var steps = new List(); + + if (status.Status == InstallStatus.NewInstall) + { + steps.AddRange(new[] + { + new InstallStep() + { + Name = "User", + View = "user" + }, + new InstallStep() + { + Name = "Database", + View = "database" + }, + new InstallStep() + { + Name = "StarterKit", + View = "starterKit" + }, + }); + } + else + { + //TODO: Add steps for upgrades + } + + return status; + } + + /// + /// Checks if the db can be connected to + /// + /// + public HttpResponseMessage PostCheckDbConnection() + { + throw new NotImplementedException(); + } + + /// + /// Checks if the db credentials are correct + /// + /// + public HttpResponseMessage PostCheckDbCredentials() + { + throw new NotImplementedException(); + } + + /// + /// Does the install + /// + /// + public HttpResponseMessage PostPerformInstall(InstallInstructions model) + { + var steps = GetSetup(); + + InstallStatusTracker.Initialize(steps.Steps); + + throw new NotImplementedException(); + } + + /// + /// Returns the current install status + /// + /// + public IDictionary GetStatus() + { + return InstallStatusTracker.GetStatus(); + } } } diff --git a/src/Umbraco.Web/Install/InstallStatusTracker.cs b/src/Umbraco.Web/Install/InstallStatusTracker.cs new file mode 100644 index 0000000000..94b8ea8acf --- /dev/null +++ b/src/Umbraco.Web/Install/InstallStatusTracker.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Umbraco.Web.Install.Models; + +namespace Umbraco.Web.Install +{ + /// + /// An internal in-memory status tracker for the current installation + /// + internal static class InstallStatusTracker + { + + private static ConcurrentDictionary _steps = new ConcurrentDictionary(); + + public static void Initialize(IEnumerable steps) + { + foreach (var step in steps) + { + _steps.TryAdd(step.Name, step.IsComplete); + } + } + + public static void SetComplete(string name) + { + _steps.TryUpdate(name, true, true); + } + + public static IDictionary GetStatus() + { + return new Dictionary(_steps); + } + } +} diff --git a/src/Umbraco.Web/Install/Models/InstallStatus.cs b/src/Umbraco.Web/Install/Models/InstallStatus.cs index dc04b19e6d..7261885c55 100644 --- a/src/Umbraco.Web/Install/Models/InstallStatus.cs +++ b/src/Umbraco.Web/Install/Models/InstallStatus.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using System.ServiceModel.ComIntegration; using System.Text; using System.Threading.Tasks; @@ -15,14 +16,74 @@ namespace Umbraco.Web.Install.Models /// /// Used when we detect an upgrade but there is no user token associated /// - UpgradeWithoutToken + UpgradeWithoutToken, + + /// + /// Used if the user presses f5 and is in the middle of an install + /// + InProgress } [DataContract(Name = "installSetup", Namespace = "")] public class InstallSetup { + public InstallSetup() + { + Steps = new List(); + } + [DataMember(Name = "status")] public InstallStatus Status { get; set; } + [DataMember(Name = "steps")] + public IEnumerable Steps { get; set; } + + } + + [DataContract(Name = "step", Namespace = "")] + public class InstallStep + { + [DataMember(Name = "name")] + public string Name { get; set; } + + [DataMember(Name = "completed")] + public bool IsComplete { get; set; } + + [DataMember(Name = "view")] + public string View { get; set; } + } + + [DataContract(Name = "instructions", Namespace = "")] + public class InstallInstructions + { + [DataMember(Name = "dbType")] + public DatabaseType DatabaseType { get; set; } + + [DataMember(Name = "starterKit")] + public Guid StarterKit { get; set; } + + [DataMember(Name = "user")] + public UserModel User { get; set; } + } + + public class UserModel + { + [DataMember(Name = "name")] + public string Name { get; set; } + + [DataMember(Name = "email")] + public string Email { get; set; } + + [DataMember(Name = "password")] + public string Password { get; set; } + } + + public enum DatabaseType + { + SqlCe, + SqlServer, + MySql, + SqlAzure, + Custom } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index b8a9fe7aae..652910efe9 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -302,6 +302,7 @@ + diff --git a/src/Umbraco.Web/UrlHelperExtensions.cs b/src/Umbraco.Web/UrlHelperExtensions.cs index eb9b47eee1..55bf64830b 100644 --- a/src/Umbraco.Web/UrlHelperExtensions.cs +++ b/src/Umbraco.Web/UrlHelperExtensions.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Linq.Expressions; using System.Management.Instrumentation; +using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core; @@ -36,7 +37,7 @@ namespace Umbraco.Web /// /// public static string GetUmbracoApiService(this UrlHelper url, string actionName, RouteValueDictionary routeVals = null) - where T : UmbracoApiController + where T : ApiController { return url.GetUmbracoApiService(actionName, typeof(T), routeVals); } @@ -49,13 +50,13 @@ namespace Umbraco.Web /// /// public static string GetUmbracoApiServiceBaseUrl(this UrlHelper url, string actionName) - where T : UmbracoApiController + where T : ApiController { return url.GetUmbracoApiService(actionName).TrimEnd(actionName); } public static string GetUmbracoApiServiceBaseUrl(this UrlHelper url, Expression> methodSelector) - where T : UmbracoApiController + where T : ApiController { var method = Core.ExpressionHelper.GetMethodInfo(methodSelector); if (method == null) @@ -66,7 +67,7 @@ namespace Umbraco.Web } public static string GetUmbracoApiService(this UrlHelper url, Expression> methodSelector) - where T : UmbracoApiController + where T : ApiController { var method = Core.ExpressionHelper.GetMethodInfo(methodSelector); if (method == null)