quintel / etmoses

Online decision support tool to create local energy situations for neighbourhoods, cities and regions with a time resolution of 15 minutes created and maintained by Quintel – Not maintained
https://moses.energytransitionmodel.com
MIT License
11 stars 3 forks source link

Switching between YAML input and Graphical input #1464

Closed grdw closed 7 years ago

grdw commented 7 years ago

I'm currently thinking about how to make a nice switch between the YAML input and the graphical input for the new topology editor.

My first approach will be a little blue text link on the bottom of the graphical editor like:

screen shot 2016-09-29 at 11 54 25

Considering this an advanced feature I don't want normal users to find it that quickly.

Also after hitting the YAML-editor button the switch should point back to the graphical editor or should it?

ChaelKruip commented 7 years ago

Also after hitting the YAML-editor button the switch should point back to the graphical editor or should it?

I think so yes.

grdw commented 7 years ago

Switching works. And synching from Graphical -> YAML works. (The other way around unfortunately doesn't work yet). There is a 'thing' which might be bad or good. So I'm leaving it up to you to decide.

This is the YAML: screen shot 2016-09-30 at 15 13 46

This is the graph: screen shot 2016-09-30 at 15 14 30

👍 Looking good and fine.


When you add a new node, the YAML will look like this: screen shot 2016-09-30 at 15 14 56

It's still valid YAML but for one, the keys are not sorted. You could for that matter also end up with this:

screen shot 2016-09-30 at 15 16 45

Still valid YAML (I guess?) but the investment costs on the bottom belong to the HV node which is a little confusing. Also I'm not sure whether or not we should display the x, y, depth and id attributes in the YAML for they make no sense. On the other hand this is a rather advanced feature and advanced feature require some technical skill so.. might also be that it's sort of nice to show these keys.

grdw commented 7 years ago

@antw might you have a suggestion to format the YAML properly? I'm using a library called jsyaml but I'm guessing it has to do with the way the Object is build up in Javascript.

For example:

{
   children: [ ... ]
}

After update info:

{
   children: [ ... ],
   initial_investment: 100
   ...
}

What I'd like is:

{
   initial_investment: 100,
   ...,
   children: [ ... ]
}

A way I'd do it is something like:

var a = { children: [], initial_investment: 100 },
    b = {};

Object.keys(a)
    .sort(function (c,d) { 
        return (c == 'children') ? 0 : -1;
    }).forEach(function(key) {  
        b[key] = a[key];
    });

console.log(b);