mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-02 05:23:14 +00:00
fix marketplace search and better category disabling (#1991)
* fix marketplace search and better category disabling * bump marketplace version * fix issue with marketplace settings and absent community reg
This commit is contained in:
committed by
Aiden McClelland
parent
f9a4699e84
commit
ccb85737f7
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@start9labs/marketplace",
|
"name": "@start9labs/marketplace",
|
||||||
"version": "0.3.6",
|
"version": "0.3.7",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/common": ">=13.2.0",
|
"@angular/common": ">=13.2.0",
|
||||||
"@angular/core": ">=13.2.0",
|
"@angular/core": ">=13.2.0",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
*ngFor="let cat of categories"
|
*ngFor="let cat of categories"
|
||||||
fill="clear"
|
fill="clear"
|
||||||
class="category"
|
class="category"
|
||||||
[class.category_selected]="cat === category && !disableCategories"
|
[class.category_selected]="cat === category"
|
||||||
(click)="switchCategory(cat)"
|
(click)="switchCategory(cat)"
|
||||||
>
|
>
|
||||||
{{ cat }}
|
{{ cat }}
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ export class CategoriesComponent {
|
|||||||
@Input()
|
@Input()
|
||||||
category = ''
|
category = ''
|
||||||
|
|
||||||
@Input()
|
|
||||||
disableCategories = false
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
readonly categoryChange = new EventEmitter<string>()
|
readonly categoryChange = new EventEmitter<string>()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { NgModule, Pipe, PipeTransform } from '@angular/core'
|
import { NgModule, Pipe, PipeTransform } from '@angular/core'
|
||||||
import { Emver } from '@start9labs/shared'
|
|
||||||
import { MarketplacePkg } from '../types'
|
import { MarketplacePkg } from '../types'
|
||||||
import Fuse from 'fuse.js'
|
import Fuse from 'fuse.js'
|
||||||
|
|
||||||
@@ -7,8 +6,6 @@ import Fuse from 'fuse.js'
|
|||||||
name: 'filterPackages',
|
name: 'filterPackages',
|
||||||
})
|
})
|
||||||
export class FilterPackagesPipe implements PipeTransform {
|
export class FilterPackagesPipe implements PipeTransform {
|
||||||
constructor(private readonly emver: Emver) {}
|
|
||||||
|
|
||||||
transform(
|
transform(
|
||||||
packages: MarketplacePkg[],
|
packages: MarketplacePkg[],
|
||||||
query: string,
|
query: string,
|
||||||
@@ -19,29 +16,51 @@ export class FilterPackagesPipe implements PipeTransform {
|
|||||||
let options: Fuse.IFuseOptions<MarketplacePkg> = {
|
let options: Fuse.IFuseOptions<MarketplacePkg> = {
|
||||||
includeScore: true,
|
includeScore: true,
|
||||||
includeMatches: true,
|
includeMatches: true,
|
||||||
ignoreLocation: true,
|
|
||||||
useExtendedSearch: true,
|
|
||||||
keys: [
|
|
||||||
{
|
|
||||||
name: 'manifest.title',
|
|
||||||
weight: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'manifest.id',
|
|
||||||
weight: 0.5,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'manifest.description.short',
|
|
||||||
weight: 0.4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'manifest.description.long',
|
|
||||||
weight: 0.1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
query = `'${query}`
|
if (query.length < 4) {
|
||||||
|
options = {
|
||||||
|
...options,
|
||||||
|
threshold: 0.2,
|
||||||
|
location: 0,
|
||||||
|
distance: 16,
|
||||||
|
keys: [
|
||||||
|
{
|
||||||
|
name: 'manifest.title',
|
||||||
|
weight: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'manifest.id',
|
||||||
|
weight: 0.5,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options = {
|
||||||
|
...options,
|
||||||
|
ignoreLocation: true,
|
||||||
|
useExtendedSearch: true,
|
||||||
|
keys: [
|
||||||
|
{
|
||||||
|
name: 'manifest.title',
|
||||||
|
weight: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'manifest.id',
|
||||||
|
weight: 0.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'manifest.description.short',
|
||||||
|
weight: 0.4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'manifest.description.long',
|
||||||
|
weight: 0.1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
query = `'${query}`
|
||||||
|
}
|
||||||
|
|
||||||
const fuse = new Fuse(packages, options)
|
const fuse = new Fuse(packages, options)
|
||||||
return fuse.search(query).map(p => p.item)
|
return fuse.search(query).map(p => p.item)
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ export class MarketplaceSettingsPage {
|
|||||||
this.marketplaceService.getSelectedHost$(),
|
this.marketplaceService.getSelectedHost$(),
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([stores, selected]) => {
|
map(([stores, selected]) => {
|
||||||
const hmmm = stores.map(s => ({
|
const toSlice = stores.map(s => ({
|
||||||
...s,
|
...s,
|
||||||
selected: s.url === selected.url,
|
selected: s.url === selected.url,
|
||||||
}))
|
}))
|
||||||
// 0 and 1 are prod and community
|
// 0 and 1 are prod and community
|
||||||
const standard = hmmm.slice(0, 2)
|
const standard = toSlice.slice(0, 1)
|
||||||
// 2 and beyond are alts
|
// 2 and beyond are alts
|
||||||
const alt = hmmm.slice(2)
|
const alt = toSlice.slice(1)
|
||||||
|
|
||||||
return { standard, alt }
|
return { standard, alt }
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -38,8 +38,7 @@
|
|||||||
<ng-container *ngIf="store$ | async as store; else loading">
|
<ng-container *ngIf="store$ | async as store; else loading">
|
||||||
<marketplace-categories
|
<marketplace-categories
|
||||||
[categories]="store.categories"
|
[categories]="store.categories"
|
||||||
[category]="category"
|
[category]="query ? '' : category"
|
||||||
[disableCategories]="!!query"
|
|
||||||
(categoryChange)="onCategoryChange($event)"
|
(categoryChange)="onCategoryChange($event)"
|
||||||
></marketplace-categories>
|
></marketplace-categories>
|
||||||
|
|
||||||
@@ -48,22 +47,30 @@
|
|||||||
<ion-grid
|
<ion-grid
|
||||||
*ngIf="store.packages | filterPackages: query:category as filtered"
|
*ngIf="store.packages | filterPackages: query:category as filtered"
|
||||||
>
|
>
|
||||||
<ion-row *ngIf="localPkgs$ | async as localPkgs">
|
<ng-container *ngIf="filtered.length; else empty">
|
||||||
<ion-col
|
<ion-row *ngIf="localPkgs$ | async as localPkgs">
|
||||||
*ngFor="let pkg of filtered"
|
<ion-col
|
||||||
sizeXs="12"
|
*ngFor="let pkg of filtered"
|
||||||
sizeSm="12"
|
sizeXs="12"
|
||||||
sizeMd="6"
|
sizeSm="12"
|
||||||
>
|
sizeMd="6"
|
||||||
<marketplace-item [pkg]="pkg">
|
>
|
||||||
<marketplace-status
|
<marketplace-item [pkg]="pkg">
|
||||||
class="status"
|
<marketplace-status
|
||||||
[version]="pkg.manifest.version"
|
class="status"
|
||||||
[localPkg]="localPkgs[pkg.manifest.id]"
|
[version]="pkg.manifest.version"
|
||||||
></marketplace-status>
|
[localPkg]="localPkgs[pkg.manifest.id]"
|
||||||
</marketplace-item>
|
></marketplace-status>
|
||||||
</ion-col>
|
</marketplace-item>
|
||||||
</ion-row>
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-template #empty>
|
||||||
|
<div class="ion-padding">
|
||||||
|
<h2>No results</h2>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
</ion-grid>
|
</ion-grid>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user