storage space occupied added. see #129
This commit is contained in:
parent
2aa692c872
commit
9bbf795709
5 changed files with 70 additions and 37 deletions
|
|
@ -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": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>__MSG_customPrompts_managePrompts__</h1>
|
||||
<h1 class="page_title">__MSG_customPrompts_managePrompts__</h1>
|
||||
<p>__MSG_customPrompts_managePrompts_info_default__<br>
|
||||
__MSG_customPrompts_managePrompts_info_default_2__<br>
|
||||
__MSG_customPrompts_managePrompts_info_default_3__
|
||||
|
|
@ -92,9 +92,9 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="storage_space">__MSG_StorageSpace__: <span id="storage_space"></span></div>
|
||||
<script src="list.js"></script>
|
||||
<script src="mzta-custom-prompts.js" type="module"></script>
|
||||
<script src="../js/mzta-i18n.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue