aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-02-02 21:14:19 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2024-02-02 21:14:19 -0500
commit52645b724834e669788a45edb9d135f243432540 (patch)
tree56a5ea56fdf339f00934b3e4cd88212ea3608b29
parentdd5e5164262c5ff7ecf6db1003d41d81e6364c09 (diff)
download file formats, button tweaks, more cache infra
-rw-r--r--back-end/src/Cache/MemPackCacheSerializer.cs34
-rw-r--r--back-end/src/Cache/ResultCacheEntry.cs44
-rw-r--r--back-end/src/Cache/SearchResultCache.cs111
-rw-r--r--back-end/src/Cache/UserSettingsStore.cs16
-rw-r--r--back-end/src/Endpoints/BookmarkEndpoint.cs44
-rw-r--r--back-end/src/ImportExportUtil.cs67
-rw-r--r--back-end/src/SimpleBookmarkEntry.cs45
-rw-r--r--front-end/src/buttons.scss2
-rw-r--r--front-end/src/components/Settings/Bookmarks.vue86
-rw-r--r--front-end/src/components/Settings/PkiSettings.vue2
-rw-r--r--front-end/src/components/Settings/TotpSettings.vue2
-rw-r--r--front-end/src/store/bookmarks.ts8
-rw-r--r--front-end/src/store/index.ts2
13 files changed, 416 insertions, 47 deletions
diff --git a/back-end/src/Cache/MemPackCacheSerializer.cs b/back-end/src/Cache/MemPackCacheSerializer.cs
new file mode 100644
index 0000000..f1ffa88
--- /dev/null
+++ b/back-end/src/Cache/MemPackCacheSerializer.cs
@@ -0,0 +1,34 @@
+// Copyright (C) 2024 Vaughn Nugent
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+
+using System;
+using System.Buffers;
+
+using MemoryPack;
+
+using VNLib.Data.Caching;
+
+namespace SimpleBookmark.Cache
+{
+ internal sealed class MemPackCacheSerializer(MemoryPackSerializerOptions? options) : ICacheObjectSerializer, ICacheObjectDeserializer
+ {
+ ///<inheritdoc/>
+ public T? Deserialize<T>(ReadOnlySpan<byte> objectData) => MemoryPackSerializer.Deserialize<T>(objectData, options);
+
+ ///<inheritdoc/>
+ public void Serialize<T>(T obj, IBufferWriter<byte> finiteWriter) => MemoryPackSerializer.Serialize(finiteWriter, obj, options);
+ }
+}
diff --git a/back-end/src/Cache/ResultCacheEntry.cs b/back-end/src/Cache/ResultCacheEntry.cs
new file mode 100644
index 0000000..3e23042
--- /dev/null
+++ b/back-end/src/Cache/ResultCacheEntry.cs
@@ -0,0 +1,44 @@
+// Copyright (C) 2024 Vaughn Nugent
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+using System;
+using System.Buffers;
+using System.Runtime.InteropServices;
+using System.Text.Json.Serialization;
+
+using MemoryPack;
+
+namespace SimpleBookmark.Cache
+{
+ [MemoryPackable]
+ internal partial class ResultCacheEntry : IDisposable
+ {
+ [MemoryPoolFormatter<byte>]
+ public Memory<byte> Payload { get; set; }
+
+ [JsonPropertyName("created")]
+ public DateTime Created { get; set; }
+
+ public void Dispose()
+ {
+ //Return the array back to the pool
+ if (MemoryMarshal.TryGetArray(Payload, out ArraySegment<byte> segment) && segment.Array is { Length: > 0 })
+ {
+ ArrayPool<byte>.Shared.Return(segment.Array);
+ Payload = default;
+ }
+ }
+ }
+}
diff --git a/back-end/src/Cache/SearchResultCache.cs b/back-end/src/Cache/SearchResultCache.cs
new file mode 100644
index 0000000..c7a263a
--- /dev/null
+++ b/back-end/src/Cache/SearchResultCache.cs
@@ -0,0 +1,111 @@
+// Copyright (C) 2024 Vaughn Nugent
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+using VNLib.Net.Http;
+using VNLib.Data.Caching;
+using VNLib.Plugins;
+using VNLib.Plugins.Extensions.Loading;
+using VNLib.Plugins.Extensions.VNCache;
+using VNLib.Plugins.Extensions.VNCache.DataModel;
+
+namespace SimpleBookmark.Cache
+{
+ [ConfigurationName("search_cache", Required = false)]
+ internal sealed class SearchResultCache
+ {
+ private readonly IEntityCache<ResultCacheEntry>? _cache;
+
+ /// <summary>
+ /// Gets a value that indicates if the configuration enabled result caching
+ /// </summary>
+ public bool IsEnabled => _cache != null;
+
+ public SearchResultCache(PluginBase plugin) : this(plugin, null)
+ { }
+
+ public SearchResultCache(PluginBase plugin, IConfigScope? config)
+ {
+ string? cachePrefix = config?.GetRequiredProperty("cachePrefix", p => p.GetString()!);
+ bool isEnabled = config?.GetRequiredProperty("enabled", p => p.GetBoolean()) ?? true;
+
+ if (!isEnabled)
+ {
+ return;
+ }
+
+ IGlobalCacheProvider? cache = plugin.GetDefaultGlobalCache();
+ if (cache != null)
+ {
+ if (cachePrefix != null)
+ {
+ _cache = cache.GetPrefixedCache(cachePrefix)
+ .CreateEntityCache<ResultCacheEntry>(
+ new MemPackCacheSerializer(null),
+ new MemPackCacheSerializer(null)
+ );
+ }
+ else
+ {
+ //non-prefixed cache
+ _cache = cache.CreateEntityCache<ResultCacheEntry>(
+ new MemPackCacheSerializer(null),
+ new MemPackCacheSerializer(null)
+ );
+ }
+ }
+ }
+
+ public async Task<IMemoryResponseReader?> GetCachedResultAsync(string[] keys, CancellationToken cancellation)
+ {
+ ResultCacheEntry? entry = await _cache!.GetAsync($"{keys}", cancellation);
+ return entry is null ? null : new ResultResponseReader(entry);
+ }
+
+ public Task StoreResultAsync(Memory<byte> data, string[] keys, CancellationToken cancellation)
+ {
+ //Init new entry
+ ResultCacheEntry entry = new()
+ {
+ Payload = data,
+ Created = DateTime.UtcNow
+ };
+
+ return _cache!.UpsertAsync($"{keys}", entry, cancellation);
+ }
+
+ public Task DeleteEntry(string[] keys, CancellationToken cancellation) => _cache!.RemoveAsync($"{keys}", cancellation);
+
+ private sealed class ResultResponseReader(ResultCacheEntry entry) : IMemoryResponseReader
+ {
+ private int _position;
+
+ ///<inheritdoc/>
+ public int Remaining => entry.Payload.Length - _position;
+
+ ///<inheritdoc/>
+ public void Advance(int written) => _position += written;
+
+ ///<inheritdoc/>
+ public void Close() => entry.Dispose();
+
+ ///<inheritdoc/>
+ public ReadOnlyMemory<byte> GetMemory() => entry.Payload.Slice(_position);
+ }
+ }
+}
diff --git a/back-end/src/Cache/UserSettingsStore.cs b/back-end/src/Cache/UserSettingsStore.cs
index 51d47ff..8887973 100644
--- a/back-end/src/Cache/UserSettingsStore.cs
+++ b/back-end/src/Cache/UserSettingsStore.cs
@@ -14,11 +14,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-using System;
-using System.Buffers;
-
-using MemoryPack;
-
using VNLib.Plugins;
using VNLib.Plugins.Extensions.Loading;
using VNLib.Data.Caching;
@@ -27,6 +22,7 @@ using VNLib.Plugins.Extensions.VNCache.DataModel;
namespace SimpleBookmark.Cache
{
+
[ConfigurationName("settings")]
internal sealed class UserSettingsStore
{
@@ -47,16 +43,6 @@ namespace SimpleBookmark.Cache
Cache = cache.GetPrefixedCache(prefix)
.CreateEntityCache<UserSettings>(serializer, serializer);
}
-
- }
-
- private sealed class MemPackCacheSerializer(MemoryPackSerializerOptions? options) : ICacheObjectSerializer, ICacheObjectDeserializer
- {
- ///<inheritdoc/>
- public T? Deserialize<T>(ReadOnlySpan<byte> objectData) => MemoryPackSerializer.Deserialize<T>(objectData, options);
-
- ///<inheritdoc/>
- public void Serialize<T>(T obj, IBufferWriter<byte> finiteWriter) => MemoryPackSerializer.Serialize(finiteWriter, obj, options);
}
}
}
diff --git a/back-end/src/Endpoints/BookmarkEndpoint.cs b/back-end/src/Endpoints/BookmarkEndpoint.cs
index 05b72d0..e6e388d 100644
--- a/back-end/src/Endpoints/BookmarkEndpoint.cs
+++ b/back-end/src/Endpoints/BookmarkEndpoint.cs
@@ -19,7 +19,6 @@ using System.Linq;
using System.Buffers;
using System.Text.Json;
using System.Collections;
-using SimpleBookmark.Model;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@@ -43,6 +42,8 @@ using VNLib.Plugins.Extensions.Loading.Sql;
using VNLib.Plugins.Extensions.Data.Extensions;
using VNLib.Plugins.Extensions.Validation;
+using SimpleBookmark.Model;
+
namespace SimpleBookmark.Endpoints
{
@@ -123,7 +124,11 @@ namespace SimpleBookmark.Endpoints
*/
if(entity.QueryArgs.ContainsKey("export"))
{
- if (entity.Server.Accepts(ContentType.Html))
+ bool html = entity.Server.Accept.Contains("text/html");
+ bool csv = entity.Server.Accept.Contains("text/csv");
+ bool json = entity.Server.Accept.Contains("application/json");
+
+ if (html | csv | json)
{
//Get the collection of bookmarks
List<BookmarkEntry> list = Bookmarks.ListRental.Rent();
@@ -134,20 +139,41 @@ namespace SimpleBookmark.Endpoints
try
{
//Write the bookmarks as a netscape file and return the file
- ImportExportUtil.ExportToNetscapeFile(list, output);
- output.Seek(0, System.IO.SeekOrigin.Begin);
- return VirtualClose(entity, HttpStatusCode.OK, ContentType.Html, output);
+ if (html)
+ {
+ ImportExportUtil.ExportToNetscapeFile(list, output);
+
+ output.Seek(0, System.IO.SeekOrigin.Begin);
+ return VirtualClose(entity, HttpStatusCode.OK, ContentType.Html, output);
+ }
+ else if(csv)
+ {
+ ImportExportUtil.ExportAsCsv(list, output);
+
+ output.Seek(0, System.IO.SeekOrigin.Begin);
+ return VirtualClose(entity, HttpStatusCode.OK, ContentType.Csv, output);
+ }
+ else if(json)
+ {
+ ImportExportUtil.ExportAsJson(list, output);
+
+ output.Seek(0, System.IO.SeekOrigin.Begin);
+ return VirtualClose(entity, HttpStatusCode.OK, ContentType.Json, output);
+ }
}
catch
{
output.Dispose();
throw;
}
+ finally
+ {
+ list.TrimExcess();
+ Bookmarks.ListRental.Return(list);
+ }
}
- else
- {
- return VirtualClose(entity, HttpStatusCode.NotAcceptable);
- }
+
+ return VirtualClose(entity, HttpStatusCode.NotAcceptable);
}
//Get query parameters
diff --git a/back-end/src/ImportExportUtil.cs b/back-end/src/ImportExportUtil.cs
index 3610ef6..6fa554c 100644
--- a/back-end/src/ImportExportUtil.cs
+++ b/back-end/src/ImportExportUtil.cs
@@ -15,8 +15,11 @@
using System;
using System.IO;
+using System.Text.Json;
using SimpleBookmark.Model;
using System.Collections.Generic;
+using System.Text.RegularExpressions;
+
using VNLib.Utils.IO;
@@ -73,5 +76,69 @@ namespace SimpleBookmark
writer.WriteLine("</DL></p>");
writer.Flush();
}
+
+ //Remove illegal characters from a string, ", \, and control characters
+ private static readonly Regex _illegalChars = new("[\"\\p{Cc}]", RegexOptions.Compiled);
+
+ private static string? Escape(string? input)
+ {
+ return input is null ? null : _illegalChars.Replace(input, "");
+ }
+
+ public static void ExportAsCsv(IEnumerable<BookmarkEntry> bookmarks, Stream outputStream)
+ {
+ using VnStreamWriter writer = new(outputStream, System.Text.Encoding.UTF8, 1024)
+ {
+ NewLine = "\r\n"
+ };
+
+ //Write header
+ writer.WriteLine("Name,Url,Description,Tags,Created,LastModified");
+
+ //Write each bookmark
+ foreach (BookmarkEntry entry in bookmarks)
+ {
+ //User params must be escaped with double quotes
+
+ writer.Write("\"");
+ writer.Write(Escape(entry.Name));
+ writer.Write("\",\"");
+ writer.Write(Escape(entry.Url));
+ writer.Write("\",\"");
+ writer.Write(Escape(entry.Description));
+ writer.Write("\",\"");
+ writer.Write(Escape(entry.Tags));
+ writer.Write("\",");
+ writer.Write(new DateTimeOffset(entry.Created).ToUnixTimeSeconds());
+ writer.Write(",");
+ writer.Write(new DateTimeOffset(entry.LastModified).ToUnixTimeSeconds());
+ writer.WriteLine();
+ }
+
+ writer.Flush();
+ }
+
+ public static void ExportAsJson(IEnumerable<BookmarkEntry> bookmarks, Stream outputStream)
+ {
+ using Utf8JsonWriter writer = new(outputStream, default);
+
+ writer.WriteStartArray();
+
+ foreach (BookmarkEntry entry in bookmarks)
+ {
+ writer.WriteStartObject();
+
+ writer.WriteString("Name", entry.Name);
+ writer.WriteString("Url", entry.Url);
+ writer.WriteString("Description", entry.Description);
+ writer.WriteString("Tags", entry.Tags);
+ writer.WriteNumber("Created", new DateTimeOffset(entry.Created).ToUnixTimeSeconds());
+ writer.WriteNumber("LastModified", new DateTimeOffset(entry.LastModified).ToUnixTimeSeconds());
+
+ writer.WriteEndObject();
+ }
+
+ writer.WriteEndArray();
+ }
}
}
diff --git a/back-end/src/SimpleBookmarkEntry.cs b/back-end/src/SimpleBookmarkEntry.cs
index d44aacb..48fcb2a 100644
--- a/back-end/src/SimpleBookmarkEntry.cs
+++ b/back-end/src/SimpleBookmarkEntry.cs
@@ -22,6 +22,9 @@
*/
using System;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
using VNLib.Plugins;
using VNLib.Utils.Logging;
@@ -37,6 +40,7 @@ namespace SimpleBookmark
public sealed class SimpleBookmarkEntry : PluginBase
{
+
///<inheritdoc/>
public override string PluginName { get; } = "SimpleBookmark";
@@ -49,7 +53,8 @@ namespace SimpleBookmark
//Ensure database is created after a delay
this.ObserveWork(() => this.EnsureDbCreatedAsync<SimpleBookmarkContext>(this), 1000);
- Log.Information("Plugin loaded");
+ Log.Information("Plugin Loaded");
+ PrintHelloMessage();
}
///<inheritdoc/>
@@ -62,5 +67,43 @@ namespace SimpleBookmark
{
throw new NotImplementedException();
}
+
+ private void PrintHelloMessage()
+ {
+ const string template =
+@"
+******************************************************************************
+ Simple-Bookmark - A linkding inspired, self hosted, bookmark manager
+ By Vaughn Nugent - vnpublic @proton.me
+ https://www.vaughnnugent.com/resources/software
+ License: GNU Affero General Public License v3.0
+ This application comes with ABSOLUTELY NO WARRANTY.
+
+ Documentation: https://www.vaughnnugent.com/resources/software/articles?tags=docs,_simple-bookmark
+ GitHub: https://github.com/VnUgE/simple-bookmark
+
+ Your server is now running at the following locations:{0}
+******************************************************************************";
+
+ string[] interfaces = HostConfig.GetProperty("virtual_hosts")
+ .EnumerateArray()
+ .Select(e =>
+ {
+ JsonElement el = e.GetProperty("interface");
+ string ipAddress = el.GetProperty("address").GetString()!;
+ int port = el.GetProperty("port").GetInt32();
+ return $"{ipAddress}:{port}";
+ })
+ .ToArray();
+
+ StringBuilder sb = new();
+ foreach (string intf in interfaces)
+ {
+ sb.Append("\n\t");
+ sb.AppendLine(intf);
+ }
+
+ Log.Information(template, sb);
+ }
}
}
diff --git a/front-end/src/buttons.scss b/front-end/src/buttons.scss
index 409f405..7088deb 100644
--- a/front-end/src/buttons.scss
+++ b/front-end/src/buttons.scss
@@ -1,5 +1,5 @@
.btn{
- @apply focus:ring-2 focus:outline-none font-medium rounded text-sm px-4 py-2 text-center me-2 text-white;
+ @apply focus:ring-2 focus:outline-none font-medium rounded text-sm px-4 py-2 text-center text-white;
&.round{
@apply rounded-full;
diff --git a/front-end/src/components/Settings/Bookmarks.vue b/front-end/src/components/Settings/Bookmarks.vue
index 68fa86b..7f73921 100644
--- a/front-end/src/components/Settings/Bookmarks.vue
+++ b/front-end/src/components/Settings/Bookmarks.vue
@@ -1,33 +1,87 @@
<script setup lang="ts">
import { apiCall, useWait } from '@vnuge/vnlib.browser';
-import { useStore } from '../../store';
-import { useObjectUrl, set } from '@vueuse/core';
+import { useStore, type DownloadContentType } from '../../store';
import { ref } from 'vue';
+import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'
const { bookmarks } = useStore();
-const blobUrl = ref<Blob>();
const downloadAnchor = ref();
-const obj = useObjectUrl(blobUrl);
const { waiting } = useWait()
-const downloadBookmarks = () => {
+const downloadBookmarks = (contentType: DownloadContentType) => {
apiCall(async () => {
- const htmlData = await bookmarks.api.downloadAll();
- const blob = new Blob([htmlData], { type: 'text/html' });
- set(blobUrl, blob);
- downloadAnchor.value?.click();
+ const htmlData = await bookmarks.api.downloadAll(contentType);
+
+ switch(contentType) {
+ case 'text/html':
+ case 'text/csv':
+ {
+ const blob = new Blob([htmlData], { type: contentType });
+ const url = URL.createObjectURL(blob);
+ downloadAnchor.value.href = url
+ }
+ break;
+ case 'application/json':
+ {
+ const json = JSON.stringify(htmlData);
+ const blob = new Blob([json], { type: contentType });
+ downloadAnchor.value.href = URL.createObjectURL(blob);
+ }
+ break;
+ }
+
+ downloadAnchor.value.download = `bookmarks.${contentType.split('/')[1]}`
+ downloadAnchor.value.click();
});
}
</script>
<template>
- <div class="flex flex-row justify-start">
- <div class="">
- <button class="flex items-center btn light" :disabled="waiting" @click="downloadBookmarks()">
- Download
- </button>
- </div>
+ <div class="relative w-fit">
+ <Menu>
+ <MenuButton :disabled="waiting" class="flex items-center gap-3 btn light">
+ <div class="hidden lg:inline">Download</div>
+ <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none">
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 13V4M7 14H5a1 1 0 0 0-1 1v4c0 .6.4 1 1 1h14c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1h-2m-1-5-4 5-4-5m9 8h0"/>
+ </svg>
+ </MenuButton>
+ <transition
+ enter-active-class="transition duration-100 ease-out"
+ enter-from-class="transform scale-95 opacity-0"
+ enter-to-class="transform scale-100 opacity-100"
+ leave-active-class="transition duration-75 ease-out"
+ leave-from-class="transform scale-100 opacity-100"
+ leave-to-class="transform scale-95 opacity-0"
+ >
+ <MenuItems class="absolute z-10 bg-white divide-y divide-gray-100 rounded-b shadow right-2 lg:left-0 min-w-32 lg:end-0 dark:bg-gray-700">
+ <ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefaultButton">
+ <!-- Use the `active` state to conditionally style the active item. -->
+ <MenuItem as="template" v-slot="{ }">
+ <li>
+ <button @click="downloadBookmarks('text/html')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
+ HTML
+ </button>
+ </li>
+ </MenuItem>
+ <MenuItem as="template" v-slot="{ }">
+ <li>
+ <button @click="downloadBookmarks('text/csv')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
+ CSV
+ </button>
+ </li>
+ </MenuItem>
+ <MenuItem as="template" v-slot="{ }">
+ <li>
+ <button @click="downloadBookmarks('application/json')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
+ JSON
+ </button>
+ </li>
+ </MenuItem>
+ </ul>
+ </MenuItems>
+ </transition>
+ </Menu>
</div>
- <a ref="downloadAnchor" :href="obj" download="bookmarks.html" class="hidden"></a>
+ <a ref="downloadAnchor" class="hidden"></a>
</template> \ No newline at end of file
diff --git a/front-end/src/components/Settings/PkiSettings.vue b/front-end/src/components/Settings/PkiSettings.vue
index 2564cf6..dfa4cad 100644
--- a/front-end/src/components/Settings/PkiSettings.vue
+++ b/front-end/src/components/Settings/PkiSettings.vue
@@ -129,7 +129,7 @@ const onAddKey = async () => {
<h3 class="text-xl font-bold">Authentication Keys</h3>
<div class="">
- <button type="button" class="btn blue" @click.prevent="showAddKeyDialog">
+ <button type="button" class="btn blue me-2" @click.prevent="showAddKeyDialog">
<div class="flex flex-row items-center gap-1.5">
Add
</div>
diff --git a/front-end/src/components/Settings/TotpSettings.vue b/front-end/src/components/Settings/TotpSettings.vue
index 0019a9d..5793795 100644
--- a/front-end/src/components/Settings/TotpSettings.vue
+++ b/front-end/src/components/Settings/TotpSettings.vue
@@ -113,7 +113,7 @@ const onVerifyOtp = async (code: string) => {
>
</span>
</div>
- <div v-if="totpEnabled" class="flex">
+ <div v-if="totpEnabled" class="flex gap-2">
<button class="btn light" @click="addOrUpdate()">
Regenerate
</button>
diff --git a/front-end/src/store/bookmarks.ts b/front-end/src/store/bookmarks.ts
index b0595e9..76cc5b9 100644
--- a/front-end/src/store/bookmarks.ts
+++ b/front-end/src/store/bookmarks.ts
@@ -43,6 +43,8 @@ export interface BookmarkError{
}>
}
+export type DownloadContentType = 'application/json' | 'text/html' | 'text/csv' | 'text/plain'
+
export interface BookmarkApi{
list: (page: number, limit: number, search: BookmarkSearch) => Promise<Bookmark[]>
add: (bookmark: Bookmark) => Promise<void>
@@ -51,7 +53,7 @@ export interface BookmarkApi{
getTags: () => Promise<string[]>
delete: (bookmark: Bookmark | Bookmark[]) => Promise<void>
count: () => Promise<number>
- downloadAll: () => Promise<string>
+ downloadAll: (contentType: DownloadContentType) => Promise<string>
}
export interface BookmarkSearch{
@@ -141,10 +143,10 @@ const useBookmarkApi = (endpoint: MaybeRef<string>): BookmarkApi => {
return data.result;
}
- const downloadAll = async () => {
+ const downloadAll = async (contentType: DownloadContentType) => {
//download the bookmarks as a html file
const { data } = await axios.get<string>(`${get(endpoint)}?export=true`, {
- headers: { 'Content-Type': 'application/htlm' }
+ headers: { 'Accept': contentType }
})
return data;
}
diff --git a/front-end/src/store/index.ts b/front-end/src/store/index.ts
index c13edcb..bcd79ad 100644
--- a/front-end/src/store/index.ts
+++ b/front-end/src/store/index.ts
@@ -19,6 +19,8 @@ import { noop, toSafeInteger, toString, defaults } from "lodash-es";
import { defineStore } from "pinia";
import { computed, shallowRef, watch } from "vue";
+export type { DownloadContentType } from './bookmarks'
+
export const useQuery = (name: string) => {
const getQuery = () => {