Improved CSS handling
This commit is contained in:
@ -175,6 +175,9 @@
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
|
||||
themetype = PageState.Site.DefaultThemeType;
|
||||
layouttype = PageState.Site.DefaultLayoutType;
|
||||
|
||||
List<PermissionString> permissionstrings = new List<PermissionString>();
|
||||
permissionstrings.Add(new PermissionString { PermissionName = "View", Permissions = Constants.AdminRole });
|
||||
permissionstrings.Add(new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole });
|
||||
|
@ -11,7 +11,7 @@
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Page" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@PageState.Pages" DisplayPages="3" PageSize="3">
|
||||
<Pager Items="@PageState.Pages">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
|
@ -70,7 +70,7 @@
|
||||
{
|
||||
if (string.IsNullOrEmpty(PageSize))
|
||||
{
|
||||
MaxItems = 5;
|
||||
MaxItems = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -102,6 +102,10 @@
|
||||
{
|
||||
permissionnames = "View,Edit";
|
||||
}
|
||||
else
|
||||
{
|
||||
permissionnames = PermissionNames;
|
||||
}
|
||||
roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
||||
roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
||||
|
||||
|
42
Oqtane.Client/Modules/HelloWorld/Index.razor
Normal file
42
Oqtane.Client/Modules/HelloWorld/Index.razor
Normal file
@ -0,0 +1,42 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Services
|
||||
@namespace Oqtane.Modules.HelloWorld
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
|
||||
<div class="container">
|
||||
<div>
|
||||
<label for="Url" class="control-label">Image Url: </label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="Url" class="form-control" placeholder="Image Url" @bind="@url" />
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" @onclick="Save">Save</button>
|
||||
<div>
|
||||
@if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
<br />
|
||||
<img src="@url" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
string url = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||
url = SettingService.GetSetting(settings, "url", "");
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||
SettingService.SetSetting(settings, "url", url);
|
||||
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,16 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public class ModuleBase : ComponentBase, IModuleControl
|
||||
{
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
|
||||
@ -25,6 +30,16 @@ namespace Oqtane.Modules
|
||||
return "Modules/" + this.GetType().Namespace + "/";
|
||||
}
|
||||
|
||||
public async Task AddCSS(string Url)
|
||||
{
|
||||
if (!Url.StartsWith("http"))
|
||||
{
|
||||
Url = ModulePath() + Url;
|
||||
}
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.AddCSS("Module:" + Utilities.CreateIdFromUrl(Url), Url);
|
||||
}
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
|
@ -42,13 +42,13 @@ namespace Oqtane.Shared
|
||||
}
|
||||
}
|
||||
|
||||
public Task AddCSS(string filename)
|
||||
public Task AddCSS(string id, string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
jsRuntime.InvokeAsync<string>(
|
||||
"interop.addCSS",
|
||||
filename);
|
||||
id, url);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch
|
||||
@ -57,13 +57,13 @@ namespace Oqtane.Shared
|
||||
}
|
||||
}
|
||||
|
||||
public Task RemoveCSS(string filepattern)
|
||||
public Task RemoveCSS(string pattern)
|
||||
{
|
||||
try
|
||||
{
|
||||
jsRuntime.InvokeAsync<string>(
|
||||
"interop.removeCSS",
|
||||
filepattern);
|
||||
pattern);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch
|
||||
|
@ -35,7 +35,7 @@
|
||||
{
|
||||
// remove any custom CSS
|
||||
var interop = new Interop(jsRuntime);
|
||||
await interop.RemoveCSS("Themes/");
|
||||
await interop.RemoveCSS("Modules/");
|
||||
await interop.RemoveCSS("Theme:");
|
||||
await interop.RemoveCSS("Module:");
|
||||
}
|
||||
}
|
||||
|
@ -191,5 +191,10 @@ namespace Oqtane.Shared
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static string CreateIdFromUrl(string value)
|
||||
{
|
||||
return value.Replace("/", "_").Replace("\\", "_").Replace(".", "_");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Themes
|
||||
{
|
||||
public class ContainerBase : ComponentBase, IContainerControl
|
||||
{
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
|
||||
@ -14,6 +19,21 @@ namespace Oqtane.Themes
|
||||
|
||||
public virtual string Name { get; set; }
|
||||
|
||||
public string ThemePath()
|
||||
{
|
||||
return "Themes/" + this.GetType().Namespace + "/";
|
||||
}
|
||||
|
||||
public async Task AddCSS(string Url)
|
||||
{
|
||||
if (!Url.StartsWith("http"))
|
||||
{
|
||||
Url = ThemePath() + Url;
|
||||
}
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.AddCSS("Theme:" + Utilities.CreateIdFromUrl(Url), Url);
|
||||
}
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
|
@ -19,6 +19,11 @@
|
||||
<div id="actions" class="overlay">
|
||||
<a href="javascript:void(0)" class="closebtn" onclick="closeActions()">x</a>
|
||||
<div class="overlay-content">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary mx-auto" href="@NavigateUrl("admin")">Admin Dashboard</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary mx-auto" href="@PageUrl("Add")">Add Page</NavLink>
|
||||
@ -99,12 +104,6 @@
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary mx-auto" style="width: 100%;" @onclick="@AddModule">Add Module To Page</button>
|
||||
</div>
|
||||
<hr style="width: 100%; color: white; height: 1px; background-color:white;" />
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary mx-auto" href="@NavigateUrl("admin")">Admin Dashboard</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -1,10 +1,15 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using Oqtane.Shared;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Themes
|
||||
{
|
||||
public class ThemeBase : ComponentBase, IThemeControl
|
||||
{
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
@ -15,6 +20,16 @@ namespace Oqtane.Themes
|
||||
return "Themes/" + this.GetType().Namespace + "/";
|
||||
}
|
||||
|
||||
public async Task AddCSS(string Url)
|
||||
{
|
||||
if (!Url.StartsWith("http"))
|
||||
{
|
||||
Url = ThemePath() + Url;
|
||||
}
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.AddCSS("Theme:" + Utilities.CreateIdFromUrl(Url), Url);
|
||||
}
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
|
Reference in New Issue
Block a user