-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for Service Instance & Bindings
Updates for service instances. Prep to allow updates to chosen parameters for instance and bindings.
- Loading branch information
Showing
20 changed files
with
1,071 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
'use strict'; | ||
|
||
angular.module('openshiftConsole') | ||
.controller('ServiceInstanceController', function ($scope, | ||
$filter, | ||
$routeParams, | ||
DataService, | ||
ProjectsService, | ||
ServiceInstancesService) { | ||
$scope.alerts = {}; | ||
$scope.projectName = $routeParams.project; | ||
$scope.serviceInstance = null; | ||
$scope.serviceClass = null; | ||
$scope.serviceClasses = null; | ||
|
||
$scope.breadcrumbs = [ | ||
{ | ||
title: "Provisioned Services", | ||
link: "project/" + $routeParams.project + "/browse/service-instances" | ||
} | ||
]; | ||
|
||
$scope.deprovision = function() { | ||
ServiceInstancesService.deprovision($scope.serviceInstance); | ||
}; | ||
|
||
var watches = []; | ||
|
||
var updateBreadcrumbs = function() { | ||
if(!$scope.serviceInstance || !$scope.serviceClasses) { | ||
return; | ||
} | ||
|
||
$scope.breadcrumbs.push({ | ||
title: $filter('serviceInstanceDisplayName')($scope.serviceInstance, $scope.serviceClasses) | ||
}); | ||
}; | ||
|
||
var updateServiceClassMetadata = function() { | ||
if(!$scope.serviceInstance || !$scope.serviceClasses) { | ||
return; | ||
} | ||
|
||
var serviceClassName = _.get($scope.serviceInstance.spec, 'serviceClassName'); | ||
$scope.serviceClass = _.get($scope.serviceClasses, [serviceClassName]); | ||
$scope.plan = _.find(_.get($scope.serviceClass, 'plans'), {name: $scope.serviceInstance.spec.planName }); | ||
}; | ||
|
||
var serviceResolved = function(service, action) { | ||
$scope.loaded = true; | ||
$scope.serviceInstance = service; | ||
|
||
if (action === "DELETED") { | ||
$scope.alerts["deleted"] = { | ||
type: "warning", | ||
message: "This provisioned service has been deleted." | ||
}; | ||
} | ||
|
||
updateServiceClassMetadata(); | ||
}; | ||
|
||
ProjectsService | ||
.get($routeParams.project) | ||
.then(_.spread(function(project, context) { | ||
$scope.project = project; | ||
$scope.projectContext = context; | ||
|
||
DataService | ||
.get({ | ||
group: 'servicecatalog.k8s.io', | ||
resource: 'serviceinstances' | ||
}, $routeParams.instance, context, { errorNotification: false }) | ||
.then(function(service) { | ||
|
||
serviceResolved(service); | ||
updateBreadcrumbs(); | ||
|
||
watches.push(DataService.watchObject({ | ||
group: 'servicecatalog.k8s.io', | ||
resource: 'serviceinstances' | ||
}, $routeParams.instance, context, serviceResolved)); | ||
|
||
}, function(error) { | ||
$scope.loaded = true; | ||
$scope.alerts["load"] = { | ||
type: "error", | ||
message: "The service details could not be loaded.", | ||
details: $filter('getErrorDetails')(error) | ||
}; | ||
}); | ||
|
||
DataService.list({ | ||
group: 'servicecatalog.k8s.io', | ||
resource: 'serviceclasses' | ||
}, context, function(serviceClasses) { | ||
$scope.serviceClasses = serviceClasses.by('metadata.name'); | ||
updateServiceClassMetadata(); | ||
updateBreadcrumbs(); | ||
}); | ||
|
||
$scope.$on('$destroy', function(){ | ||
DataService.unwatchAll(watches); | ||
}); | ||
|
||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
'use strict'; | ||
|
||
angular.module('openshiftConsole') | ||
.controller('ServiceInstancesController', function ($scope, | ||
$filter, | ||
$routeParams, | ||
APIService, | ||
BindingService, | ||
Constants, | ||
DataService, | ||
LabelFilter, | ||
Logger, | ||
ProjectsService) { | ||
$scope.alerts = {}; | ||
$scope.bindingsByInstanceRef = {}; | ||
$scope.emptyMessage = "Loading..."; | ||
$scope.labelSuggestions = {}; | ||
$scope.projectName = $routeParams.project; | ||
$scope.serviceClasses = {}; | ||
$scope.serviceInstances = {}; | ||
$scope.unfilteredServiceInstances = {}; | ||
|
||
var watches = []; | ||
|
||
var updateFilter = function() { | ||
$scope.serviceInstances = LabelFilter.getLabelSelector().select($scope.unfilteredServiceInstances); | ||
}; | ||
|
||
var sortServiceInstances = function() { | ||
$scope.unfilteredServiceInstances = BindingService.sortServiceInstances($scope.unfilteredServiceInstances, $scope.serviceClasses); | ||
}; | ||
|
||
ProjectsService | ||
.get($routeParams.project) | ||
.then(_.spread(function(project, context) { | ||
$scope.project = project; | ||
$scope.projectContext = context; | ||
|
||
watches.push(DataService.watch({ | ||
group: 'servicecatalog.k8s.io', | ||
resource: 'serviceinstancecredentials' | ||
}, context, function(bindings) { | ||
var bindingsByName = bindings.by('metadata.name'); | ||
$scope.bindingsByInstanceRef = _.groupBy(bindingsByName, 'spec.instanceRef.name'); | ||
})); | ||
|
||
watches.push(DataService.watch({ | ||
group: 'servicecatalog.k8s.io', | ||
resource: 'serviceinstances' | ||
}, context, function(serviceInstances) { | ||
$scope.emptyMessage = "No provisioned services to show"; | ||
$scope.unfilteredServiceInstances = serviceInstances.by('metadata.name'); | ||
|
||
sortServiceInstances(); | ||
updateFilter(); | ||
updateFilterWarning(); | ||
|
||
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredServiceInstances, $scope.labelSuggestions); | ||
LabelFilter.setLabelSuggestions($scope.labelSuggestions); | ||
|
||
Logger.log("provisioned services (subscribe)", $scope.unfilteredServiceInstances); | ||
})); | ||
|
||
DataService.list({ | ||
group: 'servicecatalog.k8s.io', | ||
resource: 'serviceclasses' | ||
}, context, function(serviceClasses) { | ||
$scope.serviceClasses = serviceClasses.by('metadata.name'); | ||
sortServiceInstances(); | ||
updateFilter(); | ||
}); | ||
|
||
function updateFilterWarning() { | ||
if (!LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.serviceInstances) && !_.isEmpty($scope.unfilteredServiceInstances)) { | ||
$scope.alerts["all-instances-filtered"] = { | ||
type: "warning", | ||
details: "The active filters are hiding all provisioned services." | ||
}; | ||
} | ||
else { | ||
delete $scope.alerts["all-instances-filtered"]; | ||
} | ||
} | ||
|
||
LabelFilter.onActiveFiltersChanged(function(labelSelector) { | ||
// trigger a digest loop | ||
$scope.$evalAsync(function() { | ||
$scope.serviceInstances = labelSelector.select($scope.unfilteredServiceInstances); | ||
updateFilterWarning(); | ||
}); | ||
}); | ||
|
||
$scope.$on('$destroy', function(){ | ||
DataService.unwatchAll(watches); | ||
}); | ||
|
||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.