Added support for friendly names and thumbnails in theme, layout, and container components. Added fallback support during loading for themes, layout, and containers.

This commit is contained in:
Shaun Walker 2020-06-01 14:58:46 -04:00
parent f45cb8b069
commit 1b7ca45d4a
26 changed files with 222 additions and 200 deletions

View File

@ -25,9 +25,9 @@
<td> <td>
<select id="container" class="form-control" @bind="@_containerType"> <select id="container" class="form-control" @bind="@_containerType">
<option value="-">&lt;Inherit From Page Or Site&gt;</option> <option value="-">&lt;Inherit From Page Or Site&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</td> </td>
@ -85,7 +85,7 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
private Dictionary<string, string> _containers; private List<ThemeControl> _containers = new List<ThemeControl>();
private string _title; private string _title;
private string _containerType; private string _containerType;
private string _allPages = "false"; private string _allPages = "false";
@ -105,7 +105,7 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_title = ModuleState.Title; _title = ModuleState.Title;
_containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync(), PageState.Page.ThemeType); _containers = ThemeService.GetContainerControls(await ThemeService.GetThemesAsync(), PageState.Page.ThemeType);
_containerType = ModuleState.ContainerType; _containerType = ModuleState.ContainerType;
if (!string.IsNullOrEmpty(PageState.Page.DefaultContainerType) && _containerType == PageState.Page.DefaultContainerType) if (!string.IsNullOrEmpty(PageState.Page.DefaultContainerType) && _containerType == PageState.Page.DefaultContainerType)
{ {

View File

@ -102,21 +102,21 @@
<td> <td>
<select id="Theme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="Theme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Inherit From Site&gt;</option> <option value="-">&lt;Inherit From Site&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (var theme in _themes)
{ {
if (item.Key == _themetype) if (theme.TypeName == _themetype)
{ {
<option value="@item.Key" selected>@item.Value</option> <option value="@theme.TypeName" selected>@theme.Name</option>
} }
else else
{ {
<option value="@item.Key">@item.Value</option> <option value="@theme.TypeName">@theme.Name</option>
} }
} }
</select> </select>
</td> </td>
</tr> </tr>
@if (_panelayouts.Count > 0) @if (_layouts.Count > 0)
{ {
<tr> <tr>
<td> <td>
@ -125,15 +125,15 @@
<td> <td>
<select id="Layout" class="form-control" @bind="@_layouttype"> <select id="Layout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Inherit From Site&gt;</option> <option value="-">&lt;Inherit From Site&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (var layout in _layouts)
{ {
if (panelayout.Key == _layouttype) if (layout.TypeName == _layouttype)
{ {
<option value="@panelayout.Key" selected>@panelayout.Value</option> <option value="@(layout.TypeName)" selected>@(layout.Name)</option>
} }
else else
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
} }
} }
</select> </select>
@ -147,9 +147,9 @@
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="-">&lt;Inherit From Site&gt;</option> <option value="-">&lt;Inherit From Site&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</td> </td>
@ -202,10 +202,10 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<Theme> _themeList; private List<Theme> _themeList;
private List<ThemeControl> _themes = new List<ThemeControl>();
private List<ThemeControl> _layouts = new List<ThemeControl>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private List<Page> _pageList; private List<Page> _pageList;
private string _name; private string _name;
private string _title; private string _title;
@ -235,7 +235,7 @@
_pageList = PageState.Pages; _pageList = PageState.Pages;
_children = PageState.Pages.Where(item => item.ParentId == null).ToList(); _children = PageState.Pages.Where(item => item.ParentId == null).ToList();
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeControls(_themeList);
_permissions = string.Empty; _permissions = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
@ -287,13 +287,13 @@
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _layouts = new List<ThemeControl>();
_containers = new Dictionary<string, string>(); _containers = new List<ThemeControl>();
} }
_layouttype = "-"; _layouttype = "-";
_containertype = "-"; _containertype = "-";
@ -311,7 +311,7 @@
Page page = null; Page page = null;
try try
{ {
if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype))) if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_layouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)))
{ {
page = new Page(); page = new Page();
page.SiteId = PageState.Page.SiteId; page.SiteId = PageState.Page.SiteId;

View File

@ -113,21 +113,21 @@
<td> <td>
<select id="Theme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="Theme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Inherit From Site&gt;</option> <option value="-">&lt;Inherit From Site&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (var theme in _themes)
{ {
if (item.Key == _themetype) if (theme.TypeName == _themetype)
{ {
<option value="@item.Key" selected>@item.Value</option> <option value="@theme.TypeName" selected>@theme.Name</option>
} }
else else
{ {
<option value="@item.Key">@item.Value</option> <option value="@theme.TypeName">@theme.Name</option>
} }
} }
</select> </select>
</td> </td>
</tr> </tr>
@if (_panelayouts.Count > 0) @if (_layouts.Count > 0)
{ {
<tr> <tr>
<td> <td>
@ -136,15 +136,15 @@
<td> <td>
<select id="Layout" class="form-control" @bind="@_layouttype"> <select id="Layout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Inherit From Site&gt;</option> <option value="-">&lt;Inherit From Site&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (var layout in _layouts)
{ {
if (panelayout.Key == _layouttype) if (layout.TypeName == _layouttype)
{ {
<option value="@panelayout.Key" selected>@panelayout.Value</option> <option value="@(layout.TypeName)" selected>@(layout.Name)</option>
} }
else else
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
} }
} }
</select> </select>
@ -158,9 +158,9 @@
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="-">&lt;Inherit From Site&gt;</option> <option value="-">&lt;Inherit From Site&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</td> </td>
@ -215,10 +215,10 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<Theme> _themeList; private List<Theme> _themeList;
private List<ThemeControl> _themes = new List<ThemeControl>();
private List<ThemeControl> _layouts = new List<ThemeControl>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private List<Page> _pageList; private List<Page> _pageList;
private int _pageId; private int _pageId;
private string _name; private string _name;
@ -255,11 +255,11 @@
{ {
try try
{ {
_themeList = await ThemeService.GetThemesAsync();
_pageList = PageState.Pages; _pageList = PageState.Pages;
_children = PageState.Pages.Where(item => item.ParentId == null).ToList(); _children = PageState.Pages.Where(item => item.ParentId == null).ToList();
_themes = ThemeService.GetThemeTypes(_themeList); _themeList = await ThemeService.GetThemesAsync();
_themes = ThemeService.GetThemeControls(_themeList);
_pageId = Int32.Parse(PageState.QueryString["id"]); _pageId = Int32.Parse(PageState.QueryString["id"]);
var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
@ -293,13 +293,13 @@
{ {
_themetype = "-"; _themetype = "-";
} }
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, page.ThemeType); _layouts = ThemeService.GetLayoutControls(_themeList, page.ThemeType);
_layouttype = page.LayoutType; _layouttype = page.LayoutType;
if (_layouttype == PageState.Site.DefaultLayoutType) if (_layouttype == PageState.Site.DefaultLayoutType)
{ {
_layouttype = "-"; _layouttype = "-";
} }
_containers = ThemeService.GetContainerTypes(_themeList, page.ThemeType); _containers = ThemeService.GetContainerControls(_themeList, page.ThemeType);
_containertype = page.DefaultContainerType; _containertype = page.DefaultContainerType;
if (string.IsNullOrEmpty(_containertype)) if (string.IsNullOrEmpty(_containertype))
{ {
@ -372,13 +372,13 @@
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _layouts = new List<ThemeControl>();
_containers = new Dictionary<string, string>(); _containers = new List<ThemeControl>();
} }
_layouttype = "-"; _layouttype = "-";
_containertype = "-"; _containertype = "-";

View File

@ -57,21 +57,21 @@
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Select Theme&gt;</option> <option value="-">&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (var theme in _themes)
{ {
if (item.Key == _themetype) if (theme.TypeName == _themetype)
{ {
<option value="@item.Key" selected>@item.Value</option> <option value="@theme.TypeName" selected>@theme.Name</option>
} }
else else
{ {
<option value="@item.Key">@item.Value</option> <option value="@theme.TypeName">@theme.Name</option>
} }
} }
</select> </select>
</td> </td>
</tr> </tr>
@if (_panelayouts.Count > 0) @if (_layouts.Count > 0)
{ {
<tr> <tr>
<td> <td>
@ -80,9 +80,9 @@
<td> <td>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> <select id="defaultLayout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Select Layout&gt;</option> <option value="-">&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (var layout in _layouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
} }
</select> </select>
</td> </td>
@ -95,9 +95,9 @@
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="-">&lt;Select Container&gt;</option> <option value="-">&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</td> </td>
@ -211,10 +211,10 @@
} }
@code { @code {
private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<Theme> _themeList; private List<Theme> _themeList;
private List<ThemeControl> _themes = new List<ThemeControl>();
private List<ThemeControl> _layouts = new List<ThemeControl>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private string _name = string.Empty; private string _name = string.Empty;
private List<Tenant> _tenantList; private List<Tenant> _tenantList;
private string _tenant = string.Empty; private string _tenant = string.Empty;
@ -274,10 +274,11 @@
_faviconfileid = site.FaviconFileId.Value; _faviconfileid = site.FaviconFileId.Value;
} }
_themes = ThemeService.GetThemeControls(_themeList);
_themetype = site.DefaultThemeType; _themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_layouttype = site.DefaultLayoutType; _layouttype = site.DefaultLayoutType;
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
_containertype = site.DefaultContainerType; _containertype = site.DefaultContainerType;
_allowregistration = site.AllowRegistration.ToString(); _allowregistration = site.AllowRegistration.ToString();
@ -318,9 +319,6 @@
_deletedon = site.DeletedOn; _deletedon = site.DeletedOn;
_isdeleted = site.IsDeleted.ToString(); _isdeleted = site.IsDeleted.ToString();
} }
_themes = ThemeService.GetThemeTypes(_themeList);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -336,13 +334,13 @@
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _layouts = new List<ThemeControl>();
_containers = new Dictionary<string, string>(); _containers = new List<ThemeControl>();
} }
_layouttype = "-"; _layouttype = "-";
_containertype = "-"; _containertype = "-";
@ -359,7 +357,7 @@
{ {
try try
{ {
if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_panelayouts.Count == 0 || _layouttype != "-") && _containertype != "-") if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-")
{ {
var unique = true; var unique = true;
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))

View File

@ -39,14 +39,14 @@ else
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Select Theme&gt;</option> <option value="-">&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (var theme in _themes)
{ {
<option value="@item.Key">@item.Value</option> <option value="@theme.TypeName">@theme.Name</option>
} }
</select> </select>
</td> </td>
</tr> </tr>
@if (_panelayouts.Count > 0) @if (_layouts.Count > 0)
{ {
<tr> <tr>
<td> <td>
@ -55,9 +55,9 @@ else
<td> <td>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> <select id="defaultLayout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Select Layout&gt;</option> <option value="-">&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (var layout in _layouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
} }
</select> </select>
</td> </td>
@ -70,9 +70,9 @@ else
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="-">&lt;Select Container&gt;</option> <option value="-">&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</td> </td>
@ -201,11 +201,11 @@ else
} }
@code { @code {
private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<SiteTemplate> _siteTemplates;
private List<Theme> _themeList; private List<Theme> _themeList;
private List<ThemeControl> _themes = new List<ThemeControl>();
private List<ThemeControl> _layouts = new List<ThemeControl>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private List<SiteTemplate> _siteTemplates;
private List<Tenant> _tenants; private List<Tenant> _tenants;
private string _tenantid = "-"; private string _tenantid = "-";
@ -230,10 +230,10 @@ else
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_themeList = await ThemeService.GetThemesAsync();
_tenants = await TenantService.GetTenantsAsync(); _tenants = await TenantService.GetTenantsAsync();
_urls = PageState.Alias.Name; _urls = PageState.Alias.Name;
_themes = ThemeService.GetThemeTypes(_themeList); _themeList = await ThemeService.GetThemesAsync();
_themes = ThemeService.GetThemeControls(_themeList);
_siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync(); _siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync();
} }
@ -267,13 +267,13 @@ else
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _layouts = new List<ThemeControl>();
_containers = new Dictionary<string, string>(); _containers = new List<ThemeControl>();
} }
_layouttype = "-"; _layouttype = "-";
_containertype = "-"; _containertype = "-";
@ -288,7 +288,7 @@ else
private async Task SaveSite() private async Task SaveSite()
{ {
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && (_panelayouts.Count == 0 || _layouttype != "-") && _containertype != "-" && _sitetemplatetype != "-") if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-" && _sitetemplatetype != "-")
{ {
var duplicates = new List<string>(); var duplicates = new List<string>();
var aliases = await AliasService.GetAliasesAsync(); var aliases = await AliasService.GetAliasesAsync();

View File

@ -40,21 +40,21 @@
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Select Theme&gt;</option> <option value="-">&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (var theme in _themes)
{ {
if (item.Key == _themetype) if (theme.TypeName == _themetype)
{ {
<option value="@item.Key" selected>@item.Value</option> <option value="@theme.TypeName" selected>@theme.Name</option>
} }
else else
{ {
<option value="@item.Key">@item.Value</option> <option value="@theme.TypeName">@theme.Name</option>
} }
} }
</select> </select>
</td> </td>
</tr> </tr>
@if (_panelayouts.Count > 0) @if (_layouts.Count > 0)
{ {
<tr> <tr>
<td> <td>
@ -63,9 +63,9 @@
<td> <td>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> <select id="defaultLayout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Select Layout&gt;</option> <option value="-">&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (var layout in _layouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
} }
</select> </select>
</td> </td>
@ -78,9 +78,9 @@
<td> <td>
<select id="defaultIdea" class="form-control" @bind="@_containertype"> <select id="defaultIdea" class="form-control" @bind="@_containertype">
<option value="-">&lt;Select Container&gt;</option> <option value="-">&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</td> </td>
@ -106,11 +106,11 @@
} }
@code { @code {
private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private Alias _alias;
private List<Theme> _themeList; private List<Theme> _themeList;
private List<ThemeControl> _themes = new List<ThemeControl>();
private List<ThemeControl> _layouts = new List<ThemeControl>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private Alias _alias;
private string _name = string.Empty; private string _name = string.Empty;
private List<Tenant> _tenantList; private List<Tenant> _tenantList;
private string _tenant = string.Empty; private string _tenant = string.Empty;
@ -150,11 +150,11 @@
_urls += alias.Name + "\n"; _urls += alias.Name + "\n";
} }
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeControls(_themeList);
_themetype = site.DefaultThemeType; _themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_layouttype = site.DefaultLayoutType; _layouttype = site.DefaultLayoutType;
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
_containertype = site.DefaultContainerType; _containertype = site.DefaultContainerType;
_createdby = site.CreatedBy; _createdby = site.CreatedBy;
_createdon = site.CreatedOn; _createdon = site.CreatedOn;
@ -179,13 +179,13 @@
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouts = ThemeService.GetLayoutControls(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype); _containers = ThemeService.GetContainerControls(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _layouts = new List<ThemeControl>();
_containers = new Dictionary<string, string>(); _containers = new List<ThemeControl>();
} }
_layouttype = "-"; _layouttype = "-";
_containertype = "-"; _containertype = "-";
@ -202,7 +202,7 @@
{ {
try try
{ {
if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_panelayouts.Count == 0 || _layouttype != "-") && _containertype != "-") if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-")
{ {
var unique = true; var unique = true;
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))

View File

@ -7,9 +7,9 @@ namespace Oqtane.Services
public interface IThemeService public interface IThemeService
{ {
Task<List<Theme>> GetThemesAsync(); Task<List<Theme>> GetThemesAsync();
Dictionary<string, string> GetThemeTypes(List<Theme> themes); List<ThemeControl> GetThemeControls(List<Theme> themes);
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes, string themeName); List<ThemeControl> GetLayoutControls(List<Theme> themes, string themeName);
Dictionary<string, string> GetContainerTypes(List<Theme> themes, string themeName); List<ThemeControl> GetContainerControls(List<Theme> themes, string themeName);
Task InstallThemesAsync(); Task InstallThemesAsync();
Task DeleteThemeAsync(string themeName); Task DeleteThemeAsync(string themeName);
} }

View File

@ -26,49 +26,21 @@ namespace Oqtane.Services
return themes.OrderBy(item => item.Name).ToList(); return themes.OrderBy(item => item.Name).ToList();
} }
public Dictionary<string, string> GetThemeTypes(List<Theme> themes) public List<ThemeControl> GetThemeControls(List<Theme> themes)
{ {
var selectableThemes = new Dictionary<string, string>(); return themes.SelectMany(item => item.Themes).ToList();
foreach (Theme theme in themes)
{
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
selectableThemes.Add(themecontrol, theme.Name + " - " + Utilities.GetTypeNameLastSegment(themecontrol, 0));
}
}
return selectableThemes;
} }
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes, string themeName) public List<ThemeControl> GetLayoutControls(List<Theme> themes, string themeName)
{ {
var selectablePaneLayouts = new Dictionary<string, string>(); return themes.Where(item => Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(item.ThemeName)))
foreach (Theme theme in themes) .SelectMany(item => item.Layouts).ToList();
{
if (Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(theme.ThemeName)))
{
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
selectablePaneLayouts.Add(panelayout, theme.Name + " - " + @Utilities.GetTypeNameLastSegment(panelayout, 0));
}
}
}
return selectablePaneLayouts;
} }
public Dictionary<string, string> GetContainerTypes(List<Theme> themes, string themeName) public List<ThemeControl> GetContainerControls(List<Theme> themes, string themeName)
{ {
var selectableContainers = new Dictionary<string, string>(); return themes.Where(item => Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(item.ThemeName)))
foreach (Theme theme in themes) .SelectMany(item => item.Containers).ToList();
{
if (Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(theme.ThemeName)))
{
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
selectableContainers.Add(container, theme.Name + " - " + @Utilities.GetTypeNameLastSegment(container, 0));
}
}
}
return selectableContainers;
} }
public async Task InstallThemesAsync() public async Task InstallThemesAsync()

