Skip to content

Commit

Permalink
Remove Burst, RAW Capacity (#144)
Browse files Browse the repository at this point in the history
* Remove Burst, RAW Capacity

* Reworked environment modal

* Fix bug where environment ID is wrong

* Display dynamic vms correct
  • Loading branch information
jggoebel authored Feb 6, 2023
1 parent 8901d3f commit 58f1a65
Show file tree
Hide file tree
Showing 17 changed files with 600 additions and 499 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@
line-height: unset;
height: unset;
margin: 0 0 0 0;
}

.btn-no-margin {
margin: 0;
padding: 7px 12px;
line-height: inherit;
height: inherit;
}

.no-margin-top{
margin-top: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
dnssuffix: [edit ? this.updateEnv.dnssuffix : ''],
provider: [edit ? this.updateEnv.provider : '', [Validators.required, Validators.minLength(2)]],
ws_endpoint: [edit ? this.updateEnv.ws_endpoint : '', [Validators.required, Validators.pattern(/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/)]],
capacity_mode: [edit ? this.updateEnv.capacity_mode : '', Validators.required],
burst_capable: [edit ? this.updateEnv.burst_capable : true]
});
}

Expand Down Expand Up @@ -80,17 +78,7 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {

public buildTemplateMapping() {
this.templateMappings = this._fb.group({
templates: this._fb.array([
this._fb.group({
template: ['', Validators.required],
params: this._fb.array([
this._fb.group({
key: ['', Validators.required],
value: ['', Validators.required]
})
])
})
])
templates: this._fb.array([])
});
}

Expand All @@ -117,6 +105,7 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
for (var i = 0; i < templateKeys.length; i++) {
var newGroup = this._fb.group({
template: [templateKeys[i], Validators.required],
count: [this.updateEnv.count_capacity[templateKeys[i]], [Validators.required, Validators.pattern(/-?\d+/)]],
params: this._fb.array([])
});
var paramKeys = Object.keys(this.updateEnv.template_mapping[templateKeys[i]]);
Expand Down Expand Up @@ -160,7 +149,10 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
ngOnChanges() {
if (this.updateEnv) {
this.fixNullValues();
this.env = this.updateEnv;
this._prepare();
this.wizard.navService.goTo(this.wizard.pages.last, true);
this.wizard.pages.first.makeCurrent();
}
}

Expand Down Expand Up @@ -224,6 +216,7 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
this._build();
this.wizard.reset();
if (this.updateEnv) {
this.env = this.updateEnv;
this._prepare();
}
this.wizard.open();
Expand All @@ -234,8 +227,6 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
this.env.dnssuffix = this.environmentDetails.get('dnssuffix').value;
this.env.provider = this.environmentDetails.get('provider').value;
this.env.ws_endpoint = this.environmentDetails.get('ws_endpoint').value;
this.env.capacity_mode = this.environmentDetails.get('capacity_mode').value;
this.env.burst_capable = (this.environmentDetails.get('burst_capable').value as boolean);
}

public newIpMapping(from: string = '', to: string = '') {
Expand Down Expand Up @@ -288,12 +279,8 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
public newTemplateMapping() {
var newGroup = this._fb.group({
template: [this.templateSelection.get('vmt_select').value, Validators.required],
params: this._fb.array([
this._fb.group({
key: ['', Validators.required],
value: ['', Validators.required]
})
])
count: [0, [Validators.required, Validators.pattern(/-?\d+/)]],
params: this._fb.array([])
});
(this.templateMappings.get('templates') as FormArray).push(newGroup);
}
Expand All @@ -302,18 +289,28 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
(this.templateMappings.get('templates') as FormArray).removeAt(index);
}

public getTeplateCount(vmt: string){
if(!this.env.count_capacity){
return 0;
}
return this.env.count_capacity[vmt] ?? 0
}

public copyTemplateMapping() {
this.env.template_mapping = {};
this.env.count_capacity = {};
// naïve solution, using nested for loop. gross, but gets the job done.
for (var i = 0; i < (this.templateMappings.get('templates') as FormArray).length; i++) { // i = index of template
var template = this.templateMappings.get(['templates', i, 'template']).value;
var count = this.templateMappings.get(['templates', i, 'count']).value;
var templateMap = {};
for (var j = 0; j < (this.templateMappings.get(['templates', i, 'params']) as FormArray).length; j++) { // j = index of param
var key = this.templateMappings.get(['templates', i, 'params', j]).get('key').value;
var value = this.templateMappings.get(['templates', i, 'params', j]).get('value').value;
templateMap[key] = value;
}
this.env.template_mapping[template] = templateMap;
this.env.count_capacity[template] = count;
}
}

Expand Down Expand Up @@ -345,6 +342,7 @@ export class EditEnvironmentComponent implements OnInit, OnChanges {
this.event.next(true);
}
)
this.env = new Environment();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
<clr-stack-label>Websocket Endpoint</clr-stack-label>
<clr-stack-content>{{ currentEnvironment.ws_endpoint }}</clr-stack-content>
</clr-stack-block>
<clr-stack-block>
<clr-stack-label>Capacity Mode</clr-stack-label>
<clr-stack-content>{{ currentEnvironment.capacity_mode }}</clr-stack-content>
</clr-stack-block>
<clr-stack-block>
<clr-stack-label>Burst Capable</clr-stack-label>
<clr-stack-content>{{ currentEnvironment.burst_capable }}</clr-stack-content>
</clr-stack-block>
</clr-stack-block>
<clr-stack-block>
<clr-stack-label>Environment Specifics</clr-stack-label>
Expand All @@ -46,6 +38,7 @@
</clr-stack-content>
<clr-stack-block *ngFor="let template of currentEnvironment.template_mapping | keyvalue; let i = index" [(clrSbExpanded)]="stackBoxExpanded[i]">
<clr-stack-label>{{ template.key }}</clr-stack-label>
(Limit: {{ getLimit(template.key) }})
<clr-stack-block>
<clr-stack-label class="stackbox-header">Key</clr-stack-label>
<clr-stack-content class="stackbox-header">Value</clr-stack-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ export class EnvironmentDetailComponent implements OnInit {
isEmpty(object: Object) {
return Object.keys(object).length == 0;
}

getLimit(vmt: string){
if(!this.currentEnvironment.count_capacity){
return 0
}
return this.currentEnvironment.count_capacity[vmt] ?? 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,6 @@
formControlName="image" required />
<clr-control-error *clrIfError="'required'">Image is required</clr-control-error>
</clr-input-container>
<fieldset>
<clr-input-container>
<label>CPU</label>
<input clrInput type="number" placeholder="1" name="cpu"
formControlName="cpu" />
<clr-control-helper>Number of CPUs</clr-control-helper>
</clr-input-container>
<clr-input-container>
<label>Memory</label>
<input clrInput type="number" placeholder="1" name="memory"
formControlName="memory" />
<clr-control-helper>Memory specified in MB</clr-control-helper>
</clr-input-container>
<clr-input-container>
<label>Storage</label>
<input clrInput type="number" placeholder="1" name="storage"
formControlName="storage" />
<clr-control-helper>Storage specified in GB</clr-control-helper>
</clr-input-container>
</fieldset>
</form>
</clr-wizard-page>
<clr-wizard-page [clrWizardPageNextDisabled]="!configMap.valid">
Expand Down Expand Up @@ -106,18 +86,6 @@ <h4>Basic Information</h4>
<td>Image</td>
<td>{{ template.image }}</td>
</tr>
<tr>
<td>CPU</td>
<td>{{ template.resources?.cpu }}</td>
</tr>
<tr>
<td>Memory</td>
<td>{{ template.resources?.memory }}</td>
</tr>
<tr>
<td>Storage</td>
<td>{{ template.resources?.storage }}</td>
</tr>
</tbody>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export class EditVmtemplateComponent implements OnInit, OnChanges {
this.templateDetails = null;
this.templateDetails = this._fb.group({
name: [edit ? this.editTemplate.name : '', [Validators.required, Validators.minLength(4)]],
image: [edit ? this.editTemplate.image : '', [Validators.required]],
cpu: [ edit ? this.editTemplate.resources.cpu : 0 ],
memory: [ edit ? this.editTemplate.resources.memory : 0 ],
storage: [ edit ? this.editTemplate.resources.storage : 0 ]
image: [edit ? this.editTemplate.image : '', [Validators.required]]
})
}

Expand Down Expand Up @@ -107,10 +104,6 @@ export class EditVmtemplateComponent implements OnInit, OnChanges {
public copyTemplateDetails() {
this.template.name = this.templateDetails.get('name').value;
this.template.image = this.templateDetails.get('image').value;
this.template.resources = {cpu: 0, memory: 0, storage: 0};
this.template.resources.cpu = this.templateDetails.get('cpu').value;
this.template.resources.memory = this.templateDetails.get('memory').value;
this.template.resources.storage = this.templateDetails.get('storage').value;
}

public copyConfigMap() {
Expand Down Expand Up @@ -168,6 +161,8 @@ export class EditVmtemplateComponent implements OnInit, OnChanges {
if (this.editTemplate) {
this.fixNullValues();
this._prepare();
this.wizard.navService.goTo(this.wizard.pages.last, true);
this.wizard.pages.first.makeCurrent();
} else {
this.buildTemplateDetails();
this.buildConfigMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
<clr-stack-label>Image</clr-stack-label>
<clr-stack-content>{{ currentVmTemplate.image }}</clr-stack-content>
</clr-stack-block>
<clr-stack-block>
<clr-stack-label>CPU</clr-stack-label>
<clr-stack-content>{{ currentVmTemplate.resources.cpu }}</clr-stack-content>
</clr-stack-block>
<clr-stack-block>
<clr-stack-label>Memory</clr-stack-label>
<clr-stack-content>{{ currentVmTemplate.resources.memory }}</clr-stack-content>
</clr-stack-block>
<clr-stack-block>
<clr-stack-label>Storage</clr-stack-label>
<clr-stack-content>{{ currentVmTemplate.resources.storage }}</clr-stack-content>
</clr-stack-block>
</clr-stack-block>
<clr-stack-block *ngIf="currentVmTemplate.config_map && !isEmpty(currentVmTemplate.config_map)">
<clr-stack-label>Config Map</clr-stack-label>
Expand Down
Loading

0 comments on commit 58f1a65

Please sign in to comment.