mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
* add registry icons, update links, clean up code (#1913) * add registry icons, update links, clean up code * remove seeding of registry icon and name * fix install wizard copy Co-authored-by: Lucy C <12953208+elvece@users.noreply.github.com> * remove references to bep and chime * fix shutdown language and remove chime from initializing screen * fix type error Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> Co-authored-by: Lucy C <12953208+elvece@users.noreply.github.com> Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
import { Component } from '@angular/core'
|
|
import { ActivatedRoute } from '@angular/router'
|
|
import { ModalController } from '@ionic/angular'
|
|
import { debounce, ErrorToastService } from '@start9labs/shared'
|
|
import * as yaml from 'js-yaml'
|
|
import { filter, take } from 'rxjs/operators'
|
|
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
|
import { PatchDB } from 'patch-db-client'
|
|
import { getProjectId } from 'src/app/util/get-project-id'
|
|
import { GenericFormPage } from '../../../modals/generic-form/generic-form.page'
|
|
import { DataModel } from 'src/app/services/patch-db/data-model'
|
|
|
|
@Component({
|
|
selector: 'dev-config',
|
|
templateUrl: 'dev-config.page.html',
|
|
styleUrls: ['dev-config.page.scss'],
|
|
})
|
|
export class DevConfigPage {
|
|
readonly projectId = getProjectId(this.route)
|
|
editorOptions = { theme: 'vs-dark', language: 'yaml' }
|
|
code: string = ''
|
|
saving: boolean = false
|
|
|
|
constructor(
|
|
private readonly route: ActivatedRoute,
|
|
private readonly errToast: ErrorToastService,
|
|
private readonly modalCtrl: ModalController,
|
|
private readonly patch: PatchDB<DataModel>,
|
|
private readonly api: ApiService,
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
this.patch
|
|
.watch$('ui', 'dev', this.projectId, 'config')
|
|
.pipe(filter(Boolean), take(1))
|
|
.subscribe(config => {
|
|
this.code = config
|
|
})
|
|
}
|
|
|
|
async preview() {
|
|
let doc: any
|
|
try {
|
|
doc = yaml.load(this.code)
|
|
} catch (e: any) {
|
|
this.errToast.present(e)
|
|
}
|
|
|
|
const modal = await this.modalCtrl.create({
|
|
component: GenericFormPage,
|
|
componentProps: {
|
|
title: 'Config Sample',
|
|
spec: JSON.parse(JSON.stringify(doc, null, 2)),
|
|
buttons: [
|
|
{
|
|
text: 'OK',
|
|
handler: () => {
|
|
return
|
|
},
|
|
isSubmit: true,
|
|
},
|
|
],
|
|
},
|
|
})
|
|
await modal.present()
|
|
}
|
|
|
|
@debounce(1000)
|
|
async save() {
|
|
this.saving = true
|
|
try {
|
|
await this.api.setDbValue<string>(
|
|
['dev', this.projectId, 'config'],
|
|
this.code,
|
|
)
|
|
} catch (e: any) {
|
|
this.errToast.present(e)
|
|
} finally {
|
|
this.saving = false
|
|
}
|
|
}
|
|
}
|