|
1 | 1 | import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
| 2 | +import { MatDialog } from '@angular/material/dialog'; |
2 | 3 | import { BehaviorSubject, Subject, catchError, combineLatest, debounceTime, from, map, switchMap, takeUntil } from 'rxjs';
|
3 | 4 | import { Extension, ViewCreate } from 'src/app/models/view';
|
4 | 5 | import { RestClientService } from 'src/app/services/rest-client.service';
|
| 6 | +import { ErrorDialogComponent } from '../../dialogs/error-dialog/error-dialog.component'; |
5 | 7 |
|
6 | 8 | @Component({
|
7 | 9 | selector: 'app-view-create-form',
|
@@ -84,6 +86,7 @@ export class ViewCreateFormComponent implements OnInit, OnDestroy {
|
84 | 86 |
|
85 | 87 | constructor(
|
86 | 88 | private restClient: RestClientService,
|
| 89 | + public dialog: MatDialog, |
87 | 90 | ) {
|
88 | 91 | }
|
89 | 92 |
|
@@ -149,9 +152,18 @@ export class ViewCreateFormComponent implements OnInit, OnDestroy {
|
149 | 152 | }
|
150 | 153 |
|
151 | 154 | public save() {
|
152 |
| - // TODO fix model |
153 |
| - (this.view as any)['vscode-settings'] = JSON.parse(this.view.general.vscodeSettings || '{}'); |
154 |
| - this.view.general.vscodeSettings = undefined; |
| 155 | + try { |
| 156 | + // TODO fix model |
| 157 | + (this.view as any)['vscode-settings'] = JSON.parse(this.view.general.vscodeSettings || '{}'); |
| 158 | + this.view.general.vscodeSettings = undefined; |
| 159 | + } catch (error) { |
| 160 | + this.dialog.open(ErrorDialogComponent, { |
| 161 | + width: '300px', |
| 162 | + height: '150px', |
| 163 | + data: { err: 'VSCode Settings, invalid json file' }, |
| 164 | + }); |
| 165 | + return; |
| 166 | + } |
155 | 167 |
|
156 | 168 | if (this.repositoryInfo) {
|
157 | 169 | if (this.view.repo) {
|
|
0 commit comments