View File

@ -17,6 +17,8 @@ namespace Oqtane.Themes
[CascadingParameter] [CascadingParameter]
protected Module ModuleState { get; set; } protected Module ModuleState { get; set; }
public virtual string Name { get; set; }
public virtual string Thumbnail { get; set; }
public string ThemePath() public string ThemePath()
{ {

View File

@ -161,9 +161,9 @@
<div class="col text-center"> <div class="col text-center">
<label for="Container" class="control-label">Container: </label> <label for="Container" class="control-label">Container: </label>
<select class="form-control" @bind="@ContainerType"> <select class="form-control" @bind="@ContainerType">
@foreach (KeyValuePair<string, string> container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.TypeName">@container.Name</option>
} }
</select> </select>
</div> </div>
@ -218,7 +218,7 @@
private List<ModuleDefinition> _moduleDefinitions; private List<ModuleDefinition> _moduleDefinitions;
private List<Page> _pages = new List<Page>(); private List<Page> _pages = new List<Page>();
private List<Module> _modules = new List<Module>(); private List<Module> _modules = new List<Module>();
private Dictionary<string, string> _containers = new Dictionary<string, string>(); private List<ThemeControl> _containers = new List<ThemeControl>();
private string _display = "display: none;"; private string _display = "display: none;";
private string _category = "Common"; private string _category = "Common";
@ -301,7 +301,7 @@
var panes = PageState.Page.Panes; var panes = PageState.Page.Panes;
Pane = panes.Count() == 1 ? panes.SingleOrDefault() : ""; Pane = panes.Count() == 1 ? panes.SingleOrDefault() : "";
var themes = await ThemeService.GetThemesAsync(); var themes = await ThemeService.GetThemesAsync();
_containers = ThemeService.GetContainerTypes(themes, PageState.Page.ThemeType); _containers = ThemeService.GetContainerControls(themes, PageState.Page.ThemeType);
ContainerType = PageState.Site.DefaultContainerType; ContainerType = PageState.Site.DefaultContainerType;
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId); _allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);

