Skip to content

Commit eef932f

Browse files
author
OpenShift Bot
authored
Merge pull request #1567 from sg00dwin/route-conversion-toast
Merged by openshift-bot
2 parents 3427432 + 852af7c commit eef932f

File tree

6 files changed

+76
-48
lines changed

6 files changed

+76
-48
lines changed

app/scripts/controllers/createRoute.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ angular.module('openshiftConsole')
1717
AuthorizationService,
1818
DataService,
1919
Navigate,
20+
NotificationsService,
2021
ProjectsService,
2122
keyValueEditorUtils) {
22-
$scope.alerts = {};
2323
$scope.renderOptions = {
2424
hideFilterWidget: true
2525
};
@@ -46,6 +46,15 @@ angular.module('openshiftConsole')
4646
}
4747
];
4848

49+
var hideErrorNotifications = function() {
50+
NotificationsService.hideNotification("create-route-error");
51+
};
52+
53+
$scope.cancel = function() {
54+
hideErrorNotifications();
55+
$window.history.back();
56+
};
57+
4958
ProjectsService
5059
.get($routeParams.project)
5160
.then(_.spread(function(project, context) {
@@ -83,6 +92,7 @@ angular.module('openshiftConsole')
8392

8493
$scope.createRoute = function() {
8594
if ($scope.createRouteForm.$valid) {
95+
hideErrorNotifications();
8696
$scope.disableInputs = true;
8797
var serviceName = $scope.routing.to.name;
8898
var labels = keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels));
@@ -102,15 +112,20 @@ angular.module('openshiftConsole')
102112

103113
DataService.create('routes', null, route, context)
104114
.then(function() { // Success
115+
NotificationsService.addNotification({
116+
type: "success",
117+
message: "Route " + route.metadata.name + " was successfully created."
118+
});
105119
// Return to the previous page
106120
$window.history.back();
107121
}, function(result) { // Failure
108122
$scope.disableInputs = false;
109-
$scope.alerts['create-route'] = {
123+
NotificationsService.addNotification({
110124
type: "error",
125+
id: "create-route-error",
111126
message: "An error occurred creating the route.",
112127
details: $filter('getErrorDetails')(result)
113-
};
128+
});
114129
});
115130
}
116131
};

app/scripts/controllers/edit/route.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ angular.module('openshiftConsole')
1717
AuthorizationService,
1818
DataService,
1919
Navigate,
20+
NotificationsService,
2021
ProjectsService,
2122
RoutesService) {
22-
$scope.alerts = {};
2323
$scope.renderOptions = {
2424
hideFilterWidget: true
2525
};
@@ -41,6 +41,10 @@ angular.module('openshiftConsole')
4141
title: "Edit"
4242
}];
4343

