Skip to content

Commit 965c92d

Browse files
authored
Merge pull request #538 from Optum/master
R1.1.0
2 parents c170328 + 7dd72e9 commit 965c92d

22 files changed

+396
-100
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ specs
1313
public/js/bower_components
1414
public/fusepartials
1515
.vscode/settings.json
16+
.vscode

controllers/randomController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function performRandomInsertion(resBody,reqBody,query,path){
5757
var myChance = new chance(objectHash(reqBody)+objectHash(query)+objectHash(path));
5858

5959
//Find our tags
60-
var split = resBody.split(/({{random:[A-z:,0-9]+}})/);
60+
var split = resBody.split(/({{random:[A-Za-z:,0-9]+}})/);
6161
var retBody = "";
6262

6363
//Go through each split part of body, parse tags, and reassemble

controllers/reportingController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ function getAllServicesByGroups(){
1717
totalServices:
1818
{
1919
$sum:1
20-
}
20+
},
21+
totalTransactions: {$sum:"$txnCount"}
2122
}
2223
},{
2324
$project:
2425
{
2526
sut:"$_id",
2627
services:"$totalServices",
28+
transactions:"$totalTransactions",
2729
_id:false
2830
}
2931
}

controllers/serviceController.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,10 @@ function addService(req, res) {
710710
serv.liveInvocation = req.body.liveInvocation;
711711
}
712712

713+
if(req.body.defaultResponse){
714+
serv.defaultResponse = req.body.defaultResponse;
715+
}
716+
713717
if (type === 'MQ') {
714718
createService(serv,req).then(
715719
function(service){
@@ -852,6 +856,9 @@ function addServiceAsDraft(req, res) {
852856
}
853857
});
854858
}
859+
if(req.body.defaultResponse){
860+
serv.defaultResponse = req.body.defaultResponse;
861+
}
855862