View File

@ -2,5 +2,7 @@
{ {
public interface IContainerControl public interface IContainerControl
{ {
string Name { get; } // friendly name for a container
string Thumbnail { get; } // screen shot of a container - assumed to be in the ThemePath() folder
} }
} }

View File

@ -2,7 +2,9 @@
{ {
public interface ILayoutControl public interface ILayoutControl
{ {
string Panes { get; } // identifies all panes in a theme ( delimited by ";" ) string Name { get; } // friendly name for a layout
string Thumbnail { get; } // screen shot of a layout - assumed to be in the ThemePath() folder
string Panes { get; } // identifies all panes in a theme ( delimited by "," or ";" )
} }
} }

View File

@ -8,6 +8,8 @@ namespace Oqtane.Themes
{ {
[CascadingParameter] [CascadingParameter]
protected PageState PageState { get; set; } protected PageState PageState { get; set; }
public virtual string Name { get; set; }
public virtual string Thumbnail { get; set; }
public virtual string Panes { get; set; } public virtual string Panes { get; set; }
public string LayoutPath() public string LayoutPath()

View File

@ -12,4 +12,8 @@
<ModuleInstance /> <ModuleInstance />
</div> </div>
</div> </div>
</div> </div>
@code {
public override string Name => "Standard Header";
}

View File

@ -17,6 +17,8 @@
</main> </main>
@code { @code {
public override string Name => "Default";
public override string Panes => string.Empty; public override string Panes => string.Empty;
public override List<Resource> Resources => new List<Resource>() public override List<Resource> Resources => new List<Resource>()

View File

@ -14,5 +14,7 @@
</div> </div>
@code { @code {
public override string Panes => "Top;Left;Content;Right;Bottom"; public override string Name => "Multiple Panes";
public override string Panes => "Top,Left,Content,Right,Bottom";
} }

View File

@ -6,4 +6,8 @@
<ModuleActions /> <ModuleActions />
} }
<ModuleInstance /> <ModuleInstance />
</div> </div>
@code {
public override string Name => "No Header";
}

View File

@ -6,5 +6,7 @@
</div> </div>
@code { @code {
public override string Name => "Single Pane";
public override string Panes => "Content"; public override string Panes => "Content";
} }

View File

@ -17,6 +17,8 @@ namespace Oqtane.Themes
[CascadingParameter] [CascadingParameter]
protected PageState PageState { get; set; } protected PageState PageState { get; set; }
public virtual string Name { get; set; }
public virtual string Thumbnail { get; set; }
public virtual string Panes { get; set; } public virtual string Panes { get; set; }
public virtual List<Resource> Resources { get; set; } public virtual List<Resource> Resources { get; set; }

View File

@ -27,18 +27,13 @@
DynamicComponent = builder => DynamicComponent = builder =>
{ {
Type containerType = Type.GetType(container); Type containerType = Type.GetType(container);
if (containerType != null) if (containerType == null)
{ {
builder.OpenComponent(0, containerType); // fallback
builder.CloseComponent(); containerType = Type.GetType(Constants.DefaultContainer);
}
else
{
// container does not exist with type specified
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageComponent));
builder.AddAttribute(1, "Message", "Error Loading Module Container " + container);
builder.CloseComponent();
} }
builder.OpenComponent(0, containerType);
builder.CloseComponent();
}; };
} }
} }

