diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a9955929..c3742bd6 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -538,5 +538,9 @@ "prefs_OpenAIComp_ChatName_Info": { "message": "This is the name that will be used in the AI chat.", "description": "" + }, + "StorageSpace": { + "message": "Total storage space occupied", + "description": "" } } \ No newline at end of file diff --git a/customprompts/mzta-custom-prompts.css b/customprompts/mzta-custom-prompts.css index c65acfad..4d7fb217 100644 --- a/customprompts/mzta-custom-prompts.css +++ b/customprompts/mzta-custom-prompts.css @@ -16,38 +16,6 @@ } } - -@media (prefers-color-scheme: dark) { - body { - background-color: #1C1B22; - color: rgb(251, 251, 254); - } - - a:link { color: #409EFF; } - a:visited { color: #409EFF; } - a:hover { color: #66B1FF; } - a:active { color: #66B1FF; } - - table { - background-color: #1C1B22; - border: 1px solid #ccc; - } - - table.prompts_list th { - background-color: #4c4e58; - border: 1px solid rgb(251, 251, 254); - color: rgb(194, 194, 194); - } - - #command_palette{ - background-color: inherit; - } - - table.prompts_list tr:nth-child(even) { - background-color: #2E2F36; - } -} - table { border-collapse: collapse; border-spacing: 0; @@ -180,4 +148,54 @@ table .sort.desc { #btnExportAll{ margin-bottom: 3px; +} + +.storage_space{ + font-size: 0.8em; + font-weight: normal; + font-style: italic; + color: rgb(41, 41, 41); + text-align: right; + margin-right: 1px; +} + +.page_title{ + margin-bottom: 0px; +} + + +@media (prefers-color-scheme: dark) { + body { + background-color: #1C1B22; + color: rgb(251, 251, 254); + } + + a:link { color: #409EFF; } + a:visited { color: #409EFF; } + a:hover { color: #66B1FF; } + a:active { color: #66B1FF; } + + table { + background-color: #1C1B22; + border: 1px solid #ccc; + } + + table.prompts_list th { + background-color: #4c4e58; + border: 1px solid rgb(251, 251, 254); + color: rgb(194, 194, 194); + } + + #command_palette{ + background-color: inherit; + } + + table.prompts_list tr:nth-child(even) { + background-color: #2E2F36; + } + + .storage_space{ + color: rgb(182, 182, 182); + } + } \ No newline at end of file diff --git a/customprompts/mzta-custom-prompts.html b/customprompts/mzta-custom-prompts.html index fa8a17eb..22055da4 100644 --- a/customprompts/mzta-custom-prompts.html +++ b/customprompts/mzta-custom-prompts.html @@ -7,7 +7,7 @@
-

__MSG_customPrompts_managePrompts__

+

__MSG_customPrompts_managePrompts__

__MSG_customPrompts_managePrompts_info_default__
__MSG_customPrompts_managePrompts_info_default_2__
__MSG_customPrompts_managePrompts_info_default_3__ @@ -92,9 +92,9 @@

+
__MSG_StorageSpace__:
- - + \ No newline at end of file diff --git a/customprompts/mzta-custom-prompts.js b/customprompts/mzta-custom-prompts.js index 1440506a..5cc8dc98 100644 --- a/customprompts/mzta-custom-prompts.js +++ b/customprompts/mzta-custom-prompts.js @@ -17,7 +17,7 @@ */ import { getPrompts, setDefaultPromptsProperties, setCustomPrompts, preparePromptsForExport, preparePromptsForImport } from "../js/mzta-prompts.js"; -import { isThunderbird128OrGreater } from "../js/mzta-utils.js"; +import { isThunderbird128OrGreater, getCustomPromptsUsedSpace } from "../js/mzta-utils.js"; var promptsList = null; var somethingChanged = false; @@ -28,6 +28,8 @@ var msgTimeout = null; document.addEventListener('DOMContentLoaded', async () => { + setStorageSpace(); + let values = await getPrompts(); //console.log('>>>>>>>>>>>>>>>> values: ' + JSON.stringify(values)); @@ -601,6 +603,7 @@ async function saveAll() { clearMessage(); }, 10000) } + setStorageSpace(); } function setMessage(msg, color = '') { @@ -618,6 +621,11 @@ function clearMessage() { msgDisplay.style.color = ''; } +async function setStorageSpace() { + let storage_space = await getCustomPromptsUsedSpace(); + document.getElementById('storage_space').textContent = storage_space; +} + if(await isThunderbird128OrGreater()){ window.addEventListener('beforeunload', function (event) { diff --git a/js/mzta-utils.js b/js/mzta-utils.js index d019f175..b9e65846 100644 --- a/js/mzta-utils.js +++ b/js/mzta-utils.js @@ -184,7 +184,10 @@ const insertHtml = function (replyHtml, fullBody_string) { } export async function getCustomPromptsUsedSpace(){ - let customprompts_space = await browser.storage.local.getBytesInUse("_custom_prompt"); + // we can't use this, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1385832 + //let customprompts_space = await browser.storage.local.getBytesInUse("_custom_prompt"); + //let's use a workaround + let customprompts_space = Object.entries(await browser.storage.local.get(["_custom_prompt", "_default_prompts_properties"])).map(([key, value]) => key.length + JSON.stringify(value).length).reduce((acc, x) => acc + x, 0) return formatBytes(customprompts_space); }