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 340577076c
commit 4ba012ab8e
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 var searchHandler chartSearchHandler
// SearchAPI handles requesst to /api/search // SearchAPI handles request to /api/search
type SearchAPI struct { type SearchAPI struct {
BaseController BaseController
} }
@ -41,7 +41,7 @@ type SearchAPI struct {
type searchResult struct { type searchResult struct {
Project []*models.Project `json:"project"` Project []*models.Project `json:"project"`
Repository []map[string]interface{} `json:"repository"` Repository []map[string]interface{} `json:"repository"`
Chart []*search.Result Chart []*search.Result `json:"chart,omitempty"`
} }
// Get ... // Get ...

View File

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

View File

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