From 300b0eeb2b002325805392a15b31a6bb39440dad Mon Sep 17 00:00:00 2001 From: Bartosz Kuron Date: Tue, 18 Feb 2020 11:03:29 +0100 Subject: [PATCH] 84: 'Log' page improvements --- .../main/resources/static/css/log/styles.css | 40 ++++++++- .../static/js/configuration/controller.js | 55 ++++++++++-- .../static/js/configuration/service.js | 22 +++++ .../resources/static/js/log/controller.js | 22 ++++- .../templates/configuration/page.html | 4 +- .../main/resources/templates/log/page.html | 87 +++++++++++-------- 6 files changed, 182 insertions(+), 48 deletions(-) diff --git a/src/mokka/src/main/resources/static/css/log/styles.css b/src/mokka/src/main/resources/static/css/log/styles.css index 406a9ca..26cadda 100644 --- a/src/mokka/src/main/resources/static/css/log/styles.css +++ b/src/mokka/src/main/resources/static/css/log/styles.css @@ -16,19 +16,51 @@ md-list-item { margin-bottom: 10px; } -.log-details button.md-icon-button { +.log-details button.md-icon-button { margin-left: -10px; } -.log-details h4 { +.log-details h4 { display: inline-block; margin: 0; } -.log-details svg { +.log-details svg { vertical-align: -5px; } .log-search-form .md-errors-spacer { display: none; -} \ No newline at end of file +} + +.icons-inline{ + display: flex; + align-items: center; + justify-content: space-between; +} + +.log-info { + display: flex; + align-items: center; +} + +.ng-expand-button{ + margin-top: 12px; +} + +md-list.md-dense md-list-item .material-icons-md-24 { + font-size: 24px; + height: 24px; + width: 24px; + margin: -3px 0 0 0; +} + +.expand-log-button{ + margin-left: auto; +} + +.log .date-ip-log{ + padding-top: 8px; + font-size: 0.85rem; + text-transform: none; +} diff --git a/src/mokka/src/main/resources/static/js/configuration/controller.js b/src/mokka/src/main/resources/static/js/configuration/controller.js index ffe9441..3b9a055 100644 --- a/src/mokka/src/main/resources/static/js/configuration/controller.js +++ b/src/mokka/src/main/resources/static/js/configuration/controller.js @@ -165,6 +165,8 @@ app.controller('ConfigurationController', function($rootScope, $scope, $mdToast, self.activateFilter = function() { self.activeSearch = {}; self.search.update = false; + $location.search('mockId', null); + angular.extend(self.activeSearch, self.search); self.mocks = []; self.paths = []; @@ -186,6 +188,14 @@ app.controller('ConfigurationController', function($rootScope, $scope, $mdToast, }; self.fetchMocks = function(initParams){ + + mockId = $location.search().mockId; + if(mockId != null){ + self.search.enabled = ""; + self.search.id = mockId; + } + + angular.extend(self.activeSearch, self.search); self.loading = true; var params = { 'from': (self.pagination), @@ -205,14 +215,49 @@ app.controller('ConfigurationController', function($rootScope, $scope, $mdToast, } ConfigurationService.fetchMocks(params).then(function(d) { - self.paginationHasNext = d.hasNext; - self.mocks = d.mocks; - self.loading = false; - $location.hash(''); - $anchorScroll(); + if(mockId!=null && Array.isArray(d.mocks) && d.mocks.length){ + self.showConfiguration(d.mocks[0]); + d.mocks[0].editMode = true; + } + self.paginationHasNext = d.hasNext; + self.mocks = d.mocks; + self.loading = false; + $location.hash(''); + $anchorScroll(); }); + }; + $scope.init = function(initParams) { + self.search.enabled = true; + if($location.search().mockId != null){ + + var params = { + 'from': (self.pagination), + // 'from': (self.pagination * self.mocksPerPage), + 'perPage': (1), + // 'perPage': (self.mocksPerPage + 1), + }; + + angular.extend(params, initParams); + + var mockId = parseInt($location.search().mockId); + if(isFinite(mockId)){ + + self.search.id = mockId; + ConfigurationService.getMock(params,mockId).then(function(m){ + self.search.path = m.path; + self.search.description = m.description; + self.search.pattern = m.pattern; + self.search.name = m.name; + self.search.enabled = ""; + self.paths = [m.path]; + }); + } + } + }; + + self.paginationPrevious = function() { self.pagination = self.pagination - 1; self.mocks = []; diff --git a/src/mokka/src/main/resources/static/js/configuration/service.js b/src/mokka/src/main/resources/static/js/configuration/service.js index 0547616..5c0f001 100644 --- a/src/mokka/src/main/resources/static/js/configuration/service.js +++ b/src/mokka/src/main/resources/static/js/configuration/service.js @@ -64,6 +64,28 @@ app.factory('ConfigurationService',function($http, $q){ }); }, + getMock: function(params, mockId) { + return $http.get('/configuration/' + mockId, { + 'params': params + }).then(function(response){ + + if (!response.data.configurationContent) { + e.configurationContent = {}; + } + + if (response.data.configurationContent.groovy) { + response.data.type='groovy'; + } else if (response.data.configurationContent.xml) { + response.data.type='xml'; + } else { + response.data.type='string'; + } + + + return response.data; + }); + }, + getStatuses: function(mock) { return $http.post('/configuration/statuses').then(function(response){ console.debug(response); diff --git a/src/mokka/src/main/resources/static/js/log/controller.js b/src/mokka/src/main/resources/static/js/log/controller.js index e183c40..0c13579 100644 --- a/src/mokka/src/main/resources/static/js/log/controller.js +++ b/src/mokka/src/main/resources/static/js/log/controller.js @@ -1,4 +1,4 @@ -app.controller('LogsController', function($rootScope, $mdToast, LogsService){ +app.controller('LogsController', function($rootScope, $scope, $mdToast, LogsService){ var self = this; self.logs=[]; self.fetchingLogs = false; @@ -85,4 +85,24 @@ app.controller('LogsController', function($rootScope, $mdToast, LogsService){ self.setOfLogs=response; }); }; + + self.showLogDetails = function(log) { + if (log.showLogDetails) { + log.showLogDetails = false; + log["request"]=null; + log["response"]=null; + } else { + log.configurationLoading = true; + log.showLogDetails = true; + self.showDetails(log, "request"); + self.showDetails(log, "response"); + log.configurationLoading = false; + } + }; + + $scope.aceLoaded = function(_editor){ + _editor.setOptions({ + maxLines: 20 + }) + }; }); diff --git a/src/mokka/src/main/resources/templates/configuration/page.html b/src/mokka/src/main/resources/templates/configuration/page.html index 6cc770d..dff76f5 100644 --- a/src/mokka/src/main/resources/templates/configuration/page.html +++ b/src/mokka/src/main/resources/templates/configuration/page.html @@ -7,7 +7,7 @@
-
+
@@ -35,7 +35,7 @@ - +
diff --git a/src/mokka/src/main/resources/templates/log/page.html b/src/mokka/src/main/resources/templates/log/page.html index c166688..3e32015 100644 --- a/src/mokka/src/main/resources/templates/log/page.html +++ b/src/mokka/src/main/resources/templates/log/page.html @@ -80,45 +80,60 @@
- -
-

{{ log.httpMethod }} /{{ log.uri }}

-

{{ log.date | date:"yyyy.MM.dd HH:mm:ss" }} from {{ log.from }}

- -
-
-

Request

- - {{log.request == null ? 'show' : 'hide'}} request - - - -
-
- -
-
- -
-

Response

- - {{log.response == null ? 'show' : 'hide'}} response - - - -
-
- -
-
+
+
+ + Request {{log.status == 'OK' ? 'matched' : 'umatched'}} + +

{{ log.httpMethod }} /{{ log.uri }}

+
+ + + {{log.showLogDetails ? 'hide' : 'show'}} logs details + + + + +

{{ log.date | date:"yyyy.MM.dd HH:mm:ss" }} from {{ log.from }}

+ + +
+ + + + + + Edit configuration + + +
+ +
+ +
+ + +
+
+

Request:

+
+ +
+
+

Response:

+
+ +
+
+
+
-
- - Edit configuration - - +