aboutsummaryrefslogtreecommitdiff
path: root/app/components/plan-new/plan-new.ts
diff options
context:
space:
mode:
authorRob McGinley <mcginleyr1@gmail.com>2016-06-04 10:39:56 -0400
committerRob McGinley <mcginleyr1@gmail.com>2016-06-04 10:39:56 -0400
commit8dc7986ada6631a491ff09f286a1a534e7b34a19 (patch)
tree75957a61c59ad06efcafa3ae04b622315e08dd36 /app/components/plan-new/plan-new.ts
parentffec797c18059bad36916c7593902e1906b991ce (diff)
parentd7bac26ce4a8618c4e0bba5335880c92d09acc32 (diff)
Merge branch 'master' of github.com:AlexTatiyants/pev
Diffstat (limited to 'app/components/plan-new/plan-new.ts')
-rw-r--r--app/components/plan-new/plan-new.ts21
1 files changed, 15 insertions, 6 deletions
diff --git a/app/components/plan-new/plan-new.ts b/app/components/plan-new/plan-new.ts
index 93149e2..115fa82 100644
--- a/app/components/plan-new/plan-new.ts
+++ b/app/components/plan-new/plan-new.ts
@@ -16,19 +16,28 @@ export class PlanNew {
newPlanContent: string;
newPlanQuery: string;
newPlan: IPlan;
+ validationMessage: string;
- constructor( private _router: Router, private _planService: PlanService) { }
+ constructor(private _router: Router, private _planService: PlanService) { }
submitPlan() {
+ // remove psql generated header
+ this.newPlanContent = this.newPlanContent.replace('QUERY PLAN', '');
+
+ if (!this._planService.isJsonString(this.newPlanContent)) {
+ this.validationMessage = 'The string you submitted is not valid JSON'
+ return;
+ }
+
this.newPlan = this._planService.createPlan(this.newPlanName, this.newPlanContent, this.newPlanQuery);
- this._router.navigate( ['PlanView', { id: this.newPlan.id }] );
+ this._router.navigate(['PlanView', { id: this.newPlan.id }]);
}
prefill() {
- this.newPlanName = 'Sample plan';
- this.newPlanContent = SAMPLE_JSON;
- this.newPlanQuery = SAMPLE_QUERY;
- }
+ this.newPlanName = 'Sample plan';
+ this.newPlanContent = SAMPLE_JSON;
+ this.newPlanQuery = SAMPLE_QUERY;
+ }
}
export var SAMPLE_JSON = `[
{