diff --git a/MemCheck.WebUI/Controllers/SearchController.cs b/MemCheck.WebUI/Controllers/SearchController.cs index 30e41138..3165634d 100644 --- a/MemCheck.WebUI/Controllers/SearchController.cs +++ b/MemCheck.WebUI/Controllers/SearchController.cs @@ -626,4 +626,49 @@ public SubscribeToSearchViewModel(string toastTitle, string toastMesg) public string ToastMesg { get; } } #endregion + #region GetAllCardsListData + [HttpGet("GetAllCardsListData")] + public async Task GetAllCardsListData() + { + var publicCards = await new GetAllPublicCards(callContext).RunAsync(new GetAllPublicCards.Request()); + var resultCards = publicCards.Cards.Select(publicCard => new GetAllCardsListDataResultEntry(publicCard.CardId, publicCard.FrontSide, publicCard.BackSide, publicCard.VersionUtcDate, publicCard.AverageRating)); + + var nonPublicCardCount = await new CountNonPublicCards(callContext).RunAsync(new CountNonPublicCards.Request()); + + var user = await userManager.GetUserAsync(HttpContext.User); + var result = new GetAllCardsListDataResult(resultCards, nonPublicCardCount.Count, user); + await Task.Delay(0); + return base.Ok(result); + } + #region Request and view model classes + public sealed class GetAllCardsListDataResult + { + public GetAllCardsListDataResult(IEnumerable publicCards, int nonPublicCardCount, MemCheckUser? currentUser) + { + PublicCards = publicCards; + NonPublicCardCount = nonPublicCardCount; + ShowDebugInfo = DisplayServices.ShowDebugInfo(currentUser); + } + public int NonPublicCardCount { get; } + public IEnumerable PublicCards { get; } + public bool ShowDebugInfo { get; } + } + public sealed class GetAllCardsListDataResultEntry + { + public GetAllCardsListDataResultEntry(Guid cardId, string frontSide, string backSide, DateTime versionUtcDate, double averageRating) + { + CardId = cardId; + FrontSide = frontSide; + BackSide = backSide; + VersionUtcDate = versionUtcDate; + AverageRating = averageRating; + } + public Guid CardId { get; } + public string FrontSide { get; } + public string BackSide { get; } + public DateTime VersionUtcDate { get; } + public double AverageRating { get; } + } + #endregion + #endregion } diff --git a/MemCheck.WebUI/MemCheck.WebUI.csproj b/MemCheck.WebUI/MemCheck.WebUI.csproj index 66afcd3e..fa7479c6 100644 --- a/MemCheck.WebUI/MemCheck.WebUI.csproj +++ b/MemCheck.WebUI/MemCheck.WebUI.csproj @@ -1,7 +1,7 @@  - 0.179.21 + 0.180.0 diff --git a/MemCheck.WebUI/Pages/Index.cshtml b/MemCheck.WebUI/Pages/Index.cshtml index ae4f4706..1d3d5fcd 100644 --- a/MemCheck.WebUI/Pages/Index.cshtml +++ b/MemCheck.WebUI/Pages/Index.cshtml @@ -43,6 +43,7 @@
  • {{tag.tagName}}
  • @Localizer["BeforeDocLink"]@Localizer["TheDoc"]@Localizer["AfterDocLink"]

    +

    @Localizer["BeforeAllCardsListLink"]@Localizer["AllCardsListLink"]@Localizer["AfterAllCardsListLink"]

    diff --git a/MemCheck.WebUI/Pages/Search/AllCardsList.cshtml b/MemCheck.WebUI/Pages/Search/AllCardsList.cshtml new file mode 100644 index 00000000..ae7dc07b --- /dev/null +++ b/MemCheck.WebUI/Pages/Search/AllCardsList.cshtml @@ -0,0 +1,54 @@ +@page +@using Microsoft.AspNetCore.Mvc.Localization +@using System.Web +@inject IViewLocalizer Localizer +@model MemCheck.WebUI.Pages.Search.AllCardsListModel +@section head { + +} + @section scripts { + + +} + @{ + ViewData["Title"] = @Localizer["PageTitle"]; + ViewData["HelpPage"] = "/allcardslist"; +} + +
    +
    + +

    @Localizer["PleaseWaitForMount"]

    +
    +
    +

    Liste des cartes publiques

    +

    La base de données de Mnesios contient {{allData.publicCards.length}} cartes publiques (ainsi que {{allData.nonPublicCardCount}} cartes privées, non affichées ici).

    + + + + + + + + + + + + + + + +
    @Localizer["FrontSide"]@Localizer["BackSide"]@Localizer["VersionDate"]@Localizer["Rating"]
    {{card.frontSide}}{{card.backSide}}{{dateTime(card.versionUtcDate)}}
    +
    +
    +
      +
    • {{mountDebugInfo}}
    • +
    +
    +
    diff --git a/MemCheck.WebUI/Pages/Search/AllCardsList.cshtml.cs b/MemCheck.WebUI/Pages/Search/AllCardsList.cshtml.cs new file mode 100644 index 00000000..d947d377 --- /dev/null +++ b/MemCheck.WebUI/Pages/Search/AllCardsList.cshtml.cs @@ -0,0 +1,7 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace MemCheck.WebUI.Pages.Search; + +public class AllCardsListModel : PageModel +{ +} diff --git a/MemCheck.WebUI/Resources/Pages/Index.en.resx b/MemCheck.WebUI/Resources/Pages/Index.en.resx index 4f1e27be..105640b8 100644 --- a/MemCheck.WebUI/Resources/Pages/Index.en.resx +++ b/MemCheck.WebUI/Resources/Pages/Index.en.resx @@ -237,4 +237,13 @@ for the context. + + . + + + all public cards + + + You can also get a sneak peek of + \ No newline at end of file diff --git a/MemCheck.WebUI/Resources/Pages/Index.fr.resx b/MemCheck.WebUI/Resources/Pages/Index.fr.resx index 27ce3a1e..fb85da94 100644 --- a/MemCheck.WebUI/Resources/Pages/Index.fr.resx +++ b/MemCheck.WebUI/Resources/Pages/Index.fr.resx @@ -237,4 +237,13 @@ contextuelle. + + . + + + toutes les cartes publiques + + + Vous pouvez aussi avoir un apperçu de + \ No newline at end of file diff --git a/MemCheck.WebUI/Resources/Pages/Search/AllCardsList.en.resx b/MemCheck.WebUI/Resources/Pages/Search/AllCardsList.en.resx new file mode 100644 index 00000000..0af7663a --- /dev/null +++ b/MemCheck.WebUI/Resources/Pages/Search/AllCardsList.en.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Average rating + + + Back Side + + + Front Side + + + No evaluation + + + List of all public cards + + + Please wait, initializing data... + + + Average rating + + + Date + + \ No newline at end of file diff --git a/MemCheck.WebUI/Resources/Pages/Search/AllCardsList.fr.resx b/MemCheck.WebUI/Resources/Pages/Search/AllCardsList.fr.resx new file mode 100644 index 00000000..15148585 --- /dev/null +++ b/MemCheck.WebUI/Resources/Pages/Search/AllCardsList.fr.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Moyenne des évaluations + + + Arrière + + + Avant + + + Aucune évaluation + + + Liste des cartes publiques + + + Chargement des données... + + + Éval. moyenne + + + Date + + \ No newline at end of file diff --git a/MemCheck.WebUI/wwwroot/css/allcardslist.css b/MemCheck.WebUI/wwwroot/css/allcardslist.css new file mode 100644 index 00000000..ce084c45 --- /dev/null +++ b/MemCheck.WebUI/wwwroot/css/allcardslist.css @@ -0,0 +1,3 @@ +.learning-card { + border: none; +} diff --git a/MemCheck.WebUI/wwwroot/js/CardRating.js b/MemCheck.WebUI/wwwroot/js/CardRating.js index 285d80f8..dce45c61 100644 --- a/MemCheck.WebUI/wwwroot/js/CardRating.js +++ b/MemCheck.WebUI/wwwroot/js/CardRating.js @@ -7,7 +7,7 @@ export const CardRating = Vue.defineComponent({ 'van-rate': globalThis.vant.Rate, }, props: { - modelValue: { required: false, type: Number }, + modelValue: { required: false, type: Number }, // Current user rating, can be null average: { required: true, type: Number }, countinaverage: { required: false, type: Number }, micro: { required: false, type: Boolean, default: false }, diff --git a/MemCheck.WebUI/wwwroot/js/Search/AllCardsList.js b/MemCheck.WebUI/wwwroot/js/Search/AllCardsList.js new file mode 100644 index 00000000..00f2ed93 --- /dev/null +++ b/MemCheck.WebUI/wwwroot/js/Search/AllCardsList.js @@ -0,0 +1,52 @@ +import { TagButton } from '../TagButton.js'; +import { CardRating } from '../CardRating.js'; +import { isValidDateTime } from '../Common.js'; +import { dateTime } from '../Common.js'; +import { tellAxiosError } from '../Common.js'; + +const allCardsListApp = Vue.createApp({ + components: { + 'van-button': globalThis.vant.Button, + 'van-popover': globalThis.vant.Popover, + 'van-datetimepicker': globalThis.vant.DatetimePicker, + 'card-rating': CardRating, + 'tag-button': TagButton, + }, + data() { + return { + mountFinished: false, + allData: null, // SearchController.GetAllStaticDataViewModel - We never mute this field after mounted has finished + mountDebugInfo: '', + }; + }, + beforeCreate() { + this.dateTime = dateTime; + this.isValidDateTime = isValidDateTime; + }, + async mounted() { + const start = performance.now(); + try { + await this.getAllData(); + } + finally { + this.mountFinished = true; + this.mountDebugInfo = `Vue mount time: ${((performance.now() - start) / 1000).toFixed(1)} seconds`; + } + }, + methods: { + async getAllData() { + await axios.get('/Search/GetAllCardsListData/') + .then(result => { + this.allData = result.data; + }) + .catch(error => { + tellAxiosError(error); + }); + }, + showDebugInfo() { + return this.allData !== null && this.allData.showDebugInfo; + }, + }, +}); + +allCardsListApp.mount('#AllCardsListRootDiv');