Skip to content

Commit 828a97d

Browse files
committed
Convert form alerts to toast notifications for creating, editing and deleting routes
1 parent 39a73ad commit 828a97d

File tree

3 files changed

+37
-34
lines changed

3 files changed

+37
-34
lines changed

app/scripts/controllers/createRoute.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ angular.module('openshiftConsole')
1717
AuthorizationService,
1818
DataService,
1919
Navigate,
20+
NotificationsService,
2021
ProjectsService,
2122
keyValueEditorUtils) {
2223
$scope.alerts = {};
@@ -101,15 +102,19 @@ angular.module('openshiftConsole')
101102

102103
DataService.create('routes', null, route, context)
103104
.then(function() { // Success
105+
NotificationsService.addNotification({
106+
type: "success",
107+
message: "Route " + route.metadata.name + " was successfully created."
108+
});
104109
// Return to the previous page
105110
$window.history.back();
106111
}, function(result) { // Failure
107112
$scope.disableInputs = false;
108-
$scope.alerts['create-route'] = {
113+
NotificationsService.addNotification({
109114
type: "error",
110115
message: "An error occurred creating the route.",
111116
details: $filter('getErrorDetails')(result)
112-
};
117+
});
113118
});
114119
}
115120
};

app/scripts/controllers/edit/route.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ angular.module('openshiftConsole')
1717
AuthorizationService,
1818
DataService,
1919
Navigate,
20+
NotificationsService,
2021
ProjectsService,
2122
RoutesService) {
2223
$scope.alerts = {};
@@ -162,21 +163,18 @@ angular.module('openshiftConsole')
162163
var updated = updateRouteFields();
163164
DataService.update('routes', $scope.routeName, updated, context)
164165
.then(function() { // Success
165-
AlertMessageService.addAlert({
166-
name: $scope.routeName,
167-
data: {
166+
NotificationsService.addNotification({
168167
type: "success",
169168
message: "Route " + $scope.routeName + " was successfully updated."
170-
}
171169
});
172170
$location.path($scope.routeURL);
173171
}, function(response) { // Failure
174172
$scope.disableInputs = false;
175-
$scope.alerts['update-route'] = {
173+
NotificationsService.addNotification({
176174
type: "error",
177175
message: "An error occurred updating route " + $scope.routeName + ".",
178176
details: $filter('getErrorDetails')(response)
179-
};
177+
});
180178
});
181179
}
182180
};

dist/scripts/scripts.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7864,7 +7864,7 @@ d.disableInputs = !1, n(o + " could not be updated.", m(a));
78647864
n(o + " could not be loaded.", m(a));
78657865
}) :void j.toErrorPage("You do not have authority to update " + o + ".", "access_denied");
78667866
}));
7867-
} ]), 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) {
7867+
} ]), 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) {
78687868
d.alerts = {}, d.renderOptions = {
78697869
hideFilterWidget:!0
78707870
}, d.projectName = c.project, d.routeName = c.route, d.loading = !0, d.routeURL = h.resourceURL(d.routeName, "Route", d.projectName), d.breadcrumbs = [ {
@@ -7878,20 +7878,20 @@ title:d.routeName,
78787878
link:d.routeURL
78797879
}, {
78807880
title:"Edit"
7881-
} ], i.get(c.project).then(_.spread(function(i, k) {
7882-
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");
7881+
} ], j.get(c.project).then(_.spread(function(e, j) {
7882+
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");
78837883
var l, m = a("orderByDisplayName");
7884-
g.get("routes", d.routeName, k).then(function(a) {
7884+
g.get("routes", d.routeName, j).then(function(a) {
78857885
l = angular.copy(a);
78867886
var b = _.get(l, "spec.host"), c = "Subdomain" === _.get(l, "spec.wildcardPolicy");
7887-
c && (b = "*." + j.getSubdomain(l)), d.routing = {
7887+
c && (b = "*." + k.getSubdomain(l)), d.routing = {
78887888
service:_.get(l, "spec.to.name"),
78897889
host:b,
78907890
wildcardPolicy:_.get(l, "spec.wildcardPolicy"),
78917891
path:_.get(l, "spec.path"),
78927892
targetPort:_.get(l, "spec.port.targetPort"),
78937893
tls:angular.copy(_.get(l, "spec.tls"))
7894-
}, g.list("services", k).then(function(a) {
7894+
}, g.list("services", j).then(function(a) {
78957895
var b = a.by("metadata.name"), c = _.get(l, "spec.to", {});
78967896
d.loading = !1, d.services = m(b), d.routing.to = {
78977897
service:b[c.name],
@@ -7926,20 +7926,17 @@ d.updateRoute = function() {
79267926
if (d.form.$valid) {
79277927
d.disableInputs = !0;
79287928
var c = n();
7929-
g.update("routes", d.routeName, c, k).then(function() {
7930-
e.addAlert({
7931-
name:d.routeName,
7932-
data:{
7929+
g.update("routes", d.routeName, c, j).then(function() {
7930+
i.addNotification({
79337931
type:"success",
79347932
message:"Route " + d.routeName + " was successfully updated."
7935-
}
79367933
}), b.path(d.routeURL);
79377934
}, function(b) {
7938-
d.disableInputs = !1, d.alerts["update-route"] = {
7935+
d.disableInputs = !1, i.addNotification({
79397936
type:"error",
79407937
message:"An error occurred updating route " + d.routeName + ".",
79417938
details:a("getErrorDetails")(b)
7942-
};
7939+
});
79437940
});
79447941
}
79457942
};
@@ -8690,7 +8687,7 @@ details:c("getErrorDetails")(b)
86908687
}
86918688
});
86928689
}));
8693-
} ]), 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) {
8690+
} ]), 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) {
86948691
c.alerts = {}, c.renderOptions = {
86958692
hideFilterWidget:!0
86968693
}, c.projectName = b.project, c.serviceName = b.service, c.labels = [], c.routing = {
@@ -8703,15 +8700,15 @@ title:"Routes",
87038700
link:"project/" + c.projectName + "/browse/routes"
87048701
}, {
87058702
title:"Create Route"
8706-
} ], i.get(b.project).then(_.spread(function(i, k) {
8707-
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");
8708-
var l = a("orderByDisplayName");
8709-
g.list("services", k).then(function(a) {
8710-
c.services = l(a.by("metadata.name")), c.routing.to = {}, c.routing.to.service = _.find(c.services, function(a) {
8703+
} ], j.get(b.project).then(_.spread(function(j, l) {
8704+
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");
8705+
var m = a("orderByDisplayName");
8706+
g.list("services", l).then(function(a) {
8707+
c.services = m(a.by("metadata.name")), c.routing.to = {}, c.routing.to.service = _.find(c.services, function(a) {
87118708
return !c.serviceName || a.metadata.name === c.serviceName;
87128709
});
87138710
}), c.copyServiceLabels = function() {
8714-
var a = _.get(c, "routing.to.service.metadata.labels", {}), b = j.mapEntries(j.compactEntries(c.labels)), d = _.assign(b, a);
8711+
var a = _.get(c, "routing.to.service.metadata.labels", {}), b = k.mapEntries(k.compactEntries(c.labels)), d = _.assign(b, a);
87158712
c.labels = _.map(d, function(a, b) {
87168713
return {
87178714
name:b,
@@ -8721,21 +8718,24 @@ value:a
87218718
}, c.createRoute = function() {
87228719
if (c.createRouteForm.$valid) {
87238720
c.disableInputs = !0;
8724-
var b = c.routing.to.service.metadata.name, f = j.mapEntries(j.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), i = _.get(c, "routing.alternateServices", []);
8725-
_.isEmpty(i) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(i, function(a) {
8721+
var b = c.routing.to.service.metadata.name, f = k.mapEntries(k.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), j = _.get(c, "routing.alternateServices", []);
8722+
_.isEmpty(j) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(j, function(a) {
87268723
return {
87278724
kind:"Service",
87288725
name:_.get(a, "service.metadata.name"),
87298726
weight:a.weight
87308727
};
8731-
})), g.create("routes", null, h, k).then(function() {
8732-
d.history.back();
8728+
})), g.create("routes", null, h, l).then(function() {
8729+
i.addNotification({
8730+
type:"success",
8731+
message:"Route " + h.metadata.name + " was successfully created."
8732+
}), d.history.back();
87338733
}, function(b) {
8734-
c.disableInputs = !1, c.alerts["create-route"] = {
8734+
c.disableInputs = !1, i.addNotification({
87358735
type:"error",
87368736
message:"An error occurred creating the route.",
87378737
details:a("getErrorDetails")(b)
8738-
};
8738+
});
87398739
});
87408740
}
87418741
};

0 commit comments

Comments
 (0)