@progressive-development/pd-spa-helper 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/src/InitApplicationData.d.ts +3 -0
  2. package/dist/src/InitApplicationData.js +8 -0
  3. package/dist/src/InitApplicationData.js.map +1 -0
  4. package/dist/src/PdSpaHelper.d.ts +111 -6
  5. package/dist/src/PdSpaHelper.js +410 -12
  6. package/dist/src/PdSpaHelper.js.map +1 -1
  7. package/dist/src/defaultpage/default-login.d.ts +5 -0
  8. package/dist/src/defaultpage/default-login.js +16 -0
  9. package/dist/src/defaultpage/default-login.js.map +1 -0
  10. package/dist/src/firebase/auth.d.ts +4 -0
  11. package/dist/src/firebase/auth.js +28 -0
  12. package/dist/src/firebase/auth.js.map +1 -0
  13. package/dist/src/firebase/firestore-client.d.ts +9 -0
  14. package/dist/src/firebase/firestore-client.js +19 -0
  15. package/dist/src/firebase/firestore-client.js.map +1 -0
  16. package/dist/src/firebase/functions-client.d.ts +31 -0
  17. package/dist/src/firebase/functions-client.js +70 -0
  18. package/dist/src/firebase/functions-client.js.map +1 -0
  19. package/dist/src/index.d.ts +1 -1
  20. package/dist/src/index.js +1 -1
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/pd-spa-helper.d.ts +0 -1
  23. package/dist/src/pd-spa-helper.js +4 -2
  24. package/dist/src/pd-spa-helper.js.map +1 -1
  25. package/dist/src/router/AppMain.d.ts +6 -0
  26. package/dist/src/router/AppMain.js +14 -0
  27. package/dist/src/router/AppMain.js.map +1 -0
  28. package/dist/src/service-call-controller2.d.ts +16 -0
  29. package/dist/src/service-call-controller2.js +43 -0
  30. package/dist/src/service-call-controller2.js.map +1 -0
  31. package/dist/src/tmpown/pd-login.d.ts +14 -0
  32. package/dist/src/tmpown/pd-login.js +118 -0
  33. package/dist/src/tmpown/pd-login.js.map +1 -0
  34. package/dist/src/tmpown/pd-panel-viewer.d.ts +18 -0
  35. package/dist/src/tmpown/pd-panel-viewer.js +187 -0
  36. package/dist/src/tmpown/pd-panel-viewer.js.map +1 -0
  37. package/dist/src/tmpown/pd-panel.d.ts +5 -0
  38. package/dist/src/tmpown/pd-panel.js +41 -0
  39. package/dist/src/tmpown/pd-panel.js.map +1 -0
  40. package/dist/src/tmpown/pd-toast.d.ts +12 -0
  41. package/dist/src/tmpown/pd-toast.js +114 -0
  42. package/dist/src/tmpown/pd-toast.js.map +1 -0
  43. package/dist/test/pd-spa-helper.test.js +2 -2
  44. package/dist/test/pd-spa-helper.test.js.map +1 -1
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +7 -1
  47. package/pd-spa-helper.iml +9 -0
  48. package/src/InitApplicationData.ts +9 -0
  49. package/src/PdSpaHelper.ts +490 -16
  50. package/src/defaultpage/default-login.ts +15 -0
  51. package/src/firebase/auth.ts +30 -0
  52. package/src/firebase/firestore-client.ts +21 -0
  53. package/src/firebase/functions-client.ts +103 -0
  54. package/src/index.ts +1 -1
  55. package/src/pd-spa-helper.ts +3 -3
  56. package/src/router/AppMain.ts +10 -0
  57. package/src/service-call-controller2.ts +67 -0
  58. package/src/tmpown/pd-login.ts +126 -0
  59. package/src/tmpown/pd-panel-viewer.ts +193 -0
  60. package/src/tmpown/pd-panel.ts +43 -0
  61. package/src/tmpown/pd-toast.ts +114 -0
  62. package/test/pd-spa-helper.test.ts +2 -2
