import { formatDateTime } from "../../utils/formatters.js"
import { t } from "../../services/i18n.js";
import BasicWidget from "../basic_widget.js";
import openService from "../../services/open.js";
import server from "../../services/server.js";
import utils from "../../services/utils.js";
const TPL = `
${t("about.homepage")} |
https://github.com/TriliumNext/Notes |
${t("about.app_version")} |
|
${t("about.db_version")} |
|
${t("about.sync_version")} |
|
${t("about.build_date")} |
|
${t("about.build_revision")} |
|
${t("about.data_directory")} |
|
`;
export default class AboutDialog extends BasicWidget {
doRender() {
this.$widget = $(TPL);
this.$appVersion = this.$widget.find(".app-version");
this.$dbVersion = this.$widget.find(".db-version");
this.$syncVersion = this.$widget.find(".sync-version");
this.$buildDate = this.$widget.find(".build-date");
this.$buildRevision = this.$widget.find(".build-revision");
this.$dataDirectory = this.$widget.find(".data-directory");
}
async refresh() {
const appInfo = await server.get('app-info');
this.$appVersion.text(appInfo.appVersion);
this.$dbVersion.text(appInfo.dbVersion);
this.$syncVersion.text(appInfo.syncVersion);
this.$buildDate.text(formatDateTime(appInfo.buildDate));
this.$buildRevision.text(appInfo.buildRevision);
this.$buildRevision.attr('href', `https://github.com/TriliumNext/Notes/commit/${appInfo.buildRevision}`);
if (utils.isElectron()) {
this.$dataDirectory.html($('', {
href: '#',
text: appInfo.dataDirectory,
}));
this.$dataDirectory.find("a").on('click', (event) => {
event.preventDefault();
openService.openDirectory(appInfo.dataDirectory);
})
} else {
this.$dataDirectory.text(appInfo.dataDirectory);
}
}
async openAboutDialogEvent() {
await this.refresh();
utils.openDialog(this.$widget);
}
}