From 3baff4ef1d34fde315ff349482d316468d17db8c Mon Sep 17 00:00:00 2001 From: mtangaro Date: Mon, 15 Apr 2019 12:21:51 +0000 Subject: [PATCH 01/24] add rich form --- app/routes.py | 30 ++++++++++++++++-- app/templates/createdep.html | 50 ++++++----------------------- app/templates/default_form.html | 37 ++++++++++++++++++++++ app/templates/rich_form.html | 56 +++++++++++++++++++++++++++++++++ app/templates/rich_input.html | 47 +++++++++++++++++++++++++++ app/templates/scheduling.html | 25 +++++++++++++++ 6 files changed, 202 insertions(+), 43 deletions(-) create mode 100644 app/templates/default_form.html create mode 100644 app/templates/rich_form.html create mode 100644 app/templates/rich_input.html create mode 100644 app/templates/scheduling.html diff --git a/app/routes.py b/app/routes.py index 8aa20f4e9..df48a899b 100644 --- a/app/routes.py +++ b/app/routes.py @@ -28,6 +28,9 @@ def avatar(email, size): if name[0] != '.': toscaTemplates.append( os.path.relpath(os.path.join(path, name), toscaDir )) +if app.config.get('TOSCA_PARAMETERS_DIR') is not None: + tosca_pars_dir=app.config.get('TOSCA_PARAMETERS_DIR') + "/" + orchestratorUrl = app.config.get('ORCHESTRATOR_URL') slamUrl = app.config.get('SLAM_URL') cmdbUrl = app.config.get('CMDB_URL') @@ -188,13 +191,36 @@ def depcreate(): inputs={} if 'inputs' in template['topology_template']: inputs = template['topology_template']['inputs'] - + + ## add parameters code here + enable_rich_form = False + tabs={} + if tosca_pars_dir is not None: + for path, subdirs, files in os.walk(tosca_pars_dir): + for name in files: + if fnmatch(name, os.path.splitext(selected_tosca)[0]+"*.parameters.yml") or fnmatch(name, os.path.splitext(selected_tosca)[0]+"*.parameters.yaml"): + # skip hidden files + if name[0] != '.': + tosca_pars_file = os.path.join(path, name) + with io.open(tosca_pars_file) as pars_file: + enable_rich_form = True + pars_data = yaml.load(pars_file) + inputs = pars_data["inputs"] + if( "tabs" in pars_data ): tabs = pars_data["tabs"] + description = "N/A" if 'description' in template: description = template['description'] slas = get_slas(access_token) - return render_template('createdep.html', templates=toscaTemplates, selectedTemplate=selected_tosca, description=description, inputs=inputs, slas=slas) + return render_template('createdep.html', + templates=toscaTemplates, + selectedTemplate=selected_tosca, + description=description, + inputs=inputs, + slas=slas, + enable_rich_form=enable_rich_form, + tabs=tabs) def add_sla_to_template(template, sla_id): # Add the placement policy diff --git a/app/templates/createdep.html b/app/templates/createdep.html index 640286a72..5af4d9b8d 100644 --- a/app/templates/createdep.html +++ b/app/templates/createdep.html @@ -27,6 +27,8 @@ +
+
{% if selectedTemplate is defined %} @@ -37,48 +39,13 @@

Template: {{selectedTemplate}}

Description: {{description}} {% endif %} - - {% if inputs|length > 0 %} -

Set input values:

+ + {% if enable_rich_form %} + {% include 'rich_form.html' %} + {% else %} + {% include 'default_form.html' %} {% endif %} -
- - {% if inputs|length > 0 %} - {% for key, value in inputs.items() %} -
- - - {{value.description}} -
- {% endfor %} - {% endif %} -
-

Configure scheduling:

- - -
-
- -
-
-

- - -

- -
+ {% endif %} @@ -87,6 +54,7 @@

Set input values:

