File

src/app/database/db-display/db-display.component.ts

Description

Database display component

Implements

OnInit OnChanges

Metadata

selector app-db-display
styleUrls db-display.component.css
templateUrl ./db-display.component.html

Index

Properties
Methods
Inputs

Constructor

constructor()

Create a database display component

Inputs

builds

Input profession builds

Type: literal type[]

profName

Input profession name

Type: string

Methods

getBuild
getBuild()

Get build data associated to the selected build

Returns : ProfBuild
getOverride
getOverride()

Get override of the selected build

Returns : string
ngOnChanges
ngOnChanges()

Todo on input change

Returns : void
ngOnInit
ngOnInit()

Todo on init

Returns : void
selectBuild
selectBuild(selectedBuild: literal type)

On select build event

Parameters :
Name Type Optional Description
selectedBuild literal type no

selected build

Returns : void

Properties

Private selectedBuild
selectedBuild: literal type
Type : literal type

Selected build

import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { buildDatabase, ProfBuild } from '../../helpers/profBuild';

/**
 * Database display component
 */
@Component({
  selector: 'app-db-display',
  templateUrl: './db-display.component.html',
  styleUrls: ['./db-display.component.css']
})
export class DbDisplayComponent implements OnInit, OnChanges {

  /**
   * Input profession name
   */
  @Input() profName: string;
  /**
   * Input profession builds
   */
  @Input() builds: { name: string, id: string, overrides: string[] }[];
  /**
   * Selected build
   */
  private selectedBuild: { name: string, id: string, override: string };

  /**
   * Create a database display component
   */
  constructor() { }

  /**
   * Todo on init
   */
  ngOnInit() {
  }

  /**
   * Todo on input change
   */
  ngOnChanges() {
    this.selectedBuild = null;
    for (const key in localStorage) {
      if (localStorage.hasOwnProperty(key)) {
        if (key.includes('GW2A') && key.includes('DATA')) {
          localStorage.removeItem(key);
        }
      }
    }
  }

  /**
   * On select build event
   * @param selectedBuild selected build
   */
  selectBuild(selectedBuild: { name: string, id: string, override: string }) {
    this.selectedBuild = selectedBuild;
  }

  /**
   * Get build data associated to the selected build
   */
  getBuild(): ProfBuild {
    if (this.selectedBuild) {
      return buildDatabase.get(this.selectedBuild.id);
    }
    return null;
  }

  /**
   * Get override of the selected build
   */
  getOverride(): string {
    if (this.selectedBuild) {
      return this.selectedBuild.override;
    }
    return 'Main';
  }

}
<div *ngIf='profName && builds' class='my-db-display uk-margin-large-right uk-margin-large-left'>
  <div class='uk-flex uk-flex-center uk-margin-bottom'>
    <h2 class='uk-text-bold uk-text-center uk-margin-bottom'>{{profName | uppercase}}</h2>
  </div>

  <div class='uk-flex uk-flex-row uk-flex-between'>
    <app-db-selector [builds]="builds" [profName]="profName" (selectedBuildEmit)="selectBuild($event)"></app-db-selector>
    <div class='uk-margin-large-left my-build-display'>
      <app-display-build [build]="getBuild()" [mainOverride]="getOverride()"></app-display-build>
    </div>

  </div>

</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""