From 5e9b85bafe0edb7653f98a49055d6f0d91a2996b Mon Sep 17 00:00:00 2001 From: Carlos Martinez Date: Fri, 11 Aug 2017 15:08:33 +0200 Subject: [PATCH 1/2] Add 'name' to schema by default --- public/app/services/simulation.ts | 10 ++++++++-- public/app/simform/simform.directive.ts | 21 +++++++++++++-------- public/app/simlist/simlist.directive.html | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/public/app/services/simulation.ts b/public/app/services/simulation.ts index c54971f..beb46fe 100644 --- a/public/app/services/simulation.ts +++ b/public/app/services/simulation.ts @@ -282,7 +282,10 @@ module App { this.$log.info('visualizing ' + name + ' at: ' + url); // Make sure the layer group exists - let groupId = task.input.ensemble + '_' + task.input.simulation; + let ensamble = task.input.ensamble || 'dynamic'; + let simulation = task.input.simulation || 'simulation'; + let groupId = ensamble + '_' + simulation; + let group = this.layerService.findGroupById(groupId); if (group === null) { let title = task.input.ensemble + ': ' + task.input.simulation; @@ -358,7 +361,10 @@ module App { let key = formItem.key; let layerId = 'input-' + task._id + '-' + key; - let groupId = task.input.ensemble + '_' + task.input.simulation; + let ensamble = task.input.ensamble || 'dynamic'; + let simulation = task.input.simulation || 'simulation'; + let groupId = ensamble + '_' + simulation; + let group = this.layerService.findGroupById(groupId); if (group === null) { let title = task.input.ensemble + ': ' + task.input.simulation; diff --git a/public/app/simform/simform.directive.ts b/public/app/simform/simform.directive.ts index 17114f4..8559519 100644 --- a/public/app/simform/simform.directive.ts +++ b/public/app/simform/simform.directive.ts @@ -108,12 +108,8 @@ module App { } // Initialize the simulation form - this.schema = {}; - this.form = []; - this.model = {}; - this.featureSubscriptions = []; + this.resetForm(); this.formLayers = []; - this.legend = ""; // Initialize custom type mapping BEFORE getting // the simulation form @@ -187,9 +183,11 @@ module App { * Reset the simulation form */ private resetForm(): void { - this.featureSubscriptions.forEach(handle => { - this.messageBusService.unsubscribe(handle); - }); + try { + this.featureSubscriptions.forEach(handle => { + this.messageBusService.unsubscribe(handle); + }); + } catch(e) { } this.featureSubscriptions = []; this.form = []; this.schema = {}; @@ -208,6 +206,13 @@ module App { this.form = data.form; this.legend = data.schema.title; + this.form.unshift('name'); // Push at the beginning + this.schema.properties['name'] = { + "type": "string", + "default": this.SimAdminService.simulationName, + "title": "Identifier" + }; + this.$scope.$broadcast('schemaFormValidate'); } else { this.resetForm(); diff --git a/public/app/simlist/simlist.directive.html b/public/app/simlist/simlist.directive.html index 9e270cf..47457f6 100644 --- a/public/app/simlist/simlist.directive.html +++ b/public/app/simlist/simlist.directive.html @@ -7,7 +7,7 @@ From 2242542b2c4beecdc16afaf110498ce0b55305c1 Mon Sep 17 00:00:00 2001 From: Carlos Martinez Date: Tue, 15 Aug 2017 13:21:14 +0200 Subject: [PATCH 2/2] Use task name instead of ensemble name --- public/app/simlist/simlist.directive.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/app/simlist/simlist.directive.ts b/public/app/simlist/simlist.directive.ts index 96c115f..0985c26 100644 --- a/public/app/simlist/simlist.directive.ts +++ b/public/app/simlist/simlist.directive.ts @@ -97,10 +97,11 @@ module App { this.tasks = response.data.rows.map(el => el.value); var start: TaskEnsemble = {}; this.tasksByEnsemble = response.data.rows.reduce(function (ensembles, cur, index): TaskEnsemble { - if (!ensembles.hasOwnProperty(cur.value['input']['ensemble'])) { - ensembles[cur.value['input']['ensemble']] = []; + var taskName = cur.value.input.ensemble || cur.value.input.name; + if (!ensembles.hasOwnProperty(taskName)) { + ensembles[taskName] = []; } - ensembles[cur.value['input']['ensemble']].push(cur.value); + ensembles[taskName].push(cur.value); return ensembles; }, start); if (this.status) {