view src/app/feature-extraction-menu/feature-extraction-menu.component.ts @ 46:88052122ec01

Basic select box listing all outputs from available feature extractors a la Sonic Visualiser menus.
author Lucas Thompson <dev@lucas.im>
date Mon, 05 Dec 2016 11:59:22 +0000
parents 13f5f228ed98
children 933c64ebcd13
line wrap: on
line source
import {Component, OnInit} from '@angular/core';
import {FeatureExtractionService} from "../services/feature-extraction/feature-extraction.service";

interface ExtractorInfo {
  key: string;
  name: string;
}

@Component({
  selector: 'app-feature-extraction-menu',
  templateUrl: './feature-extraction-menu.component.html',
  styleUrls: ['./feature-extraction-menu.component.css']
})
export class FeatureExtractionMenuComponent implements OnInit {

  extractors: ExtractorInfo[];

  constructor(private piperService: FeatureExtractionService) {
    this.extractors = [];
  }

  ngOnInit() {
    this.piperService.list().then(available => {
      const maxCharacterLimit = 50;
      available.available.forEach(staticData => {
        if (staticData.basicOutputInfo.length > 1)
          staticData.basicOutputInfo.forEach(output => this.extractors.push({
              key: `${staticData.key}:${output.identifier}`,
              name: `${staticData.basic.name}: ${output.name}`.substr(0, maxCharacterLimit) + '...'
            })
          );
        else
          this.extractors.push({
            key: staticData.key,
            name: staticData.basic.name.substr(0, maxCharacterLimit) + '...'
          });
      });
    });
  }

}