Skip to content

Commit b35a4b9

Browse files
committed
fix: reduce size of storage column , only showing first character
fix: redistribute columns sizes, giving more space to key+value feat: add Value Lengh colums to quick insight on the value size feat: select key and value content clicked (should make extraction quicker) feat: show full data on cell hover for key, value and value-length
1 parent 0096b2e commit b35a4b9

File tree

2 files changed

+82
-22
lines changed

2 files changed

+82
-22
lines changed

sources/localstorage-editor/popup.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
(?)
3939
</abbr>
4040
<textarea
41-
style="width: 100%; height: 380px; white-space: nowrap; resize: none;"
41+
style="
42+
width: 100%;
43+
height: 380px;
44+
white-space: nowrap;
45+
resize: none;
46+
"
4247
;
4348
spellcheck="false"
4449
></textarea>

sources/localstorage-editor/popup.js

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ function getTimeStampStr() {
105105
async function getTblData() {
106106
let data = [];
107107
try {
108-
data = await browser.tabs.executeScript(TABID, {
109-
file: "getStorage.js",
110-
});
108+
data = (
109+
await browser.tabs.executeScript(TABID, {
110+
file: "getStorage.js",
111+
})
112+
)[0];
111113
} catch (e) {
112114
data = [];
113115
}
@@ -298,7 +300,8 @@ async function onDOMContentLoaded() {
298300
resizable: false,
299301
},
300302
placeholder: "No items",
301-
layout: "fitDataStretch",
303+
//layout: "fitDataStretch",
304+
layout: "fitColumns",
302305
pagination: false,
303306
movableRows: true,
304307
validationMode: "highlight",
@@ -310,31 +313,38 @@ async function onDOMContentLoaded() {
310313
resizableColumnFit: true,
311314
columns: [
312315
{
313-
rowHandle: true,
314316
formatter: "handle",
315-
headerSort: false,
316317
frozen: true,
317-
width: 30,
318-
minWidth: 30,
319318
headerSort: false,
319+
hozAlign: "center",
320+
rowHandle: true,
321+
width: 10,
320322
},
321323
{
322324
formatter: "rowSelection",
325+
frozen: true,
326+
headerSort: false,
327+
hozAlign: "center",
328+
headerHozAlign: "center",
323329
titleFormatter: "rowSelection",
330+
width: 10,
324331
titleFormatterParams: {
325332
rowRange: "active", //only toggle the values of the active filtered rows
326333
},
327-
hozAlign: "left",
328-
headerSort: false,
329334
cellClick: (e, cell) => {
330335
cell.getRow().toggleSelect();
331336
},
332-
width: 30,
333-
minWidth: 30,
334337
},
335338
{
336-
title: "Storage",
339+
title: '<abbr title="Storage Area">SA</abbr>',
337340
field: "store",
341+
frozen: true,
342+
width: 60,
343+
hozAlign: "center",
344+
headerFilter: "list",
345+
editor: "list",
346+
editorParams: { values: ["Local", "Session"] },
347+
headerFilterPlaceholder: "Filter",
338348
cellMouseOver: function (e, cell) {
339349
const valid = cell.validate();
340350
if (valid !== true) {
@@ -343,25 +353,39 @@ async function onDOMContentLoaded() {
343353
);
344354
}
345355
},
346-
hozAlign: "left",
347-
headerFilter: "list",
348-
editor: "list",
349-
//verticalNavigation: "hybrid",
350-
editorParams: { values: ["Local", "Session"] },
351-
headerFilterPlaceholder: "Select",
352356
headerFilterFunc: storeHeaderFilter,
353357
headerFilterParams: {
354358
clearable: true,
355359
values: ["Local", "Session"],
356360
multiselect: true,
357361
},
358362
validator: ["in:Local|Session", "required"],
363+
formatter: function (cell, formatterParams, onRendered) {
364+
//cell - the cell component
365+
//formatterParams - parameters set for the column
366+
//onRendered - function to call when the formatter has been rendered
367+
const val = cell.getValue();
368+
if (["Session", "Local"].includes(val)) {
369+
return '<abbr title="' + val + '" >' + val[0] + "</abbr>";
370+
}
371+
return "";
372+
},
373+
},
374+
375+
/*
376+
{
377+
title: "",
378+
field: "ksize",
379+
headerSort: true,
380+
hozAlign : "right",
359381
},
382+
*/
360383
{
361384
title: "Key",
362385
field: "key",
363386
resizable: "header",
364387
headerSort: true,
388+
widthGrow: 2,
365389
validator: [
366390
"required",
367391
{
@@ -389,7 +413,6 @@ async function onDOMContentLoaded() {
389413
);
390414
}
391415
},
392-
width: "25%",
393416
headerFilter: "input",
394417
headerFilterPlaceholder: "Filter",
395418
formatter: "plaintext",
@@ -398,13 +421,21 @@ async function onDOMContentLoaded() {
398421
elementAttributes: {
399422
spellcheck: "false",
400423
},
424+
selectContents: true,
401425
shiftEnterSubmit: true,
402426
},
427+
/*
428+
cellEdited: function (cell) {
429+
// update the size column
430+
cell.getRow().update({ ksize: cell.getValue().length });
431+
},
432+
*/
403433
},
404434

405435
{
406436
title: "Value",
407437
field: "value",
438+
widthGrow: 4,
408439
headerFilter: "input",
409440
headerFilterPlaceholder: "Filter",
410441
editor: "textarea",
@@ -414,9 +445,10 @@ async function onDOMContentLoaded() {
414445
spellcheck: "false",
415446
wrap: "off",
416447
},
417-
verticalNavigation: "editor",
448+
verticalNavigation: "hybrid",
418449
variableHeight: true,
419450
shiftEnterSubmit: true,
451+
selectContents: true,
420452
},
421453
formatter: "plaintext",
422454
/**/
@@ -433,8 +465,27 @@ async function onDOMContentLoaded() {
433465
textareaEl.setSelectionRange(0, 0);
434466
//}
435467
},
468+
cellEdited: function (cell) {
469+
// update the size column
470+
cell.getRow().update({ vsize: cell.getValue().length });
471+
},
472+
473+
cellMouseOver: function (e, cell) {
474+
cell.getElement().setAttribute("title", cell.getValue());
475+
},
436476
/**/
437477
},
478+
{
479+
title: '<abbr title="Value Length">VL</abbr>',
480+
field: "vsize",
481+
headerSort: true,
482+
hozAlign: "left",
483+
frozen: true,
484+
minWidth: 50,
485+
cellMouseOver: function (e, cell) {
486+
cell.getElement().setAttribute("title", cell.getValue());
487+
},
488+
},
438489
],
439490
});
440491

@@ -452,6 +503,8 @@ async function onDOMContentLoaded() {
452503
table.alert("Loading data");
453504
const data = await getTblData();
454505
data.forEach(async (e, index) => {
506+
e["vsize"] = e.value.length;
507+
//e['ksize'] = e.key.length;
455508
table.addRow(e, true);
456509

457510
// after processing the last element
@@ -481,6 +534,8 @@ async function onDOMContentLoaded() {
481534
store: selectEl.value,
482535
key: inputEl.value,
483536
value: textareaEl.value,
537+
vsize: textareaEl.value.length,
538+
//ksize: inputEl.value.length,
484539
});
485540

486541
editDialog.close();

0 commit comments

Comments
 (0)