mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
ui: add embassy os release notes
This commit is contained in:
committed by
Aiden McClelland
parent
68faa17ab6
commit
79604182c8
@@ -67,7 +67,7 @@ export module ReqRes {
|
||||
export type PostLoginRes = Unit
|
||||
export type GetCheckAuthRes = { }
|
||||
export type GetServerRes = ApiServer
|
||||
export type GetVersionLatestRes = { versionLatest: string, canUpdate: boolean } // canUpdate not supported at least at 0.2.8
|
||||
export type GetVersionLatestRes = { versionLatest: string, releaseNotes: string }
|
||||
export type GetServerMetricsRes = ServerMetrics
|
||||
export type GetAppAvailableRes = ApiAppAvailableFull
|
||||
export type GetAppAvailableVersionInfoRes = AppAvailableVersionSpecificInfo
|
||||
|
||||
@@ -410,7 +410,7 @@ const mockApiServer: () => ReqRes.GetServerRes = () => ({
|
||||
status: ServerStatus.RUNNING,
|
||||
alternativeRegistryUrl: 'beta-registry.start9labs.com',
|
||||
welcomeAck: true,
|
||||
autoCheckUpdates: false,
|
||||
autoCheckUpdates: true,
|
||||
specs: {
|
||||
'Tor Address': 'nfsnjkcnaskjnlkasnfahj7dh23fdnieqwjdnhjewbfijendiueqwbd.onion',
|
||||
'CPU': 'Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz',
|
||||
@@ -440,7 +440,10 @@ const mockApiServer: () => ReqRes.GetServerRes = () => ({
|
||||
|
||||
const mockVersionLatest: ReqRes.GetVersionLatestRes = {
|
||||
versionLatest: '15.2.8.6',
|
||||
canUpdate: true,
|
||||
releaseNotes: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent aliquet, sapien sit amet pretium lacinia, neque tortor consectetur nunc, non volutpat lectus neque in leo. Curabitur a odio eleifend, placerat purus non, aliquet nulla. Aliquam eget lacinia lectus. Aliquam gravida elit eu magna pretium, non interdum tortor vulputate. Ut ac tortor vel tellus blandit malesuada ac ac tortor. Integer tincidunt est quam, non convallis sapien vehicula sed. Donec ullamcorper convallis massa, nec euismod enim tempus vitae. In condimentum semper pulvinar. Sed viverra est id lectus tincidunt, et malesuada eros malesuada.
|
||||
Curabitur scelerisque eu mauris eget dapibus. In egestas est sit amet nisi cursus iaculis. Mauris consequat pharetra ex, vitae sollicitudin tortor viverra id. Suspendisse lacinia justo id tincidunt feugiat. Nunc risus elit, viverra vel vestibulum ac, varius vel eros. Nam at tellus tempor, semper metus et, tristique elit. Vivamus a dui sit amet orci tincidunt tincidunt. Cras ut velit pretium, euismod dolor non, pulvinar lorem. Praesent dignissim eros quis tortor bibendum, nec convallis libero viverra. Aenean sit amet massa maximus eros congue pellentesque ac nec massa. Nam feugiat felis mi, a aliquet enim porta eget.
|
||||
Phasellus pellentesque magna vel elit malesuada elementum. Curabitur maximus scelerisque vulputate. Duis facilisis et nisi sed facilisis. Ut consectetur odio tortor, vitae elementum velit scelerisque eget. Maecenas bibendum, massa eu bibendum rhoncus, turpis ex condimentum elit, vel pulvinar ex mi sed urna. Etiam ac erat lectus. Suspendisse dignissim massa tortor. Donec ac dolor in tortor faucibus scelerisque. Nullam et lacus eros. Cras eget sapien nec felis condimentum tincidunt. Praesent ac ante dui. Nam euismod nunc neque, et scelerisque erat efficitur nec. Aenean efficitur tincidunt nulla, ac tempor leo blandit sed. Duis sed tellus quis ante consequat ornare nec vitae eros. Praesent ultrices nunc ut lacus tincidunt finibus. Praesent at eros non est commodo ultricies.
|
||||
Curabitur eu felis convallis, lobortis nulla laoreet, commodo lacus. Vestibulum at sapien sed metus tincidunt vulputate. Donec cursus augue non sapien imperdiet cursus. Aliquam pellentesque ligula id magna blandit rutrum. Aliquam mattis ipsum leo, nec pharetra lectus tristique eu. Duis egestas mollis aliquam. Duis aliquet dictum risus, quis dictum mauris finibus id.`,
|
||||
}
|
||||
|
||||
const mockApiServerMetrics: ReqRes.GetServerMetricsRes = {
|
||||
|
||||
@@ -8,12 +8,13 @@ import { Emver } from './emver.service'
|
||||
|
||||
|
||||
// call checkForUpdates in marketplace pages, can subscribe globally however
|
||||
type UpdateAvailable = { versionLatest: string, releaseNotes: string}
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class OsUpdateService {
|
||||
// holds version latest if update available, undefined if not.
|
||||
private readonly $updateAvailable$ = new BehaviorSubject<string>(undefined)
|
||||
private readonly $updateAvailable$ = new BehaviorSubject<UpdateAvailable>(undefined)
|
||||
|
||||
watchForUpdateAvailable$ (): Observable<undefined | string> {
|
||||
watchForUpdateAvailable$ (): Observable<undefined | UpdateAvailable> {
|
||||
return this.$updateAvailable$.asObservable().pipe(distinctUntilChanged())
|
||||
}
|
||||
|
||||
@@ -25,7 +26,7 @@ export class OsUpdateService {
|
||||
) { }
|
||||
|
||||
// emits the latest version or re-checks to see if there's a new latest version
|
||||
checkWhenNotAvailable$ (): Observable<undefined | string> {
|
||||
checkWhenNotAvailable$ (): Observable<undefined | UpdateAvailable> {
|
||||
return this.$updateAvailable$.pipe(
|
||||
take(1),
|
||||
concatMap(vl => vl ? of(vl) : this.checkForUpdates$()),
|
||||
@@ -33,12 +34,12 @@ export class OsUpdateService {
|
||||
}
|
||||
|
||||
// can sub to this imperatively and take the return value as gospel, or watch the $updateAvailable$ subject for the same info.
|
||||
checkForUpdates$ (): Observable<undefined | string> {
|
||||
checkForUpdates$ (): Observable<undefined | UpdateAvailable> {
|
||||
return forkJoin([
|
||||
this.serverModel.watch().versionInstalled.pipe(take(1)),
|
||||
this.apiService.getVersionLatest(),
|
||||
]).pipe(
|
||||
map(([vi, vl]) => this.updateIsAvailable(vi, vl.versionLatest) ? vl.versionLatest : undefined),
|
||||
map(([vi, vl]) => this.updateIsAvailable(vi, vl) ? vl : undefined),
|
||||
catchError(e => {
|
||||
console.error(`OsUpdateService Error: ${e}`)
|
||||
return of(undefined)
|
||||
@@ -48,9 +49,9 @@ export class OsUpdateService {
|
||||
)
|
||||
}
|
||||
|
||||
updateIsAvailable (vi: string, vl: string): boolean {
|
||||
updateIsAvailable (vi: string, vl: UpdateAvailable): boolean {
|
||||
if (!vi || !vl) return false
|
||||
if (this.emver.compare(vi, vl) === -1) {
|
||||
if (this.emver.compare(vi, vl.versionLatest) === -1) {
|
||||
this.$updateAvailable$.next(vl)
|
||||
return true
|
||||
} else {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { AlertController, IonicSafeString, ModalController, NavController } from '@ionic/angular'
|
||||
import { wizardModal } from '../components/install-wizard/install-wizard.component'
|
||||
import { WizardBaker } from '../components/install-wizard/prebaked-wizards'
|
||||
import { OSWelcomePage } from '../modals/os-welcome/os-welcome.page'
|
||||
import { S9Server } from '../models/server-model'
|
||||
import { displayEmver } from '../pipes/emver.pipe'
|
||||
import { ApiService } from './api/api.service'
|
||||
import { ApiService, ReqRes } from './api/api.service'
|
||||
import { ConfigService } from './config.service'
|
||||
import { Emver } from './emver.service'
|
||||
import { LoaderService } from './loader.service'
|
||||
import { OsUpdateService } from './os-update.service'
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -14,12 +15,12 @@ export class StartupAlertsNotifier {
|
||||
constructor (
|
||||
private readonly alertCtrl: AlertController,
|
||||
private readonly navCtrl: NavController,
|
||||
private readonly loader: LoaderService,
|
||||
private readonly config: ConfigService,
|
||||
private readonly modalCtrl: ModalController,
|
||||
private readonly apiService: ApiService,
|
||||
private readonly emver: Emver,
|
||||
private readonly osUpdateService: OsUpdateService,
|
||||
private readonly wizardBaker: WizardBaker,
|
||||
) { }
|
||||
|
||||
// This takes our three checks and filters down to those that should run.
|
||||
@@ -54,7 +55,7 @@ export class StartupAlertsNotifier {
|
||||
display: s => this.displayOsWelcome(s),
|
||||
hasRun: false,
|
||||
}
|
||||
osUpdate: Check<string | undefined> = {
|
||||
osUpdate: Check<ReqRes.GetVersionLatestRes | undefined> = {
|
||||
name: 'osUpdate',
|
||||
shouldRun: s => this.shouldRunOsUpdateCheck(s),
|
||||
check: s => this.osUpdateCheck(s),
|
||||
@@ -83,9 +84,9 @@ export class StartupAlertsNotifier {
|
||||
return server.autoCheckUpdates
|
||||
}
|
||||
|
||||
private async osUpdateCheck (s: Readonly<S9Server>): Promise<string | undefined> {
|
||||
const { versionLatest } = await this.apiService.getVersionLatest()
|
||||
return this.osUpdateService.updateIsAvailable(s.versionInstalled, versionLatest) ? versionLatest : undefined
|
||||
private async osUpdateCheck (s: Readonly<S9Server>): Promise<ReqRes.GetVersionLatestRes | undefined> {
|
||||
const res = await this.apiService.getVersionLatest()
|
||||
return this.osUpdateService.updateIsAvailable(s.versionInstalled, res) ? res : undefined
|
||||
}
|
||||
|
||||
private async appsCheck (): Promise<boolean> {
|
||||
@@ -113,12 +114,17 @@ export class StartupAlertsNotifier {
|
||||
})
|
||||
}
|
||||
|
||||
private async displayOsUpdateCheck (versionLatest: string | undefined): Promise<boolean> {
|
||||
const { update } = await this.presentAlertNewOS(versionLatest)
|
||||
private async displayOsUpdateCheck (res: ReqRes.GetVersionLatestRes): Promise<boolean> {
|
||||
const { update } = await this.presentAlertNewOS(res.versionLatest)
|
||||
if (update) {
|
||||
await this.loader.displayDuringP(
|
||||
this.osUpdateService.updateEmbassyOS(versionLatest),
|
||||
).catch(e => alert(e))
|
||||
const { cancelled } = await wizardModal(
|
||||
this.modalCtrl,
|
||||
this.wizardBaker.updateOS({
|
||||
version: res.versionLatest,
|
||||
releaseNotes: res.releaseNotes,
|
||||
}),
|
||||
)
|
||||
if (cancelled) return true
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -134,7 +140,7 @@ export class StartupAlertsNotifier {
|
||||
<div>New service updates are available in the Marketplace.</div>
|
||||
<div style="font-size:x-small">You can disable these checks in your Embassy Config</div>
|
||||
</div>
|
||||
`
|
||||
`,
|
||||
),
|
||||
buttons: [
|
||||
{
|
||||
@@ -165,7 +171,7 @@ export class StartupAlertsNotifier {
|
||||
<div>Update EmbassyOS to version ${displayEmver(versionLatest)}?</div>
|
||||
<div style="font-size:x-small">You can disable these checks in your Embassy Config</div>
|
||||
</div>
|
||||
`
|
||||
`,
|
||||
),
|
||||
buttons: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user