Skip to content

Commit

Permalink
UI validation (#11)
Browse files Browse the repository at this point in the history
* implement multiple UI validation
* fix npm dependency
  • Loading branch information
tuxtof authored Jul 22, 2022
1 parent 3a2bdd6 commit 0c5b051
Show file tree
Hide file tree
Showing 4 changed files with 6,443 additions and 6,115 deletions.
28 changes: 28 additions & 0 deletions component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,44 @@ export default Ember.Component.extend(NodeDriver, {

// Add more specific errors

// Check Account info
if ( !get(this, 'config.endpoint') ) {
errors.push('Management Endpoint is required');
}
if ( !get(this, 'config.username') ) {
errors.push('Username is required');
}
if ( !get(this, 'config.password') ) {
errors.push('Password is required');
}
if ( !get(this, 'config.cluster') ) {
errors.push('Cluster is required');
}

// Check something and add an error entry if it fails:
if ( parseInt(get(this, 'config.vmMem'), defaultRadix) < defaultBase ) {
errors.push('Memory Size must be at least 1024 MB');
}

// Check template image
if ( !get(this, 'config.vmImage') ) {
errors.push('Template image is required');
}

// Check network interface
if ( get(this, 'config.vmNetwork').length === 0 ) {
errors.push('Network interface is required');
}

// Check storageContainer is a UUID
if ( get(this, 'config.storageContainer') && !/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/i.test(get(this, 'config.storageContainer')) ) {
errors.push('Storage Container must be a valid UUID');
}

if ( parseInt(get(this, 'config.diskSize')) > 0 && get(this, 'config.storageContainer') === '' ) {
errors.push('Storage Container is required if disk size is set');
}

// Set the array of errors for display,
// and return true if saving should continue.
if ( get(errors, 'length') ) {
Expand Down
22 changes: 16 additions & 6 deletions component/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

<div class="row">
<div class="col span-12">
<label class="acc-label">Management Endpoint</label>
<label class="acc-label">Management Endpoint
<span class="field-required ember-view">*</span>
</label>
{{input type="text"
class="form-control"
value=model.%%DRIVERNAME%%Config.endpoint
Expand All @@ -28,7 +30,9 @@

<div class="row">
<div class="col span-6">
<label class="acc-label">Username</label>
<label class="acc-label">Username
<span class="field-required ember-view">*</span>
</label>
{{input
type="text"
class="form-control"
Expand All @@ -37,7 +41,9 @@
<p class="help-block">Nutanix management username</p>
</div>
<div class="col span-6">
<label class="acc-label">Password</label>
<label class="acc-label">Password
<span class="field-required ember-view">*</span>
</label>
{{input
type="password"
class="form-control"
Expand All @@ -64,7 +70,9 @@
}}
<div class="row">
<div class="col-md-2 form-label">
<label class="acc-label">Cluster</label>
<label class="acc-label">Cluster
<span class="field-required ember-view">*</span>
</label>
</div>
<div class="col-md-4">
{{input type="text"
Expand Down Expand Up @@ -120,7 +128,9 @@

<div class="row">
<div class="col span-6">
<label class="acc-label">Template Image</label>
<label class="acc-label">Template Image
<span class="field-required ember-view">*</span>
</label>
{{input type="text"
class="form-control"
value=model.%%DRIVERNAME%%Config.vmImage
Expand All @@ -137,7 +147,7 @@
}}
<div class="input-group-addon bg-default">GiB</div>
</div>
<p class="help-block">Size to extand the template disk. Set this to zero if you don't want to extend the template disk.</p>
<p class="help-block">Size to extend the template disk. Set this to zero if you don't want to extend it.<br>Recommended if your image is smaller than 40GB</p>
</div>
</div>

Expand Down
Loading

0 comments on commit 0c5b051

Please sign in to comment.