mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
rework endpoints and enable setting custom marketplace urls
This commit is contained in:
committed by
Aiden McClelland
parent
16f5764f74
commit
6d92c195e9
@@ -10,7 +10,6 @@ import { MarketplaceService } from '../marketplace.service'
|
||||
})
|
||||
export class AppReleaseNotes {
|
||||
@ViewChild(IonContent) content: IonContent
|
||||
error = ''
|
||||
selected: string
|
||||
pkgId: string
|
||||
|
||||
@@ -22,8 +21,8 @@ export class AppReleaseNotes {
|
||||
ngOnInit () {
|
||||
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
const version = this.route.snapshot.paramMap.get('version')
|
||||
if (!this.marketplaceService.pkgs[this.pkgId]) {
|
||||
this.marketplaceService.setPkg(this.pkgId, version)
|
||||
if (!this.marketplaceService.pkgs[this.pkgId]?.['release-notes']) {
|
||||
this.marketplaceService.getPkg(this.pkgId, version)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,17 +46,17 @@
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col *ngFor="let pkg of pkgs" sizeXs="12" sizeSm="12" sizeMd="6">
|
||||
<ion-item [routerLink]="['/marketplace', pkg.id]">
|
||||
<ion-item [routerLink]="['/marketplace', pkg.manifest.id]">
|
||||
<ion-thumbnail slot="start">
|
||||
<img [src]="pkg.icon" />
|
||||
</ion-thumbnail>
|
||||
<ion-label>
|
||||
<h2 style="font-family: 'Montserrat';">{{ pkg.title }}</h2>
|
||||
<p>{{ pkg.descriptionShort }}</p>
|
||||
<h2 style="font-family: 'Montserrat';">{{ pkg.manifest.title }}</h2>
|
||||
<p>{{ pkg.manifest.description.short }}</p>
|
||||
<ng-container *ngIf="patch.data['package-data'][pkg.id] as localPkg">
|
||||
<p *ngIf="localPkg.state === PackageState.Installed">
|
||||
<ion-text *ngIf="(pkg.version | compareEmver : localPkg.manifest.version) === 0" color="success">Installed</ion-text>
|
||||
<ion-text *ngIf="(pkg.version | compareEmver : localPkg.manifest.version) === 1" color="warning">Update Available</ion-text>
|
||||
<ion-text *ngIf="(pkg.manifest.version | compareEmver : localPkg.manifest.version) === 0" color="success">Installed</ion-text>
|
||||
<ion-text *ngIf="(pkg.manifest.version | compareEmver : localPkg.manifest.version) === 1" color="warning">Update Available</ion-text>
|
||||
</p>
|
||||
<p *ngIf="localPkg.state === PackageState.Installing" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<ion-text color="primary">Installing</ion-text>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Component, ViewChild } from '@angular/core'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
import { MarketplaceData, MarketplaceEOS, AvailablePreview } from 'src/app/services/api/api-types'
|
||||
import { MarketplaceData, MarketplaceEOS, MarketplacePkg } from 'src/app/services/api/api-types'
|
||||
import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component'
|
||||
import { IonContent, ModalController } from '@ionic/angular'
|
||||
import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
|
||||
@@ -8,6 +7,7 @@ import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service'
|
||||
import { PackageState } from 'src/app/services/patch-db/data-model'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
||||
import { MarketplaceService } from '../marketplace.service'
|
||||
|
||||
@Component({
|
||||
selector: 'marketplace-list',
|
||||
@@ -24,7 +24,7 @@ export class MarketplaceListPage {
|
||||
|
||||
data: MarketplaceData
|
||||
eos: MarketplaceEOS
|
||||
pkgs: AvailablePreview[] = []
|
||||
pkgs: MarketplacePkg[] = []
|
||||
|
||||
PackageState = PackageState
|
||||
|
||||
@@ -35,7 +35,7 @@ export class MarketplaceListPage {
|
||||
subs: Subscription[] = []
|
||||
|
||||
constructor (
|
||||
private readonly apiService: ApiService,
|
||||
private readonly marketplaceService: MarketplaceService,
|
||||
private readonly modalCtrl: ModalController,
|
||||
private readonly errToast: ErrorToastService,
|
||||
private readonly wizardBaker: WizardBaker,
|
||||
@@ -46,8 +46,8 @@ export class MarketplaceListPage {
|
||||
|
||||
try {
|
||||
const [data, eos, pkgs] = await Promise.all([
|
||||
this.apiService.getMarketplaceData({ }),
|
||||
this.apiService.getEos({ }),
|
||||
this.marketplaceService.getMarketplaceData(),
|
||||
this.marketplaceService.getEos(),
|
||||
this.getPkgs(),
|
||||
])
|
||||
this.data = data
|
||||
@@ -94,14 +94,14 @@ export class MarketplaceListPage {
|
||||
)
|
||||
}
|
||||
|
||||
private async getPkgs (): Promise<AvailablePreview[]> {
|
||||
private async getPkgs (): Promise<MarketplacePkg[]> {
|
||||
try {
|
||||
const pkgs = await this.apiService.getAvailableList({
|
||||
category: this.category !== 'all' ? this.category : undefined,
|
||||
query: this.query,
|
||||
page: this.page,
|
||||
'per-page': this.perPage,
|
||||
})
|
||||
const pkgs = await this.marketplaceService.getPkgs(
|
||||
this.category !== 'all' ? this.category : undefined,
|
||||
this.query,
|
||||
this.page,
|
||||
this.perPage,
|
||||
)
|
||||
this.needInfinite = pkgs.length >= this.perPage
|
||||
this.page++
|
||||
return pkgs
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, ViewChild } from '@angular/core'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { AlertController, IonContent, ModalController, NavController, ToastController } from '@ionic/angular'
|
||||
import { AlertController, IonContent, ModalController, NavController } from '@ionic/angular'
|
||||
import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component'
|
||||
import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
|
||||
import { Emver } from 'src/app/services/emver.service'
|
||||
@@ -51,8 +51,9 @@ export class MarketplaceShowPage {
|
||||
this.installedPkg = pkg
|
||||
}),
|
||||
]
|
||||
|
||||
this.getPkg()
|
||||
if (!this.marketplaceService.pkgs[this.pkgId]) {
|
||||
this.getPkg()
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit () {
|
||||
@@ -65,7 +66,7 @@ export class MarketplaceShowPage {
|
||||
|
||||
async getPkg (version?: string): Promise<void> {
|
||||
try {
|
||||
await this.marketplaceService.setPkg(this.pkgId, version)
|
||||
await this.marketplaceService.getPkg(this.pkgId, version)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
this.errToast.present(e.message)
|
||||
@@ -117,7 +118,7 @@ export class MarketplaceShowPage {
|
||||
}
|
||||
|
||||
async install () {
|
||||
const { id, title, version, dependencies, alerts } = this.marketplaceService.pkgs[this.pkgId].manifest
|
||||
const { id, title, version, alerts } = this.marketplaceService.pkgs[this.pkgId].manifest
|
||||
const { cancelled } = await wizardModal(
|
||||
this.modalCtrl,
|
||||
this.wizardBaker.install({
|
||||
|
||||
@@ -1,20 +1,53 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { AvailableShow } from 'src/app/services/api/api-types'
|
||||
import { MarketplacePkg } from 'src/app/services/api/api-types'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MarketplaceService {
|
||||
pkgs: { [id: string]: AvailableShow } = { }
|
||||
additionalInfo
|
||||
pkgs: { [id: string]: MarketplacePkg } = { }
|
||||
releaseNotes: { [id: string]: {
|
||||
[version: string]: string
|
||||
} }
|
||||
|
||||
constructor (
|
||||
private readonly apiService: ApiService,
|
||||
) { }
|
||||
|
||||
async setPkg (id: string, version?: string): Promise<void> {
|
||||
this.pkgs[id] = await this.apiService.getAvailableShow({ id, version })
|
||||
async getMarketplaceData () {
|
||||
return this.apiService.getMarketplaceData({ })
|
||||
}
|
||||
|
||||
async getEos () {
|
||||
return this.apiService.getEos({ })
|
||||
}
|
||||
|
||||
async getPkgs (category: string, query: string, page: number, perPage: number) : Promise<MarketplacePkg[]> {
|
||||
const pkgs = await this.apiService.getMarketplacePkgs({
|
||||
category: category !== 'all' ? category : undefined,
|
||||
query,
|
||||
page: String(page),
|
||||
'per-page': String(perPage),
|
||||
})
|
||||
this.pkgs = pkgs.reduce((cur, val) => {
|
||||
cur[val.manifest.id] = val
|
||||
return cur
|
||||
}, { })
|
||||
return pkgs
|
||||
}
|
||||
|
||||
async getPkg (id: string, version?: string): Promise<void> {
|
||||
const pkg = (await this.apiService.getMarketplacePkgs({ id, version }))[0]
|
||||
if (pkg) {
|
||||
this.pkgs[id] = pkg
|
||||
} else {
|
||||
throw new Error(`No results for ${id}${version ? ' ' + version : ''}.`)
|
||||
}
|
||||
}
|
||||
|
||||
async getReleaseNotes (id: string): Promise<void> {
|
||||
this.releaseNotes[id] = await this.apiService.getReleaseNotes({ id })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
<ion-item detail="true" button [routerLink]="['ssh-keys']">
|
||||
<ion-label>SSH Keys</ion-label>
|
||||
</ion-item>
|
||||
<ion-item button (click)="presentModalValueEdit('registry', server.registry)">
|
||||
<ion-label>Marketplace URL</ion-label>
|
||||
<ion-note slot="end">{{ server.registry }}</ion-note>
|
||||
</ion-item>
|
||||
</ion-item-group>
|
||||
|
||||
</ion-content>
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { ServerConfigService } from 'src/app/services/server-config.service'
|
||||
import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service'
|
||||
import { ServerInfo } from 'src/app/services/patch-db/data-model'
|
||||
import { Subscription } from 'rxjs'
|
||||
|
||||
@Component({
|
||||
selector: 'dev-options',
|
||||
@@ -10,7 +8,6 @@ import { Subscription } from 'rxjs'
|
||||
styleUrls: ['./dev-options.page.scss'],
|
||||
})
|
||||
export class DevOptionsPage {
|
||||
subs: Subscription[] = []
|
||||
|
||||
constructor (
|
||||
private readonly serverConfigService: ServerConfigService,
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<pwa-back-button></pwa-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Preferences</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding-top">
|
||||
|
||||
<ion-item-group>
|
||||
<ion-item button (click)="presentModalValueEdit('autoCheckUpdates', patch.data.ui['auto-check-updates'])">
|
||||
<ion-label>Auto Check for Updates</ion-label>
|
||||
<ion-note slot="end">{{ patch.data.ui['auto-check-updates'] }}</ion-note>
|
||||
</ion-item>
|
||||
</ion-item-group>
|
||||
|
||||
</ion-content>
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NgModule } from '@angular/core'
|
||||
import { CommonModule } from '@angular/common'
|
||||
import { IonicModule } from '@ionic/angular'
|
||||
import { PreferencesPage } from './preferences.page'
|
||||
import { PrivacyPage } from './privacy.page'
|
||||
import { Routes, RouterModule } from '@angular/router'
|
||||
import { SharingModule } from 'src/app/modules/sharing.module'
|
||||
import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module'
|
||||
@@ -9,7 +9,7 @@ import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-b
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: PreferencesPage,
|
||||
component: PrivacyPage,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -22,7 +22,7 @@ const routes: Routes = [
|
||||
PwaBackComponentModule,
|
||||
],
|
||||
declarations: [
|
||||
PreferencesPage,
|
||||
PrivacyPage,
|
||||
],
|
||||
})
|
||||
export class PreferencesPageModule { }
|
||||
export class PrivacyPageModule { }
|
||||
34
ui/src/app/pages/server-routes/privacy/privacy.page.html
Normal file
34
ui/src/app/pages/server-routes/privacy/privacy.page.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<pwa-back-button></pwa-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Privacy and Security</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding-top">
|
||||
|
||||
<ion-item-group>
|
||||
<ion-item-divider>Marketplace Settings</ion-item-divider>
|
||||
<ion-item button (click)="presentModalValueEdit('eosMarketplace', patch.data['server-info']['eos-marketplace'])">
|
||||
<ion-label>Use Tor</ion-label>
|
||||
<ion-note slot="end">{{ patch.data['server-info']['eos-marketplace'] === config.start9Marketplace.tor }}</ion-note>
|
||||
</ion-item>
|
||||
<ion-item button (click)="presentModalValueEdit('packageMarketplace', patch.data['server-info']['package-marketplace'])">
|
||||
<ion-label>Package Marketplace</ion-label>
|
||||
<ion-note slot="end">{{ patch.data['server-info']['package-marketplace'] }}</ion-note>
|
||||
</ion-item>
|
||||
<ion-item button (click)="presentModalValueEdit('autoCheckUpdates', patch.data.ui['auto-check-updates'])">
|
||||
<ion-label>Auto Check for Updates</ion-label>
|
||||
<ion-note slot="end">{{ patch.data.ui['auto-check-updates'] }}</ion-note>
|
||||
</ion-item>
|
||||
|
||||
<ion-item-divider></ion-item-divider>
|
||||
<ion-item button (click)="presentModalValueEdit('password')">
|
||||
<ion-label>Change Password</ion-label>
|
||||
<ion-note slot="end">********</ion-note>
|
||||
</ion-item>
|
||||
</ion-item-group>
|
||||
|
||||
</ion-content>
|
||||
@@ -2,17 +2,19 @@ import { Component } from '@angular/core'
|
||||
import { ServerConfigService } from 'src/app/services/server-config.service'
|
||||
import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { ConfigService } from 'src/app/services/config.service'
|
||||
|
||||
@Component({
|
||||
selector: 'preferences',
|
||||
templateUrl: './preferences.page.html',
|
||||
styleUrls: ['./preferences.page.scss'],
|
||||
selector: 'privacy',
|
||||
templateUrl: './privacy.page.html',
|
||||
styleUrls: ['./privacy.page.scss'],
|
||||
})
|
||||
export class PreferencesPage {
|
||||
export class PrivacyPage {
|
||||
subs: Subscription[] = []
|
||||
|
||||
constructor (
|
||||
private readonly serverConfigService: ServerConfigService,
|
||||
public readonly config: ConfigService,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
@@ -23,12 +23,8 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./server-logs/server-logs.module').then(m => m.ServerLogsPageModule),
|
||||
},
|
||||
{
|
||||
path: 'preferences',
|
||||
loadChildren: () => import('./preferences/preferences.module').then(m => m.PreferencesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'preferences/edit',
|
||||
loadChildren: () => import('./preferences/preferences.module').then(m => m.PreferencesPageModule),
|
||||
path: 'privacy',
|
||||
loadChildren: () => import('./privacy/privacy.module').then(m => m.PrivacyPageModule),
|
||||
},
|
||||
{
|
||||
path: 'wifi',
|
||||
|
||||
Reference in New Issue
Block a user