88 lines
2.9 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/>
2019-11-20 21:35:18 +01:00
<button id="fill-sync-rows-button" class="btn">Fill sync rows</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/>
<h4>Debugging</h4>
2019-11-20 21:35:18 +01:00
<button id="anonymize-button" class="btn">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>Backup database</h4>
<button id="backup-database-button" class="btn">Backup database</button>
<br/>
<br/>
<h4>Vacuum database</h4>
<p>This will rebuild database which will typically result in 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.$fillSyncRowsButton = $("#fill-sync-rows-button");
this.$anonymizeButton = $("#anonymize-button");
this.$backupDatabaseButton = $("#backup-database-button");
2019-08-21 20:24:37 +02:00
this.$vacuumDatabaseButton = $("#vacuum-database-button");
2019-12-10 22:03:00 +01:00
this.$findAndFixConsistencyIssuesButton = $("#find-and-fix-consistency-issues-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
});
2019-11-09 17:39:48 +01:00
this.$fillSyncRowsButton.on('click', async () => {
2019-08-21 20:24:37 +02:00
await server.post('sync/fill-sync-rows');
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 () => {
2019-08-21 20:24:37 +02:00
await server.post('anonymization/anonymize');
2019-10-20 10:00:18 +02:00
toastService.showMessage("Created anonymized database");
2019-08-21 20:24:37 +02:00
});
this.$backupDatabaseButton.on('click', async () => {
const {backupFile} = await server.post('database/backup-database');
toastService.showMessage("Database has been backed up to " + backupFile, 10000);
});
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.");
});
2019-08-21 20:24:37 +02:00
}
}