Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Fix new response-ratelimiting plugin schema. Ref issue #363
Browse files Browse the repository at this point in the history
  • Loading branch information
pantsel committed Apr 3, 2019
1 parent 039be5d commit 0047af9
Show file tree
Hide file tree
Showing 26 changed files with 426 additions and 69 deletions.
2 changes: 1 addition & 1 deletion assets/js/app/apis/controllers/apis-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
}

function deleteApiHealthChecks() {
DialogService.prompt(
DialogService.confirm(
"Confirm", "<strong>You are about to reset the healthchecks of <code>all APIs</code> on <code>all Kong connections</code></strong>." +
"<br><br>That means that you will have to setup each and every one of the from scratch." +
"<br><br>Don't worry about affecting the API or Kong Connections entities." +
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/certificates/certificates-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

$scope.deleteSNI = function (sni) {
DialogService.prompt(
DialogService.confirm(
"Confirm", "Really want to delete the selected item?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/app/connections/connections-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
return false;
}

DialogService.prompt(
DialogService.confirm(
"Confirm", "Really want to delete the selected item?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand Down Expand Up @@ -528,4 +528,4 @@
}
])
;
}());
}());
2 changes: 1 addition & 1 deletion assets/js/app/consumers/apis/consumer-apis-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
}

function deletePlugin(api,plugin) {
DialogService.prompt(
DialogService.confirm(
"Delete Plugin","Really want to delete the plugin?",
['No don\'t','Yes! delete it'],
function accept(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@


function deleteHMACAuthCredentials($index, credentials) {
DialogService.prompt(
DialogService.confirm(
"Delete Credentials", "Really want to delete the selected credentials?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand All @@ -112,7 +112,7 @@
}

function deleteBasicAuthCredentials($index, credentials) {
DialogService.prompt(
DialogService.confirm(
"Delete Credentials", "Really want to delete the selected credentials?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand All @@ -130,7 +130,7 @@
}

function deleteOAuth2($index, oauth) {
DialogService.prompt(
DialogService.confirm(
"Delete JWT", "Really want to delete the selected OAuth2?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand All @@ -148,7 +148,7 @@
}

function deleteJWT($index, jwt) {
DialogService.prompt(
DialogService.confirm(
"Delete JWT", "Really want to delete the selected JWT?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand All @@ -166,7 +166,7 @@
}

function deleteKey($index, key) {
DialogService.prompt(
DialogService.confirm(
"Delete Key", "Really want to delete the selected key?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


$scope.onCredentialSelected = function(credential) {
DialogService.prompt(
DialogService.confirm(
"Mass Assign Credentials",
"You are about to mass assign <strong>" + credential + "</strong> credentials" +
" to " + $scope.consumers.length + " selected consumers.<br>Continue?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}

function deleteConsumerGroup(group) {
DialogService.prompt(
DialogService.confirm(
"Delete Group", "Really want to remove the group from the consumer?",
['No', 'Remove it!'],
function accept() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

function deleteGroup(group) {

DialogService.prompt(
DialogService.confirm(
"Delete Group","Really want to delete the '" + group.name + "' group?",
['No don\'t','Yes! delete it'],
function accept(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}

function deletePlugin(plugin) {
DialogService.prompt(
DialogService.confirm(
"Delete Plugin", "Really want to delete the plugin?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@


function deletePlugin(api,plugin) {
DialogService.prompt(
DialogService.confirm(
"Delete Plugin","Really want to delete the plugin?",
['No don\'t','Yes! delete it'],
function accept(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@


function deletePlugin(api,plugin) {
DialogService.prompt(
DialogService.confirm(
"Delete Plugin","Really want to delete the plugin?",
['No don\'t','Yes! delete it'],
function accept(){
Expand Down
42 changes: 41 additions & 1 deletion assets/js/app/core/services/DialogService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@



service.prompt = function prompt(title,message, buttonTexts,accept, decline) {
service.confirm = function prompt(title,message, buttonTexts,accept, decline) {

var modalInstance = $uibModal.open({
animation: true,
Expand Down Expand Up @@ -89,6 +89,46 @@

};

service.prompt = function prompt(title,message,accept, decline) {

var modalInstance = $uibModal.open({
animation: true,
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
windowClass : 'dialog',
template: '' +
'<div class="modal-header dialog no-margin">' +
'<h5 class="modal-title">' + title + '</h5>' +
'</div>' +
'<div class="modal-body">' +
'<p>' + message + '</p>' +
'<input type="text" class="form-control" ng-model="data"></div>' +
'</div>' +
'<div class="modal-footer dialog">' +
'<button class="btn btn-link" data-ng-click="decline()">CANCEL</button>' +
'<button class="btn btn-success btn-link" data-ng-click="accept()">OK</button>' +
'</div>',
controller: function($scope,$uibModalInstance){
$scope.data = '';
$scope.accept = function() {
if(!$scope.data) return false;
$uibModalInstance.close($scope.data)
}
$scope.decline = function(){
$uibModalInstance.dismiss('decline')
}
},
size: 'sm'
});

modalInstance.result.then(function (d) {
accept(d);
}, function (d) {
decline()
});

};




Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/core/services/ListConfigService.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@

},
deleteItem: function deleteItem($index, item) {
DialogService.prompt(
DialogService.confirm(
"Confirm", "Really want to delete the selected item?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/healthchecks/healthchecks-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
$scope.deleteItem = function deleteItem(item) {


DialogService.prompt(
DialogService.confirm(
"Confirm", "Really want to delete the selected item?",
['No don\'t', 'Yes! delete it'],
function accept() {
Expand Down
29 changes: 26 additions & 3 deletions assets/js/app/plugins/add-plugin-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
angular.module('frontend.plugins')
.controller('AddPluginController', [
'_', '$scope', '$rootScope', '$log', '$state', 'ListConfig', 'ApiService',
'MessageService', 'ConsumerModel', 'ServiceService', 'SocketHelperService', 'PluginHelperService',
'MessageService', 'ConsumerModel', 'ServiceService', 'DialogService', 'SocketHelperService', 'PluginHelperService',
'KongPluginsService', '$uibModalInstance', 'PluginsService', '_pluginName', '_schema', '_context',
function controller(_, $scope, $rootScope, $log, $state, ListConfig, ApiService,
MessageService, ConsumerModel, ServiceService, SocketHelperService, PluginHelperService,
MessageService, ConsumerModel, ServiceService, DialogService, SocketHelperService, PluginHelperService,
KongPluginsService, $uibModalInstance, PluginsService, _pluginName, _schema,_context) {


Expand Down Expand Up @@ -50,7 +50,7 @@

// Define the plugins that will have their own custom form
// so that it can be included via ng-include in the .html files
$scope.customPluginForms = ['statsd'];
$scope.customPluginForms = ['statsd', 'response-ratelimiting'];

$scope.humanizeLabel = function (key) {
return key.split("_").join(" ");
Expand Down Expand Up @@ -291,6 +291,29 @@
$scope.getFieldProp = (field) => {
return Object.keys(field)[0];
}

/**
* RESPONSE RATE LIMITING
*/

$scope.addMap = (obj) => {

DialogService.prompt('Add Limit', 'Enter key', (keyName) => {
if(!obj.value) {
obj.value = {}
}

obj.value[keyName] = {};
obj.values.fields.forEach(field => {
obj.value[keyName][Object.keys(field)[0]] = null
})
})

}

$scope.removeMap = (keyName, obj) => {
delete obj.value[keyName];
}
}
]);
}());
2 changes: 1 addition & 1 deletion assets/js/app/plugins/add-plugin-modal-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Define the plugins that will have their own custom form
// so that it can be included via ng-include in the .html files
$scope.customPluginForms = ['statsd'];
$scope.customPluginForms = ['statsd', 'response-ratelimiting'];

new KongPluginsService().makePluginGroups().then(function (groups) {
$scope.pluginGroups = groups
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/plugins/api-plugins-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@


function deletePlugin(plugin) {
DialogService.prompt(
DialogService.confirm(
"Delete Plugin","Really want to delete the plugin?",
['No don\'t','Yes! delete it'],
function accept(){
Expand Down
Loading

0 comments on commit 0047af9

Please sign in to comment.