Refactor host user security model, support static assets in modules and themes, module definition permissions and categories, paging control, remove SiteUsers, move seed data from script to site template for installation
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
@inject ITenantService TenantService
|
||||
@inject IAliasService AliasService
|
||||
@inject ISiteService SiteService
|
||||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@if (tenants == null)
|
||||
{
|
||||
@ -58,6 +58,34 @@ else
|
||||
<input class="form-control" @bind="@logo" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@themetype">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveSite">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
@ -66,15 +94,23 @@ else
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
List<Tenant> tenants;
|
||||
string tenantid = "";
|
||||
string name = "";
|
||||
string url = "";
|
||||
string logo = "";
|
||||
string themetype;
|
||||
string layouttype;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
tenants = await TenantService.GetTenantsAsync();
|
||||
url = PageState.Alias.Name;
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
}
|
||||
|
||||
private async Task SaveSite()
|
||||
@ -82,9 +118,9 @@ else
|
||||
Site site = new Site();
|
||||
site.Name = name;
|
||||
site.Logo = (logo == null ? "" : logo);
|
||||
await SiteService.AddSiteAsync(site);
|
||||
List<Site> sites = await SiteService.GetSitesAsync();
|
||||
site = sites.Where(item => item.Name == name).FirstOrDefault();
|
||||
site.DefaultThemeType = themetype;
|
||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
||||
site = await SiteService.AddSiteAsync(site);
|
||||
|
||||
Alias alias = new Alias();
|
||||
alias.Name = url;
|
||||
@ -92,28 +128,6 @@ else
|
||||
alias.SiteId = site.SiteId;
|
||||
await AliasService.AddAliasAsync(alias);
|
||||
|
||||
// need to add a home page and admin pages
|
||||
Page p = new Page();
|
||||
p.SiteId = site.SiteId;
|
||||
p.ParentId = null;
|
||||
p.Name = "Home";
|
||||
p.Path = "";
|
||||
p.Order = 1;
|
||||
p.IsNavigation = true;
|
||||
p.ThemeType = PageState.Site.DefaultThemeType;
|
||||
p.LayoutType = "";
|
||||
p.Icon = "";
|
||||
Type type = Type.GetType(p.ThemeType);
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
|
||||
List<PermissionString> permissionstrings = new List<PermissionString>();
|
||||
permissionstrings.Add(new PermissionString { PermissionName = "View", Permissions = Constants.AllUsersRole });
|
||||
permissionstrings.Add(new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole });
|
||||
p.Permissions = UserSecurity.SetPermissionStrings(permissionstrings);
|
||||
|
||||
await PageService.AddPageAsync(p);
|
||||
|
||||
NavigationManager.NavigateTo(url, true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user