Skip to content

Update pvc controller to share get,watch callback #665

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

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions app/scripts/controllers/persistentVolumeClaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,35 @@ angular.module('openshiftConsole')
];

var watches = [];


var pvcResolved = function(pvc, action) {
$scope.pvc = pvc;
$scope.loaded = true;
if (action === "DELETED") {
$scope.alerts["deleted"] = {
type: "warning",
message: "This persistent volume claim has been deleted."
};
}
};

ProjectsService
.get($routeParams.project)
.then(_.spread(function(project, context) {
$scope.project = project;
DataService.get("persistentvolumeclaims", $routeParams.pvc, context).then(
// success
function(pvc) {
$scope.loaded = true;
$scope.pvc = pvc;

// If we found the item successfully, watch for changes on it
watches.push(DataService.watchObject("persistentvolumeclaims", $routeParams.pvc, context, function(pvc, action) {
if (action === "DELETED") {
$scope.alerts["deleted"] = {
type: "warning",
message: "This persistent volume claim has been deleted."
};
}
$scope.pvc = pvc;
}));
},
// failure
function(e) {
DataService
.get("persistentvolumeclaims", $routeParams.pvc, context)
.then(function(pvc) {
pvcResolved(pvc);
watches.push(DataService.watchObject("persistentvolumeclaims", $routeParams.pvc, context, pvcResolved));
}, function(e) {
$scope.loaded = true;
$scope.alerts["load"] = {
type: "error",
message: "The persistent volume claim details could not be loaded.",
details: "Reason: " + $filter('getErrorDetails')(e)
};
}
);
});

$scope.$on('$destroy', function(){
DataService.unwatchAll(watches);
Expand Down
14 changes: 7 additions & 7 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5433,15 +5433,15 @@ link:"project/" + b.project + "/browse/storage"
}, {
title:b.pvc
} ];
var f = [];
d.get(b.project).then(_.spread(function(d, g) {
a.project = d, c.get("persistentvolumeclaims", b.pvc, g).then(function(d) {
a.loaded = !0, a.pvc = d, f.push(c.watchObject("persistentvolumeclaims", b.pvc, g, function(b, c) {
"DELETED" === c && (a.alerts.deleted = {
var f = [], g = function(b, c) {
a.pvc = b, a.loaded = !0, "DELETED" === c && (a.alerts.deleted = {
type:"warning",
message:"This persistent volume claim has been deleted."
}), a.pvc = b;
}));
});
};
d.get(b.project).then(_.spread(function(d, h) {
a.project = d, c.get("persistentvolumeclaims", b.pvc, h).then(function(a) {
g(a), f.push(c.watchObject("persistentvolumeclaims", b.pvc, h, g));
}, function(b) {
a.loaded = !0, a.alerts.load = {
type:"error",
Expand Down