@ -1,6 +1,7 @@
import NoteContextAwareWidget from "../note_context_aware_widget.js" ;
import server from "../../services/server.js" ;
import utils from "../../services/utils.js" ;
import { t } from "../../services/i18n.js" ;
const TPL = `
< div class = "note-info-widget" >
@ -30,31 +31,27 @@ const TPL = `
< table class = "note-info-widget-table" >
< tr >
< th > Note ID : < / t h >
< th > ${ t ( "note_info_widget.note_id" ) } : < / t h >
< td class = "note-info-note-id" > < / t d >
< th > Created : < / t h >
< th > ${ t ( "note_info_widget.created" ) } : < / t h >
< td class = "note-info-date-created" > < / t d >
< th > Modified : < / t h >
< th > ${ t ( "note_info_widget.modified" ) } : < / t h >
< td class = "note-info-date-modified" > < / t d >
< / t r >
< tr >
< th > Type : < / t h >
< th > ${ t ( "note_info_widget.type" ) } : < / t h >
< td >
< span class = "note-info-type" > < / s p a n >
< span class = "note-info-mime" > < / s p a n >
< / t d >
< th title = "Note size provides rough estimate of storage requirements for this note. It takes into account note's content and content of its note revisions." > Note size : < / t h >
< th title = "${t(" note _info _widget . note _size _info ")}" > $ { t ( "note_info_widget.note_size" ) } : < / t h >
< td colspan = "3" >
< button class = "btn btn-sm calculate-button" style = "padding: 0px 10px 0px 10px;" >
< span class = "bx bx-calculator" > < / s p a n > ca l c u l a t e
< span class = "bx bx-calculator" > < / s p a n > ${ t ( " n o t e _ i n f o _ w i d g e t . ca l c u l a t e " ) }
< / b u t t o n >
< span class = "note-sizes-wrapper" >
< span class = "note-size" > < / s p a n >
< span class = "subtree-size" > < / s p a n >
< / s p a n >
< / t d >
@ -62,6 +59,7 @@ const TPL = `
< / t a b l e >
< / d i v >
` ;
export default class NoteInfoWidget extends NoteContextAwareWidget {
get name ( ) {
return "noteInfo" ;
@ -78,7 +76,7 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
getTitle ( ) {
return {
show : this . isEnabled ( ) ,
title : 'Note Info' ,
title : t ( "note_info_widget.title" ) ,
icon : 'bx bx-info-circle'
} ;
}
@ -111,9 +109,8 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
const subTreeResp = await server . get ( ` stats/subtree-size/ ${ this . noteId } ` ) ;
if ( subTreeResp . subTreeNoteCount > 1 ) {
this . $subTreeSize . text ( ` (subtree size: ${ utils . formatSize ( subTreeResp . subTreeSize ) } in ${ subTreeResp . subTreeNoteCount } notes) ` ) ;
}
else {
this . $subTreeSize . text ( t ( "note_info_widget.subtree_size" , { size : utils . formatSize ( subTreeResp . subTreeSize ) , count : subTreeResp . subTreeNoteCount } ) ) ;
} else {
this . $subTreeSize . text ( "" ) ;
}
} ) ;
@ -143,7 +140,7 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
this . $noteSizesWrapper . hide ( ) ;
}
entitiesReloadedEvent ( { loadResults } ) {
entitiesReloadedEvent ( { loadResults } ) {
if ( loadResults . isNoteReloaded ( this . noteId ) || loadResults . isNoteContentReloaded ( this . noteId ) ) {
this . refresh ( ) ;
}