From d0a35b53d308be8c36eb597256d309d116c6660f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 9 Feb 2018 14:30:37 +0100 Subject: [PATCH] Implement save saving... saved! button magic. Refactor via enum --- src/app/webide/source-code.ts | 1 + src/app/webide/webide.component.html | 15 +++++++++++++-- src/app/webide/webide.component.ts | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/app/webide/source-code.ts b/src/app/webide/source-code.ts index c1ed21e..e0610ef 100644 --- a/src/app/webide/source-code.ts +++ b/src/app/webide/source-code.ts @@ -4,4 +4,5 @@ export class SourceCode { language: string; files: string[]; saved: boolean; + command: string; } diff --git a/src/app/webide/webide.component.html b/src/app/webide/webide.component.html index cfc18fa..a952aa0 100644 --- a/src/app/webide/webide.component.html +++ b/src/app/webide/webide.component.html @@ -2,7 +2,8 @@ @@ -17,7 +18,17 @@ + [class.btn-warning]="saving === true" + [class.disabled]="saving === true" +>Save + Saved! + Saving... + +Saved +Saving +Not Saved +Not Saving diff --git a/src/app/webide/webide.component.ts b/src/app/webide/webide.component.ts index a080c3a..14110fb 100644 --- a/src/app/webide/webide.component.ts +++ b/src/app/webide/webide.component.ts @@ -21,6 +21,7 @@ export class WebideComponent implements OnInit { theme = 'monokai'; files: string[]; saved = false; + saving = false; constructor(private webSocketService: WebSocketService) { } @@ -30,7 +31,7 @@ export class WebideComponent implements OnInit { this.code = event.data.content; this.language = event.data.language; this.files = event.data.files; - this.saved = event.data.saved; + if (event.data.command === 'write') { this.saved = true; this.saving = false; } }); this.requestCode(); } @@ -40,6 +41,8 @@ export class WebideComponent implements OnInit { 'command': 'write', 'content': this.code }); + this.saving = true; + this.saved = false; } requestCode() {