@worktile/planet 10.0.0 → 12.1.1
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.
- package/.all-contributorsrc +84 -0
- package/.circleci/config.yml +17 -0
- package/.coveralls.yml +1 -0
- package/.docgeni/public/assets/favicon.ico +0 -0
- package/.docgeni/public/index.html +13 -0
- package/.docgenirc.js +35 -0
- package/.dockerignore +1 -0
- package/.editorconfig +22 -0
- package/.github/FUNDING.yml +12 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.prettierignore +7 -0
- package/.prettierrc +28 -0
- package/.travis.yml +26 -0
- package/.wpmrc.js +11 -0
- package/CHANGELOG.md +391 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/Dockerfile +11 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/README.zh-CN.md +307 -0
- package/SECURITY.md +21 -0
- package/angular.json +373 -0
- package/commitlint.config.js +6 -0
- package/docs/api/defineApplication.md +46 -0
- package/docs/api/globalEventDispatcher.md +51 -0
- package/docs/api/index.md +5 -0
- package/docs/api/planet.md +117 -0
- package/docs/guides/getting-started.md +174 -0
- package/docs/guides/index.md +5 -0
- package/docs/guides/intro.md +216 -0
- package/examples/app1/browserslist +11 -0
- package/examples/app1/extra-webpack.config.js +33 -0
- package/examples/app1/karma.conf.js +31 -0
- package/examples/app1/postcss.config.js +1 -0
- package/examples/app1/src/app/app.module.ts +44 -0
- package/examples/app1/src/app/app.routing.ts +49 -0
- package/examples/app1/src/app/counter.service.ts +16 -0
- package/examples/app1/src/app/dashboard/dashboard.component.html +51 -0
- package/examples/app1/src/app/dashboard/dashboard.component.ts +70 -0
- package/examples/app1/src/app/detail/detail.component.html +8 -0
- package/examples/app1/src/app/detail/detail.component.ts +18 -0
- package/examples/app1/src/app/overlay.ts +26 -0
- package/examples/app1/src/app/projects/dialog/projects-dialog.component.html +10 -0
- package/examples/app1/src/app/projects/dialog/projects-dialog.component.ts +41 -0
- package/examples/app1/src/app/projects/projects.component.ts +33 -0
- package/examples/app1/src/app/root/root.component.css +3 -0
- package/examples/app1/src/app/root/root.component.html +16 -0
- package/examples/app1/src/app/root/root.component.ts +35 -0
- package/examples/app1/src/app/services/initialized-data.resolver.ts +15 -0
- package/examples/app1/src/app/shared.module.ts +57 -0
- package/examples/app1/src/app/user/detail/user-detail.component.html +5 -0
- package/examples/app1/src/app/user/detail/user-detail.component.ts +20 -0
- package/examples/app1/src/app/user/user-list.component.html +7 -0
- package/examples/app1/src/app/user/user-list.component.ts +20 -0
- package/examples/app1/src/app/user/user.module.ts +31 -0
- package/examples/app1/src/assets/.gitkeep +0 -0
- package/examples/app1/src/assets/github.png +0 -0
- package/examples/app1/src/assets/main.css +3 -0
- package/examples/app1/src/environments/environment.prod.ts +3 -0
- package/examples/app1/src/environments/environment.ts +16 -0
- package/examples/app1/src/favicon.ico +0 -0
- package/examples/app1/src/index.html +14 -0
- package/examples/app1/src/main.ts +35 -0
- package/examples/app1/src/polyfills.ts +84 -0
- package/examples/app1/src/styles.scss +35 -0
- package/examples/app1/src/test.ts +14 -0
- package/examples/app1/temp.js +221 -0
- package/examples/app1/tsconfig.app.json +10 -0
- package/examples/app1/tsconfig.spec.json +18 -0
- package/examples/app1/tslint.json +17 -0
- package/examples/app1/webpack.config.js +127 -0
- package/examples/app2/browserslist +11 -0
- package/examples/app2/extra-webpack.config.js +32 -0
- package/examples/app2/karma.conf.js +31 -0
- package/examples/app2/src/app/app.module.ts +90 -0
- package/examples/app2/src/app/dashboard/dashboard.component.html +21 -0
- package/examples/app2/src/app/dashboard/dashboard.component.ts +27 -0
- package/examples/app2/src/app/overlay.ts +26 -0
- package/examples/app2/src/app/projects/detail/detail.component.html +16 -0
- package/examples/app2/src/app/projects/detail/detail.component.ts +21 -0
- package/examples/app2/src/app/projects/project-list.component.html +29 -0
- package/examples/app2/src/app/projects/project-list.component.ts +58 -0
- package/examples/app2/src/app/projects/project.resolver.ts +15 -0
- package/examples/app2/src/app/projects/projects.service.ts +28 -0
- package/examples/app2/src/app/projects/tasks/tasks.component.html +10 -0
- package/examples/app2/src/app/projects/tasks/tasks.component.ts +16 -0
- package/examples/app2/src/app/projects/view/view.component.html +1 -0
- package/examples/app2/src/app/projects/view/view.component.ts +20 -0
- package/examples/app2/src/app/root/root.component.html +14 -0
- package/examples/app2/src/app/root/root.component.scss +12 -0
- package/examples/app2/src/app/root/root.component.ts +28 -0
- package/examples/app2/src/app/shared.module.ts +59 -0
- package/examples/app2/src/assets/.gitkeep +0 -0
- package/examples/app2/src/environments/environment.prod.ts +3 -0
- package/examples/app2/src/environments/environment.ts +16 -0
- package/examples/app2/src/favicon.ico +0 -0
- package/examples/app2/src/index.html +14 -0
- package/examples/app2/src/main.ts +36 -0
- package/examples/app2/src/polyfills.ts +84 -0
- package/examples/app2/src/styles.scss +28 -0
- package/examples/app2/src/test.ts +14 -0
- package/examples/app2/tsconfig.app.json +10 -0
- package/examples/app2/tsconfig.spec.json +18 -0
- package/examples/app2/tslint.json +7 -0
- package/examples/app2/webpack.config.js +92 -0
- package/examples/common/app-root-context.ts +10 -0
- package/examples/common/cache.ts +82 -0
- package/examples/common/index.ts +13 -0
- package/examples/common/module.ts +10 -0
- package/examples/common/overlay-container.service.ts +28 -0
- package/examples/common/section-card/section-card.component.html +5 -0
- package/examples/common/section-card/section-card.component.scss +15 -0
- package/examples/common/section-card/section-card.component.ts +11 -0
- package/examples/common/utils.ts +0 -0
- package/examples/portal/src/app/a-detail/a-detail.component.html +8 -0
- package/examples/portal/src/app/a-detail/a-detail.component.ts +18 -0
- package/examples/portal/src/app/about/about.component.html +27 -0
- package/examples/portal/src/app/about/about.component.scss +0 -0
- package/examples/portal/src/app/about/about.component.spec.ts +26 -0
- package/examples/portal/src/app/about/about.component.ts +26 -0
- package/examples/portal/src/app/app-routing.module.ts +57 -0
- package/examples/portal/src/app/app.component.html +73 -0
- package/examples/portal/src/app/app.component.scss +58 -0
- package/examples/portal/src/app/app.component.spec.ts +33 -0
- package/examples/portal/src/app/app.component.ts +111 -0
- package/examples/portal/src/app/app.module.ts +64 -0
- package/examples/portal/src/app/custom-settings.service.ts +44 -0
- package/examples/portal/src/app/overlay.ts +26 -0
- package/examples/portal/src/app/settings/settings.component.html +31 -0
- package/examples/portal/src/app/settings/settings.component.scss +3 -0
- package/examples/portal/src/app/settings/settings.component.ts +43 -0
- package/examples/portal/src/assets/.gitkeep +0 -0
- package/examples/portal/src/assets/apps.json +29 -0
- package/examples/portal/src/assets/icons/sprite.defs.svg +1 -0
- package/examples/portal/src/assets/images/logo.svg +16 -0
- package/examples/portal/src/assets/ngx-planet-micro-front-end.gif +0 -0
- package/examples/portal/src/browserslist +11 -0
- package/examples/portal/src/environments/environment.prod.ts +3 -0
- package/examples/portal/src/environments/environment.ts +16 -0
- package/examples/portal/src/extra-webpack.config.js +32 -0
- package/examples/portal/src/favicon.ico +0 -0
- package/examples/portal/src/index.html +14 -0
- package/examples/portal/src/karma.conf.js +31 -0
- package/examples/portal/src/main.ts +18 -0
- package/examples/portal/src/polyfills.ts +84 -0
- package/examples/portal/src/reboot.scss +14 -0
- package/examples/portal/src/styles.scss +14 -0
- package/examples/portal/src/test.ts +14 -0
- package/examples/portal/src/tsconfig.app.json +10 -0
- package/examples/portal/src/tsconfig.spec.json +9 -0
- package/examples/portal/src/tslint.json +7 -0
- package/extra-webpack.config.js +5 -0
- package/nginx.conf +17 -0
- package/package.json +120 -15
- package/packages/planet/karma.conf.js +37 -0
- package/packages/planet/ng-package.json +7 -0
- package/packages/planet/package.json +10 -0
- package/packages/planet/src/application/planet-application-loader.spec.ts +1102 -0
- package/packages/planet/src/application/planet-application-loader.ts +549 -0
- package/packages/planet/src/application/planet-application-ref.spec.ts +233 -0
- package/packages/planet/src/application/planet-application-ref.ts +131 -0
- package/packages/planet/src/application/planet-application.service.spec.ts +145 -0
- package/packages/planet/src/application/planet-application.service.ts +88 -0
- package/packages/planet/src/application/portal-application.spec.ts +53 -0
- package/packages/planet/src/application/portal-application.ts +28 -0
- package/packages/planet/src/assets-loader.spec.ts +689 -0
- package/packages/planet/src/assets-loader.ts +247 -0
- package/packages/planet/src/component/planet-component-loader.spec.ts +187 -0
- package/packages/planet/src/component/planet-component-loader.ts +173 -0
- package/{component/planet-component-ref.d.ts → packages/planet/src/component/planet-component-ref.ts} +3 -2
- package/{component/plant-component.config.d.ts → packages/planet/src/component/plant-component.config.ts} +4 -3
- package/packages/planet/src/debug.spec.ts +58 -0
- package/packages/planet/src/debug.ts +66 -0
- package/packages/planet/src/empty/empty.component.spec.ts +34 -0
- package/packages/planet/src/empty/empty.component.ts +7 -0
- package/packages/planet/src/global-event-dispatcher.spec.ts +81 -0
- package/packages/planet/src/global-event-dispatcher.ts +82 -0
- package/packages/planet/src/global-planet.spec.ts +39 -0
- package/packages/planet/src/global-planet.ts +73 -0
- package/packages/planet/src/helpers.spec.ts +242 -0
- package/packages/planet/src/helpers.ts +125 -0
- package/packages/planet/src/module.spec.ts +79 -0
- package/packages/planet/src/module.ts +25 -0
- package/packages/planet/src/planet.class.ts +59 -0
- package/packages/planet/src/planet.spec.ts +226 -0
- package/packages/planet/src/planet.ts +113 -0
- package/{public-api.d.ts → packages/planet/src/public-api.ts} +4 -0
- package/packages/planet/src/sandbox/constants.ts +6 -0
- package/packages/planet/src/sandbox/exec.ts +22 -0
- package/packages/planet/src/sandbox/index.ts +24 -0
- package/packages/planet/src/sandbox/proxy/patches/document.ts +13 -0
- package/packages/planet/src/sandbox/proxy/patches/eventListener.ts +49 -0
- package/packages/planet/src/sandbox/proxy/patches/index.ts +13 -0
- package/packages/planet/src/sandbox/proxy/patches/storage.ts +53 -0
- package/packages/planet/src/sandbox/proxy/patches/timer.ts +50 -0
- package/packages/planet/src/sandbox/proxy/proxies/common.ts +137 -0
- package/packages/planet/src/sandbox/proxy/proxies/document.ts +140 -0
- package/packages/planet/src/sandbox/proxy/proxies/window.ts +176 -0
- package/packages/planet/src/sandbox/proxy/proxy-sandbox.ts +59 -0
- package/packages/planet/src/sandbox/proxy/types.ts +20 -0
- package/packages/planet/src/sandbox/sandbox.ts +20 -0
- package/packages/planet/src/sandbox/snapshot/snapshot-sandbox.ts +12 -0
- package/packages/planet/src/sandbox/types.ts +1 -0
- package/packages/planet/src/test.ts +16 -0
- package/packages/planet/src/testing/app1.module.ts +34 -0
- package/packages/planet/src/testing/app2.module.ts +24 -0
- package/packages/planet/src/testing/applications.ts +58 -0
- package/packages/planet/src/testing/index.ts +2 -0
- package/packages/planet/src/testing/utils.ts +31 -0
- package/packages/planet/tsconfig.lib.json +27 -0
- package/packages/planet/tsconfig.lib.prod.json +9 -0
- package/packages/planet/tsconfig.spec.json +17 -0
- package/packages/planet/tslint.json +7 -0
- package/postcss.config.js +3 -0
- package/proxy.conf.js +15 -0
- package/tsconfig.json +23 -0
- package/tslint.json +80 -0
- package/application/planet-application-loader.d.ts +0 -68
- package/application/planet-application-ref.d.ts +0 -32
- package/application/planet-application.service.d.ts +0 -18
- package/application/portal-application.d.ts +0 -14
- package/assets-loader.d.ts +0 -23
- package/bundles/worktile-planet.umd.js +0 -1670
- package/bundles/worktile-planet.umd.js.map +0 -1
- package/bundles/worktile-planet.umd.min.js +0 -16
- package/bundles/worktile-planet.umd.min.js.map +0 -1
- package/component/planet-component-loader.d.ts +0 -27
- package/empty/empty.component.d.ts +0 -2
- package/esm2015/application/planet-application-loader.js +0 -417
- package/esm2015/application/planet-application-ref.js +0 -86
- package/esm2015/application/planet-application.service.js +0 -87
- package/esm2015/application/portal-application.js +0 -16
- package/esm2015/assets-loader.js +0 -165
- package/esm2015/component/planet-component-loader.js +0 -157
- package/esm2015/component/planet-component-ref.js +0 -3
- package/esm2015/component/plant-component.config.js +0 -7
- package/esm2015/empty/empty.component.js +0 -10
- package/esm2015/global-event-dispatcher.js +0 -71
- package/esm2015/global-planet.js +0 -51
- package/esm2015/helpers.js +0 -116
- package/esm2015/module.js +0 -27
- package/esm2015/planet.class.js +0 -9
- package/esm2015/planet.js +0 -86
- package/esm2015/public-api.js +0 -18
- package/esm2015/worktile-planet.js +0 -6
- package/fesm2015/worktile-planet.js +0 -1257
- package/fesm2015/worktile-planet.js.map +0 -1
- package/global-event-dispatcher.d.ts +0 -19
- package/global-planet.d.ts +0 -22
- package/helpers.d.ts +0 -37
- package/module.d.ts +0 -5
- package/planet.class.d.ts +0 -34
- package/planet.d.ts +0 -24
- package/worktile-planet.d.ts +0 -5
- package/worktile-planet.metadata.json +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Component, OnInit, ChangeDetectorRef, ApplicationRef, NgZone, HostBinding } from '@angular/core';
|
|
2
|
+
import { Planet, SwitchModes, GlobalEventDispatcher, ApplicationStatus, PlanetApplication } from 'ngx-planet';
|
|
3
|
+
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
|
4
|
+
import { ThyDialog } from 'ngx-tethys/dialog';
|
|
5
|
+
import { ADetailComponent } from './a-detail/a-detail.component';
|
|
6
|
+
import { ThyNotifyService } from 'ngx-tethys/notify';
|
|
7
|
+
import { AppRootContext } from '@demo/common';
|
|
8
|
+
import { CustomSettingsService } from './custom-settings.service';
|
|
9
|
+
import { debug } from 'debug';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'app-root',
|
|
13
|
+
templateUrl: './app.component.html'
|
|
14
|
+
})
|
|
15
|
+
export class AppComponent implements OnInit {
|
|
16
|
+
// @HostBinding('class.portal') class = true;
|
|
17
|
+
|
|
18
|
+
title = 'ngx-planet';
|
|
19
|
+
|
|
20
|
+
activeAppNames: string[] = [];
|
|
21
|
+
|
|
22
|
+
get loadingDone() {
|
|
23
|
+
return this.planet.loadingDone;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
private customSettingsService: CustomSettingsService,
|
|
28
|
+
private planet: Planet,
|
|
29
|
+
private globalEventDispatcher: GlobalEventDispatcher,
|
|
30
|
+
private thyDialog: ThyDialog,
|
|
31
|
+
private thyNotify: ThyNotifyService,
|
|
32
|
+
public appRootContext: AppRootContext
|
|
33
|
+
) {}
|
|
34
|
+
|
|
35
|
+
ngOnInit() {
|
|
36
|
+
this.planet.setOptions({
|
|
37
|
+
switchMode: SwitchModes.coexist,
|
|
38
|
+
errorHandler: error => {
|
|
39
|
+
this.thyNotify.error(`错误`, '加载资源失败');
|
|
40
|
+
console.error(error);
|
|
41
|
+
},
|
|
42
|
+
debugFactory: debug
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.appRootContext.setName(`my name is app root context`);
|
|
46
|
+
|
|
47
|
+
this.planet.setPortalAppData({
|
|
48
|
+
appRootContext: this.appRootContext
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const appHostClass = 'thy-layout';
|
|
52
|
+
|
|
53
|
+
const settings = this.customSettingsService.get();
|
|
54
|
+
this.planet.registerApps([
|
|
55
|
+
{
|
|
56
|
+
name: 'app1',
|
|
57
|
+
hostParent: '#app-host-container',
|
|
58
|
+
hostClass: appHostClass,
|
|
59
|
+
routerPathPrefix: /\/app1|app4/, // '/app1',
|
|
60
|
+
resourcePathPrefix: '/static/app1/',
|
|
61
|
+
preload: settings.app1.preload,
|
|
62
|
+
switchMode: settings.app1.switchMode,
|
|
63
|
+
loadSerial: true,
|
|
64
|
+
stylePrefix: 'app1',
|
|
65
|
+
// prettier-ignore
|
|
66
|
+
scripts: [
|
|
67
|
+
'main.js',
|
|
68
|
+
// 'polyfills.js'
|
|
69
|
+
],
|
|
70
|
+
styles: ['styles.css'],
|
|
71
|
+
manifest: '/static/app1/assets-manifest.json',
|
|
72
|
+
extra: {
|
|
73
|
+
name: '应用1',
|
|
74
|
+
color: '#ffa415'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'app2',
|
|
79
|
+
hostParent: '#app-host-container',
|
|
80
|
+
hostClass: appHostClass,
|
|
81
|
+
routerPathPrefix: '/app2',
|
|
82
|
+
resourcePathPrefix: '/static/app2/',
|
|
83
|
+
preload: settings.app2.preload,
|
|
84
|
+
switchMode: settings.app2.switchMode,
|
|
85
|
+
sandbox: true,
|
|
86
|
+
stylePrefix: 'app2',
|
|
87
|
+
// prettier-ignore
|
|
88
|
+
scripts: [
|
|
89
|
+
'main.js'
|
|
90
|
+
],
|
|
91
|
+
styles: ['styles.css'],
|
|
92
|
+
manifest: '/static/app2/assets-manifest.json',
|
|
93
|
+
extra: {
|
|
94
|
+
name: '应用2',
|
|
95
|
+
color: '#66c060'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
this.planet.start();
|
|
101
|
+
|
|
102
|
+
this.globalEventDispatcher.register('openADetail').subscribe(event => {
|
|
103
|
+
this.thyDialog.open(ADetailComponent);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
this.planet.appsLoadingStart.subscribe(event => {
|
|
107
|
+
this.activeAppNames = event.shouldLoadApps.map(item => item.name);
|
|
108
|
+
console.log(`active app names: ${this.activeAppNames.join(',')}`);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { BrowserModule, DomSanitizer } from '@angular/platform-browser';
|
|
3
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
4
|
+
import { NgModule } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
7
|
+
import { AppComponent } from './app.component';
|
|
8
|
+
import { AboutComponent } from './about/about.component';
|
|
9
|
+
import { NgxPlanetModule } from 'ngx-planet';
|
|
10
|
+
import { ThyIconModule, ThyIconRegistry } from 'ngx-tethys/icon';
|
|
11
|
+
import { ThyButtonModule } from 'ngx-tethys/button';
|
|
12
|
+
import { ThyDialogModule } from 'ngx-tethys/dialog';
|
|
13
|
+
import { ThyLayoutModule } from 'ngx-tethys/layout';
|
|
14
|
+
import { ThyTableModule } from 'ngx-tethys/table';
|
|
15
|
+
import { ThyNotifyModule } from 'ngx-tethys/notify';
|
|
16
|
+
import { ThyLoadingModule } from 'ngx-tethys/loading';
|
|
17
|
+
import { ThyNavModule } from 'ngx-tethys/nav';
|
|
18
|
+
import { ThyActionMenuModule } from 'ngx-tethys/action-menu';
|
|
19
|
+
import { ThyTooltipModule } from 'ngx-tethys/tooltip';
|
|
20
|
+
import { ThyPopoverModule } from 'ngx-tethys/popover';
|
|
21
|
+
import { ThyFormModule } from 'ngx-tethys/form';
|
|
22
|
+
import { ThyRadioModule } from 'ngx-tethys/radio';
|
|
23
|
+
import { ThyCheckboxModule } from 'ngx-tethys/checkbox';
|
|
24
|
+
import { ADetailComponent } from './a-detail/a-detail.component';
|
|
25
|
+
import { SettingsComponent } from './settings/settings.component';
|
|
26
|
+
import { AppRootContext, DemoCommonModule, OVERLAY_PROVIDER } from '@demo/common';
|
|
27
|
+
import { FormsModule } from '@angular/forms';
|
|
28
|
+
import { Overlay } from '@angular/cdk/overlay';
|
|
29
|
+
import { AppOverlay } from './overlay';
|
|
30
|
+
|
|
31
|
+
@NgModule({
|
|
32
|
+
declarations: [AppComponent, AboutComponent, SettingsComponent, ADetailComponent],
|
|
33
|
+
imports: [
|
|
34
|
+
BrowserModule,
|
|
35
|
+
BrowserAnimationsModule,
|
|
36
|
+
FormsModule,
|
|
37
|
+
CommonModule,
|
|
38
|
+
ThyIconModule,
|
|
39
|
+
ThyButtonModule,
|
|
40
|
+
ThyDialogModule,
|
|
41
|
+
ThyTableModule,
|
|
42
|
+
ThyLayoutModule,
|
|
43
|
+
ThyNotifyModule,
|
|
44
|
+
ThyLoadingModule,
|
|
45
|
+
ThyNavModule,
|
|
46
|
+
ThyActionMenuModule,
|
|
47
|
+
ThyTooltipModule,
|
|
48
|
+
ThyPopoverModule,
|
|
49
|
+
ThyFormModule,
|
|
50
|
+
ThyRadioModule,
|
|
51
|
+
ThyCheckboxModule,
|
|
52
|
+
AppRoutingModule,
|
|
53
|
+
NgxPlanetModule,
|
|
54
|
+
DemoCommonModule
|
|
55
|
+
],
|
|
56
|
+
providers: [AppRootContext, OVERLAY_PROVIDER, { provide: Overlay, useClass: AppOverlay }],
|
|
57
|
+
bootstrap: [AppComponent],
|
|
58
|
+
entryComponents: [ADetailComponent]
|
|
59
|
+
})
|
|
60
|
+
export class AppModule {
|
|
61
|
+
constructor(iconRegistry: ThyIconRegistry, domSanitizer: DomSanitizer) {
|
|
62
|
+
iconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/sprite.defs.svg'));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { cache } from '@demo/common';
|
|
3
|
+
import { SwitchModes } from 'ngx-planet';
|
|
4
|
+
const SETTINGS_KEY = 'custom-settings';
|
|
5
|
+
|
|
6
|
+
export interface CustomSettingsInfo {
|
|
7
|
+
app1: {
|
|
8
|
+
preload: boolean;
|
|
9
|
+
switchMode?: SwitchModes;
|
|
10
|
+
};
|
|
11
|
+
app2: {
|
|
12
|
+
preload: boolean;
|
|
13
|
+
switchMode?: SwitchModes;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DEFAULT_SETTINGS: CustomSettingsInfo = {
|
|
18
|
+
app1: {
|
|
19
|
+
preload: true,
|
|
20
|
+
switchMode: SwitchModes.coexist
|
|
21
|
+
},
|
|
22
|
+
app2: {
|
|
23
|
+
preload: true,
|
|
24
|
+
switchMode: SwitchModes.coexist
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@Injectable({
|
|
29
|
+
providedIn: 'root'
|
|
30
|
+
})
|
|
31
|
+
export class CustomSettingsService {
|
|
32
|
+
get(): CustomSettingsInfo {
|
|
33
|
+
const settings = cache.get<CustomSettingsInfo>(SETTINGS_KEY);
|
|
34
|
+
return settings || JSON.parse(JSON.stringify(DEFAULT_SETTINGS));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
save(settings: CustomSettingsInfo) {
|
|
38
|
+
cache.set<CustomSettingsInfo>(SETTINGS_KEY, settings);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
restore() {
|
|
42
|
+
cache.set<CustomSettingsInfo>(SETTINGS_KEY, DEFAULT_SETTINGS);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Directionality } from '@angular/cdk/bidi';
|
|
2
|
+
import {
|
|
3
|
+
Overlay,
|
|
4
|
+
OverlayConfig,
|
|
5
|
+
OverlayContainer,
|
|
6
|
+
OverlayKeyboardDispatcher,
|
|
7
|
+
OverlayPositionBuilder,
|
|
8
|
+
OverlayRef,
|
|
9
|
+
ScrollStrategyOptions
|
|
10
|
+
} from '@angular/cdk/overlay';
|
|
11
|
+
import { DOCUMENT, Location } from '@angular/common';
|
|
12
|
+
import { ComponentFactoryResolver, Inject, Injectable, Injector, NgZone } from '@angular/core';
|
|
13
|
+
import { isArray, concatArray } from 'ngx-tethys/util';
|
|
14
|
+
|
|
15
|
+
@Injectable({ providedIn: 'root' })
|
|
16
|
+
export class AppOverlay extends Overlay {
|
|
17
|
+
create(config?: OverlayConfig): OverlayRef {
|
|
18
|
+
const overlayConfig: OverlayConfig = {
|
|
19
|
+
...config,
|
|
20
|
+
panelClass: concatArray(config.panelClass, 'portal')
|
|
21
|
+
};
|
|
22
|
+
const overlayRef = super.create(overlayConfig);
|
|
23
|
+
overlayRef.addPanelClass(overlayConfig.panelClass);
|
|
24
|
+
return overlayRef;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<section-card title="Settings">
|
|
2
|
+
<form thyForm name="settings">
|
|
3
|
+
<thy-form-group thyLabelText="Preload" thyLabelPaddingTopClear="true">
|
|
4
|
+
<label thyCheckbox name="app1-preload" thyLabelText="App1 Preload" [(ngModel)]="settings.app1.preload"></label>
|
|
5
|
+
<label thyCheckbox name="app2-preload" thyLabelText="App2 Preload" [(ngModel)]="settings.app2.preload"></label>
|
|
6
|
+
</thy-form-group>
|
|
7
|
+
|
|
8
|
+
<thy-form-group thyLabelText="App1 Switch Mode" thyLabelPaddingTopClear="true">
|
|
9
|
+
<thy-radio-group name="app1SwitchMode" [(ngModel)]="settings.app1.switchMode" thyLayout="flex" required>
|
|
10
|
+
<label thyRadio thyLabelText="Default (Destroy App when not active)" thyValue="default"></label>
|
|
11
|
+
<label thyRadio thyLabelText="Coexist (Hide App when when not active)" thyValue="coexist"></label>
|
|
12
|
+
</thy-radio-group>
|
|
13
|
+
</thy-form-group>
|
|
14
|
+
|
|
15
|
+
<thy-form-group thyLabelText="App2 Switch Mode" thyLabelPaddingTopClear="true">
|
|
16
|
+
<thy-radio-group name="app2SwitchMode" [(ngModel)]="settings.app2.switchMode" thyLayout="flex" required>
|
|
17
|
+
<label thyRadio thyLabelText="Default (Destroy App when not active)" thyValue="default"></label>
|
|
18
|
+
<label thyRadio thyLabelText="Coexist (Hide App when when not active)" thyValue="coexist"></label>
|
|
19
|
+
</thy-radio-group>
|
|
20
|
+
</thy-form-group>
|
|
21
|
+
|
|
22
|
+
<thy-form-group-footer>
|
|
23
|
+
<button thyButton="primary" (thyFormSubmit)="save()">Save</button>
|
|
24
|
+
<button thyButton="link-secondary" (click)="reset()">Reset</button>
|
|
25
|
+
<button thyButton="outline-info" (click)="restore()">Restore to default</button>
|
|
26
|
+
</thy-form-group-footer>
|
|
27
|
+
<!-- <thy-form-group>
|
|
28
|
+
{{ settings | json }}
|
|
29
|
+
</thy-form-group> -->
|
|
30
|
+
</form>
|
|
31
|
+
</section-card>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Component, OnInit, HostBinding } from '@angular/core';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { ThyNotifyService } from 'ngx-tethys/notify';
|
|
4
|
+
import { ADetailComponent } from '../a-detail/a-detail.component';
|
|
5
|
+
import { AppRootContext } from '@demo/common';
|
|
6
|
+
import { CustomSettingsService, CustomSettingsInfo } from '../custom-settings.service';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'app-settings',
|
|
10
|
+
templateUrl: './settings.component.html',
|
|
11
|
+
styleUrls: ['./settings.component.scss']
|
|
12
|
+
})
|
|
13
|
+
export class SettingsComponent implements OnInit {
|
|
14
|
+
@HostBinding(`class.thy-layout-content`) isThyLayoutContent = true;
|
|
15
|
+
|
|
16
|
+
settings: CustomSettingsInfo;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
public appRootContext: AppRootContext,
|
|
20
|
+
private customSettingsService: CustomSettingsService,
|
|
21
|
+
private thyNotifyService: ThyNotifyService
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
ngOnInit() {
|
|
25
|
+
this.reset();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
save() {
|
|
29
|
+
this.customSettingsService.save(this.settings);
|
|
30
|
+
this.thyNotifyService.success(`Save success`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
reset() {
|
|
34
|
+
this.settings = {
|
|
35
|
+
...this.customSettingsService.get()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
restore() {
|
|
40
|
+
this.customSettingsService.restore();
|
|
41
|
+
this.reset();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "app1",
|
|
4
|
+
"host": "#app-host-container",
|
|
5
|
+
"selector": "app1-root-container",
|
|
6
|
+
"routerPathPrefix": "/app1",
|
|
7
|
+
"hostClass": "thy-layout",
|
|
8
|
+
"preload": false,
|
|
9
|
+
"switchMode": "default",
|
|
10
|
+
"assetsUrl": "/app1/assets/app.json",
|
|
11
|
+
"stylePathPrefix": "",
|
|
12
|
+
"styles": [],
|
|
13
|
+
"scriptPathPrefix": "/app1/assets/",
|
|
14
|
+
"scripts": ["main.js"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "app2",
|
|
18
|
+
"host": "#app-host-container",
|
|
19
|
+
"selector": "app2-root-container",
|
|
20
|
+
"routerPathPrefix": "/app2",
|
|
21
|
+
"hostClass": "thy-layout",
|
|
22
|
+
"preload": false,
|
|
23
|
+
"switchMode": "default",
|
|
24
|
+
"stylePathPrefix": "",
|
|
25
|
+
"styles": [],
|
|
26
|
+
"scriptPathPrefix": "/app2/assets/",
|
|
27
|
+
"scripts": ["main.js"]
|
|
28
|
+
}
|
|
29
|
+
]
|