소스 검색

feat(admin): Deleting org from orgs list now works, will permanently delete dashboards, data sources, etc, closes #2457

Torkel Ödegaard 10 년 전
부모
커밋
8fcaa4997d
5개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      pkg/api/api.go
  2. 8 0
      pkg/api/org.go
  3. 1 0
      pkg/services/sqlstore/org.go
  4. 1 0
      public/app/features/admin/adminListOrgsCtrl.js
  5. 1 1
      public/app/features/admin/partials/users.html

+ 1 - 0
pkg/api/api.go

@@ -113,6 +113,7 @@ func Register(r *macaron.Macaron) {
 		r.Group("/orgs/:orgId", func() {
 			r.Get("/", wrap(GetOrgById))
 			r.Put("/", bind(m.UpdateOrgCommand{}), wrap(UpdateOrg))
+			r.Delete("/", wrap(DeleteOrgById))
 			r.Get("/users", wrap(GetOrgUsers))
 			r.Post("/users", bind(m.AddOrgUserCommand{}), wrap(AddOrgUser))
 			r.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), wrap(UpdateOrgUser))

+ 8 - 0
pkg/api/org.go

@@ -77,6 +77,14 @@ func updateOrgHelper(cmd m.UpdateOrgCommand) Response {
 	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 {
 	query := m.SearchOrgsQuery{
 		Query: c.Query("query"),

+ 1 - 0
pkg/services/sqlstore/org.go

@@ -130,6 +130,7 @@ func DeleteOrg(cmd *m.DeleteOrgCommand) error {
 			"DELETE FROM data_source WHERE org_id = ?",
 			"DELETE FROM org_user WHERE org_id = ?",
 			"DELETE FROM org WHERE id = ?",
+			"DELETE FROM temp_user WHERE org_id = ?",
 		}
 
 		for _, sql := range deletes {

+ 1 - 0
public/app/features/admin/adminListOrgsCtrl.js

@@ -21,6 +21,7 @@ function (angular) {
     $scope.deleteOrg = function(org) {
       $scope.appEvent('confirm-modal', {
         title: 'Do you want to delete organization ' + org.name + '?',
+        text: 'All dashboards for this organization will be removed!',
         icon: 'fa-trash',
         yesText: 'Delete',
         onConfirm: function() {

+ 1 - 1
public/app/features/admin/partials/users.html

@@ -1,6 +1,6 @@
 <topnav icon="fa fa-fw fa-user" title="Global Users" subnav="true">
 	<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>
 	</ul>
 </topnav>