File

src/app/components/app-effects-selector/app-effects-selector.component.ts

Implements

OnInit

Metadata

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

Index

Properties
Methods

Constructor

constructor(effectServ: EffectsService, playerServ: PlayerService)
Parameters :
Name Type Optional
effectServ EffectsService No
playerServ PlayerService No

Methods

change
change(i: , j: )
Parameters :
Name Optional
i No
j No
Returns : void

Properties

availableEffects
availableEffects: any
Type : any
effects
effects:
Default value : [null, null] as any
effectsNum
effectsNum: number
Type : number
Default value : 6
selectedEffects
selectedEffects: any
Type : any
import { Component, OnInit } from '@angular/core';
import { EffectsService } from '../../services/effects.service';
import { PlayerService } from '../../services/player.service';
@Component({
  selector: 'app-effects-selector',
  templateUrl: './app-effects-selector.component.html',
  styleUrls: ['./app-effects-selector.component.css']
})
export class AppEffectsSelectorComponent implements OnInit {
  constructor(private effectServ: EffectsService, private playerServ: PlayerService) {
    this.effects = JSON.parse(JSON.stringify(this.playerServ.effects));
    this.availableEffects = this.effectServ.getEffects();
    this.selectedEffects = this.effects.map(c => c.map(a => this.availableEffects.find(b => a.id === b.id).id));
  }
  effectsNum = 6;
  effects = [null, null] as any;
  availableEffects: any;
  selectedEffects: any;
  ngOnInit() {
    this.playerServ.effects$[0].subscribe(effects => {
      this.effects[0] = JSON.parse(JSON.stringify(effects));
      this.selectedEffects = this.effects.map(c => c.map(a => this.availableEffects.find(b => a.id === b.id).id));
    });
    this.playerServ.effects$[1].subscribe(effects => {
      this.effects[1] = JSON.parse(JSON.stringify(effects));
      this.selectedEffects = this.effects.map(c => c.map(a => this.availableEffects.find(b => a.id === b.id).id));
    });
  }
  change(i, j) {
    this.playerServ.saveEffects(
      i,
      j,
      JSON.parse(JSON.stringify(this.availableEffects.find(a => Number(a.id) === Number(this.selectedEffects[i][j]))))
    );
  }
}
<!-- 
    This file is part of Web Virtual DJ.

    Web Virtual DJ is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Web Virtual DJ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Web Virtual DJ.  If not, see <https://www.gnu.org/licenses/>.
-->
<div class="settings-container" id="app_effects_creator">
  <div class="question-container">
    <div class="effects-container" *ngFor="let deck of effects;let i=index">
      <div class="question-label">{{ 'SETTINGS.EFFDECK' | translate }} {{i+1}}</div>
      <table>
        <tr *ngFor="let effect of deck;let j=index">
          <td>{{ 'SETTINGS.EFFECT' | translate }} {{j+1}}</td>
          <td>
            <select [(ngModel)]="selectedEffects[i][j]" (ngModelChange)="change(i,j)">
              <option *ngFor="let availableEffect of availableEffects" [value]="availableEffect.id">
                {{availableEffect.name}}</option>
            </select>
          </td>
        </tr>
      </table>
    </div>
  </div>
</div>

result-matching ""

    No results matching ""