Commit d8934c2e by Jeffrey Phillips

Updates for edit-project and create-project components

No longer used in full pages so remove the btn-lg and input-lg classes
and remove the alerts parameters
parent df4a63c5
...@@ -206,7 +206,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -206,7 +206,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"name\" class=\"required\">Name</label>\n" + " <label for=\"name\" class=\"required\">Name</label>\n" +
" <span ng-class=\"{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}\">\n" + " <span ng-class=\"{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}\">\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"name\"\n" + " name=\"name\"\n" +
" id=\"name\"\n" + " id=\"name\"\n" +
" placeholder=\"my-project\"\n" + " placeholder=\"my-project\"\n" +
...@@ -252,7 +252,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -252,7 +252,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"displayName\">Display Name</label>\n" + " <label for=\"displayName\">Display Name</label>\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"displayName\"\n" + " name=\"displayName\"\n" +
" id=\"displayName\"\n" + " id=\"displayName\"\n" +
" placeholder=\"My Project\"\n" + " placeholder=\"My Project\"\n" +
...@@ -262,7 +262,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -262,7 +262,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"description\">Description</label>\n" + " <label for=\"description\">Description</label>\n" +
" <textarea class=\"form-control input-lg\"\n" + " <textarea class=\"form-control\"\n" +
" name=\"description\"\n" + " name=\"description\"\n" +
" id=\"description\"\n" + " id=\"description\"\n" +
" placeholder=\"A short description.\"\n" + " placeholder=\"A short description.\"\n" +
...@@ -271,7 +271,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -271,7 +271,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"button-group\">\n" + " <div class=\"button-group\">\n" +
" <button type=\"submit\"\n" + " <button type=\"submit\"\n" +
" class=\"btn btn-primary btn-lg\"\n" + " class=\"btn btn-primary\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"createProject()\"\n" + " ng-click=\"createProject()\"\n" +
" ng-disabled=\"createProjectForm.$invalid || nameTaken || disableInputs\"\n" + " ng-disabled=\"createProjectForm.$invalid || nameTaken || disableInputs\"\n" +
...@@ -279,7 +279,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -279,7 +279,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" Create\n" + " Create\n" +
" </button>\n" + " </button>\n" +
" <button\n" + " <button\n" +
" class=\"btn btn-default btn-lg\"\n" + " class=\"btn btn-default\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"cancelCreateProject()\">\n" + " ng-click=\"cancelCreateProject()\">\n" +
" Cancel\n" + " Cancel\n" +
...@@ -357,7 +357,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -357,7 +357,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <fieldset ng-disabled=\"disableInputs\">\n" + " <fieldset ng-disabled=\"disableInputs\">\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"displayName\">Display Name</label>\n" + " <label for=\"displayName\">Display Name</label>\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"displayName\"\n" + " name=\"displayName\"\n" +
" id=\"displayName\"\n" + " id=\"displayName\"\n" +
" placeholder=\"My Project\"\n" + " placeholder=\"My Project\"\n" +
...@@ -367,7 +367,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -367,7 +367,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"description\">Description</label>\n" + " <label for=\"description\">Description</label>\n" +
" <textarea class=\"form-control input-lg\"\n" + " <textarea class=\"form-control\"\n" +
" name=\"description\"\n" + " name=\"description\"\n" +
" id=\"description\"\n" + " id=\"description\"\n" +
" placeholder=\"A short description.\"\n" + " placeholder=\"A short description.\"\n" +
...@@ -376,13 +376,13 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -376,13 +376,13 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"button-group\">\n" + " <div class=\"button-group\">\n" +
" <button type=\"submit\"\n" + " <button type=\"submit\"\n" +
" class=\"btn btn-primary btn-lg\"\n" + " class=\"btn btn-primary\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"update()\"\n" + " ng-click=\"update()\"\n" +
" ng-disabled=\"editProjectForm.$invalid || disableInputs\"\n" + " ng-disabled=\"editProjectForm.$invalid || disableInputs\"\n" +
" value=\"\">{{submitButtonLabel}}</button>\n" + " value=\"\">{{submitButtonLabel}}</button>\n" +
" <button\n" + " <button\n" +
" class=\"btn btn-default btn-lg\"\n" + " class=\"btn btn-default\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"cancelEditProject()\">\n" + " ng-click=\"cancelEditProject()\">\n" +
" Cancel\n" + " Cancel\n" +
...@@ -561,7 +561,7 @@ angular.module("openshiftCommonUI") ...@@ -561,7 +561,7 @@ angular.module("openshiftCommonUI")
isDialog: '@' isDialog: '@'
}, },
templateUrl: 'src/components/create-project/createProject.html', templateUrl: 'src/components/create-project/createProject.html',
controller: function($scope, $location, ProjectsService, NotificationsService, displayNameFilter) { controller: function($scope, $location, ProjectsService, NotificationsService, displayNameFilter, Logger) {
if(!($scope.submitButtonLabel)) { if(!($scope.submitButtonLabel)) {
$scope.submitButtonLabel = 'Create'; $scope.submitButtonLabel = 'Create';
} }
...@@ -575,6 +575,8 @@ angular.module("openshiftCommonUI") ...@@ -575,6 +575,8 @@ angular.module("openshiftCommonUI")
$scope.createProject = function() { $scope.createProject = function() {
$scope.disableInputs = true; $scope.disableInputs = true;
if ($scope.createProjectForm.$valid) { if ($scope.createProjectForm.$valid) {
var displayName = $scope.displayName || $scope.name;
ProjectsService.create($scope.name, $scope.displayName, $scope.description) ProjectsService.create($scope.name, $scope.displayName, $scope.description)
.then(function(project) { .then(function(project) {
// angular is actually wrapping the redirect action // angular is actually wrapping the redirect action
...@@ -594,12 +596,12 @@ angular.module("openshiftCommonUI") ...@@ -594,12 +596,12 @@ angular.module("openshiftCommonUI")
if (data.reason === 'AlreadyExists') { if (data.reason === 'AlreadyExists') {
$scope.nameTaken = true; $scope.nameTaken = true;
} else { } else {
var msg = data.message || 'An error occurred creating the project.'; var msg = data.message || "An error occurred creating project \'" + displayName + "\'.";
NotificationsService.addNotification({ NotificationsService.addNotification({
id: 'create-project-error',
type: 'error', type: 'error',
message: msg message: msg
}); });
Logger.error("Project \'" + displayName + "\' could not be created.", result);
} }
}); });
} }
...@@ -656,10 +658,6 @@ angular.module("openshiftCommonUI") ...@@ -656,10 +658,6 @@ angular.module("openshiftCommonUI")
// Replace so ".dropdown-menu > li > a" styles are applied. // Replace so ".dropdown-menu > li > a" styles are applied.
replace: true, replace: true,
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
var showAlert = function(alert) {
NotificationsService.addNotification(alert.data);
};
var navigateToList = function() { var navigateToList = function() {
if (scope.stayOnCurrentPage) { if (scope.stayOnCurrentPage) {
return; return;
...@@ -695,19 +693,16 @@ angular.module("openshiftCommonUI") ...@@ -695,19 +693,16 @@ angular.module("openshiftCommonUI")
modalInstance.result.then(function() { modalInstance.result.then(function() {
// upon clicking delete button, delete resource and send alert // upon clicking delete button, delete resource and send alert
var projectName = scope.projectName; var projectName = scope.projectName;
var formattedResource = "Project \'" + scope.displayName + "\'"; var formattedResource = "Project \'" + (scope.displayName || projectName) + "\'";
var context = {}; var context = {};
DataService.delete({ DataService.delete({
resource: APIService.kindToResource("Project") resource: APIService.kindToResource("Project")
}, projectName, context) }, projectName, context)
.then(function() { .then(function() {
showAlert({ NotificationsService.addNotification({
name: projectName, type: "success",
data: { message: formattedResource + " was marked for deletion."
type: "success",
message: formattedResource + " was marked for deletion."
}
}); });
if (scope.success) { if (scope.success) {
...@@ -718,12 +713,11 @@ angular.module("openshiftCommonUI") ...@@ -718,12 +713,11 @@ angular.module("openshiftCommonUI")
}) })
.catch(function(err) { .catch(function(err) {
// called if failure to delete // called if failure to delete
var alert = { NotificationsService.addNotification({
type: "error", type: "error",
message: formattedResource + " could not be deleted.", message: formattedResource + " could not be deleted.",
details: $filter('getErrorDetails')(err) details: $filter('getErrorDetails')(err)
}; });
NotificationsService.addNotification(alert);
Logger.error(formattedResource + " could not be deleted.", err); Logger.error(formattedResource + " could not be deleted.", err);
}); });
}); });
...@@ -758,14 +752,13 @@ angular.module("openshiftCommonUI") ...@@ -758,14 +752,13 @@ angular.module("openshiftCommonUI")
restrict: 'E', restrict: 'E',
scope: { scope: {
project: '=', project: '=',
alerts: '=',
submitButtonLabel: '@', submitButtonLabel: '@',
redirectAction: '&', redirectAction: '&',
onCancel: '&', onCancel: '&',
isDialog: '@' isDialog: '@'
}, },
templateUrl: 'src/components/edit-project/editProject.html', templateUrl: 'src/components/edit-project/editProject.html',
controller: function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter) { controller: function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter, Logger) {
if(!($scope.submitButtonLabel)) { if(!($scope.submitButtonLabel)) {
$scope.submitButtonLabel = 'Save'; $scope.submitButtonLabel = 'Save';
} }
...@@ -802,11 +795,6 @@ angular.module("openshiftCommonUI") ...@@ -802,11 +795,6 @@ angular.module("openshiftCommonUI")
return resource; return resource;
}; };
var showAlert = function(alert) {
$scope.alerts["update"] = alert;
NotificationsService.addNotification(alert);
};
$scope.editableFields = editableFields($scope.project); $scope.editableFields = editableFields($scope.project);
$scope.update = function() { $scope.update = function() {
...@@ -826,18 +814,19 @@ angular.module("openshiftCommonUI") ...@@ -826,18 +814,19 @@ angular.module("openshiftCommonUI")
cb(encodeURIComponent($scope.project.metadata.name)); cb(encodeURIComponent($scope.project.metadata.name));
} }
showAlert({ NotificationsService.addNotification({
type: "success", type: 'success',
message: "Project \'" + displayNameFilter(project) + "\' was successfully updated." message: "Project \'" + displayNameFilter(project) + "\' was successfully updated."
}); });
}, function(result) { }, function(result) {
$scope.disableInputs = false; $scope.disableInputs = false;
$scope.editableFields = editableFields($scope.project); $scope.editableFields = editableFields($scope.project);
showAlert({ NotificationsService.addNotification({
type: "error", type: 'error',
message: "An error occurred while updating the project", message: "An error occurred while updating project \'" + displayNameFilter($scope.project) + "\'." ,
details: $filter('getErrorDetails')(result) details: $filter('getErrorDetails')(result)
}); });
Logger.error("Project \'" + displayNameFilter($scope.project) + "\' could not be updated.", result);
}); });
} }
}; };
......
...@@ -377,7 +377,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -377,7 +377,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"name\" class=\"required\">Name</label>\n" + " <label for=\"name\" class=\"required\">Name</label>\n" +
" <span ng-class=\"{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}\">\n" + " <span ng-class=\"{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}\">\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"name\"\n" + " name=\"name\"\n" +
" id=\"name\"\n" + " id=\"name\"\n" +
" placeholder=\"my-project\"\n" + " placeholder=\"my-project\"\n" +
...@@ -423,7 +423,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -423,7 +423,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"displayName\">Display Name</label>\n" + " <label for=\"displayName\">Display Name</label>\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"displayName\"\n" + " name=\"displayName\"\n" +
" id=\"displayName\"\n" + " id=\"displayName\"\n" +
" placeholder=\"My Project\"\n" + " placeholder=\"My Project\"\n" +
...@@ -433,7 +433,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -433,7 +433,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"description\">Description</label>\n" + " <label for=\"description\">Description</label>\n" +
" <textarea class=\"form-control input-lg\"\n" + " <textarea class=\"form-control\"\n" +
" name=\"description\"\n" + " name=\"description\"\n" +
" id=\"description\"\n" + " id=\"description\"\n" +
" placeholder=\"A short description.\"\n" + " placeholder=\"A short description.\"\n" +
...@@ -442,7 +442,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -442,7 +442,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"button-group\">\n" + " <div class=\"button-group\">\n" +
" <button type=\"submit\"\n" + " <button type=\"submit\"\n" +
" class=\"btn btn-primary btn-lg\"\n" + " class=\"btn btn-primary\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"createProject()\"\n" + " ng-click=\"createProject()\"\n" +
" ng-disabled=\"createProjectForm.$invalid || nameTaken || disableInputs\"\n" + " ng-disabled=\"createProjectForm.$invalid || nameTaken || disableInputs\"\n" +
...@@ -450,7 +450,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -450,7 +450,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" Create\n" + " Create\n" +
" </button>\n" + " </button>\n" +
" <button\n" + " <button\n" +
" class=\"btn btn-default btn-lg\"\n" + " class=\"btn btn-default\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"cancelCreateProject()\">\n" + " ng-click=\"cancelCreateProject()\">\n" +
" Cancel\n" + " Cancel\n" +
...@@ -528,7 +528,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -528,7 +528,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <fieldset ng-disabled=\"disableInputs\">\n" + " <fieldset ng-disabled=\"disableInputs\">\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"displayName\">Display Name</label>\n" + " <label for=\"displayName\">Display Name</label>\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"displayName\"\n" + " name=\"displayName\"\n" +
" id=\"displayName\"\n" + " id=\"displayName\"\n" +
" placeholder=\"My Project\"\n" + " placeholder=\"My Project\"\n" +
...@@ -538,7 +538,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -538,7 +538,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"description\">Description</label>\n" + " <label for=\"description\">Description</label>\n" +
" <textarea class=\"form-control input-lg\"\n" + " <textarea class=\"form-control\"\n" +
" name=\"description\"\n" + " name=\"description\"\n" +
" id=\"description\"\n" + " id=\"description\"\n" +
" placeholder=\"A short description.\"\n" + " placeholder=\"A short description.\"\n" +
...@@ -547,13 +547,13 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -547,13 +547,13 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
"\n" + "\n" +
" <div class=\"button-group\">\n" + " <div class=\"button-group\">\n" +
" <button type=\"submit\"\n" + " <button type=\"submit\"\n" +
" class=\"btn btn-primary btn-lg\"\n" + " class=\"btn btn-primary\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"update()\"\n" + " ng-click=\"update()\"\n" +
" ng-disabled=\"editProjectForm.$invalid || disableInputs\"\n" + " ng-disabled=\"editProjectForm.$invalid || disableInputs\"\n" +
" value=\"\">{{submitButtonLabel}}</button>\n" + " value=\"\">{{submitButtonLabel}}</button>\n" +
" <button\n" + " <button\n" +
" class=\"btn btn-default btn-lg\"\n" + " class=\"btn btn-default\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"cancelEditProject()\">\n" + " ng-click=\"cancelEditProject()\">\n" +
" Cancel\n" + " Cancel\n" +
...@@ -732,7 +732,7 @@ angular.module("openshiftCommonUI") ...@@ -732,7 +732,7 @@ angular.module("openshiftCommonUI")
isDialog: '@' isDialog: '@'
}, },
templateUrl: 'src/components/create-project/createProject.html', templateUrl: 'src/components/create-project/createProject.html',
controller: ["$scope", "$location", "ProjectsService", "NotificationsService", "displayNameFilter", function($scope, $location, ProjectsService, NotificationsService, displayNameFilter) { controller: ["$scope", "$location", "ProjectsService", "NotificationsService", "displayNameFilter", "Logger", function($scope, $location, ProjectsService, NotificationsService, displayNameFilter, Logger) {
if(!($scope.submitButtonLabel)) { if(!($scope.submitButtonLabel)) {
$scope.submitButtonLabel = 'Create'; $scope.submitButtonLabel = 'Create';
} }
...@@ -746,6 +746,8 @@ angular.module("openshiftCommonUI") ...@@ -746,6 +746,8 @@ angular.module("openshiftCommonUI")
$scope.createProject = function() { $scope.createProject = function() {
$scope.disableInputs = true; $scope.disableInputs = true;
if ($scope.createProjectForm.$valid) { if ($scope.createProjectForm.$valid) {
var displayName = $scope.displayName || $scope.name;
ProjectsService.create($scope.name, $scope.displayName, $scope.description) ProjectsService.create($scope.name, $scope.displayName, $scope.description)
.then(function(project) { .then(function(project) {
// angular is actually wrapping the redirect action // angular is actually wrapping the redirect action
...@@ -765,12 +767,12 @@ angular.module("openshiftCommonUI") ...@@ -765,12 +767,12 @@ angular.module("openshiftCommonUI")
if (data.reason === 'AlreadyExists') { if (data.reason === 'AlreadyExists') {
$scope.nameTaken = true; $scope.nameTaken = true;
} else { } else {
var msg = data.message || 'An error occurred creating the project.'; var msg = data.message || "An error occurred creating project \'" + displayName + "\'.";
NotificationsService.addNotification({ NotificationsService.addNotification({
id: 'create-project-error',
type: 'error', type: 'error',
message: msg message: msg
}); });
Logger.error("Project \'" + displayName + "\' could not be created.", result);
} }
}); });
} }
...@@ -827,10 +829,6 @@ angular.module("openshiftCommonUI") ...@@ -827,10 +829,6 @@ angular.module("openshiftCommonUI")
// Replace so ".dropdown-menu > li > a" styles are applied. // Replace so ".dropdown-menu > li > a" styles are applied.
replace: true, replace: true,
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
var showAlert = function(alert) {
NotificationsService.addNotification(alert.data);
};
var navigateToList = function() { var navigateToList = function() {
if (scope.stayOnCurrentPage) { if (scope.stayOnCurrentPage) {
return; return;
...@@ -866,19 +864,16 @@ angular.module("openshiftCommonUI") ...@@ -866,19 +864,16 @@ angular.module("openshiftCommonUI")
modalInstance.result.then(function() { modalInstance.result.then(function() {
// upon clicking delete button, delete resource and send alert // upon clicking delete button, delete resource and send alert
var projectName = scope.projectName; var projectName = scope.projectName;
var formattedResource = "Project \'" + scope.displayName + "\'"; var formattedResource = "Project \'" + (scope.displayName || projectName) + "\'";
var context = {}; var context = {};
DataService.delete({ DataService.delete({
resource: APIService.kindToResource("Project") resource: APIService.kindToResource("Project")
}, projectName, context) }, projectName, context)
.then(function() { .then(function() {
showAlert({ NotificationsService.addNotification({
name: projectName, type: "success",
data: { message: formattedResource + " was marked for deletion."
type: "success",
message: formattedResource + " was marked for deletion."
}
}); });
if (scope.success) { if (scope.success) {
...@@ -889,12 +884,11 @@ angular.module("openshiftCommonUI") ...@@ -889,12 +884,11 @@ angular.module("openshiftCommonUI")
}) })
.catch(function(err) { .catch(function(err) {
// called if failure to delete // called if failure to delete
var alert = { NotificationsService.addNotification({
type: "error", type: "error",
message: formattedResource + " could not be deleted.", message: formattedResource + " could not be deleted.",
details: $filter('getErrorDetails')(err) details: $filter('getErrorDetails')(err)
}; });
NotificationsService.addNotification(alert);
Logger.error(formattedResource + " could not be deleted.", err); Logger.error(formattedResource + " could not be deleted.", err);
}); });
}); });
...@@ -929,14 +923,13 @@ angular.module("openshiftCommonUI") ...@@ -929,14 +923,13 @@ angular.module("openshiftCommonUI")
restrict: 'E', restrict: 'E',
scope: { scope: {
project: '=', project: '=',
alerts: '=',
submitButtonLabel: '@', submitButtonLabel: '@',
redirectAction: '&', redirectAction: '&',
onCancel: '&', onCancel: '&',
isDialog: '@' isDialog: '@'
}, },
templateUrl: 'src/components/edit-project/editProject.html', templateUrl: 'src/components/edit-project/editProject.html',
controller: ["$scope", "$filter", "$location", "DataService", "NotificationsService", "annotationNameFilter", "displayNameFilter", function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter) { controller: ["$scope", "$filter", "$location", "DataService", "NotificationsService", "annotationNameFilter", "displayNameFilter", "Logger", function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter, Logger) {
if(!($scope.submitButtonLabel)) { if(!($scope.submitButtonLabel)) {
$scope.submitButtonLabel = 'Save'; $scope.submitButtonLabel = 'Save';
} }
...@@ -973,11 +966,6 @@ angular.module("openshiftCommonUI") ...@@ -973,11 +966,6 @@ angular.module("openshiftCommonUI")
return resource; return resource;
}; };
var showAlert = function(alert) {
$scope.alerts["update"] = alert;
NotificationsService.addNotification(alert);
};
$scope.editableFields = editableFields($scope.project); $scope.editableFields = editableFields($scope.project);
$scope.update = function() { $scope.update = function() {
...@@ -997,18 +985,19 @@ angular.module("openshiftCommonUI") ...@@ -997,18 +985,19 @@ angular.module("openshiftCommonUI")
cb(encodeURIComponent($scope.project.metadata.name)); cb(encodeURIComponent($scope.project.metadata.name));
} }
showAlert({ NotificationsService.addNotification({
type: "success", type: 'success',
message: "Project \'" + displayNameFilter(project) + "\' was successfully updated." message: "Project \'" + displayNameFilter(project) + "\' was successfully updated."
}); });
}, function(result) { }, function(result) {
$scope.disableInputs = false; $scope.disableInputs = false;
$scope.editableFields = editableFields($scope.project); $scope.editableFields = editableFields($scope.project);
showAlert({ NotificationsService.addNotification({
type: "error", type: 'error',
message: "An error occurred while updating the project", message: "An error occurred while updating project \'" + displayNameFilter($scope.project) + "\'." ,
details: $filter('getErrorDetails')(result) details: $filter('getErrorDetails')(result)
}); });
Logger.error("Project \'" + displayNameFilter($scope.project) + "\' could not be updated.", result);
}); });
} }
}; };
......
...@@ -88,9 +88,9 @@ description:"Name must consist of lower-case letters, numbers, periods, and hyph ...@@ -88,9 +88,9 @@ description:"Name must consist of lower-case letters, numbers, periods, and hyph
$templateCache.put("src/components/binding/bindApplicationForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for application <strong>{{ctrl.applicationName}}</strong></h3>\n </label>\n <span class="help-block">\n Bindings create a secret containing the necessary information for an application to use a service.\n </span>\n </div>\n </form>\n\n <label ng-if="!ctrl.allowNoBinding">\n Select a service:\n </label>\n <form name="ctrl.formName">\n <fieldset>\n <div class="radio">\n <div ng-if="ctrl.allowNoBinding" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="null">\n Do not bind at this time.\n </label>\n <div class="bind-description">\n <span class="help-block service-instance-name">\n Bindings can be created later from within a project.\n </span>\n </div>\n </div>\n <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance">\n {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}}\n </label>\n <div class="bind-description">\n <span class="pficon pficon-info"\n ng-if="!(serviceInstance | isServiceInstanceReady)"\n data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready."\n data-toggle="popover"\n data-trigger="hover">\n </span>\n <span class="help-block service-instance-name">\n {{serviceInstance.metadata.name}}\n </span>\n </div>\n </div>\n <h4 ng-if="!ctrl.bindableServiceInstances.length">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="help-block service-instance-name">\n There are no bindable services in this project\n </span>\n </h4>\n </div>\n </fieldset>\n </form>\n</div>\n'), $templateCache.put("src/components/binding/bindApplicationForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for application <strong>{{ctrl.applicationName}}</strong></h3>\n </label>\n <span class="help-block">\n Bindings create a secret containing the necessary information for an application to use a service.\n </span>\n </div>\n </form>\n\n <label ng-if="!ctrl.allowNoBinding">\n Select a service:\n </label>\n <form name="ctrl.formName">\n <fieldset>\n <div class="radio">\n <div ng-if="ctrl.allowNoBinding" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="null">\n Do not bind at this time.\n </label>\n <div class="bind-description">\n <span class="help-block service-instance-name">\n Bindings can be created later from within a project.\n </span>\n </div>\n </div>\n <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance">\n {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}}\n </label>\n <div class="bind-description">\n <span class="pficon pficon-info"\n ng-if="!(serviceInstance | isServiceInstanceReady)"\n data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready."\n data-toggle="popover"\n data-trigger="hover">\n </span>\n <span class="help-block service-instance-name">\n {{serviceInstance.metadata.name}}\n </span>\n </div>\n </div>\n <h4 ng-if="!ctrl.bindableServiceInstances.length">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="help-block service-instance-name">\n There are no bindable services in this project\n </span>\n </h4>\n </div>\n </fieldset>\n </form>\n</div>\n'),
$templateCache.put("src/components/binding/bindResults.html", '<div ng-if="!ctrl.error">\n <div ng-if="!(ctrl.binding | isBindingReady)" class="bind-status" ng-class="{\'text-center\': !ctrl.progressInline, \'show-progress\': !ctrl.progressInline}">\n <div class="spinner" ng-class="{\'spinner-sm\': ctrl.progressInline, \'spinner-inline\': ctrl.progressInline, \'spinner-lg\': !ctrl.progressInline}" aria-hidden="true"></div>\n <h3 class="bind-message">\n <span class="sr-only">Pending</span>\n <div class="bind-pending-message" ng-class="{\'progress-inline\': ctrl.progressInline}">The binding was created but is not ready yet.</div>\n </h3>\n </div>\n <div ng-if="(ctrl.binding | isBindingReady)">\n <div class="bind-status">\n <span class="pficon pficon-ok" aria-hidden="true"></span>\n <span class="sr-only">Success</span>\n <h3 class="bind-message">\n <strong>{{ctrl.serviceToBind}}</strong>\n <span>has been bound</span>\n <span ng-if="ctrl.bindType === \'application\'"> to <strong>{{ctrl.applicationToBind}}</strong> successfully</span>\n </h3>\n </div>\n <div class="sub-title">\n The binding operation created the secret\n <a ng-if="ctrl.secretHref && \'secrets\' | canI : \'list\'"\n ng-href="{{ctrl.secretHref}}">{{ctrl.binding.spec.secretName}}</a>\n <span ng-if="!ctrl.secretHref || !(\'secrets\' | canI : \'list\')">{{ctrl.binding.spec.secretName}}</span>\n that you may need to reference in your application.\n <span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span>\n </div>\n <div class="alert alert-info bind-info">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="sr-only">Info</span>\n The binding secret will only be available to new pods. You will need to redeploy your application.\n </div>\n </div>\n</div>\n<div ng-if="ctrl.error">\n <div class="bind-status">\n <span class="pficon pficon-error-circle-o text-danger" aria-hidden="true"></span>\n <span class="sr-only">Error</span>\n <h3 class="bind-message">\n <span>Binding Failed</span>\n </h3>\n </div>\n <div class="sub-title">\n <span ng-if="ctrl.error.data.message">\n {{ctrl.error.data.message | upperFirst}}\n </span>\n <span ng-if="!ctrl.error.data.message">\n An error occurred creating the binding.\n </span>\n </div>\n</div>\n'), $templateCache.put("src/components/binding/bindResults.html", '<div ng-if="!ctrl.error">\n <div ng-if="!(ctrl.binding | isBindingReady)" class="bind-status" ng-class="{\'text-center\': !ctrl.progressInline, \'show-progress\': !ctrl.progressInline}">\n <div class="spinner" ng-class="{\'spinner-sm\': ctrl.progressInline, \'spinner-inline\': ctrl.progressInline, \'spinner-lg\': !ctrl.progressInline}" aria-hidden="true"></div>\n <h3 class="bind-message">\n <span class="sr-only">Pending</span>\n <div class="bind-pending-message" ng-class="{\'progress-inline\': ctrl.progressInline}">The binding was created but is not ready yet.</div>\n </h3>\n </div>\n <div ng-if="(ctrl.binding | isBindingReady)">\n <div class="bind-status">\n <span class="pficon pficon-ok" aria-hidden="true"></span>\n <span class="sr-only">Success</span>\n <h3 class="bind-message">\n <strong>{{ctrl.serviceToBind}}</strong>\n <span>has been bound</span>\n <span ng-if="ctrl.bindType === \'application\'"> to <strong>{{ctrl.applicationToBind}}</strong> successfully</span>\n </h3>\n </div>\n <div class="sub-title">\n The binding operation created the secret\n <a ng-if="ctrl.secretHref && \'secrets\' | canI : \'list\'"\n ng-href="{{ctrl.secretHref}}">{{ctrl.binding.spec.secretName}}</a>\n <span ng-if="!ctrl.secretHref || !(\'secrets\' | canI : \'list\')">{{ctrl.binding.spec.secretName}}</span>\n that you may need to reference in your application.\n <span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span>\n </div>\n <div class="alert alert-info bind-info">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="sr-only">Info</span>\n The binding secret will only be available to new pods. You will need to redeploy your application.\n </div>\n </div>\n</div>\n<div ng-if="ctrl.error">\n <div class="bind-status">\n <span class="pficon pficon-error-circle-o text-danger" aria-hidden="true"></span>\n <span class="sr-only">Error</span>\n <h3 class="bind-message">\n <span>Binding Failed</span>\n </h3>\n </div>\n <div class="sub-title">\n <span ng-if="ctrl.error.data.message">\n {{ctrl.error.data.message | upperFirst}}\n </span>\n <span ng-if="!ctrl.error.data.message">\n An error occurred creating the binding.\n </span>\n </div>\n</div>\n'),
$templateCache.put("src/components/binding/bindServiceForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3>\n </label>\n <span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span>\n </div>\n </form>\n\n <form name="ctrl.formName" class="mar-bottom-lg">\n <fieldset>\n <div class="radio">\n <label class="bind-choice" ng-disabled="!ctrl.applications.length">\n <input type="radio" ng-model="ctrl.bindType" value="application" ng-disabled="!ctrl.applications.length">\n Create a secret and inject it into an application\n </label>\n <div class="application-select">\n <ui-select ng-model="ctrl.appToBind"\n ng-disabled="ctrl.bindType !== \'application\'"\n ng-required="ctrl.bindType === \'application\'">\n <ui-select-match placeholder="{{ctrl.applications.length ? \'Select an application\' : \'There are no applications in this project\'}}">\n <span>\n {{$select.selected.metadata.name}}\n <small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n </span>\n </ui-select-match>\n <ui-select-choices\n repeat="application in (ctrl.applications) | filter : { metadata: { name: $select.search } } track by (application | uid)"\n group-by="ctrl.groupByKind">\n <span ng-bind-html="application.metadata.name | highlight : $select.search"></span>\n </ui-select-choices>\n </ui-select>\n </div>\n <label class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="secret-only">\n Create a secret in <strong>{{ctrl.projectName}}</strong> to be used later\n </label>\n <div class="help-block bind-description">\n Secrets can be referenced later from an application.\n </div>\n <label ng-if="ctrl.allowNoBinding" class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="none">\n Do not bind at this time\n </label>\n <div ng-if="ctrl.allowNoBinding" class="help-block bind-description">\n Bindings can be created later from within a project.\n </div>\n </div>\n </fieldset>\n </form>\n</div>\n'), $templateCache.put("src/components/binding/bindServiceForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3>\n </label>\n <span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span>\n </div>\n </form>\n\n <form name="ctrl.formName" class="mar-bottom-lg">\n <fieldset>\n <div class="radio">\n <label class="bind-choice" ng-disabled="!ctrl.applications.length">\n <input type="radio" ng-model="ctrl.bindType" value="application" ng-disabled="!ctrl.applications.length">\n Create a secret and inject it into an application\n </label>\n <div class="application-select">\n <ui-select ng-model="ctrl.appToBind"\n ng-disabled="ctrl.bindType !== \'application\'"\n ng-required="ctrl.bindType === \'application\'">\n <ui-select-match placeholder="{{ctrl.applications.length ? \'Select an application\' : \'There are no applications in this project\'}}">\n <span>\n {{$select.selected.metadata.name}}\n <small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n </span>\n </ui-select-match>\n <ui-select-choices\n repeat="application in (ctrl.applications) | filter : { metadata: { name: $select.search } } track by (application | uid)"\n group-by="ctrl.groupByKind">\n <span ng-bind-html="application.metadata.name | highlight : $select.search"></span>\n </ui-select-choices>\n </ui-select>\n </div>\n <label class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="secret-only">\n Create a secret in <strong>{{ctrl.projectName}}</strong> to be used later\n </label>\n <div class="help-block bind-description">\n Secrets can be referenced later from an application.\n </div>\n <label ng-if="ctrl.allowNoBinding" class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="none">\n Do not bind at this time\n </label>\n <div ng-if="ctrl.allowNoBinding" class="help-block bind-description">\n Bindings can be created later from within a project.\n </div>\n </div>\n </fieldset>\n </form>\n</div>\n'),
$templateCache.put("src/components/create-project/createProject.html", '<form name="createProjectForm" novalidate>\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="name" class="required">Name</label>\n <span ng-class="{\'has-error\': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}">\n <input class="form-control input-lg"\n name="name"\n id="name"\n placeholder="my-project"\n type="text"\n required\n take-focus\n minlength="2"\n maxlength="63"\n pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"\n aria-describedby="nameHelp"\n ng-model="name"\n ng-model-options="{ updateOn: \'default blur\' }"\n ng-change="nameTaken = false"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false">\n </span>\n <div>\n <span class="help-block">A unique name for the project.</span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.required && createProjectForm.name.$dirty">\n Name is required.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.minlength && createProjectForm.name.$touched">\n Name must have at least two characters.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.pattern && createProjectForm.name.$touched">\n Project names may only contain lower-case letters, numbers, and dashes.\n They may not start or end with a dash.\n </span>\n </div>\n <div class="has-error">\n <span class="help-block" ng-if="nameTaken">\n This name is already in use. Please choose a different name.\n </span>\n </div>\n </div>\n\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control input-lg"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control input-lg"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary btn-lg"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="createProject()"\n ng-disabled="createProjectForm.$invalid || nameTaken || disableInputs"\n value="">\n Create\n </button>\n <button\n class="btn btn-default btn-lg"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelCreateProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'), $templateCache.put("src/components/create-project/createProject.html", '<form name="createProjectForm" novalidate>\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="name" class="required">Name</label>\n <span ng-class="{\'has-error\': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}">\n <input class="form-control"\n name="name"\n id="name"\n placeholder="my-project"\n type="text"\n required\n take-focus\n minlength="2"\n maxlength="63"\n pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"\n aria-describedby="nameHelp"\n ng-model="name"\n ng-model-options="{ updateOn: \'default blur\' }"\n ng-change="nameTaken = false"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false">\n </span>\n <div>\n <span class="help-block">A unique name for the project.</span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.required && createProjectForm.name.$dirty">\n Name is required.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.minlength && createProjectForm.name.$touched">\n Name must have at least two characters.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.pattern && createProjectForm.name.$touched">\n Project names may only contain lower-case letters, numbers, and dashes.\n They may not start or end with a dash.\n </span>\n </div>\n <div class="has-error">\n <span class="help-block" ng-if="nameTaken">\n This name is already in use. Please choose a different name.\n </span>\n </div>\n </div>\n\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="createProject()"\n ng-disabled="createProjectForm.$invalid || nameTaken || disableInputs"\n value="">\n Create\n </button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelCreateProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'),
$templateCache.put("src/components/delete-project/delete-project-button.html", '<div class="actions">\n <!-- Avoid whitespace inside the link -->\n <a href=""\n ng-click="$event.stopPropagation(); openDeleteModal()"\n role="button"\n class="action-button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n ><i class="fa fa-trash-o" aria-hidden="true"\n ></i><span class="sr-only">Delete Project {{projectName}}</span></a>\n</div>\n'), $templateCache.put("src/components/delete-project/delete-project-modal.html", '<div class="delete-resource-modal">\n <!-- Use a form so that the enter key submits when typing a project name to confirm. -->\n <form>\n <div class="modal-body">\n <h1>Are you sure you want to delete the project\n \'<strong>{{displayName ? displayName : projectName}}</strong>\'?</h1>\n <p>\n This will <strong>delete all resources</strong> associated with\n the project {{displayName ? displayName : projectName}} and <strong>cannot be\n undone</strong>. Make sure this is something you really want to do!\n </p>\n <div ng-show="typeNameToConfirm">\n <p>Type the name of the project to confirm.</p>\n <p>\n <label class="sr-only" for="resource-to-delete">project to delete</label>\n <input\n ng-model="confirmName"\n id="resource-to-delete"\n type="text"\n class="form-control input-lg"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false"\n autofocus>\n </p>\n </div>\n </div>\n <div class="modal-footer">\n <button ng-disabled="typeNameToConfirm && confirmName !== projectName && confirmName !== displayName" class="btn btn-lg btn-danger" type="submit" ng-click="delete();">Delete</button>\n <button class="btn btn-lg btn-default" type="button" ng-click="cancel();">Cancel</button>\n </div>\n </form>\n</div>\n'), $templateCache.put("src/components/delete-project/delete-project-button.html", '<div class="actions">\n <!-- Avoid whitespace inside the link -->\n <a href=""\n ng-click="$event.stopPropagation(); openDeleteModal()"\n role="button"\n class="action-button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n ><i class="fa fa-trash-o" aria-hidden="true"\n ></i><span class="sr-only">Delete Project {{projectName}}</span></a>\n</div>\n'), $templateCache.put("src/components/delete-project/delete-project-modal.html", '<div class="delete-resource-modal">\n <!-- Use a form so that the enter key submits when typing a project name to confirm. -->\n <form>\n <div class="modal-body">\n <h1>Are you sure you want to delete the project\n \'<strong>{{displayName ? displayName : projectName}}</strong>\'?</h1>\n <p>\n This will <strong>delete all resources</strong> associated with\n the project {{displayName ? displayName : projectName}} and <strong>cannot be\n undone</strong>. Make sure this is something you really want to do!\n </p>\n <div ng-show="typeNameToConfirm">\n <p>Type the name of the project to confirm.</p>\n <p>\n <label class="sr-only" for="resource-to-delete">project to delete</label>\n <input\n ng-model="confirmName"\n id="resource-to-delete"\n type="text"\n class="form-control input-lg"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false"\n autofocus>\n </p>\n </div>\n </div>\n <div class="modal-footer">\n <button ng-disabled="typeNameToConfirm && confirmName !== projectName && confirmName !== displayName" class="btn btn-lg btn-danger" type="submit" ng-click="delete();">Delete</button>\n <button class="btn btn-lg btn-default" type="button" ng-click="cancel();">Cancel</button>\n </div>\n </form>\n</div>\n'),
$templateCache.put("src/components/delete-project/delete-project.html", '<a href="javascript:void(0)"\n ng-click="openDeleteModal()"\n role="button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n>{{label || \'Delete\'}}</a>\n'), $templateCache.put("src/components/edit-project/editProject.html", '<form name="editProjectForm">\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control input-lg"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="editableFields.displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control input-lg"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="editableFields.description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary btn-lg"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="update()"\n ng-disabled="editProjectForm.$invalid || disableInputs"\n value="">{{submitButtonLabel}}</button>\n <button\n class="btn btn-default btn-lg"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelEditProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'), $templateCache.put("src/components/delete-project/delete-project.html", '<a href="javascript:void(0)"\n ng-click="openDeleteModal()"\n role="button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n>{{label || \'Delete\'}}</a>\n'), $templateCache.put("src/components/edit-project/editProject.html", '<form name="editProjectForm">\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="editableFields.displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="editableFields.description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="update()"\n ng-disabled="editProjectForm.$invalid || disableInputs"\n value="">{{submitButtonLabel}}</button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelEditProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'),
$templateCache.put("src/components/origin-modal-popup/origin-modal-popup.html", '<div class="origin-modal-popup tile-click-prevent" ng-if="$ctrl.shown" ng-style="$ctrl.positionStyle"\n ng-class="{\'position-above\': $ctrl.showAbove, \'position-left\': $ctrl.showLeft}">\n <h4 class="origin-modal-popup-title">\n {{$ctrl.modalTitle}}\n </h4>\n <div ng-transclude></div>\n <a href="" class="origin-modal-popup-close" ng-click="$ctrl.onClose()">\n <span class="pficon pficon-close"></span>\n </a>\n</div>\n'), $templateCache.put("src/components/toast-notifications/toast-notifications.html", '<div class="toast-notifications-list-pf">\n <div ng-repeat="(notificationID, notification) in notifications track by (notificationID + (notification.message || notification.details))" ng-if="!notification.hidden || notification.isHover"\n ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)">\n <div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{\'alert-dismissable\': !hideCloseButton}">\n <button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)">\n <span class="pficon pficon-close" aria-hidden="true"></span>\n <span class="sr-only">Close</span>\n </button>\n <span class="{{notification.type | alertIcon}}" aria-hidden="true"></span>\n <span class="sr-only">{{notification.type}}</span>\n <span class="toast-notification-message" ng-if="notification.message">{{notification.message}}</span>\n <div ng-if="notification.details" class="toast-notification-details">\n <truncate-long-text\n limit="200"\n content="notification.details"\n use-word-boundary="true"\n expandable="true"\n hide-collapse="true">\n </truncate-long-text>\n </div>\n <span ng-repeat="link in notification.links">\n <a ng-if="!link.href" href="" ng-click="onClick(notification, link)" role="button">{{link.label}}</a>\n <a ng-if="link.href" ng-href="{{link.href}}" ng-attr-target="{{link.target}}">{{link.label}}</a>\n <span ng-if="!$last" class="toast-action-divider">|</span>\n </span>\n </div>\n </div>\n</div>\n'), $templateCache.put("src/components/origin-modal-popup/origin-modal-popup.html", '<div class="origin-modal-popup tile-click-prevent" ng-if="$ctrl.shown" ng-style="$ctrl.positionStyle"\n ng-class="{\'position-above\': $ctrl.showAbove, \'position-left\': $ctrl.showLeft}">\n <h4 class="origin-modal-popup-title">\n {{$ctrl.modalTitle}}\n </h4>\n <div ng-transclude></div>\n <a href="" class="origin-modal-popup-close" ng-click="$ctrl.onClose()">\n <span class="pficon pficon-close"></span>\n </a>\n</div>\n'), $templateCache.put("src/components/toast-notifications/toast-notifications.html", '<div class="toast-notifications-list-pf">\n <div ng-repeat="(notificationID, notification) in notifications track by (notificationID + (notification.message || notification.details))" ng-if="!notification.hidden || notification.isHover"\n ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)">\n <div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{\'alert-dismissable\': !hideCloseButton}">\n <button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)">\n <span class="pficon pficon-close" aria-hidden="true"></span>\n <span class="sr-only">Close</span>\n </button>\n <span class="{{notification.type | alertIcon}}" aria-hidden="true"></span>\n <span class="sr-only">{{notification.type}}</span>\n <span class="toast-notification-message" ng-if="notification.message">{{notification.message}}</span>\n <div ng-if="notification.details" class="toast-notification-details">\n <truncate-long-text\n limit="200"\n content="notification.details"\n use-word-boundary="true"\n expandable="true"\n hide-collapse="true">\n </truncate-long-text>\n </div>\n <span ng-repeat="link in notification.links">\n <a ng-if="!link.href" href="" ng-click="onClick(notification, link)" role="button">{{link.label}}</a>\n <a ng-if="link.href" ng-href="{{link.href}}" ng-attr-target="{{link.target}}">{{link.label}}</a>\n <span ng-if="!$last" class="toast-action-divider">|</span>\n </span>\n </div>\n </div>\n</div>\n'),
$templateCache.put("src/components/truncate-long-text/truncateLongText.html", '<!--\n Do not remove class `truncated-content` (here or below) even though it\'s not\n styled directly in origin-web-common. `truncated-content` is used by\n origin-web-console in certain contexts.\n-->\n<span ng-if="!truncated" ng-bind-html="content | highlightKeywords : keywords" class="truncated-content"></span>\n<span ng-if="truncated">\n <span ng-if="!toggles.expanded">\n <span ng-attr-title="{{content}}" class="truncation-block">\n <span ng-bind-html="truncatedContent | highlightKeywords : keywords" class="truncated-content"></span>&hellip;\n </span>\n <a ng-if="expandable" href="" ng-click="toggles.expanded = true" class="nowrap">See All</a>\n </span>\n <span ng-if="toggles.expanded">\n <div ng-if="prettifyJson" class="well">\n <span ng-if="!hideCollapse" class="pull-right" style="margin-top: -10px;"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>\n <span ng-bind-html="content | prettifyJSON | highlightKeywords : keywords" class="pretty-json truncated-content"></span>\n </div>\n <span ng-if="!prettifyJson">\n <span ng-if="!hideCollapse" class="pull-right"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>\n <span ng-bind-html="content | highlightKeywords : keywords" class="truncated-content"></span>\n </span>\n </span>\n</span>\n'); $templateCache.put("src/components/truncate-long-text/truncateLongText.html", '<!--\n Do not remove class `truncated-content` (here or below) even though it\'s not\n styled directly in origin-web-common. `truncated-content` is used by\n origin-web-console in certain contexts.\n-->\n<span ng-if="!truncated" ng-bind-html="content | highlightKeywords : keywords" class="truncated-content"></span>\n<span ng-if="truncated">\n <span ng-if="!toggles.expanded">\n <span ng-attr-title="{{content}}" class="truncation-block">\n <span ng-bind-html="truncatedContent | highlightKeywords : keywords" class="truncated-content"></span>&hellip;\n </span>\n <a ng-if="expandable" href="" ng-click="toggles.expanded = true" class="nowrap">See All</a>\n </span>\n <span ng-if="toggles.expanded">\n <div ng-if="prettifyJson" class="well">\n <span ng-if="!hideCollapse" class="pull-right" style="margin-top: -10px;"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>\n <span ng-bind-html="content | prettifyJSON | highlightKeywords : keywords" class="pretty-json truncated-content"></span>\n </div>\n <span ng-if="!prettifyJson">\n <span ng-if="!hideCollapse" class="pull-right"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>\n <span ng-bind-html="content | highlightKeywords : keywords" class="truncated-content"></span>\n </span>\n </span>\n</span>\n');
} ]), angular.module("openshiftCommonUI").component("bindApplicationForm", { } ]), angular.module("openshiftCommonUI").component("bindApplicationForm", {
...@@ -163,13 +163,15 @@ onCancel:"&?", ...@@ -163,13 +163,15 @@ onCancel:"&?",
isDialog:"@" isDialog:"@"
}, },
templateUrl:"src/components/create-project/createProject.html", templateUrl:"src/components/create-project/createProject.html",
controller:[ "$scope", "$location", "ProjectsService", "NotificationsService", "displayNameFilter", function($scope, $location, ProjectsService, NotificationsService, displayNameFilter) { controller:[ "$scope", "$location", "ProjectsService", "NotificationsService", "displayNameFilter", "Logger", function($scope, $location, ProjectsService, NotificationsService, displayNameFilter, Logger) {
$scope.submitButtonLabel || ($scope.submitButtonLabel = "Create"), $scope.isDialog = "true" === $scope.isDialog; $scope.submitButtonLabel || ($scope.submitButtonLabel = "Create"), $scope.isDialog = "true" === $scope.isDialog;
var hideErrorNotifications = function() { var hideErrorNotifications = function() {
NotificationsService.hideNotification("create-project-error"); NotificationsService.hideNotification("create-project-error");
}; };
$scope.createProject = function() { $scope.createProject = function() {
$scope.disableInputs = !0, $scope.createProjectForm.$valid && ProjectsService.create($scope.name, $scope.displayName, $scope.description).then(function(project) { if ($scope.disableInputs = !0, $scope.createProjectForm.$valid) {
var displayName = $scope.displayName || $scope.name;
ProjectsService.create($scope.name, $scope.displayName, $scope.description).then(function(project) {
var cb = $scope.redirectAction(); var cb = $scope.redirectAction();
cb ? cb(encodeURIComponent(project.metadata.name)) :$location.path("project/" + encodeURIComponent(project.metadata.name) + "/create"), NotificationsService.addNotification({ cb ? cb(encodeURIComponent(project.metadata.name)) :$location.path("project/" + encodeURIComponent(project.metadata.name) + "/create"), NotificationsService.addNotification({
type:"success", type:"success",
...@@ -179,14 +181,14 @@ message:"Project '" + displayNameFilter(project) + "' was successfully created." ...@@ -179,14 +181,14 @@ message:"Project '" + displayNameFilter(project) + "' was successfully created."
$scope.disableInputs = !1; $scope.disableInputs = !1;
var data = result.data || {}; var data = result.data || {};
if ("AlreadyExists" === data.reason) $scope.nameTaken = !0; else { if ("AlreadyExists" === data.reason) $scope.nameTaken = !0; else {
var msg = data.message || "An error occurred creating the project."; var msg = data.message || "An error occurred creating project '" + displayName + "'.";
NotificationsService.addNotification({ NotificationsService.addNotification({
id:"create-project-error",
type:"error", type:"error",
message:msg message:msg
}); }), Logger.error("Project '" + displayName + "' could not be created.", result);
} }
}); });
}
}, $scope.cancelCreateProject = function() { }, $scope.cancelCreateProject = function() {
if ($scope.onCancel) { if ($scope.onCancel) {
var cb = $scope.onCancel(); var cb = $scope.onCancel();
...@@ -214,9 +216,7 @@ return angular.isDefined(attr.buttonOnly) ? "src/components/delete-project/delet ...@@ -214,9 +216,7 @@ return angular.isDefined(attr.buttonOnly) ? "src/components/delete-project/delet
}, },
replace:!0, replace:!0,
link:function(scope, element, attrs) { link:function(scope, element, attrs) {
var showAlert = function(alert) { var navigateToList = function() {
NotificationsService.addNotification(alert.data);
}, navigateToList = function() {
if (!scope.stayOnCurrentPage) { if (!scope.stayOnCurrentPage) {
if (scope.redirectUrl) return void $location.url(scope.redirectUrl); if (scope.redirectUrl) return void $location.url(scope.redirectUrl);
if ("/" === $location.path()) return void scope.$emit("deleteProject"); if ("/" === $location.path()) return void scope.$emit("deleteProject");
...@@ -233,24 +233,20 @@ controller:"DeleteProjectModalController", ...@@ -233,24 +233,20 @@ controller:"DeleteProjectModalController",
scope:scope scope:scope
}); });
modalInstance.result.then(function() { modalInstance.result.then(function() {
var projectName = scope.projectName, formattedResource = "Project '" + scope.displayName + "'", context = {}; var projectName = scope.projectName, formattedResource = "Project '" + (scope.displayName || projectName) + "'", context = {};
DataService["delete"]({ DataService["delete"]({
resource:APIService.kindToResource("Project") resource:APIService.kindToResource("Project")
}, projectName, context).then(function() { }, projectName, context).then(function() {
showAlert({ NotificationsService.addNotification({
name:projectName,
data:{
type:"success", type:"success",
message:formattedResource + " was marked for deletion." message:formattedResource + " was marked for deletion."
}
}), scope.success && scope.success(), navigateToList(); }), scope.success && scope.success(), navigateToList();
})["catch"](function(err) { })["catch"](function(err) {
var alert = { NotificationsService.addNotification({
type:"error", type:"error",
message:formattedResource + " could not be deleted.", message:formattedResource + " could not be deleted.",
details:$filter("getErrorDetails")(err) details:$filter("getErrorDetails")(err)
}; }), Logger.error(formattedResource + " could not be deleted.", err);
NotificationsService.addNotification(alert), Logger.error(formattedResource + " could not be deleted.", err);
}); });
}); });
} }
...@@ -268,14 +264,13 @@ return { ...@@ -268,14 +264,13 @@ return {
restrict:"E", restrict:"E",
scope:{ scope:{
project:"=", project:"=",
alerts:"=",
submitButtonLabel:"@", submitButtonLabel:"@",
redirectAction:"&", redirectAction:"&",
onCancel:"&", onCancel:"&",
isDialog:"@" isDialog:"@"
}, },
templateUrl:"src/components/edit-project/editProject.html", templateUrl:"src/components/edit-project/editProject.html",
controller:[ "$scope", "$filter", "$location", "DataService", "NotificationsService", "annotationNameFilter", "displayNameFilter", function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter) { controller:[ "$scope", "$filter", "$location", "DataService", "NotificationsService", "annotationNameFilter", "displayNameFilter", "Logger", function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter, Logger) {
$scope.submitButtonLabel || ($scope.submitButtonLabel = "Save"), $scope.isDialog = "true" === $scope.isDialog; $scope.submitButtonLabel || ($scope.submitButtonLabel = "Save"), $scope.isDialog = "true" === $scope.isDialog;
var annotation = $filter("annotation"), annotationName = $filter("annotationName"), editableFields = function(resource) { var annotation = $filter("annotation"), annotationName = $filter("annotationName"), editableFields = function(resource) {
return { return {
...@@ -290,8 +285,6 @@ var paths = [ annotationNameFilter("description"), annotationNameFilter("display ...@@ -290,8 +285,6 @@ var paths = [ annotationNameFilter("description"), annotationNameFilter("display
return _.each(paths, function(path) { return _.each(paths, function(path) {
resource.metadata.annotations[path] || delete resource.metadata.annotations[path]; resource.metadata.annotations[path] || delete resource.metadata.annotations[path];
}), resource; }), resource;
}, showAlert = function(alert) {
$scope.alerts.update = alert, NotificationsService.addNotification(alert);
}; };
$scope.editableFields = editableFields($scope.project), $scope.update = function() { $scope.editableFields = editableFields($scope.project), $scope.update = function() {
$scope.disableInputs = !0, $scope.editProjectForm.$valid && DataService.update("projects", $scope.project.metadata.name, cleanEditableAnnotations(mergeEditable($scope.project, $scope.editableFields)), { $scope.disableInputs = !0, $scope.editProjectForm.$valid && DataService.update("projects", $scope.project.metadata.name, cleanEditableAnnotations(mergeEditable($scope.project, $scope.editableFields)), {
...@@ -300,16 +293,16 @@ projectName:$scope.project.name ...@@ -300,16 +293,16 @@ projectName:$scope.project.name
errorNotification:!1 errorNotification:!1
}).then(function(project) { }).then(function(project) {
var cb = $scope.redirectAction(); var cb = $scope.redirectAction();
cb && cb(encodeURIComponent($scope.project.metadata.name)), showAlert({ cb && cb(encodeURIComponent($scope.project.metadata.name)), NotificationsService.addNotification({
type:"success", type:"success",
message:"Project '" + displayNameFilter(project) + "' was successfully updated." message:"Project '" + displayNameFilter(project) + "' was successfully updated."
}); });
}, function(result) { }, function(result) {
$scope.disableInputs = !1, $scope.editableFields = editableFields($scope.project), showAlert({ $scope.disableInputs = !1, $scope.editableFields = editableFields($scope.project), NotificationsService.addNotification({
type:"error", type:"error",
message:"An error occurred while updating the project", message:"An error occurred while updating project '" + displayNameFilter($scope.project) + "'.",
details:$filter("getErrorDetails")(result) details:$filter("getErrorDetails")(result)
}); }), Logger.error("Project '" + displayNameFilter($scope.project) + "' could not be updated.", result);
}); });
}, $scope.cancelEditProject = function() { }, $scope.cancelEditProject = function() {
var cb = $scope.onCancel(); var cb = $scope.onCancel();
......
...@@ -177,7 +177,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -177,7 +177,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"name\" class=\"required\">Name</label>\n" + " <label for=\"name\" class=\"required\">Name</label>\n" +
" <span ng-class=\"{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}\">\n" + " <span ng-class=\"{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}\">\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"name\"\n" + " name=\"name\"\n" +
" id=\"name\"\n" + " id=\"name\"\n" +
" placeholder=\"my-project\"\n" + " placeholder=\"my-project\"\n" +
...@@ -223,7 +223,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -223,7 +223,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"displayName\">Display Name</label>\n" + " <label for=\"displayName\">Display Name</label>\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"displayName\"\n" + " name=\"displayName\"\n" +
" id=\"displayName\"\n" + " id=\"displayName\"\n" +
" placeholder=\"My Project\"\n" + " placeholder=\"My Project\"\n" +
...@@ -233,7 +233,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -233,7 +233,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"description\">Description</label>\n" + " <label for=\"description\">Description</label>\n" +
" <textarea class=\"form-control input-lg\"\n" + " <textarea class=\"form-control\"\n" +
" name=\"description\"\n" + " name=\"description\"\n" +
" id=\"description\"\n" + " id=\"description\"\n" +
" placeholder=\"A short description.\"\n" + " placeholder=\"A short description.\"\n" +
...@@ -242,7 +242,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -242,7 +242,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
"\n" + "\n" +
" <div class=\"button-group\">\n" + " <div class=\"button-group\">\n" +
" <button type=\"submit\"\n" + " <button type=\"submit\"\n" +
" class=\"btn btn-primary btn-lg\"\n" + " class=\"btn btn-primary\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"createProject()\"\n" + " ng-click=\"createProject()\"\n" +
" ng-disabled=\"createProjectForm.$invalid || nameTaken || disableInputs\"\n" + " ng-disabled=\"createProjectForm.$invalid || nameTaken || disableInputs\"\n" +
...@@ -250,7 +250,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -250,7 +250,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" Create\n" + " Create\n" +
" </button>\n" + " </button>\n" +
" <button\n" + " <button\n" +
" class=\"btn btn-default btn-lg\"\n" + " class=\"btn btn-default\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"cancelCreateProject()\">\n" + " ng-click=\"cancelCreateProject()\">\n" +
" Cancel\n" + " Cancel\n" +
...@@ -328,7 +328,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -328,7 +328,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <fieldset ng-disabled=\"disableInputs\">\n" + " <fieldset ng-disabled=\"disableInputs\">\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"displayName\">Display Name</label>\n" + " <label for=\"displayName\">Display Name</label>\n" +
" <input class=\"form-control input-lg\"\n" + " <input class=\"form-control\"\n" +
" name=\"displayName\"\n" + " name=\"displayName\"\n" +
" id=\"displayName\"\n" + " id=\"displayName\"\n" +
" placeholder=\"My Project\"\n" + " placeholder=\"My Project\"\n" +
...@@ -338,7 +338,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -338,7 +338,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
"\n" + "\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label for=\"description\">Description</label>\n" + " <label for=\"description\">Description</label>\n" +
" <textarea class=\"form-control input-lg\"\n" + " <textarea class=\"form-control\"\n" +
" name=\"description\"\n" + " name=\"description\"\n" +
" id=\"description\"\n" + " id=\"description\"\n" +
" placeholder=\"A short description.\"\n" + " placeholder=\"A short description.\"\n" +
...@@ -347,13 +347,13 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -347,13 +347,13 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
"\n" + "\n" +
" <div class=\"button-group\">\n" + " <div class=\"button-group\">\n" +
" <button type=\"submit\"\n" + " <button type=\"submit\"\n" +
" class=\"btn btn-primary btn-lg\"\n" + " class=\"btn btn-primary\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"update()\"\n" + " ng-click=\"update()\"\n" +
" ng-disabled=\"editProjectForm.$invalid || disableInputs\"\n" + " ng-disabled=\"editProjectForm.$invalid || disableInputs\"\n" +
" value=\"\">{{submitButtonLabel}}</button>\n" + " value=\"\">{{submitButtonLabel}}</button>\n" +
" <button\n" + " <button\n" +
" class=\"btn btn-default btn-lg\"\n" + " class=\"btn btn-default\"\n" +
" ng-class=\"{'dialog-btn': isDialog}\"\n" + " ng-class=\"{'dialog-btn': isDialog}\"\n" +
" ng-click=\"cancelEditProject()\">\n" + " ng-click=\"cancelEditProject()\">\n" +
" Cancel\n" + " Cancel\n" +
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="form-group"> <div class="form-group">
<label for="name" class="required">Name</label> <label for="name" class="required">Name</label>
<span ng-class="{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}"> <span ng-class="{'has-error': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}">
<input class="form-control input-lg" <input class="form-control"
name="name" name="name"
id="name" id="name"
placeholder="my-project" placeholder="my-project"
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<div class="form-group"> <div class="form-group">
<label for="displayName">Display Name</label> <label for="displayName">Display Name</label>
<input class="form-control input-lg" <input class="form-control"
name="displayName" name="displayName"
id="displayName" id="displayName"
placeholder="My Project" placeholder="My Project"
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<div class="form-group"> <div class="form-group">
<label for="description">Description</label> <label for="description">Description</label>
<textarea class="form-control input-lg" <textarea class="form-control"
name="description" name="description"
id="description" id="description"
placeholder="A short description." placeholder="A short description."
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<div class="button-group"> <div class="button-group">
<button type="submit" <button type="submit"
class="btn btn-primary btn-lg" class="btn btn-primary"
ng-class="{'dialog-btn': isDialog}" ng-class="{'dialog-btn': isDialog}"
ng-click="createProject()" ng-click="createProject()"
ng-disabled="createProjectForm.$invalid || nameTaken || disableInputs" ng-disabled="createProjectForm.$invalid || nameTaken || disableInputs"
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
Create Create
</button> </button>
<button <button
class="btn btn-default btn-lg" class="btn btn-default"
ng-class="{'dialog-btn': isDialog}" ng-class="{'dialog-btn': isDialog}"
ng-click="cancelCreateProject()"> ng-click="cancelCreateProject()">
Cancel Cancel
......
...@@ -11,7 +11,7 @@ angular.module("openshiftCommonUI") ...@@ -11,7 +11,7 @@ angular.module("openshiftCommonUI")
isDialog: '@' isDialog: '@'
}, },
templateUrl: 'src/components/create-project/createProject.html', templateUrl: 'src/components/create-project/createProject.html',
controller: function($scope, $location, ProjectsService, NotificationsService, displayNameFilter) { controller: function($scope, $location, ProjectsService, NotificationsService, displayNameFilter, Logger) {
if(!($scope.submitButtonLabel)) { if(!($scope.submitButtonLabel)) {
$scope.submitButtonLabel = 'Create'; $scope.submitButtonLabel = 'Create';
} }
...@@ -25,6 +25,8 @@ angular.module("openshiftCommonUI") ...@@ -25,6 +25,8 @@ angular.module("openshiftCommonUI")
$scope.createProject = function() { $scope.createProject = function() {
$scope.disableInputs = true; $scope.disableInputs = true;
if ($scope.createProjectForm.$valid) { if ($scope.createProjectForm.$valid) {
var displayName = $scope.displayName || $scope.name;
ProjectsService.create($scope.name, $scope.displayName, $scope.description) ProjectsService.create($scope.name, $scope.displayName, $scope.description)
.then(function(project) { .then(function(project) {
// angular is actually wrapping the redirect action // angular is actually wrapping the redirect action
...@@ -44,12 +46,12 @@ angular.module("openshiftCommonUI") ...@@ -44,12 +46,12 @@ angular.module("openshiftCommonUI")
if (data.reason === 'AlreadyExists') { if (data.reason === 'AlreadyExists') {
$scope.nameTaken = true; $scope.nameTaken = true;
} else { } else {
var msg = data.message || 'An error occurred creating the project.'; var msg = data.message || "An error occurred creating project \'" + displayName + "\'.";
NotificationsService.addNotification({ NotificationsService.addNotification({
id: 'create-project-error',
type: 'error', type: 'error',
message: msg message: msg
}); });
Logger.error("Project \'" + displayName + "\' could not be created.", result);
} }
}); });
} }
......
...@@ -34,10 +34,6 @@ angular.module("openshiftCommonUI") ...@@ -34,10 +34,6 @@ angular.module("openshiftCommonUI")
// Replace so ".dropdown-menu > li > a" styles are applied. // Replace so ".dropdown-menu > li > a" styles are applied.
replace: true, replace: true,
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
var showAlert = function(alert) {
NotificationsService.addNotification(alert.data);
};
var navigateToList = function() { var navigateToList = function() {
if (scope.stayOnCurrentPage) { if (scope.stayOnCurrentPage) {
return; return;
...@@ -73,19 +69,16 @@ angular.module("openshiftCommonUI") ...@@ -73,19 +69,16 @@ angular.module("openshiftCommonUI")
modalInstance.result.then(function() { modalInstance.result.then(function() {
// upon clicking delete button, delete resource and send alert // upon clicking delete button, delete resource and send alert
var projectName = scope.projectName; var projectName = scope.projectName;
var formattedResource = "Project \'" + scope.displayName + "\'"; var formattedResource = "Project \'" + (scope.displayName || projectName) + "\'";
var context = {}; var context = {};
DataService.delete({ DataService.delete({
resource: APIService.kindToResource("Project") resource: APIService.kindToResource("Project")
}, projectName, context) }, projectName, context)
.then(function() { .then(function() {
showAlert({ NotificationsService.addNotification({
name: projectName, type: "success",
data: { message: formattedResource + " was marked for deletion."
type: "success",
message: formattedResource + " was marked for deletion."
}
}); });
if (scope.success) { if (scope.success) {
...@@ -96,12 +89,11 @@ angular.module("openshiftCommonUI") ...@@ -96,12 +89,11 @@ angular.module("openshiftCommonUI")
}) })
.catch(function(err) { .catch(function(err) {
// called if failure to delete // called if failure to delete
var alert = { NotificationsService.addNotification({
type: "error", type: "error",
message: formattedResource + " could not be deleted.", message: formattedResource + " could not be deleted.",
details: $filter('getErrorDetails')(err) details: $filter('getErrorDetails')(err)
}; });
NotificationsService.addNotification(alert);
Logger.error(formattedResource + " could not be deleted.", err); Logger.error(formattedResource + " could not be deleted.", err);
}); });
}); });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<fieldset ng-disabled="disableInputs"> <fieldset ng-disabled="disableInputs">
<div class="form-group"> <div class="form-group">
<label for="displayName">Display Name</label> <label for="displayName">Display Name</label>
<input class="form-control input-lg" <input class="form-control"
name="displayName" name="displayName"
id="displayName" id="displayName"
placeholder="My Project" placeholder="My Project"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<div class="form-group"> <div class="form-group">
<label for="description">Description</label> <label for="description">Description</label>
<textarea class="form-control input-lg" <textarea class="form-control"
name="description" name="description"
id="description" id="description"
placeholder="A short description." placeholder="A short description."
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
<div class="button-group"> <div class="button-group">
<button type="submit" <button type="submit"
class="btn btn-primary btn-lg" class="btn btn-primary"
ng-class="{'dialog-btn': isDialog}" ng-class="{'dialog-btn': isDialog}"
ng-click="update()" ng-click="update()"
ng-disabled="editProjectForm.$invalid || disableInputs" ng-disabled="editProjectForm.$invalid || disableInputs"
value="">{{submitButtonLabel}}</button> value="">{{submitButtonLabel}}</button>
<button <button
class="btn btn-default btn-lg" class="btn btn-default"
ng-class="{'dialog-btn': isDialog}" ng-class="{'dialog-btn': isDialog}"
ng-click="cancelEditProject()"> ng-click="cancelEditProject()">
Cancel Cancel
......
...@@ -7,14 +7,13 @@ angular.module("openshiftCommonUI") ...@@ -7,14 +7,13 @@ angular.module("openshiftCommonUI")
restrict: 'E', restrict: 'E',
scope: { scope: {
project: '=', project: '=',
alerts: '=',
submitButtonLabel: '@', submitButtonLabel: '@',
redirectAction: '&', redirectAction: '&',
onCancel: '&', onCancel: '&',
isDialog: '@' isDialog: '@'
}, },
templateUrl: 'src/components/edit-project/editProject.html', templateUrl: 'src/components/edit-project/editProject.html',
controller: function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter) { controller: function($scope, $filter, $location, DataService, NotificationsService, annotationNameFilter, displayNameFilter, Logger) {
if(!($scope.submitButtonLabel)) { if(!($scope.submitButtonLabel)) {
$scope.submitButtonLabel = 'Save'; $scope.submitButtonLabel = 'Save';
} }
...@@ -51,11 +50,6 @@ angular.module("openshiftCommonUI") ...@@ -51,11 +50,6 @@ angular.module("openshiftCommonUI")
return resource; return resource;
}; };
var showAlert = function(alert) {
$scope.alerts["update"] = alert;
NotificationsService.addNotification(alert);
};
$scope.editableFields = editableFields($scope.project); $scope.editableFields = editableFields($scope.project);
$scope.update = function() { $scope.update = function() {
...@@ -75,18 +69,19 @@ angular.module("openshiftCommonUI") ...@@ -75,18 +69,19 @@ angular.module("openshiftCommonUI")
cb(encodeURIComponent($scope.project.metadata.name)); cb(encodeURIComponent($scope.project.metadata.name));
} }
showAlert({ NotificationsService.addNotification({
type: "success", type: 'success',
message: "Project \'" + displayNameFilter(project) + "\' was successfully updated." message: "Project \'" + displayNameFilter(project) + "\' was successfully updated."
}); });
}, function(result) { }, function(result) {
$scope.disableInputs = false; $scope.disableInputs = false;
$scope.editableFields = editableFields($scope.project); $scope.editableFields = editableFields($scope.project);
showAlert({ NotificationsService.addNotification({
type: "error", type: 'error',
message: "An error occurred while updating the project", message: "An error occurred while updating project \'" + displayNameFilter($scope.project) + "\'." ,
details: $filter('getErrorDetails')(result) details: $filter('getErrorDetails')(result)
}); });
Logger.error("Project \'" + displayNameFilter($scope.project) + "\' could not be updated.", result);
}); });
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment