nm-page
src/app/shared/widgets/page.component.ts
Deprecated in favor of "nm-app-root" (see AppRootComponent)
providers |
{
: , : , : [, ],
}
|
selector | nm-page |
template |
|
Widget inputs |
Widget outputs |
Properties |
|
Methods |
Inputs |
constructor(authhttp: HttpClient, _widgetRegistry: WidgetRegistry, _changeDetectorRef: ChangeDetectorRef)
|
||||||||||||
Defined in src/app/shared/widgets/page.component.ts:62
|
||||||||||||
Parameters :
|
controller
|
Sets page controller to be registered. |
Defined in src/app/shared/widgets/page.component.ts:60
|
href
|
Sets href for page to be loaded.
Type: |
Defined in src/app/shared/widgets/page.component.ts:44
|
input-parameters
|
Sets input parameters. |
Defined in src/app/shared/widgets/page.component.ts:52
|
ngOnChanges | ||||||
ngOnChanges(changes: any)
|
||||||
Defined in src/app/shared/widgets/page.component.ts:70
|
||||||
Parameters :
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Defined in src/app/shared/widgets/page.component.ts:93
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in src/app/shared/widgets/page.component.ts:88
|
Returns :
void
|
_controller |
_controller:
|
Type : WidgetController
|
Defined in src/app/shared/widgets/page.component.ts:38
|
Private _href |
_href:
|
Type : string
|
Defined in src/app/shared/widgets/page.component.ts:35
|
_inputParameters |
_inputParameters:
|
Type : InputParameterDefinition
|
Defined in src/app/shared/widgets/page.component.ts:37
|
config |
config:
|
Default value : new Subject<WidgetConfig>()
|
Defined in src/app/shared/widgets/page.component.ts:36
|
href | ||||||
sethref(href: string)
|
||||||
Defined in src/app/shared/widgets/page.component.ts:44
|
||||||
Sets href for page to be loaded.
Parameters :
Returns :
void
|
inputParameters | ||||
setinputParameters(inputParameters: )
|
||||
Defined in src/app/shared/widgets/page.component.ts:52
|
||||
Sets input parameters.
Parameters :
Returns :
void
|
controller | ||||
setcontroller(controller: )
|
||||
Defined in src/app/shared/widgets/page.component.ts:60
|
||||
Sets page controller to be registered.
Parameters :
Returns :
void
|
import { map } from "rxjs/operators";
import {
Component,
OnChanges,
OnDestroy,
Input,
ChangeDetectorRef,
} from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Subject } from "rxjs";
import { WidgetRegistry, widgetRegistryFactory } from "./widget.registry";
import { WidgetConfig } from "./widget.configuration";
import { InputParameterDefinition } from "./widget.descriptor";
import { WidgetController } from "./widget.controller";
import { HalService } from "../components/hal/hal.service";
import { CurrentLocaleService } from "../components/i18n/currentLocale.service";
/**
* Deprecated in favor of "nm-app-root" (see AppRootComponent)
* @deprecated
*/
@Component({
selector: "nm-page",
template:
'<nm-container [configuration]="config | async" [parent]="null" id="root"></nm-container><br><nm-scrollToTop> </nm-scrollToTop>',
providers: [
{
provide: WidgetRegistry,
useFactory: widgetRegistryFactory,
deps: [HalService, CurrentLocaleService],
},
],
})
export class NmPageComponent implements OnChanges, OnDestroy {
private _href: string;
config = new Subject<WidgetConfig>();
_inputParameters: InputParameterDefinition;
_controller: WidgetController;
/**
* Sets href for page to be loaded.
*/
@Input("href")
set href(href: string) {
this._href = href;
}
/**
* Sets input parameters.
*/
@Input("input-parameters")
set inputParameters(inputParameters: InputParameterDefinition) {
this._inputParameters = inputParameters;
}
/**
* Sets page controller to be registered.
*/
@Input("controller")
set controller(controller: WidgetController) {
this._controller = controller;
}
constructor(
private authhttp: HttpClient,
private _widgetRegistry: WidgetRegistry,
private _changeDetectorRef: ChangeDetectorRef
) {}
ngOnChanges(changes: any): void {
if (!this._href) {
return;
}
this.authhttp
.get(this._href)
.pipe(map((page) => page["_embedded"]["root"]))
.subscribe(
(config) => {
this._widgetRegistry.parseConfiguration(config);
this.config.next(config);
this._changeDetectorRef.detectChanges();
},
(err) => this.config.error(err)
);
}
ngOnInit() {
this._widgetRegistry.registerInputParameters(this._inputParameters);
this._widgetRegistry.registerController(this._controller);
}
ngOnDestroy() {
this._widgetRegistry.dispose();
}
}