changeset 271:79fa2c4c0fce

Merge remote-tracking branch 'origin/master'
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 03 May 2017 08:39:03 +0100
parents 88ac87b1800e (current diff) 2e30a02b57ca (diff)
children c5867677987a bb44ef9deb42
files src/app/waveform/waveform.component.ts
diffstat 4 files changed, 28 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/feature-extraction-menu/feature-extraction-menu.component.html	Tue May 02 18:10:51 2017 +0100
+++ b/src/app/feature-extraction-menu/feature-extraction-menu.component.html	Wed May 03 08:39:03 2017 +0100
@@ -11,7 +11,7 @@
   <p>
     <button md-raised-button
             color="primary"
-            (click)="extract(extractorSelect.selected.value)"
+            (click)="extract(getFirstSelectedItemOrEmpty(extractorSelect))"
             [disabled]="disabled">Extract</button>
   </p>
   <p>
--- a/src/app/feature-extraction-menu/feature-extraction-menu.component.ts	Tue May 02 18:10:51 2017 +0100
+++ b/src/app/feature-extraction-menu/feature-extraction-menu.component.ts	Wed May 03 08:39:03 2017 +0100
@@ -11,6 +11,7 @@
 } from '../services/feature-extraction/feature-extraction.service';
 import {ListResponse} from 'piper';
 import {Subscription} from 'rxjs/Subscription';
+import {MdSelect} from '@angular/material';
 
 export interface ExtractorOutputInfo {
   extractorKey: string;
@@ -70,6 +71,14 @@
     };
   }
 
+  private getFirstSelectedItemOrEmpty(select: MdSelect): string {
+    const selected = select.selected;
+    if (selected) {
+      return selected instanceof Array ? selected[0].value : selected.value;
+    }
+    return '';
+  }
+
   ngOnInit() {
     this.piperService.list().then(this.populateExtractors);
     this.librariesUpdatedSubscription =
--- a/src/app/waveform/waveform.component.ts	Tue May 02 18:10:51 2017 +0100
+++ b/src/app/waveform/waveform.component.ts	Wed May 03 08:39:03 2017 +0100
@@ -32,21 +32,24 @@
 type Track = any;
 type Colour = string;
 
-const colours = function* () {
-  const circularColours = [
-    '#0868ac', // "sapphire blue", our waveform / header colour
-    '#c33c54', // "brick red"
-    '#17bebb', // "tiffany blue"
-    '#001021', // "rich black"
-    '#fa8334', // "mango tango"
-    '#034748' // "deep jungle green"
-  ];
+
+
+function* createColourGenerator(colours) {
   let index = 0;
-  const nColours = circularColours.length;
+  const nColours = colours.length;
   while (true) {
-    yield circularColours[index = ++index % nColours];
+    yield colours[index = ++index % nColours];
   }
-}();
+}
+
+const defaultColourGenerator = createColourGenerator([
+  '#0868ac', // "sapphire blue", our waveform / header colour
+  '#c33c54', // "brick red"
+  '#17bebb', // "tiffany blue"
+  '#001021', // "rich black"
+  '#fa8334', // "mango tango"
+  '#034748' // "deep jungle green"
+]);
 
 @Component({
   selector: 'ugly-waveform',
@@ -65,11 +68,11 @@
       if (this.featureExtractionSubscription) {
         return;
       }
-      
+
       this.featureExtractionSubscription =
         this.piperService.featuresExtracted$.subscribe(
           features => {
-            this.renderFeatures(features, colours.next().value);
+            this.renderFeatures(features, defaultColourGenerator.next().value);
           });
     } else {
       if (this.featureExtractionSubscription) {
--- a/tslint.json	Tue May 02 18:10:51 2017 +0100
+++ b/tslint.json	Wed May 03 08:39:03 2017 +0100
@@ -51,7 +51,7 @@
     "no-string-literal": false,
     "no-string-throw": true,
     "no-switch-case-fall-through": true,
-    "no-trailing-whitespace": true,
+    "no-trailing-whitespace": false,
     "no-unused-expression": true,
     "no-use-before-declare": true,
     "no-var-keyword": true,