                   ^{:key name}
                   [:li {:class (if (= tb @selected) "selected" "") :tabIndex 101
                         :on-click #(reset! selected tb)
-                        :on-double-click #((:preview-table ops) name)}
+                        :on-double-click #(.preview ops name)}
                    [:i.fa {:class (icons type)}] name]))]]])))
 
 (defn code-mirror [instance config]

       [:div.panel-footer]])))


(defn db-console-ops [data-tabs active-tab]
  (let [q-id (atom 1)]
    {:preview-table
     (fn[tbl]
       (when-not (some #(= tbl (:id %)) @data-tabs)
         (.log js/console "adding table " tbl)
         (swap! data-tabs conj {:id tbl :raw-sql (str "select * from " tbl)}))
       (reset! active-tab tbl))
     :exec-sql
     (fn[sql]
       (let [id (str "Query #" (swap! q-id inc))]
         (swap! data-tabs conj {:id id :raw-sql sql})
         (reset! active-tab id)))
     :delete-tab
     (fn[t]
       (swap! data-tabs (partial remove #(= t %)))
       (if (= (:id t) @active-tab)
         (reset! active-tab (:id (first @data-tabs)))))}))

(defn db-console [db active?]
  (let [active-tab (atom nil)
        data-tabs (atom [])
        ops (db-console-ops data-tabs active-tab)]
    (fn[db active?]
      [st/horizontal-splitter {:split-at 240}
       [db-objects db ops active?]

    (fn [db ops active?]
      (when active?
        (doto js/Mousetrap
          (.bind "alt+d" #(.preview ops (@selected "name")))
          (.bind "/" #(swap! search? not))
          (.bind "esc" #(reset! search? false))))
      [:div.full-height.panel.panel-default
