Commit 435d0f22 by bergquist

fix(dashlist): better handling of invalid dashboard ids

parent dc2738af
...@@ -150,7 +150,7 @@ func SearchDashboards(query *search.FindPersistedDashboardsQuery) error { ...@@ -150,7 +150,7 @@ func SearchDashboards(query *search.FindPersistedDashboardsQuery) error {
sql.WriteString(" AND (") sql.WriteString(" AND (")
for i, dashboardId := range query.DashboardIds { for i, dashboardId := range query.DashboardIds {
if i != 0 { if i != 0 {
sql.WriteString("OR") sql.WriteString(" OR")
} }
sql.WriteString(" dashboard.id = ?") sql.WriteString(" dashboard.id = ?")
...@@ -167,6 +167,7 @@ func SearchDashboards(query *search.FindPersistedDashboardsQuery) error { ...@@ -167,6 +167,7 @@ func SearchDashboards(query *search.FindPersistedDashboardsQuery) error {
sql.WriteString(fmt.Sprintf(" ORDER BY dashboard.title ASC LIMIT 1000")) sql.WriteString(fmt.Sprintf(" ORDER BY dashboard.title ASC LIMIT 1000"))
var res []DashboardSearchProjection var res []DashboardSearchProjection
err := x.Sql(sql.String(), params...).Find(&res) err := x.Sql(sql.String(), params...).Find(&res)
if err != nil { if err != nil {
return err return err
......
...@@ -28,8 +28,15 @@ export class ImpressionsStore { ...@@ -28,8 +28,15 @@ export class ImpressionsStore {
} }
getDashboardOpened() { getDashboardOpened() {
var impressions = store.get("dashboard_impressions"); var impressions = store.get("dashboard_impressions") || "[]";
return JSON.parse(impressions || "[]");
impressions = JSON.parse(impressions);
impressions = _.filter(impressions, el => {
return _.isNumber(el);
});
return impressions;
} }
} }
......
...@@ -49,11 +49,12 @@ class DashListCtrl extends PanelCtrl { ...@@ -49,11 +49,12 @@ class DashListCtrl extends PanelCtrl {
dashboardIds: impressions.getDashboardOpened(), dashboardIds: impressions.getDashboardOpened(),
limit: this.panel.limit limit: this.panel.limit
}).then(result => { }).then(result => {
this.dashList = dashboardIds.map(orderId => { this.dashList = dashboardIds.map(orderId => {
return _.find(result, dashboard => { return _.find(result, dashboard => {
return dashboard.id === orderId; return dashboard.id === orderId;
}); });
}).filter(el => {
return el !== undefined;
}); });
this.renderingCompleted(); this.renderingCompleted();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment