Mercurial > hg > ugly-duckling
comparison src/app/app.component.ts @ 427:b0415f8837d9
Setup extraction menu with a callback for closing the menu on extraction. Place the tray outside the main body to avoid weird scrolling issues when there are enough cards to scroll.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Tue, 06 Jun 2017 22:13:34 +0100 |
parents | 3eab26a629e1 |
children | d2af14e0b949 |
comparison
equal
deleted
inserted
replaced
426:8fee76ab8e90 | 427:b0415f8837d9 |
---|---|
1 import {Component, OnDestroy} from '@angular/core'; | 1 import {Component, OnDestroy, ViewChild} from '@angular/core'; |
2 import { | 2 import { |
3 AudioPlayerService, | 3 AudioPlayerService, |
4 AudioResourceError, AudioResource | 4 AudioResourceError, AudioResource |
5 } from './services/audio-player/audio-player.service'; | 5 } from './services/audio-player/audio-player.service'; |
6 import {FeatureExtractionService} from './services/feature-extraction/feature-extraction.service'; | 6 import {FeatureExtractionService} from './services/feature-extraction/feature-extraction.service'; |
12 AnalysisItem, | 12 AnalysisItem, |
13 isRootAudioItem, | 13 isRootAudioItem, |
14 Item, PendingAnalysisItem, PendingRootAudioItem, RootAudioItem | 14 Item, PendingAnalysisItem, PendingRootAudioItem, RootAudioItem |
15 } from './analysis-item/analysis-item.component'; | 15 } from './analysis-item/analysis-item.component'; |
16 import {OnSeekHandler} from './playhead/PlayHeadHelpers'; | 16 import {OnSeekHandler} from './playhead/PlayHeadHelpers'; |
17 import {ActionTrayComponent} from "./actions/action-tray.component"; | |
17 | 18 |
18 class PersistentStack<T> { | 19 class PersistentStack<T> { |
19 private stack: T[]; | 20 private stack: T[]; |
20 private history: T[][]; | 21 private history: T[][]; |
21 | 22 |
69 selector: 'ugly-root', | 70 selector: 'ugly-root', |
70 templateUrl: './app.component.html', | 71 templateUrl: './app.component.html', |
71 styleUrls: ['./app.component.css'] | 72 styleUrls: ['./app.component.css'] |
72 }) | 73 }) |
73 export class AppComponent implements OnDestroy { | 74 export class AppComponent implements OnDestroy { |
75 @ViewChild(ActionTrayComponent) tray: ActionTrayComponent; | |
74 audioBuffer: AudioBuffer; // TODO consider revising | 76 audioBuffer: AudioBuffer; // TODO consider revising |
75 canExtract: boolean; | 77 canExtract: boolean; |
76 private onAudioDataSubscription: Subscription; | 78 private onAudioDataSubscription: Subscription; |
77 private onProgressUpdated: Subscription; | 79 private onProgressUpdated: Subscription; |
78 private analyses: PersistentStack<Item>; // TODO some immutable state container describing entire session | 80 private analyses: PersistentStack<Item>; // TODO some immutable state container describing entire session |
79 private nRecordings: number; // TODO user control for naming a recording | 81 private nRecordings: number; // TODO user control for naming a recording |
80 private countingId: number; // TODO improve uniquely identifying items | 82 private countingId: number; // TODO improve uniquely identifying items |
81 private rootAudioItem: RootAudioItem; | 83 private rootAudioItem: RootAudioItem; |
82 private onSeek: OnSeekHandler; | 84 private onSeek: OnSeekHandler; |
85 private closeTray: () => void; | |
83 | 86 |
84 constructor(private audioService: AudioPlayerService, | 87 constructor(private audioService: AudioPlayerService, |
85 private featureService: FeatureExtractionService, | 88 private featureService: FeatureExtractionService, |
86 private iconRegistry: MdIconRegistry, | 89 private iconRegistry: MdIconRegistry, |
87 private sanitizer: DomSanitizer) { | 90 private sanitizer: DomSanitizer) { |
140 {progress: progress.value} | 143 {progress: progress.value} |
141 ) | 144 ) |
142 ); | 145 ); |
143 } | 146 } |
144 ); | 147 ); |
148 this.closeTray = () => { | |
149 this.tray.toggle(); | |
150 }; | |
145 } | 151 } |
146 | 152 |
147 onFileOpened(file: File | Blob) { | 153 onFileOpened(file: File | Blob) { |
148 this.canExtract = false; | 154 this.canExtract = false; |
149 const url = this.audioService.loadAudio(file); | 155 const url = this.audioService.loadAudio(file); |