Skip to content

Commit

Permalink
Take in account the plugins available_on_server
Browse files Browse the repository at this point in the history
  • Loading branch information
pantsel committed Jul 6, 2018
1 parent 4a93fc0 commit dd7c4c0
Show file tree
Hide file tree
Showing 6 changed files with 754 additions and 755 deletions.
227 changes: 98 additions & 129 deletions assets/js/app/consumers/00_consumers.js
Original file line number Diff line number Diff line change
@@ -1,136 +1,105 @@
(function () {
'use strict';

(function() {
'use strict';
angular.module('frontend.consumers', [
'angular.chips',
'ngMessages',
'angularUtils.directives.dirPagination'
]);

angular.module('frontend.consumers', [
'angular.chips',
'ngMessages',
'angularUtils.directives.dirPagination'
]);
// Module configuration
angular.module('frontend.consumers')
.config([
'$stateProvider',
function config($stateProvider) {
$stateProvider
.state('consumers', {
parent: 'frontend',
url: '/consumers',
data: {
activeNode: true,
pageName: "Consumers",
pageDescription: "The Consumer object represents a consumer - or a user - of an API. You can either rely on Kong as the primary datastore, or you can map the consumer list with your database to keep consistency between Kong and your existing primary datastore.",
//displayName : "consumers",
prefix: '<i class="material-icons">perm_identity</i>'
},

// Module configuration
angular.module('frontend.consumers')
.config([
'$stateProvider',
function config($stateProvider) {
$stateProvider
.state('consumers', {
parent : 'frontend',
url: '/consumers',
data : {
activeNode : true,
pageName : "Consumers",
pageDescription : "The Consumer object represents a consumer - or a user - of an API. You can either rely on Kong as the primary datastore, or you can map the consumer list with your database to keep consistency between Kong and your existing primary datastore.",
//displayName : "consumers",
prefix : '<i class="material-icons">perm_identity</i>'
},
views: {
'content@': {
templateUrl: 'js/app/consumers/index.html',
controller: 'ConsumersController'
}
}
})
.state('consumers.edit', {
url: '/:id',
data: {
pageName: "Edit Consumer",
pageDescription: null,
displayName: "edit consumer",
prefix: '<i class="material-icons">perm_identity</i>'
},
views: {
'content@': {
templateUrl: 'js/app/consumers/edit-consumer.html',
controller: 'ConsumerController',

views: {
'content@': {
templateUrl: 'js/app/consumers/index.html',
controller: 'ConsumersController'
}
}
})
.state('consumers.edit', {
url: '/:id',
data : {
pageName : "Edit Consumer",
pageDescription : null,
displayName : "edit consumer",
prefix : '<i class="material-icons">perm_identity</i>'
},
views: {
'content@': {
templateUrl: 'js/app/consumers/edit-consumer.html',
controller: 'ConsumerController',
},
'[email protected]': {
templateUrl: 'js/app/consumers/details/consumer-details.html',
controller: 'ConsumerDetailsController',
},
'[email protected]': {
templateUrl: 'js/app/consumers/groups/consumer-groups.html',
controller: 'ConsumerGroupsController',
resolve: {
_acls: [
'_',
'ConsumerService',
'$stateParams',
'$rootScope',
function (_, ConsumerService, $stateParams, $rootScope) {
if (_.get($rootScope, 'Gateway.plugins.available_on_server.acl')) {
return ConsumerService.fetchAcls($stateParams.id)
}

},
'[email protected]': {
templateUrl: 'js/app/consumers/details/consumer-details.html',
controller: 'ConsumerDetailsController',
},
'[email protected]': {
templateUrl: 'js/app/consumers/groups/consumer-groups.html',
controller: 'ConsumerGroupsController',
resolve : {
_acls : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.fetchAcls($stateParams.id)
}
],
}
},
'[email protected]': {
templateUrl: 'js/app/consumers/credentials/consumer-credentials.html',
controller: 'ConsumerCredentialsController',
resolve : {
_keys : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.loadCredentials($stateParams.id,'key-auth')
}
],
_jwts : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.loadCredentials($stateParams.id,'jwt')
}
],
_basic_auth_credentials : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.loadCredentials($stateParams.id,'basic-auth')
}
],
_oauth2_credentials : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.loadCredentials($stateParams.id,'oauth2')
}
],
_hmac_auth_credentials : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.loadCredentials($stateParams.id,'hmac-auth')
}
]
}
},
'[email protected]': {
templateUrl: 'js/app/consumers/apis/consumer-apis.html',
controller: 'ConsumerApisController'
},
'[email protected]': {
templateUrl: 'js/app/consumers/plugins/consumer-plugins.html',
controller: 'ConsumerPluginsController'
}
},
resolve : {
_consumer : [
'ConsumerService',
'$stateParams',
function(ConsumerService,$stateParams){
return ConsumerService.findById($stateParams.id)
}
],
_activeNode: [
'NodesService',
function resolve(NodesService) {
return NodesService.isActiveNodeSet()
}
],
},
})
return false;

}
])
;
}
],
}
},
'[email protected]': {
templateUrl: 'js/app/consumers/credentials/consumer-credentials.html',
controller: 'ConsumerCredentialsController'
},
'[email protected]': {
templateUrl: 'js/app/consumers/apis/consumer-apis.html',
controller: 'ConsumerApisController'
},
'[email protected]': {
templateUrl: 'js/app/consumers/plugins/consumer-plugins.html',
controller: 'ConsumerPluginsController'
}
},
resolve: {
_consumer: [
'ConsumerService',
'$stateParams',
function (ConsumerService, $stateParams) {
return ConsumerService.findById($stateParams.id)
}
],
_activeNode: [
'NodesService',
function resolve(NodesService) {
return NodesService.isActiveNodeSet()
}
],
},
})

}
])
;
}());
90 changes: 47 additions & 43 deletions assets/js/app/consumers/consumer-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,65 @@
*
* Note that this file should only contain controllers and nothing else.
*/
(function() {
(function () {
'use strict';

angular.module('frontend.consumers')
.controller('ConsumerController', [
'_','$scope', '$log', '$state','_consumer','$rootScope','Semver',
function controller(_,$scope, $log, $state,_consumer, $rootScope, Semver) {
'_', '$scope', '$log', '$state', '_consumer', '$rootScope', 'Semver',
function controller(_, $scope, $log, $state, _consumer, $rootScope, Semver) {


$scope.consumer = _consumer.data
$state.current.data.pageName = "CONSUMER: " + ( $scope.consumer.username || $scope.consumer.id )
$scope.activeSection = 0;
$scope.sections = [
{
id : 'details',
name : 'DETAILS',
icon : 'mdi-information-outline'
},
{
id : 'groups',
name : 'ACL GROUPS',
icon : 'mdi-account-multiple-outline'
},
{
id : 'credentials',
name : 'CREDENTIALS',
icon : 'mdi-security'
},
{
id : 'apis',
name : 'APIs',
icon : 'mdi-cloud-outline'
},
]
$scope.consumer = _consumer.data
$state.current.data.pageName = "CONSUMER: " + ($scope.consumer.username || $scope.consumer.id)
$scope.activeSection = 0;
$scope.sections = [
{
id: 'details',
name: 'DETAILS',
icon: 'mdi-information-outline'
},
{
id: 'groups',
name: 'ACL GROUPS',
icon: 'mdi-account-multiple-outline'
},
{
id: 'credentials',
name: 'CREDENTIALS',
icon: 'mdi-security'
},
{
id: 'apis',
name: 'APIs',
icon: 'mdi-cloud-outline'
},
]

if(Semver.cmp($rootScope.Gateway.version,"0.11.0") >=0) {
$scope.sections.push({
id : 'plugins',
name : 'PLUGINS',
icon : 'mdi-power-plug'
});
}
if(!_.get($rootScope, 'Gateway.plugins.available_on_server.acl')) {
$scope.sections = _.filter($scope.sections, function (item) {
return item.id !== 'groups'
})
}

$scope.showPluginsSection = Semver.cmp($rootScope.Gateway.version,"0.11.0") >=0;

$scope.showSection = function(index) {
$scope.activeSection = index;
}
if (Semver.cmp($rootScope.Gateway.version, "0.11.0") >= 0) {
$scope.sections.push({
id: 'plugins',
name: 'PLUGINS',
icon: 'mdi-power-plug'
});
}

$scope.showPluginsSection = Semver.cmp($rootScope.Gateway.version, "0.11.0") >= 0;

$scope.$on('user.node.updated',function(node){
$state.go('consumers');
});
$scope.showSection = function (index) {
$scope.activeSection = index;
}


$scope.$on('user.node.updated', function (node) {
$state.go('consumers');
});


}
Expand Down
Loading

0 comments on commit dd7c4c0

Please sign in to comment.