comparison src/app/feature-extraction-menu/feature-extraction-menu.component.ts @ 433:48904aa87ba3

Rudimentary mechanism for loading remote plugins, with a loading spinner. Also small clean up for stuff left over from the md-select stuff.
author Lucas Thompson <dev@lucas.im>
date Wed, 07 Jun 2017 14:51:30 +0100
parents 686cf74aa0a2
children 8f658642d031
comparison
equal deleted inserted replaced
432:5220174f2712 433:48904aa87ba3
9 import { 9 import {
10 FeatureExtractionService 10 FeatureExtractionService
11 } from '../services/feature-extraction/feature-extraction.service'; 11 } from '../services/feature-extraction/feature-extraction.service';
12 import {ListResponse} from 'piper'; 12 import {ListResponse} from 'piper';
13 import {Subscription} from 'rxjs/Subscription'; 13 import {Subscription} from 'rxjs/Subscription';
14 import {MdSelect} from '@angular/material';
15 14
16 export interface ExtractorOutputInfo { 15 export interface ExtractorOutputInfo {
17 extractorKey: string; 16 extractorKey: string;
18 combinedKey: string; 17 combinedKey: string;
19 outputId: string; 18 outputId: string;
46 45
47 private isDisabled: boolean; 46 private isDisabled: boolean;
48 private populateExtractors: (available: ListResponse) => void; 47 private populateExtractors: (available: ListResponse) => void;
49 extractors: Iterable<ExtractorInfo>; 48 extractors: Iterable<ExtractorInfo>;
50 private librariesUpdatedSubscription: Subscription; 49 private librariesUpdatedSubscription: Subscription;
50 private isLoading: boolean;
51 51
52 constructor(private piperService: FeatureExtractionService) { 52 constructor(private piperService: FeatureExtractionService) {
53 this.extractors = []; 53 this.extractors = [];
54 this.requestOutput = new EventEmitter<ExtractorOutputInfo>(); 54 this.requestOutput = new EventEmitter<ExtractorOutputInfo>();
55 this.isDisabled = true; 55 this.isDisabled = true;
67 }; 67 };
68 }); 68 });
69 acc.push({name, outputs}); 69 acc.push({name, outputs});
70 return acc; 70 return acc;
71 }, [] as ExtractorInfo[]); 71 }, [] as ExtractorInfo[]);
72 this.isLoading = false;
72 }; 73 };
73 }
74
75 private getFirstSelectedItemOrEmpty(select: MdSelect): string {
76 const selected = select.selected;
77 if (selected) {
78 return selected instanceof Array ? selected[0].value : selected.value;
79 }
80 return '';
81 } 74 }
82 75
83 ngOnInit() { 76 ngOnInit() {
84 this.librariesUpdatedSubscription = 77 this.librariesUpdatedSubscription =
85 this.piperService.librariesUpdated$.subscribe(this.populateExtractors); 78 this.piperService.librariesUpdated$.subscribe(this.populateExtractors);
94 this.requestOutput.emit(info); 87 this.requestOutput.emit(info);
95 } 88 }
96 } 89 }
97 90
98 load(): void { 91 load(): void {
92 this.isLoading = true;
99 this.piperService.updateAvailableLibraries(); 93 this.piperService.updateAvailableLibraries();
100 } 94 }
101 95
102 ngOnDestroy(): void { 96 ngOnDestroy(): void {
103 this.librariesUpdatedSubscription.unsubscribe(); 97 this.librariesUpdatedSubscription.unsubscribe();