From b592e5d8c5a4743a2e7ee9a1ac0778c4655209df Mon Sep 17 00:00:00 2001 From: NoorYameen Date: Mon, 25 Mar 2019 15:36:26 +0200 Subject: [PATCH] Adding equevalance templates discarding the validation results Change-Id: I37ab5a18e25b99484d69667a1de8fd504c387722 --- .../addTemplateContainer.controller.js | 36 ++++++++++--------- .../project/components/rca/rcaContainer.scss | 1 + .../template/templateContainer.controller.js | 3 ++ .../template/templateContainer.html | 27 ++++++++++---- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/vitrage_dashboard/dashboard/static/dashboard/project/components/addTemplate/addTemplateContainer.controller.js b/vitrage_dashboard/dashboard/static/dashboard/project/components/addTemplate/addTemplateContainer.controller.js index 69a4a1c..36a128b 100644 --- a/vitrage_dashboard/dashboard/static/dashboard/project/components/addTemplate/addTemplateContainer.controller.js +++ b/vitrage_dashboard/dashboard/static/dashboard/project/components/addTemplate/addTemplateContainer.controller.js @@ -106,29 +106,31 @@ ); vitrageTopologySrv.validateTemplate($scope.templateContent, type, finalParameters).then(function (result) { - if (result.data.results[0]['status code'] !== 0) { - horizon.toast.add("error", gettext(result.data.results[0].message)); + if (!result || !result.data || !result.data.results || result.data.results.length === 0) { + horizon.toast.add("error", gettext('Template Validation Failed')); } else { - vitrageTopologySrv.addTemplate($scope.templateContent, type, finalParameters).then(function (result) { + if (!(result.data.results[0]['status code'] === 0 || result.data.results[0]['status code'] === "")) { + horizon.toast.add("error", gettext(result.data.results[0].message)); + } else { + vitrageTopologySrv.addTemplate($scope.templateContent, type, finalParameters).then(function (result) { - if (result.data[0].status === 'ERROR') { - horizon.toast.add("error", gettext(result.data[0]['status details'])); - } else { - $scope.loading = false; - $rootScope.$broadcast('autoRefresh'); + if (result.data[0].status === 'ERROR') { + horizon.toast.add("error", gettext(result.data[0]['status details'])); + } else { + $scope.loading = false; + $rootScope.$broadcast('autoRefresh'); - } - - }) - .catch(function () { - $scope.loading = false; - horizon.toast.add("error", gettext("Unable to add template")); - return; - }); + } + }) + .catch(function () { + $scope.loading = false; + horizon.toast.add("error", gettext("Unable to add template")); + return; + }); + } } - }).catch(function (reason) { horizon.toast.add("error", gettext(reason)); }) diff --git a/vitrage_dashboard/dashboard/static/dashboard/project/components/rca/rcaContainer.scss b/vitrage_dashboard/dashboard/static/dashboard/project/components/rca/rcaContainer.scss index c17c78b..a870d35 100644 --- a/vitrage_dashboard/dashboard/static/dashboard/project/components/rca/rcaContainer.scss +++ b/vitrage_dashboard/dashboard/static/dashboard/project/components/rca/rcaContainer.scss @@ -2,4 +2,5 @@ height: 100%; background: #ffffff; opacity: 0.8; + margin-bottom: 10%; } \ No newline at end of file diff --git a/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.controller.js b/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.controller.js index 8521533..834ac85 100644 --- a/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.controller.js +++ b/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.controller.js @@ -18,6 +18,9 @@ $scope.closeModal = function () { modalSrv.close(); }; + $scope.isObject = function (data) { + return typeof data ==='object'; + }; vitrageTopologySrv.getTemplates(template.uuid) .then( diff --git a/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.html b/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.html index 1b2a710..43923ad 100644 --- a/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.html +++ b/vitrage_dashboard/dashboard/static/dashboard/project/components/template/templateContainer.html @@ -1,6 +1,6 @@
- @@ -95,7 +95,16 @@ {$ key $}: {$ value $}
  • - {$ property $}: {$ value $} + {$ property $}: {$ value $} + + {$ property $} +
      +
    1. + {$ label $}: {$ data $} +
    2. +
    +
    +
  • @@ -105,7 +114,15 @@
    • action: {$ keys(action)[0] $}
    • - {$ key $}: {$ value $} + {$ key $}: {$ value $} + + {$ key $} +
        +
      1. + {$ label $}: {$ data $} +
      2. +
      +
    @@ -118,9 +135,7 @@
    -
    -            {$ str_data $}
    -        
    +
    {$ str_data $}