1
0
Fork 0
VaultUI/src/pages/Me.js

77 lines
1.9 KiB
JavaScript
Raw Normal View History

import { Page } from "../types/Page.js";
import { addClipboardNotifications, setErrorText, setPageContent, changePage } from "../pageUtils.js";
import { makeElement } from "../htmlUtils.js";
import { getToken } from "../utils.js";
import { renewSelf } from "../api.js";
import ClipboardJS from "clipboard";
2021-04-18 11:52:24 +01:00
import i18next from 'i18next';
export class MePage extends Page {
constructor() {
super();
}
2021-04-18 11:52:24 +01:00
async render() {
setPageContent(makeElement({
tag: "ul",
class: "uk-nav",
children: [
makeElement({
tag: "li",
children: makeElement({
tag: "a",
2021-04-18 11:52:24 +01:00
text: i18next.t("log_out_btn"),
onclick: () => {
localStorage.removeItem("token");
changePage("HOME");
}
})
}),
makeElement({
tag: "li",
children: makeElement({
tag: "a",
2021-04-18 11:52:24 +01:00
text: i18next.t("copy_token_btn"),
attributes: {
"data-clipboard-text": getToken(),
},
thenRun: (e) => {
let clipboard = new ClipboardJS(e);
addClipboardNotifications(clipboard);
}
})
}),
makeElement({
tag: "li",
children: makeElement({
tag: "a",
2021-04-18 11:52:24 +01:00
text: i18next.t("renew_lease_btn"),
onclick: () => {
renewSelf().then(() => {
changePage("HOME");
}).catch(e => {
setErrorText(e.message);
});
}
})
2021-04-19 20:17:07 +01:00
}),
makeElement({
tag: "li",
children: makeElement({
tag: "a",
text: i18next.t("change_language_btn"),
onclick: () => {
changePage("SET_LANGUAGE");
}
})
}),
]
}));
}
get name() {
2021-04-18 11:52:24 +01:00
return i18next.t("me_page_title");
}
}