mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
bug fixes and cosmetic improvements
This commit is contained in:
committed by
Aiden McClelland
parent
aef1569e56
commit
be5952cb67
@@ -64,17 +64,17 @@
|
||||
<p>No config options for {{ pkg.manifest.title }} {{ pkg.manifest.version }}.</p>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ng-container>
|
||||
|
||||
<!-- has config -->
|
||||
<form [formGroup]="configForm" (ngSubmit)="save()" novalidate>
|
||||
<form-object
|
||||
[objectSpec]="configSpec"
|
||||
[formGroup]="configForm"
|
||||
[current]="current"
|
||||
showEdited
|
||||
></form-object>
|
||||
</form>
|
||||
<!-- has config -->
|
||||
<form [formGroup]="configForm" (ngSubmit)="save(pkg)" novalidate>
|
||||
<form-object
|
||||
[objectSpec]="configSpec"
|
||||
[formGroup]="configForm"
|
||||
[current]="current"
|
||||
[showEdited]="true"
|
||||
></form-object>
|
||||
</form>
|
||||
</ng-container>
|
||||
</ng-template>
|
||||
</ion-content>
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ export class AppRestoreComponent {
|
||||
@Input() pkgId: string
|
||||
disks: DiskInfo
|
||||
loading = true
|
||||
submitting = false
|
||||
allPartitionsMounted: boolean
|
||||
modal: HTMLIonModalElement
|
||||
|
||||
@@ -73,10 +74,17 @@ export class AppRestoreComponent {
|
||||
}
|
||||
|
||||
private async restore (logicalname: string, password: string): Promise<void> {
|
||||
await this.embassyApi.restorePackage({
|
||||
id: this.pkgId,
|
||||
logicalname,
|
||||
password,
|
||||
})
|
||||
this.submitting = true
|
||||
try {
|
||||
await this.embassyApi.restorePackage({
|
||||
id: this.pkgId,
|
||||
logicalname,
|
||||
password,
|
||||
})
|
||||
} catch (e) {
|
||||
this.errToast.present(e)
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { IonicSafeString, LoadingController, ModalController } from '@ionic/angular'
|
||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||
import { ErrorToastService, getErrorMessage } from 'src/app/services/error-toast.service'
|
||||
import { getErrorMessage } from 'src/app/services/error-toast.service'
|
||||
|
||||
@Component({
|
||||
selector: 'backup-confirmation',
|
||||
|
||||
@@ -10,18 +10,19 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding">
|
||||
<form [formGroup]="formGroup" (ngSubmit)="save()" novalidate>
|
||||
<form [formGroup]="formGroup" (ngSubmit)="handleClick(submitBtn.handler)" novalidate>
|
||||
<form-object
|
||||
[objectSpec]="spec"
|
||||
[formGroup]="formGroup"
|
||||
></form-object>
|
||||
<button hidden type="submit"></button>
|
||||
</form>
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="end" class="ion-padding-end">
|
||||
<ion-button *ngFor="let button of buttons" fill="outline" (click)="handleClick(button)">
|
||||
<ion-toolbar class="footer">
|
||||
<ion-buttons slot="end">
|
||||
<ion-button class="ion-padding-end" *ngFor="let button of buttons" (click)="handleClick(button.handler)">
|
||||
{{ button.text }}
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ConfigSpec } from 'src/app/pkg-config/config-types'
|
||||
export interface ActionButton {
|
||||
text: string
|
||||
handler: (value: any) => Promise<boolean>
|
||||
isSubmit?: boolean
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -18,6 +19,7 @@ export class GenericFormPage {
|
||||
@Input() title: string
|
||||
@Input() spec: ConfigSpec
|
||||
@Input() buttons: ActionButton[]
|
||||
submitBtn: ActionButton
|
||||
formGroup: FormGroup
|
||||
|
||||
constructor (
|
||||
@@ -27,20 +29,25 @@ export class GenericFormPage {
|
||||
|
||||
ngOnInit () {
|
||||
this.formGroup = this.formService.createForm(this.spec)
|
||||
this.submitBtn = this.buttons.find(btn => btn.isSubmit) || {
|
||||
text: '',
|
||||
handler: () => Promise.resolve(true),
|
||||
}
|
||||
console.log(this.submitBtn)
|
||||
}
|
||||
|
||||
async dismiss (): Promise<void> {
|
||||
this.modalCtrl.dismiss()
|
||||
}
|
||||
|
||||
async handleClick (button: ActionButton): Promise<void> {
|
||||
async handleClick (handler: ActionButton['handler']): Promise<void> {
|
||||
if (this.formGroup.invalid) {
|
||||
this.formGroup.markAllAsTouched()
|
||||
document.getElementsByClassName('validation-error')[0].parentElement.parentElement.scrollIntoView({ behavior: 'smooth' })
|
||||
return
|
||||
}
|
||||
|
||||
const success = await button.handler(this.formGroup.value)
|
||||
const success = await handler(this.formGroup.value)
|
||||
if (success !== false) this.modalCtrl.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user