mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Some more work on the MT UI
- tenant database setup can be preconfigured - site setup UI reflects available settings (e.g. if database setup is preconfigured then don't show db options) - updated jQuery from 1.4.1 to 1.4.2 (finally) --HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Orchard.MultiTenancy.Annotations {
|
||||
public class SqlDatabaseConnectionStringAttribute : ValidationAttribute {
|
||||
public override bool IsValid(object value) {
|
||||
if (value is string && ((string) value).Length > 0) {
|
||||
try {
|
||||
var connectionStringBuilder = new SqlConnectionStringBuilder(value as string);
|
||||
|
||||
//TODO: (erikpo) Should the keys be checked here to ensure that a valid combination was entered? Needs investigation.
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -38,6 +38,9 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
Name = viewModel.Name,
|
||||
RequestUrlHost = viewModel.RequestUrlHost,
|
||||
RequestUrlPrefix = viewModel.RequestUrlPrefix,
|
||||
DataProvider = viewModel.DatabaseOptions != null ? ((bool)viewModel.DatabaseOptions ? "SQLite" : "SqlServer") : null,
|
||||
DataConnectionString = viewModel.DatabaseConnectionString,
|
||||
DataTablePrefix = viewModel.DatabaseTablePrefix,
|
||||
State = new TenantState("Uninitialized")
|
||||
});
|
||||
|
||||
|
@@ -4,12 +4,15 @@ using Orchard.Environment.Configuration;
|
||||
namespace Orchard.MultiTenancy.Extensions {
|
||||
public static class UrlHelperExtensions {
|
||||
public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) {
|
||||
//info: (heskew) might not keep the port insertion around beyond...
|
||||
var port = urlHelper.RequestContext.HttpContext.Request.Url.Port;
|
||||
return string.Format(
|
||||
"http://{0}/{1}",
|
||||
"http://{0}{2}/{1}",
|
||||
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
|
||||
? tenantShellSettings.RequestUrlHost
|
||||
: urlHelper.RequestContext.HttpContext.Request.Url.Host,
|
||||
tenantShellSettings.RequestUrlPrefix);
|
||||
tenantShellSettings.RequestUrlPrefix,
|
||||
port != 80 ? string.Format(":{0}", port) : "");
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,6 +61,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Annotations\SqlDatabaseConnectionStringAttribute.cs" />
|
||||
<Compile Include="Commands\TenantCommand.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Extensions\UrlHelperExtensions.cs" />
|
||||
|
@@ -1,13 +1,18 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.MultiTenancy.Annotations;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.MultiTenancy.ViewModels {
|
||||
public class TenantsAddViewModel : BaseViewModel {
|
||||
[Required, DisplayName("Tenant Name:")]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public string RequestUrlHost { get; set; }
|
||||
public string RequestUrlPrefix { get; set; }
|
||||
public bool? DatabaseOptions { get; set; }
|
||||
[SqlDatabaseConnectionString]
|
||||
public string DatabaseConnectionString { get; set; }
|
||||
public string DatabaseTablePrefix { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TenantsAddViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.MultiTenancy.ViewModels"%>
|
||||
<% Html.RegisterFootScript("multitenancy.js"); %>
|
||||
<h1><%=Html.TitleForPage(T("Add New Tenant").ToString()) %></h1>
|
||||
<%using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%= Html.ValidationSummary() %>
|
||||
@@ -18,18 +19,27 @@
|
||||
<fieldset>
|
||||
<legend><%=_Encoded("Database Setup") %></legend>
|
||||
<div>
|
||||
<input type="radio" name="" value="" />
|
||||
<label for="" class="forcheckbox"><%=_Encoded("Allow the client to set up the database") %></label>
|
||||
<input type="radio" name="<%=Html.NameOf(m => m.DatabaseOptions) %>" value="" id="tenantDatabaseOption" <%=Model.DatabaseOptions == null ? " checked=\"checked\"" : "" %>/>
|
||||
<label for="tenantDatabaseOption" class="forcheckbox"><%=_Encoded("Allow the client to set up the database") %></label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="" value="" />
|
||||
<label for="" class="forcheckbox"><%=_Encoded("Use built-in data storage") %></label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="" value="" />
|
||||
<label for="" class="forcheckbox"><%=_Encoded("Use an existing SQL Server (or SQL Express) database") %></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div>
|
||||
<%=Html.RadioButtonFor(svm => svm.DatabaseOptions, true, new { id = "builtinDatabaseOption" })%>
|
||||
<label for="builtinDatabaseOption" class="forcheckbox"><%=_Encoded("Use built-in data storage (SQLite)") %></label>
|
||||
</div>
|
||||
<div>
|
||||
<%=Html.RadioButtonFor(svm => svm.DatabaseOptions, false, new { id = "sqlDatabaseOption" })%>
|
||||
<label for="sqlDatabaseOption" class="forcheckbox"><%=_Encoded("Use an existing SQL Server (or SQL Express) database") %></label>
|
||||
<span data-controllerid="sqlDatabaseOption">
|
||||
<label for="DatabaseConnectionString"><%=_Encoded("Connection string") %></label>
|
||||
<%=Html.EditorFor(svm => svm.DatabaseConnectionString)%>
|
||||
<span class="hint"><%=_Encoded("Example:") %><br /><%=_Encoded("Data Source=sqlServerName;Initial Catalog=dbName;Persist Security Info=True;User ID=userName;Password=password") %></span>
|
||||
</span>
|
||||
<span data-controllerid="sqlDatabaseOption">
|
||||
<label for="DatabaseTablePrefix"><%=_Encoded("Database Table Prefix") %></label>
|
||||
<%=Html.EditorFor(svm => svm.DatabaseTablePrefix)%>
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<input type="submit" class="button primaryAction" value="<%=_Encoded("Save") %>" />
|
||||
</fieldset>
|
||||
|
@@ -1,3 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShellSettings>" %>
|
||||
<%@ Import Namespace="Orchard.MultiTenancy.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Environment.Configuration" %>
|
||||
<%=Html.ActionLink(T("Setup").ToString(), "_setup", new {tenantName = Model.Name, area = "Orchard.MultiTenancy"}) %>
|
||||
<%=Html.Link(T("Set Up").ToString(), Url.Tenant(Model))%>
|
@@ -5,24 +5,15 @@
|
||||
<%@ Import Namespace="Orchard.MultiTenancy.ViewModels"%>
|
||||
<h1><%=Html.TitleForPage(T("List of Site's Tenants").ToString())%></h1>
|
||||
<div class="manage"><%=Html.ActionLink(T("Add a Tenant").ToString(), "Add", new {area = "Orchard.MultiTenancy"}, new { @class = "button primaryAction" })%></div>
|
||||
<ul class="contentItems"><%
|
||||
<ul class="contentItems tenants"><%
|
||||
foreach (var tenant in Model.TenantSettings) { %>
|
||||
<li class="<%=tenant.State.CurrentState %>">
|
||||
<li class="tenant <%=tenant.State.CurrentState %>">
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<h3><span class="tenantState"><%
|
||||
if (tenant.State.CurrentState == TenantState.State.Running) {
|
||||
//todo: (heskew) need common shared resources (in the theme?) %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.MultiTenancy/Content/Admin/images/enabled.gif") %>" alt="<%=_Encoded("Running") %>" title="<%=_Encoded("This tenant is currently running") %>" /><%
|
||||
}
|
||||
else { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.MultiTenancy/Content/Admin/images/disabled.gif") %>" alt="<%=_Encoded("Not Running") %>" title="<%=_Encoded("This tenant is not running for some reason") %>" /><%
|
||||
} %></span>
|
||||
<span class="tenantName"><%=Html.Encode(tenant.Name) %></span><%
|
||||
<h3><span class="tenantName"><%=Html.Encode(tenant.Name) %></span><%
|
||||
if (!string.IsNullOrEmpty(tenant.RequestUrlHost)) {
|
||||
%><span class="tenantHost"> - <%=Html.Link(Url.Tenant(tenant), Url.Tenant(tenant))%></span><%
|
||||
} %>
|
||||
</h3>
|
||||
} %></h3>
|
||||
</div>
|
||||
<div class="related"><%
|
||||
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
||||
|
Reference in New Issue
Block a user