mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
config actions and eos version marketplace
This commit is contained in:
committed by
Aiden McClelland
parent
54a65e465a
commit
bb72bdb9d1
@@ -56,15 +56,7 @@ export class AppActionsPage {
|
|||||||
|
|
||||||
async handleAction (action: { key: string, value: Action }) {
|
async handleAction (action: { key: string, value: Action }) {
|
||||||
const status = this.pkg.installed.status
|
const status = this.pkg.installed.status
|
||||||
if (!status.configured) {
|
if ((action.value['allowed-statuses'] as PackageMainStatus[]).includes(status.main.status)) {
|
||||||
const alert = await this.alertCtrl.create({
|
|
||||||
header: 'Forbidden',
|
|
||||||
message: `Service must be properly configured in order to run "${action.value.name}"`,
|
|
||||||
buttons: ['OK'],
|
|
||||||
cssClass: 'alert-error-message enter-click',
|
|
||||||
})
|
|
||||||
await alert.present()
|
|
||||||
} else if ((action.value['allowed-statuses'] as PackageMainStatus[]).includes(status.main.status)) {
|
|
||||||
if (!isEmptyObject(action.value['input-spec'])) {
|
if (!isEmptyObject(action.value['input-spec'])) {
|
||||||
const modal = await this.modalCtrl.create({
|
const modal = await this.modalCtrl.create({
|
||||||
component: GenericFormPage,
|
component: GenericFormPage,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { MarketplaceData, MarketplaceEOS, MarketplacePkg } from 'src/app/services/api/api.types'
|
import { MarketplaceData, MarketplaceEOS, MarketplacePkg } from 'src/app/services/api/api.types'
|
||||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||||
|
import { ConfigService } from 'src/app/services/config.service'
|
||||||
import { Emver } from 'src/app/services/emver.service'
|
import { Emver } from 'src/app/services/emver.service'
|
||||||
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
|
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
|
||||||
|
|
||||||
@@ -18,12 +19,15 @@ export class MarketplaceService {
|
|||||||
constructor (
|
constructor (
|
||||||
private readonly api: ApiService,
|
private readonly api: ApiService,
|
||||||
private readonly emver: Emver,
|
private readonly emver: Emver,
|
||||||
|
private readonly config: ConfigService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
async load (): Promise<void> {
|
async load (): Promise<void> {
|
||||||
const [data, eos, pkgs] = await Promise.all([
|
const [data, eos, pkgs] = await Promise.all([
|
||||||
this.api.getMarketplaceData({ }),
|
this.api.getMarketplaceData({ }),
|
||||||
this.api.getEos({ }),
|
this.api.getEos({
|
||||||
|
'eos-version': this.config.version,
|
||||||
|
}),
|
||||||
this.getPkgs(1, 100),
|
this.getPkgs(1, 100),
|
||||||
])
|
])
|
||||||
this.data = data
|
this.data = data
|
||||||
@@ -35,6 +39,7 @@ export class MarketplaceService {
|
|||||||
const idAndCurrentVersions = Object.keys(localPkgs).map(key => ({ id: key, version: localPkgs[key].manifest.version }))
|
const idAndCurrentVersions = Object.keys(localPkgs).map(key => ({ id: key, version: localPkgs[key].manifest.version }))
|
||||||
const latestPkgs = await this.api.getMarketplacePkgs({
|
const latestPkgs = await this.api.getMarketplacePkgs({
|
||||||
ids: idAndCurrentVersions,
|
ids: idAndCurrentVersions,
|
||||||
|
'eos-version': this.config.version,
|
||||||
})
|
})
|
||||||
|
|
||||||
return latestPkgs.filter(latestPkg => {
|
return latestPkgs.filter(latestPkg => {
|
||||||
@@ -47,6 +52,7 @@ export class MarketplaceService {
|
|||||||
async getPkg (id: string, version?: string): Promise<MarketplacePkg> {
|
async getPkg (id: string, version?: string): Promise<MarketplacePkg> {
|
||||||
const pkgs = await this.api.getMarketplacePkgs({
|
const pkgs = await this.api.getMarketplacePkgs({
|
||||||
ids: [{ id, version: version || '*' }],
|
ids: [{ id, version: version || '*' }],
|
||||||
|
'eos-version': this.config.version,
|
||||||
})
|
})
|
||||||
const pkg = pkgs.find(pkg => pkg.manifest.id == id)
|
const pkg = pkgs.find(pkg => pkg.manifest.id == id)
|
||||||
|
|
||||||
@@ -65,6 +71,7 @@ export class MarketplaceService {
|
|||||||
const pkgs = await this.api.getMarketplacePkgs({
|
const pkgs = await this.api.getMarketplacePkgs({
|
||||||
page: String(page),
|
page: String(page),
|
||||||
'per-page': String(perPage),
|
'per-page': String(perPage),
|
||||||
|
'eos-version': this.config.version,
|
||||||
})
|
})
|
||||||
|
|
||||||
return pkgs
|
return pkgs
|
||||||
|
|||||||
@@ -193,12 +193,15 @@ export module RR {
|
|||||||
export type GetMarketplaceDataReq = { }
|
export type GetMarketplaceDataReq = { }
|
||||||
export type GetMarketplaceDataRes = MarketplaceData
|
export type GetMarketplaceDataRes = MarketplaceData
|
||||||
|
|
||||||
export type GetMarketplaceEOSReq = { }
|
export type GetMarketplaceEOSReq = {
|
||||||
|
'eos-version': string
|
||||||
|
}
|
||||||
export type GetMarketplaceEOSRes = MarketplaceEOS
|
export type GetMarketplaceEOSRes = MarketplaceEOS
|
||||||
|
|
||||||
export type GetMarketplacePackagesReq = {
|
export type GetMarketplacePackagesReq = {
|
||||||
ids?: { id: string, version: string }[]
|
ids?: { id: string, version: string }[]
|
||||||
// iff !id
|
// iff !id
|
||||||
|
'eos-version': string
|
||||||
category?: string
|
category?: string
|
||||||
query?: string
|
query?: string
|
||||||
page?: string
|
page?: string
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ export class StartupAlertsService {
|
|||||||
// ** check **
|
// ** check **
|
||||||
|
|
||||||
private async osUpdateCheck (): Promise<RR.GetMarketplaceEOSRes | undefined> {
|
private async osUpdateCheck (): Promise<RR.GetMarketplaceEOSRes | undefined> {
|
||||||
const res = await this.api.getEos({ })
|
const res = await this.api.getEos({
|
||||||
|
'eos-version': this.config.version,
|
||||||
|
})
|
||||||
|
|
||||||
if (this.emver.compare(this.config.version, res.version) === -1) {
|
if (this.emver.compare(this.config.version, res.version) === -1) {
|
||||||
return res
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user