856863
if(req.body.liveInvocation){
857864
serv.liveInvocation = req.body.liveInvocation;
@@ -915,6 +922,9 @@ function updateService(req, res) {
915922
}
916923
});
917924
}
925+
if(req.body.defaultResponse){
926+
service.defaultResponse = req.body.defaultResponse;
927+
}
918928
if(req.body.liveInvocation){
919929
if(service.liveInvocation && service.liveInvocation.recordedRRPairs){
920930
req.body.liveInvocation.recordedRRPairs = service.liveInvocation.recordedRRPairs;
@@ -985,6 +995,9 @@ function updateServiceAsDraft(req, res) {
985995
if (req.body.matchTemplates) {
986996
draftservice.service.matchTemplates = req.body.matchTemplates;
987997
}
998+
if(req.body.defaultResponse){
999+
draftservice.service.defaultResponse = req.body.defaultResponse;
1000+
}
9881001

9891002
const delay = req.body.delay;
9901003
if (delay || delay === 0) {
@@ -1163,8 +1176,11 @@ function restoreService(req, res) {
11631176
running: false,
11641177
matchTemplates: archive.service.matchTemplates,
11651178
rrpairs: archive.service.rrpairs,
1166-
lastUpdateUser: archive.service.lastUpdateUser
1179+
lastUpdateUser: archive.service.lastUpdateUser,
1180+
defaultResponse: archive.service.defaultResponse,
1181+
liveInvocation: archive.service.liveInvocation
11671182
};
1183+
11681184
createService(newService,req).then(function(service){
11691185
res.json({ 'message' : 'restored', 'id' : archive.service._id });
11701186
},

controllers/systemController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ function updateGroup(req, res){
4242
}
4343

4444
if (req.body.mqInfo) system.mqInfo = req.body.mqInfo;
45-
system.members = _.union(system.members, req.body.members);
45+
//system.members = _.union(system.members, req.body.members);
46+
system.members = req.body.members;
4647

4748
system.save(function (err, newSystem) {
4849
if (err) {

models/http/Service.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ const serviceSchema = new mongoose.Schema({
6868
},
6969
lastUpdateUser:{
7070
type: User.schema
71-
}, liveInvocation: {
71+
},
72+
defaultResponse: {
73+
enabled:Boolean,
74+
defaultResponsePayload : String
75+
},
76+
liveInvocation: {
7277
enabled: Boolean,
7378
liveFirst: {
7479
type: Boolean,
@@ -163,7 +168,7 @@ function filterDuplicateRecordedPairs(service){
163168
rrPairs.push(pairs[i]);
164169
}
165170
}
166-
171+
rrPairs = rrPairs.slice(-10);
167172
//if changes were made, save them
168173
if(rrPairs.length != pairs.length){
169174
service.liveInvocation.recordedRRPairs = rrPairs;

public/css/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,11 @@ input[type="radio"] {
128128

129129
.ng-invalid.ng-touched{
130130
border-color:#f00;
131+
}
132+
133+
.odd {
134+
background-color: #F5FFFA;
135+
}
136+
.even {
137+
background-color: #FFFAFA;
131138
}

public/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="stylesheet" href="js/bower_components/bootstrap/dist/css/bootstrap.min.css">
88
<link rel="stylesheet" href="css/angucomplete-alt.css">
99
<link rel="stylesheet" href="css/style.css">
10-
10+
<link rel="shortcut icon" href="#" />
1111

1212
<script src="js/bower_components/angular/angular.min.js"></script>
1313
<script src="js/bower_components/angular-sanitize/angular-sanitize.min.js"></script>
@@ -21,8 +21,6 @@
2121
<script src="js/lib/angular-file-saver.bundle.js"></script>
2222
<script src="js/bower_components/angucomplete-alt/dist/angucomplete-alt.min.js"></script>
2323
<script src="js/bower_components/chance/dist/chance.min.js"></script>
24-
25-
<script src="partials/includes/constants.js"></script>
2624
<script src="js/app/factories.js"></script>
2725
<script src="js/app/services.js"></script>
2826
<script src="js/app/controllers.js"></script>
@@ -66,6 +64,7 @@
6664
<a class="dropdown-toggle" data-toggle="dropdown" href="">Tools<span class="caret"></span></a>
6765
<ul class="dropdown-menu">
6866
<li><a href="#!datagen">Data Generator</a></li>
67+
<li><a href="#!reportui">Report</a></li>
6968
</ul>
7069
</li>
7170

public/js/app/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ var mockapp = angular.module('mockapp',['mockapp.controllers','mockapp.services'
239239

240240
})
241241

242+
.when("/reportui", {
243+
templateUrl: "fusepartials/reportui.html",
244+
controller: "reportuiController"
245+
246+
})
247+
242248
.when('/login', {
243249
templateUrl: 'fusepartials/login.html',
244250
controller: 'authController'

public/js/app/controllers.js

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,47 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
389389
basePath: service.basePath,
390390

391391
};
392+
if(service.defaultResponse){
393+
$scope.servicevo.defaultResponseCheck = service.defaultResponse.enabled;
394+
$scope.servicevo.defaultResponsePayload = service.defaultResponse.defaultResponsePayload;
395+
}
396+
if (service.liveInvocation) {
397+
398+
$scope.servicevo.remoteHost = service.liveInvocation.remoteHost;
399+
$scope.servicevo.remotePort = service.liveInvocation.remotePort;
400+
$scope.servicevo.remotePath = service.liveInvocation.remoteBasePath;
401+
$scope.servicevo.liveInvocationCheck = service.liveInvocation.enabled;
402+
$scope.servicevo.invokeSSL = service.liveInvocation.ssl;
403+
//Extract and build out codes/strings for failures
404+
var failStatusCodes = service.liveInvocation.failStatusCodes;
405+
var failStrings = service.liveInvocation.failStrings;
406+
$scope.servicevo.failStatuses = [];
407+
$scope.servicevo.failStrings = [];
408+
for (var i = 0; i < failStatusCodes.length; i++) {
409+
$scope.servicevo.failStatuses[i] = { 'id': i, 'val': failStatusCodes[i] };
410+
411+
}
412+
for (var i = 0; i < failStrings.length; i++) {
413+
$scope.servicevo.failStrings[i] = { 'id': i, 'val': failStrings[i] };
414+
}
415+
if (!$scope.servicevo.failStatuses.length) {
416+
$scope.servicevo.failStatuses[0] = { 'id': 0, val: '' };
417+
}
418+
if (!$scope.servicevo.failStrings.length) {
419+
$scope.servicevo.failStrings[0] = { 'id': 0, val: '' };
420+
}
421+
//Select correct radio
422+
if (service.liveInvocation.liveFirst)
423+
$scope.servicevo.liveInvokePrePost = 'PRE';
424+
else
425+
$scope.servicevo.liveInvokePrePost = 'POST';
426+
427+
} else {
428+
$scope.servicevo.failStatuses = [];
429+
$scope.servicevo.failStrings = [];
430+
$scope.servicevo.failStatuses[0] = { 'id': 0, val: '' };
431+
$scope.servicevo.failStrings[0] = { 'id': 0, val: '' };
432+
}
392433

393434
$scope.myUser = authService.getUserInfo().username;
394435

@@ -556,6 +597,10 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
556597
basePath: service.basePath
557598
};
558599

600+
if(service.defaultResponse){
601+
$scope.servicevo.defaultResponseCheck = service.defaultResponse.enabled;
602+
$scope.servicevo.defaultResponsePayload = service.defaultResponse.defaultResponsePayload;
603+
}
559604
if (service.liveInvocation) {
560605

561606
$scope.servicevo.remoteHost = service.liveInvocation.remoteHost;
@@ -1128,6 +1173,11 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
11281173

11291174

11301175
};
1176+
console.log(service.defaultResponse);
1177+
if(service.defaultResponse){
1178+
$scope.servicevo.defaultResponseCheck = service.defaultResponse.enabled;
1179+
$scope.servicevo.defaultResponsePayload = service.defaultResponse.defaultResponsePayload;
1180+
}
11311181

11321182
if (service.liveInvocation) {
11331183

@@ -1911,6 +1961,17 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
19111961

19121962
}])
19131963

1964+
.controller("reportuiController", ['$scope', '$http',
1965+
function ($scope, $http) {
1966+
$http.get('/api/report')
1967+
.then(function (response) {
1968+
$scope.reportingJson = response.data;
1969+
})
1970+
.catch(function (err) {
1971+
console.log(err);
1972+
});
1973+
}])
1974+
19141975
.controller("adminController", ['$scope', 'authService', 'userService', 'sutService', 'ctrlConstants',
19151976
function ($scope, authService, userService, sutService, ctrlConstants) {
19161977
$scope.myUser = authService.getUserInfo().username;
@@ -1919,6 +1980,10 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
19191980
$scope.selectedSut = [];
19201981
$scope.allSUT = sutService.getAllSUT();
19211982
$scope.deleteSutList = sutService.getGroupsToBeDeleted($scope.myUser);
1983+
var adminUser;
1984+
userService.getAdmin().then(function (values) {
1985+
adminUser=values[0].name;
1986+
});
19221987

19231988
$scope.checkAndAddGroup = function (createSut) {
19241989
var count = 0;
@@ -1930,26 +1995,37 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
19301995
}
19311996
if (count != 0) {
19321997
$scope.createGroupMessage = ctrlConstants.GRP_ALREADY_EXIST_MSG;
1998+
$scope.deleteGroupMessage = '';
19331999
}
19342000
else {
19352001
sutService.addGroup($scope.createSut);
19362002
$scope.createGroupMessage = ctrlConstants.GRP_CREATED_SUCCESS_MSG;
2003+
$scope.allSUT = sutService.getAllSUT();
2004+
$scope.deleteGroupMessage = '';
19372005

19382006
}
1939-
window.location.reload(true);
2007+
//Below resets every thing else on admin page.
2008+
$scope.deleteSutList = sutService.getGroupsToBeDeleted($scope.myUser);
2009+
$scope.sutlist = sutService.getGroupsByUser($scope.myUser);
2010+
$scope.allSUT = sutService.getAllSUT();
2011+
$scope.usersList = sutService.getMembers($scope.getOwnerForThisSut.name);
19402012
};
19412013

19422014
$scope.removeGroup = function (deleteSut) {
19432015
sutService.deleteGroup(deleteSut);
2016+
//Below resets every thing else on admin page
19442017
$scope.deleteGroupMessage = ctrlConstants.GRP_DELETION_SUCCESS_MSG;
1945-
window.location.reload(true);
2018+
$scope.createGroupMessage = '';
2019+
$scope.deleteSutList = sutService.getGroupsToBeDeleted($scope.myUser);
2020+
$scope.sutlist = sutService.getGroupsByUser($scope.myUser);
2021+
$scope.allSUT = sutService.getAllSUT();
2022+
$scope.usersList = sutService.getMembers($scope.getOwnerForThisSut.name);
19462023
};
19472024

19482025

1949-
$scope.$watch('selectedSut', function (newSut) {
1950-
if ($scope.selectedSut != "") { //removes null response, saves resources
1951-
$scope.memberlist = sutService.getMembers(newSut.name);
1952-
2026+
$scope.$watch('selectedSut', function () {
2027+
if ($scope.selectedSut) { //removes null response, saves resources
2028+
$scope.memberlist = sutService.getMembers($scope.selectedSut.name);
19532029
//disallows duplicate user add
19542030
$scope.removeMembers = function (users) {
19552031
return $scope.memberlist.indexOf(users.name) === -1;
@@ -1964,9 +2040,11 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
19642040
$scope.addMember = function () {
19652041
$scope.memberlist.push($scope.member.name);
19662042
$scope.saveGroup($scope.selectedSut);
2043+
$scope.getOwnerForThisSut=[];
19672044
}
19682045

19692046
$scope.removeMember = function (index) {
2047+
$scope.getOwnerForThisSut=[];
19702048
$('#genricMsg-dialog').find('.modal-title').text(ctrlConstants.DEL_CONFIRM_TITLE);
19712049
$('#genricMsg-dialog').find('.modal-body').html(ctrlConstants.DEL_CONFIRM_USER_BODY);
19722050
$('#genricMsg-dialog').find('.modal-footer').html(ctrlConstants.DEL_CONFIRM_FOOTER);
@@ -1979,6 +2057,16 @@ var ctrl = angular.module("mockapp.controllers", ['mockapp.services', 'mockapp.f
19792057
});
19802058
};
19812059

2060+
$scope.$watch('getOwnerForThisSut', function () {
2061+
if ($scope.getOwnerForThisSut) {
2062+
$scope.usersList = sutService.getMembers($scope.getOwnerForThisSut.name);
2063+
}
2064+
});
2065+
2066+
$scope.mockiatoAdminFilter = function (item) {
2067+
return item !== adminUser;
2068+
};
2069+
19822070
}])
19832071

19842072

0 commit comments

Comments
 (0)