Skip to content

Commit

Permalink
Merge pull request #2172 from benjaminapetersen/bpetersen/trello/api-…
Browse files Browse the repository at this point in the history
…groups/image

Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Sep 27, 2017
2 parents 3c27b2c + b8c169d commit ac5246b
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 80 deletions.
18 changes: 11 additions & 7 deletions app/scripts/controllers/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ImageController', function ($scope,
.controller('ImageController', function ($filter,
$scope,
$routeParams,
APIService,
DataService,
ProjectsService,
$filter,
ImageStreamsService,
imageLayers) {
imageLayers,
ProjectsService) {
$scope.projectName = $routeParams.project;
$scope.imageStream = null;
$scope.image = null;
Expand All @@ -37,11 +38,14 @@ angular.module('openshiftConsole')
}
];

var imageStreamTagsVersion = APIService.getPreferredVersion('imagestreamtags');
var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');

var watches = [];

var fetchImageStreamTag = _.debounce(function(tagData, context) {
var name = $routeParams.imagestream + ":" + $routeParams.tag;
DataService.get("imagestreamtags", name, context).then(
DataService.get(imageStreamTagsVersion, name, context).then(
// success
function(imageStreamTag) {
$scope.loaded = true;
Expand Down Expand Up @@ -95,10 +99,10 @@ angular.module('openshiftConsole')
.then(_.spread(function(project, context) {
$scope.project = project;
DataService
.get("imagestreams", $routeParams.imagestream, context, { errorNotification: false })
.get(imageStreamsVersion, $routeParams.imagestream, context, { errorNotification: false })
.then(function(imageStream) {
imageStreamResolved(imageStream, context);
watches.push(DataService.watchObject("imagestreams", $routeParams.imagestream, context, function(imageStream, action) {
watches.push(DataService.watchObject(imageStreamsVersion, $routeParams.imagestream, context, function(imageStream, action) {
imageStreamResolved(imageStream, context, action);
}));
}, function(e) {
Expand Down
14 changes: 12 additions & 2 deletions app/scripts/controllers/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ImagesController', function ($routeParams, $scope, DataService, ProjectsService, $filter, LabelFilter, Logger) {
.controller('ImagesController', function (
$filter,
$routeParams,
$scope,
APIService,
DataService,
LabelFilter,
Logger,
ProjectsService) {
$scope.projectName = $routeParams.project;
$scope.imageStreams = {};
$scope.unfilteredImageStreams = {};
Expand All @@ -18,13 +26,15 @@ angular.module('openshiftConsole')
$scope.alerts = $scope.alerts || {};
$scope.emptyMessage = "Loading...";

var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');

var watches = [];

ProjectsService
.get($routeParams.project)
.then(_.spread(function(project, context) {
$scope.project = project;
watches.push(DataService.watch("imagestreams", context, function(imageStreams) {
watches.push(DataService.watch(imageStreamsVersion, context, function(imageStreams) {
$scope.unfilteredImageStreams = imageStreams.by("metadata.name");
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredImageStreams, $scope.labelSuggestions);
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
Expand Down
16 changes: 13 additions & 3 deletions app/scripts/controllers/imagestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ImageStreamController', function ($scope, $routeParams, DataService, ProjectsService, $filter, ImageStreamsService, Navigate) {
.controller('ImageStreamController', function (
$filter,
$routeParams,
$scope,
APIService,
DataService,
ImageStreamsService,
Navigate,
ProjectsService) {
$scope.projectName = $routeParams.project;
$scope.imageStream = null;
$scope.tags = [];
Expand All @@ -26,21 +34,23 @@ angular.module('openshiftConsole')
];
$scope.emptyMessage = "Loading...";

$scope.imageStreamsVersion = APIService.getPreferredVersion('imagestreams');

var watches = [];

ProjectsService
.get($routeParams.project)
.then(_.spread(function(project, context) {
$scope.project = project;
DataService.get("imagestreams", $routeParams.imagestream, context, { errorNotification: false }).then(
DataService.get($scope.imageStreamsVersion, $routeParams.imagestream, context, { errorNotification: false }).then(
// success
function(imageStream) {
$scope.loaded = true;
$scope.imageStream = imageStream;
$scope.emptyMessage = "No tags to show";

// If we found the item successfully, watch for changes on it
watches.push(DataService.watchObject("imagestreams", $routeParams.imagestream, context, function(imageStream, action) {
watches.push(DataService.watchObject($scope.imageStreamsVersion, $routeParams.imagestream, context, function(imageStream, action) {
if (action === "DELETED") {
$scope.alerts["deleted"] = {
type: "warning",
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/filters/canI.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ angular
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['update', 'delete']}
],
'imageStreams': [
{group: '', resource: 'imagestreams', verbs: ['update', 'delete']}
_.assign({}, APIService.getPreferredVersion('imagestreams'), {verbs: ['update', 'delete']})
],
'serviceInstances': [
{group: 'servicecatalog.k8s.io', resource: 'serviceinstances', verbs: ['update', 'delete']}
Expand Down
4 changes: 2 additions & 2 deletions app/views/browse/imagestream.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ <h1 class="contains-actions">
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span></a>
<ul class="dropdown-menu dropdown-menu-right actions action-button">
<li ng-if="'imagestreams' | canI : 'update'">
<li ng-if="imageStreamsVersion | canI : 'update'">
<a ng-href="{{imageStream | editYamlURL}}" role="button">Edit YAML</a>
</li>
<li ng-if="'imagestreams' | canI : 'delete'">
<li ng-if="imageStreamsVersion | canI : 'delete'">
<delete-link
kind="ImageStream"
resource-name="{{imageStream.metadata.name}}"
Expand Down
124 changes: 61 additions & 63 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5470,66 +5470,66 @@ i.showJenkinsfileExamples();
o.unwatchAll(d);
});
}));
} ]), angular.module("openshiftConsole").controller("ImageController", [ "$scope", "$routeParams", "DataService", "ProjectsService", "$filter", "ImageStreamsService", "imageLayers", function(e, t, n, a, r, o, i) {
function s(n, a) {
var r = o.tagsByName(n);
e.imageStream = n, e.tagsByName = r, e.tagName = t.tag;
var i = r[t.tag];
i ? (delete e.alerts.load, l(i, a)) : e.alerts.load = {
} ]), angular.module("openshiftConsole").controller("ImageController", [ "$filter", "$scope", "$routeParams", "APIService", "DataService", "ImageStreamsService", "imageLayers", "ProjectsService", function(e, t, n, a, r, o, i, s) {
function c(e, a) {
var r = o.tagsByName(e);
t.imageStream = e, t.tagsByName = r, t.tagName = n.tag;
var i = r[n.tag];
i ? (delete t.alerts.load, p(i, a)) : t.alerts.load = {
type: "error",
message: "The image tag was not found in the stream."
};
}
e.projectName = t.project, e.imageStream = null, e.image = null, e.layers = null, e.tagsByName = {}, e.alerts = {}, e.renderOptions = e.renderOptions || {}, e.renderOptions.hideFilterWidget = !0, e.breadcrumbs = [ {
t.projectName = n.project, t.imageStream = null, t.image = null, t.layers = null, t.tagsByName = {}, t.alerts = {}, t.renderOptions = t.renderOptions || {}, t.renderOptions.hideFilterWidget = !0, t.breadcrumbs = [ {
title: "Image Streams",
link: "project/" + t.project + "/browse/images"
link: "project/" + n.project + "/browse/images"
}, {
title: t.imagestream,
link: "project/" + t.project + "/browse/images/" + t.imagestream
title: n.imagestream,
link: "project/" + n.project + "/browse/images/" + n.imagestream
}, {
title: ":" + t.tag
title: ":" + n.tag
} ];
var c = [], l = _.debounce(function(a, o) {
var s = t.imagestream + ":" + t.tag;
n.get("imagestreamtags", s, o).then(function(t) {
e.loaded = !0, e.image = t.image, e.layers = i(e.image);
}, function(t) {
e.loaded = !0, e.alerts.load = {
var l = a.getPreferredVersion("imagestreamtags"), u = a.getPreferredVersion("imagestreams"), d = [], p = _.debounce(function(a, o) {
var s = n.imagestream + ":" + n.tag;
r.get(l, s, o).then(function(e) {
t.loaded = !0, t.image = e.image, t.layers = i(t.image);
}, function(n) {
t.loaded = !0, t.alerts.load = {
type: "error",
message: "The image details could not be loaded.",
details: r("getErrorDetails")(t)
details: e("getErrorDetails")(n)
};
});
}, 200), u = function(t, n, a) {
s(t, n), "DELETED" === a && (e.alerts.deleted = {
}, 200), m = function(e, n, a) {
c(e, n), "DELETED" === a && (t.alerts.deleted = {
type: "warning",
message: "This image stream has been deleted."
});
};
a.get(t.project).then(_.spread(function(a, o) {
e.project = a, n.get("imagestreams", t.imagestream, o, {
s.get(n.project).then(_.spread(function(a, o) {
t.project = a, r.get(u, n.imagestream, o, {
errorNotification: !1
}).then(function(e) {
u(e, o), c.push(n.watchObject("imagestreams", t.imagestream, o, function(e, t) {
u(e, o, t);
m(e, o), d.push(r.watchObject(u, n.imagestream, o, function(e, t) {
m(e, o, t);
}));
}, function(t) {
e.loaded = !0, e.alerts.load = {
}, function(n) {
t.loaded = !0, t.alerts.load = {
type: "error",
message: "The image stream details could not be loaded.",
details: r("getErrorDetails")(t)
details: e("getErrorDetails")(n)
};
}), e.$on("$destroy", function() {
n.unwatchAll(c);
}), t.$on("$destroy", function() {
r.unwatchAll(d);
});
}));
} ]), angular.module("openshiftConsole").controller("ImagesController", [ "$routeParams", "$scope", "DataService", "ProjectsService", "$filter", "LabelFilter", "Logger", function(e, t, n, a, r, o, i) {
t.projectName = e.project, t.imageStreams = {}, t.unfilteredImageStreams = {}, t.missingStatusTagsByImageStream = {}, t.builds = {}, t.labelSuggestions = {}, t.alerts = t.alerts || {}, t.emptyMessage = "Loading...";
var s = [];
a.get(e.project).then(_.spread(function(e, a) {
function r() {
angular.forEach(t.unfilteredImageStreams, function(e, n) {
var a = t.missingStatusTagsByImageStream[n] = {};
} ]), angular.module("openshiftConsole").controller("ImagesController", [ "$filter", "$routeParams", "$scope", "APIService", "DataService", "LabelFilter", "Logger", "ProjectsService", function(e, t, n, a, r, o, i, s) {
n.projectName = t.project, n.imageStreams = {}, n.unfilteredImageStreams = {}, n.missingStatusTagsByImageStream = {}, n.builds = {}, n.labelSuggestions = {}, n.alerts = n.alerts || {}, n.emptyMessage = "Loading...";
var c = a.getPreferredVersion("imagestreams"), l = [];
s.get(t.project).then(_.spread(function(e, t) {
function a() {
angular.forEach(n.unfilteredImageStreams, function(e, t) {
var a = n.missingStatusTagsByImageStream[t] = {};
if (e.spec && e.spec.tags) {
var r = {};
e.status && e.status.tags && angular.forEach(e.status.tags, function(e) {
Expand All @@ -5540,50 +5540,50 @@ r[e.name] || (a[e.name] = e);
}
});
}
function c() {
o.getLabelSelector().isEmpty() || !$.isEmptyObject(t.imageStreams) || $.isEmptyObject(t.unfilteredImageStreams) ? delete t.alerts.imageStreams : t.alerts.imageStreams = {
function s() {
o.getLabelSelector().isEmpty() || !$.isEmptyObject(n.imageStreams) || $.isEmptyObject(n.unfilteredImageStreams) ? delete n.alerts.imageStreams : n.alerts.imageStreams = {
type: "warning",
details: "The active filters are hiding all image streams."
};
}
t.project = e, s.push(n.watch("imagestreams", a, function(e) {
t.unfilteredImageStreams = e.by("metadata.name"), o.addLabelSuggestionsFromResources(t.unfilteredImageStreams, t.labelSuggestions), o.setLabelSuggestions(t.labelSuggestions), t.imageStreams = o.getLabelSelector().select(t.unfilteredImageStreams), t.emptyMessage = "No image streams to show", r(), c(), i.log("image streams (subscribe)", t.imageStreams);
n.project = e, l.push(r.watch(c, t, function(e) {
n.unfilteredImageStreams = e.by("metadata.name"), o.addLabelSuggestionsFromResources(n.unfilteredImageStreams, n.labelSuggestions), o.setLabelSuggestions(n.labelSuggestions), n.imageStreams = o.getLabelSelector().select(n.unfilteredImageStreams), n.emptyMessage = "No image streams to show", a(), s(), i.log("image streams (subscribe)", n.imageStreams);
})), o.onActiveFiltersChanged(function(e) {
t.$apply(function() {
t.imageStreams = e.select(t.unfilteredImageStreams), c();
n.$apply(function() {
n.imageStreams = e.select(n.unfilteredImageStreams), s();
});
}), t.$on("$destroy", function() {
n.unwatchAll(s);
}), n.$on("$destroy", function() {
r.unwatchAll(l);
});
}));
} ]), angular.module("openshiftConsole").controller("ImageStreamController", [ "$scope", "$routeParams", "DataService", "ProjectsService", "$filter", "ImageStreamsService", "Navigate", function(e, t, n, a, r, o, i) {
e.projectName = t.project, e.imageStream = null, e.tags = [], e.tagShowOlder = {}, e.alerts = {}, e.renderOptions = e.renderOptions || {}, e.renderOptions.hideFilterWidget = !0, e.breadcrumbs = [ {
} ]), angular.module("openshiftConsole").controller("ImageStreamController", [ "$filter", "$routeParams", "$scope", "APIService", "DataService", "ImageStreamsService", "Navigate", "ProjectsService", function(e, t, n, a, r, o, i, s) {
n.projectName = t.project, n.imageStream = null, n.tags = [], n.tagShowOlder = {}, n.alerts = {}, n.renderOptions = n.renderOptions || {}, n.renderOptions.hideFilterWidget = !0, n.breadcrumbs = [ {
title: "Image Streams",
link: "project/" + t.project + "/browse/images"
}, {
title: t.imagestream
} ], e.emptyMessage = "Loading...";
var s = [];
a.get(t.project).then(_.spread(function(a, i) {
e.project = a, n.get("imagestreams", t.imagestream, i, {
} ], n.emptyMessage = "Loading...", n.imageStreamsVersion = a.getPreferredVersion("imagestreams");
var c = [];
s.get(t.project).then(_.spread(function(a, i) {
n.project = a, r.get(n.imageStreamsVersion, t.imagestream, i, {
errorNotification: !1
}).then(function(a) {
e.loaded = !0, e.imageStream = a, e.emptyMessage = "No tags to show", s.push(n.watchObject("imagestreams", t.imagestream, i, function(t, n) {
"DELETED" === n && (e.alerts.deleted = {
}).then(function(e) {
n.loaded = !0, n.imageStream = e, n.emptyMessage = "No tags to show", c.push(r.watchObject(n.imageStreamsVersion, t.imagestream, i, function(e, t) {
"DELETED" === t && (n.alerts.deleted = {
type: "warning",
message: "This image stream has been deleted."
}), e.imageStream = t, e.tags = _.toArray(o.tagsByName(e.imageStream));
}), n.imageStream = e, n.tags = _.toArray(o.tagsByName(n.imageStream));
}));
}, function(t) {
e.loaded = !0, e.alerts.load = {
n.loaded = !0, n.alerts.load = {
type: "error",
message: "The image stream details could not be loaded.",
details: r("getErrorDetails")(t)
details: e("getErrorDetails")(t)
};
}), e.$on("$destroy", function() {
n.unwatchAll(s);
}), n.$on("$destroy", function() {
r.unwatchAll(c);
});
})), e.imagestreamPath = function(e, t) {
})), n.imagestreamPath = function(e, t) {
if (!t.status) return "";
var n = i.resourceURL(e.metadata.name, "ImageStream", e.metadata.namespace);
return t && (n += "/" + t.name), n;
Expand Down Expand Up @@ -15269,11 +15269,9 @@ group: "autoscaling",
resource: "horizontalpodautoscalers",
verbs: [ "update", "delete" ]
} ],
imageStreams: [ {
group: "",
resource: "imagestreams",
imageStreams: [ _.assign({}, e.getPreferredVersion("imagestreams"), {
verbs: [ "update", "delete" ]
} ],
}) ],
serviceInstances: [ {
group: "servicecatalog.k8s.io",
resource: "serviceinstances",
Expand Down
4 changes: 2 additions & 2 deletions dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2920,10 +2920,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</button>\n" +
"<a href=\"\" class=\"dropdown-toggle actions-dropdown-kebab visible-xs-inline\" data-toggle=\"dropdown\"><i class=\"fa fa-ellipsis-v\"></i><span class=\"sr-only\">Actions</span></a>\n" +
"<ul class=\"dropdown-menu dropdown-menu-right actions action-button\">\n" +
"<li ng-if=\"'imagestreams' | canI : 'update'\">\n" +
"<li ng-if=\"imageStreamsVersion | canI : 'update'\">\n" +
"<a ng-href=\"{{imageStream | editYamlURL}}\" role=\"button\">Edit YAML</a>\n" +
"</li>\n" +
"<li ng-if=\"'imagestreams' | canI : 'delete'\">\n" +
"<li ng-if=\"imageStreamsVersion | canI : 'delete'\">\n" +
"<delete-link kind=\"ImageStream\" resource-name=\"{{imageStream.metadata.name}}\" project-name=\"{{imageStream.metadata.namespace}}\" alerts=\"alerts\">\n" +
"</delete-link>\n" +
"</li>\n" +
Expand Down

0 comments on commit ac5246b

Please sign in to comment.