From 026cacf4fe89fb22304decf7113b8471ee6ab01d Mon Sep 17 00:00:00 2001 From: hardl Date: Fri, 18 Oct 2024 10:15:11 +0200 Subject: [PATCH] move main layout rendering to connector --- .../dev-tools/templates/simple/index.html | 66 +------------------ .../templates/simple/luigi-ui/lui-ui5wc.js | 15 +++++ core-modular/package-lock.json | 45 +++++++++++++ core-modular/package.json | 1 + .../src/services/navigation.service.ts | 1 - core-modular/src/types/connector.ts | 2 + core-modular/src/ui.ts | 1 + 7 files changed, 65 insertions(+), 66 deletions(-) diff --git a/core-modular/dev-tools/templates/simple/index.html b/core-modular/dev-tools/templates/simple/index.html index 20c2a82952..09b2ef3313 100644 --- a/core-modular/dev-tools/templates/simple/index.html +++ b/core-modular/dev-tools/templates/simple/index.html @@ -27,70 +27,6 @@ -
- - - - - - - - -
-
+ diff --git a/core-modular/dev-tools/templates/simple/luigi-ui/lui-ui5wc.js b/core-modular/dev-tools/templates/simple/luigi-ui/lui-ui5wc.js index 5a47ce28f0..981cf8ec76 100644 --- a/core-modular/dev-tools/templates/simple/luigi-ui/lui-ui5wc.js +++ b/core-modular/dev-tools/templates/simple/luigi-ui/lui-ui5wc.js @@ -24,6 +24,21 @@ function readExpandedState(uid) { /** @type {LuigiConnector} */ const connector = { + + renderMainLayout: () => { + if (!document.getElementById('app')) { + const appRoot = document.createElement('div'); + appRoot.id = 'app'; + appRoot.classList.add('tool-layout'); + appRoot.innerHTML = ` + + +
+ `; + document.body.appendChild(appRoot); + } + }, + renderTopNav: topNavData => { const shellbar = document.querySelector('.tool-layout > ui5-shellbar'); shellbar.setAttribute('primary-title', topNavData.appTitle); diff --git a/core-modular/package-lock.json b/core-modular/package-lock.json index 26ea9e139e..17b7576917 100644 --- a/core-modular/package-lock.json +++ b/core-modular/package-lock.json @@ -10,6 +10,7 @@ "@tsconfig/svelte": "^5.0.4", "chai": "^4.3.6", "css-tree": "^2.3.1", + "fs-extra": "^11.2.0", "jest": "^28.1.3", "jest-environment-jsdom": "^28.1.3", "jsdom": "^20.0.0", @@ -3501,6 +3502,29 @@ "integrity": "sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==", "dev": true }, + "node_modules/fs-extra": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/fs-extra/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4964,6 +4988,27 @@ "node": ">=6" } }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jsonfile/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/just-extend": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-6.2.0.tgz", diff --git a/core-modular/package.json b/core-modular/package.json index 6710558fc6..1bba8b3c97 100644 --- a/core-modular/package.json +++ b/core-modular/package.json @@ -7,6 +7,7 @@ "@tsconfig/svelte": "^5.0.4", "chai": "^4.3.6", "css-tree": "^2.3.1", + "fs-extra": "^11.2.0", "jest": "^28.1.3", "jest-environment-jsdom": "^28.1.3", "jsdom": "^20.0.0", diff --git a/core-modular/src/services/navigation.service.ts b/core-modular/src/services/navigation.service.ts index ab51180fb1..2e55267ec9 100644 --- a/core-modular/src/services/navigation.service.ts +++ b/core-modular/src/services/navigation.service.ts @@ -1,4 +1,3 @@ -import { filter, first } from 'rxjs/operators'; import type { Luigi } from '../luigi'; export interface TopNavData { appTitle: string; diff --git a/core-modular/src/types/connector.ts b/core-modular/src/types/connector.ts index 12fa598079..c3ba036271 100644 --- a/core-modular/src/types/connector.ts +++ b/core-modular/src/types/connector.ts @@ -1,6 +1,8 @@ import type { LeftNavData, Node, TopNavData } from "../services/navigation.service"; export interface LuigiConnector { + renderMainLayout(): void; + renderTopNav(data: TopNavData): void; renderLeftNav(data: LeftNavData): void; diff --git a/core-modular/src/ui.ts b/core-modular/src/ui.ts index f3b849184b..dcd8519911 100644 --- a/core-modular/src/ui.ts +++ b/core-modular/src/ui.ts @@ -10,6 +10,7 @@ export const UI = { navService : undefined, init: (luigi: Luigi) => { console.log('Init UI...'); + luigi._connector?.renderMainLayout(); const navService = new NavigationService(luigi); const path = Helpers.normalizePath(location.hash); const redirect = navService.shouldRedirect(path);