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:
		| @ -5,70 +5,100 @@ | ||||
| @inject IThemeService ThemeService | ||||
| @inject IPackageService PackageService | ||||
|  | ||||
| <table class="table table-borderless"> | ||||
|     <tr> | ||||
|         <td> | ||||
|             <Label For="theme" HelpText="Upload a theme from your system">Theme: </Label> | ||||
|         </td> | ||||
|         <td> | ||||
|             <FileManager Filter="nupkg"  ShowFiles="false" Folder="Themes" /> | ||||
|         </td> | ||||
|     </tr> | ||||
| </table> | ||||
|  | ||||
| @if (packages != null) | ||||
| @if (_packages != null) | ||||
| { | ||||
|     <hr class="app-rule" /> | ||||
|     <div class="mx-auto text-center"><h2>Available Themes</h2></div> | ||||
|  | ||||
|     <Pager Items="@packages"> | ||||
|         <Header> | ||||
|             <th>Name</th> | ||||
|             <th>Version</th> | ||||
|             <th></th> | ||||
|         </Header> | ||||
|         <Row> | ||||
|             <td>@context.Name</td> | ||||
|             <td>@context.Version</td> | ||||
|             <td> | ||||
|                 <button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadTheme(context.PackageId, context.Version))>Download Theme</button> | ||||
|             </td> | ||||
|         </Row> | ||||
|     </Pager> | ||||
| } | ||||
| <TabStrip> | ||||
|     @if (_packages.Count > 0) | ||||
|     { | ||||
|     <TabPanel Name="Download"> | ||||
|         <ModuleMessage Type="MessageType.Info" Message="Download one or more themes from the list below. Once you are ready click Install to complete the installation."></ModuleMessage> | ||||
|         <Pager Items="@_packages"> | ||||
|             <Header> | ||||
|                 <th>Name</th> | ||||
|                 <th>Version</th> | ||||
|                 <th></th> | ||||
|             </Header> | ||||
|             <Row> | ||||
|                 <td>@context.Name</td> | ||||
|                 <td>@context.Version</td> | ||||
|                 <td> | ||||
|                     <button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadTheme(context.PackageId, context.Version))>Download</button> | ||||
|                 </td> | ||||
|             </Row> | ||||
|         </Pager> | ||||
|     </TabPanel> | ||||
|     } | ||||
|     <TabPanel Name="Upload"> | ||||
|         <table class="table table-borderless"> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <Label HelpText="Upload one or more theme packages. Once they are uploaded click Install to complete the installation.">Theme: </Label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <FileManager Filter="nupkg" ShowFiles="false" Folder="Themes" UploadMultiple="True" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|     </TabPanel> | ||||
| </TabStrip> | ||||
|  | ||||
| <button type="button" class="btn btn-success" @onclick="InstallThemes">Install</button> | ||||
| <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private List<Package> packages; | ||||
|     private List<Package> _packages; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         var themes = await ThemeService.GetThemesAsync(); | ||||
|         packages = await PackageService.GetPackagesAsync("theme"); | ||||
|          | ||||
|         foreach(Package package in packages.ToArray()) | ||||
|         try | ||||
|         { | ||||
|             if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId)) | ||||
|             var themes = await ThemeService.GetThemesAsync(); | ||||
|             _packages = await PackageService.GetPackagesAsync("theme"); | ||||
|  | ||||
|             foreach (Package package in _packages.ToArray()) | ||||
|             { | ||||
|                 packages.Remove(package); | ||||
|                 if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId)) | ||||
|                 { | ||||
|                     _packages.Remove(package); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message); | ||||
|             AddModuleMessage("Error Loading Packages", MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task InstallThemes() | ||||
|     { | ||||
|         await ThemeService.InstallThemesAsync(); | ||||
|         NavigationManager.NavigateTo(NavigateUrl()); | ||||
|         try | ||||
|         { | ||||
|             await ThemeService.InstallThemesAsync(); | ||||
|             NavigationManager.NavigateTo(NavigateUrl()); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Installating Theme"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task DownloadTheme(string packageid, string version) | ||||
|     { | ||||
|         await PackageService.DownloadPackageAsync(packageid, version, "Themes"); | ||||
|         AddModuleMessage("Theme Downloaded Successfully. Click Install To Complete Installation.", MessageType.Success); | ||||
|         StateHasChanged(); | ||||
|         try | ||||
|         { | ||||
|             await PackageService.DownloadPackageAsync(packageid, version, "Themes"); | ||||
|             await logger.LogInformation("Theme {ThemeName} {Version} Downloaded Successfully", packageid, version); | ||||
|             AddModuleMessage("Themes Downloaded Successfully. Click Install To Complete Installation.", MessageType.Success); | ||||
|             StateHasChanged(); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Downloading Module {ThemeName} {Version}", packageid, version); | ||||
|             AddModuleMessage("Error Downloading Theme", MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker