Skip to content

Commit 171a4ea

Browse files
committed
Fix authentication options when switching methods
1 parent 433428e commit 171a4ea

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

dist/scripts/api-console.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@
419419
var $inactiveElements = jQuery('.raml-console-tab').add('.raml-console-resource').add('li');
420420
var methodInfo = $scope.resource.methods[$index];
421421

422-
console.log($scope.resource.methods);
423-
424422
$scope.methodInfo = methodInfo;
425423
$scope.responseInfo = getResponseInfo();
426424
$scope.context = new RAML.Services.TryIt.Context($scope.raml.baseUriParameters, $scope.resource, $scope.methodInfo);
@@ -441,6 +439,8 @@
441439
toUIModel($scope.methodInfo.headers.plain);
442440
toUIModel($scope.resource.uriParametersForDocumentation);
443441

442+
$rootScope.$broadcast('resetData');
443+
444444
$scope.securitySchemes.anonymous = {
445445
type: 'Anonymous'
446446
};
@@ -452,12 +452,6 @@
452452

453453
loadExamples();
454454

455-
var defaultScheme = Object.keys($scope.securitySchemes).sort()[0];
456-
$scope.currentScheme = {
457-
type: $scope.securitySchemes[defaultScheme].type,
458-
name: defaultScheme
459-
};
460-
461455
// Hack for codemirror
462456
setTimeout(function () {
463457
var editors = jQuery('.raml-console-sidebar-content-wrapper #sidebar-body .raml-console-codemirror-body-editor .CodeMirror');
@@ -1085,6 +1079,14 @@
10851079
});
10861080
}
10871081

1082+
$scope.$on('resetData', function(event) {
1083+
$scope.currentSchemeType = 'Anonymous';
1084+
});
1085+
1086+
$scope.securitySchemeChanged = function (value) {
1087+
$scope.currentSchemeType = value;
1088+
}
1089+
10881090
$scope.cancelRequest = function () {
10891091
$scope.showSpinner = false;
10901092
};
@@ -5315,7 +5317,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
53155317
" <div class=\"raml-console-sidebar-row raml-console-sidebar-securty\">\n" +
53165318
" <div class=\"raml-console-toggle-group raml-console-sidebar-toggle-group\">\n" +
53175319
" <label class=\"raml-console-sidebar-label\">Security Scheme</label>\n" +
5318-
" <select class=\"raml-console-sidebar-input\" ng-model=\"currentSchemeType\" style=\"margin-bottom: 0;\">\n" +
5320+
" <select class=\"raml-console-sidebar-input\" ng-model=\"currentSchemeType\" style=\"margin-bottom: 0;\" ng-change=\"securitySchemeChanged(currentSchemeType)\">\n" +
53195321
" <option ng-repeat=\"(key, scheme) in securitySchemes\" value=\"{{scheme.type}}\" ng-selected=\"scheme.type=='Anonymous'\">{{scheme.type}}</option>\n" +
53205322
" </select>\n" +
53215323
" </div>\n" +

src/app/directives/method-list.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@
9292
var $inactiveElements = jQuery('.raml-console-tab').add('.raml-console-resource').add('li');
9393
var methodInfo = $scope.resource.methods[$index];
9494

95-
console.log($scope.resource.methods);
96-
9795
$scope.methodInfo = methodInfo;
9896
$scope.responseInfo = getResponseInfo();
9997
$scope.context = new RAML.Services.TryIt.Context($scope.raml.baseUriParameters, $scope.resource, $scope.methodInfo);
@@ -114,6 +112,8 @@
114112
toUIModel($scope.methodInfo.headers.plain);
115113
toUIModel($scope.resource.uriParametersForDocumentation);
116114

115+
$rootScope.$broadcast('resetData');
116+
117117
$scope.securitySchemes.anonymous = {
118118
type: 'Anonymous'
119119
};
@@ -125,12 +125,6 @@
125125

126126
loadExamples();
127127

128-
var defaultScheme = Object.keys($scope.securitySchemes).sort()[0];
129-
$scope.currentScheme = {
130-
type: $scope.securitySchemes[defaultScheme].type,
131-
name: defaultScheme
132-
};
133-
134128
// Hack for codemirror
135129
setTimeout(function () {
136130
var editors = jQuery('.raml-console-sidebar-content-wrapper #sidebar-body .raml-console-codemirror-body-editor .CodeMirror');

src/app/directives/sidebar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@
172172
});
173173
}
174174

175+
$scope.$on('resetData', function(event) {
176+
$scope.currentSchemeType = 'Anonymous';
177+
});
178+
179+
$scope.securitySchemeChanged = function (value) {
180+
$scope.currentSchemeType = value;
181+
}
182+
175183
$scope.cancelRequest = function () {
176184
$scope.showSpinner = false;
177185
};

src/app/directives/sidebar.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h4 class="raml-console-sidebar-subhead">Authentication</h4>
2626
<div class="raml-console-sidebar-row raml-console-sidebar-securty">
2727
<div class="raml-console-toggle-group raml-console-sidebar-toggle-group">
2828
<label class="raml-console-sidebar-label">Security Scheme</label>
29-
<select class="raml-console-sidebar-input" ng-model="currentSchemeType" style="margin-bottom: 0;">
29+
<select class="raml-console-sidebar-input" ng-model="currentSchemeType" style="margin-bottom: 0;" ng-change="securitySchemeChanged(currentSchemeType)">
3030
<option ng-repeat="(key, scheme) in securitySchemes" value="{{scheme.type}}" ng-selected="scheme.type=='Anonymous'">{{scheme.type}}</option>
3131
</select>
3232
</div>

0 commit comments

Comments
 (0)