mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
action inputs
This commit is contained in:
committed by
Aiden McClelland
parent
15eb13e156
commit
edc37e33f1
55
ui/src/app/modals/app-action-input/app-action-input.page.ts
Normal file
55
ui/src/app/modals/app-action-input/app-action-input.page.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { LoadingController, ModalController } from '@ionic/angular'
|
||||
import { ConfigCursor } from 'src/app/pkg-config/config-cursor'
|
||||
import { ValueSpecObject } from 'src/app/pkg-config/config-types'
|
||||
import { LoaderService } from 'src/app/services/loader.service'
|
||||
import { Action } from 'src/app/services/patch-db/data-model'
|
||||
|
||||
@Component({
|
||||
selector: 'app-action-input',
|
||||
templateUrl: './app-action-input.page.html',
|
||||
styleUrls: ['./app-action-input.page.scss'],
|
||||
})
|
||||
export class AppActionInputPage {
|
||||
@Input() action: Action
|
||||
@Input() cursor: ConfigCursor<'object'>
|
||||
@Input() execute: () => Promise<void>
|
||||
spec: ValueSpecObject
|
||||
value: object
|
||||
error: string
|
||||
|
||||
constructor (
|
||||
private readonly modalCtrl: ModalController,
|
||||
private readonly loadingCtrl: LoadingController,
|
||||
private loaderService: LoaderService,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
this.spec = this.cursor.spec()
|
||||
this.value = this.cursor.config()
|
||||
this.error = this.cursor.checkInvalid()
|
||||
}
|
||||
|
||||
async dismiss (): Promise<void> {
|
||||
this.modalCtrl.dismiss()
|
||||
}
|
||||
|
||||
async save (): Promise<void> {
|
||||
this.loaderService.of({
|
||||
spinner: 'lines',
|
||||
message: 'Executing action',
|
||||
cssClass: 'loader-ontop-of-all',
|
||||
}).displayDuringAsync(async () => {
|
||||
try {
|
||||
await this.execute()
|
||||
this.modalCtrl.dismiss()
|
||||
} catch (e) {
|
||||
this.error = e.message
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
handleObjectEdit (): void {
|
||||
this.error = this.cursor.checkInvalid()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user