mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
Merge branch 'feature/WW-26-architecture'
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { html, render, TemplateResult } from "@github/jtml";
|
import { html, render, TemplateResult } from "@github/jtml";
|
||||||
import { AppMainElement } from "components/";
|
import { AppMainElement, AppModalElement, AppRootElement } from "components/";
|
||||||
|
import { AppService, RouterService } from "core/services";
|
||||||
|
import { AuthStore } from "core/store";
|
||||||
import { closest } from "core/utils";
|
import { closest } from "core/utils";
|
||||||
|
|
||||||
class BaseElement extends HTMLElement {
|
class BaseElement extends HTMLElement {
|
||||||
@@ -12,7 +14,31 @@ class BaseElement extends HTMLElement {
|
|||||||
this.disconnectedCallback = this.disconnectedCallback.bind(this);
|
this.disconnectedCallback = this.disconnectedCallback.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents = (): void => {
|
public get routerService(): RouterService {
|
||||||
|
return this.appMain?.routerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get authStore(): AuthStore {
|
||||||
|
return this.appMain?.authStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get appService(): AppService {
|
||||||
|
return this.appMain?.appService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get appModal(): AppModalElement {
|
||||||
|
return this.appMain?.appModal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get mainRoot(): AppRootElement {
|
||||||
|
return this.appMain?.mainRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get isAuth(): boolean {
|
||||||
|
return this.appMain?.isAuth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bindEvents = (): void => {
|
||||||
const _elems = this.querySelectorAll("[data-action]");
|
const _elems = this.querySelectorAll("[data-action]");
|
||||||
_elems?.forEach((el) => {
|
_elems?.forEach((el) => {
|
||||||
for (const action of (el.getAttribute("data-action") || "")
|
for (const action of (el.getAttribute("data-action") || "")
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ class AppLinkElement extends BaseComponentElement {
|
|||||||
@attr goBack: string;
|
@attr goBack: string;
|
||||||
@attr title: string;
|
@attr title: string;
|
||||||
@target main: Element;
|
@target main: Element;
|
||||||
routerService: RouterService;
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
elementConnected = (): void => {
|
elementConnected = (): void => {
|
||||||
this.routerService = this.appMain?.routerService;
|
|
||||||
if (!this.title && this.innerText) {
|
if (!this.title && this.innerText) {
|
||||||
const _slottedText = this.innerText;
|
const _slottedText = this.innerText;
|
||||||
this.innerText = null;
|
this.innerText = null;
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
import { controller, target } from "@github/catalyst";
|
import { controller, target } from "@github/catalyst";
|
||||||
import { AppService, HttpClient, RouterService } from "core/services";
|
import { AppService, HttpClient, RouterService } from "core/services";
|
||||||
import { AuthStore } from "core/store";
|
import { AuthStore } from "core/store";
|
||||||
import { BaseComponentElement } from "common/";
|
|
||||||
import { AppModalElement, AppRootElement } from "components/";
|
import { AppModalElement, AppRootElement } from "components/";
|
||||||
|
import { closest } from "core/utils";
|
||||||
|
|
||||||
@controller
|
@controller
|
||||||
class AppMainElement extends BaseComponentElement {
|
class AppMainElement extends HTMLElement {
|
||||||
public routerService: RouterService;
|
public routerService: RouterService;
|
||||||
public authStore: AuthStore;
|
public authStore: AuthStore;
|
||||||
private httpClient: HttpClient;
|
private httpClient: HttpClient;
|
||||||
public appService: AppService;
|
public appService: AppService;
|
||||||
@target appModal: AppModalElement;
|
@target appModal: AppModalElement;
|
||||||
@target mainRoot: AppRootElement;
|
@target mainRoot: AppRootElement;
|
||||||
|
@closest appMain: AppMainElement;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
elementConnected = () => {
|
connectedCallback() {
|
||||||
if (this.appMain !== this) return;
|
if (this.appMain !== this) return;
|
||||||
const mainRoot = this.createMainRoot();
|
const mainRoot = this.createMainRoot();
|
||||||
this.httpClient = new HttpClient();
|
this.httpClient = new HttpClient();
|
||||||
@@ -48,6 +49,11 @@ class AppMainElement extends BaseComponentElement {
|
|||||||
layout: "menu-layout",
|
layout: "menu-layout",
|
||||||
middleware: this.isAuth,
|
middleware: this.isAuth,
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
path: "/all",
|
||||||
|
component: "wallet-list",
|
||||||
|
layout: "menu-layout",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/:walletId",
|
path: "/:walletId",
|
||||||
component: "history-page",
|
component: "history-page",
|
||||||
@@ -86,7 +92,7 @@ class AppMainElement extends BaseComponentElement {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
this.routerService.init();
|
this.routerService.init();
|
||||||
};
|
}
|
||||||
|
|
||||||
middleAuth = () => {
|
middleAuth = () => {
|
||||||
if (!this.isAuth) {
|
if (!this.isAuth) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class InputFieldElement extends BaseComponentElement {
|
|||||||
@target inp: HTMLElement;
|
@target inp: HTMLElement;
|
||||||
error: string;
|
error: string;
|
||||||
randId: string;
|
randId: string;
|
||||||
routerService: RouterService;
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { attr, controller, target } from "@github/catalyst";
|
import { attr, controller, target } from "@github/catalyst";
|
||||||
import { html, TemplateResult } from "@github/jtml";
|
import { html, TemplateResult } from "@github/jtml";
|
||||||
import { AppMainElement } from "components/app-main/AppMainElement";
|
import { AppMainElement } from "components/app-main/AppMainElement";
|
||||||
import { RouterService } from "core/services";
|
|
||||||
import { BaseComponentElement } from "common/";
|
import { BaseComponentElement } from "common/";
|
||||||
|
|
||||||
@controller
|
@controller
|
||||||
@@ -9,13 +8,11 @@ class MenuItemElement extends BaseComponentElement {
|
|||||||
@attr path: string;
|
@attr path: string;
|
||||||
@attr title: string;
|
@attr title: string;
|
||||||
@target itemEl: HTMLElement;
|
@target itemEl: HTMLElement;
|
||||||
routerService: RouterService;
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public elementConnected = (): void => {
|
public elementConnected = (): void => {
|
||||||
this.routerService = this.appMain?.routerService;
|
|
||||||
if (!this.title && this.innerText) {
|
if (!this.title && this.innerText) {
|
||||||
const _slottedText = this.innerText;
|
const _slottedText = this.innerText;
|
||||||
this.innerText = null;
|
this.innerText = null;
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import { BasePageElement } from "common/";
|
|||||||
class LoginPageElement extends BasePageElement {
|
class LoginPageElement extends BasePageElement {
|
||||||
@targets inputs: Array<InputFieldElement>;
|
@targets inputs: Array<InputFieldElement>;
|
||||||
authService: AuthService;
|
authService: AuthService;
|
||||||
routerService: RouterService;
|
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
elementConnected = (): void => {
|
elementConnected = (): void => {
|
||||||
this.authService = new AuthService(this.appMain.appService);
|
this.authService = new AuthService(this.appMain.appService);
|
||||||
this.routerService = this.appMain.routerService;
|
|
||||||
this.update();
|
this.update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user