Merge pull request #391 from sbwalker/master
added system info admin page/module, improved UI for framework, module, and theme install/upgrade, added version to ModuleDefinitions, fixed bug in logging logic introduced during code standardization
This commit is contained in:
35
Oqtane.Server/Controllers/SystemController.cs
Normal file
35
Oqtane.Server/Controllers/SystemController.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class SystemController : Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
|
||||
public SystemController(IWebHostEnvironment environment)
|
||||
{
|
||||
_environment = environment;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Dictionary<string, string> Get()
|
||||
{
|
||||
Dictionary<string, string> systeminfo = new Dictionary<string, string>();
|
||||
systeminfo.Add("clrversion", Environment.Version.ToString());
|
||||
systeminfo.Add("osversion", Environment.OSVersion.ToString());
|
||||
systeminfo.Add("machinename", Environment.MachineName);
|
||||
systeminfo.Add("serverpath", _environment.ContentRootPath);
|
||||
systeminfo.Add("servertime", DateTime.Now.ToString());
|
||||
return systeminfo;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -75,7 +75,7 @@ namespace Oqtane.Infrastructure
|
||||
log.Url = $"{request.Scheme}://{request.Host}{request.Path}{request.QueryString}";
|
||||
}
|
||||
|
||||
Type type = @class.GetType();
|
||||
Type type = Type.GetType(@class.ToString());
|
||||
if (type != null)
|
||||
{
|
||||
log.Category = type.AssemblyQualifiedName;
|
||||
|
@ -105,6 +105,10 @@ namespace Oqtane.Repository
|
||||
{
|
||||
moduledefinition.Categories = moduledef.Categories;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(moduledef.Version))
|
||||
{
|
||||
moduledefinition.Version = moduledef.Version;
|
||||
}
|
||||
if (permissions.Count == 0)
|
||||
{
|
||||
_permissions.UpdatePermissions(siteId, EntityNames.ModuleDefinition, moduledef.ModuleDefinitionId, moduledefinition.Permissions);
|
||||
@ -173,23 +177,29 @@ namespace Oqtane.Repository
|
||||
.FirstOrDefault(item => item.GetInterfaces().Contains(typeof(IModule)));
|
||||
if (moduletype != null)
|
||||
{
|
||||
// get property values from IModule
|
||||
var moduleobject = Activator.CreateInstance(moduletype);
|
||||
moduledefinition = (ModuleDefinition)moduletype.GetProperty("ModuleDefinition").GetValue(moduleobject);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set default property values
|
||||
moduledefinition = new ModuleDefinition
|
||||
{
|
||||
Name = moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
||||
Description = "Manage " + moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
||||
Categories = ((qualifiedModuleType.StartsWith("Oqtane.Modules.Admin.")) ? "Admin" : ""),
|
||||
Version = new Version(1, 0, 0).ToString()
|
||||
Version = "1.0.0"
|
||||
};
|
||||
}
|
||||
// set internal properties
|
||||
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
||||
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
||||
moduledefinition.AssemblyName = assembly.FullName.Split(",")[0];
|
||||
if (assembly.FullName.StartsWith("Oqtane.Client"))
|
||||
{
|
||||
moduledefinition.Version = Constants.Version;
|
||||
}
|
||||
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||
{
|
||||
moduledefinition.Categories = "Common";
|
||||
|
@ -388,6 +388,34 @@ namespace Oqtane.Repository
|
||||
}
|
||||
});
|
||||
pageTemplates.Add(new PageTemplate
|
||||
{
|
||||
Name = "System Info",
|
||||
Parent = "Admin",
|
||||
Path = "admin/system",
|
||||
Icon = "medical-cross",
|
||||
IsNavigation = false,
|
||||
IsPersonalizable = false,
|
||||
EditMode = true,
|
||||
PagePermissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||
}.EncodePermissions(),
|
||||
PageTemplateModules = new List<PageTemplateModule>
|
||||
{
|
||||
new PageTemplateModule
|
||||
{
|
||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.SystemInfo.Index).ToModuleDefinitionName(), Title = "System Info", Pane = "Content",
|
||||
ModulePermissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||
}.EncodePermissions(),
|
||||
Content = ""
|
||||
}
|
||||
}
|
||||
});
|
||||
pageTemplates.Add(new PageTemplate
|
||||
{
|
||||
Name = "Upgrade Service", Parent = "Admin", Path = "admin/upgrade", Icon = Icons.Aperture, IsNavigation = false, IsPersonalizable = false, EditMode = true,
|
||||
PagePermissions = new List<Permission>
|
||||
|
@ -43,6 +43,7 @@ CREATE TABLE [dbo].[ModuleDefinition](
|
||||
[Name] [nvarchar](200) NULL,
|
||||
[Description] [nvarchar](2000) NULL,
|
||||
[Categories] [nvarchar](200) NULL,
|
||||
[Version] [nvarchar](50) NULL,
|
||||
[CreatedBy] [nvarchar](256) NOT NULL,
|
||||
[CreatedOn] [datetime] NOT NULL,
|
||||
[ModifiedBy] [nvarchar](256) NOT NULL,
|
||||
|
@ -102,6 +102,7 @@ namespace Oqtane
|
||||
services.AddScoped<IFileService, FileService>();
|
||||
services.AddScoped<ISiteTemplateService, SiteTemplateService>();
|
||||
services.AddScoped<ISqlService, SqlService>();
|
||||
services.AddScoped<ISystemService, SystemService>();
|
||||
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
|
||||
|
Reference in New Issue
Block a user