This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch omnibar
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/omnibar by this push:
     new 4f456c8  setup prototype for dashbaords
4f456c8 is described below

commit 4f456c88882617ab972ecb027ea6277018b5ecff
Author: hughhhh <[email protected]>
AuthorDate: Tue Jan 22 16:38:56 2019 -0800

    setup prototype for dashbaords
---
 superset/assets/src/components/OmniContainer.jsx | 37 ++++++++----------------
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/superset/assets/src/components/OmniContainer.jsx 
b/superset/assets/src/components/OmniContainer.jsx
index 9947f0d..ffb3ca2 100644
--- a/superset/assets/src/components/OmniContainer.jsx
+++ b/superset/assets/src/components/OmniContainer.jsx
@@ -17,39 +17,26 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
-import Select from 'react-select';
 import { SupersetClient } from '@superset-ui/connection';
 
 import Omnibar from 'omnibar';
 
-function MathExtension(query) {
-  SupersetClient.get({
-      endpoint: 
'/dashboardasync/api/read?_oc_DashboardModelViewAsync=changed_on&_od_DashboardModelViewAsync=desc',
-    })
-      .then(({ json }) => {
-        console.log(json.result);
+function getDashboards(query) {
+  return SupersetClient.get({
+        endpoint: 
`/dashboardasync/api/read?_oc_DashboardModelViewAsync=changed_on&_od_DashboardModelViewAsync=desc&_flt_2_dashboard_title=${query}`,
       })
-      .catch(() => {
-        console.log('An error occurred while fethching Dashboards');
-      });
-  try {
-    return [
-      {
-        title: query,
-        subtitle: "Calculate: " + query
-      }
-    ];
-  } catch (err) {
-    return [];
-  }
+        .then(({ json }) => json.result.map(item => ({
+            title: item.dashboard_title,
+            ...item,
+          }),
+        ))
+        .catch(() => {
+          this.props.addDangerToast(t('An error occurred while fethching 
Dashboards'));
+        });
 }
 
 export default class OmniContianer extends React.Component {
   render() {
-    return <Omnibar placeholder="Enter an expression" 
extensions={[MathExtension]} />;
+    return <Omnibar placeholder="Search for dashboards.." 
extensions={[getDashboards]} />;
   }
 }
-
-OmniContianer.propTypes = {};
-OmniContianer.defaultProps = {};

Reply via email to