Просмотр исходного кода

WIP: add new group, needs to be redone

Daniel Lee 8 лет назад
Родитель
Сommit
00ac446b2b

+ 11 - 4
public/app/features/org/partials/user_groups.html

@@ -6,10 +6,17 @@
 		<h1>User Groups</h1>
 
     <div class="page-header-tabs">
-      <a class="btn btn-success" href="/org/user-groups/create">
-        <i class="fa fa-plus"></i>
-          Create User Group
-      </a>
+      <form name="addTokenForm" class="gf-form-group">
+        <div class="gf-form-inline">
+          <div class="gf-form max-width-21">
+            <span class="gf-form-label">Create a User Group</span>
+            <input type="text" class="gf-form-input" ng-model='ctrl.userGroupName' placeholder="Name"></input>
+          </div>
+          <div class="gf-form">
+            <button class="btn gf-form-btn btn-success" ng-click="ctrl.createUserGroup()">Create</button>
+          </div>
+        </div>
+      </form>
     </div>
   </div>
   <div class="search-field-wrapper pull-right width-18">

+ 8 - 10
public/app/features/org/user_groups_ctrl.ts

@@ -10,6 +10,7 @@ export default class UserGroupsCtrl {
   totalPages: number;
   showPaging = false;
   query: any = '';
+  userGroupName: any = '';
 
   /** @ngInject */
   constructor(private $scope, private $http, private backendSrv) {
@@ -37,6 +38,13 @@ export default class UserGroupsCtrl {
     this.get();
   }
 
+  createUserGroup() {
+    this.backendSrv.post('/api/user-groups', {name: this.userGroupName}).then(result => {
+      this.get();
+      this.userGroupName = '';
+    });
+  }
+
   deleteUserGroup(userGroup) {
     this.$scope.appEvent('confirm-modal', {
       title: 'Delete',
@@ -53,16 +61,6 @@ export default class UserGroupsCtrl {
     this.backendSrv.delete('/api/user-groups/' + userGroup.id)
       .then(this.get.bind(this));
   }
-
-  openUserGroupModal() {
-    var modalScope = this.$scope.$new();
-
-    this.$scope.appEvent('show-modal', {
-      src: 'public/app/features/org/partials/add_user.html',
-      modalClass: 'user-group-modal',
-      scope: modalScope
-    });
-  }
 }
 
 coreModule.controller('UserGroupsCtrl', UserGroupsCtrl);