Fix: global search not work issue

Both Frontend and Backend should not send chart data when chartmusuem not enabled

Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
Qian Deng 2019-03-04 10:47:54 +08:00
parent ad47646987
commit 5add671797
3 changed files with 10 additions and 5 deletions

View File

@ -33,7 +33,7 @@ type chartSearchHandler func(string, []string) ([]*search.Result, error)
var searchHandler chartSearchHandler
// SearchAPI handles requesst to /api/search
// SearchAPI handles request to /api/search
type SearchAPI struct {
BaseController
}
@ -41,7 +41,7 @@ type SearchAPI struct {
type searchResult struct {
Project []*models.Project `json:"project"`
Repository []map[string]interface{} `json:"repository"`
Chart []*search.Result
Chart []*search.Result `json:"chart,omitempty"`
}
// Get ...

View File

@ -78,7 +78,9 @@ export class SearchResultComponent implements OnInit, OnDestroy {
if (src) {
src.project.forEach(pro => res.project.push(Object.assign({}, pro)));
src.repository.forEach(repo => res.repository.push(Object.assign({}, repo)));
src.Chart.forEach(chart => res.Chart.push(JSON.parse(JSON.stringify(chart))));
if (this.withHelmChart) {
src.chart.forEach(chart => res.chart.push(JSON.parse(JSON.stringify(chart))));
}
return res;
}
@ -129,6 +131,9 @@ export class SearchResultComponent implements OnInit, OnDestroy {
if (term === "") {
this.searchResults.project = [];
this.searchResults.repository = [];
if (this.withHelmChart) {
this.searchResults.chart = [];
}
return;
}
// Show spinner

View File

@ -18,10 +18,10 @@ export class SearchResults {
constructor() {
this.project = [];
this.repository = [];
this.Chart = [];
this.chart = [];
}
project: Project[];
repository: Repository[];
Chart: HelmChartSearchResultItem[];
chart: HelmChartSearchResultItem[];
}