@WidgetComponent

nm-imarket-progress

File

src/app/shared/widgets/apps/imarket/progress/imarket-progress.component.ts

Implements

AfterViewInit OnInit

Metadata

selector nm-imarket-progress
styleUrls imarket-progress.component.scss
templateUrl ./imarket-progress.component.html

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

constructor(widgetFrameService: WidgetframeService, cdr: ChangeDetectorRef)
Parameters :
Name Type Optional
widgetFrameService WidgetframeService no
cdr ChangeDetectorRef no

Methods

Protected configureWidget
configureWidget(configuration: WidgetConfig)
Decorators : WidgetConfigure
Parameters :
Name Type Optional
configuration WidgetConfig no
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
Public ngOnInit
ngOnInit()
Returns : void
Public sortNull
sortNull()
Returns : number

Properties

Public _id
_id: string
Type : string
Decorators : WidgetId
Public configuration
configuration: WidgetConfig
Type : WidgetConfig
Decorators : WidgetConfiguration
Public current
current: null
Type : null
Default value : null
Public currentTitle
currentTitle: string
Type : string
Public emptyMessage
emptyMessage: string
Type : string
Public infotext
infotext: string
Type : string
Private inputChannel
inputChannel: ReplaySubject<any>
Type : ReplaySubject<any>
Default value : new ReplaySubject<any>(1)
Decorators : WidgetInput
Public last
last: null
Type : null
Default value : null
Public lastTitle
lastTitle: string
Type : string
Public title
title: string
Type : string
unsubscribe
unsubscribe:
Default value : NgUnsubscribe.create()
Public wikiLink
wikiLink: string
Type : string
Public withHeader
withHeader: boolean
Type : boolean
Default value : false
import {
  AfterViewInit,
  ChangeDetectorRef,
  Component,
  Input,
  OnInit,
} from "@angular/core";
import {
  WidgetComponent,
  WidgetConfiguration,
  WidgetConfigure,
  WidgetId,
  WidgetInput,
} from "../../../widget.metadata";
import { getOrDefault, WidgetConfig } from "../../../widget.configuration";
import { ReplaySubject } from "rxjs";
import { NgUnsubscribe } from "../../../../ng-unsubscribe";
import { WidgetframeService } from "../../../widgetframe/widgetframe.service";

@WidgetComponent("nm-imarket-progress")
@Component({
  selector: "nm-imarket-progress",
  viewProviders: [],
  templateUrl: "./imarket-progress.component.html",
  styleUrls: ["./imarket-progress.component.scss"],
  providers: [],
})
export class IMarketProgressComponent implements AfterViewInit, OnInit {
  @WidgetId()
  public _id: string;

  @WidgetConfiguration()
  public configuration: WidgetConfig;

  @WidgetInput("uri")
  private inputChannel: ReplaySubject<any> = new ReplaySubject<any>(1);

  public wikiLink: string;
  public infotext: string;
  public title: string;
  public currentTitle: string;
  public lastTitle: string;
  public emptyMessage: string;
  public withHeader: boolean = false;

  public current = null;
  public last = null;

  unsubscribe = NgUnsubscribe.create();

  constructor(
    protected widgetFrameService: WidgetframeService,
    private cdr: ChangeDetectorRef
  ) {}

  @WidgetConfigure()
  protected configureWidget(configuration: WidgetConfig) {
    this.infotext = this.configuration.configuration["infoText"];
    this.title = this.configuration.configuration["title"];
    this.wikiLink = this.configuration.configuration["wikiLink"];
    this.currentTitle = this.configuration.configuration["currentTitle"];
    this.lastTitle = this.configuration.configuration["lastTitle"];
    this.emptyMessage = this.configuration.configuration["emptyMessage"];
    this.withHeader = getOrDefault(
      this.configuration.configuration.withHeader,
      true
    );

    this.inputChannel.subscribe((value) => {
      this.widgetFrameService.getData(value).subscribe((data) => {
        if (data && data.current) {
          this.current = data.current;
        } else {
          this.current = null;
        }
        if (data && data.last) {
          this.last = data.last;
        } else {
          this.last = null;
        }
        this.cdr.detectChanges();
      });
    });
  }

  public ngOnInit() {}

  public sortNull() {
    return 0;
  }

  ngAfterViewInit() {}
}
<nm-widgetframe
  widgetId="{{ _id }}"
  [header]="configuration.configuration['header']"
  [configuration]="configuration"
  [width]="configuration.configuration['width']"
  [infoTitle]="title"
  [infoText]="infotext"
  [infoPlacement]="'bottom'"
  [toolbarInvisible]="!withHeader"
  [wikiLink]="wikiLink"
  [isCollapsible]="false"
>
  <div slot="title" class="nm-widgetframe__title" style="width: 100%">
    <span style="float: left"> {{ title | translate }} </span>
  </div>
  <div slot="content" class="nm-widgetframe__content">
    <div *ngIf="!current && !last">{{ emptyMessage | translate }}</div>

    <div *ngIf="current || last">
      <div id="imarket-current-run" class="ng-cloak" *ngIf="current" ng-cloak>
        <div class="progress-title">{{ currentTitle | translate }}</div>
        <div class="sections small row">
          <span
            *ngFor="let state of current | keyvalue: sortNull"
            class="section {{ state.value.state }}"
          >
            <div class="section-content">
              <span class="section-name">{{ state.key }}</span
              ><br />
              <span class="section-time" *ngIf="state?.value?.time">{{
                state.value.time
              }}</span>
            </div>
          </span>
        </div>
      </div>
      <br />
      <div id="imarket-last-run" class="ng-cloak" *ngIf="last" ng-cloak>
        <div class="progress-title">{{ lastTitle | translate }}</div>
        <div class="sections small row ng-cloak" ng-cloak>
          <span
            *ngFor="let state of last | keyvalue: sortNull"
            class="section {{ state.value.state }}"
          >
            <div class="section-content">
              <span class="section-name">{{ state.key }}</span
              ><br />
              <span class="section-time" *ngIf="state?.value?.time">{{
                state.value.time
              }}</span>
            </div>
          </span>
        </div>
      </div>
    </div>
  </div>
</nm-widgetframe>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""