View File

@ -13,15 +13,13 @@
DynamicComponent = builder => DynamicComponent = builder =>
{ {
var layoutType = Type.GetType(PageState.Page.LayoutType); var layoutType = Type.GetType(PageState.Page.LayoutType);
if (layoutType != null) if (layoutType == null)
{ {
builder.OpenComponent(0, layoutType); // fallback
builder.CloseComponent(); layoutType = Type.GetType(Constants.DefaultLayout);
}
else
{
// layout does not exist with type specified
} }
builder.OpenComponent(0, layoutType);
builder.CloseComponent();
}; };
} }
} }

View File

@ -66,18 +66,13 @@
DynamicComponent = builder => DynamicComponent = builder =>
{ {
var themeType = Type.GetType(PageState.Page.ThemeType); var themeType = Type.GetType(PageState.Page.ThemeType);
if (themeType != null) if (themeType == null)
{ {
builder.OpenComponent(0, themeType); // fallback
builder.CloseComponent(); themeType = Type.GetType(Constants.DefaultTheme);
}
else
{
// theme does not exist with type specified
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageComponent));
builder.AddAttribute(1, "Message", "Error Loading Page Theme " + PageState.Page.ThemeType);
builder.CloseComponent();
} }
builder.OpenComponent(0, themeType);
builder.CloseComponent();
}; };
} }

View File

@ -87,26 +87,41 @@ namespace Oqtane.Repository
} }
// set internal properties // set internal properties
theme.ThemeName = qualifiedThemeType; theme.ThemeName = qualifiedThemeType;
theme.ThemeControls = ""; theme.Themes = new List<ThemeControl>();
theme.PaneLayouts = ""; theme.Layouts = new List<ThemeControl>();
theme.ContainerControls = ""; theme.Containers = new List<ThemeControl>();
theme.AssemblyName = assembly.FullName.Split(",")[0]; theme.AssemblyName = assembly.FullName.Split(",")[0];
themes.Add(theme); themes.Add(theme);
index = themes.FindIndex(item => item.ThemeName == qualifiedThemeType); index = themes.FindIndex(item => item.ThemeName == qualifiedThemeType);
} }
theme = themes[index]; theme = themes[index];
theme.ThemeControls += (themeControlType.FullName + ", " + themeControlType.Assembly.GetName().Name + ";");
var themecontrolobject = Activator.CreateInstance(themeControlType) as IThemeControl;
theme.Themes.Add(
new ThemeControl
{
TypeName = themeControlType.FullName + ", " + themeControlType.Assembly.GetName().Name,
Name = theme.Name + " - " + ((string.IsNullOrEmpty(themecontrolobject.Name)) ? Utilities.GetTypeNameLastSegment(themeControlType.FullName, 0) : themecontrolobject.Name),
Thumbnail = themecontrolobject.Thumbnail,
Panes = themecontrolobject.Panes
}
);
// layouts // layouts
Type[] layouttypes = themeTypes Type[] layouttypes = themeTypes
.Where(item => item.GetInterfaces().Contains(typeof(ILayoutControl))).ToArray(); .Where(item => item.GetInterfaces().Contains(typeof(ILayoutControl))).ToArray();
foreach (Type layouttype in layouttypes) foreach (Type layouttype in layouttypes)
{ {
string panelayout = layouttype.FullName + ", " + themeControlType.Assembly.GetName().Name + ";"; var layoutobject = Activator.CreateInstance(layouttype) as ILayoutControl;
if (!theme.PaneLayouts.Contains(panelayout)) theme.Layouts.Add(
{ new ThemeControl
theme.PaneLayouts += panelayout; {
} TypeName = layouttype.FullName + ", " + themeControlType.Assembly.GetName().Name,
Name = (string.IsNullOrEmpty(layoutobject.Name)) ? Utilities.GetTypeNameLastSegment(layouttype.FullName, 0) : layoutobject.Name,
Thumbnail = layoutobject.Thumbnail,
Panes = layoutobject.Panes
}
);
} }
// containers // containers
@ -114,11 +129,16 @@ namespace Oqtane.Repository
.Where(item => item.GetInterfaces().Contains(typeof(IContainerControl))).ToArray(); .Where(item => item.GetInterfaces().Contains(typeof(IContainerControl))).ToArray();
foreach (Type containertype in containertypes) foreach (Type containertype in containertypes)
{ {
string container = containertype.FullName + ", " + themeControlType.Assembly.GetName().Name + ";"; var containerobject = Activator.CreateInstance(containertype) as IContainerControl;
if (!theme.ContainerControls.Contains(container)) theme.Containers.Add(
{ new ThemeControl
theme.ContainerControls += container; {
} TypeName = containertype.FullName + ", " + themeControlType.Assembly.GetName().Name,
Name = (string.IsNullOrEmpty(containerobject.Name)) ? Utilities.GetTypeNameLastSegment(containertype.FullName, 0) : containerobject.Name,
Thumbnail = containerobject.Thumbnail,
Panes = ""
}
);
} }
themes[index] = theme; themes[index] = theme;

