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 {
@HostListener('document:keydown.enter', ['$event'])
@debounce()
handleKeyboardEvent() {
handleKeyboardEvent () {
const elems = document.getElementsByClassName('enter-click')
const elem = elems[elems.length - 1] as HTMLButtonElement
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 authService: AuthService,
private readonly router: Router,
@@ -110,7 +110,7 @@ export class AppComponent {
this.init()
}
async init() {
async init () {
await this.storage.create()
await this.authService.init()
await this.localStorageService.init()
@@ -181,7 +181,7 @@ export class AppComponent {
})
}
async goToWebsite(): Promise<void> {
async goToWebsite (): Promise<void> {
let url: string
if (this.config.isTor()) {
url =
@@ -192,7 +192,7 @@ export class AppComponent {
window.open(url, '_blank', 'noreferrer')
}
async presentAlertLogout() {
async presentAlertLogout () {
const alert = await this.alertCtrl.create({
header: 'Caution',
message:
@@ -215,13 +215,13 @@ export class AppComponent {
await alert.present()
}
private checkForEosUpdate(ui: UIData): void {
private checkForEosUpdate (ui: UIData): void {
if (ui['auto-check-updates']) {
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) {
const modal = await this.modalCtrl.create({
component: OSWelcomePage,
@@ -240,12 +240,12 @@ export class AppComponent {
}
// should wipe cache independant of actual BE logout
private async logout() {
private async logout () {
this.embassyApi.logout({})
this.authService.setUnverified()
}
private watchConnection(): Subscription {
private watchConnection (): Subscription {
return this.connectionService
.watchFailure$()
.pipe(distinctUntilChanged(), debounceTime(500))
@@ -278,7 +278,7 @@ export class AppComponent {
})
}
private watchRouter(): Subscription {
private watchRouter (): Subscription {
return this.router.events
.pipe(filter((e: RoutesRecognized) => !!e.urlAfterRedirects))
.subscribe(e => {
@@ -289,7 +289,7 @@ export class AppComponent {
})
}
private watchStatus(): Subscription {
private watchStatus (): Subscription {
return this.patch.watch$('server-info', 'status').subscribe(status => {
if (status === ServerStatus.Updated && !this.updateToast) {
this.presentToastUpdated()
@@ -297,7 +297,7 @@ export class AppComponent {
})
}
private watchUpdateProgress(): Subscription {
private watchUpdateProgress (): Subscription {
return this.patch
.watch$('server-info', 'update-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 => {
if (this.emver.compare(this.config.version, version) !== 0) {
this.presentAlertRefreshNeeded()
@@ -313,7 +313,7 @@ export class AppComponent {
})
}
private watchNotifications(): Subscription {
private watchNotifications (): Subscription {
let previous: number
return this.patch
.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({
backdropDismiss: false,
header: 'Refresh Needed',
@@ -344,7 +344,7 @@ export class AppComponent {
await alert.present()
}
private async presentToastUpdated() {
private async presentToastUpdated () {
if (this.updateToast) return
this.updateToast = await this.toastCtrl.create({
@@ -374,7 +374,7 @@ export class AppComponent {
await this.updateToast.present()
}
private async presentToastNotifications() {
private async presentToastNotifications () {
if (this.notificationToast) return
this.notificationToast = await this.toastCtrl.create({
@@ -404,7 +404,7 @@ export class AppComponent {
await this.notificationToast.present()
}
private async presentToastOffline(
private async presentToastOffline (
message: string | IonicSafeString,
link?: string,
) {
@@ -445,7 +445,7 @@ export class AppComponent {
await this.offlineToast.present()
}
private async restart(): Promise<void> {
private async restart (): Promise<void> {
const loader = await this.loadingCtrl.create({
spinner: 'lines',
message: 'Restarting...',
@@ -454,7 +454,9 @@ export class AppComponent {
await loader.present()
try {
await this.embassyApi.restartServer({})
await this.embassyApi.restartServer({
'marketplace-url': this.config.marketplace.url,
})
} catch (e) {
this.errToast.present(e)
} finally {
@@ -462,7 +464,7 @@ export class AppComponent {
}
}
splitPaneVisible(e: any) {
splitPaneVisible (e: any) {
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 { exists } from 'src/app/util/misc.util'
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' })
export class WizardBaker {
constructor (
constructor(
private readonly embassyApi: ApiService,
) { }
private readonly config: ConfigService,
) {}
update (values: {
update(values: {
id: string
title: string
version: string
@@ -20,25 +26,27 @@ export class WizardBaker {
const { id, title, version, installAlert } = values
const action = 'update'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
installAlert ? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
} : undefined,
installAlert
? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
}
: undefined,
{
slide: {
selector: 'dependents',
@@ -46,7 +54,10 @@ export class WizardBaker {
action,
verb: 'updating',
title,
fetchBreakages: () => this.embassyApi.dryUpdatePackage({ id, version }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryUpdatePackage({ id, version })
.then(breakages => breakages),
},
},
bottomBar: {
@@ -63,11 +74,15 @@ export class WizardBaker {
action,
verb: 'beginning update for',
title,
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }),
executeAction: () =>
this.embassyApi.installPackage({
id,
'version-spec': version ? `=${version}` : undefined,
}),
},
},
bottomBar: {
cancel: { whileLoading: { } },
cancel: { whileLoading: {} },
finish: 'Dismiss',
},
},
@@ -75,7 +90,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
updateOS (values: {
updateOS(values: {
version: string
releaseNotes: { [version: string]: string }
headline: string
@@ -84,11 +99,11 @@ export class WizardBaker {
const action = 'update'
const title = 'EmbassyOS'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
slide : {
slide: {
selector: 'notes',
params: {
notes: releaseNotes,
@@ -111,11 +126,14 @@ export class WizardBaker {
action,
verb: 'beginning update for',
title,
executeAction: () => this.embassyApi.updateServer({ }),
executeAction: () =>
this.embassyApi.updateServer({
'marketplace-url': this.config.marketplace.url,
}),
},
},
bottomBar: {
cancel: { whileLoading: { }},
cancel: { whileLoading: {} },
finish: 'Dismiss',
},
},
@@ -123,7 +141,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
downgrade (values: {
downgrade(values: {
id: string
title: string
version: string
@@ -132,53 +150,64 @@ export class WizardBaker {
const { id, title, version, installAlert } = values
const action = 'downgrade'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
installAlert ? {
installAlert
? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
}
: undefined,
{
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
} : undefined,
{ slide: {
selector: 'dependents',
params: {
action,
verb: 'downgrading',
title,
fetchBreakages: () => this.embassyApi.dryUpdatePackage({ id, version }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryUpdatePackage({ id, version })
.then(breakages => breakages),
},
},
bottomBar: {
cancel: {
whileLoading: { },
whileLoading: {},
afterLoading: { text: 'Cancel' },
},
next: 'Downgrade Anyway',
},
},
{ slide: {
{
slide: {
selector: 'complete',
params: {
action,
verb: 'beginning downgrade for',
title,
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }),
executeAction: () =>
this.embassyApi.installPackage({
id,
'version-spec': version ? `=${version}` : undefined,
}),
},
},
bottomBar: {
cancel: { whileLoading: { } },
cancel: { whileLoading: {} },
finish: 'Dismiss',
},
},
@@ -186,7 +215,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
uninstall (values: {
uninstall(values: {
id: string
title: string
version: string
@@ -195,7 +224,7 @@ export class WizardBaker {
const { id, title, version, uninstallAlert } = values
const action = 'uninstall'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
@@ -211,7 +240,8 @@ export class WizardBaker {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Continue' },
next: 'Continue',
},
},
{
slide: {
@@ -220,15 +250,19 @@ export class WizardBaker {
action,
verb: 'uninstalling',
title,
fetchBreakages: () => this.embassyApi.dryUninstallPackage({ id }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryUninstallPackage({ id })
.then(breakages => breakages),
},
},
bottomBar: {
cancel: {
whileLoading: { },
whileLoading: {},
afterLoading: { text: 'Cancel' },
},
next: 'Uninstall' },
next: 'Uninstall',
},
},
{
slide: {
@@ -243,7 +277,7 @@ export class WizardBaker {
bottomBar: {
finish: 'Dismiss',
cancel: {
whileLoading: { },
whileLoading: {},
},
},
},
@@ -251,7 +285,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
stop (values: {
stop(values: {
id: string
title: string
version: string
@@ -259,7 +293,7 @@ export class WizardBaker {
const { title, version, id } = values
const action = 'stop'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
@@ -269,12 +303,15 @@ export class WizardBaker {
action,
verb: 'stopping',
title,
fetchBreakages: () => this.embassyApi.dryStopPackage({ id }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryStopPackage({ id })
.then(breakages => breakages),
},
},
bottomBar: {
cancel: {
whileLoading: { },
whileLoading: {},
afterLoading: { text: 'Cancel' },
},
next: 'Stop Service',
@@ -293,7 +330,7 @@ export class WizardBaker {
bottomBar: {
finish: 'Dismiss',
cancel: {
whileLoading: { },
whileLoading: {},
},
},
},
@@ -301,14 +338,14 @@ export class WizardBaker {
return { toolbar, slideDefinitions }
}
configure (values: {
configure(values: {
pkg: PackageDataEntry
breakages: Breakages
}): InstallWizardComponent['params'] {
const { breakages, pkg } = values
const { title, version } = pkg.manifest
const action = 'configure'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
@@ -317,18 +354,21 @@ export class WizardBaker {
params: {
action,
verb: 'saving config for',
title, fetchBreakages: () => Promise.resolve(breakages),
title,
fetchBreakages: () => Promise.resolve(breakages),
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Save Config Anyway' },
next: 'Save Config Anyway',
},
},
]
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 { exists, isEmptyObject } from 'src/app/util/misc.util'
import { EOSService } from 'src/app/services/eos.service'
import { ConfigService } from 'src/app/services/config.service'
@Component({
selector: 'server-show',
@@ -36,6 +37,7 @@ export class ServerShowPage {
private readonly embassyApi: ApiService,
private readonly navCtrl: NavController,
private readonly route: ActivatedRoute,
private readonly config: ConfigService,
public readonly eosService: EOSService,
public readonly patch: PatchDbService,
) {}
@@ -153,7 +155,9 @@ export class ServerShowPage {
await loader.present()
try {
await this.embassyApi.restartServer({})
await this.embassyApi.restartServer({
'marketplace-url': this.config.marketplace.url,
})
} catch (e) {
this.errToast.present(e)
} finally {

View File

@@ -38,7 +38,7 @@ export module RR {
export type GetServerMetricsReq = {} // server.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 RestartServerReq = {} // server.restart