From b000f2225c2d74db10ecd4ad352290bd08e17a67 Mon Sep 17 00:00:00 2001 From: Rok Rejc Date: Mon, 16 Jan 2023 13:01:53 +0100 Subject: [PATCH] Change extension of export file from csv to txt. --- .../WebApp/src/hooks/use-download.js | 2 +- .../Concordances/ExportConcordancesHandler.cs | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/apps/Rsdo.Concordancer.Api/WebApp/src/hooks/use-download.js b/src/apps/Rsdo.Concordancer.Api/WebApp/src/hooks/use-download.js index 46bf9e4..279358f 100644 --- a/src/apps/Rsdo.Concordancer.Api/WebApp/src/hooks/use-download.js +++ b/src/apps/Rsdo.Concordancer.Api/WebApp/src/hooks/use-download.js @@ -12,7 +12,7 @@ const useDownload = (url) => { var url = window.URL.createObjectURL(blob); var a = document.createElement('a'); a.href = url; - a.download = "export.csv"; + a.download = "export.txt"; document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox a.click(); a.remove(); //afterwards we remove the element again diff --git a/src/core/Rsdo.Concordancer.Services/RequestHandlers/Concordances/ExportConcordancesHandler.cs b/src/core/Rsdo.Concordancer.Services/RequestHandlers/Concordances/ExportConcordancesHandler.cs index f4e73aa..c4a527c 100644 --- a/src/core/Rsdo.Concordancer.Services/RequestHandlers/Concordances/ExportConcordancesHandler.cs +++ b/src/core/Rsdo.Concordancer.Services/RequestHandlers/Concordances/ExportConcordancesHandler.cs @@ -75,21 +75,6 @@ public class ExportConcordancesHandler : BaseSearchConcordancesHandler, IRequest }; } - private async Task> GetSources(List items) - { - var paragraphIds = items.Select(i => i.ParagraphId).ToList(); - var sources = await dbContext.Paragraph.Include(p => p.Text) - .Where(p => paragraphIds.Contains(p.Id)) - .Select( - p => new - { - p.Id, - p.Text.SourceFile, - }) - .ToListAsync(); - return sources.ToDictionary(x => x.Id, x => Path.GetFileNameWithoutExtension(x.SourceFile)); - } - private static async Task WriteContext(StreamWriter writer, List tokens) { if (tokens != null) @@ -132,4 +117,19 @@ public class ExportConcordancesHandler : BaseSearchConcordancesHandler, IRequest await writer.WriteAsync(source); await writer.WriteLineAsync(); } + + private async Task> GetSources(List items) + { + var paragraphIds = items.Select(i => i.ParagraphId).ToList(); + var sources = await dbContext.Paragraph.Include(p => p.Text) + .Where(p => paragraphIds.Contains(p.Id)) + .Select( + p => new + { + p.Id, + p.Text.SourceFile, + }) + .ToListAsync(); + return sources.ToDictionary(x => x.Id, x => Path.GetFileNameWithoutExtension(x.SourceFile)); + } } \ No newline at end of file