Skip to content
Snippets Groups Projects
Commit 551f78f9 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

rounding out a few things. now have all persistent functions for cards &...

rounding out a few things.  now have all persistent functions for cards & dashboards publishing activity events.
parent f4c5ed13
No related branches found
No related tags found
No related merge requests found
......@@ -39,8 +39,10 @@
"The `Set` of topics which are subscribed to and included in the Metabase published activity feed."
#{:card-create
:card-update
:card-delete
:dashboard-create
:dashboard-update
:dashboard-delete
:dashboard-add-cards
:dashboard-remove-cards
:dashboard-reposition-cards})
......
......@@ -88,22 +88,23 @@
public_perms PublicPerms
display CardDisplayType}
(write-check Card id)
(->> (upd-non-nil-keys Card id
:dataset_query dataset_query
:description description
:display display
:name name
:public_perms public_perms
:visualization_settings visualization_settings)
(activity/publish-activity :card-update))
;; TODO - have revision stuff work using activity framework and then we can remove this call
(upd-non-nil-keys Card id
:dataset_query dataset_query
:description description
:display display
:name name
:public_perms public_perms
:visualization_settings visualization_settings)
(activity/publish-activity :card-update {:id id :actor_id *current-user-id*})
(push-revision :entity Card, :object (Card id)))
(defendpoint DELETE "/:id"
"Delete a `Card`."
[id]
(write-check Card id)
(cascade-delete Card :id id))
(let [result (cascade-delete Card :id id)]
(activity/publish-activity :card-delete {:id id :actor_id *current-user-id*})
result))
(defendpoint GET "/:id/favorite"
"Has current user favorited this `Card`?"
......
......@@ -2,6 +2,7 @@
"/api/dash endpoints."
(:require [compojure.core :refer [GET POST PUT DELETE]]
[korma.core :as k]
[metabase.activity :as activity]
[metabase.api.common :refer :all]
[metabase.db :refer :all]
(metabase.models [hydrate :refer [hydrate]]
......@@ -29,11 +30,12 @@
[:as {{:keys [name description public_perms] :as body} :body}]
{name [Required NonEmptyString]
public_perms [Required PublicPerms]}
(ins Dashboard
:name name
:description description
:public_perms public_perms
:creator_id *current-user-id*))
(->> (ins Dashboard
:name name
:description description
:public_perms public_perms
:creator_id *current-user-id*)
(activity/publish-activity :dashboard-create)))
(defendpoint GET "/:id"
"Get `Dashboard` with ID."
......@@ -52,13 +54,16 @@
:description description
:name name
:public_perms public_perms))
(activity/publish-activity :dashboard-update {:id id :actor_id *current-user-id*})
(push-revision :entity Dashboard, :object (Dashboard id)))
(defendpoint DELETE "/:id"
"Delete a `Dashboard`."
[id]
(write-check Dashboard id)
(cascade-delete Dashboard :id id))
(let [result (cascade-delete Dashboard :id id)]
(activity/publish-activity :dashboard-delete {:id id :actor_id *current-user-id*})
result))
(defendpoint POST "/:id/cards"
"Add a `Card` to a `Dashboard`."
......@@ -67,6 +72,7 @@
(write-check Dashboard id)
(check-400 (exists? Card :id cardId))
(let [result (ins DashboardCard :card_id cardId :dashboard_id id)]
(activity/publish-activity :dashboard-add-cards (merge {:actor_id *current-user-id*} result))
(push-revision :entity Dashboard, :object (Dashboard id))
result))
......@@ -76,6 +82,7 @@
{dashcardId [Required String->Integer]}
(write-check Dashboard id)
(let [result (del DashboardCard :id dashcardId :dashboard_id id)]
(activity/publish-activity :dashboard-remove-cards {:id dashcardId :dashboard_id id :actor_id *current-user-id*})
(push-revision :entity Dashboard, :object (Dashboard id))
result))
......@@ -94,6 +101,7 @@
(let [dashcard (sel :one [DashboardCard :id] :id dashcard-id :dashboard_id id)]
(when dashcard
(upd DashboardCard dashcard-id :sizeX sizeX :sizeY sizeY :row row :col col))))
(activity/publish-activity :dashboard-reposition-cards {:dashboard_id id :actor_id *current-user-id* :cards cards})
(push-revision :entity Dashboard, :object (Dashboard id))
{:status :ok})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment