Merge pull request #15 from avatao-content/webide-directories

Implement workdir changing support on frontend
This commit is contained in:
Bokros Bálint 2018-03-09 11:23:11 +01:00 committed by GitHub
commit ecec5e9bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,7 @@
export interface SourceCode {
filename?: string;
filename: string;
content?: string;
files?: string[];
files: string[];
directory: string;
command: string;
}

View File

@ -32,14 +32,16 @@ export class WebideComponent implements OnInit {
code: string = defaultSourceCode;
language = 'javascript';
theme = 'monokai';
directory = '';
files: string[];
codeState = 'SAVED';
deployButtonState = 'DEPLOYED';
autosave = null;
command_handlers = {'reload': this.reloadHandler.bind(this),
'read': this.readHandler.bind(this),
'select': this.selectHandler.bind(this),
'write': this.writeHandler.bind(this)};
command_handlers = {'reload': this.reloadHandler.bind(this),
'read': this.readHandler.bind(this),
'select': this.selectHandler.bind(this),
'write': this.writeHandler.bind(this),
'selectdir': this.selectdirHandler.bind(this)};
constructor(private webSocketService: WebSocketService,
private changeDetectorRef: ChangeDetectorRef,
@ -64,6 +66,7 @@ export class WebideComponent implements OnInit {
updateFileData(data: SourceCode) {
this.filename = data.filename;
this.directory = data.directory;
this.code = data.content;
this.language = modelist.getModeForPath(this.filename).name;
this.files = data.files;
@ -86,6 +89,10 @@ export class WebideComponent implements OnInit {
this.setCodeState('SAVED');
}
selectdirHandler(data: SourceCode) {
this.updateFileData(data);
}
resetAutoSaveCountdown() {
if (this.autosave) {
clearInterval(this.autosave);