Skip to content

Commit

Permalink
ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Panagis Tselentis committed May 17, 2017
1 parent 474f7a6 commit d4ceb0c
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 219 deletions.
4 changes: 3 additions & 1 deletion api/base/KongController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict';
var KongService = require('../services/KongService')

var KongService = require('../services/KongService')
var unirest = require("unirest")

module.exports = {

create : function(req,res) {
return KongService.create(req,res)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ApiController
* RemoteApiController
*/

var unirest = require("unirest")
Expand All @@ -14,8 +14,7 @@ module.exports = {
*/
proxy : function(req,res) {


req.url = req.url.replace('/api','') // Remove the /api prefix
req.url = req.url.replace('/kong','') // Remove the /api prefix

sails.log("req.url",req.url)

Expand Down
2 changes: 1 addition & 1 deletion api/controllers/SettingsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var _ = require('lodash');
*/
module.exports = _.merge(_.cloneDeep(require('../base/Controller')), {

initial : function(req,res) {
find : function(req,res) {

// ToDo cache settings to memory
//if(sails.KONGA_CONFIG) {
Expand Down
13 changes: 13 additions & 0 deletions assets/js/app/apis/add-api-plugin-modal-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,20 @@
fetchPlugins()
})

function getApiPlugins() {
ApiService.plugins($scope.api.id)
.then(function(response){
$scope.existingPlugins = response.data.data.map(function(item){
return item.name
})
})
.catch(function(err){

})
}


getApiPlugins();

}
])
Expand Down
6 changes: 5 additions & 1 deletion assets/js/app/apis/add-api-plugin-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ <h4><i class="material-icons pull-left">{{group.icon}}</i>&nbsp;{{group.name}}</
</div>

<div class="col-md-4" data-ng-repeat="(key,value) in group.plugins">
<div class="panel panel-default" iln-match-height>
<div class="panel"
ng-class="{'panel-success' : existingPlugins.indexOf(key) > -1, 'panel-default' : existingPlugins.indexOf(key) <0}"
iln-match-height>
<div class="panel-heading">
<div class="panel-title">
<span class="capitalize">{{key.split('-').join(" ")}}</span>
<div class="pull-right">
<button
data-ng-if="existingPlugins.indexOf(key) < 0"
class="btn btn-primary btn-link btn-icon"
angular-ripple data-ng-click="onAddPlugin(key)">
<i class="material-icons">add</i>
</button>
<i class="mdi mdi-check-all" data-ng-if="existingPlugins.indexOf(key) > -1"></i>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/core/models/DataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

// Subscribe to specified endpoint
if (endpoint) {
this.endpoint = endpoint;
this.endpoint = 'api/' + endpoint;

this._subscribe();
} else {
Expand Down
22 changes: 16 additions & 6 deletions assets/js/app/plugins/add-plugin-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

angular.module('frontend.plugins')
.controller('AddPluginController', [
'_','$scope','$rootScope','$log','$state','ListConfig',
'_','$scope','$rootScope','$log','$state','ListConfig','ApiService',
'MessageService','ConsumerModel','SocketHelperService','PluginHelperService',
'KongPluginsService','$uibModalInstance','PluginsService','_pluginName','_schema','_api',
function controller(_,$scope,$rootScope,$log,$state,ListConfig,
function controller(_,$scope,$rootScope,$log,$state,ListConfig,ApiService,
MessageService,ConsumerModel,SocketHelperService,PluginHelperService,
KongPluginsService,$uibModalInstance,PluginsService,_pluginName,_schema,_api ) {

Expand Down Expand Up @@ -120,10 +120,20 @@
$scope.busy = false;
$log.error("create plugin",err)
var errors = {}
Object.keys(err.data.customMessage).forEach(function(key){
errors[key.replace('config.','')] = err.data.customMessage[key]
MessageService.error(key + " : " + err.data.customMessage[key])
})

if(err.data.customMessage) {
Object.keys(err.data.customMessage).forEach(function(key){
errors[key.replace('config.','')] = err.data.customMessage[key]
MessageService.error(key + " : " + err.data.customMessage[key])
})
}

if(err.data.body) {
Object.keys(err.data.body).forEach(function(key){
errors[key] = err.data.body[key]
MessageService.error(key + " : " + err.data.body[key])
})
}
$scope.errors = errors
},function evt(event){
// Only used for ssl plugin certs upload
Expand Down
9 changes: 9 additions & 0 deletions assets/styles/_panels.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$pbrands: primary $brand-primary, success $brand-success, warning $brand-warning, danger $brand-danger, info $brand-info;

@each $brand in $pbrands {
$key: nth($brand, 1);
$value: nth($brand, 2);
.panel-#{$key} {
border: 1px solid $value;
}
}
1 change: 1 addition & 0 deletions assets/styles/importer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import "animloader";
@import "mdi";
@import "login";
@import "panels";


$color-footer-text: #999;
Expand Down
2 changes: 1 addition & 1 deletion config/blueprints.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports.blueprints = {
* `sails.config.routes`) *
* *
***************************************************************************/
//prefix: '/api',
prefix: '/api',

/***************************************************************************
* *
Expand Down
3 changes: 2 additions & 1 deletion config/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ module.exports.policies = {
},

SettingsController : {
'initial' : true
'find' : true,
'*': ['authenticated','isAdmin'],
}


Expand Down
81 changes: 41 additions & 40 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,44 +73,45 @@ module.exports.routes = {
'DELETE /kong/cluster' : 'KongInfoController.deleteCluster',

// Api routes
'POST /kong/apis' : 'KongApiController.create',
'GET /kong/apis/:id' : 'KongApiController.retrieve',
'GET /kong/apis' : 'KongApiController.list',
'PATCH /kong/apis/:id' : 'KongApiController.update',
'PUT /kong/apis/' : 'KongApiController.updateOrCreate',
'DELETE /kong/apis/:id' : 'KongApiController.delete',


'POST /kong/consumers' : 'KongConsumerController.create',
'POST /kong/consumers/:id/acls' : 'KongConsumerController.addAcl',
'GET /kong/consumers/:id' : 'KongConsumerController.retrieve',
'GET /kong/consumers/:id/acls' : 'KongConsumerController.retrieveAcls',
'GET /kong/consumers' : 'KongConsumerController.list',
'PATCH /kong/consumers/:id' : 'KongConsumerController.update',
'PUT /kong/consumers' : 'KongConsumerController.updateOrCreate',
'DELETE /kong/consumers/:id' : 'KongConsumerController.delete',
//'POST /kong/apis' : 'KongApiController.create',
//'GET /kong/apis/:id' : 'KongApiController.retrieve',
'GET /kong/apis' : 'KongApiController.list',
//'PATCH /kong/apis/:id' : 'KongApiController.update',
//'PUT /kong/apis/' : 'KongApiController.updateOrCreate',
//'DELETE /kong/apis/:id' : 'KongApiController.delete',


'GET /kong/consumers/:id/credentials' : 'KongConsumerController.listCredentials',
'GET /kong/consumers/:id/:credential' : 'KongConsumerController.retrieveCredentials',
'POST /kong/consumers/:id/:credential' : 'KongConsumerController.createCredential',
'DELETE /kong/consumers/:id/:credential/:credential_id' : 'KongConsumerController.removeCredential',
'GET /kong/consumers' : 'KongConsumerController.list',

// Plugin routes
'POST /kong/plugins' : 'KongPluginController.create',
'DELETE /kong/plugins/:id' : 'KongPluginController.delete',
'PATCH /kong/plugins/:id' : 'KongPluginController.update',
//'POST /kong/consumers' : 'KongConsumerController.create',
//'POST /kong/consumers/:id/acls' : 'KongConsumerController.addAcl',
//'GET /kong/consumers/:id' : 'KongConsumerController.retrieve',
//'GET /kong/consumers/:id/acls' : 'KongConsumerController.retrieveAcls',
//'PATCH /kong/consumers/:id' : 'KongConsumerController.update',
//'PUT /kong/consumers' : 'KongConsumerController.updateOrCreate',
//'DELETE /kong/consumers/:id' : 'KongConsumerController.delete',


'POST /kong/apis/:api/plugins' : 'KongPluginController.create',
'GET /kong/plugins/:id' : 'KongPluginController.retrieve',
'GET /kong/plugins/enabled' : 'KongPluginController.retrieveEnabled',
'GET /kong/plugins/schema/:plugin' : 'KongPluginController.retrieveSchema',
//'GET /kong/consumers/:id/credentials' : 'KongConsumerController.listCredentials',
//'GET /kong/consumers/:id/:credential' : 'KongConsumerController.retrieveCredentials',
//'POST /kong/consumers/:id/:credential' : 'KongConsumerController.createCredential',
//'DELETE /kong/consumers/:id/:credential/:credential_id' : 'KongConsumerController.removeCredential',

// Plugin routes
//'POST /kong/plugins' : 'KongPluginController.create',
//'DELETE /kong/plugins/:id' : 'KongPluginController.delete',
//'PATCH /kong/plugins/:id' : 'KongPluginController.update',
//
//
//'POST /kong/apis/:api/plugins' : 'KongPluginController.create',
//'GET /kong/plugins/:id' : 'KongPluginController.retrieve',
//'GET /kong/plugins/enabled' : 'KongPluginController.retrieveEnabled',
//'GET /kong/plugins/schema/:plugin' : 'KongPluginController.retrieveSchema',
'GET /kong/plugins' : 'KongPluginController.list',
'GET /kong/apis/:api/plugins' : 'KongPluginController.listApi',
'PATCH /kong/apis/:api/plugins/:id' : 'KongPluginController.update',
'PUT /kong/apis/:api/plugins' : 'KongPluginController.updateOrCreate',
'DELETE /kong/apis/:api/plugins/:id' : 'KongPluginController.delete',
//'GET /kong/apis/:api/plugins' : 'KongPluginController.listApi',
//'PATCH /kong/apis/:api/plugins/:id' : 'KongPluginController.update',
//'PUT /kong/apis/:api/plugins' : 'KongPluginController.updateOrCreate',
//'DELETE /kong/apis/:api/plugins/:id' : 'KongPluginController.delete',

// Remote Storage routes
'GET /remote/adapters' : 'RemoteStorageController.loadAdapters',
Expand Down Expand Up @@ -143,22 +144,22 @@ module.exports.routes = {
'GET /api/kongnodes/healthchecks/subscribe' : 'KongNodeController.subscribeHealthChecks',
'GET /api/apis/healthchecks/subscribe' : 'ApiHealthCheckController.subscribeHealthChecks',

// Upstream routes
//'GET /kong/upstreams' : 'KongUpstreamsController.list',
// Upstream routes
'GET /kong/upstreams' : 'KongUpstreamsController.list',


'GET /api/settings/initial' : 'SettingsController.initial',
'GET /api/settings' : 'SettingsController.find',


/**
* Fallback to proxy
*/

'GET /api/*' : 'ApiController.proxy',
'POST /api/*' : 'ApiController.proxy',
'PUT /api/*' : 'ApiController.proxy',
'PATCH /api/*' : 'ApiController.proxy',
'DELETE /api/*' : 'ApiController.proxy'
'GET /kong/*' : 'KongProxyController.proxy',
'POST /kong/*' : 'KongProxyController.proxy',
'PUT /kong/*' : 'KongProxyController.proxy',
'PATCH /kong/*' : 'KongProxyController.proxy',
'DELETE /kong/*' : 'KongProxyController.proxy'


};
Loading

0 comments on commit d4ceb0c

Please sign in to comment.