mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
fix form display for services with no config
This commit is contained in:
committed by
Aiden McClelland
parent
c5585f7f35
commit
946d4c6c1d
@@ -6,7 +6,7 @@
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Config</ion-title>
|
||||
<ion-buttons slot="end" class="ion-padding-end">
|
||||
<ion-buttons *ngIf="hasConfig" slot="end" class="ion-padding-end">
|
||||
<ion-button fill="clear" [disabled]="loadingText" (click)="resetDefaults()">
|
||||
<ion-icon slot="start" name="refresh"></ion-icon>
|
||||
Reset Defaults
|
||||
@@ -24,7 +24,7 @@
|
||||
<ng-template #loaded>
|
||||
|
||||
<ng-container *ngIf="patch.data['package-data'][pkgId] as pkg">
|
||||
<ion-item>
|
||||
<ion-item *ngIf="hasConfig && !pkg.installed.status.configured && !configForm.dirty">
|
||||
<ion-label>
|
||||
<ion-text color="success">To use the default config for {{ pkg.manifest.title }}, click "Save" below.</ion-text>
|
||||
</ion-label>
|
||||
@@ -66,7 +66,7 @@
|
||||
</ion-item>
|
||||
|
||||
<!-- has config -->
|
||||
<form [formGroup]="configForm" (ngSubmit)="save(pkg)" novalidate>
|
||||
<form *ngIf="hasConfig" [formGroup]="configForm" (ngSubmit)="save(pkg)" novalidate>
|
||||
<form-object
|
||||
[objectSpec]="configSpec"
|
||||
[formGroup]="configForm"
|
||||
@@ -81,9 +81,12 @@
|
||||
<ion-footer>
|
||||
<ion-toolbar *ngIf="patch.data['package-data'][pkgId] as pkg">
|
||||
<ion-buttons slot="end" class="ion-padding-end">
|
||||
<ion-button fill="outline" [disabled]="saving" (click)="save(pkg)" class="enter-click" [class.no-click]="saving">
|
||||
<ion-button *ngIf="hasConfig" fill="outline" [disabled]="saving" (click)="save(pkg)" class="enter-click" [class.no-click]="saving">
|
||||
Save
|
||||
</ion-button>
|
||||
<ion-button *ngIf="!loadingText && !hasConfig" fill="outline" (click)="dismiss()" class="enter-click">
|
||||
Close
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
|
||||
@@ -72,18 +72,18 @@ export class AppConfigPage {
|
||||
this.configForm.markAllAsTouched()
|
||||
|
||||
if (depConfig) {
|
||||
this.markDirtyRecursive(this.configForm, depConfig)
|
||||
this.alterConfigRecursive(this.configForm, depConfig)
|
||||
}
|
||||
}
|
||||
|
||||
markDirtyRecursive (group: FormGroup, config: object) {
|
||||
alterConfigRecursive (group: FormGroup, config: object) {
|
||||
Object.keys(config).forEach(key => {
|
||||
const next = group.get(key)
|
||||
if (!next) throw new Error('Dependency config not compatible with service version. Please contact support')
|
||||
const newVal = config[key]
|
||||
// check if val is an object
|
||||
if (newVal && typeof newVal === 'object' && !Array.isArray(newVal)) {
|
||||
this.markDirtyRecursive(next as FormGroup, newVal)
|
||||
this.alterConfigRecursive(next as FormGroup, newVal)
|
||||
} else {
|
||||
let val1 = group.get(key).value
|
||||
let val2 = config[key]
|
||||
@@ -98,7 +98,7 @@ export class AppConfigPage {
|
||||
|
||||
resetDefaults () {
|
||||
this.configForm = this.formService.createForm(this.configSpec)
|
||||
this.markDirtyRecursive(this.configForm, this.current)
|
||||
this.alterConfigRecursive(this.configForm, this.current)
|
||||
}
|
||||
|
||||
dismissRec () {
|
||||
|
||||
Reference in New Issue
Block a user