added IsClickable Page property #1092, improve validation in Role Management, display database information in SQL Management, improve HttpClient header support
This commit is contained in:
		| @ -9,83 +9,94 @@ | ||||
|     <TabPanel Name="Settings" ResourceKey="Settings"> | ||||
|         @if (_themeList != null) | ||||
|         { | ||||
|             <table class="table table-borderless"> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input id="Name" class="form-control" @bind="@_name" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <select id="Parent" class="form-control" @onchange="(e => ParentChanged(e))"> | ||||
|                             <option value="-1"><@Localizer["Site Root"]></option> | ||||
|                             @foreach (Page page in _pageList) | ||||
|                             { | ||||
|                                 <option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option> | ||||
|                             } | ||||
|                         </select> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Insert" HelpText="Select the location where you would like the page to be inserted in relation to other pages" ResourceKey="Insert">Insert: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <select id="Insert" class="form-control" @bind="@_insert"> | ||||
|                             <option value="<<">@Localizer["At Beginning"]</option> | ||||
|                             @if (_children != null && _children.Count > 0) | ||||
|                             { | ||||
|                                 <option value="<">@Localizer["Before"]</option> | ||||
|                                 <option value=">">@Localizer["After"]</option> | ||||
|                             } | ||||
|                             <option value=">>">@Localizer["At End"]</option> | ||||
|                         </select> | ||||
|                         @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) | ||||
|         <table class="table table-borderless"> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input id="Name" class="form-control" @bind="@_name" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Parent" class="form-control" @onchange="(e => ParentChanged(e))"> | ||||
|                         <option value="-1"><@Localizer["Site Root"]></option> | ||||
|                         @foreach (Page page in _pageList) | ||||
|                         { | ||||
|                             <select class="form-control" @bind="@_childid"> | ||||
|                                 <option value="-1"><@Localizer["Select Page"]></option> | ||||
|                                 @foreach (Page page in _children) | ||||
|                                 { | ||||
|                                     <option value="@(page.PageId)">@(page.Name)</option> | ||||
|                                 } | ||||
|                             </select> | ||||
|                             <option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option> | ||||
|                         } | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <select id="Navigation" class="form-control" @bind="@_isnavigation"> | ||||
|                             <option value="True">@Localizer["Yes"]</option> | ||||
|                             <option value="False">@Localizer["No"]</option> | ||||
|                     </select> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Insert" HelpText="Select the location where you would like the page to be inserted in relation to other pages" ResourceKey="Insert">Insert: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Insert" class="form-control" @bind="@_insert"> | ||||
|                         <option value="<<">@Localizer["At Beginning"]</option> | ||||
|                         @if (_children != null && _children.Count > 0) | ||||
|                         { | ||||
|                             <option value="<">@Localizer["Before"]</option> | ||||
|                             <option value=">">@Localizer["After"]</option> | ||||
|                         } | ||||
|                         <option value=">>">@Localizer["At End"]</option> | ||||
|                     </select> | ||||
|                     @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) | ||||
|                     { | ||||
|                         <select class="form-control" @bind="@_childid"> | ||||
|                             <option value="-1"><@Localizer["Select Page"]></option> | ||||
|                             @foreach (Page page in _children) | ||||
|                             { | ||||
|                                 <option value="@(page.PageId)">@(page.Name)</option> | ||||
|                             } | ||||
|                         </select> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input id="Path" class="form-control" @bind="@_path" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input id="Url" class="form-control" @bind="@_url" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|                     } | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Navigation" class="form-control" @bind="@_isnavigation"> | ||||
|                         <option value="True">@Localizer["Yes"]</option> | ||||
|                         <option value="False">@Localizer["No"]</option> | ||||
|                     </select> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Clickablen" HelpText="Select whether the link in the site navigation is enabled or disabled" ResourceKey="Clickable">Clickable? </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Navigation" class="form-control" @bind="@_isclickable"> | ||||
|                         <option value="True">@Localizer["Yes"]</option> | ||||
|                         <option value="False">@Localizer["No"]</option> | ||||
|                     </select> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input id="Path" class="form-control" @bind="@_path" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input id="Url" class="form-control" @bind="@_url" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|             <Section Name="Appearance" ResourceKey="Appearance"> | ||||
|                 <table class="table table-borderless"> | ||||
|                     <tr> | ||||
| @ -180,6 +191,7 @@ | ||||
|     private List<Page> _children; | ||||
|     private int _childid = -1; | ||||
|     private string _isnavigation = "True"; | ||||
|     private string _isclickable = "True"; | ||||
|     private string _url; | ||||
|     private string _ispersonalizable = "False"; | ||||
|     private string _themetype = string.Empty; | ||||
| @ -351,6 +363,7 @@ | ||||
|                 } | ||||
|  | ||||
|                 page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation)); | ||||
|                 page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable)); | ||||
|                 page.Url = _url; | ||||
|                 page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; | ||||
|                 if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) | ||||
|  | ||||
| @ -10,90 +10,101 @@ | ||||
|     <TabPanel Name="Settings" ResourceKey="Settings"> | ||||
|         @if (_themeList != null) | ||||
|         { | ||||
|             <table class="table table-borderless"> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input id="Name" class="form-control" @bind="@_name" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <select id="Parent" class="form-control" value="@_parentid" @onchange="(e => ParentChanged(e))"> | ||||
|                             <option value="-1"><@Localizer["Site Root"]></option> | ||||
|                             @foreach (Page page in _pageList) | ||||
|                             { | ||||
|                                 if (page.PageId != _pageId) | ||||
|                                 { | ||||
|                                     <option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option> | ||||
|                                 } | ||||
|                             } | ||||
|                         </select> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Move" HelpText="Select the location where you would like the page to be moved in relation to other pages" ResourceKey="Move">Move: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <select id="Move" class="form-control" @bind="@_insert"> | ||||
|                             @if (_parentid == _currentparentid) | ||||
|                             { | ||||
|                                 <option value="="><@Localizer["Maintain Current Location"]></option> | ||||
|                             } | ||||
|                             <option value="<<">@Localizer["To Beginning"]</option> | ||||
|                             @if (_children != null && _children.Count > 0) | ||||
|                             { | ||||
|                                 <option value="<">@Localizer["Before"]</option> | ||||
|                                 <option value=">">@Localizer["After"]</option> | ||||
|                             } | ||||
|                             <option value=">>">@Localizer["To End"]</option> | ||||
|                         </select> | ||||
|                         @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) | ||||
|         <table class="table table-borderless"> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input id="Name" class="form-control" @bind="@_name" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Parent" class="form-control" value="@_parentid" @onchange="(e => ParentChanged(e))"> | ||||
|                         <option value="-1"><@Localizer["Site Root"]></option> | ||||
|                         @foreach (Page page in _pageList) | ||||
|                         { | ||||
|                             <select class="form-control" @bind="@_childid"> | ||||
|                                 <option value="-1"><@Localizer["Select Page"]></option> | ||||
|                                 @foreach (Page page in _children) | ||||
|                                 { | ||||
|                                     <option value="@(page.PageId)">@(page.Name)</option> | ||||
|                                 } | ||||
|                             </select> | ||||
|                             if (page.PageId != _pageId) | ||||
|                             { | ||||
|                                 <option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option> | ||||
|                             } | ||||
|                         } | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <select id="Navigation" class="form-control" @bind="@_isnavigation"> | ||||
|                             <option value="True">@Localizer["Yes"]</option> | ||||
|                             <option value="False">@Localizer["No"]</option> | ||||
|                     </select> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Move" HelpText="Select the location where you would like the page to be moved in relation to other pages" ResourceKey="Move">Move: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Move" class="form-control" @bind="@_insert"> | ||||
|                         @if (_parentid == _currentparentid) | ||||
|                         { | ||||
|                             <option value="="><@Localizer["Maintain Current Location"]></option> | ||||
|                         } | ||||
|                         <option value="<<">@Localizer["To Beginning"]</option> | ||||
|                         @if (_children != null && _children.Count > 0) | ||||
|                         { | ||||
|                             <option value="<">@Localizer["Before"]</option> | ||||
|                             <option value=">">@Localizer["After"]</option> | ||||
|                         } | ||||
|                         <option value=">>">@Localizer["To End"]</option> | ||||
|                     </select> | ||||
|                     @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) | ||||
|                     { | ||||
|                         <select class="form-control" @bind="@_childid"> | ||||
|                             <option value="-1"><@Localizer["Select Page"]></option> | ||||
|                             @foreach (Page page in _children) | ||||
|                             { | ||||
|                                 <option value="@(page.PageId)">@(page.Name)</option> | ||||
|                             } | ||||
|                         </select> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input id="Path" class="form-control" @bind="@_path" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <Label For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input id="Url" class="form-control" @bind="@_url" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|                     } | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Navigation" class="form-control" @bind="@_isnavigation"> | ||||
|                         <option value="True">@Localizer["Yes"]</option> | ||||
|                         <option value="False">@Localizer["No"]</option> | ||||
|                     </select> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Clickablen" HelpText="Select whether the link in the site navigation is enabled or disabled" ResourceKey="Clickable">Clickable? </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <select id="Navigation" class="form-control" @bind="@_isclickable"> | ||||
|                         <option value="True">@Localizer["Yes"]</option> | ||||
|                         <option value="False">@Localizer["No"]</option> | ||||
|                     </select> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input id="Path" class="form-control" @bind="@_path" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input id="Url" class="form-control" @bind="@_url" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|             <Section Name="Appearance" ResourceKey="Appearance"> | ||||
|                 <table class="table table-borderless"> | ||||
|                     <tr> | ||||
| @ -195,6 +206,7 @@ | ||||
|     private List<Page> _children; | ||||
|     private int _childid = -1; | ||||
|     private string _isnavigation; | ||||
|     private string _isclickable; | ||||
|     private string _url; | ||||
|     private string _ispersonalizable; | ||||
|     private string _themetype; | ||||
| @ -247,6 +259,7 @@ | ||||
|  | ||||
|                 _currentparentid = _parentid; | ||||
|                 _isnavigation = page.IsNavigation.ToString(); | ||||
|                 _isclickable = page.IsClickable.ToString(); | ||||
|                 _url = page.Url; | ||||
|                 _ispersonalizable = page.IsPersonalizable.ToString(); | ||||
|                 _themetype = page.ThemeType; | ||||
| @ -427,6 +440,7 @@ | ||||
|                     } | ||||
|                 } | ||||
|                 page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation)); | ||||
|                 page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable)); | ||||
|                 page.Url = _url; | ||||
|                 page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; | ||||
|                 if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) | ||||
|  | ||||
| @ -4,39 +4,44 @@ | ||||
| @inject IRoleService RoleService | ||||
| @inject IStringLocalizer<Add> Localizer | ||||
|  | ||||
| <table class="table table-borderless"> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="name" HelpText="Name Of The Role" ResourceKey="Name">Name:</Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <input id="name" class="form-control" @bind="@_name" /> | ||||
|         </td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="description" HelpText="A Short Description Of The Role Which Describes Its Purpose" ResourceKey="Description">Description:</Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <textarea id="description" class="form-control" @bind="@_description" rows="5"></textarea> | ||||
|         </td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <select id="isautoassigned" class="form-control" @bind="@_isautoassigned"> | ||||
|                 <option value="True">@Localizer["Yes"]</option> | ||||
|                 <option value="False">@Localizer["No"]</option> | ||||
|             </select> | ||||
|         </td> | ||||
|     </tr> | ||||
| </table> | ||||
| <button type="button" class="btn btn-success" @onclick="SaveRole">@Localizer["Save"]</button> | ||||
| <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
| <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|     <table class="table table-borderless"> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="name" HelpText="Name Of The Role" ResourceKey="Name">Name:</Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <input id="name" class="form-control" @bind="@_name" required /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="description" HelpText="A Short Description Of The Role Which Describes Its Purpose" ResourceKey="Description">Description:</Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <textarea id="description" class="form-control" @bind="@_description" rows="5" required></textarea> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <select id="isautoassigned" class="form-control" @bind="@_isautoassigned"> | ||||
|                     <option value="True">@Localizer["Yes"]</option> | ||||
|                     <option value="False">@Localizer["No"]</option> | ||||
|                 </select> | ||||
|             </td> | ||||
|         </tr> | ||||
|     </table> | ||||
|     <button type="button" class="btn btn-success" @onclick="SaveRole">@Localizer["Save"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
| </form> | ||||
|  | ||||
| @code { | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|  | ||||
|     private string _name = string.Empty; | ||||
|     private string _description = string.Empty; | ||||
|     private string _isautoassigned = "False"; | ||||
| @ -45,24 +50,33 @@ | ||||
|  | ||||
|     private async Task SaveRole() | ||||
|     { | ||||
|         var role = new Role(); | ||||
|         role.SiteId = PageState.Page.SiteId; | ||||
|         role.Name = _name; | ||||
|         role.Description = _description; | ||||
|         role.IsAutoAssigned = (_isautoassigned == null ? false : Boolean.Parse(_isautoassigned)); | ||||
|         role.IsSystem = false; | ||||
|  | ||||
|         try | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             role = await RoleService.AddRoleAsync(role); | ||||
|             await logger.LogInformation("Role Added {Role}", role); | ||||
|             var role = new Role(); | ||||
|             role.SiteId = PageState.Page.SiteId; | ||||
|             role.Name = _name; | ||||
|             role.Description = _description; | ||||
|             role.IsAutoAssigned = (_isautoassigned == null ? false : Boolean.Parse(_isautoassigned)); | ||||
|             role.IsSystem = false; | ||||
|  | ||||
|             NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             try | ||||
|             { | ||||
|                 role = await RoleService.AddRoleAsync(role); | ||||
|                 await logger.LogInformation("Role Added {Role}", role); | ||||
|  | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 await logger.LogError(ex, "Error Adding Role {Role} {Error}", role, ex.Message); | ||||
|                 AddModuleMessage(Localizer["Error Adding Role"], MessageType.Error); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         else | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Adding Role {Role} {Error}", role, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error Adding Role"], MessageType.Error); | ||||
|             AddModuleMessage(Localizer["Please Provide All Required Information"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -4,43 +4,54 @@ | ||||
| @inject IRoleService RoleService | ||||
| @inject IStringLocalizer<Edit> Localizer | ||||
|  | ||||
| <table class="table table-borderless"> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="name" HelpText="Name Of The Role" ResourceKey="Name">Name:</Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <input id="name" class="form-control" @bind="@_name" /> | ||||
|         </td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="description" HelpText="A Short Description Of The Role Which Describes Its Purpose" ResourceKey="Description">Description:</Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <textarea id="description" class="form-control" @bind="@_description" rows="5"></textarea> | ||||
|         </td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <select id="isautoassigned" class="form-control" @bind="@_isautoassigned"> | ||||
|                 <option value="True">@Localizer["Yes"]</option> | ||||
|                 <option value="False">@Localizer["No"]</option> | ||||
|             </select> | ||||
|         </td> | ||||
|     </tr> | ||||
| </table> | ||||
| <button type="button" class="btn btn-success" @onclick="SaveRole">@Localizer["Save"]</button> | ||||
| <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
| <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|     <table class="table table-borderless"> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="name" HelpText="Name Of The Role" ResourceKey="Name">Name:</Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <input id="name" class="form-control" @bind="@_name" required /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="description" HelpText="A Short Description Of The Role Which Describes Its Purpose" ResourceKey="Description">Description:</Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <textarea id="description" class="form-control" @bind="@_description" rows="5" required></textarea> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <select id="isautoassigned" class="form-control" @bind="@_isautoassigned"> | ||||
|                     <option value="True">@Localizer["Yes"]</option> | ||||
|                     <option value="False">@Localizer["No"]</option> | ||||
|                 </select> | ||||
|             </td> | ||||
|         </tr> | ||||
|     </table> | ||||
|     <button type="button" class="btn btn-success" @onclick="SaveRole">@Localizer["Save"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
|     <br /><br /> | ||||
|     <AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo> | ||||
| </form> | ||||
|  | ||||
| @code { | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|  | ||||
|     private int _roleid; | ||||
|     private string _name = string.Empty; | ||||
|     private string _description = string.Empty; | ||||
|     private string _isautoassigned = "False"; | ||||
|     private string _createdby; | ||||
|     private DateTime _createdon; | ||||
|     private string _modifiedby; | ||||
|     private DateTime _modifiedon; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; | ||||
|  | ||||
| @ -55,6 +66,10 @@ | ||||
|                 _name = role.Name; | ||||
|                 _description = role.Description; | ||||
|                 _isautoassigned = role.IsAutoAssigned.ToString(); | ||||
|                 _createdby = role.CreatedBy; | ||||
|                 _createdon = role.CreatedOn; | ||||
|                 _modifiedby = role.ModifiedBy; | ||||
|                 _modifiedon = role.ModifiedOn; | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
| @ -66,22 +81,31 @@ | ||||
|  | ||||
|     private async Task SaveRole() | ||||
|     { | ||||
|         var role = await RoleService.GetRoleAsync(_roleid); | ||||
|         role.Name = _name; | ||||
|         role.Description = _description; | ||||
|         role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned)); | ||||
|         role.IsSystem = false; | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             var role = await RoleService.GetRoleAsync(_roleid); | ||||
|             role.Name = _name; | ||||
|             role.Description = _description; | ||||
|             role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned)); | ||||
|             role.IsSystem = false; | ||||
|  | ||||
|         try | ||||
|         { | ||||
|             role = await RoleService.UpdateRoleAsync(role); | ||||
|             await logger.LogInformation("Role Saved {Role}", role); | ||||
|             NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             try | ||||
|             { | ||||
|                 role = await RoleService.UpdateRoleAsync(role); | ||||
|                 await logger.LogInformation("Role Saved {Role}", role); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 await logger.LogError(ex, "Error Saving Role {Role} {Error}", role, ex.Message); | ||||
|                 AddModuleMessage(Localizer["Error Saving Role"], MessageType.Error); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         else | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Saving Role {Role} {Error}", role, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error Saving Role"], MessageType.Error); | ||||
|             AddModuleMessage(Localizer["Please Provide All Required Information"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -33,6 +33,27 @@ else | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; | ||||
|  | ||||
|     protected override async Task OnParametersSetAsync() | ||||
|     { | ||||
|         await GetRoles(); | ||||
|     } | ||||
|  | ||||
|     private async Task DeleteRole(Role role) | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             await RoleService.DeleteRoleAsync(role.RoleId); | ||||
|             await logger.LogInformation("Role Deleted {Role}", role); | ||||
|             await GetRoles(); | ||||
|             StateHasChanged(); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Deleting Role {Role} {Error}", role, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error Deleting Role"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task GetRoles() | ||||
|     { | ||||
|         if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) | ||||
|         { | ||||
| @ -44,19 +65,4 @@ else | ||||
|             _roles = await RoleService.GetRolesAsync(PageState.Site.SiteId); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task DeleteRole(Role role) | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             await RoleService.DeleteRoleAsync(role.RoleId); | ||||
|             await logger.LogInformation("Role Deleted {Role}", role); | ||||
|             StateHasChanged(); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Deleting Role {Role} {Error}", role, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error Deleting Role"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -369,7 +369,7 @@ | ||||
|                     var tenants = await TenantService.GetTenantsAsync(); | ||||
|                     var _databases = await DatabaseService.GetDatabasesAsync(); | ||||
|                     var tenant = tenants.Find(item => item.TenantId == site.TenantId); | ||||
|                     if (_tenant != null) | ||||
|                     if (tenant != null) | ||||
|                     { | ||||
|                         _tenant = tenant.Name; | ||||
|                         _database = _databases.Find(item => item.DBType == tenant.DBType)?.Name; | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| @inherits ModuleBase | ||||
| @inject NavigationManager NavigationManager | ||||
| @inject ITenantService TenantService | ||||
| @inject IDatabaseService DatabaseService | ||||
| @inject ISqlService SqlService | ||||
| @inject IStringLocalizer<Index> Localizer | ||||
|  | ||||
| @ -11,19 +12,37 @@ | ||||
| } | ||||
| else | ||||
| { | ||||
|     <table class="table table-borderless"> | ||||
| <table class="table table-borderless"> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="tenant" HelpText="Select the tenant for the SQL server" ResourceKey="Tenant">Tenant: </Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <select id="tenant" class="form-control" value="@_tenantid" @onchange="(e => TenantChanged(e))"> | ||||
|                 <option value="-1"><@Localizer["Select Tenant"]></option> | ||||
|                 @foreach (Tenant tenant in _tenants) | ||||
|                 { | ||||
|                     <option value="@tenant.TenantId">@tenant.Name</option> | ||||
|                 } | ||||
|             </select> | ||||
|         </td> | ||||
|     </tr> | ||||
|     @if (_tenantid != "-1") | ||||
|     { | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="tenant" HelpText="Select the tenant for the SQL server" ResourceKey="Tenant">Tenant: </Label> | ||||
|                 <Label For="database" HelpText="The database for the tenant" ResourceKey="Database">Database: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <select id="teneant" class="form-control" @bind="_tenantid"> | ||||
|                     <option value="-1"><@Localizer["Select Tenant"]></option> | ||||
|                     @foreach (Tenant tenant in _tenants) | ||||
|                     { | ||||
|                         <option value="@tenant.TenantId">@tenant.Name</option> | ||||
|                     } | ||||
|                 </select> | ||||
|                 <input id="database" class="form-control" @bind="@_database" readonly /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="connectionstring" HelpText="The connection information for the database" ResourceKey="ConnectionString">Connection: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <textarea id="connectionstring" class="form-control" @bind="@_connectionstring" rows="2" readonly></textarea> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
| @ -34,6 +53,7 @@ else | ||||
|                 <textarea id="sqlQeury" class="form-control" @bind="@_sql" rows="5"></textarea> | ||||
|             </td> | ||||
|         </tr> | ||||
|     } | ||||
|     </table> | ||||
|     <button type="button" class="btn btn-success" @onclick="Execute">@Localizer["Execute"]</button> | ||||
|     <br /> | ||||
| @ -47,6 +67,8 @@ else | ||||
| @code { | ||||
|     private List<Tenant> _tenants; | ||||
|     private string _tenantid = "-1"; | ||||
|     private string _database = string.Empty; | ||||
|     private string _connectionstring = string.Empty; | ||||
|     private string _sql = string.Empty; | ||||
|     private string _results = string.Empty; | ||||
|  | ||||
| @ -54,20 +76,59 @@ else | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         _tenants = await TenantService.GetTenantsAsync(); | ||||
|         try | ||||
|         { | ||||
|             _tenants = await TenantService.GetTenantsAsync(); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Loading Tenants {Error}", ex.Message); | ||||
|             AddModuleMessage(ex.Message, MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async void TenantChanged(ChangeEventArgs e) | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             _tenantid = (string)e.Value; | ||||
|             var tenants = await TenantService.GetTenantsAsync(); | ||||
|             var _databases = await DatabaseService.GetDatabasesAsync(); | ||||
|             var tenant = tenants.Find(item => item.TenantId == int.Parse(_tenantid)); | ||||
|             if (tenant != null) | ||||
|             { | ||||
|                 _database = _databases.Find(item => item.DBType == tenant.DBType)?.Name; | ||||
|                 _connectionstring = tenant.DBConnectionString; | ||||
|             } | ||||
|             StateHasChanged(); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", _tenantid, ex.Message); | ||||
|             AddModuleMessage(ex.Message, MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task Execute() | ||||
|     { | ||||
|         if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql)) | ||||
|         try | ||||
|         { | ||||
|             var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql }; | ||||
|             sqlquery = await SqlService.ExecuteQueryAsync(sqlquery); | ||||
|             _results = DisplayResults(sqlquery.Results); | ||||
|             if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql)) | ||||
|             { | ||||
|                 var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql }; | ||||
|                 sqlquery = await SqlService.ExecuteQueryAsync(sqlquery); | ||||
|                 _results = DisplayResults(sqlquery.Results); | ||||
|                 AddModuleMessage(Localizer["SQL Query Executed"], MessageType.Success); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["You Must Select A Tenant And Provide A Valid SQL Query"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             AddModuleMessage(Localizer["You Must Select A Tenant And Provide A SQL Query"], MessageType.Warning); | ||||
|             await logger.LogError(ex, "Error Executing SQL Query {SQL} {Error}", _sql, ex.Message); | ||||
|             AddModuleMessage(ex.Message, MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker