File

src/app/bosses/bosses.component.ts

Description

Bosses component

Implements

OnInit

Metadata

selector app-bosses
styleUrls bosses.component.css
templateUrl ./bosses.component.html

Index

Properties
Methods

Constructor

constructor(http: HttpClient)

Create a boss component

Parameters :
Name Type Optional Description
http HttpClient no

To load json

Methods

ngOnInit
ngOnInit()

Todo on init

Returns : void
onSelect
onSelect(boss: Boss)

On select boss event

Parameters :
Name Type Optional Description
boss Boss no

The selected boss

Returns : void
onSelectDisplay
onSelectDisplay(display: string)

On select display event

Parameters :
Name Type Optional Description
display string no

The selected display - composition or mechanics

Returns : void

Properties

Public bosses
bosses: Boss[]
Type : Boss[]
Default value : []

Array of boss data

Private compoStyle
compoStyle: object
Type : object
Default value : { 'background-image': 'url(assets/compo.png)', 'width': '250px', 'heigth': '100px', 'background-repeat': 'no-repeat', 'background-size': 'cover' }

Style of the composition button

Private logsStyle
logsStyle: object
Type : object
Default value : { 'background-image': 'url(assets/logs.png)', 'width': '250px', 'heigth': '100px', 'background-repeat': 'no-repeat', 'background-size': 'cover' }

Style of the logs button

Public selectedBoss
selectedBoss: Boss
Type : Boss

Selected boss

Private selectedDisplay
selectedDisplay: string
Type : string

Selected display mode - composition or mechanics

Private stratStyle
stratStyle: object
Type : object
Default value : { 'background-image': 'url(assets/raid.jpg)', 'width': '250px', 'heigth': '100px', 'background-repeat': 'no-repeat', 'background-size': 'cover' }

Style of the mechanics button

import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';

import { Boss } from '../helpers/boss';

import { HttpClient } from '@angular/common/http';

/*$.getJSON('assets/logs.json', function (data) {
  if (!data) {
    return;
  }
  console.log('logs json loaded');
  for (let i = 0; i < BOSSES.length; i++) {
    BOSSES[i].buildLogs(data);
  }
  console.log('logs done');
});*/

/**
 * Bosses component
 */
@Component({
  selector: 'app-bosses',
  templateUrl: './bosses.component.html',
  styleUrls: ['./bosses.component.css']
})
export class BossesComponent implements OnInit {
  /**
   * Array of boss data
   */
  public bosses: Boss[] = [];
  /**
   * Selected boss
   */
  public selectedBoss: Boss;
  /**
   * Selected display mode - composition or mechanics
   */
  private selectedDisplay: string;
  /**
   * Style of the logs button
   */
  private logsStyle = {
    'background-image': 'url(assets/logs.png)', 'width': '250px', 'heigth': '100px',
    'background-repeat': 'no-repeat', 'background-size': 'cover'
  };
  /**
   * Style of the composition button
   */
  private compoStyle = {
    'background-image': 'url(assets/compo.png)', 'width': '250px', 'heigth': '100px',
    'background-repeat': 'no-repeat', 'background-size': 'cover'
  };
  /**
   * Style of the mechanics button
   */
  private stratStyle = {
    'background-image': 'url(assets/raid.jpg)', 'width': '250px', 'heigth': '100px',
    'background-repeat': 'no-repeat', 'background-size': 'cover'
  };

  /**
   * Create a boss component
   * @param http To load json
   */
  constructor(private http: HttpClient) {
    const _this = this;
    const localBoss = localStorage.getItem('selectedBoss') ? localStorage.getItem('selectedBoss') : null;
    this.http.get('assets/bosses.json')
      .subscribe(function (data: { bosses: any[] }) {
        console.log('bosses.json loaded');
        _this.bosses = data.bosses.map(bossData => new Boss(bossData));
        console.log('bosses done');
        _this.http.get('assets/logs.json')
          .subscribe(function (logs: any) {
            console.log('logs json loaded');
            for (let i = 0; i < _this.bosses.length; i++) {
              _this.bosses[i].buildLogs(logs);
              if (_this.bosses[i].shortName === localBoss) {
                _this.selectedBoss = _this.bosses[i];
              }
            }
            console.log('logs done');
            if (!localBoss) {
              _this.selectedBoss = _this.bosses[0];
            }
          });
      });
    this.selectedDisplay = localStorage.getItem('selectedDisplay') ? localStorage.getItem('selectedDisplay') : 'compo';
  }

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