display: none; } + From 2b5e3b32b5ef5e3150f91c16dae8b0e369b97d30 Mon Sep 17 00:00:00 2001 From: mtangaro Date: Tue, 16 Apr 2019 14:50:34 +0000 Subject: [PATCH 08/24] change enable_config_form variable --- app/routes.py | 6 +++--- app/templates/createdep.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/routes.py b/app/routes.py index fa73066ff..7744aeefc 100644 --- a/app/routes.py +++ b/app/routes.py @@ -193,7 +193,7 @@ def depcreate(): inputs = template['topology_template']['inputs'] ## add parameters code here - enable_rich_form = False + enable_config_form = False tabs={} if tosca_pars_dir is not None: for path, subdirs, files in os.walk(tosca_pars_dir): @@ -203,7 +203,7 @@ def depcreate(): if name[0] != '.': tosca_pars_file = os.path.join(path, name) with io.open(tosca_pars_file) as pars_file: - enable_rich_form = True + enable_config_form = True pars_data = yaml.load(pars_file) inputs = pars_data["inputs"] if( "tabs" in pars_data ): tabs = pars_data["tabs"] @@ -219,7 +219,7 @@ def depcreate(): description=description, inputs=inputs, slas=slas, - enable_rich_form=enable_rich_form, + enable_config_form=enable_config_form, tabs=tabs) def add_sla_to_template(template, sla_id): diff --git a/app/templates/createdep.html b/app/templates/createdep.html index 901d8314e..fbe94877e 100644 --- a/app/templates/createdep.html +++ b/app/templates/createdep.html @@ -40,7 +40,7 @@

Template: {{selectedTemplate}}

{% endif %} - {% if enable_rich_form %} + {% if enable_config_form %} {% include 'config_form.html' %} {% else %} {% include 'default_form.html' %} From 1886dca122328220f72aab834024fe2db14ebf77 Mon Sep 17 00:00:00 2001 From: mtangaro Date: Wed, 17 Apr 2019 11:16:27 +0000 Subject: [PATCH 09/24] fix when TOSCA_PARAMETERS_DIR is not defined --- app/routes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/routes.py b/app/routes.py index fb01e2964..6fc36efba 100644 --- a/app/routes.py +++ b/app/routes.py @@ -28,8 +28,7 @@ def avatar(email, size): if name[0] != '.': toscaTemplates.append( os.path.relpath(os.path.join(path, name), toscaDir )) -if app.config.get('TOSCA_PARAMETERS_DIR') is not None: - tosca_pars_dir=app.config.get('TOSCA_PARAMETERS_DIR') + "/" +tosca_pars_dir = app.config.get('TOSCA_PARAMETERS_DIR') orchestratorUrl = app.config.get('ORCHESTRATOR_URL') slamUrl = app.config.get('SLAM_URL') @@ -69,7 +68,7 @@ def get_slas(access_token): url = slamUrl + "/rest/slam/preferences/" + session['organisation_name'] verify = True - if slam_cert: + if slam_cert: verify = slam_cert response = requests.get(url, headers=headers, timeout=20, verify=verify) app.logger.info("SLA response status: " + str(response.status_code)) @@ -199,8 +198,9 @@ def depcreate(): ## add parameters code here enable_config_form = False tabs={} - if tosca_pars_dir is not None: - for path, subdirs, files in os.walk(tosca_pars_dir): + if tosca_pars_dir: + tosca_pars_path = tosca_pars_dir + "/" # this has to be reassigned here because is local. + for path, subdirs, files in os.walk(tosca_pars_path): for name in files: if fnmatch(name, os.path.splitext(selected_tosca)[0]+".parameters.yml") or fnmatch(name, os.path.splitext(selected_tosca)[0]+".parameters.yaml"): # skip hidden files From a4a15e271566aa6fd32bc8ed1a5c7a7c800e2058 Mon Sep 17 00:00:00 2001 From: mtangaro Date: Sat, 4 May 2019 16:26:20 +0000 Subject: [PATCH 10/24] port navbar to bootstrap4 --- app/templates/base.html | 49 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/app/templates/base.html b/app/templates/base.html index d36c5dae8..656e86b33 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -2,39 +2,38 @@ - - - + + + + -