more install bits
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
@{
|
||||
@using Umbraco.Web
|
||||
@using Umbraco.Web.Install.Controllers
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
@@ -12,5 +14,13 @@
|
||||
<div>
|
||||
Hello world
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var Umbraco = {};
|
||||
Umbraco.Sys = {};
|
||||
Umbraco.Sys.ServerVariables = {
|
||||
"loginApiBaaseUrl": "@(Url.GetUmbracoApiServiceBaseUrl<InstallApiController>(controller => controller.GetStatus()))",
|
||||
"defaultStarterKit": Guid.NewGuid()
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public UmbracoContext UmbracoContext { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the install setup
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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<InstallStep>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the db can be connected to
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public HttpResponseMessage PostCheckDbConnection()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the db credentials are correct
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public HttpResponseMessage PostCheckDbCredentials()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does the install
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public HttpResponseMessage PostPerformInstall(InstallInstructions model)
|
||||
{
|
||||
var steps = GetSetup();
|
||||
|
||||
InstallStatusTracker.Initialize(steps.Steps);
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current install status
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDictionary<string, bool> GetStatus()
|
||||
{
|
||||
return InstallStatusTracker.GetStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
37
src/Umbraco.Web/Install/InstallStatusTracker.cs
Normal file
37
src/Umbraco.Web/Install/InstallStatusTracker.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// An internal in-memory status tracker for the current installation
|
||||
/// </summary>
|
||||
internal static class InstallStatusTracker
|
||||
{
|
||||
|
||||
private static ConcurrentDictionary<string, bool> _steps = new ConcurrentDictionary<string, bool>();
|
||||
|
||||
public static void Initialize(IEnumerable<InstallStep> 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<string, bool> GetStatus()
|
||||
{
|
||||
return new Dictionary<string, bool>(_steps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Used when we detect an upgrade but there is no user token associated
|
||||
/// </summary>
|
||||
UpgradeWithoutToken
|
||||
UpgradeWithoutToken,
|
||||
|
||||
/// <summary>
|
||||
/// Used if the user presses f5 and is in the middle of an install
|
||||
/// </summary>
|
||||
InProgress
|
||||
}
|
||||
|
||||
[DataContract(Name = "installSetup", Namespace = "")]
|
||||
public class InstallSetup
|
||||
{
|
||||
public InstallSetup()
|
||||
{
|
||||
Steps = new List<InstallStep>();
|
||||
}
|
||||
|
||||
[DataMember(Name = "status")]
|
||||
public InstallStatus Status { get; set; }
|
||||
|
||||
[DataMember(Name = "steps")]
|
||||
public IEnumerable<InstallStep> 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@
|
||||
<Compile Include="Editors\DataTypeValidateAttribute.cs" />
|
||||
<Compile Include="Editors\EntityControllerActionSelector.cs" />
|
||||
<Compile Include="Editors\ImagesController.cs" />
|
||||
<Compile Include="Install\InstallStatusTracker.cs" />
|
||||
<Compile Include="Install\UmbracoInstallArea.cs" />
|
||||
<Compile Include="Install\Controllers\InstallApiController.cs" />
|
||||
<Compile Include="Install\Controllers\InstallController.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
|
||||
/// <param name="routeVals"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUmbracoApiService<T>(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
|
||||
/// <param name="actionName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUmbracoApiServiceBaseUrl<T>(this UrlHelper url, string actionName)
|
||||
where T : UmbracoApiController
|
||||
where T : ApiController
|
||||
{
|
||||
return url.GetUmbracoApiService<T>(actionName).TrimEnd(actionName);
|
||||
}
|
||||
|
||||
public static string GetUmbracoApiServiceBaseUrl<T>(this UrlHelper url, Expression<Func<T, object>> 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<T>(this UrlHelper url, Expression<Func<T, object>> methodSelector)
|
||||
where T : UmbracoApiController
|
||||
where T : ApiController
|
||||
{
|
||||
var method = Core.ExpressionHelper.GetMethodInfo(methodSelector);
|
||||
if (method == null)
|
||||
|
||||
Reference in New Issue
Block a user