  /**
   * On select boss event
   * @param boss The selected boss
   */
  onSelect(boss: Boss): void {
    this.selectedBoss = boss;
    localStorage.setItem('selectedBoss', this.selectedBoss.shortName);
  }

  /**
   * On select display event
   * @param display The selected display - composition or mechanics
   */
  onSelectDisplay(display: string): void {
    this.selectedDisplay = display;
    localStorage.setItem('selectedDisplay', this.selectedDisplay);
  }

}
<h1 class="uk-text-center uk-text-bold">
  Les Boss de raids
</h1>

<ul *ngIf="bosses.length > 0">
  <div class="uk-flex uk-flex-wrap uk-margin-top">
    <div *ngFor="let boss of bosses" class="uk-margin-top uk-margin-small-left uk-margin-small-right uk-transition-toggle">
      <span (click)="onSelect(boss)" class="uk-border-rounded selector bosses uk-background-center-center uk-flex uk-flex-around uk-flex-middle"
        [class.selected]="boss === selectedBoss" [ngStyle]="boss.style">
        <div class="my-button-title uk-text-bold uk-text-center uk-transition-fade">
          {{boss.buttonName | uppercase}}
        </div>
      </span>
    </div>
  </div>

</ul>

<hr class="uk-divider-icon">

<div *ngIf="selectedBoss">
  <h2 class="uk-text-center uk-text-bold">{{ selectedBoss.displayName | uppercase }}</h2>
  <div class='uk-flex uk-flex-center uk-flex-middle uk-margin-top'>
    <span (click)="onSelectDisplay('compo')" [class.selected]="selectedDisplay === 'compo'" [ngStyle]="compoStyle" class="uk-transition-toggle uk-border-rounded selector switcher uk-background-center-center uk-flex uk-flex-around uk-flex-middle uk-margin-small-right uk-margin-small-left">
      <div class="my-button-title uk-text-bold uk-text-center uk-transition-fade">
        Composition
      </div>
    </span>
    <span (click)="onSelectDisplay('logs')" [class.selected]="selectedDisplay === 'logs'" [ngStyle]="logsStyle" class="uk-transition-toggle uk-border-rounded selector switcher uk-background-center-center uk-flex uk-flex-around uk-flex-middle uk-margin-small-right uk-margin-small-left">
      <div class="my-button-title uk-text-bold uk-text-center uk-transition-fade">
        Logs
      </div>
    </span>
    <span (click)="onSelectDisplay('strat')" [class.selected]="selectedDisplay === 'strat'" [ngStyle]="stratStyle" class="uk-transition-toggle uk-border-rounded selector switcher uk-background-center-center uk-flex uk-flex-around uk-flex-middle uk-margin-small-right uk-margin-small-left">
      <div class="my-button-title uk-text-bold uk-text-center uk-transition-fade">
        Mécaniques
      </div>
    </span>
  </div>
  <div [ngSwitch]="selectedDisplay">
    <div *ngSwitchCase="'compo'">
      <app-composition-detail [boss]="selectedBoss"></app-composition-detail>
    </div>
    <div *ngSwitchCase="'logs'">
      <app-logs-detail [boss]="selectedBoss"></app-logs-detail>
    </div>
    <div *ngSwitchCase="'strat'">
      <app-strat [boss]="selectedBoss"></app-strat>
    </div>
  </div>


</div>
<a href="#" style="background-color: rgba(250,250,250,0.4)" uk-totop uk-scroll title="retour top" uk-tooltip></a>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""