Handle additional directories for Docker

This commit is contained in:
grossmj 2023-02-01 13:06:03 +08:00
parent a8aef0729d
commit fac07ceeb4
2 changed files with 17 additions and 1 deletions

View File

@ -110,7 +110,7 @@
<h6>Additional volumes</h6>
<mat-form-field class="form-field">
<textarea matInput type="text" [(ngModel)]="node.properties.extra_volumes"></textarea>
<textarea matInput type="text" [(ngModel)]="additionalDirectories"></textarea>
</mat-form-field>
</mat-tab>

View File

@ -55,9 +55,16 @@ export class ConfiguratorDialogDockerComponent implements OnInit {
this.name = node.name;
this.getConfiguration();
if (!this.node.properties.cpus) this.node.properties.cpus = 0.0;
if (this.node.properties.extra_volumes && this.node.properties.extra_volumes.length>0) {
for (let index = 0; index < this.node.properties.extra_volumes.length - 1; index++) {
this.additionalDirectories = this.additionalDirectories + this.node.properties.extra_volumes[index] + "\n";
}
this.additionalDirectories = this.additionalDirectories + this.node.properties.extra_volumes[this.node.properties.extra_volumes.length - 1];
}
});
}
getConfiguration() {
this.consoleTypes = this.dockerConfigurationService.getConsoleTypes();
}
@ -77,7 +84,16 @@ export class ConfiguratorDialogDockerComponent implements OnInit {
}
onSaveClick() {
var extraVolumes = this.additionalDirectories.split("\n").filter(elem => elem != "");
for (const item of extraVolumes) {
console.log(item);
if (!item.startsWith("/")) {
this.toasterService.error(`Wrong format for additional directories.`);
return;
}
}
if (this.generalSettingsForm.valid) {
this.node.properties.extra_volumes = extraVolumes;
this.nodeService.updateNode(this.controller, this.node).subscribe(() => {
this.toasterService.success(`Node ${this.node.name} updated.`);
this.onCancelClick();