Track settings changes.

This commit is contained in:
Paulo Reis 2016-07-05 15:37:13 +01:00
parent 304529754d
commit 96f6603bd3

View file

@ -1,19 +1,37 @@
define [
"base"
], (App) ->
App.factory "settings", ["ide", (ide) ->
App.factory "settings", ["ide", "event_tracking", (ide, event_tracking) ->
return {
saveSettings: (data) ->
for key in Object.keys(data)
changedSetting = key
changedSettingVal = data[key]
event_tracking.send "setting-changed", { changedSetting, changedSettingVal }
data._csrf = window.csrfToken
ide.$http.post "/user/settings", data
saveProjectSettings: (data) ->
for key in Object.keys(data)
changedSetting = key
changedSettingVal = data[key]
event_tracking.send "project-setting-changed", { changedSetting, changedSettingVal}
data._csrf = window.csrfToken
ide.$http.post "/project/#{ide.project_id}/settings", data
saveProjectAdminSettings: (data) ->
for key in Object.keys(data)
changedSetting = key
changedSettingVal = data[key]
event_tracking.send "project-admin-setting-changed", { changedSetting, changedSettingVal }
data._csrf = window.csrfToken
ide.$http.post "/project/#{ide.project_id}/settings/admin", data
}
]