mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
ui: completes welcome ack trigger
This commit is contained in:
committed by
Aiden McClelland
parent
778d22ab2b
commit
939ad844e8
@@ -105,7 +105,7 @@ export class ServerModel {
|
||||
wifi: { ssids: [], current: undefined },
|
||||
ssh: [],
|
||||
notifications: [],
|
||||
welcomeSeen: true,
|
||||
welcomeAck: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ export interface S9Server {
|
||||
wifi: { ssids: string[], current: string }
|
||||
ssh: SSHFingerprint[]
|
||||
notifications: S9Notification[]
|
||||
welcomeSeen: boolean
|
||||
welcomeAck: boolean
|
||||
}
|
||||
|
||||
export interface S9Notification {
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface ApiServer {
|
||||
}
|
||||
ssh: SSHFingerprint[]
|
||||
serverId: string
|
||||
welcomeAck: boolean
|
||||
}
|
||||
|
||||
/** APPS **/
|
||||
|
||||
@@ -29,6 +29,7 @@ export abstract class ApiService {
|
||||
abstract getNotifications (page: number, perPage: number): Promise<S9Notification[]>
|
||||
abstract deleteNotification (id: string): Promise<Unit>
|
||||
abstract updateAgent (thing: any): Promise<Unit>
|
||||
abstract acknowledgeOSWelcome (): Promise<Unit>
|
||||
abstract getAvailableApps (): Promise<AppAvailablePreview[]>
|
||||
abstract getAvailableApp (appId: string): Promise<AppAvailableFull>
|
||||
abstract getAvailableAppVersionSpecificInfo (appId: string, versionSpec: string): Promise<AppAvailableVersionSpecificInfo>
|
||||
|
||||
@@ -37,6 +37,10 @@ export class LiveApiService extends ApiService {
|
||||
return this.authRequest<ReqRes.GetServerRes>({ method: Method.GET, url: '/', readTimeout: timeout })
|
||||
}
|
||||
|
||||
async acknowledgeOSWelcome (): Promise<Unit> {
|
||||
return this.authRequest<Unit>({ method: Method.POST, url: '/welcome' })
|
||||
}
|
||||
|
||||
async getVersionLatest (): Promise<ReqRes.GetVersionLatestRes> {
|
||||
return this.authRequest<ReqRes.GetVersionLatestRes>({ method: Method.GET, url: '/versionLatest' }, { version: '' })
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { mockApiAppAvailableFull, mockApiAppAvailableVersionInfo, mockApiAppInst
|
||||
//@TODO consider moving to test folders.
|
||||
@Injectable()
|
||||
export class MockApiService extends ApiService {
|
||||
welcomeAck = false
|
||||
constructor (
|
||||
private readonly appModel: AppModel,
|
||||
private readonly serverModel: ServerModel,
|
||||
@@ -32,7 +33,8 @@ export class MockApiService extends ApiService {
|
||||
}
|
||||
|
||||
async getServer (): Promise<ApiServer> {
|
||||
return mockGetServer()
|
||||
const res = await mockGetServer()
|
||||
return { ...res, welcomeAck: this.welcomeAck }
|
||||
}
|
||||
|
||||
async ejectExternalDisk (): Promise<Unit> {
|
||||
@@ -115,6 +117,12 @@ export class MockApiService extends ApiService {
|
||||
return mockUninstallApp()
|
||||
}
|
||||
|
||||
async acknowledgeOSWelcome () {
|
||||
await pauseFor(2000)
|
||||
this.welcomeAck = true
|
||||
return { }
|
||||
}
|
||||
|
||||
async startApp (appId: string): Promise<EmptyResponse> {
|
||||
console.log('start app mock')
|
||||
await mockStartApp()
|
||||
@@ -396,6 +404,7 @@ const mockApiServer: () => ReqRes.GetServerRes = () => ({
|
||||
versionInstalled: '0.2.8',
|
||||
status: ServerStatus.RUNNING,
|
||||
alternativeRegistryUrl: 'beta-registry.start9labs.com',
|
||||
welcomeAck: true,
|
||||
specs: {
|
||||
'Tor Address': 'nfsnjkcnaskjnlkasnfahj7dh23fdnieqwjdnhjewbfijendiueqwbd.onion',
|
||||
'CPU': 'Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz',
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ConfigService } from 'src/app/services/config.service'
|
||||
import { ToastController, NavController, ModalController } from '@ionic/angular'
|
||||
import { ServerModel, S9Server } from '../models/server-model'
|
||||
import { OSWelcomePage } from '../modals/os-welcome/os-welcome.page'
|
||||
import { ApiService } from './api/api.service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -14,6 +15,7 @@ export class SyncNotifier {
|
||||
private readonly modalCtrl: ModalController,
|
||||
private readonly navCtrl: NavController,
|
||||
private readonly serverModel: ServerModel,
|
||||
private readonly apiService: ApiService,
|
||||
) { }
|
||||
|
||||
async handleSpecial (server: Readonly<S9Server>): Promise<void> {
|
||||
@@ -57,18 +59,24 @@ export class SyncNotifier {
|
||||
this.serverModel.update(updates)
|
||||
}
|
||||
|
||||
private async handleOSWelcome(server: Readonly<S9Server>) {
|
||||
if (server.welcomeSeen || server.versionInstalled !== this.config.version) return
|
||||
osWelcomeOpen = false
|
||||
private async handleOSWelcome (server: Readonly<S9Server>) {
|
||||
if (server.welcomeAck || server.versionInstalled !== this.config.version || this.osWelcomeOpen) return
|
||||
|
||||
const modal = await this.modalCtrl.create({
|
||||
backdropDismiss: false,
|
||||
component: OSWelcomePage,
|
||||
presentingElement: await this.modalCtrl.getTop(),
|
||||
componentProps: {
|
||||
version: server.versionInstalled
|
||||
version: server.versionInstalled,
|
||||
},
|
||||
})
|
||||
this.osWelcomeOpen = true
|
||||
|
||||
modal.onWillDismiss().then(() => {
|
||||
this.osWelcomeOpen = false
|
||||
return this.apiService.acknowledgeOSWelcome()
|
||||
})
|
||||
await modal.present()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user