From 8d6380265299c36f6356c746460baa0cfd2ad4e1 Mon Sep 17 00:00:00 2001 From: thuva4 Date: Sat, 31 Mar 2018 10:58:08 +0530 Subject: Remove code duplication in pod page Create a service to map the object field with the data label. Change-Id: I0c3e96dca01a27ec4785c1426d82e115afb6c1df Signed-off-by: thuva4 --- testapi/opnfv_testapi/ui/app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'testapi/opnfv_testapi/ui/app.js') diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js index b4e8d08..3fb4bc7 100644 --- a/testapi/opnfv_testapi/ui/app.js +++ b/testapi/opnfv_testapi/ui/app.js @@ -62,6 +62,21 @@ } }); + angular + .module('testapiApp') + .service('dataFieldService', function(){ + this.dataFunction = dataFunction + function dataFunction(data, data_field){ + Object.keys(data).forEach(function (key) { + if (typeof data[key] === 'object' && data[key] != null) { + return dataFunction(data[key], data_field); + } + data_field[key] = key.replace(/_/g, " ").trim(); + }); + return data_field; + } + }); + angular .module('testapiApp') .directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) { -- cgit 1.2.3-korg