fixed types

This commit is contained in:
Fran Jurmanović
2021-06-02 23:29:05 +02:00
parent c840041b51
commit 8754b4391b
26 changed files with 185 additions and 175 deletions

View File

@@ -1,6 +1,5 @@
import { attr, targets, controller, target } from "@github/catalyst";
import { closest, index, update, isTrue } from "core/utils";
import { html, render, until } from "@github/jtml";
import { controller, target } from "@github/catalyst";
import { html, TemplateResult } from "@github/jtml";
import { TransactionsService } from "services/";
import { AppMainElement, AppPaginationElement } from "components/";
import { BasePageElement } from "common/";
@@ -13,20 +12,20 @@ class HistoryPageElement extends BasePageElement {
super();
}
elementConnected = () => {
elementConnected = (): void => {
this.transactionsService = new TransactionsService(
this.appMain?.appService
);
this.update();
this.pagination?.setFetchFunc?.(this.getTransactions, true)!;
window.addEventListener("tokenchange", this.update);
this.appMain.addEventListener("tokenchange", this.update);
};
elementDisconnected = () => {
window.removeEventListener("tokenchange", this.update);
elementDisconnected = (appMain: AppMainElement): void => {
appMain?.removeEventListener("tokenchange", this.update);
};
getTransactions = async (options) => {
getTransactions = async (options): Promise<any> => {
try {
const response = await this.transactionsService.getAll(options);
return response;
@@ -35,7 +34,7 @@ class HistoryPageElement extends BasePageElement {
}
};
render = () => {
render = (): TemplateResult => {
return html`
<app-pagination
data-target="history-page.pagination"
@@ -43,3 +42,5 @@ class HistoryPageElement extends BasePageElement {
`;
};
}
export type { HistoryPageElement };

View File

@@ -1,6 +1,5 @@
import { attr, targets, controller, target } from "@github/catalyst";
import { closest, index, update, isTrue } from "core/utils";
import { html, render, until } from "@github/jtml";
import { controller } from "@github/catalyst";
import { html, TemplateResult, until } from "@github/jtml";
import { PingService } from "services/";
import { AppMainElement } from "components/";
import { BasePageElement } from "common/";
@@ -12,17 +11,17 @@ class HomePageElement extends BasePageElement {
super();
}
elementConnected = () => {
elementConnected = (): void => {
this.pingService = new PingService(this.appMain?.appService);
this.update();
window.addEventListener("tokenchange", this.update);
this.appMain.addEventListener("tokenchange", this.update);
};
elementDisconnected = (): void => {
window.removeEventListener("tokenchange", this.update);
elementDisconnected = (appMain: AppMainElement): void => {
appMain?.removeEventListener("tokenchange", this.update);
};
getPong = async () => {
getPong = async (): Promise<void> => {
try {
const response = await this.pingService.getAll();
} catch (err) {
@@ -30,11 +29,11 @@ class HomePageElement extends BasePageElement {
}
};
pongEl = () => {
pongEl = (): TemplateResult => {
return html`<div>${until(this.getPong())}</div>`;
};
openModal = () => {
openModal = (): void => {
const _modal = this.appMain.appModal;
if (_modal) {
this.appMain.closeModal();
@@ -43,9 +42,11 @@ class HomePageElement extends BasePageElement {
}
};
render = () => {
render = (): TemplateResult => {
return html`
<button data-action="click:home-page#openModal">Test</button>
`;
};
}
export { HomePageElement };

View File

@@ -1,14 +1,7 @@
import {
attr,
targets,
controller,
target,
listenForBind,
} from "@github/catalyst";
import { closest, index, update, isTrue } from "core/utils";
import { html, render, until } from "@github/jtml";
import { AuthService, PingService } from "services/";
import { AppMainElement, InputFieldElement } from "components/";
import { targets, controller } from "@github/catalyst";
import { html, TemplateResult } from "@github/jtml";
import { AuthService } from "services/";
import { InputFieldElement } from "components/";
import { RouterService } from "core/services";
import { BasePageElement } from "common/";
@@ -21,13 +14,13 @@ class LoginPageElement extends BasePageElement {
constructor() {
super();
}
elementConnected = () => {
elementConnected = (): void => {
this.authService = new AuthService(this.appMain.appService);
this.routerService = this.appMain.routerService;
this.update();
};
get emailInput() {
get emailInput(): InputFieldElement {
for (const i in this.inputs) {
if (this.inputs[i]?.name == "email") {
return this.inputs[i];
@@ -35,7 +28,7 @@ class LoginPageElement extends BasePageElement {
}
}
get passwordInput() {
get passwordInput(): InputFieldElement {
for (const i in this.inputs) {
if (this.inputs[i]?.name == "password") {
return this.inputs[i];
@@ -44,7 +37,7 @@ class LoginPageElement extends BasePageElement {
}
get values(): Object {
const formObject = {};
const formObject: any = {};
this.inputs.forEach((input: InputFieldElement) => {
const inputType = input.inp;
formObject[input.name] = (inputType as HTMLInputElement).value;
@@ -52,9 +45,8 @@ class LoginPageElement extends BasePageElement {
return formObject;
}
onSubmit = async () => {
onSubmit = async (): Promise<void> => {
try {
console.log("test");
if (!this.validate()) {
return;
}
@@ -63,7 +55,6 @@ class LoginPageElement extends BasePageElement {
);
if (response?.token) {
console.log(this.appMain);
this.routerService.goTo("/");
}
} catch (err) {
@@ -89,7 +80,7 @@ class LoginPageElement extends BasePageElement {
return _return;
}
render = () => {
render = (): TemplateResult => {
return html`
<form>
<input-field
@@ -121,3 +112,5 @@ class LoginPageElement extends BasePageElement {
`;
};
}
export type { LoginPageElement };

View File

@@ -1,7 +1,5 @@
import { controller } from "@github/catalyst";
import { closest, update } from "core/utils";
import { AuthService } from "services/";
import { AppMainElement } from "components/";
import { BasePageElement } from "common/";
@controller
@@ -10,9 +8,11 @@ class LogoutPageElement extends BasePageElement {
constructor() {
super();
}
elementConnected = () => {
elementConnected = (): void => {
this.authService = new AuthService(this.appMain.appService);
this.appMain?.authStore?.userLogout();
this.appMain?.routerService.goTo("/login");
};
}
export type { LogoutPageElement };

View File

@@ -1,7 +1,5 @@
import { controller } from "@github/catalyst";
import { closest, update } from "core/utils";
import { html, render } from "@github/jtml";
import { AppMainElement } from "components/";
import { html, TemplateResult } from "@github/jtml";
import { BasePageElement } from "common/";
@controller
@@ -9,14 +7,16 @@ class NotFoundElement extends BasePageElement {
constructor() {
super();
}
elementConnected = () => {
elementConnected = (): void => {
this.update();
};
render = () => {
render = (): TemplateResult => {
return html`
<div>404 - Page not found</div>
<div><app-link data-to="/" data-title="Homepage"></app-link></div>
`;
};
}
export type { NotFoundElement };

View File

@@ -1,8 +1,7 @@
import { attr, targets, controller, target } from "@github/catalyst";
import { closest, index, update, isTrue } from "core/utils";
import { html, render, until } from "@github/jtml";
import { AuthService, PingService } from "services/";
import { AppMainElement, InputFieldElement } from "components/";
import { targets, controller } from "@github/catalyst";
import { html, TemplateResult } from "@github/jtml";
import { AuthService } from "services/";
import { InputFieldElement } from "components/";
import { BasePageElement } from "common/";
@controller
@@ -12,7 +11,7 @@ class RegisterPageElement extends BasePageElement {
constructor() {
super();
}
elementConnected = () => {
elementConnected = (): void => {
this.authService = new AuthService(this.appMain.appService);
this.update();
};
@@ -26,7 +25,7 @@ class RegisterPageElement extends BasePageElement {
return formObject;
}
onSubmit = async () => {
onSubmit = async (): Promise<void> => {
try {
if (!this.validate()) {
return;
@@ -50,7 +49,7 @@ class RegisterPageElement extends BasePageElement {
return _return;
}
render = () => {
render = (): TemplateResult => {
return html`
<form>
<input-field
@@ -85,3 +84,5 @@ class RegisterPageElement extends BasePageElement {
`;
};
}
export type { RegisterPageElement };