View File

@ -5,7 +5,9 @@ namespace Oqtane.Themes
{ {
public interface IThemeControl public interface IThemeControl
{ {
string Panes { get; } // identifies all panes in a theme ( delimited by ";" ) - assumed to be a layout if no panes specified string Name { get; } // friendly name for a theme
string Thumbnail { get; } // screen shot of a theme - assumed to be in the ThemePath() folder
string Panes { get; } // identifies all panes in a theme ( delimited by "," or ";") - assumed to be a layout if no panes specified
List<Resource> Resources { get; } // identifies all resources in a theme List<Resource> Resources { get; } // identifies all resources in a theme
} }
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace Oqtane.Models namespace Oqtane.Models
{ {
@ -23,9 +24,16 @@ namespace Oqtane.Models
public string Contact { get; set; } public string Contact { get; set; }
public string License { get; set; } public string License { get; set; }
public string Dependencies { get; set; } public string Dependencies { get; set; }
public string ThemeControls { get; set; }
public string PaneLayouts { get; set; }
public string ContainerControls { get; set; }
public string AssemblyName { get; set; } public string AssemblyName { get; set; }
public List<ThemeControl> Themes { get; set; }
public List<ThemeControl> Layouts { get; set; }
public List<ThemeControl> Containers { get; set; }
//[Obsolete("This property is obsolete. Use Themes instead.", false)]
public string ThemeControls { get; set; }
//[Obsolete("This property is obsolete. Use Layouts instead.", false)]
public string PaneLayouts { get; set; }
//[Obsolete("This property is obsolete. Use Containers instead.", false)]
public string ContainerControls { get; set; }
} }
} }

View File

@ -0,0 +1,10 @@
namespace Oqtane.Models
{
public class ThemeControl
{
public string TypeName { get; set; }
public string Name { get; set; }
public string Thumbnail { get; set; }
public string Panes { get; set; }
}
}