Add typing to TransitView.ts.
This commit is contained in:
parent
8b0512a3ec
commit
d00826fa67
|
@ -15,7 +15,7 @@ import { SetVaultURLPage } from "./pages/SetVaultURL";
|
||||||
import { TOTPViewPage } from "./pages/TOTP/TOTPView";
|
import { TOTPViewPage } from "./pages/TOTP/TOTPView";
|
||||||
import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js";
|
import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js";
|
||||||
import { TransitEncryptPage } from "./pages/Transit/TransitEncrypt.js";
|
import { TransitEncryptPage } from "./pages/Transit/TransitEncrypt.js";
|
||||||
import { TransitViewPage } from "./pages/Transit/TransitView.js";
|
import { TransitViewPage } from "./pages/Transit/TransitView";
|
||||||
import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret.js";
|
import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret.js";
|
||||||
import { UnsealPage } from "./pages/Unseal";
|
import { UnsealPage } from "./pages/Unseal";
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
import { DoesNotExistError } from "../../types/internalErrors";
|
import { DoesNotExistError } from "../../types/internalErrors";
|
||||||
import { Page } from "../../types/Page";
|
import { Page } from "../../types/Page";
|
||||||
import { changePage, setErrorText, setTitleElement } from "../../pageUtils";
|
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||||
import { getTransitKeys } from "../../api/getTransitKeys";
|
import { getTransitKeys } from "../../api/getTransitKeys";
|
||||||
import { makeElement } from "../../htmlUtils";
|
import { makeElement } from "../../htmlUtils";
|
||||||
import { pageState } from "../../globalPageState.ts";
|
import { pageState } from "../../globalPageState";
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
|
|
||||||
export class TransitViewPage extends Page {
|
export class TransitViewPage extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
goBack() {
|
|
||||||
|
goBack(): void {
|
||||||
changePage("HOME");
|
changePage("HOME");
|
||||||
}
|
}
|
||||||
async render() {
|
|
||||||
|
async render(): Promise<void> {
|
||||||
pageState.currentSecret = "";
|
pageState.currentSecret = "";
|
||||||
|
|
||||||
setTitleElement(pageState);
|
setTitleElement(pageState);
|
||||||
|
|
||||||
let newButton = makeElement({
|
const transitViewContent = makeElement({ tag: "div" });
|
||||||
|
setPageContent(transitViewContent);
|
||||||
|
|
||||||
|
const newButton = makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
text: "New",
|
text: "New",
|
||||||
class: ["uk-button", "uk-button-primary", "uk-margin-bottom"],
|
class: ["uk-button", "uk-button-primary", "uk-margin-bottom"],
|
||||||
|
@ -26,12 +31,12 @@ export class TransitViewPage extends Page {
|
||||||
changePage("TRANSIT_NEW_KEY");
|
changePage("TRANSIT_NEW_KEY");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pageContent.appendChild(newButton);
|
transitViewContent.appendChild(newButton);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let res = await getTransitKeys(pageState.currentBaseMount);
|
const res = await getTransitKeys(pageState.currentBaseMount);
|
||||||
|
|
||||||
pageContent.appendChild(makeElement({
|
transitViewContent.appendChild(makeElement({
|
||||||
tag: "ul",
|
tag: "ul",
|
||||||
class: ["uk-nav", "uk-nav-default"],
|
class: ["uk-nav", "uk-nav-default"],
|
||||||
children: [
|
children: [
|
||||||
|
@ -52,7 +57,7 @@ export class TransitViewPage extends Page {
|
||||||
}));
|
}));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e == DoesNotExistError) {
|
if (e == DoesNotExistError) {
|
||||||
pageContent.appendChild(makeElement({
|
transitViewContent.appendChild(makeElement({
|
||||||
tag: "p",
|
tag: "p",
|
||||||
text: i18next.t("transit_view_none_here_text")
|
text: i18next.t("transit_view_none_here_text")
|
||||||
}));
|
}));
|
||||||
|
@ -62,7 +67,7 @@ export class TransitViewPage extends Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name(): string {
|
||||||
return i18next.t("transit_view_title");
|
return i18next.t("transit_view_title");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue