mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 13:02:00 +08:00
chore(client/ts): port options/advanced
This commit is contained in:
parent
fcb7d9754f
commit
5bfcf88acd
@ -2,6 +2,7 @@ import OptionsWidget from "../options_widget.js";
|
||||
import toastService from "../../../../services/toast.js";
|
||||
import server from "../../../../services/server.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
@ -33,7 +34,22 @@ const TPL = `
|
||||
<ul class="existing-anonymized-databases"></ul>
|
||||
</div>`;
|
||||
|
||||
// TODO: Deduplicate with server
|
||||
interface AnonymizeResponse {
|
||||
success: boolean;
|
||||
anonymizedFilePath: string;
|
||||
}
|
||||
|
||||
interface AnonymizedDbResponse {
|
||||
filePath: string;
|
||||
}
|
||||
|
||||
export default class DatabaseAnonymizationOptions extends OptionsWidget {
|
||||
|
||||
private $anonymizeFullButton!: JQuery<HTMLElement>;
|
||||
private $anonymizeLightButton!: JQuery<HTMLElement>;
|
||||
private $existingAnonymizedDatabases!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$anonymizeFullButton = this.$widget.find(".anonymize-full-button");
|
||||
@ -41,7 +57,7 @@ export default class DatabaseAnonymizationOptions extends OptionsWidget {
|
||||
this.$anonymizeFullButton.on("click", async () => {
|
||||
toastService.showMessage(t("database_anonymization.creating_fully_anonymized_database"));
|
||||
|
||||
const resp = await server.post("database/anonymize/full");
|
||||
const resp = await server.post<AnonymizeResponse>("database/anonymize/full");
|
||||
|
||||
if (!resp.success) {
|
||||
toastService.showError(t("database_anonymization.error_creating_anonymized_database"));
|
||||
@ -55,7 +71,7 @@ export default class DatabaseAnonymizationOptions extends OptionsWidget {
|
||||
this.$anonymizeLightButton.on("click", async () => {
|
||||
toastService.showMessage(t("database_anonymization.creating_lightly_anonymized_database"));
|
||||
|
||||
const resp = await server.post("database/anonymize/light");
|
||||
const resp = await server.post<AnonymizeResponse>("database/anonymize/light");
|
||||
|
||||
if (!resp.success) {
|
||||
toastService.showError(t("database_anonymization.error_creating_anonymized_database"));
|
||||
@ -69,8 +85,8 @@ export default class DatabaseAnonymizationOptions extends OptionsWidget {
|
||||
this.$existingAnonymizedDatabases = this.$widget.find(".existing-anonymized-databases");
|
||||
}
|
||||
|
||||
optionsLoaded(options) {
|
||||
server.get("database/anonymized-databases").then((anonymizedDatabases) => {
|
||||
optionsLoaded(options: OptionMap) {
|
||||
server.get<AnonymizedDbResponse[]>("database/anonymized-databases").then((anonymizedDatabases) => {
|
||||
this.$existingAnonymizedDatabases.empty();
|
||||
|
||||
if (!anonymizedDatabases.length) {
|
@ -14,14 +14,25 @@ const TPL = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
// TODO: Deduplicate with server
|
||||
interface Response {
|
||||
results: {
|
||||
integrity_check: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export default class DatabaseIntegrityCheckOptions extends OptionsWidget {
|
||||
|
||||
private $checkIntegrityButton!: JQuery<HTMLElement>;
|
||||
private $findAndFixConsistencyIssuesButton!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$checkIntegrityButton = this.$widget.find(".check-integrity-button");
|
||||
this.$checkIntegrityButton.on("click", async () => {
|
||||
toastService.showMessage(t("database_integrity_check.checking_integrity"));
|
||||
|
||||
const { results } = await server.get("database/check-integrity");
|
||||
const { results } = await server.get<Response>("database/check-integrity");
|
||||
|
||||
if (results.length === 1 && results[0].integrity_check === "ok") {
|
||||
toastService.showMessage(t("database_integrity_check.integrity_check_succeeded"));
|
@ -2,6 +2,7 @@ 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 type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
@ -12,6 +13,10 @@ const TPL = `
|
||||
</div>`;
|
||||
|
||||
export default class AdvancedSyncOptions extends OptionsWidget {
|
||||
|
||||
private $forceFullSyncButton!: JQuery<HTMLElement>;
|
||||
private $fillEntityChangesButton!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$forceFullSyncButton = this.$widget.find(".force-full-sync-button");
|
||||
@ -31,5 +36,5 @@ export default class AdvancedSyncOptions extends OptionsWidget {
|
||||
});
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {}
|
||||
async optionsLoaded(options: OptionMap) {}
|
||||
}
|
@ -13,6 +13,8 @@ const TPL = `
|
||||
</div>`;
|
||||
|
||||
export default class VacuumDatabaseOptions extends OptionsWidget {
|
||||
private $vacuumDatabaseButton!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$vacuumDatabaseButton = this.$widget.find(".vacuum-database-button");
|
Loading…
x
Reference in New Issue
Block a user