on create or update failure, show the message returned from the api

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/57b70fe6
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/57b70fe6
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/57b70fe6

Branch: refs/heads/psql
Commit: 57b70fe63394015c35440bb959513a087bdbbd33
Parents: fd51d68
Author: Jeremy Mitchell <mitchell...@gmail.com>
Authored: Fri Oct 14 10:13:32 2016 -0600
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Fri Oct 14 10:13:32 2016 -0600

----------------------------------------------------------------------
 .../ui/app/src/common/api/ASNService.js         |  8 +++----
 .../ui/app/src/common/api/CDNService.js         |  8 +++----
 .../ui/app/src/common/api/CacheGroupService.js  |  8 +++----
 .../src/common/api/DeliveryServiceService.js    |  8 +++----
 .../ui/app/src/common/api/DivisionService.js    |  8 +++----
 .../ui/app/src/common/api/LocationService.js    |  8 +++----
 .../ui/app/src/common/api/ParameterService.js   |  8 +++----
 .../ui/app/src/common/api/ProfileService.js     |  8 +++----
 .../ui/app/src/common/api/RegionService.js      |  8 +++----
 .../ui/app/src/common/api/RoleService.js        | 24 ++++++++++----------
 .../ui/app/src/common/api/ServerService.js      |  8 +++----
 .../ui/app/src/common/api/StatusService.js      |  8 +++----
 .../ui/app/src/common/api/TenantService.js      | 16 ++++++-------
 .../ui/app/src/common/api/TypeService.js        |  8 +++----
 .../ui/app/src/common/api/UserService.js        |  8 +++----
 15 files changed, 72 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/ASNService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ASNService.js 
b/traffic_ops/experimental/ui/app/src/common/api/ASNService.js
index 31a6472..addd29d 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ASNService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ASNService.js
@@ -15,8 +15,8 @@ var ASNService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 'ASN 
created' } ], true);
                     locationUtils.navigateToPath('/admin/asns');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'ASN 
create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var ASNService = function(Restangular, locationUtils, 
messageModel) {
             function() {
                 messageModel.setMessages([ { level: 'success', text: 'ASN 
updated' } ], false);
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'ASN update 
failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/CDNService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/CDNService.js 
b/traffic_ops/experimental/ui/app/src/common/api/CDNService.js
index f633146..3805859 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/CDNService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/CDNService.js
@@ -15,8 +15,8 @@ var CDNService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 'CDN 
created' } ], true);
                     locationUtils.navigateToPath('/admin/cdns');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'CDN 
create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var CDNService = function(Restangular, locationUtils, 
messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 'CDN 
updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'CDN 
update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
----------------------------------------------------------------------
diff --git 
a/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js 
b/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
index 34ee0e6..cd381a9 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
@@ -15,8 +15,8 @@ var CacheGroupService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 
'CacheGroup created' } ], true);
                     locationUtils.navigateToPath('/configure/cache-groups');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'CacheGroup create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var CacheGroupService = function(Restangular, locationUtils, 
messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Cache group updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Cache 
group update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js
----------------------------------------------------------------------
diff --git 
a/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js 
b/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js
index b05f94b..bfefe85 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js
@@ -15,8 +15,8 @@ var DeliveryServiceService = function(Restangular, 
locationUtils, messageModel)
                     messageModel.setMessages([ { level: 'success', text: 
'DeliveryService created' } ], true);
                     
locationUtils.navigateToPath('/configure/delivery-services');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'DeliveryService create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var DeliveryServiceService = function(Restangular, 
locationUtils, messageModel)
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Delivery service updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'Delivery service update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/DivisionService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/DivisionService.js 
b/traffic_ops/experimental/ui/app/src/common/api/DivisionService.js
index cd0108b..5ad4084 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/DivisionService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/DivisionService.js
@@ -15,8 +15,8 @@ var DivisionService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 
'Division created' } ], true);
                     locationUtils.navigateToPath('/admin/divisions');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'Division create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var DivisionService = function(Restangular, locationUtils, 
messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Division updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'Division update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/LocationService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/LocationService.js 
b/traffic_ops/experimental/ui/app/src/common/api/LocationService.js
index b177dc9..5aceafb 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/LocationService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/LocationService.js
@@ -16,8 +16,8 @@ var LocationService = function(Restangular, locationUtils, 
messageModel) {
                     locationUtils.navigateToPath('/admin/locations');
 
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'Location create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -28,8 +28,8 @@ var LocationService = function(Restangular, locationUtils, 
messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Location updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'Location update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js 
b/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
index 1a7b6a0..82807bf 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
@@ -15,8 +15,8 @@ var ParameterService = function(Restangular, locationUtils, 
messageModel) {
                 messageModel.setMessages([ { level: 'success', text: 
'Parameter created' } ], true);
                 locationUtils.navigateToPath('/admin/parameters');
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Parameter 
create failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };
@@ -27,8 +27,8 @@ var ParameterService = function(Restangular, locationUtils, 
messageModel) {
             function() {
                 messageModel.setMessages([ { level: 'success', text: 
'Parameter updated' } ], false);
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Parameter 
update failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js 
b/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
index 4b1422b..f51575a 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
@@ -15,8 +15,8 @@ var ProfileService = function(Restangular, locationUtils, 
messageModel) {
                 messageModel.setMessages([ { level: 'success', text: 'Profile 
created' } ], true);
                 locationUtils.navigateToPath('/admin/profiles');
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Profile 
create failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };
@@ -27,8 +27,8 @@ var ProfileService = function(Restangular, locationUtils, 
messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Profile updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 
'Profile update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
         );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/RegionService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/RegionService.js 
b/traffic_ops/experimental/ui/app/src/common/api/RegionService.js
index 6d71970..705c9cc 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/RegionService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/RegionService.js
@@ -14,8 +14,8 @@ var RegionService = function(Restangular, messageModel) {
             function() {
                 messageModel.setMessages([ { level: 'success', text: 'Region 
created' } ], true);
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Region 
create failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };
@@ -26,8 +26,8 @@ var RegionService = function(Restangular, messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Region updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Region 
update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/RoleService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/RoleService.js 
b/traffic_ops/experimental/ui/app/src/common/api/RoleService.js
index c531450..f0afdf9 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/RoleService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/RoleService.js
@@ -11,24 +11,24 @@ var RoleService = function(Restangular, messageModel) {
     this.updateRole = function(role) {
         return role.put()
             .then(
-            function() {
-                messageModel.setMessages([ { level: 'success', text: 'Role 
updated' } ], false);
-            },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Role 
update failed' } ], false);
-            }
+                function() {
+                    messageModel.setMessages([ { level: 'success', text: 'Role 
updated' } ], false);
+                },
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
+                }
         );
     };
 
     this.deleteRole = function(id) {
         return Restangular.one("roles", id).remove()
             .then(
-            function() {
-                messageModel.setMessages([ { level: 'success', text: 'Role 
deleted' } ], true);
-            },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Role 
delete failed' } ], false);
-            }
+                function() {
+                    messageModel.setMessages([ { level: 'success', text: 'Role 
deleted' } ], true);
+                },
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
+                }
         );
     };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/ServerService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ServerService.js 
b/traffic_ops/experimental/ui/app/src/common/api/ServerService.js
index 1aa58b7..c8edfaa 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ServerService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ServerService.js
@@ -15,8 +15,8 @@ var ServerService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 
'Server created' } ], true);
                     locationUtils.navigateToPath('/configure/servers');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Server 
create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var ServerService = function(Restangular, locationUtils, 
messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Server updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Server 
update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/StatusService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/StatusService.js 
b/traffic_ops/experimental/ui/app/src/common/api/StatusService.js
index 0854d96..6d68aee 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/StatusService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/StatusService.js
@@ -15,8 +15,8 @@ var StatusService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 
'Status created' } ], true);
                     locationUtils.navigateToPath('/admin/statuses');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Status 
create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var StatusService = function(Restangular, locationUtils, 
messageModel) {
             function() {
                 messageModel.setMessages([ { level: 'success', text: 'Status 
updated' } ], false);
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Status 
update failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/TenantService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/TenantService.js 
b/traffic_ops/experimental/ui/app/src/common/api/TenantService.js
index e3000e0..d880deb 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/TenantService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/TenantService.js
@@ -11,12 +11,12 @@ var TenantService = function(Restangular, messageModel) {
     this.createTenant = function(tenant) {
         return Restangular.service('tenant').post(tenant)
             .then(
-            function() {
-                messageModel.setMessages([ { level: 'success', text: 'Tenant 
created' } ], true);
-            },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Tenant 
create failed' } ], false);
-            }
+                function() {
+                    messageModel.setMessages([ { level: 'success', text: 
'Tenant created' } ], true);
+                },
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
+                }
         );
     };
 
@@ -26,8 +26,8 @@ var TenantService = function(Restangular, messageModel) {
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 
'Tenant updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Tenant 
update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/TypeService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/TypeService.js 
b/traffic_ops/experimental/ui/app/src/common/api/TypeService.js
index e943d3a..28b2c70 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/TypeService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/TypeService.js
@@ -15,8 +15,8 @@ var TypeService = function(Restangular, locationUtils, 
messageModel) {
                     messageModel.setMessages([ { level: 'success', text: 'Type 
created' } ], true);
                     locationUtils.navigateToPath('/admin/types');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'Type 
create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -27,8 +27,8 @@ var TypeService = function(Restangular, locationUtils, 
messageModel) {
             function() {
                 messageModel.setMessages([ { level: 'success', text: 'Type 
updated' } ], false);
             },
-            function() {
-                messageModel.setMessages([ { level: 'error', text: 'Type 
update failed' } ], false);
+            function(fault) {
+                messageModel.setMessages(fault.data.alerts, false);
             }
         );
     };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/57b70fe6/traffic_ops/experimental/ui/app/src/common/api/UserService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/UserService.js 
b/traffic_ops/experimental/ui/app/src/common/api/UserService.js
index 261f0a0..b8c010d 100755
--- a/traffic_ops/experimental/ui/app/src/common/api/UserService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/UserService.js
@@ -57,8 +57,8 @@ var UserService = function(Restangular, $http, $location, $q, 
authService, locat
                     messageModel.setMessages([ { level: 'success', text: 'User 
created' } ], true);
                     locationUtils.navigateToPath('/admin/users');
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'User 
create failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };
@@ -69,8 +69,8 @@ var UserService = function(Restangular, $http, $location, $q, 
authService, locat
                 function() {
                     messageModel.setMessages([ { level: 'success', text: 'User 
updated' } ], false);
                 },
-                function() {
-                    messageModel.setMessages([ { level: 'error', text: 'User 
update failed' } ], false);
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
                 }
             );
     };

Reply via email to