Commit 8fcaa499 by Torkel Ödegaard

feat(admin): Deleting org from orgs list now works, will permanently delete…

feat(admin): Deleting org from orgs list now works, will permanently delete dashboards, data sources, etc, closes #2457
parent 7370af9a
...@@ -113,6 +113,7 @@ func Register(r *macaron.Macaron) { ...@@ -113,6 +113,7 @@ func Register(r *macaron.Macaron) {
r.Group("/orgs/:orgId", func() { r.Group("/orgs/:orgId", func() {
r.Get("/", wrap(GetOrgById)) r.Get("/", wrap(GetOrgById))
r.Put("/", bind(m.UpdateOrgCommand{}), wrap(UpdateOrg)) r.Put("/", bind(m.UpdateOrgCommand{}), wrap(UpdateOrg))
r.Delete("/", wrap(DeleteOrgById))
r.Get("/users", wrap(GetOrgUsers)) r.Get("/users", wrap(GetOrgUsers))
r.Post("/users", bind(m.AddOrgUserCommand{}), wrap(AddOrgUser)) r.Post("/users", bind(m.AddOrgUserCommand{}), wrap(AddOrgUser))
r.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), wrap(UpdateOrgUser)) r.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), wrap(UpdateOrgUser))
......
...@@ -77,6 +77,14 @@ func updateOrgHelper(cmd m.UpdateOrgCommand) Response { ...@@ -77,6 +77,14 @@ func updateOrgHelper(cmd m.UpdateOrgCommand) Response {
return ApiSuccess("Organization updated") return ApiSuccess("Organization updated")
} }
// GET /api/orgs/:orgId
func DeleteOrgById(c *middleware.Context) Response {
if err := bus.Dispatch(&m.DeleteOrgCommand{Id: c.ParamsInt64(":orgId")}); err != nil {
return ApiError(500, "Failed to update organization", err)
}
return ApiSuccess("Organization deleted")
}
func SearchOrgs(c *middleware.Context) Response { func SearchOrgs(c *middleware.Context) Response {
query := m.SearchOrgsQuery{ query := m.SearchOrgsQuery{
Query: c.Query("query"), Query: c.Query("query"),
......
...@@ -130,6 +130,7 @@ func DeleteOrg(cmd *m.DeleteOrgCommand) error { ...@@ -130,6 +130,7 @@ func DeleteOrg(cmd *m.DeleteOrgCommand) error {
"DELETE FROM data_source WHERE org_id = ?", "DELETE FROM data_source WHERE org_id = ?",
"DELETE FROM org_user WHERE org_id = ?", "DELETE FROM org_user WHERE org_id = ?",
"DELETE FROM org WHERE id = ?", "DELETE FROM org WHERE id = ?",
"DELETE FROM temp_user WHERE org_id = ?",
} }
for _, sql := range deletes { for _, sql := range deletes {
......
...@@ -21,6 +21,7 @@ function (angular) { ...@@ -21,6 +21,7 @@ function (angular) {
$scope.deleteOrg = function(org) { $scope.deleteOrg = function(org) {
$scope.appEvent('confirm-modal', { $scope.appEvent('confirm-modal', {
title: 'Do you want to delete organization ' + org.name + '?', title: 'Do you want to delete organization ' + org.name + '?',
text: 'All dashboards for this organization will be removed!',
icon: 'fa-trash', icon: 'fa-trash',
yesText: 'Delete', yesText: 'Delete',
onConfirm: function() { onConfirm: function() {
......
<topnav icon="fa fa-fw fa-user" title="Global Users" subnav="true"> <topnav icon="fa fa-fw fa-user" title="Global Users" subnav="true">
<ul class="nav"> <ul class="nav">
<li class="active"><a href="admin/users">Overview</a></li> <li class="active"><a href="admin/users">List</a></li>
<li><a href="admin/users/create">Create user</a></li> <li><a href="admin/users/create">Create user</a></li>
</ul> </ul>
</topnav> </topnav>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment