Skip to content

Commit

Permalink
opensearch-project#416: Filter panels from app analytics
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Lee <eugenesk@amazon.com>
  • Loading branch information
eugenesk24 committed Jan 31, 2022
1 parent ca4399d commit 86235b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions dashboards-observability/common/types/custom_panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type CustomPanelListType = {
id: string;
dateCreated: number;
dateModified: number;
applicationId?: string;
};

export type VisualizationType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OBSERVABILITY_BASE,
SAVED_OBJECTS,
} from '../../../common/constants/shared';
import { CustomPanelListType } from '../../../common/types/custom_panels';
import { CustomPanelListType, PanelType } from '../../../common/types/custom_panels';
import { ObservabilitySideBar } from '../common/side_nav';
import { CustomPanelTable } from './custom_panel_table';
import { CustomPanelView } from './custom_panel_view';
Expand Down Expand Up @@ -62,7 +62,9 @@ export const Home = ({ http, chrome, parentBreadcrumb, pplService, renderProps }
http
.get(`${CUSTOM_PANELS_API_PREFIX}/panels`)
.then((res) => {
setcustomPanelData(res.panels);
// Filter out panels that do not have applicationId field
const nonAppPanels = res.panels.filter((p: PanelType) => !p.applicationId);
setcustomPanelData(nonAppPanels);
})
.catch((err) => {
console.error('Issue in fetching the operational panels', err.body.message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { v4 as uuidv4 } from 'uuid';
import { PanelType, VisualizationType } from '../../../common/types/custom_panels';
import { CustomPanelListType, PanelType, VisualizationType } from '../../../common/types/custom_panels';
import { ILegacyScopedClusterClient } from '../../../../../src/core/server';
import { createDemoPanel } from '../../common/helpers/custom_panels/sample_panels';

Expand Down Expand Up @@ -71,12 +71,20 @@ export class CustomPanelsAdaptor {
objectType: 'operationalPanel',
maxItems: 10000,
});
return response.observabilityObjectList.map((panel: any) => ({
name: panel.operationalPanel.name,
id: panel.objectId,
dateCreated: panel.createdTimeMs,
dateModified: panel.lastUpdatedTimeMs,
}));
var panelList: any[] = [];
for (const panel of response.observabilityObjectList) {
var object: CustomPanelListType = {
name: panel.operationalPanel.name,
id: panel.objectId,
dateCreated: panel.createdTimeMs,
dateModified: panel.lastUpdatedTimeMs
}
if (panel.operationalPanel.applicationId) {
object.applicationId = panel.operationalPanel.applicationId;
}
panelList.push(object);
}
return panelList;
} catch (error) {
throw new Error('View Panel List Error:' + error);
}
Expand Down

0 comments on commit 86235b5

Please sign in to comment.