44+
$scope.hideErrorNotifications = function() {
45+
NotificationsService.hideNotification("edit-route-error");
46+
};
47+
4448
ProjectsService
4549
.get($routeParams.project)
4650
.then(_.spread(function(project, context) {
@@ -161,25 +165,24 @@ angular.module('openshiftConsole')
161165

162166
$scope.updateRoute = function() {
163167
if ($scope.form.$valid) {
168+
$scope.hideErrorNotifications();
164169
$scope.disableInputs = true;
165170
var updated = updateRouteFields();
166171
DataService.update('routes', $scope.routeName, updated, context)
167172
.then(function() { // Success
168-
AlertMessageService.addAlert({
169-
name: $scope.routeName,
170-
data: {
171-
type: "success",
172-
message: "Route " + $scope.routeName + " was successfully updated."
173-
}
173+
NotificationsService.addNotification({
174+
type: "success",
175+
message: "Route " + $scope.routeName + " was successfully updated."
174176
});
175177
$location.path($scope.routeURL);
176178
}, function(response) { // Failure
177179
$scope.disableInputs = false;
178-
$scope.alerts['update-route'] = {
180+
NotificationsService.addNotification({
179181
type: "error",
182+
id: "edit-route-error",
180183
message: "An error occurred updating route " + $scope.routeName + ".",
181184
details: $filter('getErrorDetails')(response)
182-
};
185+
});
183186
});
184187
}
185188
};

app/views/create-route.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<div class="row">
1313
<div class="col-md-10 col-md-offset-1">
1414
<breadcrumbs breadcrumbs="breadcrumbs"></breadcrumbs>
15-
<alerts alerts="alerts"></alerts>
1615
<div class="mar-top-xl">
1716
<h1>Create Route</h1>
1817
<div class="help-block">
@@ -40,7 +39,7 @@ <h1>Create Route</h1>
4039
ng-click="createRoute()"
4140
ng-disabled="createRouteForm.$invalid || disableInputs || !createRoute"
4241
value="">Create</button>
43-
<a class="btn btn-default btn-lg" href="#" back>Cancel</a>
42+
<a class="btn btn-default btn-lg" href="" ng-click="cancel()">Cancel</a>
4443
</div>
4544
</fieldset>
4645
</div>

app/views/edit/route.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ <h1>Edit Route {{routeName}}</h1>
3030
ng-click="updateRoute()"
3131
ng-disabled="form.$invalid || disableInputs"
3232
value="">Save</button>
33-
<a class="btn btn-default btn-lg" ng-href="{{routeURL}}">Cancel</a>
33+
<a class="btn btn-default btn-lg"
34+
ng-click="hideErrorNotifications()"
35+
ng-href="{{routeURL}}">Cancel</a>
3436
</div>
3537
</fieldset>
3638
</form>

dist/scripts/scripts.js

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7362,8 +7362,8 @@ d.disableInputs = !1, n(o + " could not be updated.", m(a));
73627362
n(o + " could not be loaded.", m(a));
73637363
}) :void j.toErrorPage("You do not have authority to update " + o + ".", "access_denied");
73647364
}));
7365-
} ]), angular.module("openshiftConsole").controller("EditRouteController", [ "$filter", "$location", "$routeParams", "$scope", "AlertMessageService", "AuthorizationService", "DataService", "Navigate", "ProjectsService", "RoutesService", function(a, b, c, d, e, f, g, h, i, j) {
7366-
d.alerts = {}, d.renderOptions = {
7365+
} ]), angular.module("openshiftConsole").controller("EditRouteController", [ "$filter", "$location", "$routeParams", "$scope", "AlertMessageService", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "RoutesService", function(a, b, c, d, e, f, g, h, i, j, k) {
7366+
d.renderOptions = {
73677367
hideFilterWidget:!0
73687368
}, d.projectName = c.project, d.routeName = c.route, d.loading = !0, d.routeURL = h.resourceURL(d.routeName, "Route", d.projectName), d.breadcrumbs = [ {
73697369
title:d.projectName,
@@ -7376,22 +7376,24 @@ title:d.routeName,
73767376
link:d.routeURL
73777377
}, {
73787378
title:"Edit"
7379-
} ], i.get(c.project).then(_.spread(function(i, k) {
7380-
if (d.project = i, d.breadcrumbs[0].title = a("displayName")(i), !f.canI("routes", "update", c.project)) return void h.toErrorPage("You do not have authority to update route " + c.routeName + ".", "access_denied");
7379+
} ], d.hideErrorNotifications = function() {
7380+
i.hideNotification("edit-route-error");
7381+
}, j.get(c.project).then(_.spread(function(e, j) {
7382+
if (d.project = e, d.breadcrumbs[0].title = a("displayName")(e), !f.canI("routes", "update", c.project)) return void h.toErrorPage("You do not have authority to update route " + c.routeName + ".", "access_denied");
73817383
var l, m = a("orderByDisplayName"), n = function() {
73827384
h.toErrorPage('Editing routes with non-service targets is unsupported. You can edit the route with the "Edit YAML" action instead.');
73837385
};
7384-
g.get("routes", d.routeName, k).then(function(a) {
7386+
g.get("routes", d.routeName, j).then(function(a) {
73857387
if ("Service" !== a.spec.to.kind) return void n();
73867388
l = angular.copy(a);
73877389
var b = _.get(l, "spec.host"), c = "Subdomain" === _.get(l, "spec.wildcardPolicy");
7388-
c && (b = "*." + j.getSubdomain(l)), d.routing = {
7390+
c && (b = "*." + k.getSubdomain(l)), d.routing = {
73897391
host:b,
73907392
wildcardPolicy:_.get(l, "spec.wildcardPolicy"),
73917393
path:_.get(l, "spec.path"),
73927394
targetPort:_.get(l, "spec.port.targetPort"),
73937395
tls:angular.copy(_.get(l, "spec.tls"))
7394-
}, g.list("services", k).then(function(a) {
7396+
}, g.list("services", j).then(function(a) {
73957397
d.loading = !1;
73967398
var b = a.by("metadata.name");
73977399
d.routing.to = l.spec.to, d.routing.alternateServices = [], _.each(_.get(l, "spec.alternateBackends"), function(a) {
@@ -7419,22 +7421,20 @@ weight:a.weight
74197421
};
74207422
d.updateRoute = function() {
74217423
if (d.form.$valid) {
7422-
d.disableInputs = !0;
7424+
d.hideErrorNotifications(), d.disableInputs = !0;
74237425
var c = o();
7424-
g.update("routes", d.routeName, c, k).then(function() {
7425-
e.addAlert({
7426-
name:d.routeName,
7427-
data:{
7426+
g.update("routes", d.routeName, c, j).then(function() {
7427+
i.addNotification({
74287428
type:"success",
74297429
message:"Route " + d.routeName + " was successfully updated."
7430-
}
74317430
}), b.path(d.routeURL);
74327431
}, function(b) {
7433-
d.disableInputs = !1, d.alerts["update-route"] = {
7432+
d.disableInputs = !1, i.addNotification({
74347433
type:"error",
7434+
id:"edit-route-error",
74357435
message:"An error occurred updating route " + d.routeName + ".",
74367436
details:a("getErrorDetails")(b)
7437-
};
7437+
});
74387438
});
74397439
}
74407440
};
@@ -8185,8 +8185,8 @@ details:c("getErrorDetails")(b)
81858185
}
81868186
});
81878187
}));
8188-
} ]), angular.module("openshiftConsole").controller("CreateRouteController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j) {
8189-
c.alerts = {}, c.renderOptions = {
8188+
} ]), angular.module("openshiftConsole").controller("CreateRouteController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j, k) {
8189+
c.renderOptions = {
81908190
hideFilterWidget:!0
81918191
}, c.projectName = b.project, c.serviceName = b.service, c.labels = [], c.routing = {
81928192
name:c.serviceName || ""
@@ -8198,17 +8198,23 @@ title:"Routes",
81988198
link:"project/" + c.projectName + "/browse/routes"
81998199
}, {
82008200
title:"Create Route"
8201-
} ], i.get(b.project).then(_.spread(function(i, k) {
8202-
if (c.project = i, c.breadcrumbs[0].title = a("displayName")(i), !f.canI("routes", "create", b.project)) return void h.toErrorPage("You do not have authority to create routes in project " + b.project + ".", "access_denied");
8203-
var l = a("orderByDisplayName");
8201+
} ];
8202+
var l = function() {
8203+
i.hideNotification("create-route-error");
8204+
};
8205+
c.cancel = function() {
8206+
l(), d.history.back();
8207+
}, j.get(b.project).then(_.spread(function(j, m) {
8208+
if (c.project = j, c.breadcrumbs[0].title = a("displayName")(j), !f.canI("routes", "create", b.project)) return void h.toErrorPage("You do not have authority to create routes in project " + b.project + ".", "access_denied");
8209+
var n = a("orderByDisplayName");
82048210
c.routing.to = {
82058211
kind:"Service",
82068212
name:c.serviceName,
82078213
weight:1
8208-
}, g.list("services", k).then(function(a) {
8209-
c.services = l(a.by("metadata.name"));
8214+
}, g.list("services", m).then(function(a) {
8215+
c.services = n(a.by("metadata.name"));
82108216
}), c.copyServiceLabels = function() {
8211-
var a = _.get(c, "routing.to.service.metadata.labels", {}), b = j.mapEntries(j.compactEntries(c.labels)), d = _.assign(b, a);
8217+
var a = _.get(c, "routing.to.service.metadata.labels", {}), b = k.mapEntries(k.compactEntries(c.labels)), d = _.assign(b, a);
82128218
c.labels = _.map(d, function(a, b) {
82138219
return {
82148220
name:b,
@@ -8217,22 +8223,26 @@ value:a
82178223
});
82188224
}, c.createRoute = function() {
82198225
if (c.createRouteForm.$valid) {
8220-
c.disableInputs = !0;
8221-
var b = c.routing.to.name, f = j.mapEntries(j.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), i = _.get(c, "routing.alternateServices", []);
8222-
_.isEmpty(i) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(i, function(a) {
8226+
l(), c.disableInputs = !0;
8227+
var b = c.routing.to.name, f = k.mapEntries(k.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), j = _.get(c, "routing.alternateServices", []);
8228+
_.isEmpty(j) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(j, function(a) {
82238229
return {
82248230
kind:"Service",
82258231
name:a.name,
82268232
weight:a.weight
82278233
};
8228-
})), g.create("routes", null, h, k).then(function() {
8229-
d.history.back();
8234+
})), g.create("routes", null, h, m).then(function() {
8235+
i.addNotification({
8236+
type:"success",
8237+
message:"Route " + h.metadata.name + " was successfully created."
8238+
}), d.history.back();
82308239
}, function(b) {
8231-
c.disableInputs = !1, c.alerts["create-route"] = {
8240+
c.disableInputs = !1, i.addNotification({
82328241
type:"error",
8242+
id:"create-route-error",
82338243
message:"An error occurred creating the route.",
82348244
details:a("getErrorDetails")(b)
8235-
};
8245+
});
82368246
});
82378247
}
82388248
};

dist/scripts/templates.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,7 +4698,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
46984698
"<div class=\"row\">\n" +
46994699
"<div class=\"col-md-10 col-md-offset-1\">\n" +
47004700
"<breadcrumbs breadcrumbs=\"breadcrumbs\"></breadcrumbs>\n" +
4701-
"<alerts alerts=\"alerts\"></alerts>\n" +
47024701
"<div class=\"mar-top-xl\">\n" +
47034702
"<h1>Create Route</h1>\n" +
47044703
"<div class=\"help-block\">\n" +
@@ -4715,7 +4714,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
47154714
"<a href=\"\" ng-click=\"copyServiceLabels()\">Copy Service Labels</a>\n" +
47164715
"<div class=\"button-group gutter-top gutter-bottom\">\n" +
47174716
"<button type=\"submit\" class=\"btn btn-primary btn-lg\" ng-click=\"createRoute()\" ng-disabled=\"createRouteForm.$invalid || disableInputs || !createRoute\" value=\"\">Create</button>\n" +
4718-
"<a class=\"btn btn-default btn-lg\" href=\"#\" back>Cancel</a>\n" +
4717+
"<a class=\"btn btn-default btn-lg\" href=\"\" ng-click=\"cancel()\">Cancel</a>\n" +
47194718
"</div>\n" +
47204719
"</fieldset>\n" +
47214720
"</div>\n" +
@@ -9796,7 +9795,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
97969795
"</osc-routing>\n" +
97979796
"<div class=\"button-group gutter-top gutter-bottom\">\n" +
97989797
"<button type=\"submit\" class=\"btn btn-primary btn-lg\" ng-click=\"updateRoute()\" ng-disabled=\"form.$invalid || disableInputs\" value=\"\">Save</button>\n" +
9799-
"<a class=\"btn btn-default btn-lg\" ng-href=\"{{routeURL}}\">Cancel</a>\n" +
9798+
"<a class=\"btn btn-default btn-lg\" ng-click=\"hideErrorNotifications()\" ng-href=\"{{routeURL}}\">Cancel</a>\n" +
98009799
"</div>\n" +
98019800
"</fieldset>\n" +
98029801
"</form>\n" +

0 commit comments

Comments
 (0)