Merge "Yangman - connecting parts"
authorMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Thu, 11 Aug 2016 21:42:09 +0000 (21:42 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 11 Aug 2016 21:42:09 +0000 (21:42 +0000)
24 files changed:
modules/yangman-resources/src/main/resources/yangman/assets/data/locale-en_US.json
modules/yangman-resources/src/main/resources/yangman/assets/js/codemirror/addon/hint/yangman-json-hint.js [new file with mode: 0644]
modules/yangman-resources/src/main/resources/yangman/controllers/edit-collection-dialog.controller.js
modules/yangman-resources/src/main/resources/yangman/controllers/modules-list.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/controllers/yangman.controller.js
modules/yangman-resources/src/main/resources/yangman/main.js
modules/yangman-resources/src/main/resources/yangman/models/collectionlist.model.js
modules/yangman-resources/src/main/resources/yangman/models/history-request.model.js
modules/yangman-resources/src/main/resources/yangman/models/historylist.model.js
modules/yangman-resources/src/main/resources/yangman/services/requests.services.js
modules/yangman-resources/src/main/resources/yangman/services/yangman.services.js
modules/yangman-resources/src/main/resources/yangman/views/index.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/collections-tab.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/history-tab.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/request-item.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/rightpanel/detail.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/rightpanel/request-data.tpl.html
modules/yangman-resources/src/main/resources/yangman/views/rightpanel/request-header.tpl.html
modules/yangman-resources/src/main/resources/yangman/yangman.less
modules/yangman-resources/src/main/resources/yangman/yangman.module.js

index a2dfc419eee9a22d8f52ec023df5591c41e7cbfa..3c1d836991d6dfe48bf3f448a41a1d450bd82650 100644 (file)
   "YANGMAN_OK": "OK",
   "YANGMAN_REQ_DELETE": "Delete request",
   "YANGMAN_REQ_DUPLICATE": "Duplicate request",
-  "YANGMAN_REQ_FILL_FORM": "Fill form",
+  "YANGMAN_REQ_SHOW_FORM": "Show form",
   "YANGMAN_REQ_RUN": "Run request",
-  "YANGMAN_REQ_SHOW_RCVD_DATA": "Show received data",
-  "YANGMAN_REQ_SHOW_SENT_DATA": "Show sent data",
+  "YANGMAN_REQ_SHOW_JSON_DATA": "Show json data",
   "YANGMAN_REQ_URL": "Request URL",
   "YANGMAN_REQS_DELETE": "Delete selected",
   "YANGMAN_REQS_DUPLICATE": "Duplicating request",
@@ -63,6 +62,8 @@
   "YANGMAN_PARAMS_VALUE": "value",
   "YANGMAN_PARAM_KEY_REQUIRED": "Required value",
   "YANGMAN_PARAM_EXISTING_KEY": "Duplicate value",
-  "YANGMAN_SORTING": "Sorting"
+  "YANGMAN_SORTING": "Sorting",
+  "YANGMAN_CLEAR_HISTORY": "Clear history"
+
 
 }
