Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Doing some general clean up and applying patch from

  • Loading branch information...
commit af39838f9cf4c981ee15ddb2f31d9109eea4893a 1 parent 4fda6b9
@kelvl kelvl authored
Showing with 375 additions and 400 deletions.
  1. +287 −288 src/main/resources/static/index.html
  2. +88 −112 src/main/resources/static/js/shadow.js
View
575 src/main/resources/static/index.html
@@ -1,313 +1,312 @@
<!DOCTYPE html>
<html ng-app="shadowApp">
- <head>
- <title>Shadow</title>
- <link rel="stylesheet" href="static/css/bootstrap.css">
- <link rel="stylesheet" href="static/css/bootstrap-responsive.css">
- <link rel="stylesheet" href="static/css/ng-grid.css">
- <script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script>
- <script type="text/javascript" src="static/js/underscore-min.js"></script>
- <script type="text/javascript" src="static/js/angular-1.0.6.min.js"></script>
- <script type="text/javascript" src="static/js/ng-grid-2.0.4.debug.js"></script>
- <script type="text/javascript" src="static/js/shadow.js"></script>
- <script type="text/javascript" src="static/js/diff.js"></script>
- <style type="text/css">
- .requests-buttons {
- float: right;
- }
- .filter-labels {
- display: inline-block;
- }
- .filter-labels .label {
- margin-right: 5px;
- cursor: pointer;
- }
- #scrollableTable {
- width: 100%;
- display: block;
- height: 200px;
- overflow-y: scroll;
- margin-top: 10px;
- margin-bottom: 10px;
- }
- #follow-buttons {
- float: right;
- }
- .margin-top-20 {
- margin-top: 20px;
- }
- .response-label {
- float: right;
- }
- span.ins {
- background: #76e213;
- color: #22360c;
- text-decoration: none;
- }
+<head>
+ <title>Shadow</title>
+ <link rel="stylesheet" href="static/css/bootstrap.css">
+ <link rel="stylesheet" href="static/css/bootstrap-responsive.css">
+ <link rel="stylesheet" href="static/css/ng-grid.css">
+ <script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script>
+ <script type="text/javascript" src="static/js/underscore-min.js"></script>
+ <script type="text/javascript" src="static/js/angular-1.0.6.min.js"></script>
+ <script type="text/javascript" src="static/js/ng-grid-2.0.4.min.js"></script>
+ <script type="text/javascript" src="static/js/shadow.js"></script>
+ <script type="text/javascript" src="static/js/diff.js"></script>
+ <style type="text/css">
+ .requests-buttons {
+ float: right;
+ }
- tr.selected {
- background: #f5f5f5;
- }
+ .filter-labels {
+ display: inline-block;
+ }
- span.del {
- text-decoration: none;
- color: #b30000;
- background: #e7a7a1;
- }
+ .filter-labels .label {
+ margin-right: 5px;
+ cursor: pointer;
+ }
- .gridStyle {
- height: 400px;
- }
+ #follow-buttons {
+ float: right;
+ }
- .ngCell div {
- padding: 7px 10px;
- }
+ .margin-top-20 {
+ margin-top: 20px;
+ }
- .ngViewport :focus {
- outline: rgba(0,0,0,0) auto 0px;
- }
- </style>
- </head>
- <body ng-controller="ResultsCtrl">
- <div class="navbar navbar-fixed-top">
- <div class="navbar-inner">
- <div class="container">
- <a href="#" class="brand">Shadow</a>
- </div>
- </div>
+ .response-label {
+ float: right;
+ }
+
+ span.ins {
+ background: #76e213;
+ color: #22360c;
+ text-decoration: none;
+ }
+
+ span.del {
+ text-decoration: none;
+ color: #b30000;
+ background: #e7a7a1;
+ }
+
+ .gridStyle {
+ height: 400px;
+ }
+
+ .ngCell div {
+ padding: 7px 10px;
+ }
+
+ .ngViewport :focus {
+ outline: rgba(0, 0, 0, 0) auto 0px;
+ }
+ </style>
+</head>
+<body ng-controller="ResultsCtrl">
+<div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a href="#" class="brand">Shadow</a>
</div>
- <div class="container" style="margin-top: 60px">
- <div class="row">
- <div class="span12">
- <div class="requests-buttons">
- <div class="filter-labels">
- <a class="label" ng-class="filterClass('success')" ng-click="toggleFilter('success')">
- Success - {{resultsFilter['success'].count}}
- </a>
- <span class="label" ng-class="filterClass('status_code_diff')" ng-click="toggleFilter('status_code_diff')">
+ </div>
+</div>
+<div class="container" style="margin-top: 60px">
+<div class="row">
+ <div class="span12">
+ <div class="requests-buttons">
+ <div class="filter-labels">
+ <a class="label" ng-class="filterClass('success')" ng-click="toggleFilter('success')">
+ Success - {{resultsFilter['success'].count}}
+ </a>
+ <span class="label" ng-class="filterClass('status_code_diff')"
+ ng-click="toggleFilter('status_code_diff')">
Status Code Diff - {{resultsFilter['status_code_diff'].count}}
</span>
- <span class="label" ng-class="filterClass('body_diff')" ng-click="toggleFilter('body_diff')">
+ <span class="label" ng-class="filterClass('body_diff')"
+ ng-click="toggleFilter('body_diff')">
Body Diff - {{resultsFilter['body_diff'].count}}
</span>
- </div>
- <button class="btn btn-info" ng-click='deleteNonError()'>Delete Non-errors</button>
- <button class="btn-danger btn" ng-click='emptyResults()'>Delete All</button>
- </div>
- <h2>Requests</h2>
+ </div>
+ <button class="btn btn-info" ng-click='deleteNonError()'>Delete Non-errors</button>
+ <button class="btn-danger btn" ng-click='emptyResults()'>Delete All</button>
+ </div>
+ <h2>Requests</h2>
+
+ <div ng-grid="gridOptions" class="gridStyle"></div>
- <div ng-grid="gridOptions" class="gridStyle"></div>
+ <div id="follow-buttons">
+ <button class="btn" ng-class="followBtn[followState].clazz" ng-click="followState = !followState">
+ {{ followBtn[followState].label }}
+ </button>
+ </div>
+ </div>
+</div>
+<div class="row well margin-top-20" ng-hide="currentResult == ''">
+<div class="container">
+<div class="row">
+<div class="span12">
+ <div style="float: right">
+ <button class="btn" ng-click="prevResult()">Prev</button>
+ <button class="btn" ng-click="nextResult()">Next</button>
+ <button class="btn btn-danger" ng-click='removeResult(currentResult.index)'>Delete</button>
+ </div>
+ <h2>
+ Request {{currentResult.index}}
+ </h2>
- <div id="follow-buttons">
- <button class="btn" ng-class="followBtn[followState].clazz" ng-click="followState = !followState">
- {{ followBtn[followState].label }}
- </button>
- </div>
- </div>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Path</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{currentResult.request.original.url}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th colspan="2">Headers</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat='(key, value) in currentResult.request.original.headers'>
+ <td>{{key}}</td>
+ <td>{{value}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div class="span6">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th colspan="2">GET Params</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat='(key, value) in currentResult.request.original.get'>
+ <td>{{key}}</td>
+ <td>{{value}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th colspan="2">POST Params</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat='(key, value) in currentResult.request.original.post'>
+ <td>{{key}}</td>
+ <td>{{value}}</td>
+ </tr>
+ </tbody>
+ </table>
</div>
- <div class="row well margin-top-20" ng-hide="currentResult == ''">
- <div class="container">
- <div class="row">
- <div class="span12">
- <div style="float: right">
- <button class="btn" ng-click="prevResult()">Prev</button>
- <button class="btn" ng-click="nextResult()">Next</button>
- <button class="btn btn-danger" ng-click='removeResult(currentResult.index)'>Delete</button>
- </div>
- <h2>
- Request {{currentResult.index}}
- </h2>
- <div class="container">
- <div class="row">
- <div class="span6">
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Path</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{currentResult.request.original.url}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th colspan="2">Headers</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat='(key, value) in currentResult.request.original.headers'>
- <td>{{key}}</td>
- <td>{{value}}</td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="span6">
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th colspan="2">GET Params</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat='(key, value) in currentResult.request.original.get'>
- <td>{{key}}</td>
- <td>{{value}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th colspan="2">POST Params</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat='(key, value) in currentResult.request.original.post'>
- <td>{{key}}</td>
- <td>{{value}}</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- <div class="span12">
- <h2>
- Responses
- </h2>
- </div>
- <div class="span6">
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th colspan="2">Headers</th>
+ </div>
+ </div>
+</div>
+<div class="span12">
+ <h2>
+ Responses
+ </h2>
+</div>
+<div class="span6">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th colspan="2">Headers</th>
<span class="label label-info response-label">
Actual
</span>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat='(key, value) in orig.headers'>
- <td>{{key}}</td>
- <td>{{value}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Response Time</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{orig.elapsed_time}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Status</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{orig.status_code}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Body</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td style="word-wrap: break-word;">{{orig.body}}</td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="span6">
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th colspan="2">Headers</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat='(key, value) in orig.headers'>
+ <td>{{key}}</td>
+ <td>{{value}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Response Time</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{orig.elapsed_time}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Status</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{orig.status_code}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Body</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td style="word-wrap: break-word;">{{orig.body}}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<div class="span6">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th colspan="2">Headers</th>
<span class="label label-inverse response-label">
Shadow
</span>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat='(key, value) in shadowed.headers'>
- <td>{{key}}</td>
- <td>{{value}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Response Time</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{shadowed.elapsed_time}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Status
- <span class="label label-important response-label" ng-show='currentResult.status_code_diff'>Status Code Diff</span>
- </th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{shadowed.status_code}}</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>Body
- <span class="label label-warning response-label" ng-show='currentResult.body_diff'>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat='(key, value) in shadowed.headers'>
+ <td>{{key}}</td>
+ <td>{{value}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Response Time</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{shadowed.elapsed_time}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Status
+ <span class="label label-important response-label" ng-show='currentResult.status_code_diff'>Status Code Diff</span>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{shadowed.status_code}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>Body
+ <span class="label label-warning response-label"
+ ng-show='currentResult.body_diff'>
Body Diff
</span>
- <button class="btn btn-mini response-label" style="margin-top:-1px; margin-right:2px" ng-class="showDiffBtn[shadowed.show_diff].clazz"
- ng-click="shadowed.show_diff = !shadowed.show_diff"
- ng-show='currentResult.body_diff'>
- {{showDiffBtn[shadowed.show_diff].label}}
- </button>
- </th>
+ <button class="btn btn-mini response-label" style="margin-top:-1px; margin-right:2px"
+ ng-class="showDiffBtn[shadowed.show_diff].clazz"
+ ng-click="shadowed.show_diff = !shadowed.show_diff"
+ ng-show='currentResult.body_diff'>
+ {{showDiffBtn[shadowed.show_diff].label}}
+ </button>
+ </th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td style="word-wrap: break-word;">
- <span ng-show='!shadowed.show_diff' ng-bind="shadowed.body"></span>
- <span ng-show='shadowed.show_diff' ng-bind-html-unsafe="shadowed.body_diff"></span>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </body>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td style="word-wrap: break-word;">
+ <span ng-show='!shadowed.show_diff' ng-bind="shadowed.body"></span>
+ <span ng-show='shadowed.show_diff' ng-bind-html-unsafe="shadowed.body_diff"></span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+</div>
+</div>
+</div>
+</div>
+</body>
</html>
View
200 src/main/resources/static/js/shadow.js
@@ -1,10 +1,7 @@
var app = angular.module('shadowApp', ['ngGrid']);
-app.controller('ResultsCtrl', function($scope, $filter){
-
- var STATUS_DIFF = 1;
- var BODY_DIFF = 2;
+app.controller('ResultsCtrl', function ($scope, $filter) {
$scope.results = [];
$scope.currentResult = '';
@@ -14,7 +11,7 @@ app.controller('ResultsCtrl', function($scope, $filter){
$scope.gridOptions = {
data: 'filteredResults',
columnDefs: [
- {field: 'index', displayName:'No', width: "*"},
+ {field: 'index', displayName: 'No', width: "*"},
{field: '_incoming', displayName: 'Incoming Request', width: "****"},
{field: '_diffs', displayName: ' ', width: "***"}
],
@@ -27,69 +24,62 @@ app.controller('ResultsCtrl', function($scope, $filter){
filterOptions: {
useExternalFilter: true
},
- afterSelectionChange: function(row) {
+ afterSelectionChange: function (row) {
$scope.selectResult(row.rowIndex, row.entity);
}
};
-//
-// $scope.$on("rowSelected", function(event, row){
-// $scope.selectResult(row.rowIndex, row.entity);
-// });
- $scope.selectResult = function(rowIndex, entity) {
-// $scope.gridOptions.selectRow(rowIndex, true);
+ $scope.selectResult = function (rowIndex, entity) {
$scope.followState = false;
- var result = entity;
-
- var bodies = _.pluck(result.results, 'body');
+ var bodies = _.pluck(entity.results, 'body');
var diff = JsDiff.diffChars(bodies[0], bodies[1]);
- if(result.results[1].body_diff === undefined){
+ if (entity.results[1].body_diff === undefined) {
- var diffs =_.map(diff, function(x){
- if(x.added === true){
+ var diffs = _.map(diff, function (x) {
+ if (x.added === true) {
return $("<span>").addClass("ins").text(x.value)[0].outerHTML;
- }else if(x.removed === true){
+ } else if (x.removed === true) {
return $("<span>").addClass("del").text(x.value)[0].outerHTML;
- }else{
+ } else {
return $("<span>").text(x.value)[0].outerHTML;
}
});
- result.results[1].body_diff = diffs.join("");
+ entity.results[1].body_diff = diffs.join("");
- result.results[1].show_diff = diffs.length <= 8;
+ entity.results[1].show_diff = diffs.length <= 8;
}
- $scope.currentResult = result;
+ $scope.currentResult = entity;
$scope.prev = rowIndex - 1;
$scope.next = rowIndex + 1;
- }
+ };
- $scope.$on('ngGridEventData', function(){
- if($scope.followState) {
+ $scope.$on('ngGridEventData', function () {
+ if ($scope.followState) {
$scope.scrollBottom();
}
});
- $scope.scrollToSelected = function(){
+ $scope.scrollToSelected = function () {
$scope.gridOptions.ngGrid.$viewport.scrollTop($('.selected.ngRow').first().position().top);
- }
+ };
- $scope.nextResult = function(){
+ $scope.nextResult = function () {
$scope.gridOptions.selectRow($scope.next, true);
$scope.gridOptions.ngGrid.$viewport.scrollTop(($scope.next - 1) * $scope.gridOptions.ngGrid.config.rowHeight);
};
- $scope.prevResult = function(){
+ $scope.prevResult = function () {
$scope.gridOptions.selectRow($scope.prev, true);
$scope.gridOptions.ngGrid.$viewport.scrollTop(($scope.prev + 1) * $scope.gridOptions.ngGrid.config.rowHeight);
};
- $scope.scrollBottom = _.debounce(_.throttle(function(){
+ $scope.scrollBottom = _.debounce(_.throttle(function () {
$scope.gridOptions.ngGrid.$viewport.scrollTop($scope.gridOptions.ngGrid.$canvas.height());
}, 30), 100);
@@ -112,22 +102,22 @@ app.controller('ResultsCtrl', function($scope, $filter){
};
$scope.showDiffBtn = {
- true: {
+ 'true': {
label: 'Hide Diff',
clazz: 'btn-inverse'
},
- false: {
+ 'false': {
label: 'Show Diff',
clazz: ''
}
};
$scope.followBtn = {
- true: {
+ 'true': {
label: 'Un-Follow',
clazz: 'btn-inverse'
},
- false: {
+ 'false': {
label: 'Follow',
clazz: ''
}
@@ -136,28 +126,60 @@ app.controller('ResultsCtrl', function($scope, $filter){
$scope.followState = false;
$scope.eventSource = new EventSource('/stream');
- $scope.eventSource.addEventListener('message', function(ev) {
+ $scope.eventSource.addEventListener('message', function (ev) {
var data = JSON.parse(ev.data);
$scope.addResult(data);
- }, false)
+ }, false);
$scope.count = 1;
- var throttledApply = _.throttle(function(){
+ var throttledApply = _.throttle(function () {
$scope.$apply();
}, 100);
- $scope.addResult = function(result){
- status_code_diff = result.results[0].status_code != result.results[1].status_code;
- body_diff = result.results[0].body != result.results[1].body;
+ $scope.addResult = function (result) {
+ var status_code_diff = result.results[0].status_code != result.results[1].status_code;
+ var body_diff = false;
+
+ var strict_check = false;
+
+ if (_.all(result.results, function (result) {
+ return (/json/i).test(result.headers['content-type']);
+ })) {
+ // Try comparing the parsed JSON, maybe make this optional if we
+ // actually care about spacing or the order of properties in the
+ // returned JSON
+ try {
+ _.each(result.results, function (a) {
+ var aJson = JSON.parse(a.body);
+
+ _.each(result.results, function (b) {
+ var bJson = JSON.parse(b.body);
+
+ if (!_.isEqual(aJson, bJson)) {
+ body_diff = true;
+ }
+ });
+ });
+ } catch (e) {
+ strict_check = true;
+ }
+ } else {
+ strict_check = true;
+ }
+
+ // strict check if the body content is different
+ if (strict_check) {
+ body_diff = _.chain(result.results).pluck('body').uniq().size().value() > 1;
+ }
result['status_code_diff'] = status_code_diff;
result['body_diff'] = body_diff;
result['success'] = !body_diff && !status_code_diff;
- angular.forEach(['status_code_diff', 'body_diff', 'success'], function(filter_name){
- if(result[filter_name]){
+ angular.forEach(['status_code_diff', 'body_diff', 'success'], function (filter_name) {
+ if (result[filter_name]) {
$scope.resultsFilter[filter_name].count++;
}
});
@@ -166,14 +188,14 @@ app.controller('ResultsCtrl', function($scope, $filter){
$scope.results.push(result);
- if($scope.filterResult(result)) {
+ if ($scope.filterResult(result)) {
$scope.filteredResults.push(result);
}
throttledApply();
};
- $scope.toggleFilter = function(filter_name){
+ $scope.toggleFilter = function (filter_name) {
var filter = $scope.resultsFilter[filter_name];
filter.state = !filter.state;
@@ -181,112 +203,66 @@ app.controller('ResultsCtrl', function($scope, $filter){
_.debounce($scope.scrollToSelected, 100)();
};
- $scope.applyFilter = function() {
+ $scope.applyFilter = function () {
$scope.filteredResults = $filter('filter')($scope.results, $scope.filterResult);
- }
+ };
- $scope.filterResult = function(result) {
+ $scope.filterResult = function (result) {
var show = true;
- angular.forEach(['status_code_diff', 'body_diff', 'success'], function(filter){
- if (!$scope.resultsFilter[filter].state && result[filter]){
+ angular.forEach(['status_code_diff', 'body_diff', 'success'], function (filter) {
+ if (!$scope.resultsFilter[filter].state && result[filter]) {
show = false;
}
});
return show;
- }
+ };
- $scope.filterClass = function(filter_name){
+ $scope.filterClass = function (filter_name) {
var filter = $scope.resultsFilter[filter_name];
return (filter.state) ? filter.clazz : '';
};
- $scope.deleteNonError = function(){
- $scope.results = _.filter($scope.results, function(result){
+ $scope.deleteNonError = function () {
+ $scope.results = _.filter($scope.results, function (result) {
return !result.success;
});
- angular.forEach(['status_code_diff', 'body_diff', 'success'], function(filter_name){
- $scope.resultsFilter[filter_name].count = _.chain($scope.results).filter(function(result){
+ angular.forEach(['status_code_diff', 'body_diff', 'success'], function (filter_name) {
+ $scope.resultsFilter[filter_name].count = _.chain($scope.results).filter(function (result) {
return result[filter_name];
}).size().value();
});
$scope.applyFilter();
};
- $scope.emptyResults = function(){
- $scope.results=[];
- angular.forEach(['status_code_diff', 'body_diff', 'success'], function(filter_name){
+ $scope.emptyResults = function () {
+ $scope.results = [];
+ angular.forEach(['status_code_diff', 'body_diff', 'success'], function (filter_name) {
$scope.resultsFilter[filter_name].count = 0;
});
$scope.applyFilter();
};
- $scope.$watch('currentResult', function(result){
- if(result !== ''){
+ $scope.$watch('currentResult', function (result) {
+ if (result !== '') {
$scope.orig = result.results[0];
$scope.shadowed = result.results[1];
}
});
- $scope.removeResult = function(index){
+ $scope.removeResult = function (index) {
var result = $scope.results[index];
- angular.forEach(['status_code_diff', 'body_diff', 'success'], function(filter_name){
- if(result[filter_name]){
+ angular.forEach(['status_code_diff', 'body_diff', 'success'], function (filter_name) {
+ if (result[filter_name]) {
$scope.resultsFilter[filter_name].count--;
}
});
$scope.results.splice(index, 1);
- if(index === $scope.results.length){
- index-=1;
+ if (index === $scope.results.length) {
+ index -= 1;
}
-// $scope.setCurrentResult($scope.results[index]);
$scope.gridOptions.selectRow(index, true);
$scope.applyFilter();
};
- /*$scope.setCurrentResult = function(result, index, results){
- $scope.followState = false;
-
- var table = angular.element("#scrollableTable");
- var row = angular.element("#scrollableTable tbody tr").eq(index+1);
-
- table.scrollTop(row.position().top);
-
- var bodies = _.pluck(result.results, 'body');
- var diff = JsDiff.diffChars(bodies[0], bodies[1]);
-
- $scope.prev = {
- result: results[Math.max(0, index - 1)],
- index: Math.max(0, index - 1),
- results: results
- };
-
- $scope.next = {
- result: results[Math.min(index + 1, results.length)],
- index: Math.min(index + 1, results.length),
- results: results
- };
-
- if(result.results[1].body_diff === undefined){
-
- var diffs =_.map(diff, function(x){
- if(x.added === true){
- return $("<span>").addClass("ins").text(x.value)[0].outerHTML;
- }else if(x.removed === true){
- return $("<span>").addClass("del").text(x.value)[0].outerHTML;
- }else{
- return $("<span>").text(x.value)[0].outerHTML;
- }
- });
-
- result.results[1].body_diff = diffs.join("");
-
- if(diffs.length > 8){
- result.results[1].show_diff = false;
- }else{
- result.results[1].show_diff = true;
- }
- }
- $scope.currentResult = result;
- };*/
});
Please sign in to comment.
Something went wrong with that request. Please try again.