mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
* rename frontend to web and update contributing guide * rename this time * fix build * restructure rust code * update documentation * update descriptions * Update CONTRIBUTING.md Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com> --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'
|
|
import { LoadingController } from '@ionic/angular'
|
|
import { ErrorToastService } from '@start9labs/shared'
|
|
import { Observable, Subject, merge } from 'rxjs'
|
|
|
|
import { UpdateToastService } from './update-toast.service'
|
|
import { ApiService } from '../../../services/api/embassy-api.service'
|
|
|
|
@Component({
|
|
selector: 'update-toast',
|
|
templateUrl: './update-toast.component.html',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class UpdateToastComponent {
|
|
private readonly dismiss$ = new Subject<boolean>()
|
|
|
|
readonly visible$: Observable<boolean> = merge(this.dismiss$, this.update$)
|
|
|
|
constructor(
|
|
@Inject(UpdateToastService) private readonly update$: Observable<boolean>,
|
|
private readonly embassyApi: ApiService,
|
|
private readonly errToast: ErrorToastService,
|
|
private readonly loadingCtrl: LoadingController,
|
|
) {}
|
|
|
|
onDismiss() {
|
|
this.dismiss$.next(false)
|
|
}
|
|
|
|
async restart(): Promise<void> {
|
|
this.onDismiss()
|
|
|
|
const loader = await this.loadingCtrl.create({
|
|
message: 'Restarting...',
|
|
})
|
|
|
|
await loader.present()
|
|
|
|
try {
|
|
await this.embassyApi.restartServer({})
|
|
} catch (e: any) {
|
|
await this.errToast.present(e)
|
|
} finally {
|
|
await loader.dismiss()
|
|
}
|
|
}
|
|
}
|