-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service Instance Details Pages #1906
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partially worked here... since the "crumb" display title/name is both partially dependent on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. Then let's not set the breadcrumb until both load. Then we can call it safely from both callbacks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the load check, instead now checking for |
||
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); | ||
}); | ||
|
||
})); | ||
}); |
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); | ||
}); | ||
|
||
})); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that upstream it will either be called
ServiceInstance
orServiceCatalogInstance
. What you have now looks good, but we might change the name to align with the final name in the upstream service catalog.(Nothing to change right now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up to say the name upstream will be
ServiceInstance
, so what you have is good 👍