Skip to content

Commit bf2a6f2

Browse files
author
OpenShift Bot
authoredAug 15, 2017
Merge pull request #1919 from spadgett/request-template-metadata
Merged by openshift-bot
2 parents 179deb2 + 946fe5b commit bf2a6f2

File tree

6 files changed

+142
-106
lines changed

6 files changed

+142
-106
lines changed
 

‎app/scripts/controllers/create.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ angular.module('openshiftConsole')
5050
$scope.openshiftImageStreams = resp.by("metadata.name");
5151
});
5252

53-
DataService.list("templates", {namespace: "openshift"}).then(function(resp) {
53+
// Request only the template metadata. Otherwise the response contains all of the object definitions, which can be megabytes of data.
54+
DataService.list("templates", {namespace: "openshift"}, null, {partialObjectMetadataList: true}).then(function(resp) {
5455
$scope.openshiftTemplates = resp.by("metadata.name");
5556
});
5657

@@ -64,7 +65,7 @@ angular.module('openshiftConsole')
6465
$scope.projectImageStreams = resp.by("metadata.name");
6566
});
6667

67-
DataService.list("templates", context).then(function(resp) {
68+
DataService.list("templates", context, null, {partialObjectMetadataList: true}).then(function(resp) {
6869
$scope.projectTemplates = resp.by("metadata.name");
6970
});
7071
}

‎app/scripts/controllers/create/browseCategory.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ angular.module('openshiftConsole')
9999
$scope.openshiftImageStreams = resp.by("metadata.name");
100100
});
101101

102-
DataService.list("templates", {namespace: "openshift"}).then(function(resp) {
102+
// Request only the template metadata. Otherwise the response contains all of the object definitions, which can be megabytes of data.
103+
DataService.list("templates", {namespace: "openshift"}, null, {partialObjectMetadataList: true}).then(function(resp) {
103104
$scope.openshiftTemplates = resp.by("metadata.name");
104105
});
105106

@@ -113,7 +114,7 @@ angular.module('openshiftConsole')
113114
$scope.projectImageStreams = resp.by("metadata.name");
114115
});
115116

116-
DataService.list("templates", context).then(function(resp) {
117+
DataService.list("templates", context, null, {partialObjectMetadataList: true}).then(function(resp) {
117118
$scope.projectTemplates = resp.by("metadata.name");
118119
});
119120
}

‎app/scripts/controllers/landingPage.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ angular.module('openshiftConsole')
77
AuthService,
88
Catalog,
99
Constants,
10+
DataService,
1011
Navigate,
1112
NotificationsService,
1213
RecentlyViewedServiceItems,
1314
GuidedTourService,
1415
HTMLService,
1516
$timeout,
17+
$q,
1618
$routeParams,
1719
$location) {
1820
var tourConfig = _.get(Constants, 'GUIDED_TOURS.landing_page_tour');
@@ -46,8 +48,23 @@ angular.module('openshiftConsole')
4648
}
4749
};
4850

