Skip to content

Commit

Permalink
Fixing bug with saving dashboards with new names
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Troyer committed Nov 19, 2014
1 parent 9e607c2 commit 2b57938
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/templates/dashboard_js.twig
Expand Up @@ -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);
});
Expand Down Expand Up @@ -769,4 +769,4 @@
</script>

{% endautoescape %}
{% endautoescape %}
30 changes: 20 additions & 10 deletions src/StatusWolf/Controllers/ApiDashboardController.php
Expand Up @@ -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) {
Expand Down

0 comments on commit 2b57938

Please sign in to comment.