mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 15:09:01 +01:00
feat(react/settings): port attachment erasure timeout
This commit is contained in:
parent
436fd16f3a
commit
a71d28500d
@ -10,6 +10,7 @@ export default function OtherSettings() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NoteErasureTimeout />
|
<NoteErasureTimeout />
|
||||||
|
<AttachmentErasureTimeout />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -21,8 +22,7 @@ function NoteErasureTimeout() {
|
|||||||
<TimeSelector
|
<TimeSelector
|
||||||
name="erase-entities-after"
|
name="erase-entities-after"
|
||||||
label={t("note_erasure_timeout.erase_notes_after")}
|
label={t("note_erasure_timeout.erase_notes_after")}
|
||||||
optionValueId="eraseEntitiesAfterTimeInSeconds"
|
optionValueId="eraseEntitiesAfterTimeInSeconds" optionTimeScaleId="eraseEntitiesAfterTimeScale"
|
||||||
optionTimeScaleId="eraseEntitiesAfterTimeScale"
|
|
||||||
/>
|
/>
|
||||||
<FormText>{t("note_erasure_timeout.manual_erasing_description")}</FormText>
|
<FormText>{t("note_erasure_timeout.manual_erasing_description")}</FormText>
|
||||||
|
|
||||||
@ -37,3 +37,26 @@ function NoteErasureTimeout() {
|
|||||||
</OptionsSection>
|
</OptionsSection>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AttachmentErasureTimeout() {
|
||||||
|
return (
|
||||||
|
<OptionsSection title={t("attachment_erasure_timeout.attachment_erasure_timeout")}>
|
||||||
|
<FormText>{t("attachment_erasure_timeout.attachment_auto_deletion_description")}</FormText>
|
||||||
|
<TimeSelector
|
||||||
|
name="erase-unused-attachments-after"
|
||||||
|
label={t("attachment_erasure_timeout.erase_attachments_after")}
|
||||||
|
optionValueId="eraseUnusedAttachmentsAfterSeconds" optionTimeScaleId="eraseUnusedAttachmentsAfterTimeScale"
|
||||||
|
/>
|
||||||
|
<FormText>{t("attachment_erasure_timeout.manual_erasing_description")}</FormText>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
text={t("attachment_erasure_timeout.erase_unused_attachments_now")}
|
||||||
|
onClick={() => {
|
||||||
|
server.post("notes/erase-unused-attachments-now").then(() => {
|
||||||
|
toast.showMessage(t("attachment_erasure_timeout.unused_attachments_erased"));
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</OptionsSection>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -1,44 +0,0 @@
|
|||||||
import OptionsWidget from "../options_widget.js";
|
|
||||||
import server from "../../../../services/server.js";
|
|
||||||
import toastService from "../../../../services/toast.js";
|
|
||||||
import { t } from "../../../../services/i18n.js";
|
|
||||||
import TimeSelector from "../time_selector.js";
|
|
||||||
|
|
||||||
const TPL = /*html*/`
|
|
||||||
<div class="options-section">
|
|
||||||
<h4>${t("attachment_erasure_timeout.attachment_erasure_timeout")}</h4>
|
|
||||||
|
|
||||||
<p class="form-text">${t("attachment_erasure_timeout.attachment_auto_deletion_description")}</p>
|
|
||||||
<div id="time-selector-placeholder"></div>
|
|
||||||
|
|
||||||
<p class="form-text">${t("attachment_erasure_timeout.manual_erasing_description")}</p>
|
|
||||||
<button class="erase-unused-attachments-now-button btn btn-secondary">${t("attachment_erasure_timeout.erase_unused_attachments_now")}</button>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
export default class AttachmentErasureTimeoutOptions extends TimeSelector {
|
|
||||||
private $eraseUnusedAttachmentsNowButton!: JQuery<HTMLElement>;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super({
|
|
||||||
widgetId: "erase-unused-attachments-after",
|
|
||||||
widgetLabelId: "attachment_erasure_timeout.erase_attachments_after",
|
|
||||||
optionValueId: "eraseUnusedAttachmentsAfterSeconds",
|
|
||||||
optionTimeScaleId: "eraseUnusedAttachmentsAfterTimeScale"
|
|
||||||
});
|
|
||||||
super.doRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
doRender() {
|
|
||||||
const $timeSelector = this.$widget;
|
|
||||||
this.$widget = $(TPL);
|
|
||||||
// inject TimeSelector widget template
|
|
||||||
this.$widget.find("#time-selector-placeholder").replaceWith($timeSelector);
|
|
||||||
|
|
||||||
this.$eraseUnusedAttachmentsNowButton = this.$widget.find(".erase-unused-attachments-now-button");
|
|
||||||
this.$eraseUnusedAttachmentsNowButton.on("click", () => {
|
|
||||||
server.post("notes/erase-unused-attachments-now").then(() => {
|
|
||||||
toastService.showMessage(t("attachment_erasure_timeout.unused_attachments_erased"));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user