Skip to content
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

Migrate frontend to Blazor #992

Merged
merged 117 commits into from
Mar 26, 2024
Merged

Conversation

calledude
Copy link
Contributor

@calledude calledude commented Jul 29, 2023

Initial implementations

  • Navbar (username, avatar)
    • Guild switch
  • Landing page
  • Stats
  • Commands
  • User Lookup
  • Tags
  • Promotions
    • Info button/modal
  • Logs
    • Infractions
    • Deleted messages
  • Hidden /logfiles page
  • Modix configuration page
    • Claims
    • Channels
    • Roles

If there's anything I've missed in the checklist above, please let me know

Current known issues

  • When starting up the web locally, the discord bot often cannot start fast enough, which leads to an error when serving the page to the user (e.g. DiscordClient.GetUser(id) returns null
  • The donut graph on the Stats and User Lookup pages does not show information in the same way that the vue version does
    • This is a limitation of MudBlazor, there are other libraries available for this purpose but I have not checked them out
  • I've tried my best in making it look OK on mobile, but there is still room for improvement
  • The markdown library used seems to have issues editing codeblocks (the page becomes unresponsive)

TODO

  • Discuss and/or decide on whether or not the structure I've decided to go with here is something we want to change
  • Themes? I have currently skipped implementing this

@calledude calledude force-pushed the blazor branch 2 times, most recently from ffc11a4 to 98b766a Compare July 29, 2023 21:32
@Scott-Caldwell Scott-Caldwell added 2.0 and removed 2.0 labels Jul 29, 2023
@calledude calledude marked this pull request as ready for review August 6, 2023 19:38
Copy link
Member

@Scott-Caldwell Scott-Caldwell Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure what's happening, but something seems broken with the markdown preview. When I type a codeblock into the tag content, the page seems to freeze (preview stops updating, buttons stop working), and I need to refresh the page. Not sure if this is something we're able to do anything about on our end or if it's a bug with MudMarkdown component that we just have to live with for now

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it was kinda wonky during development as well, it works when copy pasting something into it
There are probably better packages out there but I haven't looked into it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing between the create/refresh buttons seems off

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar spacing issue with the checkbox filters

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't spend an awful amount of time on the styling, I just remember this was the only quick way I could get it to look good on all resolutions (they buttons kinda overlap on some screensizes otherwise)
Obviously there's room for improvement but I'm honestly not sure where to begin here, CSS really isn't my forte

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

FWIW this is what I was referring to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have fixed this now, can you check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the channel names aren't displaying in the autocomplete. If I click on one of the empty spaces in the autocomplete, it does populate (what I assume was) the channel I selected into the dialog

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought I had covered all the cases where this component is used when I fixed the nullability warnings
I guess not.
prop = null!; it is :)

Wrote a comment explaining why the workaround exists

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar autocomplete display issues as the channel designations screen:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@calledude calledude force-pushed the blazor branch 2 times, most recently from 00e2051 to ef3f0e1 Compare December 28, 2023 23:02
auto-merge was automatically disabled March 26, 2024 15:55

Head branch was pushed to by a user without write access

@Scott-Caldwell Scott-Caldwell enabled auto-merge (squash) March 26, 2024 15:59
@Scott-Caldwell Scott-Caldwell merged commit 045decc into discord-csharp:main Mar 26, 2024
2 checks passed
@calledude calledude deleted the blazor branch March 26, 2024 16:56
Scott-Caldwell pushed a commit to Scott-Caldwell/MODiX that referenced this pull request Mar 26, 2024
* Initial blazor implementation

* Remove template files

* Add developmentSettings to gitignore and allow wwwroot in blazor project

* Add MudBlazor to _Host.cshtml

* Initial landing page implementation

* Migrate Modix startup to Modix.Web
Add Authorization policies based on AuthorizationClaim enum
Add crude implementation of DiscordUserService

* Implement navbar with separate views depending on authorization state

* Initial implementation of UserLookup page

* Initial implementation of Commands page

* Initial implementation of Stats page

* Initial implementation of Tags page

* Initial implementation of Promotions page

* Run AuthorizationService.OnAuthenticatedAsync in MainLayout instead
ClaimsTransformation uses a different service scope from the blazor circuit - which leads to AuthorizationService properties not being set properly for the authenticated user
Also remove redundant authorization setup in startup

* Initial implementation of Logs/Infractions page

* Use dropdown for 'Type' in infractions grid

* Remove unnecessary comments

* Move navbar from MainLayout to separate component

* Change page titles

* Get SocketGuild from SocketGuildUser instead

* Use OnAfterRenderAsync instead to avoid duplicate DB calls

* Implement guild selection
Remove ClaimsTransformationService
Overall improvements to navbar
Move logic for adding claims to App.razor
Read selected guild from cookie and pass it down the chain

* Remove <AuthorizeView> etc in favor of Authorize attribute

* Use OnAfterRenderAsync to avoid unnecessary execution of db calls etc

* Use [Authorize] attribute to avoid rendering of the page whatsoever

* Fix icon colors of navbar in the logged out state

* Use middleware to assign claims rather than have it in App.razor
The call to AuthorizationService.OnAuthenticatedAsync is still needed in App.razor to be able to set the values in the correct scope.

