Merge pull request #10 from oqtane/dev

Merge
This commit is contained in:
Leigh Pointer
2021-03-05 06:32:14 +01:00
committed by GitHub
3 changed files with 46 additions and 37 deletions

2
.gitignore vendored
View File

@ -8,6 +8,8 @@ msbuild.binlog
*.binlog *.binlog
*.nupkg *.nupkg
*.idea
Oqtane.Server/appsettings.json Oqtane.Server/appsettings.json
Oqtane.Server/Data/*.mdf Oqtane.Server/Data/*.mdf
Oqtane.Server/Data/*.ldf Oqtane.Server/Data/*.ldf

View File

@ -85,28 +85,38 @@ else
} }
@code { @code {
private string _moduledefinitionname = ""; private string _moduledefinitionname = string.Empty;
private string _owner = string.Empty; private string _owner = string.Empty;
private string _module = string.Empty; private string _module = string.Empty;
private string _description = string.Empty; private string _description = string.Empty;
private string _template = "-"; private string _template = "-";
public string _reference = Constants.Version; public string _reference = Constants.Version;
private string _location = string.Empty; private string _location = string.Empty;
private Dictionary<string, string> _systeminfo;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override void OnInitialized() protected override async Task OnInitializedAsync()
{ {
_moduledefinitionname = SettingService.GetSetting(ModuleState.Settings, "ModuleDefinitionName", ""); try
if (string.IsNullOrEmpty(_moduledefinitionname))
{ {
_owner = ModuleState.Title; _moduledefinitionname = SettingService.GetSetting(ModuleState.Settings, "ModuleDefinitionName", "");
_module = ModuleState.Title; _systeminfo = await SystemService.GetSystemInfoAsync();
_description = ModuleState.Title;
if (string.IsNullOrEmpty(_moduledefinitionname))
{
_owner = ModuleState.Title;
_module = ModuleState.Title;
_description = ModuleState.Title;
}
else
{
AddModuleMessage(Localizer["Once You Have Compiled The Module And Restarted The Application You Can Activate The Module Below"], MessageType.Info);
}
} }
else catch (Exception ex)
{ {
AddModuleMessage(Localizer["Once You Have Compiled The Module And Restarted The Application You Can Activate The Module Below"], MessageType.Info); await logger.LogError(ex, "Error Loading Module Creator");
} }
} }
@ -123,6 +133,8 @@ else
SettingService.SetSetting(settings, "ModuleDefinitionName", moduleDefinition.ModuleDefinitionName); SettingService.SetSetting(settings, "ModuleDefinitionName", moduleDefinition.ModuleDefinitionName);
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId); await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
GetLocation();
AddModuleMessage(Localizer["The Source Code For Your Module Has Been Created At The Location Specified Below And Must Be Compiled In Order To Make It Functional. Once It Has Been Compiled You Must <a href=\"{0}\">Restart</a> Your Application To Apply These Changes.", NavigateUrl("admin/system")], MessageType.Success); AddModuleMessage(Localizer["The Source Code For Your Module Has Been Created At The Location Specified Below And Must Be Compiled In Order To Make It Functional. Once It Has Been Compiled You Must <a href=\"{0}\">Restart</a> Your Application To Apply These Changes.", NavigateUrl("admin/system")], MessageType.Success);
} }
else else
@ -161,38 +173,31 @@ else
return !string.IsNullOrEmpty(name) && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$"); return !string.IsNullOrEmpty(name) && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
} }
private async void TemplateChanged(ChangeEventArgs e) private void TemplateChanged(ChangeEventArgs e)
{ {
try _template = (string)e.Value;
GetLocation();
}
private void GetLocation()
{
_location = string.Empty;
if (_template != "-" && _systeminfo != null && _systeminfo.ContainsKey("serverpath"))
{ {
_location = string.Empty; string[] path = _systeminfo["serverpath"].Split(Path.DirectorySeparatorChar);
_template = (string)e.Value; if (_template == "internal")
if (_template != "-")
{ {
Dictionary<string, string> systeminfo = await SystemService.GetSystemInfoAsync(); _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 1) +
if (systeminfo != null) Path.DirectorySeparatorChar + "Oqtane.Client" +
{ Path.DirectorySeparatorChar + "Modules" +
string[] path = systeminfo["serverpath"].Split(Path.DirectorySeparatorChar); Path.DirectorySeparatorChar + _owner + "." + _module;
if (_template == "internal") }
{ else
_location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 1) + {
Path.DirectorySeparatorChar + "Oqtane.Client" + _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 2) +
Path.DirectorySeparatorChar + "Modules" + Path.DirectorySeparatorChar + _owner + "." + _module;
Path.DirectorySeparatorChar + _owner + "." + _module;
}
else
{
_location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 2) +
Path.DirectorySeparatorChar + _owner + "." + _module;
}
}
} }
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Getting System Info {Error}", ex.Message);
AddModuleMessage(Localizer["Error Getting System Info"], MessageType.Error);
} }
StateHasChanged();
} }
} }

View File

@ -16,6 +16,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{77EECA8C-B58E-469E-B8C5-D543AFC9A654}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{77EECA8C-B58E-469E-B8C5-D543AFC9A654}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig .editorconfig = .editorconfig
.gitignore = .gitignore
README.md = README.md
EndProjectSection EndProjectSection
EndProject EndProject
Global Global