@@ -0,0 +1,3 @@
1
+ import { FirebaseApp } from "firebase/app";
2
+ import { FunctionsConfig } from "./firebase/functions-client.js";
3
+ export declare const initApplicationServices: (firebaseApp: FirebaseApp, functionsConfig: FunctionsConfig) => void;
@@ -0,0 +1,8 @@
1
+ import { initFirestore } from "./firebase/firestore-client.js";
2
+ import { initFunctions } from "./firebase/functions-client.js";
3
+ export const initApplicationServices = (firebaseApp, functionsConfig) => {
4
+ // do something with the app, init db, firestore and functions
5
+ initFunctions(firebaseApp, functionsConfig);
6
+ initFirestore(firebaseApp);
7
+ };
8
+ //# sourceMappingURL=InitApplicationData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitApplicationData.js","sourceRoot":"","sources":["../../src/InitApplicationData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAmB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEhF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,WAAwB,EAAE,eAAgC,EAAE,EAAE;IAClG,kEAAkE;IAClE,aAAa,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAA","sourcesContent":["import { FirebaseApp } from \"firebase/app\";\nimport { initFirestore } from \"./firebase/firestore-client.js\";\nimport { FunctionsConfig, initFunctions } from \"./firebase/functions-client.js\";\n\nexport const initApplicationServices = (firebaseApp: FirebaseApp, functionsConfig: FunctionsConfig) => {\n // do something with the app, init db, firestore and functions \n initFunctions(firebaseApp, functionsConfig);\n initFirestore(firebaseApp);\n}\n"]}
@@ -1,10 +1,115 @@
1
- import { LitElement } from 'lit';
1
+ import { FirebaseOptions } from 'firebase/app';
2
+ import { User } from 'firebase/auth';
3
+ import { LitElement, CSSResultGroup, TemplateResult } from 'lit';
4
+ import { ServiceCallController } from './service-call-controller2.js';
5
+ import { FunctionResult, FunctionsConfig } from './firebase/functions-client.js';
6
+ import '@progressive-development/pd-page/pd-menu.js';
7
+ import '@progressive-development/pd-page/pd-footer.js';
8
+ import './router/AppMain.js';
9
+ import './defaultpage/default-login.js';
10
+ import './tmpown/pd-panel-viewer.js';
11
+ import './tmpown/pd-panel.js';
12
+ import './tmpown/pd-toast.js';
13
+ /**
14
+ * Data models.
15
+ */
16
+ export interface MenuElement {
17
+ key: string;
18
+ name: string;
19
+ sec?: string;
20
+ route?: string;
21
+ action?: Function;
22
+ topItem?: boolean;
23
+ ref?: any;
24
+ icon?: string;
25
+ }
26
+ export interface NavigationPage {
27
+ name: string;
28
+ pattern: Array<string>;
29
+ auth: boolean;
30
+ menu?: Array<MenuElement>;
31
+ withTeaser?: boolean;
32
+ withFooter?: boolean;
33
+ }
34
+ export interface NavigationConfig {
35
+ pages: Array<NavigationPage>;
36
+ includeLogin: boolean;
37
+ }
38
+ /**
39
+ * Init the firebase app and application services like
40
+ * functions and firestore. Generate routes from navigationConfig.
41
+ *
42
+ * @param firebaseConfig
43
+ * @param functionsConfig
44
+ * @param navigationConfig
45
+ */
46
+ export declare const startInit: (firebaseConfig: FirebaseOptions, functionsConfig: FunctionsConfig, navigationConfigParam: NavigationConfig) => void;
2
47
  declare const PdSpaHelper_base: import("lit-element-router").Constructor<import("lit-element-router").Router> & import("lit-element-router").Constructor<import("lit-element-router").Navigator> & typeof LitElement;
