-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement data aquisition #60
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
627e9db
Basic "get json" test.
nstephenh 02fab75
Attempt to use gallery code to load additional data sources.
nstephenh 5dc7d03
move appsettings.json so it is loaded
nstephenh 505a9ae
Select a system (it doesn't do anything)
nstephenh 1957442
Fix archive button
nstephenh bbfd024
Add (unused) "use playground" option
nstephenh 8c799bb
Non-crashing system select
nstephenh 52969fc
Merge branch 'nsh-load-data' of github.com:BSData/phalanx into nsh-lo…
nstephenh 5a244f0
Load Workspace with SystemSelect
nstephenh 23e23a2
move changes from index to diferent page
nstephenh af76b5d
There's no I in team but there's a U in armoury.
nstephenh 0d86785
fix: update folder, namespace to Armoury
amis92 737f036
style: reformat, cleanup, simplify
amis92 560e3e4
Merge pull request #63 from BSData/fix/load-data
nstephenh ec96e97
Remove references to appSettings
nstephenh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
@using Microsoft.Extensions.Options | ||
@using WarHub.ArmouryModel.DataProviders | ||
@using WarHub.ArmouryModel.Workspaces.BattleScribe; | ||
|
||
@inject GalleryHttpClient client | ||
@inject GalleryBrowserState state | ||
|
||
@if (CatpkgGallery is { InfoCache: { } galleryInfo }) | ||
{ | ||
<h2>System:</h2> | ||
<FluentSelect TValue=string Value="_selectedRepoName" ValueChanged="(x => SelectCatpkg(x))"> | ||
@foreach (var repo in _repositories) | ||
{ | ||
<FluentOption Value="repo.Name">@repo.Name</FluentOption> | ||
} | ||
</FluentSelect> | ||
<FluentCheckbox @bind-Value="ShowArchived"> | ||
Show Archived Repositories | ||
</FluentCheckbox> | ||
} | ||
else | ||
{ | ||
<FluentProgressRing /> | ||
<p>Loading catpkg gallery...</p> | ||
} | ||
|
||
@code { | ||
[Parameter] | ||
public CatpkgGalleryCache? CatpkgGallery { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<CatpkgGalleryCache> CatpkgGalleryChanged { get; set; } | ||
|
||
XmlWorkspace? workspace; | ||
|
||
string _selectedRepoName = ""; | ||
|
||
bool _showArchived; | ||
|
||
bool ShowArchived | ||
{ | ||
get => _showArchived; | ||
set | ||
{ | ||
_showArchived = value; | ||
UpdateRepositories(); | ||
} | ||
} | ||
|
||
readonly List<CatpkgRepositoryInfo> _repositories = new(); | ||
|
||
List<ColumnDefinition<CatpkgRepositoryInfo>> ColumnDefinitions { get; } = new() | ||
{ | ||
#nullable disable | ||
new("Name", x => x.Description), | ||
new("Latest Release", x => x.Version), | ||
#nullable restore | ||
}; | ||
|
||
void UpdateRepositories() | ||
{ | ||
_repositories.Clear(); | ||
if (CatpkgGallery?.InfoCache?.Repositories is { } repos) | ||
{ | ||
_repositories.AddRange(repos.Where(x => x.Archived != true || ShowArchived).OrderBy(x => x.Description)); | ||
// Clear value if we switch away from archived | ||
if (!ShowArchived && (repos.Where(x => x.Description == _selectedRepoName).FirstOrDefault()?.Archived ?? false)) | ||
{ | ||
_selectedRepoName = ""; | ||
} | ||
} | ||
} | ||
|
||
CatpkgRepositoryInfo? repositoryInfo; | ||
|
||
async Task SelectCatpkg(string catName) | ||
{ | ||
if (CatpkgGallery is null) | ||
return; | ||
_selectedRepoName = catName; | ||
repositoryInfo = CatpkgGallery.InfoCache?.Repositories.Find(x => x.Name == catName); | ||
var repoRef = new RepositoryReference(_selectedRepoName, CatpkgGallery.Reference); | ||
repositoryInfo = await state.Cache.GetHydratedCatpkgAsync(client, repoRef); | ||
workspace = await state.Cache.GetXMLWorkspaceAsync(client, repoRef); | ||
Console.WriteLine(workspace); | ||
} | ||
|
||
protected async override Task OnParametersSetAsync() | ||
{ | ||
await base.OnParametersSetAsync(); | ||
if (CatpkgGallery is { Reference: { } galleryRef, InfoCache: null }) | ||
{ | ||
var result = await state.Cache.GetHydratedCatpkgGalleryCacheAsync(client, galleryRef); | ||
await CatpkgGalleryChanged.InvokeAsync(result); | ||
} | ||
UpdateRepositories(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
@page "/" | ||
|
||
|
||
<Phalanx.App.Pages.Home.WelcomeView></Phalanx.App.Pages.Home.WelcomeView> | ||
|
||
<div style="display: flex; justify-content: space-around;"> | ||
<FluentAnchor Appearance="Appearance.Accent" Href="/rosteredit">Edit sample roster</FluentAnchor> | ||
<FluentAnchor Appearance="Appearance.Accent" Href="/print">Format roster</FluentAnchor> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@page "/rostercreateselectsystem" | ||
|
||
@using WarHub.ArmouryModel.Source | ||
@using Microsoft.Extensions.Options | ||
@using WarHub.ArmouryModel.DataProviders | ||
@using WarHub.ArmouryModel.Workspaces.BattleScribe | ||
|
||
@inject GalleryHttpClient httpClient | ||
@inject IOptions<GalleryBrowserOptions> options | ||
@inject GalleryBrowserState state | ||
|
||
<h1>Select System for Roster</h1> | ||
|
||
<FluentSelect TValue=string Value="_selectedGalleryName" ValueChanged="(x => onSelectedGalleryChanged(x))"> | ||
<FluentOption>Phalanx Playground</FluentOption> | ||
@foreach (var galleryRef in state.Cache.GalleryReferences) | ||
{ | ||
<FluentOption Value="galleryRef.Name">@galleryRef.Name</FluentOption> | ||
} | ||
</FluentSelect> | ||
|
||
@if (_selectedGalleryName.Length > 0) | ||
{ | ||
<Phalanx.App.Pages.Configuration.SystemSelect @bind-CatpkgGallery=SelectedGalleryCache> | ||
</Phalanx.App.Pages.Configuration.SystemSelect> | ||
} | ||
|
||
@code { | ||
private string _selectedGalleryName = ""; | ||
|
||
private CatpkgGalleryCache? SelectedGalleryCache | ||
{ | ||
get | ||
{ | ||
return _selectedGalleryName == "" | ||
? new CatpkgGalleryCache(new GalleryReference("Phalanx Playground", new Uri("file://"))) | ||
: state.Cache[_selectedGalleryName]; | ||
} | ||
set | ||
{ | ||
if (value is not null) | ||
{ | ||
state.Cache.Upsert(value); | ||
} | ||
} | ||
} | ||
|
||
protected override void OnInitialized() | ||
{ | ||
base.OnInitialized(); | ||
|
||
// add if not already existing | ||
foreach (var galleryRefDto in options.Value.DefaultGalleries) | ||
{ | ||
var galleryRef = galleryRefDto.ToRecord(); | ||
if (state.Cache[galleryRef] is null) | ||
{ | ||
state.Cache.Upsert(new(galleryRef)); | ||
} | ||
} | ||
_selectedGalleryName = options.Value.DefaultGalleries.FirstOrDefault()?.Name ?? ""; | ||
} | ||
|
||
protected async override Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
await base.OnAfterRenderAsync(firstRender); | ||
foreach (var galleryRef in options.Value.DefaultGalleries) | ||
{ | ||
var galleryInfo = await state.Cache.GetCatpkgGalleryInfoAsync(httpClient, galleryRef.ToRecord()); | ||
} | ||
} | ||
protected async Task onSelectedGalleryChanged(string galleryName) | ||
{ | ||
await base.OnParametersSetAsync(); | ||
_selectedGalleryName = galleryName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"GalleryBrowser:DefaultGalleries": [ | ||
{ | ||
"Name": "BSData/gallery", | ||
"CatpkgUrl": "https://github.com/BSData/gallery/releases/download/index-v1/bsdata.catpkg-gallery.json" | ||
} | ||
] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these changes are necessary.
wwwroot/appsettings.json
will automatically be included.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 29-35.