Initial commit
This commit is contained in:
34
Oqtane.Client/Modules/Admin/Admin/Index.razor
Normal file
34
Oqtane.Client/Modules/Admin/Admin/Index.razor
Normal file
@ -0,0 +1,34 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models;
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IPageService PageService
|
||||
@inject IUserService UserService
|
||||
|
||||
<ul class="list-group">
|
||||
@foreach (var p in pages)
|
||||
{
|
||||
if (p.IsNavigation && UserService.IsAuthorized(PageState.User, p.ViewPermissions))
|
||||
{
|
||||
string url = PageState.Alias + p.Path;
|
||||
<li class="list-group-item">
|
||||
<NavLink class="nav-link" href="@url" Match="NavLinkMatch.All">
|
||||
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
|
||||
</NavLink>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
<br /><br />
|
||||
|
||||
@functions {
|
||||
List<Page> pages;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
// display list of pages which are children of current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
||||
}
|
||||
}
|
49
Oqtane.Client/Modules/Admin/Login/Index.razor
Normal file
49
Oqtane.Client/Modules/Admin/Login/Index.razor
Normal file
@ -0,0 +1,49 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Modules
|
||||
@using Microsoft.JSInterop
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IJSRuntime jsRuntime
|
||||
@inject IUserService UserService
|
||||
|
||||
<div class="container">
|
||||
@((MarkupString)Message)
|
||||
<div class="form-group">
|
||||
<label for="Username" class="control-label">Username: </label>
|
||||
<input type="text" name="Username" class="form-control" placeholder="Username" bind="@Username" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Password" class="control-label">Password: </label>
|
||||
<input type="password" name="Password" class="form-control" placeholder="Password" bind="@Password" />
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" onclick="@Login">Login</button>
|
||||
<NavLink class="btn btn" href="/">Cancel</NavLink>
|
||||
</div>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
||||
|
||||
public string Message { get; set; } = "<div class=\"alert alert-info\" role=\"alert\">Use host/host For Demo Access</div>";
|
||||
public string Username { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
|
||||
private async Task Login()
|
||||
{
|
||||
List<User> users = await UserService.GetUsersAsync();
|
||||
User user = users.Where(item => item.Username == Username).FirstOrDefault();
|
||||
if (user != null)
|
||||
{
|
||||
var interop = new Interop(jsRuntime);
|
||||
await interop.SetCookie("user", user.UserId.ToString(), 7);
|
||||
UriHelper.NavigateTo(PageState.Alias, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">User Does Not Exist</div>";
|
||||
}
|
||||
}
|
||||
}
|
41
Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor
Normal file
41
Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor
Normal file
@ -0,0 +1,41 @@
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
|
||||
@if (moduledefinitions == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var moduledefinition in moduledefinitions)
|
||||
{
|
||||
<tr>
|
||||
<td>@moduledefinition.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
|
||||
List<ModuleDefinition> moduledefinitions;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||
}
|
||||
}
|
115
Oqtane.Client/Modules/Admin/ModuleSettings/Index.razor
Normal file
115
Oqtane.Client/Modules/Admin/ModuleSettings/Index.razor
Normal file
@ -0,0 +1,115 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject ISkinService SkinService
|
||||
@inject IModuleService ModuleService
|
||||
@inject IPageModuleService PageModuleService
|
||||
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label">Title: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="Title" class="form-control" bind="@title" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Container" class="control-label">Container: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@containertype">
|
||||
<option value=""><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string> container in containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="ViewPermissions" class="control-label">View Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="ViewPermissions" class="form-control" bind="@viewpermissions" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="EditPermissions" class="control-label">Edit Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="EditPermissions" class="form-control" bind="@editpermissions" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Page" class="control-label">Page: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@pageid">
|
||||
@foreach (Page p in PageState.Pages)
|
||||
{
|
||||
<option value="@p.PageId">@p.Name</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SaveModule">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Edit; } }
|
||||
|
||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||
string title;
|
||||
string containertype;
|
||||
string viewpermissions;
|
||||
string editpermissions;
|
||||
string pageid;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
title = ModuleState.Title;
|
||||
List<Skin> Skins = await SkinService.GetSkinsAsync();
|
||||
foreach (Skin skin in Skins)
|
||||
{
|
||||
foreach (string container in skin.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
containers.Add(container, skin.Name + " - " + @Utilities.GetTypeNameClass(container));
|
||||
}
|
||||
}
|
||||
containertype = ModuleState.ContainerType;
|
||||
viewpermissions = ModuleState.ViewPermissions;
|
||||
editpermissions = ModuleState.EditPermissions;
|
||||
pageid = ModuleState.PageId.ToString();
|
||||
}
|
||||
|
||||
private async Task SaveModule()
|
||||
{
|
||||
Module module = ModuleState;
|
||||
module.ViewPermissions = viewpermissions;
|
||||
module.EditPermissions = editpermissions;
|
||||
await ModuleService.UpdateModuleAsync(module);
|
||||
|
||||
PageModule pagemodule = new PageModule();
|
||||
pagemodule.PageModuleId = ModuleState.PageModuleId;
|
||||
pagemodule.PageId = Int32.Parse(pageid);
|
||||
pagemodule.ModuleId = ModuleState.ModuleId;
|
||||
pagemodule.Title = title;
|
||||
pagemodule.Pane = ModuleState.Pane;
|
||||
pagemodule.Order = ModuleState.Order;
|
||||
pagemodule.ContainerType = containertype;
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
|
||||
UriHelper.NavigateTo(NavigateUrl(true));
|
||||
}
|
||||
}
|
187
Oqtane.Client/Modules/Admin/Pages/Add.razor
Normal file
187
Oqtane.Client/Modules/Admin/Pages/Add.razor
Normal file
@ -0,0 +1,187 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IPageService PageService
|
||||
@inject ISkinService SkinService
|
||||
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@parentid">
|
||||
<option value=""><Select Parent></option>
|
||||
@foreach (Page p in PageState.Pages)
|
||||
{
|
||||
<option value="@p.PageId">@p.Name</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Order: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@order" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@isnavigation">
|
||||
<option value="true">Yes</option>
|
||||
<option value="false">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Skin: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@skintype">
|
||||
<option value=""><Select Skin></option>
|
||||
@foreach (KeyValuePair<string, string> skin in skins)
|
||||
{
|
||||
<option value="@skin.Key">@skin.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">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>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">View Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@viewpermissions" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Edit Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@editpermissions" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SavePage">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
|
||||
Dictionary<string, string> skins = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
string name;
|
||||
string path;
|
||||
string parentid;
|
||||
string order = "";
|
||||
string isnavigation = "True";
|
||||
string skintype;
|
||||
string layouttype = "";
|
||||
string icon = "";
|
||||
string viewpermissions = "All Users";
|
||||
string editpermissions = "Administrators";
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
List<Skin> Skins = await SkinService.GetSkinsAsync();
|
||||
foreach (Skin skin in Skins)
|
||||
{
|
||||
foreach (string skincontrol in skin.SkinControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
skins.Add(skincontrol, skin.Name + " - " + @Utilities.GetTypeNameClass(skincontrol));
|
||||
}
|
||||
foreach (string panelayout in skin.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
panelayouts.Add(panelayout, skin.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SavePage()
|
||||
{
|
||||
Page p = new Page();
|
||||
p.SiteId = PageState.Page.SiteId;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
p.ParentId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.ParentId = Int32.Parse(parentid);
|
||||
}
|
||||
p.Name = name;
|
||||
p.Path = path;
|
||||
p.Order = (order == null ? 1 : Int32.Parse(order));
|
||||
p.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
p.SkinType = skintype;
|
||||
p.LayoutType = (layouttype == null ? "" : layouttype);
|
||||
p.Icon = (icon == null ? "" : icon);
|
||||
Type type;
|
||||
if (!string.IsNullOrEmpty(layouttype))
|
||||
{
|
||||
type = Type.GetType(layouttype);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Type.GetType(skintype);
|
||||
}
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
p.ViewPermissions = viewpermissions;
|
||||
p.EditPermissions = editpermissions;
|
||||
await PageService.AddPageAsync(p);
|
||||
StateHasChanged();
|
||||
UriHelper.NavigateTo(NavigateUrl(path, true));
|
||||
}
|
||||
}
|
173
Oqtane.Client/Modules/Admin/Pages/Delete.razor
Normal file
173
Oqtane.Client/Modules/Admin/Pages/Delete.razor
Normal file
@ -0,0 +1,173 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IPageService PageService
|
||||
@inject ISkinService SkinService
|
||||
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@name" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@path" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@parentid" readonly>
|
||||
<option value=""><Select Parent></option>
|
||||
@foreach (Page p in PageState.Pages)
|
||||
{
|
||||
<option value="@p.PageId">@p.Name</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Order: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@order" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@isnavigation" readonly>
|
||||
<option value="true">Yes</option>
|
||||
<option value="false">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Skin: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@skintype">
|
||||
<option value=""><Select Skin></option>
|
||||
@foreach (KeyValuePair<string, string> skin in skins)
|
||||
{
|
||||
<option value="@skin.Key">@skin.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">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>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@icon" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">View Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@viewpermissions" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Edit Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@editpermissions" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@DeletePage">Delete</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
|
||||
Dictionary<string, string> skins = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
int PageId;
|
||||
string name;
|
||||
string path;
|
||||
string parentid;
|
||||
string order;
|
||||
string isnavigation;
|
||||
string skintype;
|
||||
string layouttype;
|
||||
string icon;
|
||||
string viewpermissions;
|
||||
string editpermissions;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
List<Skin> Skins = await SkinService.GetSkinsAsync();
|
||||
foreach (Skin skin in Skins)
|
||||
{
|
||||
foreach (string skincontrol in skin.SkinControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
skins.Add(skincontrol, skin.Name + " - " + @Utilities.GetTypeNameClass(skincontrol));
|
||||
}
|
||||
foreach (string panelayout in skin.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
panelayouts.Add(panelayout, skin.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
||||
}
|
||||
}
|
||||
|
||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||
if (p != null)
|
||||
{
|
||||
name = p.Name;
|
||||
path = p.Path;
|
||||
|
||||
order = p.Order.ToString();
|
||||
isnavigation = p.IsNavigation.ToString();
|
||||
skintype = p.SkinType;
|
||||
layouttype = p.LayoutType;
|
||||
icon = p.Icon;
|
||||
viewpermissions = p.ViewPermissions;
|
||||
editpermissions = p.EditPermissions;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeletePage()
|
||||
{
|
||||
await PageService.DeletePageAsync(Int32.Parse(PageState.QueryString["id"]));
|
||||
UriHelper.NavigateTo(PageState.Alias);
|
||||
}
|
||||
}
|
210
Oqtane.Client/Modules/Admin/Pages/Edit.razor
Normal file
210
Oqtane.Client/Modules/Admin/Pages/Edit.razor
Normal file
@ -0,0 +1,210 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IPageService PageService
|
||||
@inject ISkinService SkinService
|
||||
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@parentid">
|
||||
<option value=""><Select Parent></option>
|
||||
@foreach (Page p in PageState.Pages)
|
||||
{
|
||||
<option value="@p.PageId">@p.Name</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Order: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@order" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@isnavigation">
|
||||
<option value="true">Yes</option>
|
||||
<option value="false">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Skin: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@skintype">
|
||||
<option value=""><Select Skin></option>
|
||||
@foreach (KeyValuePair<string, string> skin in skins)
|
||||
{
|
||||
<option value="@skin.Key">@skin.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">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>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">View Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@viewpermissions" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Edit Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@editpermissions" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SavePage">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
|
||||
Dictionary<string, string> skins = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
int PageId;
|
||||
string name;
|
||||
string path;
|
||||
string parentid;
|
||||
string order;
|
||||
string isnavigation;
|
||||
string skintype;
|
||||
string layouttype;
|
||||
string icon;
|
||||
string viewpermissions;
|
||||
string editpermissions;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
List<Skin> Skins = await SkinService.GetSkinsAsync();
|
||||
foreach (Skin skin in Skins)
|
||||
{
|
||||
foreach (string skincontrol in skin.SkinControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
skins.Add(skincontrol, skin.Name + " - " + @Utilities.GetTypeNameClass(skincontrol));
|
||||
}
|
||||
foreach (string panelayout in skin.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
panelayouts.Add(panelayout, skin.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
||||
}
|
||||
}
|
||||
|
||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||
if (p != null)
|
||||
{
|
||||
name = p.Name;
|
||||
path = p.Path;
|
||||
if (p.ParentId == null)
|
||||
{
|
||||
parentid = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
parentid = p.ParentId.ToString();
|
||||
}
|
||||
order = p.Order.ToString();
|
||||
isnavigation = p.IsNavigation.ToString();
|
||||
skintype = p.SkinType;
|
||||
layouttype = p.LayoutType;
|
||||
icon = p.Icon;
|
||||
viewpermissions = p.ViewPermissions;
|
||||
editpermissions = p.EditPermissions;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SavePage()
|
||||
{
|
||||
Page p = PageState.Page;
|
||||
p.PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
p.ParentId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.ParentId = Int32.Parse(parentid);
|
||||
}
|
||||
p.Name = name;
|
||||
p.Path = path;
|
||||
p.Order = (order == null ? 1 : Int32.Parse(order));
|
||||
p.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
p.SkinType = skintype;
|
||||
p.LayoutType = (layouttype == null ? "" : layouttype);
|
||||
p.Icon = (icon == null ? "" : icon);
|
||||
Type type;
|
||||
if (!string.IsNullOrEmpty(layouttype))
|
||||
{
|
||||
type = Type.GetType(layouttype);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Type.GetType(skintype);
|
||||
}
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
p.ViewPermissions = viewpermissions;
|
||||
p.EditPermissions = editpermissions;
|
||||
await PageService.UpdatePageAsync(p);
|
||||
UriHelper.NavigateTo(NavigateUrl(path));
|
||||
}
|
||||
}
|
40
Oqtane.Client/Modules/Admin/Pages/Index.razor
Normal file
40
Oqtane.Client/Modules/Admin/Pages/Index.razor
Normal file
@ -0,0 +1,40 @@
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@inject IPageService PageService
|
||||
|
||||
@if (PageState.Pages == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Path</th>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var p in PageState.Pages)
|
||||
{
|
||||
<tr>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + p.PageId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + p.PageId.ToString())" /></td>
|
||||
<td>@p.Path</td>
|
||||
<td>@p.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Add Page" />
|
||||
}
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
}
|
29
Oqtane.Client/Modules/Admin/Register/Index.razor
Normal file
29
Oqtane.Client/Modules/Admin/Register/Index.razor
Normal file
@ -0,0 +1,29 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Modules
|
||||
@using Microsoft.JSInterop
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div class="form-group">
|
||||
<label for="Username" class="control-label">Email: </label>
|
||||
<input type="text" name="Username" class="form-control" placeholder="Username" bind="@Username" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Password" class="control-label">Password: </label>
|
||||
<input type="password" name="Password" class="form-control" placeholder="Password" bind="@Password" />
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary">Register</button>
|
||||
<NavLink class="btn btn" href="/">Cancel</NavLink>
|
||||
</div>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
||||
|
||||
public string Username { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
}
|
46
Oqtane.Client/Modules/Admin/Sites/Add.razor
Normal file
46
Oqtane.Client/Modules/Admin/Sites/Add.razor
Normal file
@ -0,0 +1,46 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject ISiteService SiteService
|
||||
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Alias: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" bind="@alias" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SaveSite">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
|
||||
string name;
|
||||
string alias;
|
||||
|
||||
private async Task SaveSite()
|
||||
{
|
||||
Site site = new Site();
|
||||
site.Name = name;
|
||||
site.Logo = "";
|
||||
await SiteService.AddSiteAsync(site);
|
||||
StateHasChanged();
|
||||
UriHelper.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
42
Oqtane.Client/Modules/Admin/Sites/Index.razor
Normal file
42
Oqtane.Client/Modules/Admin/Sites/Index.razor
Normal file
@ -0,0 +1,42 @@
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@inject ISiteService SiteService
|
||||
|
||||
@if (sites == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var site in sites)
|
||||
{
|
||||
<tr>
|
||||
<td>@site.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Add Site" />
|
||||
}
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
|
||||
List<Site> sites;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
sites = await SiteService.GetSitesAsync();
|
||||
}
|
||||
}
|
41
Oqtane.Client/Modules/Admin/Skins/Index.razor
Normal file
41
Oqtane.Client/Modules/Admin/Skins/Index.razor
Normal file
@ -0,0 +1,41 @@
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@inject ISkinService SkinService
|
||||
|
||||
@if (Skins == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var Skin in Skins)
|
||||
{
|
||||
<tr>
|
||||
<td>@Skin.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
|
||||
List<Skin> Skins;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
Skins = await SkinService.GetSkinsAsync();
|
||||
}
|
||||
}
|
41
Oqtane.Client/Modules/Admin/Users/Index.razor
Normal file
41
Oqtane.Client/Modules/Admin/Users/Index.razor
Normal file
@ -0,0 +1,41 @@
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (Users == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var User in Users)
|
||||
{
|
||||
<tr>
|
||||
<td>@User.Username</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
|
||||
List<User> Users;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
Users = await UserService.GetUsersAsync();
|
||||
}
|
||||
}
|
67
Oqtane.Client/Modules/Controls/ActionLink.razor
Normal file
67
Oqtane.Client/Modules/Controls/ActionLink.razor
Normal file
@ -0,0 +1,67 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Shared
|
||||
@inherits ModuleBase
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (authorized)
|
||||
{
|
||||
<NavLink class="btn btn-primary" href="@url">@text</NavLink>
|
||||
}
|
||||
|
||||
@functions {
|
||||
[Parameter]
|
||||
private string Action { get; set; }
|
||||
|
||||
[Parameter]
|
||||
private string Text { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
private string Parameters { get; set; } // optional
|
||||
|
||||
string text = "";
|
||||
string url = "";
|
||||
string parameters = "";
|
||||
bool authorized = false;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
text = Action;
|
||||
if (!String.IsNullOrEmpty(Text))
|
||||
{
|
||||
text = Text;
|
||||
}
|
||||
if (!String.IsNullOrEmpty(Parameters))
|
||||
{
|
||||
parameters = Parameters;
|
||||
}
|
||||
url = EditUrl(Action, parameters);
|
||||
|
||||
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameClass(ModuleState.ModuleType) + ",", Action + ",");
|
||||
Type moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduleType);
|
||||
SecurityAccessLevelEnum SecurityAccessLevel = (SecurityAccessLevelEnum)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
switch (SecurityAccessLevel)
|
||||
{
|
||||
case SecurityAccessLevelEnum.Anonymous:
|
||||
authorized = true;
|
||||
break;
|
||||
case SecurityAccessLevelEnum.View:
|
||||
authorized = UserService.IsAuthorized(PageState.User, ModuleState.ViewPermissions);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Edit:
|
||||
authorized = UserService.IsAuthorized(PageState.User, ModuleState.EditPermissions);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Admin:
|
||||
authorized = UserService.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Host:
|
||||
authorized = PageState.User.IsSuperUser;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
Oqtane.Client/Modules/Counter/Index.razor
Normal file
15
Oqtane.Client/Modules/Counter/Index.razor
Normal file
@ -0,0 +1,15 @@
|
||||
@using Oqtane.Modules
|
||||
@inherits ModuleBase
|
||||
Current count: @currentCount
|
||||
<br />
|
||||
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
|
||||
<br /><br />
|
||||
|
||||
@functions {
|
||||
int currentCount = 0;
|
||||
|
||||
void IncrementCount()
|
||||
{
|
||||
currentCount++;
|
||||
}
|
||||
}
|
16
Oqtane.Client/Modules/Counter/Module.cs
Normal file
16
Oqtane.Client/Modules/Counter/Module.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Client.Modules.Counter
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "Counter"; } }
|
||||
public string Description { get { return "Increments a counter"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
}
|
||||
}
|
61
Oqtane.Client/Modules/HtmlText/Edit.razor
Normal file
61
Oqtane.Client/Modules/HtmlText/Edit.razor
Normal file
@ -0,0 +1,61 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.HtmlText.Services
|
||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
||||
@using System.Net.Http;
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject HttpClient http
|
||||
|
||||
<form>
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Content: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" bind="@content" rows="5" style="width:400px;" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SaveContent">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
</form>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Edit; } }
|
||||
public override string Title { get { return "Edit Html/Text"; } }
|
||||
|
||||
HtmlTextInfo htmltext;
|
||||
string content;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
if (htmltextlist != null)
|
||||
{
|
||||
htmltext = htmltextlist.FirstOrDefault();
|
||||
content = htmltext.Content;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveContent()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
if (htmltext != null)
|
||||
{
|
||||
htmltext.Content = content;
|
||||
await htmltextservice.UpdateHtmlTextAsync(htmltext);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = new HtmlTextInfo();
|
||||
htmltext.ModuleId = ModuleState.ModuleId;
|
||||
htmltext.Content = content;
|
||||
await htmltextservice.AddHtmlTextAsync(htmltext);
|
||||
}
|
||||
UriHelper.NavigateTo(NavigateUrl(), true);
|
||||
}
|
||||
}
|
26
Oqtane.Client/Modules/HtmlText/Index.razor
Normal file
26
Oqtane.Client/Modules/HtmlText/Index.razor
Normal file
@ -0,0 +1,26 @@
|
||||
@using Oqtane.Client.Modules.HtmlText.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
||||
@using System.Net.Http;
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject HttpClient http
|
||||
@inject IUriHelper UriHelper
|
||||
|
||||
@((MarkupString)content)
|
||||
|
||||
<br /><ActionLink Action="Edit" /><br /><br />
|
||||
|
||||
@functions {
|
||||
string content;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
content = htmltext.FirstOrDefault().Content;
|
||||
}
|
||||
}
|
||||
}
|
16
Oqtane.Client/Modules/HtmlText/Module.cs
Normal file
16
Oqtane.Client/Modules/HtmlText/Module.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "HtmlText"; } }
|
||||
public string Description { get { return "Renders HTML or Text"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
}
|
||||
}
|
46
Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
Normal file
46
Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared.Modules.HtmlText.Models;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText.Services
|
||||
{
|
||||
public class HtmlTextService : ServiceBase, IHtmlTextService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public HtmlTextService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "HtmlText");
|
||||
}
|
||||
|
||||
public async Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId)
|
||||
{
|
||||
List<HtmlTextInfo> htmltext = await http.GetJsonAsync<List<HtmlTextInfo>>(apiurl);
|
||||
htmltext = htmltext
|
||||
.Where(item => item.ModuleId == ModuleId)
|
||||
.ToList();
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
public async Task AddHtmlTextAsync(HtmlTextInfo htmltext)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, htmltext);
|
||||
}
|
||||
|
||||
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmltext)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + htmltext.HtmlTextId.ToString(), htmltext);
|
||||
}
|
||||
|
||||
public async Task DeleteHtmlTextAsync(int HtmlTextId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + HtmlTextId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
17
Oqtane.Client/Modules/HtmlText/Services/IHtmlTextService.cs
Normal file
17
Oqtane.Client/Modules/HtmlText/Services/IHtmlTextService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Shared.Modules.HtmlText.Models;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText.Services
|
||||
{
|
||||
public interface IHtmlTextService
|
||||
{
|
||||
Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId);
|
||||
|
||||
Task AddHtmlTextAsync(HtmlTextInfo htmltext);
|
||||
|
||||
Task UpdateHtmlTextAsync(HtmlTextInfo htmltext);
|
||||
|
||||
Task DeleteHtmlTextAsync(int HtmlTextId);
|
||||
}
|
||||
}
|
14
Oqtane.Client/Modules/IModule.cs
Normal file
14
Oqtane.Client/Modules/IModule.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public interface IModule
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
string Version { get; }
|
||||
string Owner { get; }
|
||||
string Url { get; }
|
||||
string Contact { get; }
|
||||
string License { get; }
|
||||
string Dependencies { get; }
|
||||
}
|
||||
}
|
9
Oqtane.Client/Modules/IModuleControl.cs
Normal file
9
Oqtane.Client/Modules/IModuleControl.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public interface IModuleControl
|
||||
{
|
||||
string Title { get; }
|
||||
SecurityAccessLevelEnum SecurityAccessLevel { get; }
|
||||
string Actions { get; } // can be specified as a comma delimited set of values
|
||||
}
|
||||
}
|
65
Oqtane.Client/Modules/ModuleBase.cs
Normal file
65
Oqtane.Client/Modules/ModuleBase.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public class ModuleBase : ComponentBase, IModuleControl
|
||||
{
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
protected Module ModuleState { get; set; }
|
||||
|
||||
public virtual string Title { get { return ""; } }
|
||||
|
||||
public virtual SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.View; } set { } } // default security
|
||||
|
||||
public virtual string Actions { get { return ""; } }
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path, false);
|
||||
}
|
||||
|
||||
public string NavigateUrl(bool reload)
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path, reload);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return NavigateUrl(path, false);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, bool reload)
|
||||
{
|
||||
string url = PageState.Alias + path;
|
||||
if (reload)
|
||||
{
|
||||
url += "?reload=true";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public string EditUrl(string action)
|
||||
{
|
||||
return EditUrl(action, "");
|
||||
}
|
||||
|
||||
public string EditUrl(string action, string parameters)
|
||||
{
|
||||
string url = PageState.Alias + PageState.Page.Path + "?mid=" + ModuleState.ModuleId.ToString();
|
||||
if (action != "")
|
||||
{
|
||||
url += "&ctl=" + action;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(parameters))
|
||||
{
|
||||
url += "&" + parameters;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
11
Oqtane.Client/Modules/SecurityAccessLevel.cs
Normal file
11
Oqtane.Client/Modules/SecurityAccessLevel.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public enum SecurityAccessLevelEnum
|
||||
{
|
||||
Anonymous,
|
||||
View,
|
||||
Edit,
|
||||
Admin,
|
||||
Host
|
||||
}
|
||||
}
|
42
Oqtane.Client/Modules/Weather/Index.razor
Normal file
42
Oqtane.Client/Modules/Weather/Index.razor
Normal file
@ -0,0 +1,42 @@
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Weather.Services
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Temp. (C)</th>
|
||||
<th>Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@functions {
|
||||
WeatherForecast[] forecasts;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
WeatherForecastService forecastservice = new WeatherForecastService();
|
||||
forecasts = await forecastservice.GetForecastAsync(DateTime.Now);
|
||||
}
|
||||
}
|
12
Oqtane.Client/Modules/Weather/Models/WeatherForecast.cs
Normal file
12
Oqtane.Client/Modules/Weather/Models/WeatherForecast.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public int TemperatureF { get; set; }
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
16
Oqtane.Client/Modules/Weather/Module.cs
Normal file
16
Oqtane.Client/Modules/Weather/Module.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "Weather"; } }
|
||||
public string Description { get { return "Displays random weather using a service"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather.Services
|
||||
{
|
||||
public interface IWeatherForecastService
|
||||
{
|
||||
Task<WeatherForecast[]> GetForecastAsync(DateTime startDate);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using Oqtane.Modules;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather.Services
|
||||
{
|
||||
public class WeatherForecastService : IWeatherForecastService
|
||||
{
|
||||
private static string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
|
||||
{
|
||||
var rng = new Random();
|
||||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = startDate.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
}).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user