* Move logout button to dropdown menu
Small tidy up

* Rename LocalStorageService -> CookieService

* Show current user when first visiting UserLookup
Slight improvements with nullability
Remove commented code

* Move models to Models folder

* Propagate CurrentUserId down to components via SessionState to avoid reading from user claims constantly

* Fix issue with filters not resetting properly

* Initially select nothing in the dropdown for InfractionType (nothing was actually initially selected, it just appeared to be)

* Force cookie to be created on root path

* Continue with first found guild if no guild cookie was found

* Case-insensitive filtering on Tags page

* Improve feedback when Tag creation fails (or succeeds)

* Allow null/empty comments for promotions
Use MudSpacer instead of manual flex-grow

* Disable editing comments for closed campaigns
Update UI after editing comment
Better feedback after editing comment

* Initial implementation of Configuration (Claims)

* Small touchup

* Remove unnecessary stuff in MainLayout

* Modify DesignatedRoleService API slightly to return the id of the created entity

* Initial implementation of Configuration (Roles)

* Slight improvement to styling of menu for Configuration and Logs

* Modify DesignatedChannelService API slightly to return the id of the created entity

* Make IndividualDesignation component generic

* Initial implementation of Configuration (Channels)

* Slight improvements to Channels/Roles configuration pages

* Make Autocomplete component generic

* Move ModixUser and RoleInformation into Common

* Modify interface of PromotionsService to return the PromotionActionSummary after updating a comment
Fix bug in Promotions UI where you could edit a comment and inadvertently have two active ones as a result

* Implement possibility of passing query parameters to infractions page, such as ?id=<infraction_id> and ?subject=<username>
Also redirect from /infractions to /logs/infractions

* Add possibility of accepting/rejecting/forcing a campaign as well as link to the infractions page for the campaign subject

* Simplify styling on Infractions page

* Use iconbuttons instead for accept/reject

* Re-use existing extension method for getting full username

* Initial implementation of Logs/DeletedMessages page

* Fix bug with filtering DeletedMessageEntity
- When Batch is set, use that to filter on CreatedBy(Id)
- Move AsExpandable() to sourceQuery

* Set _currentContext before potential early bail
Close dialog on error

* Show role color if relevant in Tags grid

* Enable query parameter for Tags page

* Use generic version of DialogParameters when instantiating Dialogs

* Persist infraction table settings to local storage
Move cookie constants into separate class

* Slight styling improvements to stats page

* Fix/consolidate date string formatting

* Responsive navmenu

* Responsive commands page

* Better styling for DeletedMessages

* Better styling for Infractions page

* Responsive styling for Configuration (Claims)

* Responsive styling for UserLookup

* Slightly improve styling for landing and promotions pages

* Remove unnecessary elements from landing page

* Change Primary color to match the vue website

* Fix weird flickering issue when navigating via anchors

* Use MudGrid instead of MudDrawer
Improve styling on Commands page
Fix element Ids not being navigable to because of having spaces in them

* Rename DiscordUserService to DiscordHelper

* Make it possible to switch between Vue and Blazor via config flag 'UseBlazor'
Convert Startup based startup to minimal hosting model in Modix
Make Modix.Web into a class library

* Remove appsettings from Modix.Web

* Add NoDefaultLaunchSettingsFile to avoid re-creating launchSettings.json

* Remove LocalStorageService in favor of reading cookies upon first HTTP request to the site and propagating settings through SessionState instead

* Remove unused package/project references

* Add favicon

* Use Roles instead of Policy authorization

* Improve grid size for bigger screens

* Implement comment creation box to show when the user has yet to vote on a campaign

* Fit content to screen width on Tags page

* Minor touchups

* Remove unused css

* Fix more nullability stuff
Some of it might technically be impossible scenarios, but "meh" :)

* Fixed AutoComplete after breaking it by not invoking the RenderFragment after fixing nullability

* Disable button/comment box on promotion creation page if no "next rank" is available

* Fix compilation issue

* Upgrade packages to stable version to fix startup issue

* Fix ItemTemplate issue causing preview to be empty

* Remove TODO comments, add error message when fetching of campaign details fails

* Make Title an optional parameter on the AutoComplete component and remove the usage of it on the UserLookup page

* Remove background color from UserLookup

* Apply small gap rule on small screen sizes (that aren't quite xs yet) to avoid overlapping between elements

* Improved styling for toolbar on Infractions page

* Improved styling for toolbar on Tags page

* Fix css not being served from the correct folder

* Improve styling for Promotions page on small resolutions

* Update NuGet packages and change from deprecated APIs/properties

* Remove UseStaticFiles call in favor of linking to static files correctly in the _Host file

* Update Dockerfile to use .net8 instead of .net8-preview image

* Update more NuGet packages to .NET pinned versions and cleanup some of the version references in projects

* Use maxcpucount:1 in Dockerfile to avoid files being used by other processes error

* Slight mobile styling tweaks to Infractions and Tags page

* Reduce reliance on inline styling

* Update default value for UseBlazor setting in deployment configuration files

* Format code

* Improved styling on CreatePromotion page on small resolutions

* Improved styling for Configuration/Logs pages

* Add margin to make it look a bit nicer when scrolling to the bottom of the page

* Tweak styling for large resolutions on Stats and Logs pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants