summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/app.js
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2018-03-31 10:58:08 +0530
committerthuva4 <tharma.thuva@gmail.com>2018-03-31 10:58:08 +0530
commit8d6380265299c36f6356c746460baa0cfd2ad4e1 (patch)
treec7f70dd55350b5d78ba8c240dcc4660fe6f878cc /testapi/opnfv_testapi/ui/app.js
parentc20c8286d72ca64751162b1932e0e3f680f0e32f (diff)
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 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/ui/app.js')
-rw-r--r--testapi/opnfv_testapi/ui/app.js15
1 files changed, 15 insertions, 0 deletions
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
@@ -64,6 +64,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) {
return {
restrict: 'A',