Skip to content

Commit

Permalink
updated apis when MDS is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy committed Aug 30, 2024
1 parent 2433e06 commit 3817694
Showing 1 changed file with 48 additions and 6 deletions.
54 changes: 48 additions & 6 deletions public/components/notebooks/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,28 +357,70 @@ export class Main extends React.Component<MainProps, MainState> {
query: {
type: 'visualization',
search_fields: 'title',
search: `[Logs] Response Codes Over Time + Annotations_${dataSourceMDSLabel}`,
search:
`[Logs] Response Codes Over Time + Annotations` +
(dataSourceMDSLabel ? `_${dataSourceMDSLabel}` : ''),
},
})
.then((resp) => visIds.push(resp.saved_objects[0].id));
.then((resp) => {
if (this.props.dataSourceEnabled) {
const searchTitle = `[Logs] Response Codes Over Time + Annotations_${dataSourceMDSLabel}`;
const savedObjects = resp.saved_objects;

const foundObject = savedObjects.find((obj) => obj.attributes.title === searchTitle);
if (foundObject) {
visIds.push(foundObject.id);
}
} else {
visIds.push(resp.saved_objects[0].id);
}
});
await this.props.http
.get('../api/saved_objects/_find', {
query: {
type: 'visualization',
search_fields: 'title',
search: `[Logs] Unique Visitors vs. Average Bytes_${dataSourceMDSLabel}`,
search:
`[Logs] Unique Visitors vs. Average Bytes` +
(dataSourceMDSLabel ? `_${dataSourceMDSLabel}` : ''),
},
})
.then((resp) => visIds.push(resp.saved_objects[0].id));
.then((resp) => {
if (this.props.dataSourceEnabled) {
const searchTitle = `[Logs] Unique Visitors vs. Average Bytes_${dataSourceMDSLabel}`;
const savedObjects = resp.saved_objects;

const foundObject = savedObjects.find((obj) => obj.attributes.title === searchTitle);
if (foundObject) {
visIds.push(foundObject.id);
}
} else {
visIds.push(resp.saved_objects[0].id);
}
});
await this.props.http
.get('../api/saved_objects/_find', {
query: {
type: 'visualization',
search_fields: 'title',
search: `[Flights] Flight Count and Average Ticket Price_${dataSourceMDSLabel}`,
search:
`[Flights] Flight Count and Average Ticket Price` +
(dataSourceMDSLabel ? `_${dataSourceMDSLabel}` : ''),
},
})
.then((resp) => visIds.push(resp.saved_objects[0].id));
.then((resp) => {
if (this.props.dataSourceEnabled) {
const searchTitle = `[Flights] Flight Count and Average Ticket Price_${dataSourceMDSLabel}`;
const savedObjects = resp.saved_objects;

const foundObject = savedObjects.find((obj) => obj.attributes.title === searchTitle);
if (foundObject) {
visIds.push(foundObject.id);
}
} else {
visIds.push(resp.saved_objects[0].id);
}
});
await this.props.http
.post(`${NOTEBOOKS_API_PREFIX}/note/savedNotebook/addSampleNotebooks`, {
body: JSON.stringify({ visIds }),
Expand Down

0 comments on commit 3817694

Please sign in to comment.