mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +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>
61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
import { Injectable } from '@angular/core'
|
|
import { IonicSafeString, ToastController } from '@ionic/angular'
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ErrorToastService {
|
|
private toast?: HTMLIonToastElement
|
|
|
|
constructor(private readonly toastCtrl: ToastController) {}
|
|
|
|
async present(e: { message: string }, link?: string): Promise<void> {
|
|
console.error(e)
|
|
|
|
if (this.toast) return
|
|
|
|
this.toast = await this.toastCtrl.create({
|
|
header: 'Error',
|
|
message: getErrorMessage(e, link),
|
|
duration: 0,
|
|
position: 'top',
|
|
cssClass: 'error-toast',
|
|
buttons: [
|
|
{
|
|
side: 'end',
|
|
icon: 'close',
|
|
handler: () => {
|
|
this.dismiss()
|
|
},
|
|
},
|
|
],
|
|
})
|
|
await this.toast.present()
|
|
}
|
|
|
|
async dismiss(): Promise<void> {
|
|
if (this.toast) {
|
|
await this.toast.dismiss()
|
|
this.toast = undefined
|
|
}
|
|
}
|
|
}
|
|
|
|
export function getErrorMessage(
|
|
{ message }: { message: string },
|
|
link?: string,
|
|
): string | IonicSafeString {
|
|
if (!message) {
|
|
message = 'Unknown Error.'
|
|
link = 'https://docs.start9.com/latest/support/faq'
|
|
}
|
|
|
|
if (link) {
|
|
return new IonicSafeString(
|
|
`${message}<br /><br /><a href=${link} target="_blank" rel="noreferrer" style="color: white;">Get Help</a>`,
|
|
)
|
|
}
|
|
|
|
return message
|
|
}
|