Skip to content

Commit

Permalink
Fix size field formatting on resize and clone pages
Browse files Browse the repository at this point in the history
  • Loading branch information
subuk committed Nov 25, 2019
1 parent ef8e3ca commit b2647f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions compute/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type Volume struct {
Metadata VolumeMetadata
}

func (v *Volume) SizeMb() uint64 {
return v.Size / 1024 / 1024
}

func (volume *Volume) Base() string {
return filepath.Base(volume.Path)
}
Expand Down
6 changes: 3 additions & 3 deletions templates/volume/clone.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h4>Clone Volume {{ .Volume.Path }}</h4>
<label>New Volume Pool</label>
<select required="required" class="form-control" name="Pool">
{{ range .Pools }}
<option value="{{ .Name }}">{{ .Name }} ({{ .FreeGB }}G free {{ .UsagePercent }}% used)</option>
<option value="{{ .Name }}">{{ .Name }} ({{ .Free | HumanizeBytes }} free {{ .UsagePercent }}% used)</option>
{{ end }}
</select>
</div>
Expand All @@ -44,8 +44,8 @@ <h4>Clone Volume {{ .Volume.Path }}</h4>
<div class="form-group row">
<div class="col-md-12">
<label>New Volume Size (megabytes)</label>
<input value="{{ .Volume.Size }}" required="required" name="Size" class="form-control" id="Size">
<small id="nameHelp" class="form-text text-muted">Volume can be resized after creation</small>
<input value="{{ .Volume.SizeMb }}" required="required" name="Size" class="form-control" id="Size">
<small id="nameHelp" class="form-text text-muted">LVM volumes cannot be resized after creation</small>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion templates/volume/resize.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4>Resize Volume {{ .Volume.Path }}</h4>
<div class="form-group row">
<div class="col-md-12">
<label>New Volume Size (megabytes)</label>
<input value="{{ .Volume.Size }}" required="required" class="form-control" name="Size" id="Name">
<input value="{{ .Volume.SizeMb }}" required="required" class="form-control" name="Size" id="Name">
<small id="nameHelp" class="form-text text-muted">Volume size can only be increased, current size is {{ .Volume.Size }}M</small>
</div>
</div>
Expand Down

0 comments on commit b2647f6

Please sign in to comment.