Intermediate commit:
- webpack build does not run successfully, typescript errors out, saying "TS2304: Cannot find name 'module'." or 'require' or 'process' in certain .ts files.
This commit is contained in:
parent
d6604351fe
commit
be51aab2ee
43 changed files with 213 additions and 53 deletions
61
src/app/app.component.ts
Normal file
61
src/app/app.component.ts
Normal file
|
@ -0,0 +1,61 @@
|
|||
import {Component, OnInit} from "@angular/core";
|
||||
import {ConverterRegistryService} from "./converterregistry.service";
|
||||
import {InputComponentManagerService} from "./inputcomponentmanager.service";
|
||||
import {Converter} from "./converter/converter";
|
||||
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
|
||||
import {Step} from "./step";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "den-app",
|
||||
templateUrl: "app.component.html",
|
||||
styleUrls: ["app.component.css"],
|
||||
providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService]
|
||||
})
|
||||
export class AppComponent extends OnInit {
|
||||
public steps:Step[] = [];
|
||||
public converters:Converter[] = [];
|
||||
|
||||
constructor(private converterRegistryService:ConverterRegistryService, private inputComponentManagerService:InputComponentManagerService) {
|
||||
super();
|
||||
}
|
||||
|
||||
convert(step:Step, $event:any):void {
|
||||
step.selectedConverter = this.converterRegistryService.getConverter($event.target.selectedOptions[0].id);
|
||||
this.update(step);
|
||||
}
|
||||
|
||||
update(step:Step):void {
|
||||
let converter:Converter = step.selectedConverter;
|
||||
|
||||
if (converter !== undefined) {
|
||||
let content:string = step.content;
|
||||
let result:string;
|
||||
try {
|
||||
result = converter.convert(content);
|
||||
} catch (error) {
|
||||
if (typeof console === "object" && typeof console.log === "function") {
|
||||
console.log(error);
|
||||
}
|
||||
step.message = error.message;
|
||||
step.error = true;
|
||||
result = null;
|
||||
}
|
||||
if (result !== null) {
|
||||
step.message = "";
|
||||
step.error = false;
|
||||
if (result !== "") {
|
||||
let nextComponent:Step = this.inputComponentManagerService.getNext(step);
|
||||
nextComponent.content = result;
|
||||
this.update(nextComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit():void {
|
||||
this.converters = this.converterRegistryService.getAllConverters();
|
||||
this.steps = this.inputComponentManagerService.getAllComponents();
|
||||
this.inputComponentManagerService.getFirst();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue