mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-16 05:01:56 +00:00
Merge pull request #9 from avatao-content/webide_revisit
Update WebIDE component to conform to reality and type safety
This commit is contained in:
commit
fd5e557960
@ -1,8 +1,6 @@
|
|||||||
export class SourceCode {
|
export interface SourceCode {
|
||||||
filename: string;
|
filename?: string;
|
||||||
content: string;
|
content?: string;
|
||||||
language: string;
|
files?: string[];
|
||||||
files: string[];
|
|
||||||
saved: boolean;
|
|
||||||
command: string;
|
command: string;
|
||||||
}
|
}
|
||||||
|
@ -48,31 +48,31 @@ export class WebideComponent implements OnInit {
|
|||||||
|
|
||||||
subscribeWS() {
|
subscribeWS() {
|
||||||
this.webSocketService.observeAnchor<SourceCode>(this.anchor_id).subscribe((event) => {
|
this.webSocketService.observeAnchor<SourceCode>(this.anchor_id).subscribe((event) => {
|
||||||
this.command_handlers[event.data.command](event);
|
this.command_handlers[event.data.command](event.data);
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFileData(event: any) {
|
updateFileData(data: SourceCode) {
|
||||||
this.filename = event.data.filename;
|
this.filename = data.filename;
|
||||||
this.code = event.data.content;
|
this.code = data.content;
|
||||||
this.language = modelist.getModeForPath(this.filename).name;
|
this.language = modelist.getModeForPath(this.filename).name;
|
||||||
this.files = event.data.files;
|
this.files = data.files;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectHandler(event: any) {
|
selectHandler(data: SourceCode) {
|
||||||
this.updateFileData(event);
|
this.updateFileData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadHandler(event: any) {
|
reloadHandler(data: SourceCode) {
|
||||||
this.requestCode();
|
this.requestCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
readHandler(event: any) {
|
readHandler(data: SourceCode) {
|
||||||
this.updateFileData(event);
|
this.updateFileData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeHandler(event: any) {
|
writeHandler(data: SourceCode) {
|
||||||
this.saveButtonState = 'SAVED';
|
this.saveButtonState = 'SAVED';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user