mirror of
https://github.com/zadam/trilium.git
synced 2025-01-25 00:18:15 +08:00
size calculation is always on demand
This commit is contained in:
parent
35ea877c7d
commit
480aec1667
3 changed files with 31 additions and 17 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -2360,9 +2360,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dayjs": {
|
"dayjs": {
|
||||||
"version": "1.10.3",
|
"version": "1.10.4",
|
||||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.3.tgz",
|
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.4.tgz",
|
||||||
"integrity": "sha512-/2fdLN987N8Ki7Id8BUN2nhuiRyxTLumQnSQf9CNncFCyqFsSKb9TNhzRYcC8K8eJSJOKvbvkImo/MKKhNi4iw=="
|
"integrity": "sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw=="
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"commonmark": "0.29.3",
|
"commonmark": "0.29.3",
|
||||||
"cookie-parser": "1.4.5",
|
"cookie-parser": "1.4.5",
|
||||||
"csurf": "1.11.0",
|
"csurf": "1.11.0",
|
||||||
"dayjs": "1.10.3",
|
"dayjs": "1.10.4",
|
||||||
"ejs": "3.1.5",
|
"ejs": "3.1.5",
|
||||||
"electron-debug": "3.2.0",
|
"electron-debug": "3.2.0",
|
||||||
"electron-dl": "3.0.2",
|
"electron-dl": "3.0.2",
|
||||||
|
|
|
@ -43,9 +43,15 @@ const TPL = `
|
||||||
<th>Note size:</th>
|
<th>Note size:</th>
|
||||||
|
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<span class="note-size"></span>
|
<button class="btn btn-sm calculate-button" style="padding: 0px 10px 0px 10px;">
|
||||||
|
<span class="bx bx-calculator"></span> calculate
|
||||||
|
</button>
|
||||||
|
|
||||||
(subtree size: <span class="subtree-size"></span>)
|
<span class="note-sizes-wrapper">
|
||||||
|
<span class="note-size"></span>
|
||||||
|
|
||||||
|
(subtree size: <span class="subtree-size"></span>)
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -66,8 +72,25 @@ export default class NoteInfoWidget extends CollapsibleWidget {
|
||||||
this.$dateModified = this.$body.find(".note-info-date-modified");
|
this.$dateModified = this.$body.find(".note-info-date-modified");
|
||||||
this.$type = this.$body.find(".note-info-type");
|
this.$type = this.$body.find(".note-info-type");
|
||||||
this.$mime = this.$body.find(".note-info-mime");
|
this.$mime = this.$body.find(".note-info-mime");
|
||||||
|
|
||||||
|
this.$noteSizesWrapper = this.$body.find('.note-sizes-wrapper');
|
||||||
this.$noteSize = this.$body.find(".note-size");
|
this.$noteSize = this.$body.find(".note-size");
|
||||||
this.$subTreeSize = this.$body.find(".subtree-size");
|
this.$subTreeSize = this.$body.find(".subtree-size");
|
||||||
|
|
||||||
|
this.$calculateButton = this.$body.find(".calculate-button");
|
||||||
|
this.$calculateButton.on('click', async () => {
|
||||||
|
this.$noteSizesWrapper.show();
|
||||||
|
this.$calculateButton.hide();
|
||||||
|
|
||||||
|
this.$noteSize.empty().append($('<span class="bx bx-loader bx-spin"></span>'));
|
||||||
|
this.$subTreeSize.empty().append($('<span class="bx bx-loader bx-spin"></span>'));
|
||||||
|
|
||||||
|
const noteSizeResp = await server.get(`stats/note-size/${this.noteId}`);
|
||||||
|
this.$noteSize.text(this.formatSize(noteSizeResp.noteSize));
|
||||||
|
|
||||||
|
const subTreeSizeResp = await server.get(`stats/subtree-size/${this.noteId}`);
|
||||||
|
this.$subTreeSize.text(this.formatSize(subTreeSizeResp.subTreeSize));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
|
@ -91,17 +114,8 @@ export default class NoteInfoWidget extends CollapsibleWidget {
|
||||||
this.$mime.empty();
|
this.$mime.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const resp = await server.get(`stats/note-size/${note.noteId}`);
|
this.$calculateButton.show();
|
||||||
this.$noteSize.text(this.formatSize(resp.noteSize));
|
this.$noteSizesWrapper.hide();
|
||||||
|
|
||||||
const $calculateLink = $('<a href="javascript:">calculate</a>')
|
|
||||||
.on('click', async () => {
|
|
||||||
const resp = await server.get(`stats/subtree-size/${note.noteId}`);
|
|
||||||
|
|
||||||
this.$subTreeSize.text(this.formatSize(resp.subTreeSize));
|
|
||||||
})
|
|
||||||
|
|
||||||
this.$subTreeSize.empty().append($calculateLink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatSize(size) {
|
formatSize(size) {
|
||||||
|
|
Loading…
Reference in a new issue