marketplace url in server.update

This commit is contained in:
Drew Ansbacher
2022-02-10 10:28:21 -07:00
committed by Aiden McClelland
parent 1d8512e1dd
commit b66720dfd0
4 changed files with 138 additions and 92 deletions

View File

@@ -42,7 +42,7 @@ import { OSWelcomePage } from './modals/os-welcome/os-welcome.page'
export class AppComponent { export class AppComponent {
@HostListener('document:keydown.enter', ['$event']) @HostListener('document:keydown.enter', ['$event'])
@debounce() @debounce()
handleKeyboardEvent() { handleKeyboardEvent () {
const elems = document.getElementsByClassName('enter-click') const elems = document.getElementsByClassName('enter-click')
const elem = elems[elems.length - 1] as HTMLButtonElement const elem = elems[elems.length - 1] as HTMLButtonElement
if (!elem || elem.classList.contains('no-click') || elem.disabled) return if (!elem || elem.classList.contains('no-click') || elem.disabled) return
@@ -87,7 +87,7 @@ export class AppComponent {
}, },
] ]
constructor( constructor (
private readonly storage: Storage, private readonly storage: Storage,
private readonly authService: AuthService, private readonly authService: AuthService,
private readonly router: Router, private readonly router: Router,
@@ -110,7 +110,7 @@ export class AppComponent {
this.init() this.init()
} }
async init() { async init () {
await this.storage.create() await this.storage.create()
await this.authService.init() await this.authService.init()
await this.localStorageService.init() await this.localStorageService.init()
@@ -181,7 +181,7 @@ export class AppComponent {
}) })
} }
async goToWebsite(): Promise<void> { async goToWebsite (): Promise<void> {
let url: string let url: string
if (this.config.isTor()) { if (this.config.isTor()) {
url = url =
@@ -192,7 +192,7 @@ export class AppComponent {
window.open(url, '_blank', 'noreferrer') window.open(url, '_blank', 'noreferrer')
} }
async presentAlertLogout() { async presentAlertLogout () {
const alert = await this.alertCtrl.create({ const alert = await this.alertCtrl.create({
header: 'Caution', header: 'Caution',
message: message:
@@ -215,13 +215,13 @@ export class AppComponent {
await alert.present() await alert.present()
} }
private checkForEosUpdate(ui: UIData): void { private checkForEosUpdate (ui: UIData): void {
if (ui['auto-check-updates']) { if (ui['auto-check-updates']) {
this.eosService.getEOS() this.eosService.getEOS()
} }
} }
private async showEosWelcome(ackVersion: string): Promise<void> { private async showEosWelcome (ackVersion: string): Promise<void> {
if (!this.config.skipStartupAlerts && ackVersion !== this.config.version) { if (!this.config.skipStartupAlerts && ackVersion !== this.config.version) {
const modal = await this.modalCtrl.create({ const modal = await this.modalCtrl.create({
component: OSWelcomePage, component: OSWelcomePage,
@@ -240,12 +240,12 @@ export class AppComponent {
} }
// should wipe cache independant of actual BE logout // should wipe cache independant of actual BE logout
private async logout() { private async logout () {
this.embassyApi.logout({}) this.embassyApi.logout({})
this.authService.setUnverified() this.authService.setUnverified()
} }
private watchConnection(): Subscription { private watchConnection (): Subscription {
return this.connectionService return this.connectionService
.watchFailure$() .watchFailure$()
.pipe(distinctUntilChanged(), debounceTime(500)) .pipe(distinctUntilChanged(), debounceTime(500))
@@ -278,7 +278,7 @@ export class AppComponent {
}) })
} }
private watchRouter(): Subscription { private watchRouter (): Subscription {
return this.router.events return this.router.events
.pipe(filter((e: RoutesRecognized) => !!e.urlAfterRedirects)) .pipe(filter((e: RoutesRecognized) => !!e.urlAfterRedirects))
.subscribe(e => { .subscribe(e => {
@@ -289,7 +289,7 @@ export class AppComponent {
}) })
} }
private watchStatus(): Subscription { private watchStatus (): Subscription {
return this.patch.watch$('server-info', 'status').subscribe(status => { return this.patch.watch$('server-info', 'status').subscribe(status => {
if (status === ServerStatus.Updated && !this.updateToast) { if (status === ServerStatus.Updated && !this.updateToast) {
this.presentToastUpdated() this.presentToastUpdated()
@@ -297,7 +297,7 @@ export class AppComponent {
}) })
} }
private watchUpdateProgress(): Subscription { private watchUpdateProgress (): Subscription {
return this.patch return this.patch
.watch$('server-info', 'update-progress') .watch$('server-info', 'update-progress')
.subscribe(progress => { .subscribe(progress => {
@@ -305,7 +305,7 @@ export class AppComponent {
}) })
} }
private watchVersion(): Subscription { private watchVersion (): Subscription {
return this.patch.watch$('server-info', 'version').subscribe(version => { return this.patch.watch$('server-info', 'version').subscribe(version => {
if (this.emver.compare(this.config.version, version) !== 0) { if (this.emver.compare(this.config.version, version) !== 0) {
this.presentAlertRefreshNeeded() this.presentAlertRefreshNeeded()
@@ -313,7 +313,7 @@ export class AppComponent {
}) })
} }
private watchNotifications(): Subscription { private watchNotifications (): Subscription {
let previous: number let previous: number
return this.patch return this.patch
.watch$('server-info', 'unread-notification-count') .watch$('server-info', 'unread-notification-count')
@@ -325,7 +325,7 @@ export class AppComponent {
}) })
} }
private async presentAlertRefreshNeeded() { private async presentAlertRefreshNeeded () {
const alert = await this.alertCtrl.create({ const alert = await this.alertCtrl.create({
backdropDismiss: false, backdropDismiss: false,
header: 'Refresh Needed', header: 'Refresh Needed',
@@ -344,7 +344,7 @@ export class AppComponent {
await alert.present() await alert.present()
} }
private async presentToastUpdated() { private async presentToastUpdated () {
if (this.updateToast) return if (this.updateToast) return
this.updateToast = await this.toastCtrl.create({ this.updateToast = await this.toastCtrl.create({
@@ -374,7 +374,7 @@ export class AppComponent {
await this.updateToast.present() await this.updateToast.present()
} }
private async presentToastNotifications() { private async presentToastNotifications () {
if (this.notificationToast) return if (this.notificationToast) return
this.notificationToast = await this.toastCtrl.create({ this.notificationToast = await this.toastCtrl.create({
@@ -404,7 +404,7 @@ export class AppComponent {
await this.notificationToast.present() await this.notificationToast.present()
} }
private async presentToastOffline( private async presentToastOffline (
message: string | IonicSafeString, message: string | IonicSafeString,
link?: string, link?: string,
) { ) {
@@ -445,7 +445,7 @@ export class AppComponent {
await this.offlineToast.present() await this.offlineToast.present()
} }
private async restart(): Promise<void> { private async restart (): Promise<void> {
const loader = await this.loadingCtrl.create({ const loader = await this.loadingCtrl.create({
spinner: 'lines', spinner: 'lines',
message: 'Restarting...', message: 'Restarting...',
@@ -454,7 +454,9 @@ export class AppComponent {
await loader.present() await loader.present()
try { try {
await this.embassyApi.restartServer({}) await this.embassyApi.restartServer({
'marketplace-url': this.config.marketplace.url,
})
} catch (e) { } catch (e) {
this.errToast.present(e) this.errToast.present(e)
} finally { } finally {
@@ -462,7 +464,7 @@ export class AppComponent {
} }
} }
splitPaneVisible(e: any) { splitPaneVisible (e: any) {
this.splitPane.sidebarOpen$.next(e.detail.visible) this.splitPane.sidebarOpen$.next(e.detail.visible)
} }
} }

View File

@@ -3,15 +3,21 @@ import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
import { Breakages } from 'src/app/services/api/api.types' import { Breakages } from 'src/app/services/api/api.types'
import { exists } from 'src/app/util/misc.util' import { exists } from 'src/app/util/misc.util'
import { ApiService } from '../../services/api/embassy-api.service' import { ApiService } from '../../services/api/embassy-api.service'
import { InstallWizardComponent, SlideDefinition, TopbarParams } from './install-wizard.component' import {
InstallWizardComponent,
SlideDefinition,
TopbarParams,
} from './install-wizard.component'
import { ConfigService } from 'src/app/services/config.service'
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class WizardBaker { export class WizardBaker {
constructor ( constructor(
private readonly embassyApi: ApiService, private readonly embassyApi: ApiService,
) { } private readonly config: ConfigService,
) {}
update (values: { update(values: {
id: string id: string
title: string title: string
version: string version: string
@@ -20,25 +26,27 @@ export class WizardBaker {
const { id, title, version, installAlert } = values const { id, title, version, installAlert } = values
const action = 'update' const action = 'update'
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
installAlert ? { installAlert
slide: { ? {
selector: 'alert', slide: {
params: { selector: 'alert',
title: 'Warning', params: {
message: installAlert, title: 'Warning',
titleColor: 'warning', message: installAlert,
}, titleColor: 'warning',
}, },
bottomBar: { },
cancel: { bottomBar: {
afterLoading: { text: 'Cancel' }, cancel: {
}, afterLoading: { text: 'Cancel' },
next: 'Next', },
}, next: 'Next',
} : undefined, },
}
: undefined,
{ {
slide: { slide: {
selector: 'dependents', selector: 'dependents',
@@ -46,7 +54,10 @@ export class WizardBaker {
action, action,
verb: 'updating', verb: 'updating',
title, title,
fetchBreakages: () => this.embassyApi.dryUpdatePackage({ id, version }).then(breakages => breakages), fetchBreakages: () =>
this.embassyApi
.dryUpdatePackage({ id, version })
.then(breakages => breakages),
}, },
}, },
bottomBar: { bottomBar: {
@@ -63,11 +74,15 @@ export class WizardBaker {
action, action,
verb: 'beginning update for', verb: 'beginning update for',
title, title,
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }), executeAction: () =>
this.embassyApi.installPackage({
id,
'version-spec': version ? `=${version}` : undefined,
}),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { whileLoading: { } }, cancel: { whileLoading: {} },
finish: 'Dismiss', finish: 'Dismiss',
}, },
}, },
@@ -75,7 +90,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) } return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
} }
updateOS (values: { updateOS(values: {
version: string version: string
releaseNotes: { [version: string]: string } releaseNotes: { [version: string]: string }
headline: string headline: string
@@ -84,11 +99,11 @@ export class WizardBaker {
const action = 'update' const action = 'update'
const title = 'EmbassyOS' const title = 'EmbassyOS'
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
{ {
slide : { slide: {
selector: 'notes', selector: 'notes',
params: { params: {
notes: releaseNotes, notes: releaseNotes,
@@ -111,11 +126,14 @@ export class WizardBaker {
action, action,
verb: 'beginning update for', verb: 'beginning update for',
title, title,
executeAction: () => this.embassyApi.updateServer({ }), executeAction: () =>
this.embassyApi.updateServer({
'marketplace-url': this.config.marketplace.url,
}),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { whileLoading: { }}, cancel: { whileLoading: {} },
finish: 'Dismiss', finish: 'Dismiss',
}, },
}, },
@@ -123,7 +141,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) } return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
} }
downgrade (values: { downgrade(values: {
id: string id: string
title: string title: string
version: string version: string
@@ -132,53 +150,64 @@ export class WizardBaker {
const { id, title, version, installAlert } = values const { id, title, version, installAlert } = values
const action = 'downgrade' const action = 'downgrade'
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
installAlert ? { installAlert
? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
}
: undefined,
{
slide: { slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
} : undefined,
{ slide: {
selector: 'dependents', selector: 'dependents',
params: { params: {
action, action,
verb: 'downgrading', verb: 'downgrading',
title, title,
fetchBreakages: () => this.embassyApi.dryUpdatePackage({ id, version }).then(breakages => breakages), fetchBreakages: () =>
this.embassyApi
.dryUpdatePackage({ id, version })
.then(breakages => breakages),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { cancel: {
whileLoading: { }, whileLoading: {},
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Downgrade Anyway', next: 'Downgrade Anyway',
}, },
}, },
{ slide: { {
slide: {
selector: 'complete', selector: 'complete',
params: { params: {
action, action,
verb: 'beginning downgrade for', verb: 'beginning downgrade for',
title, title,
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }), executeAction: () =>
this.embassyApi.installPackage({
id,
'version-spec': version ? `=${version}` : undefined,
}),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { whileLoading: { } }, cancel: { whileLoading: {} },
finish: 'Dismiss', finish: 'Dismiss',
}, },
}, },
@@ -186,7 +215,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) } return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
} }
uninstall (values: { uninstall(values: {
id: string id: string
title: string title: string
version: string version: string
@@ -195,7 +224,7 @@ export class WizardBaker {
const { id, title, version, uninstallAlert } = values const { id, title, version, uninstallAlert } = values
const action = 'uninstall' const action = 'uninstall'
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
{ {
@@ -211,7 +240,8 @@ export class WizardBaker {
cancel: { cancel: {
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Continue' }, next: 'Continue',
},
}, },
{ {
slide: { slide: {
@@ -220,15 +250,19 @@ export class WizardBaker {
action, action,
verb: 'uninstalling', verb: 'uninstalling',
title, title,
fetchBreakages: () => this.embassyApi.dryUninstallPackage({ id }).then(breakages => breakages), fetchBreakages: () =>
this.embassyApi
.dryUninstallPackage({ id })
.then(breakages => breakages),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { cancel: {
whileLoading: { }, whileLoading: {},
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Uninstall' }, next: 'Uninstall',
},
}, },
{ {
slide: { slide: {
@@ -243,7 +277,7 @@ export class WizardBaker {
bottomBar: { bottomBar: {
finish: 'Dismiss', finish: 'Dismiss',
cancel: { cancel: {
whileLoading: { }, whileLoading: {},
}, },
}, },
}, },
@@ -251,7 +285,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) } return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
} }
stop (values: { stop(values: {
id: string id: string
title: string title: string
version: string version: string
@@ -259,7 +293,7 @@ export class WizardBaker {
const { title, version, id } = values const { title, version, id } = values
const action = 'stop' const action = 'stop'
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
{ {
@@ -269,12 +303,15 @@ export class WizardBaker {
action, action,
verb: 'stopping', verb: 'stopping',
title, title,
fetchBreakages: () => this.embassyApi.dryStopPackage({ id }).then(breakages => breakages), fetchBreakages: () =>
this.embassyApi
.dryStopPackage({ id })
.then(breakages => breakages),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { cancel: {
whileLoading: { }, whileLoading: {},
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Stop Service', next: 'Stop Service',
@@ -293,7 +330,7 @@ export class WizardBaker {
bottomBar: { bottomBar: {
finish: 'Dismiss', finish: 'Dismiss',
cancel: { cancel: {
whileLoading: { }, whileLoading: {},
}, },
}, },
}, },
@@ -301,14 +338,14 @@ export class WizardBaker {
return { toolbar, slideDefinitions } return { toolbar, slideDefinitions }
} }
configure (values: { configure(values: {
pkg: PackageDataEntry pkg: PackageDataEntry
breakages: Breakages breakages: Breakages
}): InstallWizardComponent['params'] { }): InstallWizardComponent['params'] {
const { breakages, pkg } = values const { breakages, pkg } = values
const { title, version } = pkg.manifest const { title, version } = pkg.manifest
const action = 'configure' const action = 'configure'
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
{ {
@@ -317,18 +354,21 @@ export class WizardBaker {
params: { params: {
action, action,
verb: 'saving config for', verb: 'saving config for',
title, fetchBreakages: () => Promise.resolve(breakages), title,
fetchBreakages: () => Promise.resolve(breakages),
}, },
}, },
bottomBar: { bottomBar: {
cancel: { cancel: {
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Save Config Anyway' }, next: 'Save Config Anyway',
},
}, },
] ]
return { toolbar, slideDefinitions } return { toolbar, slideDefinitions }
} }
} }
const defaultUninstallWarning = (serviceName: string) => `Uninstalling ${ serviceName } will result in the deletion of its data.` const defaultUninstallWarning = (serviceName: string) =>
`Uninstalling ${serviceName} will result in the deletion of its data.`

View File

@@ -17,6 +17,7 @@ import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component' import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component'
import { exists, isEmptyObject } from 'src/app/util/misc.util' import { exists, isEmptyObject } from 'src/app/util/misc.util'
import { EOSService } from 'src/app/services/eos.service' import { EOSService } from 'src/app/services/eos.service'
import { ConfigService } from 'src/app/services/config.service'
@Component({ @Component({
selector: 'server-show', selector: 'server-show',
@@ -36,6 +37,7 @@ export class ServerShowPage {
private readonly embassyApi: ApiService, private readonly embassyApi: ApiService,
private readonly navCtrl: NavController, private readonly navCtrl: NavController,
private readonly route: ActivatedRoute, private readonly route: ActivatedRoute,
private readonly config: ConfigService,
public readonly eosService: EOSService, public readonly eosService: EOSService,
public readonly patch: PatchDbService, public readonly patch: PatchDbService,
) {} ) {}
@@ -153,7 +155,9 @@ export class ServerShowPage {
await loader.present() await loader.present()
try { try {
await this.embassyApi.restartServer({}) await this.embassyApi.restartServer({
'marketplace-url': this.config.marketplace.url,
})
} catch (e) { } catch (e) {
this.errToast.present(e) this.errToast.present(e)
} finally { } finally {

View File

@@ -38,7 +38,7 @@ export module RR {
export type GetServerMetricsReq = {} // server.metrics export type GetServerMetricsReq = {} // server.metrics
export type GetServerMetricsRes = Metrics export type GetServerMetricsRes = Metrics
export type UpdateServerReq = WithExpire<{}> // server.update export type UpdateServerReq = WithExpire<{ 'marketplace-url': string }> // server.update
export type UpdateServerRes = WithRevision<'updating' | 'no-updates'> export type UpdateServerRes = WithRevision<'updating' | 'no-updates'>
export type RestartServerReq = {} // server.restart export type RestartServerReq = {} // server.restart