49-
$scope.templateSelected = function(template) {
50-
$scope.template = template;
51+
var isPartialObject = function(apiObject) {
52+
return apiObject.kind === 'PartialObjectMetadata';
53+
};
54+
55+
var loadCompleteTemplate = function(template) {
56+
if (isPartialObject(template)) {
57+
return DataService.get("templates", template.metadata.name, { namespace: template.metadata.namespace });
58+
}
59+
60+
return $q.when(template);
61+
};
62+
63+
$scope.templateSelected = function(selectedTemplate) {
64+
// `selectedTemplate` might be a parial object (metadata only). If necessary, load the complete template object.
65+
loadCompleteTemplate(selectedTemplate).then(function(template) {
66+
$scope.template = template;
67+
});
5168
};
5269

5370
$scope.templateDialogClosed = function() {

‎bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"angular-moment": "1.0.0",
4747
"angular-utf8-base64": "0.0.5",
4848
"file-saver": "1.3.3",
49-
"origin-web-common": "0.0.45",
50-
"origin-web-catalog": "0.0.35"
49+
"origin-web-common": "0.0.46",
50+
"origin-web-catalog": "0.0.36"
5151
},
5252
"devDependencies": {
5353
"angular-mocks": "1.5.11",

‎dist/scripts/scripts.js

+37-21
Original file line numberDiff line numberDiff line change
@@ -4177,31 +4177,39 @@ controller: !0
41774177
});
41784178
}
41794179
};
4180-
}), angular.module("openshiftConsole").controller("LandingPageController", [ "$scope", "$rootScope", "AuthService", "Catalog", "Constants", "Navigate", "NotificationsService", "RecentlyViewedServiceItems", "GuidedTourService", "HTMLService", "$timeout", "$routeParams", "$location", function(e, t, n, a, r, o, i, s, c, l, u, d, m) {
4181-
function p() {
4182-
if (f) if (d.startTour) u(function() {
4183-
m.replace(), m.search("startTour", null), e.startGuidedTour();
4184-
}, 500); else if (_.get(g, "auto_launch")) {
4180+
}), angular.module("openshiftConsole").controller("LandingPageController", [ "$scope", "$rootScope", "AuthService", "Catalog", "Constants", "DataService", "Navigate", "NotificationsService", "RecentlyViewedServiceItems", "GuidedTourService", "HTMLService", "$timeout", "$q", "$routeParams", "$location", function(e, t, n, a, r, o, i, s, c, l, u, d, m, p, g) {
4181+
function f() {
4182+
if (v) if (p.startTour) d(function() {
4183+
g.replace(), g.search("startTour", null), e.startGuidedTour();
4184+
}, 500); else if (_.get(h, "auto_launch")) {
41854185
var n = "openshift/viewedHomePage/" + t.user.metadata.name;
4186-
"true" !== localStorage.getItem(n) && u(function() {
4186+
"true" !== localStorage.getItem(n) && d(function() {
41874187
e.startGuidedTour() && localStorage.setItem(n, "true");
41884188
}, 500);
41894189
}
41904190
}
4191-
var g = _.get(r, "GUIDED_TOURS.landing_page_tour"), f = g && g.enabled && g.steps;
4191+
var h = _.get(r, "GUIDED_TOURS.landing_page_tour"), v = h && h.enabled && h.steps;
41924192
e.saasOfferings = r.SAAS_OFFERINGS, e.viewMembership = function(e) {
4193-
o.toProjectMembership(e.metadata.name);
4194-
}, f && (e.startGuidedTour = function() {
4195-
return !l.isWindowBelowBreakpoint(l.WINDOW_SIZE_SM) && (c.startTour(g.steps), !0);
4196-
}), i.clearNotifications();
4197-
var h = function() {
4193+
i.toProjectMembership(e.metadata.name);
4194+
}, v && (e.startGuidedTour = function() {
4195+
return !u.isWindowBelowBreakpoint(u.WINDOW_SIZE_SM) && (l.startTour(h.steps), !0);
4196+
}), s.clearNotifications();
4197+
var y = function() {
41984198
var t = _.get(e, "template.metadata.uid");
4199-
t && s.addItem(t);
4199+
t && c.addItem(t);
4200+
}, b = function(e) {
4201+
return "PartialObjectMetadata" === e.kind;
4202+
}, C = function(e) {
4203+
return b(e) ? o.get("templates", e.metadata.name, {
4204+
namespace: e.metadata.namespace
4205+
}) : m.when(e);
42004206
};
42014207
e.templateSelected = function(t) {
4208+
C(t).then(function(t) {
42024209
e.template = t;
4210+
});
42034211
}, e.templateDialogClosed = function() {
4204-
h(), e.template = null;
4212+
y(), e.template = null;
42054213
}, n.withUser().then(function() {
42064214
var t = !_.get(r, "ENABLE_TECH_PREVIEW_FEATURE.template_service_broker");
42074215
a.getCatalogItems(t).then(_.spread(function(t, n) {
@@ -4210,14 +4218,14 @@ var a = {
42104218
type: "error",
42114219
message: n
42124220
};
4213-
i.addNotification(a);
4221+
s.addNotification(a);
42144222
}
4215-
e.catalogItems = t, p();
4223+
e.catalogItems = t, f();
42164224
}));
42174225
}), e.$on("$destroy", function() {
4218-
h();
4219-
}), f && e.$on("$locationChangeStart", function(t) {
4220-
m.search().startTour && (e.startGuidedTour(), t.preventDefault());
4226+
y();
4227+
}), v && e.$on("$locationChangeStart", function(t) {
4228+
g.search().startTour && (e.startGuidedTour(), t.preventDefault());
42214229
});
42224230
} ]), angular.module("openshiftConsole").controller("ProjectsController", [ "$scope", "$filter", "$location", "$route", "$timeout", "AuthService", "DataService", "KeywordService", "Logger", "ProjectsService", function(e, t, n, a, r, o, i, s, c, l) {
42234231
var u, d, m = [], p = [];
@@ -7453,11 +7461,15 @@ namespace: "openshift"
74537461
e.openshiftImageStreams = t.by("metadata.name");
74547462
}), s.list("templates", {
74557463
namespace: "openshift"
7464+
}, null, {
7465+
partialObjectMetadataList: !0
74567466
}).then(function(t) {
74577467
e.openshiftTemplates = t.by("metadata.name");
74587468
}), "openshift" === r.project ? (e.projectImageStreams = [], e.projectTemplates = []) : (s.list("imagestreams", a).then(function(t) {
74597469
e.projectImageStreams = t.by("metadata.name");
7460-
}), s.list("templates", a).then(function(t) {
7470+
}), s.list("templates", a, null, {
7471+
partialObjectMetadataList: !0
7472+
}).then(function(t) {
74617473
e.projectTemplates = t.by("metadata.name");
74627474
}));
74637475
}))) : l.toErrorPage("Catalog category " + r.category + "/" + r.subcategory + " not found.");
@@ -7919,11 +7931,15 @@ namespace: "openshift"
79197931
e.openshiftImageStreams = t.by("metadata.name");
79207932
}), c.list("templates", {
79217933
namespace: "openshift"
7934+
}, null, {
7935+
partialObjectMetadataList: !0
79227936
}).then(function(t) {
79237937
e.openshiftTemplates = t.by("metadata.name");
79247938
}), "openshift" === r.project ? (e.projectImageStreams = [], e.projectTemplates = []) : (c.list("imagestreams", a).then(function(t) {
79257939
e.projectImageStreams = t.by("metadata.name");
7926-
}), c.list("templates", a).then(function(t) {
7940+
}), c.list("templates", a, null, {
7941+
partialObjectMetadataList: !0
7942+
}).then(function(t) {
79277943
e.projectTemplates = t.by("metadata.name");
79287944
}));
79297945
}));

0 commit comments

Comments
 (0)
Please sign in to comment.