trilium/src/public/javascripts/dialogs/options/advanced.js

80 lines
2.8 KiB
JavaScript
Raw Normal View History

2019-08-22 02:24:37 +08:00
import server from "../../services/server.js";
2019-10-20 16:00:18 +08:00
import toastService from "../../services/toast.js";
2019-08-22 02:24:37 +08:00
const TPL = `
<h4 style="margin-top: 0;">Sync</h4>
<button id="force-full-sync-button" class="btn btn-secondary">Force full sync</button>
<br/>
<br/>
<button id="fill-sync-rows-button" class="btn btn-secondary">Fill sync rows</button>
<br/>
<br/>
<h4>Debugging</h4>
<button id="anonymize-button" class="btn btn-secondary">Save anonymized database</button><br/><br/>
<p>This action will create a new copy of the database and anonymise it (remove all note content and leave only structure and metadata)
for sharing online for debugging purposes without fear of leaking your personal data.</p>
<h4>Vacuum database</h4>
<p>This will rebuild database which will typically result in smaller database file. No data will be actually changed.</p>
<button id="vacuum-database-button" class="btn btn-secondary">Vacuum database</button>`;
2019-08-22 02:24:37 +08:00
export default class AdvancedOptions {
constructor() {
$("#options-advanced").html(TPL);
2019-08-22 02:24:37 +08:00
this.$forceFullSyncButton = $("#force-full-sync-button");
this.$fillSyncRowsButton = $("#fill-sync-rows-button");
this.$anonymizeButton = $("#anonymize-button");
this.$cleanupSoftDeletedButton = $("#cleanup-soft-deleted-items-button");
this.$cleanupUnusedImagesButton = $("#cleanup-unused-images-button");
this.$vacuumDatabaseButton = $("#vacuum-database-button");
2019-11-10 00:39:48 +08:00
this.$forceFullSyncButton.on('click', async () => {
2019-08-22 02:24:37 +08:00
await server.post('sync/force-full-sync');
2019-10-20 16:00:18 +08:00
toastService.showMessage("Full sync triggered");
2019-08-22 02:24:37 +08:00
});
2019-11-10 00:39:48 +08:00
this.$fillSyncRowsButton.on('click', async () => {
2019-08-22 02:24:37 +08:00
await server.post('sync/fill-sync-rows');
2019-10-20 16:00:18 +08:00
toastService.showMessage("Sync rows filled successfully");
2019-08-22 02:24:37 +08:00
});
2019-11-10 00:39:48 +08:00
this.$anonymizeButton.on('click', async () => {
2019-08-22 02:24:37 +08:00
await server.post('anonymization/anonymize');
2019-10-20 16:00:18 +08:00
toastService.showMessage("Created anonymized database");
2019-08-22 02:24:37 +08:00
});
2019-11-10 00:39:48 +08:00
this.$cleanupSoftDeletedButton.on('click', async () => {
2019-08-22 02:24:37 +08:00
if (confirm("Do you really want to clean up soft-deleted items?")) {
await server.post('cleanup/cleanup-soft-deleted-items');
2019-10-20 16:00:18 +08:00
toastService.showMessage("Soft deleted items have been cleaned up");
2019-08-22 02:24:37 +08:00
}
});
2019-11-10 00:39:48 +08:00
this.$cleanupUnusedImagesButton.on('click', async () => {
2019-08-22 02:24:37 +08:00
if (confirm("Do you really want to clean up unused images?")) {
await server.post('cleanup/cleanup-unused-images');
2019-10-20 16:00:18 +08:00
toastService.showMessage("Unused images have been cleaned up");
2019-08-22 02:24:37 +08:00
}
});
2019-11-10 00:39:48 +08:00
this.$vacuumDatabaseButton.on('click', async () => {
2019-08-22 02:24:37 +08:00
await server.post('cleanup/vacuum-database');
2019-10-20 16:00:18 +08:00
toastService.showMessage("Database has been vacuumed");
2019-08-22 02:24:37 +08:00
});
}
}