diff --git a/app/scripts/controllers/createRoute.js b/app/scripts/controllers/createRoute.js
index 41b1e3c1cb..75fa9e52b7 100644
--- a/app/scripts/controllers/createRoute.js
+++ b/app/scripts/controllers/createRoute.js
@@ -17,9 +17,9 @@ angular.module('openshiftConsole')
AuthorizationService,
DataService,
Navigate,
+ NotificationsService,
ProjectsService,
keyValueEditorUtils) {
- $scope.alerts = {};
$scope.renderOptions = {
hideFilterWidget: true
};
@@ -46,6 +46,15 @@ angular.module('openshiftConsole')
}
];
+ var hideErrorNotifications = function() {
+ NotificationsService.hideNotification("create-route-error");
+ };
+
+ $scope.cancel = function() {
+ hideErrorNotifications();
+ $window.history.back();
+ };
+
ProjectsService
.get($routeParams.project)
.then(_.spread(function(project, context) {
@@ -83,6 +92,7 @@ angular.module('openshiftConsole')
$scope.createRoute = function() {
if ($scope.createRouteForm.$valid) {
+ hideErrorNotifications();
$scope.disableInputs = true;
var serviceName = $scope.routing.to.name;
var labels = keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels));
@@ -102,15 +112,20 @@ angular.module('openshiftConsole')
DataService.create('routes', null, route, context)
.then(function() { // Success
+ NotificationsService.addNotification({
+ type: "success",
+ message: "Route " + route.metadata.name + " was successfully created."
+ });
// Return to the previous page
$window.history.back();
}, function(result) { // Failure
$scope.disableInputs = false;
- $scope.alerts['create-route'] = {
+ NotificationsService.addNotification({
type: "error",
+ id: "create-route-error",
message: "An error occurred creating the route.",
details: $filter('getErrorDetails')(result)
- };
+ });
});
}
};
diff --git a/app/scripts/controllers/edit/route.js b/app/scripts/controllers/edit/route.js
index f8bdfe8f91..451c363214 100644
--- a/app/scripts/controllers/edit/route.js
+++ b/app/scripts/controllers/edit/route.js
@@ -17,9 +17,9 @@ angular.module('openshiftConsole')
AuthorizationService,
DataService,
Navigate,
+ NotificationsService,
ProjectsService,
RoutesService) {
- $scope.alerts = {};
$scope.renderOptions = {
hideFilterWidget: true
};
@@ -41,6 +41,10 @@ angular.module('openshiftConsole')
title: "Edit"
}];
+ $scope.hideErrorNotifications = function() {
+ NotificationsService.hideNotification("edit-route-error");
+ };
+
ProjectsService
.get($routeParams.project)
.then(_.spread(function(project, context) {
@@ -161,25 +165,24 @@ angular.module('openshiftConsole')
$scope.updateRoute = function() {
if ($scope.form.$valid) {
+ $scope.hideErrorNotifications();
$scope.disableInputs = true;
var updated = updateRouteFields();
DataService.update('routes', $scope.routeName, updated, context)
.then(function() { // Success
- AlertMessageService.addAlert({
- name: $scope.routeName,
- data: {
- type: "success",
- message: "Route " + $scope.routeName + " was successfully updated."
- }
+ NotificationsService.addNotification({
+ type: "success",
+ message: "Route " + $scope.routeName + " was successfully updated."
});
$location.path($scope.routeURL);
}, function(response) { // Failure
$scope.disableInputs = false;
- $scope.alerts['update-route'] = {
+ NotificationsService.addNotification({
type: "error",
+ id: "edit-route-error",
message: "An error occurred updating route " + $scope.routeName + ".",
details: $filter('getErrorDetails')(response)
- };
+ });
});
}
};
diff --git a/app/views/create-route.html b/app/views/create-route.html
index 5417810773..0db1513520 100644
--- a/app/views/create-route.html
+++ b/app/views/create-route.html
@@ -12,7 +12,6 @@
-
Create Route
@@ -40,7 +39,7 @@
Create Route
ng-click="createRoute()"
ng-disabled="createRouteForm.$invalid || disableInputs || !createRoute"
value="">Create
-
Cancel
+
Cancel
diff --git a/app/views/edit/route.html b/app/views/edit/route.html
index 8aeab6cb0d..c053cb295f 100644
--- a/app/views/edit/route.html
+++ b/app/views/edit/route.html
@@ -30,7 +30,9 @@
Edit Route {{routeName}}
ng-click="updateRoute()"
ng-disabled="form.$invalid || disableInputs"
value="">Save
-
Cancel
+
Cancel
diff --git a/dist/scripts/scripts.js b/dist/scripts/scripts.js
index 110677cdeb..ac171b90cf 100644
--- a/dist/scripts/scripts.js
+++ b/dist/scripts/scripts.js
@@ -7923,8 +7923,8 @@ d.disableInputs = !1, n(o + " could not be updated.", m(a));
n(o + " could not be loaded.", m(a));
}) :void j.toErrorPage("You do not have authority to update " + o + ".", "access_denied");
}));
-} ]), 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) {
-d.alerts = {}, d.renderOptions = {
+} ]), 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) {
+d.renderOptions = {
hideFilterWidget:!0
}, d.projectName = c.project, d.routeName = c.route, d.loading = !0, d.routeURL = h.resourceURL(d.routeName, "Route", d.projectName), d.breadcrumbs = [ {
title:d.projectName,
@@ -7937,22 +7937,24 @@ title:d.routeName,
link:d.routeURL
}, {
title:"Edit"
-} ], i.get(c.project).then(_.spread(function(i, k) {
-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");
+} ], d.hideErrorNotifications = function() {
+i.hideNotification("edit-route-error");
+}, j.get(c.project).then(_.spread(function(e, j) {
+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");
var l, m = a("orderByDisplayName"), n = function() {
h.toErrorPage('Editing routes with non-service targets is unsupported. You can edit the route with the "Edit YAML" action instead.');
};
-g.get("routes", d.routeName, k).then(function(a) {
+g.get("routes", d.routeName, j).then(function(a) {
if ("Service" !== a.spec.to.kind) return void n();
l = angular.copy(a);
var b = _.get(l, "spec.host"), c = "Subdomain" === _.get(l, "spec.wildcardPolicy");
-c && (b = "*." + j.getSubdomain(l)), d.routing = {
+c && (b = "*." + k.getSubdomain(l)), d.routing = {
host:b,
wildcardPolicy:_.get(l, "spec.wildcardPolicy"),
path:_.get(l, "spec.path"),
targetPort:_.get(l, "spec.port.targetPort"),
tls:angular.copy(_.get(l, "spec.tls"))
-}, g.list("services", k).then(function(a) {
+}, g.list("services", j).then(function(a) {
d.loading = !1;
var b = a.by("metadata.name");
d.routing.to = l.spec.to, d.routing.alternateServices = [], _.each(_.get(l, "spec.alternateBackends"), function(a) {
@@ -7980,22 +7982,20 @@ weight:a.weight
};
d.updateRoute = function() {
if (d.form.$valid) {
-d.disableInputs = !0;
+d.hideErrorNotifications(), d.disableInputs = !0;
var c = o();
-g.update("routes", d.routeName, c, k).then(function() {
-e.addAlert({
-name:d.routeName,
-data:{
+g.update("routes", d.routeName, c, j).then(function() {
+i.addNotification({
type:"success",
message:"Route " + d.routeName + " was successfully updated."
-}
}), b.path(d.routeURL);
}, function(b) {
-d.disableInputs = !1, d.alerts["update-route"] = {
+d.disableInputs = !1, i.addNotification({
type:"error",
+id:"edit-route-error",
message:"An error occurred updating route " + d.routeName + ".",
details:a("getErrorDetails")(b)
-};
+});
});
}
};
@@ -8746,8 +8746,8 @@ details:c("getErrorDetails")(b)
}
});
}));
-} ]), 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) {
-c.alerts = {}, c.renderOptions = {
+} ]), 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) {
+c.renderOptions = {
hideFilterWidget:!0
}, c.projectName = b.project, c.serviceName = b.service, c.labels = [], c.routing = {
name:c.serviceName || ""
@@ -8759,17 +8759,23 @@ title:"Routes",
link:"project/" + c.projectName + "/browse/routes"
}, {
title:"Create Route"
-} ], i.get(b.project).then(_.spread(function(i, k) {
-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");
-var l = a("orderByDisplayName");
+} ];
+var l = function() {
+i.hideNotification("create-route-error");
+};
+c.cancel = function() {
+l(), d.history.back();
+}, j.get(b.project).then(_.spread(function(j, m) {
+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");
+var n = a("orderByDisplayName");
c.routing.to = {
kind:"Service",
name:c.serviceName,
weight:1
-}, g.list("services", k).then(function(a) {
-c.services = l(a.by("metadata.name"));
+}, g.list("services", m).then(function(a) {
+c.services = n(a.by("metadata.name"));
}), c.copyServiceLabels = function() {
-var a = _.get(c, "routing.to.service.metadata.labels", {}), b = j.mapEntries(j.compactEntries(c.labels)), d = _.assign(b, a);
+var a = _.get(c, "routing.to.service.metadata.labels", {}), b = k.mapEntries(k.compactEntries(c.labels)), d = _.assign(b, a);
c.labels = _.map(d, function(a, b) {
return {
name:b,
@@ -8778,22 +8784,26 @@ value:a
});
}, c.createRoute = function() {
if (c.createRouteForm.$valid) {
-c.disableInputs = !0;
-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", []);
-_.isEmpty(i) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(i, function(a) {
+l(), c.disableInputs = !0;
+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", []);
+_.isEmpty(j) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(j, function(a) {
return {
kind:"Service",
name:a.name,
weight:a.weight
};
-})), g.create("routes", null, h, k).then(function() {
-d.history.back();
+})), g.create("routes", null, h, m).then(function() {
+i.addNotification({
+type:"success",
+message:"Route " + h.metadata.name + " was successfully created."
+}), d.history.back();
}, function(b) {
-c.disableInputs = !1, c.alerts["create-route"] = {
+c.disableInputs = !1, i.addNotification({
type:"error",
+id:"create-route-error",
message:"An error occurred creating the route.",
details:a("getErrorDetails")(b)
-};
+});
});
}
};
diff --git a/dist/scripts/templates.js b/dist/scripts/templates.js
index 586fe8b8c0..1cf88e6268 100644
--- a/dist/scripts/templates.js
+++ b/dist/scripts/templates.js
@@ -4695,7 +4695,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"
\n" +
"
\n" +
"
\n" +
- "
\n" +
"
\n" +
"
Create Route
\n" +
"
\n" +
@@ -4712,7 +4711,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"
Copy Service Labels\n" +
"
\n" +
"\n" +
"
\n" +
@@ -9793,7 +9792,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"\n" +
"
\n" +
"\n" +
"\n" +