3
- export declare class PdSpaHelper extends PdSpaHelper_base {
4
- static styles: import("lit").CSSResult;
48
+ /**
49
+ * Abstract class for SPAs. Extend within the app main class.
50
+ */
51
+ export declare abstract class PdSpaHelper extends PdSpaHelper_base {
52
+ protected functionsController: ServiceCallController;
5
53
  title: string;
6
- counter: number;
7
- __increment(): void;
8
- render(): import("lit-html").TemplateResult<1>;
54
+ /**
55
+ * Properties needed for login/profile data.
56
+ */
57
+ _user: User | undefined;
58
+ _profile: any | undefined;
59
+ /**
60
+ * Properties needed for the router.
61
+ */
62
+ route: string;
63
+ params: {};
64
+ query: {};
65
+ /**
66
+ * Indicates if the teaser should closed (depends on scroll position).
67
+ */
68
+ _teaserClosed: boolean;
69
+ static styles: CSSResultGroup;
70
+ constructor();
71
+ /**
72
+ * Non reactive private property for the index db class.
73
+ */
74
+ /**
75
+ * Needed for the router.
76
+ * Return all configured routes.
77
+ */
78
+ static get routes(): any[];
79
+ /**
80
+ * Needed for the router.
81
+ * Set route params to internal members.
82
+ */
83
+ router(route: string, params: Object, query: Object): void;
84
+ /**
85
+ * Call to activate onAuthState change with profile request callbacks.
86
+ */
87
+ activateLoginHandler(): void;
88
+ render(): TemplateResult<1>;
89
+ _renderMenu(pageConfig: NavigationPage, hideTeaser: boolean): "" | TemplateResult<1>;
90
+ _renderTeaser(): TemplateResult | string;
91
+ _renderFooter(): TemplateResult<1>;
92
+ /**
93
+ * Called when (any) cloud function call was finished.
94
+ */
95
+ _renderSuccessResultInfo(result: FunctionResult): TemplateResult<1>;
96
+ /**
97
+ * Called when (any) cloud function is currently running.
98
+ */
99
+ _renderPendingInfo(): TemplateResult<1>;
100
+ /**
101
+ * Called when (any) cloud function stopped with errors.
102
+ */
103
+ _renderErrorInfo(error: any): TemplateResult<1>;
104
+ protected abstract _getTeaserContent(): Array<TemplateResult>;
105
+ protected abstract _getFooterItems(): Array<any>;
106
+ protected abstract _getAppLogo(): TemplateResult;
107
+ protected abstract _renderRoutePages(): any;
108
+ _handleMenuRouteEvent(e: any): void;
109
+ _handleFooterRouteEvent(e: CustomEvent): void;
110
+ _initMenuSections(e: any): void;
111
+ _createTemporaryToast(e: any): void;
112
+ static _scrollToTop(): void;
113
+ _scrollToContent(el: HTMLElement): void;
9
114
  }
10
115
  export {};
@@ -1,34 +1,432 @@
1
1
  import { __decorate } from "tslib";
2
+ import { initializeApp } from 'firebase/app';
3
+ import { getAuth, onAuthStateChanged } from 'firebase/auth';
4
+ // TODO: Add SDKs for Firebase products that you want to use
5
+ // https://firebase.google.com/docs/web/setup#available-libraries
2
6
  import { router, navigator } from 'lit-element-router';
3
- import { html, css, LitElement } from 'lit';
7
+ import { html, LitElement, css } from 'lit';
4
8
  import { property } from 'lit/decorators.js';
9
+ import { initApplicationServices } from './InitApplicationData.js';
10
+ import { isAuthenticated } from './firebase/auth.js';
11
+ import { ServiceCallController } from './service-call-controller2.js';
12
+ import { callFunction } from './firebase/functions-client.js';
13
+ import '@progressive-development/pd-page/pd-menu.js';
14
+ import '@progressive-development/pd-page/pd-footer.js';
15
+ import './router/AppMain.js';
16
+ import './defaultpage/default-login.js';
17
+ import './tmpown/pd-panel-viewer.js';
18
+ import './tmpown/pd-panel.js';
19
+ // TODO: How to solve this import problem?
20
+ // eslint-disable-next-line import/no-duplicates
21
+ import './tmpown/pd-toast.js';
22
+ // eslint-disable-next-line import/no-duplicates
23
+ import { PdToast } from './tmpown/pd-toast.js';
24
+ // Footer Text
25
+ const MADE_BY = {
26
+ txt: "made by PD Progressive Development",
27
+ email: "info@progressive-development.com"
28
+ };
29
+ // Visible time for time-limited toast
30
+ const TOAST_DURATION = 6000;
31
+ /**
32
+ * Transformed routes, generated during startInit.
33
+ */
34
+ let transformedRoutes;
35
+ let navigationConfig;
36
+ let postLoginFunc;
37
+ /**
38
+ * Internal helper functions to generate route elemets for lit-router.
39
+ */
40
+ const transformRoutes = () => {
41
+ const transformAuthConfig = (withAuth) => withAuth ?
42
+ {
43
+ unauthenticated: {
44
+ name: 'login',
45
+ },
46
+ authenticate: () => isAuthenticated(),
47
+ } : undefined;
48
+ let generatedRoutes = [];
49
+ navigationConfig.pages.forEach(cfEntry => {
50
+ const addAraay = cfEntry.pattern.map(routeMapPattern => ({
51
+ name: cfEntry.name,
52
+ pattern: routeMapPattern,
53
+ authentication: transformAuthConfig(cfEntry.auth),
54
+ }));
55
+ generatedRoutes = generatedRoutes.concat(addAraay);
56
+ });
57
+ // add not-found route
58
+ generatedRoutes.push({
59
+ name: 'not-found',
60
+ pattern: '*',
61
+ });
62
+ return generatedRoutes;
63
+ };
64
+ /**
65
+ * Init the firebase app and application services like
66
+ * functions and firestore. Generate routes from navigationConfig.
67
+ *
68
+ * @param firebaseConfig
69
+ * @param functionsConfig
70
+ * @param navigationConfig
71
+ */
72
+ export const startInit = (firebaseConfig, functionsConfig, navigationConfigParam) => {
73
+ // init firebase app
74
+ const app = initializeApp(firebaseConfig);
75
+ // init application services (functions, store)
76
+ initApplicationServices(app, functionsConfig);
77
+ postLoginFunc = functionsConfig.postLoginFunc;
78
+ if (navigationConfigParam.includeLogin) {
79
+ navigationConfigParam.pages.push({
80
+ name: "login",
81
+ menu: [
82
+ { key: "login", name: "Login" }
83
+ ],
84
+ pattern: ["login"],
85
+ auth: false
86
+ });
87
+ }
88
+ // generate routes from navigation config
89
+ navigationConfig = navigationConfigParam;
90
+ transformedRoutes = transformRoutes();
91
+ };
92
+ /**
93
+ * Abstract class for SPAs. Extend within the app main class.
94
+ */
5
95
  export class PdSpaHelper extends router(navigator(LitElement)) {
6
96
  constructor() {
7
- super(...arguments);
97
+ super();
98
+ this.functionsController = new ServiceCallController(this);
99
+ // not used at the moment
8
100
  this.title = 'Hey there';
9
- this.counter = 5;
101
+ /**
102
+ * Properties needed for the router.
103
+ */
104
+ this.route = "";
105
+ this.params = {};
106
+ this.query = {};
107
+ /**
108
+ * Indicates if the teaser should closed (depends on scroll position).
109
+ */
110
+ this._teaserClosed = false;
111
+ const doSomething = (scrollPos) => {
112
+ if (scrollPos <= 50) {
113
+ this._teaserClosed = false;
114
+ }
115
+ else {
116
+ this._teaserClosed = true;
117
+ }
118
+ };
119
+ let ticking = false;
120
+ document.addEventListener('scroll', () => {
121
+ const lastKnownScrollPosition = window.scrollY;
122
+ if (!ticking) {
123
+ window.requestAnimationFrame(() => {
124
+ doSomething(lastKnownScrollPosition);
125
+ ticking = false;
126
+ });
127
+ ticking = true;
128
+ }
129
+ });
130
+ this.activateLoginHandler();
131
+ // For common toast messages (not for callfunction toasts => handelt by own controller)
132
+ this.addEventListener("toast-event", this._createTemporaryToast);
133
+ this.addEventListener("route-event", this._handleMenuRouteEvent);
134
+ }
135
+ /**
136
+ * Non reactive private property for the index db class.
137
+ */
138
+ // private _indexDBClient?: YoIndexDBClient|null;
139
+ /**
140
+ * Needed for the router.
141
+ * Return all configured routes.
142
+ */
143
+ static get routes() {
144
+ return transformedRoutes;
145
+ }
146
+ /**
147
+ * Needed for the router.
148
+ * Set route params to internal members.
149
+ */
150
+ router(route, params, query) {
151
+ this.route = route;
152
+ this.params = params;
153
+ this.query = query;
10
154
  }
11
- __increment() {
12
- this.counter += 1;
155
+ /**
156
+ * Call to activate onAuthState change with profile request callbacks.
157
+ */
158
+ activateLoginHandler() {
159
+ // activate firebase auth handler
160
+ const auth = getAuth();
161
+ onAuthStateChanged(auth, user => {
162
+ if (user) {
163
+ this._user = user;
164
+ if (postLoginFunc) {
165
+ callFunction(postLoginFunc, undefined)
166
+ .then((result) => {
167
+ this._profile = result.resultData;
168
+ // redirect if login in the meantime is available
169
+ // => else stay on the login page after reload/url navigation
170
+ if (this.route === "login") {
171
+ this.navigate("profile");
172
+ }
173
+ });
174
+ }
175
+ }
176
+ else {
177
+ this._user = undefined;
178
+ this._profile = undefined;
179
+ }
180
+ });
13
181
  }
14
182
  render() {
183
+ const pageConf = navigationConfig.pages.filter(p => p.name === this.route)[0];
184
+ const hideTeaser = this._teaserClosed || !(pageConf === null || pageConf === void 0 ? void 0 : pageConf.withTeaser);
185
+ return html `
186
+ <header id="headerElementId" class="default-header">
187
+ ${hideTeaser ? '' : this._renderTeaser()}
188
+ ${this._renderMenu(pageConf, hideTeaser)}
189
+ </header>
190
+
191
+ <main class="${hideTeaser ? "default-main" : "default-main-withteaser"}">
192
+ <app-main active-route=${this.route}
193
+ @init-menu-sections="${this._initMenuSections}">
194
+ ${this._renderRoutePages()}
195
+ ${navigationConfig.includeLogin ? html `
196
+ <default-login route="login"></default-login>` : ''}
197
+ </app-main>
198
+ </main>
199
+
200
+ ${this.functionsController.render({
201
+ complete: (result) => this._renderSuccessResultInfo(result),
202
+ initial: () => '',
203
+ pending: () => this._renderPendingInfo(),
204
+ error: (e) => this._renderErrorInfo(e),
205
+ })}
206
+
207
+ ${(pageConf === null || pageConf === void 0 ? void 0 : pageConf.withFooter) ? html `
208
+ <footer class="default-footer">
209
+ ${this._renderFooter()}
210
+ </footer>` : ''}
211
+ `;
212
+ }
213
+ _renderMenu(pageConfig, hideTeaser) {
214
+ const menuForPage = pageConfig ? (pageConfig.menu || []) : [];
215
+ return menuForPage ? html `
216
+ <pd-menu
217
+ class="${hideTeaser ? "default-menu" : "default-menu-withteaser"}"
218
+ .menuItems=${menuForPage.filter(mfp => !mfp.topItem)}
219
+ .topMenuItems=${menuForPage.filter(mfp => mfp.topItem)}
220
+ headerSize="${hideTeaser ? 80 : 440}"
221
+ >
222
+ ${hideTeaser ? this._getAppLogo() : ''}
223
+ </pd-menu>
224
+ ` : '';
225
+ }
226
+ // eslint-disable-next-line class-methods-use-this
227
+ _renderTeaser() {
228
+ const teaserContent = this._getTeaserContent();
229
+ if (!teaserContent || teaserContent.length <= 0) {
230
+ return '';
231
+ }
232
+ return html `
233
+ <pd-panel-viewer class="default-teaser" id="teaserPanelViewerId" deltaCalc="4">
234
+ ${teaserContent.map(content => html `
235
+ <pd-panel>
236
+ ${content}
237
+ </pd-panel>
238
+ `)}
239
+ </pd-panel-viewer>
240
+ `;
241
+ }
242
+ _renderFooter() {
15
243
  return html `
16
- <h2>${this.title} Nr. ${this.counter}!</h2>
17
- <button @click=${this.__increment}>increment</button>
244
+ <pd-footer
245
+ class="default-footer"
246
+ .footerLinks="${this._getFooterItems()}"
247
+ version="0.5"
248
+ copyright="PD Progressive Developent UG"
249
+ .madeBy="${MADE_BY}"
250
+ @footer-link="${this._handleFooterRouteEvent}">
251
+ </pd-footer>
18
252
  `;
19
253
  }
254
+ /**
255
+ * Called when (any) cloud function call was finished.
256
+ */
257
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
258
+ _renderSuccessResultInfo(result) {
259
+ var _a;
260
+ return html `
261
+ <pd-toast isSuccess duration="${TOAST_DURATION}">
262
+ ${(_a = this.functionsController.callDataPromise) === null || _a === void 0 ? void 0 : _a.func.successTxt}
263
+ </pd-toast>`;
264
+ }
265
+ /**
266
+ * Called when (any) cloud function is currently running.
267
+ */
268
+ _renderPendingInfo() {
269
+ var _a, _b, _c;
270
+ return ((_a = this.functionsController.callDataPromise) === null || _a === void 0 ? void 0 : _a.func.fadeWindow) ? html `
271
+ <p>Überblende und lade ${(_b = this.functionsController.callDataPromise) === null || _b === void 0 ? void 0 : _b.func.name}...</p>`
272
+ : html `
273
+ <pd-toast duration="-1">
274
+ ${(_c = this.functionsController.callDataPromise) === null || _c === void 0 ? void 0 : _c.func.pendingTxt}
275
+ </pd-toast>`;
276
+ }
277
+ /**
278
+ * Called when (any) cloud function stopped with errors.
279
+ */
280
+ // eslint-disable-next-line class-methods-use-this
281
+ _renderErrorInfo(error) {
282
+ return html `
283
+ <pd-toast isError duration="-1">
284
+ ${error}
285
+ </pd-toast>`;
286
+ }
287
+ // eslint-disable-next-line class-methods-use-this
288
+ _handleMenuRouteEvent(e) {
289
+ // test with el, to handel jumps also here, not used at the moment, same postion link problems...
290
+ if (e.detail.el) {
291
+ this._scrollToContent(e.detail.el);
292
+ }
293
+ else {
294
+ PdSpaHelper._scrollToTop();
295
+ this.navigate(e.detail.route);
296
+ }
297
+ }
298
+ // eslint-disable-next-line class-methods-use-this
299
+ _handleFooterRouteEvent(e) {
300
+ PdSpaHelper._scrollToTop();
301
+ this.navigate(e.detail.link);
302
+ }
303
+ // eslint-disable-next-line class-methods-use-this
304
+ _initMenuSections(e) {
305
+ // get page for event
306
+ const menRefConf = navigationConfig.pages.filter(p => p.name === e.detail.key)[0];
307
+ if (menRefConf) {
308
+ menRefConf.menu = e.detail.menu;
309
+ }
310
+ }
311
+ _createTemporaryToast(e) {
312
+ var _a;
313
+ // hide existing call function toast (old one still is visible for directly incoming errors)
314
+ this.functionsController.clear();
315
+ const tmpToast = new PdToast();
316
+ tmpToast.isError = e.detail.isError;
317
+ tmpToast.isSuccess = e.detail.isSuccess;
318
+ const slotContent = document.createTextNode(e.detail.txt);
319
+ tmpToast.appendChild(slotContent);
320
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(tmpToast);
321
+ tmpToast.duration = TOAST_DURATION;
322
+ // set timeout to remove toast (one second later)
323
+ setTimeout(() => {
324
+ var _a;
325
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeChild(tmpToast);
326
+ }, TOAST_DURATION + 1000);
327
+ }
328
+ static _scrollToTop() {
329
+ window.scrollTo({
330
+ top: 0,
331
+ left: 0,
332
+ behavior: 'smooth',
333
+ });
334
+ }
335
+ // Test, not used at the moment, jump/menu problem...
336
+ // eslint-disable-next-line class-methods-use-this
337
+ _scrollToContent(el) {
338
+ if (el) {
339
+ const rect = el.getBoundingClientRect();
340
+ console.log("Rect: ", rect);
341
+ console.log("Offset Top/Height: ", el.offsetTop, el.offsetHeight);
342
+ window.scrollBy({
343
+ top: rect.top - (this._teaserClosed ? 80 : 450),
344
+ left: 0,
345
+ behavior: 'smooth',
346
+ });
347
+ }
348
+ }
20
349
  }
21
- PdSpaHelper.styles = css `
350
+ PdSpaHelper.styles =
351
+ // Ref: Additional use classmap to add custom classes in concrete impl
352
+ css `
353
+
22
354
  :host {
355
+ display: flex;
356
+ flex-flow: column;
357
+ height: 100%;
358
+ }
359
+
360
+ header {
361
+ flex-grow: 0;
362
+ }
363
+
364
+ main {
365
+ flex-grow: 1;
366
+ flex-basis: max-content;
367
+ }
368
+
369
+ footer {
370
+ flex-grow: 0;
371
+ }
372
+
373
+ .default-header {
374
+ width: 100%;
375
+ position: fixed;
376
+ top: 0;
23
377
  display: block;
24
- padding: 25px;
25
- color: var(--pd-spa-helper-text-color, #000);
378
+ z-index: 99;
379
+ }
380
+
381
+ .default-teaser {
382
+ --pd-panel-overflow: hidden;
383
+ --pd-panel-height: 32vh;
384
+ --pd-panel-width: 100%;
385
+ --pd-panel-border-radius: 0;
386
+ --pd-panel-bg: var(--pd-default-col);
387
+ --pd-panel-viewer-bg-col: var(--pd-default-col);
388
+ }
389
+
390
+ .default-menu {
391
+ transition: background-color 1s;
26
392
  }
393
+
394
+ .default-menu-withteaser {
395
+ --pd-menu-bg-col: #AFC1D2;
396
+ --pd-menu-font-col: #0A3A48;
397
+ transition: background-color 1s;
398
+ }
399
+
400
+ .default-main {
401
+ padding-top: calc(var(--pd-menu-height) + 2em);
402
+ transition: padding-top 1s;
403
+ }
404
+
405
+ .default-main-withteaser {
406
+ padding-top: calc(var(--pd-menu-height) + 32vh);
407
+ transition: padding-top 1s;
408
+ }
409
+
27
410
  `;
28
411
  __decorate([
29
412
  property({ type: String })
30
413
  ], PdSpaHelper.prototype, "title", void 0);
31
414
  __decorate([
32
- property({ type: Number })
33
- ], PdSpaHelper.prototype, "counter", void 0);
415
+ property({ type: Object, state: true })
416
+ ], PdSpaHelper.prototype, "_user", void 0);
417
+ __decorate([
418
+ property({ type: Object, state: true })
419
+ ], PdSpaHelper.prototype, "_profile", void 0);
420
+ __decorate([
421
+ property({ type: String, reflect: true })
422
+ ], PdSpaHelper.prototype, "route", void 0);
423
+ __decorate([
424
+ property({ type: Object })
425
+ ], PdSpaHelper.prototype, "params", void 0);
426
+ __decorate([
427
+ property({ type: Object })
428
+ ], PdSpaHelper.prototype, "query", void 0);
429
+ __decorate([
430
+ property({ type: Boolean })
431
+ ], PdSpaHelper.prototype, "_teaserClosed", void 0);
34
432
  //# sourceMappingURL=PdSpaHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdSpaHelper.js","sourceRoot":"","sources":["../../src/PdSpaHelper.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAA9D;;QAU8B,UAAK,GAAG,WAAW,CAAC;QAEpB,YAAO,GAAG,CAAC,CAAC;IAY1C,CAAC;IAVC,WAAW;QACT,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;YACH,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,OAAO;uBACnB,IAAI,CAAC,WAAW;KAClC,CAAC;IACJ,CAAC;;AArBM,kBAAM,GAAG,GAAG,CAAA;;;;;;GAMlB,CAAC;AAE0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAqB;AAEpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAa","sourcesContent":["import { initializeApp } from 'firebase/app';\nimport { getAuth, onAuthStateChanged } from 'firebase/auth';\n\nimport { router, navigator } from 'lit-element-router';\n\nimport { html, css, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nexport class PdSpaHelper extends router(navigator(LitElement)) {\n\n static styles = css`\n :host {\n display: block;\n padding: 25px;\n color: var(--pd-spa-helper-text-color, #000);\n }\n `;\n\n @property({ type: String }) title = 'Hey there';\n\n @property({ type: Number }) counter = 5;\n\n __increment() {\n this.counter += 1;\n }\n\n render() {\n return html`\n <h2>${this.title} Nr. ${this.counter}!</h2>\n <button @click=${this.__increment}>increment</button>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"PdSpaHelper.js","sourceRoot":"","sources":["../../src/PdSpaHelper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgC,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAQ,MAAM,eAAe,CAAC;AAClE,4DAA4D;AAC5D,iEAAiE;AAEjE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAuD,MAAM,gCAAgC,CA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3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAa;AAEZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAY;AAKV;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAuB","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from 'firebase/app';\nimport { getAuth, onAuthStateChanged, User } from 'firebase/auth';\n// TODO: Add SDKs for Firebase products that you want to use\n// https://firebase.google.com/docs/web/setup#available-libraries\n\nimport { router, navigator } from 'lit-element-router';\n\nimport { html, LitElement, css, CSSResultGroup, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { initApplicationServices } from './InitApplicationData.js';\n\nimport { isAuthenticated } from './firebase/auth.js';\nimport { ServiceCallController } from './service-call-controller2.js';\nimport { callFunction, FunctionDefinition, FunctionResult, FunctionsConfig } from './firebase/functions-client.js';\n\nimport '@progressive-development/pd-page/pd-menu.js';\nimport '@progressive-development/pd-page/pd-footer.js';\n\nimport './router/AppMain.js';\nimport './defaultpage/default-login.js';\nimport './tmpown/pd-panel-viewer.js';\nimport './tmpown/pd-panel.js';\n\n// TODO: How to solve this import problem?\n// eslint-disable-next-line import/no-duplicates\nimport './tmpown/pd-toast.js';\n// eslint-disable-next-line import/no-duplicates\nimport { PdToast } from './tmpown/pd-toast.js';\n\n// Footer Text\nconst MADE_BY = {\n txt: \"made by PD Progressive Development\",\n email: \"info@progressive-development.com\"};\n\n// Visible time for time-limited toast\nconst TOAST_DURATION = 6000;\n\n/**\n * Data models.\n */\n\nexport interface MenuElement {\n key: string,\n name: string,\n sec?: string,\n route?: string,\n action?: Function,\n topItem?: boolean,\n ref?: any,\n icon?: string,\n}\n\nexport interface NavigationPage {\n name: string,\n pattern: Array<string>, \n auth: boolean,\n menu?: Array<MenuElement>,\n withTeaser?: boolean,\n withFooter?: boolean\n}\n\nexport interface NavigationConfig {\n pages: Array<NavigationPage>,\n includeLogin: boolean\n}\n\n/**\n * Transformed routes, generated during startInit.\n */\nlet transformedRoutes:Array<any>;\nlet navigationConfig:NavigationConfig;\nlet postLoginFunc:FunctionDefinition | undefined;\n\n/**\n * Internal helper functions to generate route elemets for lit-router. \n */\nconst transformRoutes = () => {\n\n const transformAuthConfig = (withAuth:boolean) => \n withAuth ? \n {\n unauthenticated: {\n name: 'login',\n },\n authenticate: () => isAuthenticated(),\n } : undefined;\n\n let generatedRoutes:Array<any> = [];\n navigationConfig.pages.forEach(cfEntry => {\n const addAraay = cfEntry.pattern.map(routeMapPattern => (\n {\n name: cfEntry.name,\n pattern: routeMapPattern,\n authentication: transformAuthConfig(cfEntry.auth),\n }\n )); \n generatedRoutes = generatedRoutes.concat(addAraay);\n });\n \n // add not-found route\n generatedRoutes.push({\n name: 'not-found',\n pattern: '*',\n });\n\n return generatedRoutes;\n}\n\n\n/**\n * Init the firebase app and application services like\n * functions and firestore. Generate routes from navigationConfig.\n * \n * @param firebaseConfig \n * @param functionsConfig \n * @param navigationConfig \n */\nexport const startInit = (firebaseConfig: FirebaseOptions, \n functionsConfig: FunctionsConfig, navigationConfigParam: NavigationConfig) => {\n \n // init firebase app\n const app:FirebaseApp = initializeApp(firebaseConfig);\n \n // init application services (functions, store)\n initApplicationServices(app, functionsConfig);\n postLoginFunc = functionsConfig.postLoginFunc;\n\n if (navigationConfigParam.includeLogin) {\n navigationConfigParam.pages.push({\n name: \"login\",\n menu: [\n {key: \"login\", name: \"Login\"}\n ],\n pattern: [\"login\"],\n auth: false\n });\n }\n\n // generate routes from navigation config\n navigationConfig = navigationConfigParam;\n transformedRoutes = transformRoutes(); \n};\n\n/**\n * Abstract class for SPAs. Extend within the app main class.\n */\nexport abstract class PdSpaHelper extends router(navigator(LitElement)) {\n\n protected functionsController = new ServiceCallController(this);\n\n // not used at the moment\n @property({ type: String }) title = 'Hey there';\n\n /**\n * Properties needed for login/profile data.\n */\n @property({ type: Object, state: true }) _user: User | undefined;\n\n @property({ type: Object, state: true }) _profile: any | undefined;\n \n /**\n * Properties needed for the router.\n */\n @property({ type: String, reflect: true }) route = \"\";\n\n @property({ type: Object }) params = {};\n\n @property({ type: Object }) query = {};\n\n /**\n * Indicates if the teaser should closed (depends on scroll position).\n */\n @property({ type: Boolean }) _teaserClosed = false; \n\n static styles = \n // Ref: Additional use classmap to add custom classes in concrete impl\n css`\n\n :host {\n display: flex;\n flex-flow: column;\n height: 100%;\n }\n\n header {\n flex-grow: 0;\n }\n\n main {\n flex-grow: 1;\n flex-basis: max-content;\n }\n\n footer {\n flex-grow: 0;\n }\n\n .default-header {\n width: 100%;\n position: fixed;\n top: 0;\n display: block;\n z-index: 99;\n }\n\n .default-teaser {\n --pd-panel-overflow: hidden;\n --pd-panel-height: 32vh;\n --pd-panel-width: 100%; \n --pd-panel-border-radius: 0;\n --pd-panel-bg: var(--pd-default-col);\n --pd-panel-viewer-bg-col: var(--pd-default-col);\n }\n\n .default-menu { \n transition: background-color 1s;\n }\n\n .default-menu-withteaser { \n --pd-menu-bg-col: #AFC1D2;\n --pd-menu-font-col: #0A3A48;\n transition: background-color 1s;\n }\n\n .default-main {\n padding-top: calc(var(--pd-menu-height) + 2em);\n transition: padding-top 1s;\n }\n\n .default-main-withteaser {\n padding-top: calc(var(--pd-menu-height) + 32vh);\n transition: padding-top 1s;\n }\n\n ` as CSSResultGroup;\n\n constructor() {\n\n super();\n\n const doSomething = (scrollPos:Number) => {\n if (scrollPos <= 50) {\n this._teaserClosed = false;\n } else {\n this._teaserClosed = true;\n }\n };\n\n let ticking = false;\n document.addEventListener('scroll', () => {\n const lastKnownScrollPosition = window.scrollY;\n if (!ticking) {\n window.requestAnimationFrame(() => {\n doSomething(lastKnownScrollPosition);\n ticking = false;\n });\n ticking = true;\n }\n });\n\n this.activateLoginHandler();\n\n // For common toast messages (not for callfunction toasts => handelt by own controller)\n this.addEventListener(\"toast-event\", this._createTemporaryToast);\n this.addEventListener(\"route-event\", this._handleMenuRouteEvent); \n }\n\n /**\n * Non reactive private property for the index db class.\n */\n // private _indexDBClient?: YoIndexDBClient|null; \n\n /**\n * Needed for the router.\n * Return all configured routes.\n */\n static get routes() {\n return transformedRoutes; \n }\n\n /**\n * Needed for the router.\n * Set route params to internal members.\n */\n router(route:string, params:Object, query:Object) {\n this.route = route;\n this.params = params;\n this.query = query;\n } \n \n /**\n * Call to activate onAuthState change with profile request callbacks.\n */\n activateLoginHandler() {\n // activate firebase auth handler\n const auth = getAuth();\n onAuthStateChanged(auth, user => {\n if (user) {\n this._user = user;\n if (postLoginFunc) {\n\n callFunction(postLoginFunc, undefined)\n .then((result:any) => {\n this._profile = result.resultData;\n // redirect if login in the meantime is available \n // => else stay on the login page after reload/url navigation\n if (this.route === \"login\") {\n this.navigate(\"profile\");\n }\n });\n }\n } else {\n this._user = undefined;\n this._profile = undefined;\n }\n });\n }\n\n render() { \n const pageConf = navigationConfig.pages.filter(p => p.name === this.route)[0];\n const hideTeaser = this._teaserClosed || !pageConf?.withTeaser;\n return html`\n <header id=\"headerElementId\" class=\"default-header\">\n ${hideTeaser ? '' : this._renderTeaser()}\n ${this._renderMenu(pageConf, hideTeaser)} \n </header> \n\n <main class=\"${hideTeaser ? \"default-main\" : \"default-main-withteaser\"}\">\n <app-main active-route=${this.route}\n @init-menu-sections=\"${this._initMenuSections}\">\n ${this._renderRoutePages()}\n ${navigationConfig.includeLogin ? html`\n <default-login route=\"login\"></default-login>` : ''}\n </app-main>\n </main>\n\n ${this.functionsController.render({\n complete: (result: FunctionResult) => this._renderSuccessResultInfo(result),\n initial: () => '',\n pending: () => this._renderPendingInfo(),\n error: (e: any) => this._renderErrorInfo(e),\n })}\n\n ${pageConf?.withFooter ? html`\n <footer class=\"default-footer\">\n ${this._renderFooter()}\n </footer>` : ''}\n `;\n }\n\n _renderMenu(pageConfig:NavigationPage, hideTeaser:boolean) {\n const menuForPage = pageConfig ? (pageConfig.menu || []) : [];\n return menuForPage ? html`\n <pd-menu\n class=\"${hideTeaser ? \"default-menu\" : \"default-menu-withteaser\"}\"\n .menuItems=${menuForPage.filter(mfp => !mfp.topItem)}\n .topMenuItems=${menuForPage.filter(mfp => mfp.topItem)}\n headerSize=\"${hideTeaser ? 80 : 440}\"\n >\n ${hideTeaser ? this._getAppLogo() : ''}\n </pd-menu>\n ` : '';\n }\n\n // eslint-disable-next-line class-methods-use-this\n _renderTeaser(): TemplateResult | string {\n const teaserContent = this._getTeaserContent();\n if (!teaserContent || teaserContent.length <= 0) {\n return '';\n }\n return html`\n <pd-panel-viewer class=\"default-teaser\" id=\"teaserPanelViewerId\" deltaCalc=\"4\">\n ${teaserContent.map(content => html`\n <pd-panel>\n ${content}\n </pd-panel>\n `)}\n </pd-panel-viewer>\n `;\n }\n\n _renderFooter() {\n return html`\n <pd-footer \n class=\"default-footer\"\n .footerLinks=\"${this._getFooterItems()}\"\n version=\"0.5\" \n copyright=\"PD Progressive Developent UG\" \n .madeBy=\"${MADE_BY}\" \n @footer-link=\"${this._handleFooterRouteEvent}\">\n </pd-footer>\n `;\n }\n\n /**\n * Called when (any) cloud function call was finished. \n */\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n _renderSuccessResultInfo(result: FunctionResult) {\n return html`\n <pd-toast isSuccess duration=\"${TOAST_DURATION}\">\n ${this.functionsController.callDataPromise?.func.successTxt}\n </pd-toast>`;\n }\n\n /**\n * Called when (any) cloud function is currently running. \n */\n _renderPendingInfo() {\n return this.functionsController.callDataPromise?.func.fadeWindow ? html`\n <p>Überblende und lade ${this.functionsController.callDataPromise?.func.name}...</p>` \n : html`\n <pd-toast duration=\"-1\">\n ${this.functionsController.callDataPromise?.func.pendingTxt}\n </pd-toast>`; \n }\n\n /**\n * Called when (any) cloud function stopped with errors.\n */\n // eslint-disable-next-line class-methods-use-this\n _renderErrorInfo(error:any) {\n return html`\n <pd-toast isError duration=\"-1\">\n ${error}\n </pd-toast>`;\n }\n\n protected abstract _getTeaserContent(): Array<TemplateResult>;\n\n protected abstract _getFooterItems(): Array<any>;\n\n protected abstract _getAppLogo(): TemplateResult;\n\n protected abstract _renderRoutePages(): any;\n\n // eslint-disable-next-line class-methods-use-this\n _handleMenuRouteEvent(e:any) {\n // test with el, to handel jumps also here, not used at the moment, same postion link problems...\n if (e.detail.el) {\n this._scrollToContent(e.detail.el);\n } else {\n PdSpaHelper._scrollToTop();\n this.navigate(e.detail.route);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n _handleFooterRouteEvent(e: CustomEvent) { \n PdSpaHelper._scrollToTop();\n this.navigate(e.detail.link); \n }\n \n // eslint-disable-next-line class-methods-use-this\n _initMenuSections(e:any) {\n // get page for event\n const menRefConf = navigationConfig.pages.filter(p => p.name === e.detail.key)[0];\n if (menRefConf) {\n menRefConf.menu = e.detail.menu;\n }\n }\n\n _createTemporaryToast(e: any) {\n \n // hide existing call function toast (old one still is visible for directly incoming errors)\n this.functionsController.clear();\n \n const tmpToast = new PdToast(); \n tmpToast.isError = e.detail.isError;\n tmpToast.isSuccess = e.detail.isSuccess;\n const slotContent = document.createTextNode(e.detail.txt);\n tmpToast.appendChild(slotContent) \n\n this.shadowRoot?.appendChild(tmpToast);\n tmpToast.duration = TOAST_DURATION;\n\n // set timeout to remove toast (one second later)\n setTimeout(() => {\n this.shadowRoot?.removeChild(tmpToast);\n }, TOAST_DURATION + 1000);\n }\n\n static _scrollToTop() {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth',\n });\n }\n\n // Test, not used at the moment, jump/menu problem...\n // eslint-disable-next-line class-methods-use-this\n _scrollToContent(el:HTMLElement) {\n if (el) {\n const rect = el.getBoundingClientRect();\n console.log(\"Rect: \", rect);\n console.log(\"Offset Top/Height: \", el.offsetTop, el.offsetHeight);\n window.scrollBy({\n top: rect.top - (this._teaserClosed ? 80 : 450),\n left: 0,\n behavior: 'smooth',\n });\n }\n }\n\n}"]}
@@ -0,0 +1,5 @@
1
+ import { LitElement } from "lit";
2
+ import '../tmpown/pd-login.js';
3
+ export declare class DefaultLogin extends LitElement {
4
+ render(): import("lit-html").TemplateResult<1>;
5
+ }
@@ -0,0 +1,16 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, LitElement } from "lit";
3
+ import { customElement } from "lit/decorators.js";
4
+ import '../tmpown/pd-login.js';
5
+ let DefaultLogin = class DefaultLogin extends LitElement {
6
+ render() {
7
+ return html `
8
+ <pd-login></pd-login>
9
+ `;
10
+ }
11
+ };
12
+ DefaultLogin = __decorate([
13
+ customElement("default-login")
14
+ ], DefaultLogin);
15
+ export { DefaultLogin };
16
+ //# sourceMappingURL=default-login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-login.js","sourceRoot":"","sources":["../../../src/defaultpage/default-login.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,uBAAuB,CAAC;AAG/B,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAE1C,MAAM;QACJ,OAAO,IAAI,CAAA;;KAEV,CAAC;IACJ,CAAC;CAEF,CAAA;AARY,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAQxB;SARY,YAAY","sourcesContent":["import { html, LitElement } from \"lit\";\nimport { customElement } from \"lit/decorators.js\";\n\nimport '../tmpown/pd-login.js';\n\n@customElement(\"default-login\")\nexport class DefaultLogin extends LitElement {\n\n render() {\n return html`\n <pd-login></pd-login>\n `;\n }\n\n}"]}