diff --git a/Desktop/Ui/Pages/Dash/Tabs/ModuleManagerTab.razor b/Desktop/Ui/Pages/Dash/Tabs/ModuleManagerTab.razor index a21448a..40ba5a6 100644 --- a/Desktop/Ui/Pages/Dash/Tabs/ModuleManagerTab.razor +++ b/Desktop/Ui/Pages/Dash/Tabs/ModuleManagerTab.razor @@ -1,19 +1,66 @@ @page "/dash/modules" +@using OpenShock.Desktop.ModuleManager @using OpenShock.Desktop.ModuleManager.Repository @using OpenShock.Desktop.Ui.Pages.Dash.Components @inject RepositoryManager RepositoryManager +@inject ModuleManager ModuleManager
- @foreach (var (repoUri, repoContext) in RepositoryManager.Repositories.Where(x => x.Value.Repository != null)) + + Installed + + @foreach (var module in InstalledModules) { - foreach (var module in repoContext.Repository!.Modules) - { - - } + } + + Unknown Loaded Modules + @foreach (var module in UnknownModules) + { + + } + + Installable Modules + + @foreach (var module in InstallableModules) + { + + } +
@code { + + private IEnumerable> UnknownModules; + private IEnumerable> InstallableModules; + private Dictionary> InstalledModules; + + protected override void OnInitialized() + { + PopulateModuleLists(); + } + private void PopulateModuleLists() + { + var loadedModules = ModuleManager.Modules; + + var modulesFromRepos = RepositoryManager.Repositories + .Where(x => x.Value.Repository != null) + .SelectMany(x => x.Value.Repository!.Modules).ToDictionary(); + + UnknownModules = loadedModules.Where(x => modulesFromRepos.All(y => y.Key != x.Key)); + InstallableModules = modulesFromRepos.Where(x => !loadedModules.Keys.Contains(x.Key)); + + var installedModules = new Dictionary>(); + + foreach (var loadedModule in loadedModules) + { + if (!modulesFromRepos.TryGetValue(loadedModule.Key, out var repoModule)) continue; + + installedModules.Add(loadedModule.Key, new KeyValuePair(repoModule, loadedModule.Value)); + } + + InstalledModules = installedModules; + } } \ No newline at end of file