Files
Trilium/src/public/app/dialogs/options/advanced.js

97 lines
3.6 KiB
JavaScript
Raw Normal View History

2019-08-21 20:24:37 +02:00
import server from "../../services/server.js";
2019-10-20 10:00:18 +02:00
import toastService from "../../services/toast.js";
2019-08-21 20:24:37 +02:00
const TPL = `
<h4 style="margin-top: 0;">Sync</h4>
2019-11-20 21:35:18 +01:00
<button id="force-full-sync-button" class="btn">Force full sync</button>
<br/>
<br/>
<button id="fill-entity-changes-button" class="btn">Fill entity changes records</button>
<br/>
<br/>
<h4>Database integrity check</h4>
<p>This will check that the database is not corrupted on the SQLite level. It might take some time, depending on the DB size.</p>
<button id="check-integrity-button" class="btn">Check database integrity</button><br/><br/>
2019-12-10 22:03:00 +01:00
<h4>Consistency checks</h4>
<button id="find-and-fix-consistency-issues-button" class="btn">Find and fix consistency issues</button><br/><br/>
2020-06-03 12:16:16 +02:00
<h4>Anonymize database</h4>
<p>This action will create a new copy of the database and anonymize it (remove all note content and leave only structure and some non-sensitive metadata)
for sharing online for debugging purposes without fear of leaking your personal data.</p>
2020-06-03 12:16:16 +02:00
<button id="anonymize-button" class="btn">Save anonymized database</button><br/><br/>
<h4>Vacuum database</h4>
<p>This will rebuild the database which will typically result in a smaller database file. No data will be actually changed.</p>
2019-11-20 21:35:18 +01:00
<button id="vacuum-database-button" class="btn">Vacuum database</button>`;
2019-08-21 20:24:37 +02:00
export default class AdvancedOptions {
constructor() {
$("#options-advanced").html(TPL);
2019-08-21 20:24:37 +02:00
this.$forceFullSyncButton = $("#force-full-sync-button");
this.$fillEntityChangesButton = $("#fill-entity-changes-button");
2019-08-21 20:24:37 +02:00
this.$anonymizeButton = $("#anonymize-button");
this.$vacuumDatabaseButton = $("#vacuum-database-button");
2019-12-10 22:03:00 +01:00
this.$findAndFixConsistencyIssuesButton = $("#find-and-fix-consistency-issues-button");
this.$checkIntegrityButton = $("#check-integrity-button");
2019-08-21 20:24:37 +02:00
2019-11-09 17:39:48 +01:00
this.$forceFullSyncButton.on('click', async () => {
2019-08-21 20:24:37 +02:00
await server.post('sync/force-full-sync');
2019-10-20 10:00:18 +02:00
toastService.showMessage("Full sync triggered");
2019-08-21 20:24:37 +02:00
});
this.$fillEntityChangesButton.on('click', async () => {
await server.post('sync/fill-entity-changes');
2019-08-21 20:24:37 +02:00
2019-10-20 10:00:18 +02:00
toastService.showMessage("Sync rows filled successfully");
2019-08-21 20:24:37 +02:00
});
2019-11-09 17:39:48 +01:00
this.$anonymizeButton.on('click', async () => {
2020-06-02 23:13:55 +02:00
const resp = await server.post('database/anonymize');
if (!resp.success) {
toastService.showError("Could not create anonymized database, check backend logs for details");
}
else {
toastService.showMessage(`Created anonymized database in ${resp.anonymizedFilePath}`, 10000);
}
2019-08-21 20:24:37 +02:00
});
2019-11-09 17:39:48 +01:00
this.$vacuumDatabaseButton.on('click', async () => {
await server.post('database/vacuum-database');
2019-08-21 20:24:37 +02:00
2019-10-20 10:00:18 +02:00
toastService.showMessage("Database has been vacuumed");
2019-08-21 20:24:37 +02:00
});
2019-12-10 22:03:00 +01:00
this.$findAndFixConsistencyIssuesButton.on('click', async () => {
await server.post('database/find-and-fix-consistency-issues');
2019-12-10 22:03:00 +01:00
toastService.showMessage("Consistency issues should be fixed.");
});
this.$checkIntegrityButton.on('click', async () => {
const {results} = await server.get('database/check-integrity');
if (results.length === 1 && results[0].integrity_check === "ok") {
toastService.showMessage("Integrity check succeeded - no problems found.");
}
else {
toastService.showMessage("Integrity check failed: " + JSON.stringify(results, null, 2), 15000);
}
});
2019-08-21 20:24:37 +02:00
}
}