Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
TEAMFOUR-483 - Added validation to HCE Registration form (#393)
Browse files Browse the repository at this point in the history
* TEAMFOUR-483 - Added validation to HCE Registration form
  • Loading branch information
irfanhabib committed Jun 22, 2016
1 parent d337222 commit 4b4a5cc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
13 changes: 7 additions & 6 deletions src/app/view/hce-registration/hce-registration.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<div class="hce-registration">
<div class="modal-body">
<form name="hceRegistrationForm">
<div class="form-group" focusable-input
ng-class="{'has-error': addClusterFormCtrl.addClusterForm.url.$invalid && addClusterFormCtrl.addClusterForm.url.$dirty}">
ng-class="{'has-error': hceRegistrationForm.url.$invalid && hceRegistrationForm.url.$dirty}">
<label class="control-label" translate>Code Engine Endpoint</label>
<input type="text" name="url" class="form-control" ng-model="detailViewCtrl.context.data.url"
required />
required
ng-pattern="/^http(s)?://(.)+$/"
helion-unique items="detailViewCtrl.context.options.instances"
ignore-case/>
</div>
<div class="form-group" focusable-input>
<label class="control-label" translate>Code Engine Name</label>
<input type="text" class="form-control" ng-model="detailViewCtrl.context.data.name" required/>
</div>
</div>
</form>

<div class="modal-footer">
Expand All @@ -20,8 +21,8 @@
{{ 'Cancel' }}
</button>
<button class="btn btn-primary"
ng-click="$close();">
ng-disabled="hceRegistrationForm.$invalid" ng-click="$close();">
{{ 'Register' }}
</button>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
(function() {
'use strict';

angular
Expand Down Expand Up @@ -61,7 +61,7 @@
this.credentialsFormOpen = false;
this.warningMsg = gettext('Authentication failed, please try reconnect.');
this.detailView = detailView;

this.currentEndpoints = [];
// TODO(woodnt): There must be a more reproducable/general way of doing this. https://jira.hpcloud.net/browse/TEAMFOUR-626
this.cfModel = modelManager.retrieve('cloud-foundry.model.application');

Expand All @@ -78,7 +78,17 @@
});
});

this.userCnsiModel.list().then(function () {
$scope.$watchCollection(function() {
return that.serviceInstances;
}, function(newCnsis) {
that.currentEndpoints = _.map(newCnsis,
function(c) {
var endpoint = c.api_endpoint;
return endpoint.Scheme + '://' + endpoint.Host;
});
});

this.userCnsiModel.list().then(function() {
angular.extend(that.serviceInstances, that.userCnsiModel.serviceInstances);
that.cnsiModel.list();
});
Expand Down Expand Up @@ -183,6 +193,7 @@
// This code is shamelessly copied from app/view/cluster-registration/cluster-registration.directive.js
// I take that back, it was EXTREMELY SHAMEFUL.
// -- woodnt

var that = this;
var data = { name: '', url: '' };
this.detailView(
Expand All @@ -191,7 +202,10 @@
title: gettext('Register Code Engine Endpoint')
},
{
data: data
data: data,
options: {
instances: this.currentEndpoints
}
}
).result.then(function () {
return that.serviceInstanceApi.createHCE(data.url, data.name).then(function () {
Expand Down

0 comments on commit 4b4a5cc

Please sign in to comment.