@WidgetComponent

nm-page

File

src/app/shared/widgets/page.component.ts

Description

Deprecated in favor of "nm-app-root" (see AppRootComponent)

Implements

OnChanges OnDestroy

Example

Metadata

providers { : , : , : [, ], }
selector nm-page
template
<nm-container [configuration]="config | async" [parent]="null" id="root"></nm-container><br><nm-scrollToTop> </nm-scrollToTop>

Index

Widget inputs
Widget outputs
Properties
Methods
Inputs

Constructor

constructor(authhttp: HttpClient, _widgetRegistry: WidgetRegistry, _changeDetectorRef: ChangeDetectorRef)
Parameters :
Name Type Optional
authhttp HttpClient no
_widgetRegistry WidgetRegistry no
_changeDetectorRef ChangeDetectorRef no

Inputs

controller

Sets page controller to be registered.

href

Sets href for page to be loaded.

Type: string

input-parameters

Sets input parameters.

Methods

ngOnChanges
ngOnChanges(changes: any)
Parameters :
Name Type Optional
changes any no
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

_controller
_controller: WidgetController
Type : WidgetController
Private _href
_href: string
Type : string
_inputParameters
_inputParameters: InputParameterDefinition
Type : InputParameterDefinition
config
config:
Default value : new Subject<WidgetConfig>()

Accessors

href
sethref(href: string)

Sets href for page to be loaded.

Parameters :
Name Type Optional
href string no
Returns : void
inputParameters
setinputParameters(inputParameters: )

Sets input parameters.

Parameters :
Name Optional
inputParameters no
Returns : void
controller
setcontroller(controller: )

Sets page controller to be registered.

Parameters :
Name Optional
controller no
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();
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""