<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<div class="container">
  <div class="row" style="margin-top:15px;" ng-if="!allowUseUserAndGroupModule">User management does not apply to the current security configuration, go to the correct permissions management page for editing.</div>
  <div class="row" style="margin-top:15px;" ng-if="allowUseUserAndGroupModule">
    
    <!--No Instances-->
    <div ng-if="!grouploading && groupsTotal == 0">
      <div no-result text="No user group"></div>
    </div>
    <!--Loading Instances-->
    <div ng-if="grouploading">
      <loading text="Loading user group ..."></loading>
    </div>
    <div class="row">
      <div class="col-xs-9">
        <label class="table-header-text">Group List</label>
      </div>
      <div class="col-xs-3">
      <form style="float:right;" >
          <span class="input-icon input-icon-right nav-search">
            <input type="text" placeholder="Search by group name" class="nav-search-input" ng-model="filter.name" />
            <i class="ace-icon fa fa-search blue" ng-click="listGroups();"></i>
          </span>
      </form>
      </div>
    </div>
    <button class="btn btn-primary btn-sm" ng-click="createGroup()"><i class="fa fa-plus"></i> Group</button>
    <!--Queries Table Content-->
    <table ng-if="groupsTotal > 0" style="margin-top:20px;table-layout:fixed;" class="table table-striped table-bordered table-hover dataTable no-footer">
      <thead>
      <tr style="cursor: pointer">
        <th width="7%">
          ID
        </th>
        <th>
          Group Name
        </th>
        <th>
          User Count
        </th>
        <th width="17%">
          Actions
        </th>
      </tr>
      </thead>
      <tbody class="odd table table-striped table-bordered table-hover dataTable no-footer">
      <tr ng-repeat="(group, value) in groups" style="cursor: pointer">
        <td>
          {{$index+1 + page.limit * (page.curpage - 1)}}
        </td>
        <td>
          {{group}}
        </td>
        <td>
          <a ng-click="showUserListByGroup(group)">{{value.length}}</a>
        </td>
        <td>
          <button type="button" tooltip="Add user to group" class="btn btn-default btn-xs" ng-if="group!=='ALL_USERS'" ng-click="assignToUser(group)">
            <i class="fa fa-user-plus fa-fw"></i>
          </button>
          <button type="button" tooltip="Delete group" ng-if="group!=='ROLE_ADMIN' && group!=='ALL_USERS'" class="btn btn-default btn-xs" ng-click="delGroup(group)">
            <i class="fa fa-trash-o  fa-fw"></i>
          </button>
        </td>
      </tr>
      </tbody>
    </table>
    <div class="row">
      <div class="col-xs-12">
          <pagination total-items="groupsTotal" boundary-link-numbers="true" rotate="false" boundary-links="true" force-ellipses="true" page="page.curpage" max-size="10" items-per-page="page.limit" on-select-page="listGroups(page)"  class="pagination-sm"></pagination>
      </div>
    </div>
  </div>
</div>

<div ng-include="'partials/admin/group_create.html'"></div>
<div ng-include="'partials/admin/user_assign.html'"></div>
