mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +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
@@ -2,7 +2,7 @@
|
||||
*ngFor="let cat of categories"
|
||||
fill="clear"
|
||||
class="category"
|
||||
[class.category_selected]="cat === category && !disableCategories"
|
||||
[class.category_selected]="cat === category"
|
||||
(click)="switchCategory(cat)"
|
||||
>
|
||||
{{ cat }}
|
||||
|
||||
@@ -22,9 +22,6 @@ export class CategoriesComponent {
|
||||
@Input()
|
||||
category = ''
|
||||
|
||||
@Input()
|
||||
disableCategories = false
|
||||
|
||||
@Output()
|
||||
readonly categoryChange = new EventEmitter<string>()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { NgModule, Pipe, PipeTransform } from '@angular/core'
|
||||
import { Emver } from '@start9labs/shared'
|
||||
import { MarketplacePkg } from '../types'
|
||||
import Fuse from 'fuse.js'
|
||||
|
||||
@@ -7,8 +6,6 @@ import Fuse from 'fuse.js'
|
||||
name: 'filterPackages',
|
||||
})
|
||||
export class FilterPackagesPipe implements PipeTransform {
|
||||
constructor(private readonly emver: Emver) {}
|
||||
|
||||
transform(
|
||||
packages: MarketplacePkg[],
|
||||
query: string,
|
||||
@@ -19,29 +16,51 @@ export class FilterPackagesPipe implements PipeTransform {
|
||||
let options: Fuse.IFuseOptions<MarketplacePkg> = {
|
||||
includeScore: 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)
|
||||
return fuse.search(query).map(p => p.item)
|
||||
|
||||
Reference in New Issue
Block a user