(true);
@@ -63,6 +62,28 @@ export class EditorComponent {
},
{ allowSignalWrites: true }
);
+
+ effect(async () => {
+ const selectedFile = this.selectedFile();
+ console.log('selected file' + selectedFile);
+ if (selectedFile) {
+ const fileContents = await readTextFile(selectedFile);
+ try {
+ const parsed = JSON.parse(fileContents);
+ this.values.set(parsed);
+ } catch (err) {
+ console.error(
+ `Failed to parse contents of file ${selectedFile}`,
+ err
+ );
+ this.snackBar.open(
+ `Failed to parse contents of file ${selectedFile}, please check the file is correctly formatted`,
+ 'Dismiss',
+ { duration: 5000 }
+ );
+ }
+ }
+ });
}
protected updateValue(key: string, value: any) {
diff --git a/src/app/file-tree/file-tree.component.html b/src/app/file-tree/file-tree.component.html
index 07c8ec5..de5fcd3 100644
--- a/src/app/file-tree/file-tree.component.html
+++ b/src/app/file-tree/file-tree.component.html
@@ -1,4 +1,6 @@
-@if(workspaceName()) {workspaceName()} @else { No Worspace Selected}
+
+ @if(workspaceName()) { {{ workspaceName() }} } @else { No Worspace Selected}
+
@if(!selectedDirectory()) {