Permalink
Browse files

Fixing bug with saving dashboards with new names

  • Loading branch information...
Mark Troyer
Mark Troyer committed Nov 19, 2014
1 parent 9e607c2 commit 2b5793811615386df00547bfb7059d4767e87b98
Showing with 22 additions and 12 deletions.
  1. +2 −2 app/templates/dashboard_js.twig
  2. +20 −10 src/StatusWolf/Controllers/ApiDashboardController.php
@@ -641,7 +641,7 @@
$.magnificPopup.close();
}).on('click', '#save-new-dashboard-button', function() {
query_data.dashboard_config.id = md5('dashboard' + document._session.dashboard_username + new Date.now().getTime());
save_dashboard_handler(event, true, query_data.dashboard_config.id);
save_dashboard_handler(event, 0, query_data.dashboard_config.id);
}).on('click', '#confirm-dashboard-save-button', function() {
save_dashboard_handler(event, true, query_data.dashboard_config.id);
});
@@ -769,4 +769,4 @@
</script>
{% endautoescape %}
{% endautoescape %}
@@ -97,18 +97,28 @@ public function connect(Application $sw) {
}
try {
$sw['db']->executeUpdate("REPLACE INTO saved_dashboards VALUES(?, ?, ?, ?, ?, ?)",
array(
$query_data['id'],
$query_data['title'],
$query_data['columns'],
$query_data['user_id'],
$query_data['shared'],
$widgets_string
)
);
if ($new_dashboard) {
$sw['db']->executeUpdate("INSERT INTO saved_dashboards VALUES(?, ?, ?, ?, ?, ?)",
array(
$query_data['id'],
$query_data['title'],
$query_data['columns'],
$query_data['user_id'],
$query_data['shared'],
$widgets_string
)
);
$sw['db']->executeUpdate("INSERT INTO dashboard_rank VALUES(?, 0)", array($query_data['id']));
} else {
$sql = "UPDATE saved_dashboards SET title = ?, columns = ?, user_id = ?, shared = ?, widgets = ? WHERE id = ?";
$update_dashboard_query = $sw['db']->prepare($sql);
$update_dashboard_query->bindValue(1, $query_data['title']);
$update_dashboard_query->bindValue(2, $query_data['columns']);
$update_dashboard_query->bindValue(3, $query_data['user_id']);
$update_dashboard_query->bindValue(4, $query_data['shared']);
$update_dashboard_query->bindValue(5, $widgets_string);
$update_dashboard_query->bindValue(6, $query_data['id']);
$update_dashboard_query->execute();
}
return $sw->json(array('query_result' => 'Success'));
} catch(\PDOException $e) {

0 comments on commit 2b57938

Please sign in to comment.