mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
reg test
This commit is contained in:
committed by
Aiden McClelland
parent
edc37e33f1
commit
dc71a625b2
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
/*.img
|
/*.img
|
||||||
/buster.zip
|
/buster.zip
|
||||||
/product_key
|
/product_key
|
||||||
|
config.json
|
||||||
@@ -42,7 +42,8 @@ Then open `patch-db`, `ws-example`, and `embassy-os`, in separate tabs.
|
|||||||
|
|
||||||
`npm i`
|
`npm i`
|
||||||
|
|
||||||
In `ui-config.json`, edit the "mocks" section to look like the following:
|
Copy `config-sample.json` to new file `config.json`
|
||||||
|
In `config.json`, edit the "mocks" section to look like the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
"mocks": {
|
"mocks": {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"rpcPort": "5959",
|
"rpcPort": "5959",
|
||||||
"wsPort": "5960",
|
"wsPort": "5960",
|
||||||
"maskAs": "tor",
|
"maskAs": "tor",
|
||||||
"skipStartupAlerts": true
|
"skipStartupAlerts": true,
|
||||||
|
"registryURL": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,9 @@ import { DataModel, PackageDataEntry, PackageMainStatus, PackageState, ServerSta
|
|||||||
import { RR } from './api-types'
|
import { RR } from './api-types'
|
||||||
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
||||||
import { Mock } from './mock-app-fixures'
|
import { Mock } from './mock-app-fixures'
|
||||||
import { HttpService } from '../http.service'
|
import { HttpService, Method } from '../http.service'
|
||||||
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
|
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
|
||||||
|
import { ConfigService } from '../config.service'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MockApiService extends ApiService {
|
export class MockApiService extends ApiService {
|
||||||
@@ -17,6 +18,7 @@ export class MockApiService extends ApiService {
|
|||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private readonly http: HttpService,
|
private readonly http: HttpService,
|
||||||
|
private readonly configService: ConfigService,
|
||||||
) { super() }
|
) { super() }
|
||||||
|
|
||||||
// every time a patch is returned from the mock, we override its sequence to be 1 more than the last sequence in the patch-db as provided by `o`.
|
// every time a patch is returned from the mock, we override its sequence to be 1 more than the last sequence in the patch-db as provided by `o`.
|
||||||
@@ -472,26 +474,53 @@ export class MockApiService extends ApiService {
|
|||||||
// marketplace
|
// marketplace
|
||||||
|
|
||||||
async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise<RR.GetMarketplaceDataRes> {
|
async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise<RR.GetMarketplaceDataRes> {
|
||||||
|
const registryURL = this.configService.mocks.registryURL
|
||||||
|
if(!registryURL) {
|
||||||
await pauseFor(2000)
|
await pauseFor(2000)
|
||||||
return {
|
return {
|
||||||
categories: ['featured', 'bitcoin', 'lightning', 'data', 'messaging', 'social', 'alt coin'],
|
categories: ['featured', 'bitcoin', 'lightning', 'data', 'messaging', 'social', 'alt coin'],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const url = `${registryURL}/marketplace/data`
|
||||||
|
let md = await this.http.simpleGet(url)
|
||||||
|
return (md as any)
|
||||||
|
}
|
||||||
|
|
||||||
async getEos (params: RR.GetMarketplaceEOSReq): Promise<RR.GetMarketplaceEOSRes> {
|
async getEos (params: RR.GetMarketplaceEOSReq): Promise<RR.GetMarketplaceEOSRes> {
|
||||||
|
const registryURL = this.configService.mocks.registryURL
|
||||||
|
if(!registryURL) {
|
||||||
|
await pauseFor(2000)
|
||||||
|
return Mock.MarketplaceEos
|
||||||
|
}
|
||||||
|
const url = `${registryURL}/sys/version/eos`
|
||||||
|
let eos = await this.http.simpleGet(url)
|
||||||
|
return (eos as any)
|
||||||
await pauseFor(2000)
|
await pauseFor(2000)
|
||||||
return Mock.MarketplaceEos
|
return Mock.MarketplaceEos
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAvailableList (params: RR.GetAvailableListReq): Promise<RR.GetAvailableListRes> {
|
async getAvailableList (params: RR.GetAvailableListReq): Promise<RR.GetAvailableListRes> {
|
||||||
|
const registryURL = this.configService.mocks.registryURL
|
||||||
|
if(!registryURL) {
|
||||||
await pauseFor(2000)
|
await pauseFor(2000)
|
||||||
return Mock.AvailableList
|
return Mock.AvailableList
|
||||||
}
|
}
|
||||||
|
const url = `${registryURL}/marketplace/available/list?category=${params.category || 'featured'}&per-page=${params['per-page'] || '20'}&page=${params.page || '1'}&query=${params.query || ''}`
|
||||||
|
let av = await this.http.simpleGet(url)
|
||||||
|
return (av as any)
|
||||||
|
}
|
||||||
|
|
||||||
async getAvailableShow (params: RR.GetAvailableShowReq): Promise<RR.GetAvailableShowRes> {
|
async getAvailableShow (params: RR.GetAvailableShowReq): Promise<RR.GetAvailableShowRes> {
|
||||||
|
const registryURL = this.configService.mocks.registryURL
|
||||||
|
if(!registryURL) {
|
||||||
await pauseFor(2000)
|
await pauseFor(2000)
|
||||||
return Mock.AvailableShow[params.id][params.version || 'latest']
|
return Mock.AvailableShow[params.id][params.version || 'latest']
|
||||||
}
|
}
|
||||||
|
const url = `${registryURL}/marketplace/available?id=${params.id}&version=${params.version || '1.3.0'}`
|
||||||
|
let res = await this.http.simpleGet(url)
|
||||||
|
console.log('res RES RES', res)
|
||||||
|
return (res as any)
|
||||||
|
}
|
||||||
|
|
||||||
private nextSequence () {
|
private nextSequence () {
|
||||||
console.log('next')
|
console.log('next')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { InstalledPackageDataEntry, InterfaceDef, Manifest, PackageDataEntry, PackageMainStatus, PackageState } from './patch-db/data-model'
|
import { InstalledPackageDataEntry, InterfaceDef, Manifest, PackageDataEntry, PackageMainStatus, PackageState } from './patch-db/data-model'
|
||||||
|
|
||||||
const { patchDb, api, mocks } = require('../../../ui-config.json') as UiConfig
|
const { patchDb, api, mocks } = require('../../../config.json') as UiConfig
|
||||||
|
|
||||||
type UiConfig = {
|
type UiConfig = {
|
||||||
patchDb: {
|
patchDb: {
|
||||||
@@ -20,6 +20,7 @@ type UiConfig = {
|
|||||||
wsPort: number
|
wsPort: number
|
||||||
maskAs: 'tor' | 'lan'
|
maskAs: 'tor' | 'lan'
|
||||||
skipStartupAlerts: boolean
|
skipStartupAlerts: boolean
|
||||||
|
registryURL: String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ export class HttpService {
|
|||||||
if (isRpcSuccess(res)) return res.result
|
if (isRpcSuccess(res)) return res.result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async simpleGet (url: string): Promise<object> {
|
||||||
|
const data = await this.http.get(url).toPromise()
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
async httpRequest<T> (httpOpts: HttpOptions): Promise<T> {
|
async httpRequest<T> (httpOpts: HttpOptions): Promise<T> {
|
||||||
let { body, timeout, ...rest} = this.translateOptions(httpOpts)
|
let { body, timeout, ...rest} = this.translateOptions(httpOpts)
|
||||||
let req: Observable<{ body: T }>
|
let req: Observable<{ body: T }>
|
||||||
|
|||||||
Reference in New Issue
Block a user