Merge "Yangman - modules tree order, fix highlighting, fix post received data"
authorMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Thu, 11 Aug 2016 22:30:31 +0000 (22:30 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 11 Aug 2016 22:30:31 +0000 (22:30 +0000)
12 files changed:
modules/yangman-resources/src/main/resources/yangman/controllers/form/type-boolean.controller.js
modules/yangman-resources/src/main/resources/yangman/controllers/params-admin.controller.js
modules/yangman-resources/src/main/resources/yangman/controllers/request-data.controller.js
modules/yangman-resources/src/main/resources/yangman/controllers/request-header.controller.js
modules/yangman-resources/src/main/resources/yangman/controllers/requests-list.controller.js
modules/yangman-resources/src/main/resources/yangman/models/parameter.model.js
modules/yangman-resources/src/main/resources/yangman/models/parameterslist.model.js
modules/yangman-resources/src/main/resources/yangman/services/yangman.services.js
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/collections-tab.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/modules-tab.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/request-item.tpl.html
modules/yangman-resources/src/main/resources/yangman/yangman.less

index 3e3c65e563ae7aabb1841623456d615cfa8967f8..2b32249a1371d6ba89a6db5b4d2cfa524805a4b4 100644 (file)
@@ -1,7 +1,7 @@
-define(['app/yangman/yangman.module'], function (yangman) {
+define([], function () {
     'use strict';
 
-    yangman.register.controller('TypeBooleanCtrl', TypeBooleanCtrl);
+    angular.module('app.yangman').controller('TypeBooleanCtrl', TypeBooleanCtrl);
 
     TypeBooleanCtrl.$inject = ['$scope'];
 
index 469d946267e753ce5bfa7fc02d4f4a6805f1dba4..fea67ecc11b17f59fb2f4a6df555f297ca9910c4 100644 (file)
@@ -91,6 +91,7 @@ define([
         function sortBy(sortField) {
             vm.sortField = sortField;
             vm.sortAsc = !vm.sortAsc;
+            vm.parametersList.applyValsForFilters();
         }
 
         /**
@@ -99,7 +100,7 @@ define([
          * @returns {*}
          */
         function sortFunc(item) {
-            return item[vm.sortField] ? item[vm.sortField] : vm.sortAsc ? 'zzzzzzzzzzzzzzzz' : '';
+            return item[vm.sortField] ? item[vm.sortField] : (vm.sortAsc ? String.fromCharCode(255) : '');
         }
 
         /**
@@ -109,8 +110,8 @@ define([
          */
         function filterParam(paramObj) {
             return !(paramObj._name || paramObj._value) ||
-                    paramObj._name.indexOf(vm.search) !== -1 ||
-                    paramObj._value.indexOf(vm.search) !== -1;
+                (paramObj._name && paramObj._name.indexOf(vm.search) !== -1) ||
+                (paramObj._value && paramObj._value.indexOf(vm.search) !== -1);
         }
 
 
@@ -146,6 +147,8 @@ define([
          */
         function close() {
             vm.parametersList.removeEmptyParams();
+            console.debug('closing');
+
             $mdDialog.hide(vm.parametersList);
         }
 
index 160c990eb60a2bc702a4c884aa66fb3e2c565522..70e64990c50334c82794fc2f1a3038167b9d6aff 100644 (file)
@@ -134,8 +134,6 @@ define([], function () {
             $scope.$on('YANGMAN_GET_CODEMIRROR_DATA_' + type, function (event, args){
                 args.params.reqData = requestData.data;
             });
-
-
         }
     }
 
index 01d5a4bc81499412e09c47c92280f99033385336..b2ae3ac951d493c9cfeda442dc3b1667322b73ee 100644 (file)
@@ -132,24 +132,57 @@ define([
 
             // if changing to form, try to fill node data
             if (requestHeader.selectedShownDataType === 'form') {
-                var params = {
-                        reqData: null,
-                    },
-                    reqData = {},
-                    dataType = requestHeader.selectedOperation === 'GET' ? 'RECEIVED' : 'SENT';
-
+                var reqData = {};
 
-                $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_' + dataType, params);
-                reqData = params.reqData ? angular.fromJson(params.reqData) : {};
+                reqData = getDataForForm();
                 setNodeDataFromRequestData(requestHeader.requestUrl);
 
                 if ( $scope.node ) {
+
                     YangmanService.fillNodeFromResponse($scope.node, reqData);
                     $scope.node.expanded = true;
                 }
             }
         }
 
+        /**
+         * Helper method for building correct json data for form, rpc included
+         * @returns {*}
+         */
+        function getDataForForm(){
+            var params = {
+                    reqData: null,
+                },
+                dataTypeFunc = {
+                    rpc: function () {
+                        var sentData = { reqData: null },
+                            allData = { sent: null, received: null };
+
+                        $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_RECEIVED', params);
+                        $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_SENT', sentData);
+
+                        allData.sent = sentData.reqData ? angular.fromJson(sentData.reqData) : {};
+                        allData.received = params.reqData ? angular.fromJson(params.reqData) : {};
+
+                        return YangmanService.prepareReceivedData(
+                            $scope.node,
+                            requestHeader.selectedOperation,
+                            allData.received,
+                            allData.sent,
+                            requestHeader.selectedShownDataType
+                        );
+                    },
+                    default: function (){
+                        var dataType = requestHeader.selectedOperation === 'GET' ? 'RECEIVED' : 'SENT';
+
+                        $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_' + dataType, params);
+                        return params.reqData ? angular.fromJson(params.reqData) : {};
+                    },
+                };
+
+            return (dataTypeFunc[$scope.node.type] || dataTypeFunc.default)();
+        }
+
         /**
          * Send data to codemirror
          * @param data
@@ -279,7 +312,7 @@ define([
         }
 
 
-        function finishRequestProgress(message){
+        function finishRequestProgress (message){
             $scope.rootBroadcast('YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP');
             // $mdToast.show(
             //     $mdToast.simple()
@@ -433,7 +466,6 @@ define([
          */
         function prepareDataAndExecute(cbk){
 
-
             if ( requestHeader.requestUrl.length ) {
 
                 if ( requestHeader.selectedShownDataType === 'req-data' ) {
index ddfe7162fc6e8e3981f61167eedde59047e4f7a5..1b7f3edbb907dd1cd7d9b93fe7364e1d9275ce6b 100644 (file)
@@ -363,7 +363,7 @@ define([
          * @returns {boolean}
          */
         function filterReq(reqObj){
-            return reqObj.path.indexOf(vm.search) !== -1;
+            return reqObj.path.toLowerCase().indexOf(vm.search.toLowerCase()) > -1;
         }
 
         /**
@@ -389,7 +389,7 @@ define([
          * @returns {boolean}
          */
         function filterColName(colObj){
-            return colObj.name.indexOf(vm.search) !== -1;
+            return colObj.name.toLowerCase().indexOf(vm.search.toLowerCase()) > -1;
         }
 
         /**
index fab9579cdbd3e1eebd45cd5693b786c182296e5e..294d76a346300ed852bd2085cb983896932ad62d 100644 (file)
@@ -20,6 +20,16 @@ define([], function (){
         self.toJSON = toJSON;
         self.setData = setData;
         self.clone = clone;
+        self.applyValsForFilters = applyValsForFilters;
+
+        /**
+         * Copy model name and value to _name and _value properties, which are used when sorting and filtering list
+         * of parameters
+         */
+        function applyValsForFilters() {
+            self._name = self.name;
+            self._value = self.value;
+        }
 
         /**
          * Grouped setter
index bcbd560cf3d6af201d8f7687cfaea9e3f2d27c7e..2448422d391ec2373a01a25b02c412ae52dec26c 100644 (file)
@@ -25,6 +25,16 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
         self.createParamsFromJson = createParamsFromJson;
         self.isNameUnique = isNameUnique;
         self.removeEmptyParams = removeEmptyParams;
+        self.applyValsForFilters = applyValsForFilters;
+
+        /**
+         * Apply all parameters names and values for filtering
+         */
+        function applyValsForFilters() {
+            self.list.forEach(function (param) {
+                param.applyValsForFilters();
+            });
+        }
 
         /**
          * Returns false if name is already used
@@ -32,7 +42,7 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
          * @returns {boolean}
          */
         function isNameUnique(nameValue) {
-            return nameValue.length === 0 || self.list.filter(function (item) {
+            return !nameValue || self.list.filter(function (item) {
                 return item.name === nameValue;
             }).length === 1;
         }
@@ -79,7 +89,7 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
 
         function removeEmptyParams() {
             self.list = self.list.filter(function (param) {
-                return param.name.length > 0;
+                return param.name && param.name.length > 0;
             });
         }
 
index fc9ebc981fd49781c3b04532420f6d00c30aa0f2..ce286a188f21b1d58e79e4dec0ea593ea037c3f9 100644 (file)
@@ -28,11 +28,18 @@ define([], function () {
             getDataStoreIndex: getDataStoreIndex,
             prepareAllRequestData: prepareAllRequestData,
             prepareReceivedData: prepareReceivedData,
+            putIntoObj: putIntoObj,
             validateFile: validateFile,
         };
 
         return service;
 
+        /**
+         * Put data to output container if root node is rpc
+         * @param data
+         * @param node
+         * @returns {*}
+         */
         function checkRpcReceivedData(data, node){
             return node.type === 'rpc' ? cutData(data) : data;
 
@@ -43,6 +50,18 @@ define([], function () {
             }
         }
 
+        /**
+         * Put source object into destination object by source properties
+         * @param sourceObj
+         * @param destinationObj
+         */
+        function putIntoObj(sourceObj, destinationObj, containter){
+            Object.keys(sourceObj).forEach(function(prop){
+                destinationObj[containter] = destinationObj[containter] ? destinationObj[containter] : {};
+                destinationObj[containter][prop] = sourceObj[prop];
+            });
+        }
+
         /**
          * Prepare request date before filling into node depends on method and node type
          * @param node
@@ -64,18 +83,6 @@ define([], function () {
                     } else {
                         return rData;
                     }
-
-                    /**
-                     * Put source object into destination object by source properties
-                     * @param sourceObj
-                     * @param destinationObj
-                     */
-                    function putIntoObj(sourceObj, destinationObj, containter){
-                        Object.keys(sourceObj).forEach(function(prop){
-                            destinationObj[containter] = destinationObj[containter] ? destinationObj[containter] : {};
-                            destinationObj[containter][prop] = sourceObj[prop];
-                        });
-                    }
                 },
                 default: function (){
                     var methodType = {
@@ -91,11 +98,8 @@ define([], function () {
                             }
                             return {};
                         },
-                        PUT: function () {
-                            return rData;
-                        },
                         DEFAULT: function () {
-                            return outputType === 'form' ? sData : rData;
+                            return rData;
                         }
                     };
 
index 2ccb9b5c627e2fe7661a83b5c596be255f460e41..5b8f137e65e11d491db7d3a2cf781c8289efcc9c 100644 (file)
@@ -61,6 +61,7 @@
 
     <md-divider></md-divider>
 
+    <!-- collection list -->
     <md-content class="scrollableY">
 
         <div ng-repeat="collection in reqList.mainList.collections | filter: reqList.filterCol | orderBy: (reqList.collectionsSortAsc ? '' : '-')+'name'">
@@ -79,7 +80,7 @@
                         <div layout="column">
 
                             <p flex>
-                            <span md-highlight-text="reqList.search" >
+                            <span md-highlight-text="reqList.search" md-highlight-flags="i">
                                 {{collection.name}}
                             </span><br />
                             <span class="desc">
index 79e051fa8eee4c84dbf3a506afaded6e9c6bb2b5..bd309c8960da1bcdae35d83ef5258d6167557e8c 100644 (file)
     <md-list ng-cloak class="yangmanModule__modules-list scrollableY">
 
         <!-- Loading box -->
-        <!--<div class="yangmanModule__left-panel__loading-container" ng-show="modulesList.showLoadingBox">-->
-            <!--<md-progress-linear md-mode="query"></md-progress-linear>-->
-            <!--<div class="bottom-block">-->
-                <!--<span>{{ 'YANGMAN_LOADING_MODULES' | translate }}</span>-->
-            <!--</div>-->
-        <!--</div>-->
         <md-progress-linear md-mode="indeterminate" ng-show="modulesList.showLoadingBox"></md-progress-linear>
 
         <!-- Mount point title -->
@@ -46,7 +40,7 @@
         </section>
 
         <!-- Modules list -->
-        <md-list-item ng-repeat="module in modulesList.treeApis | filter: modulesList.customSearch"
+        <md-list-item ng-repeat="module in modulesList.treeApis | filter: modulesList.customSearch | orderBy: 'label'"
                       class="yangmanModule__modules-list__item"
                       ng-class="{'expanded' : module.expanded, 'selected' : modulesList.checkSelectedModule(module)}"
                       ng-hide="modulesList.showLoadingBox"
@@ -58,7 +52,7 @@
                     <md-icon md-font-set="material-icons" class="top-icon top-element">
                         {{module.expanded ? 'keyboard_arrow_down':'keyboard_arrow_right'}}
                     </md-icon>
-                    <p flex class="top-element" md-highlight-text="modulesList.search"> {{module.label}} </p>
+                    <p flex class="top-element" md-highlight-text="modulesList.search" md-highlight-flags="i"> {{module.label}} </p>
                 </div>
 
                 <!-- Datastore && rpc -->
index 1fe796e88f088e3768c1b4a73e02ef6b9c5780e8..2c47b3b78cb96b62dc16b7b3685259c69b545b18 100644 (file)
@@ -11,7 +11,7 @@
     </div>
 
     <div flex class="yangmanModule__requests-list__group__item__path" layout="column">
-        <p md-highlight-text="reqList.search">
+        <p md-highlight-text="reqList.search" md-highlight-flags="i">
             {{ request.path }}
         </p>
     </div>
index 3ccf1abf464838cef58fc6476d062c21a097655b..a7453514c7939ec5ce41bd803f9f733d6292b454 100644 (file)
@@ -559,7 +559,7 @@ md-dialog{
 
 
                 > div:not(.ui-resizable-handle) {
-                    height: calc(~'100% - 25px');
+                    height: calc(~'100% - 28px');
                     overflow-y: auto;
                 }
 
@@ -818,8 +818,19 @@ md-dialog{
                 }
             }
 
+            p.top-element{
+                padding: 6px 0;
+            }
+
             md-icon{
                 margin: 12px 16px;
+
+                &.top-element{
+                    margin: 0;
+                    padding: 12px 16px;
+                    width: 56px;
+                    height: 48px;
+                }
             }
 
             &:hover{