             [cljsjs.mousetrap]
             [ajax.core :refer [GET POST]]))
 
-(deftype ConsoleControl [data-tabs active-tab q-id]
+(deftype ConsoleControl [data-tabs active-tab q-id out-text]
   Object
   (preview [_ tbl]
     (when-not (some #(= tbl (:id %)) @data-tabs)

      (swap! data-tabs conj {:id tbl :raw-sql (str "select * from " tbl)}))
    (reset! active-tab tbl))

  (exec-sql [_ sql & opts]
    (let [id (str "Query #" (swap! q-id inc))]
      (swap! data-tabs conj (merge opts {:id id :raw-sql sql}))
      (reset! active-tab id)))

  (delete-tab [_ t]

        (fn[]
          (let [sql (if (empty? (.getSelection @cm))
                      (.getValue @cm) (.getSelection @cm))]
            (execute-query db {:raw-sql sql}
                           #(if-let [data (% "data")]
                              (.exec-sql ops sql data)
                              (.output ops (str "rows affected :" (% "rowsAffected"))))
                           #(.output ops (error-text %)))))]
    (fn[db ops]
      (when active?
        (doto js/Mousetrap
