Merge pull request #11 from mitchelsellers/ThemeServiceChanges
ThemeService Improvements
This commit is contained in:
commit
068399f1f7
|
@ -80,14 +80,7 @@
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitAsync()
|
||||||
{
|
{
|
||||||
title = ModuleState.Title;
|
title = ModuleState.Title;
|
||||||
List<Theme> Themes = await ThemeService.GetThemesAsync();
|
containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
|
||||||
foreach (Theme theme in Themes)
|
|
||||||
{
|
|
||||||
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
containers.Add(container, theme.Name + " - " + @Utilities.GetTypeNameClass(container));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
containertype = ModuleState.ContainerType;
|
containertype = ModuleState.ContainerType;
|
||||||
viewpermissions = ModuleState.ViewPermissions;
|
viewpermissions = ModuleState.ViewPermissions;
|
||||||
editpermissions = ModuleState.EditPermissions;
|
editpermissions = ModuleState.EditPermissions;
|
||||||
|
|
|
@ -134,18 +134,9 @@
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitAsync()
|
||||||
{
|
{
|
||||||
List<Theme> Themes = await ThemeService.GetThemesAsync();
|
var Themes = await ThemeService.GetThemesAsync();
|
||||||
foreach (Theme theme in Themes)
|
themes = ThemeService.GetThemeTypes(Themes);
|
||||||
{
|
panelayouts = ThemeService.GetPaneLayoutTypes(Themes);
|
||||||
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
themes.Add(themecontrol, theme.Name + " - " + @Utilities.GetTypeNameClass(themecontrol));
|
|
||||||
}
|
|
||||||
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
panelayouts.Add(panelayout, theme.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SavePage()
|
private async Task SavePage()
|
||||||
|
|
|
@ -136,17 +136,8 @@
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitAsync()
|
||||||
{
|
{
|
||||||
List<Theme> Themes = await ThemeService.GetThemesAsync();
|
List<Theme> Themes = await ThemeService.GetThemesAsync();
|
||||||
foreach (Theme theme in Themes)
|
themes = ThemeService.GetThemeTypes(Themes);
|
||||||
{
|
panelayouts = ThemeService.GetPaneLayoutTypes(Themes);
|
||||||
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
themes.Add(themecontrol, theme.Name + " - " + @Utilities.GetTypeNameClass(themecontrol));
|
|
||||||
}
|
|
||||||
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
panelayouts.Add(panelayout, theme.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||||
|
|
|
@ -136,17 +136,8 @@
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitAsync()
|
||||||
{
|
{
|
||||||
List<Theme> Themes = await ThemeService.GetThemesAsync();
|
List<Theme> Themes = await ThemeService.GetThemesAsync();
|
||||||
foreach (Theme theme in Themes)
|
themes = ThemeService.GetThemeTypes(Themes);
|
||||||
{
|
panelayouts = ThemeService.GetPaneLayoutTypes(Themes);
|
||||||
foreach (string themeControl in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
themes.Add(themeControl, theme.Name + " - " + @Utilities.GetTypeNameClass(themeControl));
|
|
||||||
}
|
|
||||||
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
panelayouts.Add(panelayout, theme.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
using Oqtane.Models;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Oqtane.Services
|
|
||||||
{
|
|
||||||
public interface IThemeService
|
|
||||||
{
|
|
||||||
Task<List<Theme>> GetThemesAsync();
|
|
||||||
}
|
|
||||||
}
|
|
14
Oqtane.Client/Services/IthemeService.cs
Normal file
14
Oqtane.Client/Services/IthemeService.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IThemeService
|
||||||
|
{
|
||||||
|
Task<List<Theme>> GetThemesAsync();
|
||||||
|
Dictionary<string, string> GetThemeTypes(List<Theme> themes);
|
||||||
|
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes);
|
||||||
|
Dictionary<string, string> GetContainerTypes(List<Theme> themes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Services
|
namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
|
@ -21,7 +22,7 @@ namespace Oqtane.Services
|
||||||
this.http = http;
|
this.http = http;
|
||||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Theme");
|
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Theme");
|
||||||
}
|
}
|
||||||
|
//TODO: Implement Caching or otherwise on this, and other calls within this class
|
||||||
public async Task<List<Theme>> GetThemesAsync()
|
public async Task<List<Theme>> GetThemesAsync()
|
||||||
{
|
{
|
||||||
if (themes == null)
|
if (themes == null)
|
||||||
|
@ -56,5 +57,44 @@ 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)
|
||||||
|
{
|
||||||
|
var selectableThemes = new Dictionary<string, string>();
|
||||||
|
foreach (Theme theme in themes)
|
||||||
|
{
|
||||||
|
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
selectableThemes.Add(themecontrol, theme.Name + " - " + Utilities.GetTypeNameClass(themecontrol));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectableThemes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes)
|
||||||
|
{
|
||||||
|
var selectablePaneLayouts = new Dictionary<string, string>();
|
||||||
|
foreach (Theme theme in themes)
|
||||||
|
{
|
||||||
|
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
selectablePaneLayouts.Add(panelayout, theme.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectablePaneLayouts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string> GetContainerTypes(List<Theme> themes)
|
||||||
|
{
|
||||||
|
var selectableContainers = new Dictionary<string, string>();
|
||||||
|
foreach (Theme theme in themes)
|
||||||
|
{
|
||||||
|
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
selectableContainers.Add(container, theme.Name + " - " + @Utilities.GetTypeNameClass(container));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectableContainers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,14 +84,7 @@
|
||||||
{
|
{
|
||||||
//TODO: Move this to shared component. This is used in this control Add, Edit, and Delete controls as well
|
//TODO: Move this to shared component. This is used in this control Add, Edit, and Delete controls as well
|
||||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||||
List<Theme> themes = await ThemeService.GetThemesAsync();
|
containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
|
||||||
foreach (Theme theme in themes)
|
|
||||||
{
|
|
||||||
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
containers.Add(container, theme.Name + " - " + @Utilities.GetTypeNameClass(container));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, Constants.PageManagementModule);
|
List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, Constants.PageManagementModule);
|
||||||
pagemanagementmoduleid = modules.FirstOrDefault().ModuleId;
|
pagemanagementmoduleid = modules.FirstOrDefault().ModuleId;
|
||||||
if (UserService.IsAuthorized(PageState.User, PageState.Page.EditPermissions))
|
if (UserService.IsAuthorized(PageState.User, PageState.Page.EditPermissions))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user