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

@@ -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 {

View File

@@ -3,12 +3,18 @@ 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: {
@@ -23,7 +29,8 @@ export class WizardBaker {
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
installAlert ? { installAlert
? {
slide: { slide: {
selector: 'alert', selector: 'alert',
params: { params: {
@@ -38,7 +45,8 @@ export class WizardBaker {
}, },
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,7 +74,11 @@ 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: {
@@ -111,7 +126,10 @@ 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: {
@@ -135,7 +153,8 @@ export class WizardBaker {
const toolbar: TopbarParams = { action, title, version } const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [ const slideDefinitions: SlideDefinition[] = [
installAlert ? { installAlert
? {
slide: { slide: {
selector: 'alert', selector: 'alert',
params: { params: {
@@ -150,14 +169,19 @@ export class WizardBaker {
}, },
next: 'Next', next: 'Next',
}, },
} : undefined, }
{ slide: { : 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: {
@@ -168,13 +192,18 @@ export class WizardBaker {
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: {
@@ -211,7 +240,8 @@ export class WizardBaker {
cancel: { cancel: {
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Continue' }, next: 'Continue',
},
}, },
{ {
slide: { slide: {
@@ -220,7 +250,10 @@ 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: {
@@ -228,7 +261,8 @@ export class WizardBaker {
whileLoading: {}, whileLoading: {},
afterLoading: { text: 'Cancel' }, afterLoading: { text: 'Cancel' },
}, },
next: 'Uninstall' }, next: 'Uninstall',
},
}, },
{ {
slide: { slide: {
@@ -269,7 +303,10 @@ 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: {
@@ -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