import server from "../../services/server.js"; import toastService from "../../services/toast.js"; const TPL = `
This will check that the database is not corrupted on the SQLite level. It might take some time, depending on the DB size.
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.
This will rebuild the database which will typically result in a smaller database file. No data will be actually changed.
`; export default class AdvancedOptions { constructor() { $("#options-advanced").html(TPL); this.$forceFullSyncButton = $("#force-full-sync-button"); this.$fillEntityChangesButton = $("#fill-entity-changes-button"); this.$anonymizeButton = $("#anonymize-button"); this.$vacuumDatabaseButton = $("#vacuum-database-button"); this.$findAndFixConsistencyIssuesButton = $("#find-and-fix-consistency-issues-button"); this.$checkIntegrityButton = $("#check-integrity-button"); this.$forceFullSyncButton.on('click', async () => { await server.post('sync/force-full-sync'); toastService.showMessage("Full sync triggered"); }); this.$fillEntityChangesButton.on('click', async () => { await server.post('sync/fill-entity-changes'); toastService.showMessage("Sync rows filled successfully"); }); this.$anonymizeButton.on('click', async () => { 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); } }); this.$vacuumDatabaseButton.on('click', async () => { await server.post('database/vacuum-database'); toastService.showMessage("Database has been vacuumed"); }); this.$findAndFixConsistencyIssuesButton.on('click', async () => { await server.post('database/find-and-fix-consistency-issues'); 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); } }); } }