@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
Cancel @functions { public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } } Dictionary skins = new Dictionary(); Dictionary panelayouts = new Dictionary(); 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 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)); } }