From eeb99cf37c821887543fa7abf3972006c28e06ca Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 18 Feb 2025 08:57:58 +0100 Subject: [PATCH 1/5] feat: add revisionSnapshotTimeIntervalTimeScale option to be used in the revision_snapshot_interval widget, when it is ported to use TimeSelector --- src/routes/api/options.ts | 1 + src/services/options_init.ts | 1 + src/services/options_interface.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/src/routes/api/options.ts b/src/routes/api/options.ts index 33cd5fa8c4..29cea62002 100644 --- a/src/routes/api/options.ts +++ b/src/routes/api/options.ts @@ -15,6 +15,7 @@ const ALLOWED_OPTIONS = new Set([ "eraseEntitiesAfterTimeScale", "protectedSessionTimeout", "revisionSnapshotTimeInterval", + "revisionSnapshotTimeIntervalTimeScale", "revisionSnapshotNumberLimit", "zoomFactor", "theme", diff --git a/src/services/options_init.ts b/src/services/options_init.ts index 3bb87703e1..16eb28795f 100644 --- a/src/services/options_init.ts +++ b/src/services/options_init.ts @@ -75,6 +75,7 @@ async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = */ const defaultOptions: DefaultOption[] = [ { name: "revisionSnapshotTimeInterval", value: "600", isSynced: true }, + { name: "revisionSnapshotTimeIntervalTimeScale", value: "60", isSynced: true }, // default to Minutes { name: "revisionSnapshotNumberLimit", value: "-1", isSynced: true }, { name: "protectedSessionTimeout", value: "600", isSynced: true }, { name: "zoomFactor", value: isWindows ? "0.9" : "1.0", isSynced: false }, diff --git a/src/services/options_interface.ts b/src/services/options_interface.ts index fb234240c6..c8a49518f1 100644 --- a/src/services/options_interface.ts +++ b/src/services/options_interface.ts @@ -49,6 +49,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions Date: Tue, 18 Feb 2025 09:00:57 +0100 Subject: [PATCH 2/5] feat: use TimeSelector for revision_snapshot_interval added one TODO that needs to be handled in TimeSelector: minimum allowed value (!in seconds!) --- .../other/revisions_snapshot_interval.ts | 32 +++++++++---------- .../type_widgets/options/time_selector.ts | 1 + 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts b/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts index 751f70653f..db095fa81d 100644 --- a/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts +++ b/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts @@ -1,30 +1,30 @@ -import OptionsWidget from "../options_widget.js"; import { t } from "../../../../services/i18n.js"; -import type { OptionMap } from "../../../../../../services/options_interface.js"; +import TimeSelector from "../time_selector.js"; const TPL = `

${t("revisions_snapshot_interval.note_revisions_snapshot_interval_title")}

- -
- - -
+
`; +//TriliumNextTODO: add support for setting minimum number of entered seconds -> snapshot revision should not be less than 10 seconds +export default class RevisionsSnapshotIntervalOptions extends TimeSelector { -export default class RevisionsSnapshotIntervalOptions extends OptionsWidget { - - private $revisionsTimeInterval!: JQuery; + constructor() { + super({ + widgetId: "revision-snapshot-time-interval", + widgetLabelId: "revisions_snapshot_interval.snapshot_time_interval_label", + optionValueId: "revisionSnapshotTimeInterval", + optionTimeScaleId: "revisionSnapshotTimeIntervalTimeScale" + }); + super.doRender(); + } doRender() { + const $timeSelector = this.$widget; + // inject TimeSelector widget template this.$widget = $(TPL); - this.$revisionsTimeInterval = this.$widget.find(".revision-snapshot-time-interval-in-seconds"); - this.$revisionsTimeInterval.on("change", () => this.updateOption("revisionSnapshotTimeInterval", this.$revisionsTimeInterval.val())); - } - - async optionsLoaded(options: OptionMap) { - this.$revisionsTimeInterval.val(options.revisionSnapshotTimeInterval); + this.$widget.find("#time-selector-placeholder").replaceWith($timeSelector) } } diff --git a/src/public/app/widgets/type_widgets/options/time_selector.ts b/src/public/app/widgets/type_widgets/options/time_selector.ts index a3ec7c9bb4..74c85faa7e 100644 --- a/src/public/app/widgets/type_widgets/options/time_selector.ts +++ b/src/public/app/widgets/type_widgets/options/time_selector.ts @@ -36,6 +36,7 @@ const TPL = (options: Omit`; +//TriliumNextTODO: add support for setting minimum number of entered seconds export default class TimeSelector extends OptionsWidget { private $timeValueInput!: JQuery; private $timeScaleSelect!: JQuery; From 28148b32d23d66957d3669714681a1778e9e8877 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 18 Feb 2025 09:07:37 +0100 Subject: [PATCH 3/5] i18n: adjust labels for update revision_snapshot_interval options we don't do seconds only anymore, so strings needed adjusting --- src/public/translations/cn/translation.json | 6 +++--- src/public/translations/de/translation.json | 4 ++-- src/public/translations/en/translation.json | 4 ++-- src/public/translations/es/translation.json | 4 ++-- src/public/translations/fr/translation.json | 4 ++-- src/public/translations/ro/translation.json | 4 ++-- src/public/translations/tw/translation.json | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json index 7deb0d59c1..de278739b8 100644 --- a/src/public/translations/cn/translation.json +++ b/src/public/translations/cn/translation.json @@ -1138,9 +1138,9 @@ "deleted_notes_erased": "已删除的笔记已被清理。" }, "revisions_snapshot_interval": { - "note_revisions_snapshot_interval_title": "笔记修改快照间隔", - "note_revisions_snapshot_description": "笔记修改快照时间间隔是指经过多少秒后会为笔记创建新的修改历史。更多信息请参见wiki。", - "snapshot_time_interval_label": "笔记修改快照时间间隔(单位:秒)" + "note_revisions_snapshot_interval_title": "Note Revision Snapshot Interval", + "note_revisions_snapshot_description": "The Note revision snapshot interval is the time after which a new note revision will be created for the note. See wiki for more info.", + "snapshot_time_interval_label": "Note revision snapshot time interval:" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "笔记历史快照限制", diff --git a/src/public/translations/de/translation.json b/src/public/translations/de/translation.json index c450085e31..a38c09fcda 100644 --- a/src/public/translations/de/translation.json +++ b/src/public/translations/de/translation.json @@ -1107,8 +1107,8 @@ }, "revisions_snapshot_interval": { "note_revisions_snapshot_interval_title": "Snapshot-Intervall für Notizrevisionen", - "note_revisions_snapshot_description": "Das Snapshot-Zeitintervall für Notizrevisionen ist die Zeit in Sekunden, nach der eine neue Notizrevision erstellt wird. Weitere Informationen findest du im Wiki.", - "snapshot_time_interval_label": "Zeitintervall für Notiz-Revisions-Snapshot (in Sekunden)" + "note_revisions_snapshot_description": "Das Snapshot-Zeitintervall für Notizrevisionen ist die Zeit, nach der eine neue Notizrevision erstellt wird. Weitere Informationen findest du im Wiki.", + "snapshot_time_interval_label": "Zeitintervall für Notiz-Revisions-Snapshot:" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "Limit für Notizrevision-Snapshots", diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index 32474d5c13..1dc4432006 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1165,8 +1165,8 @@ }, "revisions_snapshot_interval": { "note_revisions_snapshot_interval_title": "Note Revision Snapshot Interval", - "note_revisions_snapshot_description": "The Note revision snapshot interval is the time in seconds after which a new note revision will be created for the note. See wiki for more info.", - "snapshot_time_interval_label": "Note revision snapshot time interval (in seconds):" + "note_revisions_snapshot_description": "The Note revision snapshot interval is the time after which a new note revision will be created for the note. See wiki for more info.", + "snapshot_time_interval_label": "Note revision snapshot time interval:" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "Note Revision Snapshot Limit", diff --git a/src/public/translations/es/translation.json b/src/public/translations/es/translation.json index 3810997c3f..1902ba01a2 100644 --- a/src/public/translations/es/translation.json +++ b/src/public/translations/es/translation.json @@ -1163,8 +1163,8 @@ }, "revisions_snapshot_interval": { "note_revisions_snapshot_interval_title": "Intervalo de instantáneas de revisiones de notas", - "note_revisions_snapshot_description": "El intervalo de tiempo de la instantánea de revisión de nota es el tiempo en segundos después de lo cual se creará una nueva revisión para la nota. Ver wiki para obtener más información.", - "snapshot_time_interval_label": "Intervalo de tiempo de la instantánea de revisión de notas (en segundos)" + "note_revisions_snapshot_description": "El intervalo de tiempo de la instantánea de revisión de nota es el tiempo después de lo cual se creará una nueva revisión para la nota. Ver wiki para obtener más información.", + "snapshot_time_interval_label": "Intervalo de tiempo de la instantánea de revisión de notas:" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "Límite de respaldos de revisiones de nota", diff --git a/src/public/translations/fr/translation.json b/src/public/translations/fr/translation.json index 891760da8f..bb99773c72 100644 --- a/src/public/translations/fr/translation.json +++ b/src/public/translations/fr/translation.json @@ -1108,8 +1108,8 @@ }, "revisions_snapshot_interval": { "note_revisions_snapshot_interval_title": "Intervalle d'enregistrement automatique des versions des notes", - "note_revisions_snapshot_description": "L'intervalle d'enregistrement automatique des versions de note est le temps en secondes après lequel une nouvelle version de note est créée pour une note. Consultez le wiki pour plus d'informations.", - "snapshot_time_interval_label": "Intervalle de temps entre deux enregistrements de version de note (en secondes) :" + "note_revisions_snapshot_description": "L'intervalle d'enregistrement automatique des versions de note est le temps après lequel une nouvelle version de note est créée pour une note. Consultez le wiki pour plus d'informations.", + "snapshot_time_interval_label": "Intervalle de temps entre deux enregistrements de version de note :" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "Limite des enregistrements de version de note", diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index 2d22c2c3c0..b0a3ccf40d 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -1068,9 +1068,9 @@ "note_revisions": "Revizii ale notiței" }, "revisions_snapshot_interval": { - "note_revisions_snapshot_description": "Intervalul de salvare a reviziilor este timpul în secunde după care se crează o nouă revizie a unei notițe. Vedeți wiki-ul pentru mai multe informații.", + "note_revisions_snapshot_description": "Intervalul de salvare a reviziilor este timpul după care se crează o nouă revizie a unei notițe. Vedeți wiki-ul pentru mai multe informații.", "note_revisions_snapshot_interval_title": "Intervalul de salvare a reviziilor", - "snapshot_time_interval_label": "Intervalul de salvare a reviziilor (în secunde)" + "snapshot_time_interval_label": "Intervalul de salvare a reviziilor:" }, "ribbon": { "edited_notes_message": "Tab-ul panglicii „Notițe editate” se va deschide automat pentru notițele zilnice", diff --git a/src/public/translations/tw/translation.json b/src/public/translations/tw/translation.json index 6540335804..830c761673 100644 --- a/src/public/translations/tw/translation.json +++ b/src/public/translations/tw/translation.json @@ -1116,9 +1116,9 @@ "deleted_notes_erased": "已刪除的筆記已被清理。" }, "revisions_snapshot_interval": { - "note_revisions_snapshot_interval_title": "筆記修改快照間隔", - "note_revisions_snapshot_description": "筆記修改快照時間間隔是指經過多少秒後會為筆記新增新的修改歷史。更多資訊請參見wiki。", - "snapshot_time_interval_label": "筆記修改快照時間間隔(單位:秒)" + "note_revisions_snapshot_interval_title": "Note Revision Snapshot Interval", + "note_revisions_snapshot_description": "The Note revision snapshot interval is the time after which a new note revision will be created for the note. See wiki for more info.", + "snapshot_time_interval_label": "Note revision snapshot time interval:" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "筆記歷史快照限制", From bf41c54bd05f56643223b706c5ca4c44a2ff95bc Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 18 Feb 2025 22:32:43 +0100 Subject: [PATCH 4/5] feat: set TimeSelector minimumSeconds for revision_snapshot_interval and remove TODO --- .../options/other/revisions_snapshot_interval.ts | 5 +++-- src/public/app/widgets/type_widgets/options/time_selector.ts | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts b/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts index db095fa81d..13c86fc887 100644 --- a/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts +++ b/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts @@ -8,7 +8,7 @@ const TPL = `
`; -//TriliumNextTODO: add support for setting minimum number of entered seconds -> snapshot revision should not be less than 10 seconds + export default class RevisionsSnapshotIntervalOptions extends TimeSelector { constructor() { @@ -16,7 +16,8 @@ export default class RevisionsSnapshotIntervalOptions extends TimeSelector { widgetId: "revision-snapshot-time-interval", widgetLabelId: "revisions_snapshot_interval.snapshot_time_interval_label", optionValueId: "revisionSnapshotTimeInterval", - optionTimeScaleId: "revisionSnapshotTimeIntervalTimeScale" + optionTimeScaleId: "revisionSnapshotTimeIntervalTimeScale", + minimumSeconds: 10 }); super.doRender(); } diff --git a/src/public/app/widgets/type_widgets/options/time_selector.ts b/src/public/app/widgets/type_widgets/options/time_selector.ts index 74c85faa7e..a3ec7c9bb4 100644 --- a/src/public/app/widgets/type_widgets/options/time_selector.ts +++ b/src/public/app/widgets/type_widgets/options/time_selector.ts @@ -36,7 +36,6 @@ const TPL = (options: Omit`; -//TriliumNextTODO: add support for setting minimum number of entered seconds export default class TimeSelector extends OptionsWidget { private $timeValueInput!: JQuery; private $timeScaleSelect!: JQuery; From 6fae7a98f58ec46bad9c45d7c575fb4b0293b103 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Fri, 21 Feb 2025 07:41:50 +0100 Subject: [PATCH 5/5] i18n: use empty string instead of English string it will fallback to the English string by default --- src/public/translations/cn/translation.json | 6 +++--- src/public/translations/tw/translation.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json index 5aa329df0f..b7771755ae 100644 --- a/src/public/translations/cn/translation.json +++ b/src/public/translations/cn/translation.json @@ -1138,9 +1138,9 @@ "deleted_notes_erased": "已删除的笔记已被清理。" }, "revisions_snapshot_interval": { - "note_revisions_snapshot_interval_title": "Note Revision Snapshot Interval", - "note_revisions_snapshot_description": "The Note revision snapshot interval is the time after which a new note revision will be created for the note. See wiki for more info.", - "snapshot_time_interval_label": "Note revision snapshot time interval:" + "note_revisions_snapshot_interval_title": "", + "note_revisions_snapshot_description": "", + "snapshot_time_interval_label": "" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "笔记历史快照限制", diff --git a/src/public/translations/tw/translation.json b/src/public/translations/tw/translation.json index 830c761673..a5a5191b1e 100644 --- a/src/public/translations/tw/translation.json +++ b/src/public/translations/tw/translation.json @@ -1116,9 +1116,9 @@ "deleted_notes_erased": "已刪除的筆記已被清理。" }, "revisions_snapshot_interval": { - "note_revisions_snapshot_interval_title": "Note Revision Snapshot Interval", - "note_revisions_snapshot_description": "The Note revision snapshot interval is the time after which a new note revision will be created for the note. See wiki for more info.", - "snapshot_time_interval_label": "Note revision snapshot time interval:" + "note_revisions_snapshot_interval_title": "", + "note_revisions_snapshot_description": "", + "snapshot_time_interval_label": "" }, "revisions_snapshot_limit": { "note_revisions_snapshot_limit_title": "筆記歷史快照限制",