diff --git a/modules/yangman-resources/src/main/resources/yangman/assets/js/codemirror/addon/hint/yangman-json-hint.js b/modules/yangman-resources/src/main/resources/yangman/assets/js/codemirror/addon/hint/yangman-json-hint.js
new file mode 100644 (file)
index 0000000..c2327f3
--- /dev/null
@@ -0,0 +1,66 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+    if (typeof exports == "object" && typeof module == "object") // CommonJS
+        mod(require("codemirror"));
+    else if (typeof define == "function" && define.amd) // AMD
+        define(["codemirror"], mod);
+    else // Plain browser env
+        mod(CodeMirror);
+})(function(CodeMirror) {
+    "use strict";
+
+    var WORD = /[<<\w$]+/, RANGE = 500;
+    CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
+        var acList = [],
+            word = options && options.word || WORD,
+            cur = editor.getCursor(),
+            curLine = editor.getLine(cur.line),
+            end = cur.ch,
+            start = end,
+            paramList = editor.data.parameterListObj.list;
+
+        function forEachParam(arr, f, fParam) {
+            for (var i = 0, e = arr.length; i < e; ++i){
+                f(arr[i].key, fParam);
+            }
+        }
+
+
+        function maybeAdd(possibleWord, word) {
+            var pw = '<<' + possibleWord + '>>';
+            if (pw.lastIndexOf(word, 0) == 0 && !arrayContains(acList, pw))
+                acList.push(pw);
+        }
+
+        function arrayContains(arr, item) {
+            if (!Array.prototype.indexOf) {
+                var i = arr.length;
+                while (i--) {
+                    if (arr[i] === item) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+            return arr.indexOf(item) != -1;
+        }
+
+
+        options.completeSingle = false;
+
+        while (start && word.test(curLine.charAt(start - 1)))
+            --start;
+
+        var curWord = curLine.slice(start, end);
+
+        if(curWord.length > 1){
+            forEachParam(paramList, maybeAdd, curWord);
+        }
+
+
+
+        return {list: acList, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
+    });
+});
index d4e994bd6abeddb35e8eec71eeac6e130babe43d..e449c90ac2189de018c5840a9fd4efbbaa268bd2 100644 (file)
@@ -1,5 +1,4 @@
-define([
-], function () {
+define([], function () {
     'use strict';
 
     angular.module('app.yangman').controller('EditCollectionDialogCtrl', EditCollectionDialogCtrl);
index c6ffd57c67cdf35df18aaeeba266c944ac951a2a..cb0ca9b17e956f6a16a0fba4b1e8d37fe4278a2c 100644 (file)
@@ -72,7 +72,7 @@ define([], function () {
          */
         function setDataStore(dataStore, module){
             $scope.setModule(module);
-            $scope.setDataStore(dataStore, true);
+            $scope.setDataStore(dataStore, true, 1);
         }
 
         /**
index c5eed47e4d22aba4a3dbb1a7c9aa0e4117f33668..b66d8c3d74e35b815811c886564eed3fab8fc065 100644 (file)
@@ -37,7 +37,7 @@ define([
         }
 
         /**
-         * Sort parameters, so that empty params will be always the last
+         * Sort parameters with empty params at the end of list
          * @param item
          * @returns {*}
          */
index 86060434649325a3252b9a9fb7531b18350f10d0..ba9ca4c8a31a213e5325976a0877116bb61e02b0 100644 (file)
@@ -3,16 +3,18 @@ define([], function () {
 
     angular.module('app.yangman').controller('RequestDataCtrl', RequestDataCtrl);
 
-    RequestDataCtrl.$inject = ['$scope'];
+    RequestDataCtrl.$inject = ['$scope', 'RequestsService'];
 
-    function RequestDataCtrl($scope) {
+    function RequestDataCtrl($scope, RequestsService) {
         var requestData = this;
 
+        requestData.paramsArray = [];
+
         requestData.dataEditorOptions = {
             mode: 'javascript',
             lineNumbers: true,
             theme: 'eclipse',
-            readOnly: false,
+            readOnly: requestData.type === 'RECEIVED',
             lineWrapping: true,
             matchBrackets: true,
             extraKeys: { 'Ctrl-Space': 'autocomplete' },
@@ -22,15 +24,45 @@ define([], function () {
         requestData.type = null;
 
         // methods
-        requestData.getDataEditorOptions = getDataEditorOptions;
         requestData.init = init;
 
+
+        function initCMOpts() {
+            requestData.dataEditorOptions.readOnly = requestData.type === 'RECEIVED';
+            requestData.dataEditorOptions.theme = requestData.type === 'RECEIVED' ? 'eclipse-disabled' : 'eclipse';
+
+            if (requestData.type === 'SENT') {
+                requestData.dataEditorOptions.onLoad = function (cmInstance){
+                    cmInstance.data = { parameterListObj: $scope.parametersList || { list: [] } };
+
+                    cmInstance.on('changes', function (){
+                        if (angular.isFunction(cmInstance.showHint)){
+                            cmInstance.showHint();
+                        }
+                    });
+
+                    cmInstance.on('cursorActivity', function (){
+                        var lineString = cmInstance.getLine(cmInstance.getCursor().line);
+                        requestData.paramsArray = RequestsService.scanDataParams($scope.parametersList, lineString);
+
+                        if (!$scope.$$phase) {
+                            $scope.$apply();
+                        }
+                    });
+
+                    cmInstance.refresh();
+                };
+            }
+        }
+
         /**
          * Initialization
          * @param type
          */
         function init(type){
             requestData.type = type;
+            initCMOpts();
+
 
             // watchers
             $scope.$on('YANGMAN_REFRESH_CM_DATA_' + type, refreshData);
@@ -42,6 +74,7 @@ define([], function () {
             $scope.$on('YANGMAN_GET_CODEMIRROR_DATA_' + type, function (event, args){
                 args.params.reqData = requestData.data;
             });
+
         }
 
         /**
@@ -52,28 +85,6 @@ define([], function () {
                 $scope.requestToShow.setDataForView(true, $scope.requestToShow[$scope.requestDataToShow]);
         }
 
-        /**
-         *
-         * @param read
-         * @param theme
-         * @returns {
-         * {mode: string,
-         * lineNumbers: boolean,
-         * theme: string,
-         * readOnly: boolean,
-         * lineWrapping: boolean,
-         * matchBrackets: boolean,
-         * extraKeys: {Ctrl-Space: string},
-         * onLoad: Function}|*
-         * }
-         */
-        function getDataEditorOptions(read, theme){
-            requestData.dataEditorOptions.readOnly = read;
-            requestData.dataEditorOptions.theme = theme;
-
-            return requestData.dataEditorOptions;
-        }
-
     }
 
 });
index 8284964f5c28ede48e59a41333c3e67b35c65560..ca5413f2588e23f3c4d7e112f1a78e81379f060b 100644 (file)
@@ -1,11 +1,17 @@
-define([], function () {
+define([
+    'app/yangman/controllers/params-admin.controller',
+], function (ParamsAdminCtrl) {
     'use strict';
 
     angular.module('app.yangman').controller('RequestHeaderCtrl', RequestHeaderCtrl);
 
-    RequestHeaderCtrl.$inject = ['$scope', '$rootScope', 'ENV', 'YangmanService', 'PathUtilsService', '$filter'];
+    RequestHeaderCtrl.$inject = [
+        '$mdDialog', '$scope', '$rootScope', 'ENV', 'YangmanService', 'ParametersService', 'PathUtilsService',
+        'RequestsService', '$filter',
+    ];
 
-    function RequestHeaderCtrl($scope, $rootScope, ENV, YangmanService, PathUtilsService, $filter) {
+    function RequestHeaderCtrl($mdDialog, $scope, $rootScope, ENV, YangmanService, ParametersService, PathUtilsService,
+                               RequestService, $filter) {
         var requestHeader = this;
 
         requestHeader.allOperations = ['GET', 'POST', 'PUT', 'DELETE'];
@@ -18,9 +24,12 @@ define([], function () {
         requestHeader.executeOperation = executeOperation;
         requestHeader.fillNodeData = fillNodeData;
         requestHeader.changeDataType = changeDataType;
-        requestHeader.checkExecutedData = checkExecutedData;
+        requestHeader.prepareDataAndExecute = prepareDataAndExecute;
         requestHeader.setJsonView = setJsonView;
         requestHeader.setRequestUrl = setRequestUrl;
+        requestHeader.showParamsAdmin = showParamsAdmin;
+        requestHeader.saveRequestToCollection = saveRequestToCollection;
+
 
         // watchers
         /**
@@ -37,10 +46,46 @@ define([], function () {
         $scope.$on('YANGMAN_HEADER_INIT', function (event, args) {
             init();
             setRequestUrl(args.params.path);
+            setRequestMethod(args.params.method);
+            (args.cbk || angular.noop)();
+        });
+
+        $scope.$on('YANGMAN_FILL_NODE_FROM_REQ', function (event, args) {
+            setNodeDataFromRequestData(args.params.requestUrl, args.params.leftpanel);
+            (args.cbk || angular.noop)();
         });
 
+        $scope.$on('YANGMAN_EXECUTE_WITH_DATA', executeWithData);
+
         init();
 
+
+        function executeWithData(event, args) {
+            executeOperation(args.params.data ? angular.fromJson(args.params.data) : {}, args.cbk);
+        }
+
+        function setRequestMethod(method){
+            requestHeader.selectedOperation = method;
+        }
+
+        /**
+         * Show popup for parameters administration
+         * @param event
+         */
+        function showParamsAdmin(event) {
+            $mdDialog.show({
+                controller: ParamsAdminCtrl,
+                controllerAs: 'paramsAdmin',
+                templateUrl: $scope.globalViewPath + 'popup/parameters-admin.tpl.html',
+                parent: angular.element('#yangmanModule'),
+                targetEvent: event,
+                clickOutsideToClose: true,
+                locals: {
+                    parametersList: $scope.parametersList,
+                },
+            });
+        }
+
         /**
          * Method for selecting correct json view by selected operation
          */
@@ -53,35 +98,65 @@ define([], function () {
                 $scope.setJsonView(true, false);
             }
 
-            sendRequestData({}, 'RECEIVED');
+            // sendRequestData({}, 'RECEIVED');
         }
 
         /**
-         * Method for executing after data type was change (radio button)
+         * Change displayed data type to json or form, after switching set current data to be displayed
          */
         function changeDataType(){
             $scope.switchSection('rightPanelSection', requestHeader.selectedShownDataType);
             requestHeader.setRequestUrl();
 
+            // if changing to json, fill codemirror data
             if ( requestHeader.selectedShownDataType === 'req-data' && $scope.node ){
                 setJsonView();
                 sendRequestData($scope.buildRootRequest(), 'SENT');
             }
+
+            // if changing to form, try to fill node data
+            if (requestHeader.selectedShownDataType === 'form') {
+                var params = {
+                        reqData: null,
+                    },
+                    reqData = {},
+                    dataType = requestHeader.selectedOperation === 'GET' ? 'RECEIVED' : 'SENT';
+
+
+                $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_' + dataType, params);
+                reqData = params.reqData ? angular.fromJson(params.reqData) : {};
+                setNodeDataFromRequestData(requestHeader.requestUrl);
+
+                if ( $scope.node ) {
+                    YangmanService.fillNodeFromResponse($scope.node, reqData);
+                    $scope.node.expanded = true;
+                }
+            }
         }
 
         /**
-         * Method for sending data to code mirror
+         * Send data to codemirror
          * @param data
          */
         function sendRequestData(data, type){
             $scope.rootBroadcast('YANGMAN_SET_CODEMIRROR_DATA_' + type, { data: JSON.stringify(data, null, 4) });
         }
 
+        /**
+         * Create empty parameters list, load from local storage and set to $scope
+         */
+        function initParams(){
+            var paramsList = ParametersService.createEmptyParametersList('yangman_parameters');
+            paramsList.loadListFromStorage();
+            $scope.setParametersList(paramsList);
+        }
+
         /**
          * Initialization
          */
         function init(){
             setAllowedMethods(requestHeader.allOperations);
+            initParams();
             requestHeader.selectedShownDataType = $scope.rightPanelSection;
         }
 
@@ -91,7 +166,9 @@ define([], function () {
          */
         function setAllowedMethods(operations){
             requestHeader.selectedOperationsList = operations.length ? operations : requestHeader.allOperations;
-            requestHeader.selectedOperation = requestHeader.selectedOperationsList[0];
+            if (operations.indexOf(requestHeader.selectedOperation) === -1){
+                requestHeader.selectedOperation = requestHeader.selectedOperationsList[0];
+            }
         }
 
         /**
@@ -102,10 +179,80 @@ define([], function () {
                     ENV.getBaseURL('MD_SAL') + '/restconf/' + $scope.selectedSubApi.buildApiRequestString() : '');
         }
 
+
+        /**
+         * Try to set api, module, dataStore and node, if api indexes for request url available
+         * and set (or unset) module detail panel to be displayed
+         * @param requestUrl url to try to find
+         * @param leftpanel index of main left tabs to be displayed (we dont want to display module detail in all cases)
+         */
+        function setNodeDataFromRequestData(requestUrl, leftpanel){
+
+            $scope.rootBroadcast('YANGMAN_GET_API_TREE_DATA', null, function (treeApis) {
+                var apisIndexes =
+                        PathUtilsService.searchNodeByPath(requestUrl, treeApis, null, true);
+
+                if ( apisIndexes ){
+                    // set apis
+                    $scope.setApi(
+                        $scope.apis[apisIndexes.indexApi],
+                        $scope.apis[apisIndexes.indexApi].subApis[apisIndexes.indexSubApi]
+                    );
+
+                    // set module
+                    $scope.setModule($filter('filter')(treeApis, { label: $scope.selectedApi.module })[0]);
+
+                    // set datastore
+                    $scope.setDataStore(
+                        $filter('filter')(
+                            $scope.selectedModule.children,
+                            { label: $scope.selectedSubApi.storage })[0],
+                        true,
+                        leftpanel
+                    );
+
+                    // set node
+                    $scope.setNode($scope.selectedSubApi.node);
+
+                }
+            });
+        }
+
+        function saveRequestToCollection(event) {
+            var historyReq = RequestService.createHistoryRequest(null, null, requestHeader.requestUrl,
+                    requestHeader.selectedOperation, '', '', ''),
+                reqData = {};
+
+            if ( requestHeader.selectedShownDataType === 'req-data' ) {
+                var params = { reqData: null };
+                $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_SENT', params);
+                reqData = params.reqData ? angular.fromJson(params.reqData) : {};
+            }
+
+            var historyReqData = YangmanService.prepareAllRequestData(
+                    $scope.selectedApi,
+                    $scope.selectedSubApi,
+                    requestHeader.selectedOperation,
+                    $scope.node,
+                    requestHeader.selectedShownDataType,
+                    requestHeader.requestUrl,
+                    reqData,
+                    $scope.parametersList
+                );
+
+            historyReq.setExecutionData(historyReqData.reqData, {}, '');
+
+            $scope.rootBroadcast('YANGMAN_SAVE_REQUEST_TO_COLLECTION', { event: event, reqObj: historyReq });
+        }
+
+
         /**
          * Execute request operation
          */
-        function executeOperation(requestData){
+        function executeOperation(requestData, executeCbk){
+
+            var historyReq = RequestService.createHistoryRequest(null, null, requestHeader.requestUrl,
+                requestHeader.selectedOperation, '', '', '');
 
             YangmanService.executeRequestOperation(
                 $scope.selectedApi,
@@ -115,78 +262,79 @@ define([], function () {
                 requestHeader.selectedShownDataType,
                 requestHeader.requestUrl,
                 requestData,
-                function (reqInfo, response) {
-                    requestHeader.statusObj = reqInfo;
-
-                    console.log('response.data', response.data);
-
-                    if (response.data) {
-
-                        if ( requestHeader.selectedShownDataType === 'req-data' ) {
-
-                            // try to fill code mirror editor
-                            sendRequestData(response.data.plain(), 'RECEIVED');
-
-                            // try to find api, subapi and node
-                            $scope.rootBroadcast('YANGMAN_GET_API_TREE_DATA', null, function (treeApis) {
-                                var apisIndexes =
-                                    PathUtilsService.searchNodeByPath(requestHeader.requestUrl, treeApis, null, true);
-
-                                if ( apisIndexes ){
-                                    // set apis
-                                    $scope.setApi(
-                                        $scope.apis[apisIndexes.indexApi],
-                                        $scope.apis[apisIndexes.indexApi].subApis[apisIndexes.indexSubApi]
-                                    );
-
-                                    // set module
-                                    $scope.setModule($filter('filter')(treeApis, { label: $scope.selectedApi.module })[0]);
-
-                                    // set datastore
-                                    $scope.setDataStore(
-                                        $filter('filter')(
-                                            $scope.selectedModule.children,
-                                            { label: $scope.selectedSubApi.storage })[0],
-                                        true,
-                                        1
-                                    );
-
-                                    // set node
-                                    $scope.setNode($scope.selectedSubApi.node);
-
-                                    if ( $scope.node ) {
-                                        // try to fill node
-                                        YangmanService.fillNodeFromResponse($scope.node, response.data);
-                                        $scope.node.expanded = true;
-                                    }
-                                }
-                            });
-                        } else {
-
-                            if ( $scope.node ) {
-                                // try to fill node
-                                YangmanService.fillNodeFromResponse($scope.node, response.data);
-                                $scope.node.expanded = true;
-                            }
-                        }
-
-
-                    } else {
-                        sendRequestData({}, 'RECEIVED');
+                $scope.parametersList,
+                executeReqSuccCbk,
+                executeReqErrCbk
+            );
+
+            /**
+             *
+             * @param reqInfo
+             * @param response
+             */
+            function executeReqSuccCbk(reqInfo, response) {
+                requestHeader.statusObj = reqInfo;
+
+                // create and set history request
+                historyReq.setExecutionData(
+                    reqInfo.requestData,
+                    response.data ? response.data.plain() : {},
+                    reqInfo.status
+                );
+
+                if (response.data) {
+
+                    // if executing from json form, try to find api, subapi and node
+                    if ( requestHeader.selectedShownDataType === 'req-data' ) {
+                        setNodeDataFromRequestData(requestHeader.requestUrl);
                     }
-                }, function (reqInfo, response) {
-                    requestHeader.statusObj = reqInfo;
-
-                    if (response.data) {
-                        if ( requestHeader.selectedShownDataType === 'req-data' ) {
-                            // try to fill code mirror editor
-                            sendRequestData(response.data, 'RECEIVED');
-                        }
+
+                    // try to fill code mirror editor
+                    sendRequestData(response.data.plain(), 'RECEIVED');
+
+                    // try to fill node, if some was found or filled in form
+                    if ( $scope.node ) {
+                        YangmanService.fillNodeFromResponse($scope.node, response.data);
+                        $scope.node.expanded = true;
+                    }
+
+                } else {
+                    sendRequestData({}, 'RECEIVED');
+                }
+
+                $scope.rootBroadcast('YANGMAN_SAVE_EXECUTED_REQUEST', historyReq);
+                (executeCbk || angular.noop)(historyReq);
+
+            }
+
+            /**
+             *
+             * @param reqInfo
+             * @param response
+             */
+            function executeReqErrCbk(reqInfo, response) {
+
+                requestHeader.statusObj = reqInfo;
+
+                historyReq.setExecutionData(reqInfo.requestData, null, reqInfo.status);
+                $scope.rootBroadcast('YANGMAN_SAVE_EXECUTED_REQUEST', historyReq);
+
+                if (response.data) {
+                    if ( requestHeader.selectedShownDataType === 'req-data' ) {
+                        // try to fill code mirror editor
+                        sendRequestData(response.data, 'RECEIVED');
                     }
-                });
+                }
+                (executeCbk || angular.noop)(historyReq);
+            }
+
         }
 
-        // TODO :: description
+        /**
+         * TODO :: description
+         * @param pathElem
+         * @param identifier
+         */
         function fillNodeData(pathElem, identifier) {
             if ($scope.selectedSubApi && $scope.selectedSubApi.storage === 'config' &&
                 $scope.selectedSubApi.pathArray.indexOf(pathElem) === ($scope.selectedSubApi.pathArray.length - 1)) {
@@ -197,17 +345,15 @@ define([], function () {
         /**
          * Check data before executin operations
          */
-        function checkExecutedData(){
+        function prepareDataAndExecute(){
 
             if ( requestHeader.requestUrl.length ) {
-                var params = {
-                    reqData: null,
-                };
 
                 if ( requestHeader.selectedShownDataType === 'req-data' ) {
                     // get json data
+                    var params = { reqData: null };
                     $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_SENT', params);
-                    executeOperation(angular.fromJson(params.reqData));
+                    executeOperation(params.reqData ? angular.fromJson(params.reqData) : {});
                 } else {
                     executeOperation({});
                 }
index d80c91da194adb628d615f0ca8b0ec53863938ad..02b3b6b5bab8439a4f7e35b8cbb233216150a19f 100644 (file)
@@ -8,44 +8,74 @@ define([
     angular.module('app.yangman').controller('RequestsListCtrl', RequestsListCtrl);
 
     RequestsListCtrl.$inject = [
-        '$filter', '$mdDialog', '$scope', 'HandleFileService', 'PathUtilsService', 'RequestsService',
+        '$filter', '$mdDialog', '$scope', 'HandleFileService', 'PathUtilsService', 'RequestsService', 'YangmanService',
     ];
 
-    function RequestsListCtrl($filter, $mdDialog, $scope, HandleFileService, PathUtilsService, RequestsService) {
+    function RequestsListCtrl($filter, $mdDialog, $scope, HandleFileService, PathUtilsService, RequestsService,
+                              YangmanService) {
         var vm = this;
 
-        vm.collectionList = RequestsService.createEmptyCollectionList('yangman_collectionsList', vm.getApiCallback);
+        vm.collectionList = RequestsService.createEmptyCollectionList('yangman_collectionsList');
+        vm.collectionsSortAsc = true;
         vm.mainList = null;
-        vm.requestList = RequestsService.createEmptyHistoryList('yangman_requestsList', vm.getApiCallback);
+        vm.requestList = RequestsService.createEmptyHistoryList('yangman_requestsList');
         vm.search = '';
-        vm.collectionsSortAsc = true;
 
         vm.clearFilter = clearFilter;
-        vm.filterReq = filterReq;
-        vm.filterCol = filterCol;
-        vm.filterColName = filterColName;
+        vm.clearHistoryList = clearHistoryList;
         vm.colMatchingReqsCount = colMatchingReqsCount;
         vm.downloadCollection = downloadCollection;
+        vm.executeRequest = executeRequest;
         vm.fakeFilter = fakeFilter;
-        vm.getApiCallback = getApiCallback;
+        vm.filterCol = filterCol;
+        vm.filterColName = filterColName;
+        vm.filterReq = filterReq;
+        vm.init = init;
         vm.loadRequests = loadRequests;
-        vm.toggleCollectionsSort = toggleCollectionsSort;
+        vm.readCollectionFromFile = readCollectionFromFile;
         vm.selectRequest = selectRequest;
-
+        vm.showData = showData;
         vm.showDgDeleteCollection = showDgDeleteCollection;
         vm.showDgDeleteRequests = showDgDeleteRequests;
         vm.showDgEditCollection = showDgEditCollection;
-        vm.readCollectionFromFile = readCollectionFromFile;
         vm.showDgSaveReq = showDgSaveReq;
+        vm.toggleCollectionsSort = toggleCollectionsSort;
+        vm.showForm = showForm;
 
-        vm.showData = showData;
-        vm.useAsMainList = useAsMainList;
-
-        $scope.$on('YANGMAN_REFRESH_HISTORY', loadHistoryRequests);
         $scope.$on('YANGMAN_REFRESH_COLLECTIONS', loadCollectionRequest);
+        $scope.$on('YANGMAN_REFRESH_HISTORY', loadHistoryRequests);
 
         loadRequests();
 
+        /**
+         * Save request obje to collection from other controller
+         * @param reqObj
+         */
+        function saveRequestFromExt(event, args) {
+            vm.showDgSaveReq(args.params.event, args.params.reqObj, false);
+        }
+
+
+        /**
+         * Clear history requests list and save to storage
+         */
+        function clearHistoryList() {
+            vm.requestList.clear();
+            vm.requestList.saveToStorage();
+        }
+
+        /**
+         * Create history request from other ctrl
+         * @param broadcastEvent
+         * @param params
+         */
+        function saveBcstedHistoryRequest(broadcastEvent, params) {
+            vm.requestList.addRequestToList(params.params);
+            vm.requestList.groupListByDate();
+            vm.requestList.saveToStorage();
+            loadHistoryRequests();
+        }
+
         /**
          * Clear value of input file used to import collection
          */
@@ -60,7 +90,8 @@ define([
          */
         function readCollectionFromFile($fileContent) {
             var data = $fileContent,
-                checkArray = ['sentData',
+                checkArray = [
+                    'sentData',
                     'receivedData',
                     'path',
                     'collection',
@@ -106,17 +137,84 @@ define([
             );
         }
 
+        /**
+         * Fill request form in right panel with request data
+         * @param reqObj
+         */
+        function showForm(reqObj) {
+            var data = reqObj.method === 'GET' ? reqObj.receivedData : reqObj.sentData;
+
+            $scope.rootBroadcast('YANGMAN_FILL_NODE_FROM_REQ', { requestUrl: reqObj.path, requestData: data },
+                function (){
+                    $scope.setRightPanelSection('form');
+                    $scope.rootBroadcast('YANGMAN_HEADER_INIT', { path: reqObj.path, method: reqObj.method });
+
+                    if ( $scope.node ) {
+                        // try to fill node
+                        YangmanService.fillNodeFromResponse($scope.node, data);
+                        $scope.node.expanded = true;
+                    }
+
+                }
+            );
+
+        }
+
+        /**
+         * Force request header to execute request with data from reqObj
+         * @param reqObj
+         */
+        function executeRequest(reqObj) {
+            $scope.rootBroadcast(
+                'YANGMAN_HEADER_INIT',
+                { path: reqObj.path, method: reqObj.method },
+                function (){
+                    $scope.rootBroadcast(
+                        'YANGMAN_EXECUTE_WITH_DATA',
+                        { data: reqObj.sentData },
+                        function (historyReq){
+                            showData(historyReq);
+                        }
+                    );
+                }
+            );
+
+        }
+
 
         /**
-         * Show current reqObj sent data in right panel section
+         * Show current reqObj json data in right panel section
          * @param reqObj
          * @param dataType
          */
-        function showData(reqObj, dataType) {
-            $scope.setRequestToShow(reqObj, dataType);
+        function showData(reqObj) {
+
             $scope.setRightPanelSection('req-data');
-            $scope.broadcastFromRoot('YANGMAN_REFRESH_CM_DATA');
-            $scope.rootBroadcast('YANGMAN_HEADER_INIT', { path: $scope.requestToShow.path });
+            $scope.setJsonView(true, reqObj.method !== 'GET');
+
+            $scope.rootBroadcast('YANGMAN_HEADER_INIT', { path: reqObj.path, method: reqObj.method });
+
+            $scope.rootBroadcast(
+                'YANGMAN_SET_CODEMIRROR_DATA_SENT',
+                { data: reqObj.setDataForView(reqObj.sentData) }
+            );
+            $scope.rootBroadcast(
+                'YANGMAN_SET_CODEMIRROR_DATA_RECEIVED',
+                { data: reqObj.setDataForView(reqObj.receivedData) }
+            );
+
+            var data = reqObj.method === 'GET' ? reqObj.receivedData : reqObj.sentData;
+
+            $scope.rootBroadcast('YANGMAN_FILL_NODE_FROM_REQ', { requestUrl: reqObj.path, leftpanel: 0},
+                function (){
+                    if ( $scope.node ) {
+                        // try to fill node
+                        YangmanService.fillNodeFromResponse($scope.node, data);
+                        $scope.node.expanded = true;
+                    }
+
+                }
+            );
         }
 
         /**
@@ -151,7 +249,7 @@ define([
                     });
                 }
                 vm.mainList.saveToStorage();
-                loadRequests();
+                $scope.rootBroadcast('YANGMAN_REFRESH_HISTORY');
             });
         }
 
@@ -304,8 +402,16 @@ define([
          *
          * @param list collectionList or requestList object
          */
-        function useAsMainList(list){
+        function init(list){
             vm.mainList = list;
+
+            if (list === vm.requestList){
+                // saving from request header after execution
+                $scope.$on('YANGMAN_SAVE_EXECUTED_REQUEST', saveBcstedHistoryRequest);
+                // saving from request header
+                $scope.$on('YANGMAN_SAVE_REQUEST_TO_COLLECTION', saveRequestFromExt);
+            }
+
         }
 
         /**
@@ -342,41 +448,6 @@ define([
             $scope.setHistoryReqsSelected(vm.requestList.selectedRequests.length > 0);
         }
 
-        /**
-         *
-         * @param pathString
-         * @returns {*}
-         */
-        function getApiCallback(pathString) {
-            var snp = PathUtilsService.getStorageAndNormalizedPath(pathString),
-            // if the path is for mountpoint then get the path to treedata structure
-                mpSearchPath = MountPointsConnectorService.alterMpPath(pathString),
-                apiIndexes = PathUtilsService.searchNodeByPath(mpSearchPath, $scope.treeApis, $scope.treeRows),
-                selApi = apiIndexes ? $scope.apis[apiIndexes.indexApi] : null,
-                selSubApi = selApi ? selApi.subApis[apiIndexes.indexSubApi] : null,
-                copiedApi = selSubApi ?
-                    selSubApi.clone({ storage: snp.storage, withoutNode: true, clonePathArray: true }) :
-                    null;
-
-            if (copiedApi) {
-                copiedApi.pathArray.forEach(function (p) {
-                    p.hover = false;
-                });
-
-                PathUtilsService.fillPath(copiedApi.pathArray, snp.normalizedPath);
-            }
-
-            var searchedModule = PathUtilsService.getModuleNameFromPath(pathString);
-
-            if (mpSearchPath.indexOf(mountPrefix) !== -1 && copiedApi){
-                copiedApi = $scope.selSubApi &&
-                searchedModule === $scope.selSubApi.pathArray[1].module ?
-                    copiedApi :
-                    null;
-            }
-
-            return copiedApi;
-        }
     }
 
 });
index 95ee5178b06316af7062f990c7d10b3064c3da54..9ced6ab1ca2b29e4515de963688ac34dd771e8d3 100644 (file)
@@ -1,5 +1,4 @@
 define([
-    'app/yangman/controllers/params-admin.controller',
     'app/yangman/yangman.filters',
     'app/yangman/controllers/modules-list.controller',
     'app/yangman/controllers/module-detail.controller',
@@ -12,18 +11,18 @@ define([
     'app/yangman/services/requests.services',
     'app/yangman/services/parameters.services',
     'app/yangman/directives/ui-codemirror.directive',
-], function (ParamsAdminCtrl) {
+], function () {
     'use strict';
 
     angular.module('app.yangman').controller('YangmanCtrl', YangmanCtrl);
 
     YangmanCtrl.$inject = [
-        '$mdDialog', '$scope', '$rootScope', 'YangmanDesignService', 'ParametersService', 'RequestBuilderService',
+        '$mdDialog', '$scope', '$rootScope', 'YangmanDesignService', 'RequestBuilderService',
         'EventDispatcherService', 'constants', 'PathUtilsService',
     ];
 
     function YangmanCtrl(
-        $mdDialog, $scope, $rootScope, YangmanDesignService, ParametersService, RequestBuilderService,
+        $mdDialog, $scope, $rootScope, YangmanDesignService, RequestBuilderService,
         EventDispatcherService, constants, PathUtilsService
     ) {
         var main = this;
@@ -70,28 +69,16 @@ define([
         $scope.setRequestToShow = setRequestToShow;
         $scope.setRightPanelSection = setRightPanelSection;
         $scope.switchSection = switchSection;
-        $scope.showParamsAdmin = showParamsAdmin;
+        $scope.setParametersList = setParametersList;
 
         init();
 
-
-
         /**
-         * Show popup for parameters administration
-         * @param event
+         * Set parametersList
+         * @param parametersList
          */
-        function showParamsAdmin(event) {
-            $mdDialog.show({
-                controller: ParamsAdminCtrl,
-                controllerAs: 'paramsAdmin',
-                templateUrl: $scope.globalViewPath + 'popup/parameters-admin.tpl.html',
-                parent: angular.element('#yangmanModule'),
-                targetEvent: event,
-                clickOutsideToClose: true,
-                locals: {
-                    parametersList: $scope.parametersList,
-                },
-            });
+        function setParametersList(parametersList) {
+            $scope.parametersList = parametersList;
         }
 
         /**
@@ -115,8 +102,6 @@ define([
          */
         function init(){
             YangmanDesignService.hideMainMenu();
-            $scope.parametersList = ParametersService.createEmptyParametersList('yangman_parameters');
-            $scope.parametersList.loadListFromStorage();
 
             EventDispatcherService.registerHandler(constants.EV_FILL_PATH, fillPathIdentifiersByKey);
             EventDispatcherService.registerHandler(constants.EV_LIST_CHANGED, fillPathIdentifiersByListData);
@@ -164,8 +149,14 @@ define([
         /**
          * Switcher between modules list and module detail
          */
-        function toggleLeftPanel(value){
-            main.leftPanelTab = value || (main.leftPanelTab + 1) % 2;
+        function toggleLeftPanel(){
+            main.leftPanelTab = (main.leftPanelTab + 1) % 2;
+        }
+
+        function setLeftPanel(value) {
+            if ( !angular.isUndefined(value) ) {
+                main.leftPanelTab = value;
+            }
         }
 
         // TODO :: description
@@ -219,7 +210,8 @@ define([
 
             if ( expand ) {
                 $scope.node = null;
-                toggleLeftPanel(leftPanel);
+                // toggleLeftPanel(leftPanel);
+                setLeftPanel(leftPanel);
                 $scope.$broadcast('YANGMAN_MODULE_D_INIT');
             } else {
 
@@ -278,6 +270,11 @@ define([
             $scope.rightPanelSection = section;
         }
 
+        /**
+         * Which codemirror instances will be displayed
+         * @param received
+         * @param sent
+         */
         function setJsonView(received, sent){
             main.jsonView.received = received;
             main.jsonView.sent = sent;
index 356a08814c3f64e16b5e1e8bd4ea7efc27b635d8..46e96d3f4908d725adda77be2e94d8d9657a24ff 100644 (file)
@@ -1,5 +1,7 @@
 require.config({
-
+    paths: {
+        'codeMirror-yangmanJsonHint': 'app/yangman/assets/js/codemirror/addon/hint/yangman-json-hint',
+    },
 });
 
 define(['app/yangman/yangman.module']);
index fcb994a9782ea57d786c516e8cf7c886599d6dc2..9607d1f537f73a2c5c519554c902c66762be6179 100644 (file)
@@ -18,7 +18,6 @@ define(
             var self = this;
 
             self.collections = [];
-            self.getApiFunction = null;
             self.selectedRequests = [];
 
             self.addRequestToList = addRequestToList;
@@ -31,21 +30,15 @@ define(
             self.getCollection = getCollection;
             self.getCollectionNames = getCollectionNames;
             self.loadListFromFile = loadListFromFile;
-            self.refresh = refresh;
             self.renameCollection = renameCollection;
             self.toggleReqSelection = toggleReqSelection;
             self.toJSON = toJSON;
             self.getCollectionInJSON = getCollectionInJSON;
-            self.setGetApiFunction = setGetApiFunction;
 
             /**
-             * Setter for getApiFunction
-             * @param getApiFunction
+             *
+             * @param collectionName
              */
-            function setGetApiFunction(getApiFunction){
-                self.getApiFunction = getApiFunction;
-            }
-
             function getCollectionInJSON(collectionName){
                 return JSON.stringify(self.toJSON(collectionName));
             }
@@ -91,7 +84,6 @@ define(
                         req.selected = reqObj === req;
                     });
                 });
-
             }
 
             /**
@@ -110,7 +102,7 @@ define(
              * @returns {HistoryRequest|*}
              */
             function createEntry(elem) {
-                return RequestsService.createHistoryRequestFromElement(elem, self.getApiFunction);
+                return RequestsService.createHistoryRequestFromElement(elem);
             }
 
             /**
@@ -164,16 +156,6 @@ define(
                 }
             }
 
-            /**
-             * Refresh each requst in collections using his getApiFunction
-             */
-            function refresh() {
-                self.collections.forEach(function (collection) {
-                    collection.data.forEach(function (elem) {
-                        elem.refresh(self.getApiFunction);
-                    });
-                });
-            }
 
             /**
              *
@@ -222,8 +204,7 @@ define(
                 if (data){
                     ParsingJsonService.parseJson(data).map(function (elem) {
                         return RequestsService.createHistoryRequest(elem.sentData, elem.receivedData, elem.path,
-                            elem.parametrizedPath, elem.method, elem.status, elem.name, elem.collection,
-                            self.getApiFunction);
+                            elem.parametrizedPath, elem.method, elem.status, elem.name, elem.collection);
                     }).forEach(function (elem) {
                         self.addRequestToList(elem);
                     });
index a7a335a7af2823d9d4ec13c9cfbe19451c889470..d24be1c1993049ffaca03842eefd58dfcf610950 100644 (file)
@@ -12,31 +12,23 @@ define([], function (){
         var self = this;
 
         // properties
+        self.collection = '';
+        self.method = '';
         self.name = '';
-        self.sentData = null;
         self.path = '';
-        self.parametrizedPath = null;
-        self.method = '';
-        self.status = '';
         self.receivedData = null;
-        self.api = null;
-        self.availability = false;
-        self.collection = '';
-        self.timestamp = '';
         self.selected = false;
+        self.sentData = null;
+        self.status = '';
+        self.timestamp = '';
 
         // functions
-        self.getIdentifiers = getIdentifiers;
-        self.refresh = refresh;
         self.clone = clone;
         self.toJSON = toJSON;
-        self.clonePathArray = clonePathArray;
-        self.setParametrizedPath = setParametrizedPath;
         self.getLastPathDataElemName = getLastPathDataElemName;
         self.setDataForView = setDataForView;
-        self.clearParametrizedData = clearParametrizedData;
-        self.copyWithParametrizationAsNatural = copyWithParametrizationAsNatural;
         self.setData = setData;
+        self.setExecutionData = setExecutionData;
 
         /**
          * Grouped setter
@@ -45,71 +37,41 @@ define([], function (){
          * @param receivedData
          * @param status
          * @param path
-         * @param parametrizedPath
          * @param operation
-         * @param api
          * @param name
          * @param collection
          * @param timestamp
          */
-        function setData(sentData, receivedData, status, path, parametrizedPath, operation, api, name, collection,
-                         timestamp) {
+        function setData(sentData, receivedData, status, path, operation, name, collection, timestamp) {
 
             self.sentData = sentData === null || sentData === undefined || $.isEmptyObject(sentData) ? null : sentData;
             self.name = name;
             self.path = path;
-            self.parametrizedPath = parametrizedPath;
             self.method = operation;
             self.status = status;
             self.receivedData = receivedData === null || receivedData === undefined || $.isEmptyObject(receivedData) ?
-                null :
-                receivedData;
-            self.api = api;
-            self.availability = (api !== null);
+                null : receivedData;
             self.collection = collection;
             self.timestamp = timestamp;
         }
 
         /**
-         *
-         * @returns {Array}
+         * Set data which might be available after executing request
+         * @param sentData
+         * @param receivedData
+         * @param status - http status from response header
          */
-        function getIdentifiers() {
-            var identifiers = [];
-
-            self.api.pathArray.forEach(function (elem) {
-                elem.identifiers.forEach(function (i) {
-                    identifiers.push(i);
-                });
-            });
-
-            return identifiers;
+        function setExecutionData(sentData, receivedData, status) {
+            self.sentData = sentData;
+            self.receivedData = receivedData;
+            self.status = status ? (status > 199 && status < 205 ? 'success' : 'erorr') : '';
         }
 
-        /**
-         * Refresh each element using getApiFunction
-         * @param getApiFunction
-         */
-        function refresh(getApiFunction) {
-            var refreshedApi = getApiFunction(self.path);
-
-            self.api = refreshedApi;
-            self.availability = (refreshedApi !== null);
-        }
 
         /**
          *
-         * @returns {{
-             *  sentData: *,
-             *  receivedData: *,
-             *  path: *,
-             *  collection: *,
-             *  parametrizedPath: *,
-             *  method: *,
-             *  status: *,
-             *  name: *,
-             *  timestamp: *
-             * }}
+         * @returns {{sentData: (null|*), receivedData: (null|*), path: (string|*), collection: (string|*),
+         * method: (string|*), status: (string|*), name: (string|*), timestamp: (string|*)}}
          */
         function toJSON() {
             var obj = {
@@ -117,7 +79,6 @@ define([], function (){
                 receivedData: self.receivedData,
                 path: self.path,
                 collection: self.collection,
-                parametrizedPath: self.parametrizedPath,
                 method: self.method,
                 status: self.status,
                 name: self.name,
@@ -127,23 +88,7 @@ define([], function (){
             return obj;
         }
 
-        /**
-         *
-         */
-        function clonePathArray() {
-            if ( self.api && self.api.pathArray ) {
-                self.api.clonedPathArray = self.api.pathArray.map(function (pe) {
-                    return pe.clone();
-                });
-            } else {
-                self.api.clonedPathArray = [];
-            }
-        }
 
-        function setParametrizedPath(){
-            self.clonePathArray();
-            PathUtilsService.fillPath(self.api.clonedPathArray, self.parametrizedPath);
-        }
 
         /**
          *
@@ -160,7 +105,7 @@ define([], function (){
          * @param data
          * @returns {string}
          */
-        function setDataForView(sent, data){
+        function setDataForView(data){
             var newData = {},
                 parsedData = '';
 
@@ -168,21 +113,9 @@ define([], function (){
             parsedData = JSON.stringify(
                 YangUtilsService.stripAngularGarbage(newData, self.getLastPathDataElemName()), null, 4);
 
-            if ( sent && self.api ) {
-                if ( self.parametrizedPath ) {
-                    self.setParametrizedPath();
-                } else {
-                    self.clonePathArray();
-                }
-            }
-
             return parsedData;
         }
 
-        function clearParametrizedData() {
-            self.parametrizedPath = null;
-            self.clonePathArray();
-        }
 
         /**
          *
@@ -190,33 +123,8 @@ define([], function (){
          */
         function clone() {
             var result = new HistoryRequestModel(PathUtilsService, YangUtilsService, ParsingJsonService);
-            result.setData(self.sentData, self.receivedData, self.status, self.path,
-                self.parametrizedPath, self.method, self.api, self.name, self.collection, self.timestamp);
-            return result;
-        }
-
-        /**
-         *
-         * @param parametrizedPath
-         * @param getApiFunction
-         * @param dataForView
-         * @param JSONparsingErrorClbk
-         * @returns {*}
-         */
-        function copyWithParametrizationAsNatural(parametrizedPath, getApiFunction, dataForView,
-                                                  JSONparsingErrorClbk){
-
-            var parsedJsonObj = null,
-                result = null;
-
-            parsedJsonObj = ParsingJsonService.parseJson(dataForView, JSONparsingErrorClbk);
-
-            if (parsedJsonObj){
-                result = new HistoryRequestModel(PathUtilsService, YangUtilsService, ParsingJsonService);
-                result.setData(parsedJsonObj, self.receivedData, self.status, parametrizedPath, '', self.method,
-                    (getApiFunction || angular.noop)(result.path), self.name, self.collection, self.timestamp);
-            }
-
+            result.setData(self.sentData, self.receivedData, self.status, self.path, self.method, self.name,
+                self.collection, self.timestamp);
             return result;
         }
 
index dd018a52605d34fcebf08faeeab270286789a165..a21397801a9cb716a37297085284b7565274b3e1 100644 (file)
@@ -14,27 +14,15 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
         /* jshint validthis: true */
         var self = this;
         self.list = [];
-        self.listGroupedByDate = {};
+        self.dateGroups = [];
         self.selectedRequests = [];
 
         self.addRequestToList = addRequestToList;
         self.clear = clear;
         self.createEntry = createEntry;
         self.deleteRequestItem = deleteRequestItem;
-        self.getApiFunction = null;
         self.groupListByDate = groupListByDate;
-        self.refresh = refresh;
         self.toggleReqSelection = toggleReqSelection;
-        self.setGetApiFunction = setGetApiFunction;
-
-        /**
-         * Setter for getApiFunction
-         * @param getApiFunction
-         */
-        function setGetApiFunction(getApiFunction){
-            self.getApiFunction = getApiFunction;
-        }
-
 
         /**
          * Mark reqObj as selected
@@ -60,6 +48,17 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
 
         }
 
+        /**
+         * Round timestamp to day
+         * @param timeStamp
+         * @returns {number|*}
+         */
+        function roundTimestampToDate(timeStamp){
+            timeStamp -= timeStamp % (24 * 60 * 60 * 1000);//subtract amount of time since midnight
+            timeStamp += new Date().getTimezoneOffset() * 60 * 1000;//add on the timezone offset
+            return timeStamp;
+        }
+
         /**
          * Grouping by date to show date groups in yangman
          */
@@ -67,11 +66,24 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
             self.list.forEach(addToListDateGroup);
 
             function addToListDateGroup(elem){
-                var groupName = new Date(elem.timestamp).toDateString();
-                if (!self.listGroupedByDate.hasOwnProperty(groupName)){
-                    self.listGroupedByDate[groupName] = [];
+                var groupName = roundTimestampToDate(elem.timestamp),
+                    dateGroupArr = self.dateGroups.filter(function(group){
+                        return group.name === groupName;
+                    }),
+                    dateGroup = null;
+
+                if (dateGroupArr.length){
+                    dateGroup = dateGroupArr[0];
+                }
+                else {
+                    dateGroup = {
+                        name: groupName,
+                        longName: new Date(groupName).toDateString(),
+                        requests: [],
+                    };
+                    self.dateGroups.push(dateGroup);
                 }
-                self.listGroupedByDate[groupName].push(elem);
+                dateGroup.requests.push(elem);
             }
         }
 
@@ -81,7 +93,7 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
          * @returns {HistoryRequest|*}
          */
         function createEntry(elem) {
-            return RequestsService.createHistoryRequestFromElement(elem, self.getApiFunction);
+            return RequestsService.createHistoryRequestFromElement(elem);
         }
 
         /**
@@ -92,15 +104,6 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
             self.list.push(reqObj);
         }
 
-        /**
-         * Refresh each element using self.detApiFunction
-         */
-        function refresh() {
-            self.list.forEach(function (elem) {
-                elem.refresh(self.getApiFunction);
-            });
-        }
-
         /**
          *
          * @param elem
@@ -111,7 +114,7 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
 
         function clear() {
             self.list = [];
-            self.listGroupedByDate = {};
+            self.dateGroups = [];
             self.selectedRequests = [];
         }
 
index eaaeb3be6900315cc22233c9a4a98a169c5a5393..0da83abee9a2f6328ac0716b24727426459478a9 100644 (file)
@@ -9,17 +9,110 @@ define(
 
         angular.module('app.yangman').service('RequestsService', RequestsService);
 
-        RequestsService.$inject = ['PathUtilsService', 'ParsingJsonService', 'YangUtilsService'];
+        RequestsService.$inject = ['PathUtilsService', 'ParametersService', 'ParsingJsonService', 'YangUtilsService'];
 
-        function RequestsService(PathUtilsService, ParsingJsonService, YangUtilsService){
+        function RequestsService(PathUtilsService, ParametersService, ParsingJsonService, YangUtilsService){
 
             var service = {};
 
+            service.applyParams = applyParams;
             service.createEmptyCollectionList = createEmptyCollectionList;
             service.createEmptyHistoryList = createEmptyHistoryList;
             service.createHistoryRequestFromElement = createHistoryRequestFromElement;
             service.createHistoryRequest = createHistoryRequest;
+            service.scanDataParams = scanDataParams;
             service.validateFile = validateFile;
+            service.replaceStringInText = replaceStringInText;
+
+            /**
+             * Scan used parameters in current line of codemirror
+             * @param {ParametersListModel} paramsObj - list of parameters to be searched for
+             * @param {string} lineString - line from current codemirror to be inspected
+             * @returns array of {ParameterModel}
+             */
+            function scanDataParams(paramsObj, lineString) {
+
+                var usedParamLabelArray = [];
+
+                var params = lineString ? lineString.match(/<<(?!<<)[a-zA-Z0-9]+>>/g) : null;
+
+                if ( params ) {
+                    params
+                        .filter(onlyUnique)
+                        .forEach(function (param) {
+                            usedParamLabelArray.push(removeUnwantedChars(param));
+                        });
+                }
+
+                var returnedParamsList = paramsObj.list.filter( function (param){
+                    var paramIndex = usedParamLabelArray.indexOf(param.key);
+                    if ( paramIndex !== -1 ) {
+                        return usedParamLabelArray.splice(paramIndex, 1);
+                    }
+                    else {
+                        return false;
+                    }
+                });
+
+                usedParamLabelArray.forEach(function (param){
+                    returnedParamsList.push(ParametersService.createParameter(param));
+                });
+
+                return returnedParamsList;
+
+                /**
+                 * remove chars greater then and less then from parameter definition
+                 * @param val
+                 * @returns {string}
+                 */
+                function removeUnwantedChars(val){
+                    var string = val.substring(2);
+                    return string.substring(0, string.indexOf('>>'));
+                }
+
+                /**
+                 * Filter function
+                 * @param value
+                 * @param index
+                 * @param self
+                 * @returns {boolean}
+                 */
+                function onlyUnique(value, index, self) {
+                    return self.indexOf(value) === index;
+                }
+            }
+
+            /**
+             * Replace all parameters with its values
+             * @param paramsObj
+             * @param requestData
+             * @returns {*}
+             */
+            function applyParams(paramsObj, data) {
+                var dataStr = JSON.stringify(data);
+
+                paramsObj.list.forEach(function (param){
+                    dataStr = service.replaceStringInText(dataStr, '<<' + param.key + '>>', param.value);
+                });
+
+                return ParsingJsonService.parseJson(dataStr);
+            }
+
+            /**
+             * Service for replacing string in text
+             * @param text
+             * @param strToReplace
+             * @param newStr
+             * @returns {*}
+             */
+            function replaceStringInText(text, strToReplace, newStr) {
+                var replacedText = text;
+                if (text.indexOf(strToReplace) > -1) {
+                    replacedText = text.split(strToReplace).join(newStr);
+                }
+                return replacedText;
+            }
+
 
             /**
              * Validating collection import file
@@ -46,23 +139,19 @@ define(
              * @param sentData
              * @param receivedData
              * @param path
-             * @param parametrizedPath
              * @param operation
              * @param status
              * @param name
              * @param collection
-             * @param getApiFunction
-             * @returns {HistoryRequest}
+             * @returns {*}
+             * @param timestamp
              */
-            function createHistoryRequest(sentData, receivedData, path, parametrizedPath, operation, status, name,
-                                          collection, timestamp, getApiFunction){
+            function createHistoryRequest(sentData, receivedData, path, operation, status, name, collection) {
 
-                var api = (getApiFunction || angular.noop)(path),
-                    receivedDataProcessed = status === 'success' ? receivedData : null,
+                var receivedDataProcessed = status === 'success' ? receivedData : null,
                     result = new HistoryRequestModel(PathUtilsService, YangUtilsService, ParsingJsonService);
 
-                result.setData(sentData, receivedDataProcessed, status, path, parametrizedPath, operation, api, name,
-                    collection, timestamp);
+                result.setData(sentData, receivedDataProcessed, status, path, operation, name, collection, Date.now());
 
                 return result;
             }
@@ -70,14 +159,11 @@ define(
             /**
              * Creating {HistoryRequest} from elem containing all necessary data
              * @param {Object} elem
-             * @param {function} getApiFunction
-             * @returns {HistoryRequest}
+             * @returns {*}
              */
-            function createHistoryRequestFromElement(elem, getApiFunction) {
-                return service.createHistoryRequest(elem.sentData, elem.receivedData,
-                    elem.path, elem.parametrizedPath,
-                    elem.method, elem.status, elem.name,
-                    elem.collection, elem.timestamp, getApiFunction);
+            function createHistoryRequestFromElement(elem) {
+                return service.createHistoryRequest(elem.sentData, elem.receivedData, elem.path, elem.method,
+                    elem.status, elem.name, elem.collection, Date.now());
             }
 
             /**
@@ -86,23 +172,20 @@ define(
              * @param getApiFunction
              * @returns {CollectionList}
              */
-            function createEmptyCollectionList(name, getApiFunction){
+            function createEmptyCollectionList(name){
                 var result = new CollectionListModel(ParsingJsonService, service);
                 result.setName(name);
-                result.setGetApiFunction(getApiFunction);
                 return result;
             }
 
             /**
              * Service for creating empty history list
              * @param name
-             * @param getApiFunction
-             * @returns {HistoryList}
+             * @returns {*}
              */
-            function createEmptyHistoryList(name, getApiFunction){
+            function createEmptyHistoryList(name){
                 var result = new HistoryListModel(ParsingJsonService, service);
                 result.setName(name);
-                result.setGetApiFunction(getApiFunction);
                 return result;
             }
 
index 7efe5b5be7f38d0d0557f8193bd6c1c23a911b97..339a137bf38539274b90fd36fd281e213b2469bf 100644 (file)
@@ -8,18 +8,21 @@ define([], function () {
         'YangUtilsService',
         'YangUtilsRestangularService',
         'ENV',
+        'RequestsService',
     ];
 
     function YangmanService(
         RequestBuilderService,
         YangUtilsService,
         YangUtilsRestangularService,
-        ENV
+        ENV,
+        RequestsService
     ){
         var service = {
             executeRequestOperation: executeRequestOperation,
             fillNodeFromResponse: fillNodeFromResponse,
             getDataStoreIndex: getDataStoreIndex,
+            prepareAllRequestData: prepareAllRequestData,
         };
 
         return service;
@@ -40,28 +43,29 @@ define([], function () {
             return result ? rIndex : null;
         }
 
-        function executeRequestOperation(
-            selectedApi,
-            selectedSubApi,
-            operation,
-            node,
-            dataType,
-            requestUrl,
-            requestData,
-            successCbk,
-            errorCbk
-        ){
-            var reqString = selectedSubApi ? selectedSubApi.buildApiRequestString() : '',
-                preparedRequestData = {},
-                headers,
-                time = {
-                    started: 0,
-                    finished: 0,
-                },
-                customRestangular = null;
-
-            // set full response detail
-            YangUtilsRestangularService.setFullResponse(true);
+        /**
+         * Prepare all necessary data for executing or saving request
+         * @param selectedApi
+         * @param selectedSubApi
+         * @param operation
+         * @param node
+         * @param dataType
+         * @param requestUrl
+         * @param requestData
+         * @param params
+         * @returns {{customRestangular: null, headers: {}, operation: string, reqString: string, reqHeaders: {},
+         *          reqData: {}}}
+         */
+        function prepareAllRequestData(selectedApi, selectedSubApi, operation, node, dataType, requestUrl, requestData,
+                                       params) {
+            var allPreparedData = {
+                customRestangular: null,
+                headers: {},
+                operation: '',
+                reqString: selectedSubApi ? selectedSubApi.buildApiRequestString() : '',
+                reqHeaders: {},
+                reqData: {},
+            };
 
             // set correct host into restangular based on shown data type
             if ( dataType === 'req-data' ){
@@ -69,95 +73,95 @@ define([], function () {
                     raParam = '';
 
                 YangUtilsRestangularService.setBaseUrl(parser.origin);
-                reqString = parser.pathname.slice(1).split('/');
-                raParam = reqString.shift();
-                reqString = reqString.join('/');
+                allPreparedData.reqString = parser.pathname.slice(1).split('/');
+                raParam = allPreparedData.reqString.shift();
+                allPreparedData.reqString = allPreparedData.reqString.join('/');
 
-                customRestangular = YangUtilsRestangularService.one(raParam);
-                preparedRequestData = requestData;
+                allPreparedData.customRestangular = YangUtilsRestangularService.one(raParam);
+                allPreparedData.reqData = RequestsService.applyParams(params, requestData);
             } else {
 
                 YangUtilsRestangularService.setBaseUrl(ENV.getBaseURL('MD_SAL'));
-                customRestangular  = YangUtilsRestangularService.one('restconf');
+                allPreparedData.customRestangular  = YangUtilsRestangularService.one('restconf');
 
-                // if node build sent request
                 if ( node ) {
 
                     node.buildRequest(RequestBuilderService, requestData, node.module);
-                    angular.copy(requestData, preparedRequestData);
+                    angular.copy(requestData, allPreparedData.reqData);
+                    allPreparedData.reqData = RequestsService.applyParams(params, allPreparedData.reqData);
 
-                    preparedRequestData = YangUtilsService.prepareRequestData(
-                        preparedRequestData,
+                    allPreparedData.reqData = YangUtilsService.prepareRequestData(
+                        allPreparedData.reqData,
                         operation,
-                        reqString,
+                        allPreparedData.reqString,
                         selectedSubApi
                     );
 
-                    headers = YangUtilsService.prepareHeaders(preparedRequestData);
+                    allPreparedData.headers = YangUtilsService.prepareHeaders(allPreparedData.reqData);
                 }
             }
 
-            //reqString = reqPath ? reqPath.slice(selectedApi.basePath.length, reqPath.length) : reqString;
-            //var requestPath = selectedApi.basePath + reqString;
+            allPreparedData.operation = YangUtilsService.prepareOperation(operation);
+            return allPreparedData;
+        }
 
+        /**
+         * Execute request built from this data
+         * @param selectedApi
+         * @param selectedSubApi
+         * @param operation
+         * @param node
+         * @param dataType
+         * @param requestUrl
+         * @param requestData
+         * @param successCbk
+         * @param errorCbk
+         * @param params
+         */
+        function executeRequestOperation(selectedApi, selectedSubApi, operation, node, dataType, requestUrl,
+                                         requestData, params, successCbk, errorCbk) {
+            var time = {
+                started: 0,
+                finished: 0,
+            };
 
+            YangUtilsRestangularService.setFullResponse(true);
 
-            operation = YangUtilsService.prepareOperation(operation);
+            // prepare all necessary data
+            var allPreparedData = prepareAllRequestData(selectedApi, selectedSubApi, operation, node, dataType,
+                requestUrl, requestData, params);
 
             // start track time response
             time.started = new Date().getMilliseconds();
 
             // executing operation
-            customRestangular
-                .customOperation(operation.toLowerCase(), reqString, null, headers, preparedRequestData)
-                .then(function (response) {
-                    // finish track time response
-                    time.finished = new Date().getMilliseconds();
-
-                    var reqObj = {
-                        status: response.status,
-                        statusText: response.statusText,
-                        time: (time.finished - time.started),
-                    };
-
-                    (successCbk || angular.noop)(reqObj, response);
-
-                }, function (response) {
-                    // finish track time response
-                    time.finished = new Date().getMilliseconds();
-
-                    var reqObj = {
-                        status: response.status,
-                        statusText: response.statusText,
-                        time: (time.finished - time.started),
-                    };
-
-                    (errorCbk || angular.noop)(reqObj, response);
-
-                    /*var errorMsg = '';
-
-                    if (resp.data && resp.data.errors && resp.data.errors.error && resp.data.errors.error.length) {
-                        errorMsg = ': ' + resp.data.errors.error.map(function (e) {
-                            return e['error-message'];
-                        }).join(', ');
-                    }
-
-                    /!**
-                     * TODO after first GET we have set $scope.node with data
-                     * so build from the top of this function return requestData
-                     *!/
-                    if (operation === 'GET'){
-                        requestData = {};
-                    }
-
-                    console.info(
-                        'error sending request to', selectedSubApi ? selectedSubApi.buildApiRequestString() : '',
-                        'reqString', reqString,
-                        'got', resp.status,
-                        'data', resp.data
-                    );*/
+            allPreparedData.customRestangular.customOperation(
+                allPreparedData.operation.toLowerCase(),
+                allPreparedData.reqString,
+                null,
+                allPreparedData.headers,
+                allPreparedData.reqData
+            )
+            .then(
+                function (response) {
+                    (successCbk || angular.noop)(finishExecuting(response), response);
+                },
+                function (response) {
+                    (errorCbk || angular.noop)(finishExecuting(response), response);
                 }
             );
+
+            function finishExecuting(response){
+                // finish track time response
+                time.finished = new Date().getMilliseconds();
+
+                return {
+                    status: response.status,
+                    statusText: response.statusText,
+                    time: (time.finished - time.started),
+                    requestData: allPreparedData.reqData,
+                };
+            }
         }
 
         /**
@@ -185,7 +189,7 @@ define([], function () {
          * @param data
          */
         function fillNodeFromResponse(node, data){
-            var props = Object.getOwnPropertyNames(data);
+            var props = data ? Object.getOwnPropertyNames(data) : [];
 
             // fill each property - needed for root mountpoint node,
             // in other cases there should be only one property anyway
index 54cc869b1adac80a87afbf36f7c2156b89065085..0f386d8edb00535e263d24a789845bf17f674a30 100644 (file)
@@ -7,7 +7,8 @@
                  class="arrow-switcher"
                  ng-click="main.toggleLeftPanel()"
                  ng-class="{'arrow-switcher__left' : main.leftPanelTab === 0}"
-                 ng-show="!main.selectedMainTab && selectedDatastore"> play_arrow </md-icon>
+                 ng-show="selectedDatastore"> play_arrow </md-icon>
+                 <!--ng-show="!main.selectedMainTab && selectedDatastore"> play_arrow </md-icon>-->
         <!-- content -->
         <md-tabs md-border-bottom md-selected="main.leftPanelTab" class="yangmanModule__left-panel__detail-list-tabs-container">
             <md-tab label="models tree">
index 6c7a3e267323cefd7b8e46208b1c62611475118a..ba049c1fcb51917be3e75bc39a6b752cc3f6a25d 100644 (file)
@@ -1,6 +1,6 @@
 <md-list class="yangmanModule__requests-list__collections-list"
          ng-cloak
-         ng-init="reqList.useAsMainList(reqList.collectionList)"
+         ng-init="reqList.init(reqList.collectionList)"
          ng-controller="RequestsListCtrl as reqList">
 
     <md-content class="searchBox" layout="row">
index d470887e8820c00d1f786f2e37d20929304b6ccd..59822ca23cf523953769d125e64173cb74bc0fd9 100644 (file)
@@ -1,8 +1,9 @@
 <md-list class="yangmanModule__requests-list h100"
          ng-cloak
-         ng-init="reqList.useAsMainList(reqList.requestList)"
+         ng-init="reqList.init(reqList.requestList)"
          ng-controller="RequestsListCtrl as reqList">
 
+    <!-- search box -->
     <md-content class="searchBox" layout="row">
         <md-icon class="material-icons">search</md-icon>
         <input class="ng-pristine ng-valid ng-touched"
@@ -18,7 +19,9 @@
     </md-content>
 
     <md-divider></md-divider>
+    <!-- /search box-->
 
+    <!-- buttons for saving, deleting, clearing -->
     <md-button ng-show="reqList.mainList.selectedRequests.length"
                ng-click="reqList.showDgSaveReq($event, main.currentPath)">
         {{'YANGMAN_REQS_SAVE_TO_COL'| translate}}
                ng-click="reqList.showDgDeleteRequests($event)">
         {{'YANGMAN_REQS_DELETE'| translate}}
     </md-button>
-
+    <md-button ng-hide="reqList.mainList.selectedRequests.length || !reqList.mainList.list.length"
+               ng-click="reqList.clearHistoryList()">
+        {{'YANGMAN_CLEAR_HISTORY' | translate}}
+    </md-button>
     <md-divider ng-show="reqList.mainList.selectedRequests.length"></md-divider>
+    <!-- /buttons for saving, deleting, clearing -->
 
+    <!-- list of items grouped by date -->
     <md-content class="scrollableY">
-        <md-list-item ng-repeat="(groupName, requests) in reqList.mainList.listGroupedByDate"
+        <md-list-item ng-repeat="group in reqList.mainList.dateGroups | orderBy: 'name': true"
                       class="yangmanModule__requests-list__group"
-                      ng-if="(requests|filter:reqList.filterReq).length">
+                      ng-if="(group.requests | filter:reqList.filterReq).length">
 
             <div layout="column" flex>
 
+                <!-- date group header -->
                 <md-subheader class="md-no-sticky">
-                    {{groupName | date : 'short'}}
+                    {{group.longName}}
                 </md-subheader>
+                <!-- /date group header -->
 
+                <!-- list of requests in current group -->
                 <md-list>
-                    <div ng-repeat="request in requests | filter: reqList.filterReq"
+                    <div ng-repeat="request in group.requests | filter: reqList.filterReq track by $index | orderBy: 'timestamp'"
                          layout="row"
                          ng-include src="globalViewPath + 'leftpanel/request-item.tpl.html'">
                     </div>
                 </md-list>
+                <!-- /list of requests in current group -->
 
             </div>
 
@@ -54,4 +66,6 @@
 
         </md-list-item>
     </md-content>
+    <!-- /list of items grouped by date -->
+
 </md-list>
index 4b1bcb5a36fb10b8dd8770d07446a6b129cee9ec..20178969b522de70ba114b63d0534d60fdb99298 100644 (file)
@@ -3,11 +3,11 @@
               ng-class="{selected: request.selected}"
               layout="row"
               flex="100"
-              ng-click="reqList.selectRequest($event, request)">
+              ng-click="reqList.selectRequest($event, request); reqList.showData(request);">
 
     <div flex="15" class="yangmanModule__requests-list__group__item__method" layout-align="center center">
-        <p class="{{request.method}}"> {{request.method}} </p>
-        <md-tooltip md-direction="right">{{request}}</md-tooltip>
+        <p class="{{request.status === 'success' || !request.status ? request.method : 'error'}}"> {{request.method === 'DELETE' ? 'DEL' : request.method }} </p>
+        <md-tooltip md-direction="bottom" ng-show="request.status">{{request.status | uppercase }}</md-tooltip>
     </div>
 
     <div flex class="yangmanModule__requests-list__group__item__path" layout="column">
     </md-button>
     <md-menu-content class="reqMenu">
         <md-menu-item>
-            <md-button aria-label="{{'YANGMAN_REQ_RUN'| translate}}" class=" " ng-click="" ng-disabled="true">
+            <md-button aria-label="{{'YANGMAN_REQ_RUN'| translate}}" class="" ng-click="reqList.executeRequest(request)">
                 <i class="material-icons">play_arrow</i>
                 {{'YANGMAN_REQ_RUN'| translate}}
             </md-button>
         </md-menu-item>
         <md-menu-item>
-            <md-button aria-label="{{'YANGMAN_REQ_FILL_FORM'| translate}}" ng-disabled="true">
+            <md-button aria-label="{{'YANGMAN_REQ_SHOW_FORM'| translate}}" ng-click="reqList.showForm(request)">
                 <i class="material-icons">exit_to_app</i>
-                {{'YANGMAN_REQ_FILL_FORM'| translate}}
+                {{'YANGMAN_REQ_SHOW_FORM'| translate}}
             </md-button>
         </md-menu-item>
         <md-menu-item>
             <md-button aria-label="{{'YANGMAN_REQ_SHOW_SENT_DATA'| translate}}"
-                       ng-click="reqList.showData(request, 'sentData')"
-                       ng-disabled="request.sentData===null">
+                       ng-click="reqList.showData(request)">
                 <i class="material-icons">call_made</i>
-                {{'YANGMAN_REQ_SHOW_SENT_DATA'| translate}}
-            </md-button>
-        </md-menu-item>
-        <md-menu-item>
-            <md-button aria-label="{{'YANGMAN_REQ_SHOW_RCVD_DATA'| translate}}"
-                       ng-click="reqList.showData(request, 'receivedData')"
-                       ng-disabled="request.receivedData===null">
-                <i class="material-icons">call_received</i>
-                {{'YANGMAN_REQ_SHOW_RCVD_DATA'| translate}}
+                {{'YANGMAN_REQ_SHOW_JSON_DATA'| translate}}
             </md-button>
         </md-menu-item>
         <md-menu-item ng-if="request.collection.length">
index 0181b6caeee341927fe131b988e56d4ec32ef5f2..0247cc3dde7a352b9b485b6e9e5324b924b5708c 100644 (file)
@@ -19,7 +19,7 @@
 
     <!-- Sent data -->
     <div ng-controller="RequestDataCtrl as requestData"
-         ng-if="main.jsonView.sent"
+         ng-show="main.jsonView.sent"
          ng-init="requestData.init('SENT')"
          ng-class="{'half-size': main.jsonView.received && main.jsonView.sent}">
 
@@ -29,7 +29,7 @@
 
     <!-- Received data -->
     <div ng-controller="RequestDataCtrl as requestData"
-         ng-if="main.jsonView.received"
+         ng-show="main.jsonView.received"
          ng-init="requestData.init('RECEIVED')"
          ng-class="{'half-size': main.jsonView.received && main.jsonView.sent}">
 
index c5ca7495b46838602a40209c1bb8d1113d5f5ac0..30a983cdd59cb963e3da803f26808bec5a6769d5 100644 (file)
@@ -1,5 +1,11 @@
-<div ng-model="requestData.data"
-     ui-codemirror
-     ui-codemirror-opts="requestData.getDataEditorOptions(false, 'eclipse')"
-     class="codemirror-container">
+<textarea ng-model="requestData.data"
+          ui-codemirror
+          ui-codemirror-opts="requestData.dataEditorOptions"
+          class="codemirror-container">
+</textarea>
+
+<div class="paramsBox" ng-show="requestData.paramsArray.length">
+    <div  ng-repeat="param in requestData.paramsArray" class="line">
+        <strong><<{{param.key}}>></strong> : <span>{{param.value !== undefined ? param.value : 'YANGUI_PARAM_DONT_REPLACE' | translate}}</span>
+    </div>
 </div>
index 847320bf15ae6a2709b05b2685e474df4fb9247f..450c6532e15e8ceaa0e382954715f669583b5c33 100644 (file)
@@ -52,8 +52,9 @@
 
         <!-- Action buttons -->
         <md-input-container flex="nogrow" layout="row" layout-align="start start" class="action-buttons">
-            <md-button class="md-raised md-primary" ng-click="requestHeader.checkExecutedData()">{{'YANGMAN_SEND' | translate}}</md-button>
-            <md-button class="md-raised md-warn">{{'YANGMAN_SAVE' | translate}}</md-button>
+            <md-button class="md-raised md-primary" ng-click="requestHeader.prepareDataAndExecute()">{{'YANGMAN_SEND' | translate}}</md-button>
+            <md-button class="md-raised md-warn" ng-click="requestHeader.saveRequestToCollection($event)">{{'YANGMAN_SAVE' | translate}}</md-button>
+            <md-button class="md-raised" ng-click="requestHeader.showParamsAdmin($event)">{{'YANGMAN_PARAMETERS' | translate}}</md-button>
         </md-input-container>
     </section>
 
@@ -95,4 +96,4 @@
             </span>
         </md-content>
     </section>
-</md-content>
\ No newline at end of file
+</md-content>
index bbc5f6f3b1d974cc85aa03470f2af07d87dbd34a..943889221c73f32380801c461ee03e50c1367b64 100644 (file)
@@ -21,7 +21,8 @@
 @reqMethodGet: #63d33b;
 @reqMethodPut: #6fbad3;
 @reqMethodPost: #ea9c30;
-@reqMethodDelete: #ea3b27;
+@reqMethodDelete: #eabb2f;
+@reqError: #ff0000;
 
 // helpers
 .pointer{
@@ -381,6 +382,8 @@ md-ink-bar.custom{
                 height: 100%;
                 padding-right: 2px;
                 padding-bottom: 10px;
+                position: relative;
+
 
                 > div {
                     height: calc(~'100% - 25px');
@@ -396,6 +399,14 @@ md-ink-bar.custom{
                 }
             }
 
+            .paramsBox{
+                position: absolute;
+                top: 30px;
+                right: 26px;
+                background-color: rgba(235, 235, 228, 0.62);
+                padding: 15px;
+            }
+
             .CodeMirror { height: 100%; }
         }
 
@@ -688,6 +699,9 @@ md-ink-bar.custom{
                     .DELETE{
                         color: @reqMethodDelete;
                     }
+                    .error{
+                        color: @reqError;
+                    }
                 }
             }
 
@@ -805,6 +819,13 @@ md-ink-bar.custom{
 }
 
 md-dialog{
+
+    .md-toolbar-tools{
+        button{
+            min-width: auto;
+        }
+    }
+
     md-dialog-content, md-dialog-actions{
         h2, span{
             color: @fontColor;
index 4f268232729cd463434e440a18e1095026237f17..b8592e1e6ff99997bd55d911a75f3d58a5ca06c3 100644 (file)
@@ -8,7 +8,7 @@ define([
     'ngMessages',
     'common/yangutils/yangutils.module',
     'codemirror',
-    'codeMirror-showHint',
+    'codeMirror-yangmanJsonHint',
     'codeMirror-javascriptMode',
     'codeMirror-matchBrackets',
 ], function () {